diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 1999-02-22 21:09:13 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 1999-02-22 21:09:13 +0000 |
| commit | 1bc5accffe15b5029745a502c727d7d980e94a59 (patch) | |
| tree | 3e54d4a0f35a5f665f46352a00f7fa070af4116e /test | |
| parent | 767cad1311e99e1d926fa63969058bc356b936d2 (diff) | |
Updated demo program to append d.exe or .exe to end of command name and
not the options...
git-svn-id: file:///fltk/svn/fltk/trunk@316 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
| -rw-r--r-- | test/demo.cxx | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/test/demo.cxx b/test/demo.cxx index cdd88d110..13ea3e5bf 100644 --- a/test/demo.cxx +++ b/test/demo.cxx @@ -1,5 +1,5 @@ // -// "$Id: demo.cxx,v 1.7 1999/01/07 19:17:52 mike Exp $" +// "$Id: demo.cxx,v 1.8 1999/02/22 21:09:13 mike Exp $" // // Main demo program for the Fast Light Tool Kit (FLTK). // @@ -191,31 +191,74 @@ void pop_menu() void dobut(Fl_Widget *, long arg) /* handles a button push */ { - char command[255]; int men = find_menu(stack[stsize-1]); int n = menus[men].numb; int bn = but2numb( (int) arg, n-1); if (menus[men].icommand[bn][0] == '@') push_menu(menus[men].icommand[bn]); else { + #ifdef WIN32 STARTUPINFO suInfo; // Process startup information PROCESS_INFORMATION prInfo; // Process information - + memset(&suInfo, 0, sizeof(suInfo)); suInfo.cb = sizeof(suInfo); + int icommand_length = strlen(menus[men].icommand[bn]); + + char* copy_of_icommand = new char[icommand_length+1]; + strcpy(copy_of_icommand,menus[men].icommand[bn]); + + // On WIN32 the .exe suffix needs to be appended to the command + // whilst leaving any additional parameters unchanged - this + // is required to handle the correct conversion of cases such as : + // `../fluid/fluid valuators.fl' to '../fluid/fluid.exe valuators.fl'. + + // skip leading spaces. + char* start_command = copy_of_icommand; + while(*start_command == ' ') ++start_command; + + // find the space between the command and parameters if one exists. + char* start_parameters = strchr(start_command,' '); + + char* command = new char[icommand_length+6]; // 6 for extra 'd.exe\0' + + if (start_parameters==NULL) { // no parameters required. +# ifdef _DEBUG + sprintf(command, "%sd.exe", start_command); +# else + sprintf(command, "%s.exe", start_command); +# endif // _DEBUG + } else { // parameters required. + // break the start_command at the intermediate space between + // start_command and start_parameters. + *start_parameters = 0; + // move start_paremeters to skip over the intermediate space. + ++start_parameters; + # ifdef _DEBUG - sprintf(command, "%sd.exe", menus[men].icommand[bn]); + sprintf(command, "%sd.exe %s", start_command, start_parameters); # else - sprintf(command, "%s.exe", menus[men].icommand[bn]); + sprintf(command, "%s.exe %s", start_command, start_parameters); # endif // _DEBUG + } CreateProcess(NULL, command, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &suInfo, &prInfo); -#else + + delete command; + delete copy_of_icommand; + +#else // NON WIN32 systems. + + int icommand_length = strlen(menus[men].icommand[bn]); + char* command = new char[icommand_length+5]; // 5 for extra './' and ' &\0' + sprintf(command, "./%s &", menus[men].icommand[bn]); system(command); + + delete command; #endif // WIN32 } } @@ -288,5 +331,6 @@ int main(int argc, char **argv) { } // -// End of "$Id: demo.cxx,v 1.7 1999/01/07 19:17:52 mike Exp $". +// End of "$Id: demo.cxx,v 1.8 1999/02/22 21:09:13 mike Exp $". // + |
