@@ -363,58 +363,19 @@ const char *make_relative_path(const char *abs, const char *base)
363363}
364364
365365/*
366- * path = absolute path
367- * buf = buffer of at least max(2, strlen(path)+1) bytes
368- * It is okay if buf == path, but they should not overlap otherwise.
366+ * It is okay if dst == src, but they should not overlap otherwise.
369367 *
370- * Performs the following normalizations on path , storing the result in buf :
371- * - Removes trailing slashes.
372- * - Removes empty components .
368+ * Performs the following normalizations on src , storing the result in dst :
369+ * - Ensures that components are separated by '/' (Windows only)
370+ * - Squashes sequences of '/' .
373371 * - Removes "." components.
374372 * - Removes ".." components, and the components the precede them.
375- * "" and paths that contain only slashes are normalized to "/".
376- * Returns the length of the output .
373+ * Returns failure (non-zero) if a ".." component appears as first path
374+ * component anytime during the normalization. Otherwise, returns success (0) .
377375 *
378376 * Note that this function is purely textual. It does not follow symlinks,
379377 * verify the existence of the path, or make any system calls.
380378 */
381- int normalize_absolute_path (char * buf , const char * path )
382- {
383- const char * comp_start = path , * comp_end = path ;
384- char * dst = buf ;
385- int comp_len ;
386- assert (buf );
387- assert (path );
388-
389- while (* comp_start ) {
390- assert (* comp_start == '/' );
391- while (* ++ comp_end && * comp_end != '/' )
392- ; /* nothing */
393- comp_len = comp_end - comp_start ;
394-
395- if (!strncmp ("/" , comp_start , comp_len ) ||
396- !strncmp ("/." , comp_start , comp_len ))
397- goto next ;
398-
399- if (!strncmp ("/.." , comp_start , comp_len )) {
400- while (dst > buf && * -- dst != '/' )
401- ; /* nothing */
402- goto next ;
403- }
404-
405- memmove (dst , comp_start , comp_len );
406- dst += comp_len ;
407- next :
408- comp_start = comp_end ;
409- }
410-
411- if (dst == buf )
412- * dst ++ = '/' ;
413-
414- * dst = '\0' ;
415- return dst - buf ;
416- }
417-
418379int normalize_path_copy (char * dst , const char * src )
419380{
420381 char * dst0 ;
0 commit comments