]> www.ginac.de Git - ginac.git/blobdiff - ginac/archive.cpp
More evaluation rules: abs(x^n) => abs(x)^n (x > 0, n is real).
[ginac.git] / ginac / archive.cpp
index f4a59f735d9c51e1b5c7b2f8ce550699cfe122eb..6466834140a7e6e3a08b2ad40b5585b0646e20b4 100644 (file)
@@ -3,7 +3,7 @@
  *  Archiving of GiNaC expressions. */
 
 /*
- *  GiNaC Copyright (C) 1999-2009 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #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);