OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [unix/] [basename.c] - Blame information for rev 345

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
#ifndef _NO_BASENAME
2
/* Copyright 2005 Shaun Jackman
3
 * Permission to use, copy, modify, and distribute this software
4
 * is freely granted, provided that this notice is preserved.
5
 */
6
 
7
#include <libgen.h>
8
#include <string.h>
9
 
10
char*
11
_DEFUN (basename, (path),
12
        char *path)
13
{
14
        char *p;
15
        if( path == NULL || *path == '\0' )
16
                return ".";
17
        p = path + strlen(path) - 1;
18
        while( *p == '/' ) {
19
                if( p == path )
20
                        return path;
21
                *p-- = '\0';
22
        }
23
        while( p >= path && *p != '/' )
24
                p--;
25
        return p + 1;
26
}
27
 
28
#endif /* !_NO_BASENAME  */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.