@@ -24,6 +24,7 @@ SOFTWARE.
2424#include " anf.hpp"
2525
2626#include < cctype>
27+ #include < cstdio>
2728#include < fstream>
2829#include < string>
2930#include < boost/lexical_cast.hpp>
@@ -66,7 +67,7 @@ bool isCharInStr(const char c, const std::string& s) {
6667 return false ;
6768}
6869
69- size_t ANF::readFileForMaxVar (const std::string& filename)
70+ size_t ANF::readFileForNumVars (const std::string& filename)
7071{
7172 // Read in the file line by line
7273 size_t maxes[26 ] = {0 };
@@ -100,9 +101,7 @@ size_t ANF::readFileForMaxVar(const std::string& filename)
100101 // At this point, only numbers are valid
101102 if (!std::isdigit (temp[i])) {
102103 var = 0 ;
103- char temp_char = temp[i];
104- if (temp_char >= ' A' && temp_char <= ' Z' )
105- temp_char += ' a' - ' A' ;
104+
106105 if (temp[i] == ' _' )
107106 continue ;
108107
@@ -122,10 +121,17 @@ size_t ANF::readFileForMaxVar(const std::string& filename)
122121 start_bracket = true ;
123122 continue ;
124123 }
125- if (isCharInStr (temp_char,var_letters)) {
126- varLetter = temp_char;
124+ tmp_char = tolower (temp[i]);
125+ if (isCharInStr (tmp_char,var_letters)) {
126+ varLetter = tmp_char;
127127 isMonomial = true ;
128128 } else {
129+ if (!isascii (temp[i])) {
130+ cout << " ERROR: Unknown character 0x" << (int )temp[i] << " (" << temp[i] << " )"
131+ << " at position " << i
132+ << " in equation: \" " << temp << " \" " << endl;
133+ exit (-1 );
134+ }
129135 isMonomial = false ;
130136 }
131137 } else if (isMonomial) {
@@ -148,7 +154,7 @@ size_t ANF::readFileForMaxVar(const std::string& filename)
148154 return maxVar+2 ;
149155}
150156
151- size_t ANF::readFile (const std::string& filename)
157+ size_t ANF::readANFFromFile (const std::string& filename)
152158{
153159 // Read in the file line by line
154160 vector<std::string> text_file;
@@ -381,9 +387,9 @@ size_t ANF::readFile(const std::string& filename)
381387
382388 // At this point, only numbers are valid
383389 if (temp[i] < ' 0' || temp[i] > ' 9' ) {
384- cout << " ERROR: Unknown character 0x" << (int )temp[i]
390+ cout << " ERROR: Unknown character 0x" << (int )temp[i] << " ( " << temp[i] << " ) "
385391 << " at position " << i
386- << " in equation: " << temp << " \" " << endl;
392+ << " in equation: \" " << temp << " \" " << endl;
387393 exit (-1 );
388394 }
389395
0 commit comments