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 |
|
10 version 2 of the License, or (at your option) any later version. |
|
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 |
|
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
|
20 |
|
21 #if defined (HAVE_CONFIG_H) |
|
22 #include <config.h> |
|
23 #endif |
|
24 |
4385
|
25 #include <string.h> |
4378
|
26 |
4379
|
27 #include "kpse-xfns.h" |
4378
|
28 |
4399
|
29 /* Return the last element in a path. */ |
4378
|
30 |
|
31 #ifndef HAVE_BASENAME |
|
32 |
|
33 /* Return NAME with any leading path stripped off. This returns a |
|
34 pointer into NAME. For example, `basename ("/foo/bar.baz")' |
|
35 returns "bar.baz". */ |
|
36 |
4385
|
37 static const char * |
4378
|
38 basename (const char *name) |
|
39 { |
|
40 const char *base = NULL; |
|
41 unsigned len = strlen (name); |
|
42 |
|
43 for (len = strlen (name); len > 0; len--) { |
|
44 if (IS_DIR_SEP (name[len - 1]) || IS_DEVICE_SEP (name[len - 1])) { |
|
45 base = name + len; |
|
46 break; |
|
47 } |
|
48 } |
|
49 |
|
50 if (!base) |
|
51 base = name; |
|
52 |
|
53 return base; |
|
54 } |
|
55 |
|
56 #endif |
|
57 |
4399
|
58 const char * |
|
59 octave_basename (const char *name) |
4378
|
60 { |
4399
|
61 return (const char *) basename (name); |
4378
|
62 } |