1 |
greg |
2.1 |
#ifndef lint |
2 |
schorsch |
2.4 |
static const char RCSid[] = "$Id: fixargv0.c,v 2.3 2003/02/25 02:47:21 greg Exp $"; |
3 |
greg |
2.1 |
#endif |
4 |
|
|
/* |
5 |
|
|
* Fix argv[0] for DOS environments |
6 |
greg |
2.2 |
* |
7 |
schorsch |
2.4 |
* External symbols declared in paths.h |
8 |
greg |
2.2 |
*/ |
9 |
|
|
|
10 |
greg |
2.3 |
#include "copyright.h" |
11 |
greg |
2.1 |
|
12 |
schorsch |
2.4 |
#include <ctype.h> |
13 |
greg |
2.1 |
|
14 |
|
|
char * |
15 |
|
|
fixargv0(av0) /* extract command name from full path */ |
16 |
|
|
char *av0; |
17 |
|
|
{ |
18 |
|
|
register char *cp = av0; |
19 |
|
|
|
20 |
|
|
while (*cp) cp++; /* start from end */ |
21 |
|
|
while (cp-- > av0) |
22 |
|
|
switch (*cp) { /* fix up command name */ |
23 |
|
|
case '.': /* remove extension */ |
24 |
|
|
*cp = '\0'; |
25 |
|
|
continue; |
26 |
|
|
case '\\': /* remove directory */ |
27 |
|
|
return(cp+1); |
28 |
|
|
default: /* convert to lower case */ |
29 |
|
|
*cp = tolower(*cp); |
30 |
|
|
continue; |
31 |
|
|
} |
32 |
|
|
return(av0); |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
|