Commit 9a393eb2 authored by sof's avatar sof

[project @ 2005-03-15 23:44:06 by sof]

[mingw only]setProgName():
  robustify by looking for the last '/' or '\\' in argv[0].
  My copy of 'gdb' likes to use a mixture of the two, which causes a
  fatal error when trying to debug libHSrts_p.a. Other process-invoking
  apps/shells might be equally wavering when it comes to the use of slashes.

Merge to STABLE.
parent 2daf9175
......@@ -2188,20 +2188,25 @@ bad_option(const char *s)
void
setProgName(char *argv[])
{
char *last_slash;
/* Remove directory from argv[0] -- default files in current directory */
if ((last_slash = (char *) strrchr(argv[0],
#if !defined(mingw32_HOST_OS)
'/'
#else
'\\'
#endif
)) != NULL) {
char *last_slash;
if ( (last_slash = (char *) strrchr(argv[0], '/')) != NULL ) {
prog_name = last_slash+1;
} else {
prog_name = argv[0];
}
#else
char* last_slash = argv[0] + (strlen(argv[0]) - 1);
while ( last_slash > argv[0] ) {
if ( *last_slash == '/' || *last_slash == '\\' ) {
prog_name = last_slash+1;
return;
}
last_slash--;
}
prog_name = argv[0];
#endif
}
void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment