@@ -486,30 +486,29 @@ void SpLatex::defmacro(size_t ln, size_t indent, const std::string& cmdline)
486486 {
487487 for (unsigned int col = 0 ; col < count; ++col) {
488488 if (col != 0 ) oss << std::endl;
489- oss << " \\ def \\ "
489+ oss << " \\ def\\ "
490490 << str_reduce (sql->col_name (col))
491- << " {"
491+ << " {"
492492 << reformat.format (0 , col, sql->text (0 , col))
493493 << " }" ;
494494 }
495495 }
496496
497497 std::string output = oss.str ();
498498
499- // check whether line contains an \addplot command
499+ // scan lines forward and gobble all lines containing \def commands
500500 static const boost::regex
501- re_defmacro (" [[:blank:]]*( \\\\ def \\\\ [^}]+ \\ {) [^}]+( \\ }.*) " );
501+ re_defmacro (" [[:blank:]]*\\\\ def\\\\ [^{]+ \\ {[^}]+\\ }.*" );
502502 boost::smatch rm;
503503
504- if (ln + count < m_lines.size () &&
505- boost::regex_match (m_lines[ln], rm, re_defmacro))
506- {
507- m_lines.replace (ln, ln+count, indent, output, " DEFMACRO" );
508- }
509- else
504+ size_t eln = ln;
505+ while (eln < m_lines.size () &&
506+ boost::regex_match (m_lines[eln], rm, re_defmacro))
510507 {
511- m_lines. replace (ln, ln, indent, output, " DEFMACRO " ) ;
508+ ++eln ;
512509 }
510+
511+ m_lines.replace (ln, eln, indent, output, " DEFMACRO" );
513512}
514513
515514// ! process line-based file in place
0 commit comments