Mercurial > octave-nkf
diff libgui/src/main-window.cc @ 18318:770c525a1a2b gui-release
Warn when saving/running a script whose name is not a valid identifier.
* file-editor-tab.h: rename save_file_check_spaces
* file-editor-tab.cc (check_valid_identifier): renamed save_file_check_spaces,
check if valid identifier and adapt message;
(handle_save_file_as_answer, handle_save_file_as_answer_close): use this
function
* main-window.cc (run_file_in_terminal): use the function
author | Julien Bect <julien.bect@supelec.fr> |
---|---|
date | Tue, 21 Jan 2014 18:11:50 +0100 |
parents | 024940bd5b77 |
children | dfc6ef6ac455 |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Sun Jan 19 08:25:58 2014 +0100 +++ b/libgui/src/main-window.cc Tue Jan 21 18:11:50 2014 +0100 @@ -60,6 +60,7 @@ #include "defaults.h" #include "symtab.h" #include "version.h" +#include "utils.h" static file_editor_interface * create_default_editor (QWidget *p) @@ -263,16 +264,17 @@ main_window::run_file_in_terminal (const QFileInfo& info) { QString file_name = info.canonicalFilePath (); - QString command = "run \""+file_name+"\""; + QString command = "run \"" + file_name + "\""; QString function_name = info.fileName (); function_name.chop (info.suffix ().length () + 1); - if (function_name.contains (' ')) + if (! valid_identifier (function_name.toStdString ())) { int ans = QMessageBox::question (0, tr ("Octave"), tr ("The file %1\n" - "contains spaces and can not be executed.\n\n" + "can not be executed because its name\n" + "is not a valid identifier.\n\n" "Do you want to execute\n%2\n" "instead?"). arg (file_name).arg (command),