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.1 by greg, Fri Oct 9 10:27:41 1992 UTC vs.
Revision 2.8 by greg, Fri Aug 5 00:12:46 2016 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
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(av0)                   /* extract command name from full path */
14 < char  *av0;
14 > fixargv0(char *av0)             /* extract command name from full path */
15   {
16 <        register char  *cp = av0;
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 <                        return(cp+1);
27 >                        /* make sure the original pointer remains the same */
28 >                        memmove(av0, cp+1, end-cp);
29 >                        return(av0);
30                  default:                        /* convert to lower case */
31                          *cp = tolower(*cp);
32                          continue;
33                  }
34          return(av0);
35   }
32
33

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines