mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 14:52:46 +08:00
Fix -o and -h command line arg handling
This commit is contained in:
+17
-5
@@ -163,6 +163,10 @@ int compile_strings = 0; // fluic -cs
|
|||||||
/// Set, if Fluid runs in batch mode, and no user interface is activated.
|
/// 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
|
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
|
/** \var int Project::header_file_set
|
||||||
If set, commandline overrides header file name in .fl file.
|
If set, commandline overrides header file name in .fl file.
|
||||||
*/
|
*/
|
||||||
@@ -1911,16 +1915,14 @@ static int arg(int argc, char** argv, int& i) {
|
|||||||
if (argv[i][1] == 'c' && !argv[i][2]) {compile_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] == '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) {
|
if (argv[i][1] == 'o' && !argv[i][2] && i+1 < argc) {
|
||||||
P.code_file_name = argv[i+1];
|
g_code_filename_arg = argv[i+1];
|
||||||
P.code_file_set = 1;
|
|
||||||
batch_mode++;
|
batch_mode++;
|
||||||
i += 2;
|
i += 2;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if (argv[i][1] == 'h' && !argv[i][2]) {
|
if (argv[i][1] == 'h' && !argv[i][2]) {
|
||||||
if (i+1 < argc) {
|
if ( (i+1 < argc) && (argv[i+1][0] != '-') ) {
|
||||||
P.header_file_name = argv[i+1];
|
g_header_filename_arg = argv[i+1];
|
||||||
P.header_file_set = 1;
|
|
||||||
batch_mode++;
|
batch_mode++;
|
||||||
i += 2;
|
i += 2;
|
||||||
return 2;
|
return 2;
|
||||||
@@ -2036,6 +2038,16 @@ int main(int argc,char **argv) {
|
|||||||
}
|
}
|
||||||
undo_resume();
|
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
|
if (update_file) { // fluid -u
|
||||||
write_file(c,0);
|
write_file(c,0);
|
||||||
if (!compile_file)
|
if (!compile_file)
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ public:
|
|||||||
|
|
||||||
extern Project P;
|
extern Project P;
|
||||||
|
|
||||||
|
extern Fd_String g_code_filename_arg;
|
||||||
|
extern Fd_String g_header_filename_arg;
|
||||||
|
|
||||||
// ---- public functions
|
// ---- public functions
|
||||||
|
|
||||||
extern void set_filename(const char *c);
|
extern void set_filename(const char *c);
|
||||||
|
|||||||
Reference in New Issue
Block a user