diff --git a/pub/lib/file_in.cpp b/pub/lib/file_in.cpp index 54d4034a2d3d97560aa9a7f5d2070928aed1e5dd..eb050a439ecf65123624eb581ecb75595c5972c4 100644 --- a/pub/lib/file_in.cpp +++ b/pub/lib/file_in.cpp @@ -590,9 +590,14 @@ void NFileIn::Load_96(FILE* F_in, string fshort) if (ival != j + 1) cout << "warning: file " << fshort << " has spectrum " << j+1 << " incorrectly numbered " << ival << "\n"; - if (!triv::freadln(F_in, &lin) || sscanf(lin.c_str(), "%i %lg", &n, &r0) != 2) + if (!triv::freadln(F_in, &lin) || sscanf(lin.substr(0,16).c_str(), "%i", &n) != 1) throw "no valid header in spectrum"; - sout->z.push_back(PObjDbl(new CObjDbl(r0))); + for (int iz=0; iz<fout->ZCo.size(); ++iz) { + if (lin.length()<=iz*16 || sscanf(lin.substr((iz+1)*16,16).c_str(), "%lg", &r0) != 1) + throw "file "+fshort+", spectrum "+S(j+1)+": no entry z"+S(iz) + +" in line '"+lin+"'"; + sout->z.push_back(PObjDbl(new CObjDbl(r0))); + } for (int i = 0; i < n; ++i) { if (!F_in || !triv::freadln(F_in, &lin)) throw "i96: failed to read data line " + S(i) + " of " + S(n); diff --git a/pub/lib/toplevel.cpp b/pub/lib/toplevel.cpp index c73cbe90662cf815950d5327d03b79b6324dd38e..da48a2f06cf1094efd50fe2ec455eb9b25ba8990 100644 --- a/pub/lib/toplevel.cpp +++ b/pub/lib/toplevel.cpp @@ -222,6 +222,13 @@ void CFrida::execute_file(const string& fnam, bool batchMode) exit(1); } throw msg; + } catch (const char* ex) { + string msg = "'" + cmdline + "':\n " + ex; + if (batchMode) { + std::cerr << msg << "\n"; + exit(1); + } + throw msg; } catch (...) { string msg = "'" + cmdline + "':\n unforeseen exception type"; if (batchMode) {