4399
|
1 /* |
4378
|
2 |
|
3 Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. |
|
4 Copyright (C) 1993, 94, 95, 96, 97, 98 Karl Berry. |
|
5 Copyright (C) 1994, 95, 96, 97 Karl Berry & Olaf Weber. |
|
6 |
|
7 This library is free software; you can redistribute it and/or |
|
8 modify it under the terms of the GNU Library General Public |
|
9 License as published by the Free Software Foundation; either |
7016
|
10 version 2 of the License, or (at your option) any later version. |
4378
|
11 |
|
12 This library is distributed in the hope that it will be useful, |
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 Library General Public License for more details. |
|
16 |
|
17 You should have received a copy of the GNU Library General Public |
|
18 License along with this library; if not, write to the Free Software |
5307
|
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. */ |
4378
|
21 |
|
22 #if defined (HAVE_CONFIG_H) |
|
23 #include <config.h> |
|
24 #endif |
|
25 |
4385
|
26 #include <string.h> |
4378
|
27 |
4379
|
28 #include "kpse-xfns.h" |
4378
|
29 |
4399
|
30 /* Return the last element in a path. */ |
4378
|
31 |
|
32 #ifndef HAVE_BASENAME |
|
33 |
|
34 /* Return NAME with any leading path stripped off. This returns a |
|
35 pointer into NAME. For example, `basename ("/foo/bar.baz")' |
|
36 returns "bar.baz". */ |
|
37 |
4385
|
38 static const char * |
4378
|
39 basename (const char *name) |
|
40 { |
|
41 const char *base = NULL; |
|
42 unsigned len = strlen (name); |
|
43 |
|
44 for (len = strlen (name); len > 0; len--) { |
|
45 if (IS_DIR_SEP (name[len - 1]) || IS_DEVICE_SEP (name[len - 1])) { |
|
46 base = name + len; |
|
47 break; |
|
48 } |
|
49 } |
|
50 |
|
51 if (!base) |
|
52 base = name; |
|
53 |
|
54 return base; |
|
55 } |
|
56 |
|
57 #endif |
|
58 |
4399
|
59 const char * |
|
60 octave_basename (const char *name) |
4378
|
61 { |
4399
|
62 return (const char *) basename (name); |
4378
|
63 } |