httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@hyperreal.org>
Subject cvs commit: apache/src util.c
Date Sun, 27 Jul 1997 02:07:22 GMT
dgaudet     97/07/26 19:07:21

  Modified:    src       util.c
  Log:
  chdir_file takes a const char *.  It shouldn't modify its argument.
  
  Revision  Changes    Path
  1.66      +14 -7     apache/src/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/util.c,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- util.c	1997/07/27 01:21:40	1.65
  +++ util.c	1997/07/27 02:07:20	1.66
  @@ -424,14 +424,21 @@
   }
   
   
  -API_EXPORT(void) chdir_file(const char *file) {
  -    int i;
  +API_EXPORT(void) chdir_file(const char *file)
  +{
  +    const char *x;
  +    char buf[HUGE_STRING_LEN];
   
  -    if((i = rind(file,'/')) == -1)
  -        return;
  -    ((char *)file)[i] = '\0';
  -    chdir(file);
  -    ((char *)file)[i] = '/';
  +    x = strrchr (file, '/');
  +    if (x == NULL) {
  +	chdir (file);
  +    } else if (x - file < sizeof(buf)-1) {
  +	memcpy (buf, file, x - file);
  +	buf[x - file] = '\0';
  +	chdir (buf);
  +    }
  +    /* XXX: well, this is a silly function, no method of reporting an
  +     * error... ah well. */
   }
   
   API_EXPORT(char *) getword_nc(pool* atrans, char **line, char stop)
  
  
  

Mime
View raw message