# HG changeset patch # User Markus Mützel # Date 1581957440 -3600 # Node ID b0f94905509717e8677475ef9236b83f76f0524e # Parent 05c1217d0dae79693cea4e239ac7a2d825069023 Fix parse error when running code with single quotes with F9 (bug #57837). * libgui/src/m-editor/octave-qscintilla.cc (contextmenu_run): Escape single quotes for single quoted strings. diff -r 05c1217d0dae -r b0f949055097 libgui/src/m-editor/octave-qscintilla.cc --- a/libgui/src/m-editor/octave-qscintilla.cc Tue Feb 18 08:15:39 2020 -0800 +++ b/libgui/src/m-editor/octave-qscintilla.cc Mon Feb 17 17:37:20 2020 +0100 @@ -856,10 +856,13 @@ for (int i = 0; i < lines.count (); i++) { QString line = lines.at (i); + QString line_escaped = line; + line_escaped.replace (QString ("'"), QString ("''")); QString line_history = line; line_history.replace (QString ("\\"), QString ("\\\\")); line_history.replace (QString ("\""), QString ("\\\"")); line_history.replace (QString ("%"), QString ("%%")); + line_history.replace (QString ("'"), QString ("''")); // Prevent output of breakpoint in temp. file for keyboard QString next_bp_quiet; @@ -867,25 +870,27 @@ if (line.contains ("keyboard")) { // Define commands for not showing bp location and for resetting - // thisin case "keyboard" was within a comment + // this in case "keyboard" was within a comment next_bp_quiet = "__db_next_breakpoint_quiet__;\n"; next_bp_quiet_reset = "__db_next_breakpoint_quiet__(false);\n"; } - // Add codeline togetcher with call to echo/hitory function to tmp + // Add codeline together with call to echo/history function to tmp // %1 : function name for displaying and adding to history // %2 : line number - // %3 : command line (eval and display) + // %3 : command line with escaped single quotes (display) // %4 : command line for history (via fprintf) + // %5 : command line (eval) code += QString ("%1 (%2, '%3', '%4');\n" + next_bp_quiet - + "%3\n" + + "%5\n" + next_bp_quiet_reset + "\n") .arg (tmp_script_name) .arg (i) - .arg (line) - .arg (line_history); + .arg (line_escaped) + .arg (line_history) + .arg (line); } code += QString ("munlock (\"%1\"); clear %1;\n").arg (tmp_script_name);