dvitomp fix from Akira
[mplib] / src / texk / kpathsea / rm-suffix.c
1 /* rm-suffix.c: remove any suffix.
2
3    Copyright 2008 Karl Berry.
4    Copyright 1992, 1993, 1995 Free Software Foundation, Inc.
5    Modified for kpathsea by Karl Berry.
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 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    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public License
18    along with this library; if not, see <http://www.gnu.org/licenses/>.  */
19
20 #include <kpathsea/config.h>
21
22
23 /* Generic const warning -- see extend-fname.c.  */
24
25 string
26 remove_suffix P1C(const_string, s)
27 {
28   string ret;
29   const_string suffix = find_suffix (s);
30   
31   if (suffix)
32     {
33       /* Back up to before the dot.  */
34       suffix--;
35       ret = (string) xmalloc (suffix - s + 1);
36       strncpy (ret, s, suffix - s);
37       ret[suffix - s] = 0;
38     }
39   else
40     ret = (string) s;
41     
42   return ret;
43 }