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.4 by schorsch, Tue Oct 21 19:19:28 2003 UTC vs.
Revision 2.7 by schorsch, Sun Mar 20 16:36:17 2016 UTC

# Line 10 | Line 10 | static const char      RCSid[] = "$Id$";
10   #include "copyright.h"
11  
12   #include <ctype.h>
13 + #include <string.h>
14  
15 < char *
15 > extern char *
16   fixargv0(av0)                   /* extract command name from full path */
17   char  *av0;
18   {
19 <        register char  *cp = av0;
19 >        register char  *cp = av0, *end = av0;
20  
21          while (*cp) cp++;               /* start from end */
22 +        end = cp;
23          while (cp-- > av0)
24                  switch (*cp) {          /* fix up command name */
25                  case '.':                       /* remove extension */
26                          *cp = '\0';
27 +                        end = cp;
28                          continue;
29                  case '\\':                      /* remove directory */
30 <                        return(cp+1);
30 >                        /* make sure the original pointer remains the same */
31 >                        memmove(av0, cp+1, end-cp);
32 >                        break;
33                  default:                        /* convert to lower case */
34                          *cp = tolower(*cp);
35                          continue;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines