summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2016-03-05 14:40:49 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2016-03-05 14:40:49 +0000
commitb4126742f2c947d1fa01ec786b5b1b3f4ceb519a (patch)
tree6729abac47b2ccda53cc78a11b61ae5ae2dfe759
parent420408e7d35bbeb124316ef428e162a679c160a7 (diff)
Fix and simplify exe name handling in demo (Windows).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11294 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--test/demo.cxx34
1 files changed, 16 insertions, 18 deletions
diff --git a/test/demo.cxx b/test/demo.cxx
index 743acd966..7a076fc74 100644
--- a/test/demo.cxx
+++ b/test/demo.cxx
@@ -244,7 +244,13 @@ void dobut(Fl_Widget *, long arg)
#ifdef WIN32
STARTUPINFO suInfo; // Process startup information
PROCESS_INFORMATION prInfo; // Process information
-
+
+# if DEBUG_EXE_WITH_D
+ const char *exe = "d.exe"; // exe name with trailing 'd'
+# else
+ const char *exe = ".exe"; // exe name w/o trailing 'd'
+# endif
+
memset(&suInfo, 0, sizeof(suInfo));
suInfo.cb = sizeof(suInfo);
@@ -257,22 +263,18 @@ void dobut(Fl_Widget *, long arg)
// 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;
-
+ 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.
-# if DEBUG_EXE_WITH_D
- sprintf(command, "%sd.exe", start_command);
-# else
- sprintf(command, "%s.exe", start_command);
-# endif // _DEBUG
+ sprintf(command, "%s%s", start_command, exe);
} else { // parameters required.
// break the start_command at the intermediate space between
// start_command and start_parameters.
@@ -280,11 +282,7 @@ void dobut(Fl_Widget *, long arg)
// move start_paremeters to skip over the intermediate space.
++start_parameters;
-# ifdef _DEBUG
- sprintf(command, "%sd.exe %s", start_command, start_parameters);
-# else
- sprintf(command, "%s.exe %s", start_command, start_parameters);
-# endif // _DEBUG
+ sprintf(command, "%s%s %s", start_command, exe, start_parameters);
}
CreateProcess(NULL, command, NULL, NULL, FALSE,
@@ -299,8 +297,8 @@ void dobut(Fl_Widget *, long arg)
char command[2048], path[2048], app_path[2048];
- // this neat litle block of code ensures that the current directory is set
- // to the location of the Demo application.
+ // this neat little block of code ensures that the current directory
+ // is set to the location of the Demo application.
CFBundleRef app = CFBundleGetMainBundle();
CFURLRef url = CFBundleCopyBundleURL(app);
CFStringRef cc_app_path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);