newlib-2.4.0: wide character strings
git-svn-id: svn://kolibrios.org@6557 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
26
contrib/sdk/sources/newlib/libc/string/gnu_basename.c
Normal file
26
contrib/sdk/sources/newlib/libc/string/gnu_basename.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef _NO_BASENAME
|
||||
/* Copyright 2015 Red Hat, Inc.
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* is freely granted, provided that this notice is preserved.
|
||||
*/
|
||||
|
||||
/* The differences with the POSIX version (unix/basename.c):
|
||||
* - declared in <string.h> (instead of <libgen.h>);
|
||||
* - the argument is never modified, and therefore is marked const;
|
||||
* - the empty string is returned if path is an empty string, "/", or ends
|
||||
* with a trailing slash.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
char *
|
||||
_DEFUN (__gnu_basename, (path),
|
||||
const char *path)
|
||||
{
|
||||
char *p;
|
||||
if ((p = strrchr (path, '/')))
|
||||
return p + 1;
|
||||
return (char *) path;
|
||||
}
|
||||
|
||||
#endif /* !_NO_BASENAME */
|
Reference in New Issue
Block a user