summaryrefslogtreecommitdiff
path: root/basename.c
blob: 1cc7854f5b121f5d1739ff96f7a9d50cb9415b46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* basename.c -- return the last element in a path */

#if HAVE_CONFIG_H
# include <config.h>
#endif

#include <backupfile.h>

/* In general, we can't use the builtin `basename' function if available,
   since it has different meanings in different environments.
   In some environments the builtin `basename' modifies its argument.  */

char *
base_name (name)
     char const *name;
{
  char const *base = name;

  while (*name)
    if (*name++ == '/')
      base = name;

  return (char *) base;
}