Back to index

radiance  4R0+20100331
fixargv0.c
Go to the documentation of this file.
00001 #ifndef lint
00002 static const char    RCSid[] = "$Id: fixargv0.c,v 2.5 2003/10/27 10:19:31 schorsch Exp $";
00003 #endif
00004 /*
00005  * Fix argv[0] for DOS environments
00006  *
00007  *  External symbols declared in paths.h
00008  */
00009 
00010 #include "copyright.h"
00011 
00012 #include <ctype.h>
00013 
00014 extern char *
00015 fixargv0(av0)               /* extract command name from full path */
00016 char  *av0;
00017 {
00018        register char  *cp = av0;
00019 
00020        while (*cp) cp++;           /* start from end */
00021        while (cp-- > av0)
00022               switch (*cp) {              /* fix up command name */
00023               case '.':                   /* remove extension */
00024                      *cp = '\0';
00025                      continue;
00026               case '\\':                  /* remove directory */
00027                      return(cp+1);
00028               default:                    /* convert to lower case */
00029                      *cp = tolower(*cp);
00030                      continue;
00031               }
00032        return(av0);
00033 }
00034 
00035