You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Dean Gaudet <dg...@hyperreal.org> on 1997/07/27 04:07:22 UTC

cvs commit: apache/src util.c

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)