beta-0.89.2
[luatex.git] / source / texk / kpathsea / rm-suffix.c
blob289847de45561bb248eb13d46a1aa7996b45f271
1 /* rm-suffix.c: remove any suffix.
3 Copyright 2008, 2011, 2012 Karl Berry.
4 Copyright 1992, 1993, 1995 Free Software Foundation, Inc.
5 Modified for kpathsea by Karl Berry.
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.
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.
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/>. */
20 #include <kpathsea/config.h>
23 string
24 remove_suffix (const_string s)
26 string ret;
27 const_string suffix = find_suffix (s);
29 if (suffix)
31 /* Back up to before the dot. */
32 suffix--;
33 ret = (string) xmalloc (suffix - s + 1);
34 strncpy (ret, s, suffix - s);
35 ret[suffix - s] = 0;
37 else
38 ret = xstrdup (s);
40 return ret;