X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Farchive.cpp;h=6466834140a7e6e3a08b2ad40b5585b0646e20b4;hp=d643e68bf31166933ae5830cfaaf66f927f2761f;hb=eded9cd9d5df793c1ea5a1f766eff261ded46bde;hpb=e0f0681b814fecff5523d21b4368ebbeecc330eb diff --git a/ginac/archive.cpp b/ginac/archive.cpp index d643e68b..64668341 100644 --- a/ginac/archive.cpp +++ b/ginac/archive.cpp @@ -28,6 +28,7 @@ #include "config.h" #endif #include "tostring.h" +#include "version.h" #include #include @@ -220,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(); @@ -267,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);