ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fixargv0.c
Revision: 2.9
Committed: Fri Jul 24 16:58:16 2020 UTC (3 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, rad5R3, HEAD
Changes since 2.8: +2 -1 lines
Log Message:
Hopeful fix to Windows test issues

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: fixargv0.c,v 2.8 2016/08/05 00:12:46 greg Exp $";
3 #endif
4 /*
5 * Fix argv[0] for DOS environments
6 *
7 * External symbols declared in paths.h
8 */
9
10 #include <ctype.h>
11 #include <string.h>
12
13 char *
14 fixargv0(char *av0) /* extract command name from full path */
15 {
16 char *cp = av0, *end;
17
18 while (*cp) cp++; /* start from end */
19 end = cp;
20 while (cp-- > av0)
21 switch (*cp) { /* fix up command name */
22 case '.': /* remove extension */
23 *cp = '\0';
24 end = cp;
25 continue;
26 case '\\': /* remove directory */
27 case '/':
28 /* make sure the original pointer remains the same */
29 memmove(av0, cp+1, end-cp);
30 return(av0);
31 default: /* convert to lower case */
32 *cp = tolower(*cp);
33 continue;
34 }
35 return(av0);
36 }