ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fixargv0.c
(Generate patch)

Comparing ray/src/common/fixargv0.c (file contents):
Revision 2.7 by schorsch, Sun Mar 20 16:36:17 2016 UTC vs.
Revision 2.10 by greg, Tue Jun 3 21:31:51 2025 UTC

# Line 2 | Line 2
2   static const char       RCSid[] = "$Id$";
3   #endif
4   /*
5 < * Fix argv[0] for DOS environments
5 > * Fix argv[0] and assign global progname variable
6   *
7   *  External symbols declared in paths.h
8   */
9  
10 < #include "copyright.h"
11 <
10 > #include "paths.h"
11   #include <ctype.h>
13 #include <string.h>
12  
13 < extern char *
14 < fixargv0(av0)                   /* extract command name from full path */
15 < char  *av0;
13 > char    *progname = NULL;       /* global argv[0] */
14 >
15 > char *
16 > fixargv0(char *av0)             /* extract command name from full path */
17   {
18 <        register char  *cp = av0, *end = av0;
18 >        char  *cp = av0;
19  
20          while (*cp) cp++;               /* start from end */
21 <        end = cp;
21 >
22          while (cp-- > av0)
23 <                switch (*cp) {          /* fix up command name */
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';
27                        end = cp;
30                          continue;
29                case '\\':                      /* remove directory */
30                        /* make sure the original pointer remains the same */
31                        memmove(av0, cp+1, end-cp);
32                        break;
31                  default:                        /* convert to lower case */
32                          *cp = tolower(*cp);
33                          continue;
34 + #endif
35                  }
36 <        return(av0);
36 >        return(progname = av0);
37   }
39
40

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines