@@ -67,7 +67,7 @@ class SpGnuplot
6767 void sql (size_t ln, size_t indent, const std::string& cmdline);
6868
6969 // ! Process # IMPORT-DATA commands
70- void importdata (size_t ln, size_t indent, const std::string& cmdline);
70+ int importdata (size_t ln, size_t indent, const std::string& cmdline);
7171
7272 // ! Struct to rewrite Gnuplot "plot" directives with new datafile/index pairs
7373 struct Dataset
@@ -91,7 +91,7 @@ class SpGnuplot
9191 void macro (size_t ln, size_t indent, const std::string& cmdline);
9292
9393 // ! Process TextLines
94- void process ();
94+ int process ();
9595
9696 // ! Process Textlines
9797 SpGnuplot (const std::string& filename, TextLines& lines);
@@ -105,7 +105,7 @@ void SpGnuplot::sql(size_t /* ln */, size_t /* indent */, const std::string& cmd
105105}
106106
107107// ! Process # IMPORT-DATA commands
108- void SpGnuplot::importdata (size_t /* ln */ , size_t /* indent */ , const std::string& cmdline)
108+ int SpGnuplot::importdata (size_t /* ln */ , size_t /* indent */ , const std::string& cmdline)
109109{
110110 // split argument at whitespaces
111111 std::vector<std::string> args = split_ws (cmdline);
@@ -118,7 +118,7 @@ void SpGnuplot::importdata(size_t /* ln */, size_t /* indent */, const std::stri
118118
119119 argv[args.size ()] = NULL ;
120120
121- ImportData (true ).main (args.size (), argv);
121+ return ImportData (true ).main (args.size (), argv);
122122}
123123
124124// ! Helper to rewrite Gnuplot "plot" directives with new datafile/index pairs
@@ -396,7 +396,7 @@ void SpGnuplot::macro(size_t ln, size_t indent, const std::string& cmdline)
396396}
397397
398398// ! process line-based file in place
399- void SpGnuplot::process ()
399+ int SpGnuplot::process ()
400400{
401401 // iterate over all lines
402402 for (size_t ln = 0 ; ln < m_lines.size ();)
@@ -421,7 +421,8 @@ void SpGnuplot::process()
421421 else if (first_word == " IMPORT-DATA" )
422422 {
423423 OUT (ln << " # " << cmd);
424- importdata (ln, indent, cmd);
424+ if (importdata (ln, indent, cmd) != EXIT_SUCCESS)
425+ return EXIT_FAILURE;
425426 }
426427 else if (first_word == " PLOT" )
427428 {
@@ -444,6 +445,7 @@ void SpGnuplot::process()
444445 OUT (" ? maybe unknown keyword " << first_word);
445446 }
446447 }
448+ return EXIT_SUCCESS;
447449}
448450
449451// ! process a stream
@@ -490,7 +492,8 @@ SpGnuplot::SpGnuplot(const std::string& filename, TextLines& lines)
490492 }
491493
492494 // process lines in place
493- process ();
495+ if (process () != EXIT_SUCCESS)
496+ exit (EXIT_FAILURE);
494497
495498 // verify processed output against file
496499 if (gopt_check_output)
0 commit comments