Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6557 serge 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  (instead of );
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 
15
 
16
char *
17
_DEFUN (__gnu_basename, (path),
18
	const char *path)
19
{
20
  char *p;
21
  if ((p = strrchr (path, '/')))
22
    return p + 1;
23
  return (char *) path;
24
}
25
 
26
#endif /* !_NO_BASENAME  */