diff options
| author | Matthias Melcher <github@matthiasm.com> | 2022-11-29 00:04:47 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2022-11-29 00:05:00 +0100 |
| commit | 8f9728d511f45c98bc505cdd4f0f8bdbc99dd1a2 (patch) | |
| tree | 1d01d2764a7ffb4bf92c1d06a0e1b10f819cd750 /fluid | |
| parent | 401b3dc008f81c11fd08d786ed251127e122860f (diff) | |
Fix -o and -h command line arg handling
Diffstat (limited to 'fluid')
| -rw-r--r-- | fluid/fluid.cxx | 24 | ||||
| -rw-r--r-- | fluid/fluid.h | 3 |
2 files changed, 21 insertions, 6 deletions
diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx index 2dc359186..0ca92ea08 100644 --- a/fluid/fluid.cxx +++ b/fluid/fluid.cxx @@ -163,6 +163,10 @@ int compile_strings = 0; // fluic -cs /// Set, if Fluid runs in batch mode, and no user interface is activated. int batch_mode = 0; // if set (-c, -u) don't open display +/// command line arguments override settings in the projectfile +Fd_String g_code_filename_arg; +Fd_String g_header_filename_arg; + /** \var int Project::header_file_set If set, commandline overrides header file name in .fl file. */ @@ -1904,23 +1908,21 @@ void update_sourceview_timer(void*) \return number of arguments used; if 0, the argument is not supported */ static int arg(int argc, char** argv, int& i) { - if (argv[i][0]!='-') + if (argv[i][0] != '-') return 0; if (argv[i][1] == 'd' && !argv[i][2]) {G_debug=1; i++; return 1;} if (argv[i][1] == 'u' && !argv[i][2]) {update_file++; batch_mode++; i++; return 1;} if (argv[i][1] == 'c' && !argv[i][2]) {compile_file++; batch_mode++; i++; return 1;} if (argv[i][1] == 'c' && argv[i][2] == 's' && !argv[i][3]) {compile_file++; compile_strings++; batch_mode++; i++; return 1;} if (argv[i][1] == 'o' && !argv[i][2] && i+1 < argc) { - P.code_file_name = argv[i+1]; - P.code_file_set = 1; + g_code_filename_arg = argv[i+1]; batch_mode++; i += 2; return 2; } if (argv[i][1] == 'h' && !argv[i][2]) { - if (i+1 < argc) { - P.header_file_name = argv[i+1]; - P.header_file_set = 1; + if ( (i+1 < argc) && (argv[i+1][0] != '-') ) { + g_header_filename_arg = argv[i+1]; batch_mode++; i += 2; return 2; @@ -2036,6 +2038,16 @@ int main(int argc,char **argv) { } undo_resume(); + // command line args override code and header filenams from the project file + if (!g_code_filename_arg.empty()) { + P.code_file_set = 1; + P.code_file_name = g_code_filename_arg; + } + if (!g_header_filename_arg.empty()) { + P.header_file_set = 1; + P.header_file_name = g_header_filename_arg; + } + if (update_file) { // fluid -u write_file(c,0); if (!compile_file) diff --git a/fluid/fluid.h b/fluid/fluid.h index ac2f8fbe6..98ed1886d 100644 --- a/fluid/fluid.h +++ b/fluid/fluid.h @@ -118,6 +118,9 @@ public: extern Project P; +extern Fd_String g_code_filename_arg; +extern Fd_String g_header_filename_arg; + // ---- public functions extern void set_filename(const char *c); |
