OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [unix/] [basename.c] - Blame information for rev 171

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 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.