@matheusbsbs / matheus-bagliano / commits / f2a782b8ba
Fork 0

Remove unused normalize_absolute_path()

This function is now superseded by normalize_path_copy(). Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Feb 7, 2009 at 16:08 UTC f2a782b8ba189b5ed51d18aa3eb93a670c220018
2 files changed +6 -46
cache.h
-1
@@ -547,7 +547,6 @@ static inline int is_absolute_path(const char *path)
547 const char *make_absolute_path(const char *path);
548 const char *make_nonrelative_path(const char *path);
549 const char *make_relative_path(const char *abs, const char *base);
550 -int normalize_absolute_path(char *buf, const char *path);
550 int normalize_path_copy(char *dst, const char *src);
551 int longest_ancestor_length(const char *path, const char *prefix_list);
552
path.c
+6 -45
@@ -363,58 +363,19 @@ const char *make_relative_path(const char *abs, const char *base)
363 }
364
365 /*
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.
367 *
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 '/'.
371 * - Removes "." components.
372 * - 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).
375 *
376 * Note that this function is purely textual. It does not follow symlinks,
377 * verify the existence of the path, or make any system calls.
378 */
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 -
379 int normalize_path_copy(char *dst, const char *src)
380 {
381 char *dst0;