From: Gonzalo A. <ga...@us...> - 2006-09-12 00:21:59
|
Update of /cvsroot/mod-c/ehtml/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2452/src Modified Files: Dictionary.cpp Log Message: Bugfix: istringstream.eof() is signalled before the actual eof. Index: Dictionary.cpp =================================================================== RCS file: /cvsroot/mod-c/ehtml/src/Dictionary.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Dictionary.cpp 8 Sep 2006 14:27:10 -0000 1.1 --- Dictionary.cpp 12 Sep 2006 00:21:56 -0000 1.2 *************** *** 55,69 **** istream& operator >> (istream& i, Dictionary& d) { char line[512]; ! while (!i.getline(line,sizeof(line)-1)) { ! istringstream l(line); ! string k, v; ! l >> k; ! if (!l); throw "Invalid input stream"; ! l >> v; ! if (!l.eof()) throw "Invalid input stream"; // should check that urldecode(k) is not present. ! d[urldecode(k).AsString()] = urldecode(v).AsString(); } return i; --- 55,76 ---- istream& operator >> (istream& i, Dictionary& d) { char line[512]; ! printf("reading session data\n"); ! while (!i.getline(line,sizeof(line)-1).eof()) { ! printf("got line %s\n", line); ! char* _k = skip_ws(line); ! char* end = skip_word(_k); ! if (!*end) throw "Invalid input stream"; ! *end++ = '\0'; ! char* _v = skip_ws(end); ! if (!*_v) throw "Invalid input stream"; + + string k(_k), v(_v); // should check that urldecode(k) is not present. ! MemBuf mk(urldecode(k)); ! MemBuf mv(urldecode(v)); ! printf("%s => %s\n", mk.AsString().c_str(), mv.AsString().c_str()); ! d[mk.AsString()] = mv.AsString(); } return i; |