beta-0.89.2
[luatex.git] / source / texk / web2c / web2c / kps.c
blob0363f7e7644a26848349545c188ace7e55adb655
1 /* Functions copied over from kpathsea library.
3 Original uppercasify is
4 Copyright 1993 Karl Berry.
6 Original xfopen/xfclose are
7 Copyright 1992, 93, 95 Free Software Foundation, Inc.
9 Further modifications
10 Copyright 2004 Olaf Weber.
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public
14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version.
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Library General Public License for more details.
22 You should have received a copy of the GNU Library General Public
23 License along with this library; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 #include "web2c.h"
27 #include <kpathsea/c-ctype.h>
28 /* Get rid of kpathsea debug definitions. */
29 #undef fopen
30 #undef fclose
32 string
33 uppercasify (const_string s)
35 string target;
36 string ret = malloc (strlen(s) + 1);
38 target = ret;
39 while (*s) {
40 *target = TOUPPER(*s);
41 target++;
42 s++;
44 *target = '\0';
46 return ret;
49 /* These routines just check the return status from standard library
50 routines and abort if an error happens. */
52 FILE *
53 xfopen (const_string filename, const_string mode)
55 FILE *f;
57 assert (filename && mode);
59 f = fopen (filename, mode);
60 if (f == NULL) {
61 perror(filename);
62 exit(EXIT_FAILURE);
65 return f;
69 void
70 xfclose (FILE *f, const_string filename)
72 assert (f);
74 if (fclose (f) == EOF) {
75 perror(filename);
76 exit(EXIT_FAILURE);