[BACK]Return to which.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / which

Diff for /src/usr.bin/which/which.c between version 1.7 and 1.8

version 1.7, 2003/04/04 00:42:34 version 1.8, 2003/04/04 03:25:28
Line 28 
Line 28 
  */   */
   
 #ifndef lint  #ifndef lint
 static char rcsid[] = "$OpenBSD$";  static const char rcsid[] = "$OpenBSD$";
 #endif /* not lint */  #endif /* not lint */
   
 #include <sys/param.h>  #include <sys/param.h>
Line 62 
Line 62 
  */   */
   
 int  int
 main(argc, argv)  main(int argc, char **argv)
         int argc;  
         char **argv;  
 {  {
         char *path;          char *path;
         size_t n;          size_t n;
Line 123 
Line 121 
 }  }
   
 int  int
 findprog(prog, path, progmode, allmatches)  findprog(char *prog, char *path, int progmode, int allmatches)
         char *prog;  
         char *path;  
         int progmode;  
         int allmatches;  
 {  {
         char *p, filename[MAXPATHLEN];          char *p, filename[MAXPATHLEN];
         int proglen, plen, rval = 0;          int proglen, plen, rval = 0;
Line 162 
Line 156 
                         return(0);                          return(0);
                 }                  }
   
                 (void)strlcpy(filename, p, sizeof filename);                  snprintf(filename, sizeof(filename), "%s/%s", p, prog);
                 filename[plen] = '/';  
                 (void)strlcpy(filename + plen + 1, prog, sizeof filename - (plen + 1));  
                 if ((stat(filename, &sbuf) == 0) && S_ISREG(sbuf.st_mode) &&                  if ((stat(filename, &sbuf) == 0) && S_ISREG(sbuf.st_mode) &&
                     access(filename, X_OK) == 0) {                      access(filename, X_OK) == 0) {
                         (void)puts(filename);                          (void)puts(filename);
Line 182 
Line 174 
 }  }
   
 void  void
 usage()  usage(void)
 {  {
         (void) fprintf(stderr, "Usage: %s [-a] name [...]\n", __progname);          (void) fprintf(stderr, "Usage: %s [-a] name [...]\n", __progname);
         exit(1);          exit(1);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8