]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/basename.c
reload_out[i]->rld[i].out.
[thirdparty/gcc.git] / libiberty / basename.c
CommitLineData
6599da04
JM
1/* Return the basename of a pathname.
2 This file is in the public domain. */
3
4/*
5NAME
6 basename -- return pointer to last component of a pathname
7
8SYNOPSIS
9 char *basename (const char *name)
10
11DESCRIPTION
12 Given a pointer to a string containing a typical pathname
13 (/usr/src/cmd/ls/ls.c for example), returns a pointer to the
14 last component of the pathname ("ls.c" in this case).
15
16BUGS
17 Presumes a UNIX style path with UNIX style separators.
18*/
19
20#include "ansidecl.h"
21#include "libiberty.h"
22
6599da04
JM
23char *
24basename (name)
25 const char *name;
26{
27 const char *base = name;
28
29 while (*name)
30 {
31 if (*name++ == '/')
32 {
33 base = name;
34 }
35 }
36 return (char *) base;
37}