]> www.ginac.de Git - ginac.git/blobdiff - ginac/archive.cpp
Add support for Texinfo-5.0.
[ginac.git] / ginac / archive.cpp
index a7152ba74a4fa38a958c1c223d2f2b296f5bff1f..6466834140a7e6e3a08b2ad40b5585b0646e20b4 100644 (file)
 #include "registrar.h"
 #include "ex.h"
 #include "lst.h"
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 #include "tostring.h"
+#include "version.h"
 
 #include <iostream>
 #include <stdexcept>
@@ -218,7 +221,7 @@ std::ostream &operator<<(std::ostream &os, const archive &ar)
        os.put('A');
        os.put('R');
        os.put('C');
-       write_unsigned(os, ARCHIVE_VERSION);
+       write_unsigned(os, GINACLIB_ARCHIVE_VERSION);
 
        // Write atoms
        unsigned num_atoms = ar.atoms.size();
@@ -265,9 +268,11 @@ std::istream &operator>>(std::istream &is, archive &ar)
        is.get(c1); is.get(c2); is.get(c3); is.get(c4);
        if (c1 != 'G' || c2 != 'A' || c3 != 'R' || c4 != 'C')
                throw (std::runtime_error("not a GiNaC archive (signature not found)"));
+       static const unsigned max_version = GINACLIB_ARCHIVE_VERSION;
+       static const unsigned min_version = GINACLIB_ARCHIVE_VERSION - GINACLIB_ARCHIVE_AGE;
        unsigned version = read_unsigned(is);
-       if (version > ARCHIVE_VERSION || version < ARCHIVE_VERSION - ARCHIVE_AGE)
-               throw (std::runtime_error("archive version " + ToString(version) + " cannot be read by this GiNaC library (which supports versions " + ToString(ARCHIVE_VERSION-ARCHIVE_AGE) + " thru " + ToString(ARCHIVE_VERSION)));
+       if ((version > max_version) || (version < min_version))
+               throw (std::runtime_error("archive version " + ToString(version) + " cannot be read by this GiNaC library (which supports versions " + ToString(min_version) + " thru " + ToString(max_version)));
 
        // Read atoms
        unsigned num_atoms = read_unsigned(is);