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/] [dirname.c] - Diff between revs 207 and 345

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
#ifndef _NO_DIRNAME
#ifndef _NO_DIRNAME
 
 
/* Copyright 2005 Shaun Jackman
/* Copyright 2005 Shaun Jackman
 * Permission to use, copy, modify, and distribute this software
 * Permission to use, copy, modify, and distribute this software
 * is freely granted, provided that this notice is preserved.
 * is freely granted, provided that this notice is preserved.
 */
 */
 
 
#include <libgen.h>
#include <libgen.h>
#include <string.h>
#include <string.h>
 
 
char *
char *
_DEFUN (dirname, (path),
_DEFUN (dirname, (path),
        char *path)
        char *path)
{
{
        char *p;
        char *p;
        if( path == NULL || *path == '\0' )
        if( path == NULL || *path == '\0' )
                return ".";
                return ".";
        p = path + strlen(path) - 1;
        p = path + strlen(path) - 1;
        while( *p == '/' ) {
        while( *p == '/' ) {
                if( p == path )
                if( p == path )
                        return path;
                        return path;
                *p-- = '\0';
                *p-- = '\0';
        }
        }
        while( p >= path && *p != '/' )
        while( p >= path && *p != '/' )
                p--;
                p--;
        return
        return
                p < path ? "." :
                p < path ? "." :
                p == path ? "/" :
                p == path ? "/" :
                (*p = '\0', path);
                (*p = '\0', path);
}
}
 
 
#endif /* !_NO_DIRNAME  */
#endif /* !_NO_DIRNAME  */
 
 

powered by: WebSVN 2.1.0

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