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/get_last_path_component.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 */
    99
    1010#include "libbb.h"
     11/*
     12 * "/"        -> "/"
     13 * "abc"      -> "abc"
     14 * "abc/def"  -> "def"
     15 * "abc/def/" -> ""
     16 */
     17char* FAST_FUNC bb_get_last_path_component_nostrip(const char *path)
     18{
     19    char *slash = strrchr(path, '/');
    1120
    12 char *bb_get_last_path_component(char *path)
     21    if (!slash || (slash == path && !slash[1]))
     22        return (char*)path;
     23
     24    return slash + 1;
     25}
     26
     27/*
     28 * "/"        -> "/"
     29 * "abc"      -> "abc"
     30 * "abc/def"  -> "def"
     31 * "abc/def/" -> "def" !!
     32 */
     33char* FAST_FUNC bb_get_last_path_component_strip(char *path)
    1334{
    14     char *first = path;
    15     char *last;
     35    char *slash = last_char_is(path, '/');
    1636
    17     last = path - 1;
     37    if (slash)
     38        while (*slash == '/' && slash != path)
     39            *slash-- = '\0';
    1840
    19     while (*path) {
    20         if ((*path != '/') && (path > ++last)) {
    21             last = first = path;
    22         }
    23         ++path;
    24     }
    25 
    26     if (*first == '/') {
    27         last = first;
    28     }
    29     last[1] = '\0';
    30 
    31     return first;
     41    return bb_get_last_path_component_nostrip(path);
    3242}
Note: See TracChangeset for help on using the changeset viewer.