Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/libbb/simplify_path.c

    r1765 r2725  
    55 * Copyright (C) 2001  Manuel Novoa III  <mjn3@codepoet.org>
    66 *
    7  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
    9 
    109#include "libbb.h"
    1110
    12 char *bb_simplify_path(const char *path)
     11char* FAST_FUNC bb_simplify_abs_path_inplace(char *start)
    1312{
    14     char *s, *start, *p;
     13    char *s, *p;
    1514
    16     if (path[0] == '/')
    17         start = xstrdup(path);
    18     else {
    19         s = xrealloc_getcwd_or_warn(NULL);
    20         start = concat_path_file(s, path);
    21         free(s);
    22     }
    2315    p = s = start;
    24 
    2516    do {
    2617        if (*p == '/') {
    27             if (*s == '/') {    /* skip duplicate (or initial) slash */
     18            if (*s == '/') {  /* skip duplicate (or initial) slash */
    2819                continue;
    2920            }
    3021            if (*s == '.') {
    31                 if (s[1] == '/' || !s[1]) { /* remove extra '.' */
     22                if (s[1] == '/' || !s[1]) {  /* remove extra '.' */
    3223                    continue;
    3324                }
     
    3526                    ++s;
    3627                    if (p > start) {
    37                         while (*--p != '/') /* omit previous dir */
     28                        while (*--p != '/')  /* omit previous dir */
    3829                            continue;
    3930                    }
     
    4536    } while (*++s);
    4637
    47     if ((p == start) || (*p != '/')) {  /* not a trailing slash */
    48         ++p;                    /* so keep last character */
     38    if ((p == start) || (*p != '/')) {  /* not a trailing slash */
     39        ++p;  /* so keep last character */
    4940    }
    50     *p = 0;
     41    *p = '\0';
     42    return p;
     43}
    5144
    52     return start;
     45char* FAST_FUNC bb_simplify_path(const char *path)
     46{
     47    char *s, *p;
     48
     49    if (path[0] == '/')
     50        s = xstrdup(path);
     51    else {
     52        p = xrealloc_getcwd_or_warn(NULL);
     53        s = concat_path_file(p, path);
     54        free(p);
     55    }
     56
     57    bb_simplify_abs_path_inplace(s);
     58    return s;
    5359}
Note: See TracChangeset for help on using the changeset viewer.