--- ray/src/common/fixargv0.c 2016/03/19 00:44:46 2.6 +++ ray/src/common/fixargv0.c 2016/08/05 00:12:46 2.8 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: fixargv0.c,v 2.6 2016/03/19 00:44:46 schorsch Exp $"; +static const char RCSid[] = "$Id: fixargv0.c,v 2.8 2016/08/05 00:12:46 greg Exp $"; #endif /* * Fix argv[0] for DOS environments @@ -7,31 +7,29 @@ static const char RCSid[] = "$Id: fixargv0.c,v 2.6 201 * External symbols declared in paths.h */ -#include "copyright.h" - #include #include -extern char * -fixargv0(av0) /* extract command name from full path */ -char *av0; +char * +fixargv0(char *av0) /* extract command name from full path */ { - register char *cp = av0; + char *cp = av0, *end; while (*cp) cp++; /* start from end */ + end = cp; while (cp-- > av0) switch (*cp) { /* fix up command name */ case '.': /* remove extension */ *cp = '\0'; + end = cp; continue; case '\\': /* remove directory */ - strcpy(av0, cp+1); - break; + /* make sure the original pointer remains the same */ + memmove(av0, cp+1, end-cp); + return(av0); default: /* convert to lower case */ *cp = tolower(*cp); continue; } return(av0); } - -