ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fixargv0.c
Revision: 2.10
Committed: Tue Jun 3 21:31:51 2025 UTC (3 days, 8 hours ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.9: +14 -13 lines
Log Message:
refactor: More consistent use of global char * progname and fixargv0()

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: fixargv0.c,v 2.9 2020/07/24 16:58:16 greg Exp $";
3 #endif
4 /*
5 * Fix argv[0] and assign global progname variable
6 *
7 * External symbols declared in paths.h
8 */
9
10 #include "paths.h"
11 #include <ctype.h>
12
13 char *progname = NULL; /* global argv[0] */
14
15 char *
16 fixargv0(char *av0) /* extract command name from full path */
17 {
18 char *cp = av0;
19
20 while (*cp) cp++; /* start from end */
21
22 while (cp-- > av0)
23 switch (*cp) {
24 CASEDIRSEP: /* remove directory */
25 av0 = cp+1;
26 break;
27 #if defined(_WIN32) || defined(_WIN64) /* only do for Windows: */
28 case '.': /* remove extension */
29 *cp = '\0';
30 continue;
31 default: /* convert to lower case */
32 *cp = tolower(*cp);
33 continue;
34 #endif
35 }
36 return(progname = av0);
37 }