Magellan Linux

Annotation of /tags/mkinitrd-6_1_11/busybox/libbb/get_last_path_component.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (hide annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
Original Path: trunk/mkinitrd-magellan/busybox/libbb/get_last_path_component.c
File MIME type: text/plain
File size: 533 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 niro 532 /* vi: set sw=4 ts=4: */
2     /*
3     * bb_get_last_path_component implementation for busybox
4     *
5     * Copyright (C) 2001 Manuel Novoa III <mjn3@codepoet.org>
6     *
7     * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8     */
9    
10     #include "libbb.h"
11    
12     char *bb_get_last_path_component(char *path)
13     {
14     char *first = path;
15     char *last;
16    
17     last = path - 1;
18    
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;
32     }