Last change
on this file since 577 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
656 bytes
|
Line | |
---|
1 | #ifndef _NO_BASENAME |
---|
2 | /* Copyright 2015 Red Hat, Inc. |
---|
3 | * Permission to use, copy, modify, and distribute this software |
---|
4 | * is freely granted, provided that this notice is preserved. |
---|
5 | */ |
---|
6 | |
---|
7 | /* The differences with the POSIX version (unix/basename.c): |
---|
8 | * - declared in <string.h> (instead of <libgen.h>); |
---|
9 | * - the argument is never modified, and therefore is marked const; |
---|
10 | * - the empty string is returned if path is an empty string, "/", or ends |
---|
11 | * with a trailing slash. |
---|
12 | */ |
---|
13 | |
---|
14 | #include <string.h> |
---|
15 | |
---|
16 | char * |
---|
17 | __gnu_basename (const char *path) |
---|
18 | { |
---|
19 | char *p; |
---|
20 | if ((p = strrchr (path, '/'))) |
---|
21 | return p + 1; |
---|
22 | return (char *) path; |
---|
23 | } |
---|
24 | |
---|
25 | #endif /* !_NO_BASENAME */ |
---|
Note: See
TracBrowser
for help on using the repository browser.