Revision: | 2.5 |
Committed: | Mon Oct 27 10:19:31 2003 UTC (21 years, 6 months ago) by schorsch |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | rad4R2P2, rad5R0, rad3R7P2, rad3R7P1, rad4R2, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9, rad4R2P1 |
Changes since 2.4: | +2 -2 lines |
Log Message: | Added gethomedir.c and various compatibility fixes. |
# | User | Rev | Content |
---|---|---|---|
1 | greg | 2.1 | #ifndef lint |
2 | schorsch | 2.5 | static const char RCSid[] = "$Id: fixargv0.c,v 2.4 2003/10/21 19:19:28 schorsch 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 | schorsch | 2.5 | extern char * |
15 | greg | 2.1 | 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 |