4 * Copyright 1998,2000 Bertho A. Stultiens
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
35 #define SUPPRESS_YACC_ERROR_MESSAGE
37 static void generic_msg(const char *s, const char *t, va_list ap)
39 fprintf(stderr, "%s:%d:%d: %s: ", input_name ? input_name : "stdin", line_number, char_number, t);
40 vfprintf(stderr, s, ap);
44 * The yyerror routine should not exit because we use the error-token
45 * to determine the syntactic error in the source. However, YACC
46 * uses the same routine to print an error just before the error
48 * The extra routine 'xyyerror' is used to exit after giving a real
51 int mcy_error(const char *s, ...)
53 #ifndef SUPPRESS_YACC_ERROR_MESSAGE
56 generic_msg(s, "Yacc error", ap);
62 int xyyerror(const char *s, ...)
66 generic_msg(s, "Error", ap);
72 int mcy_warning(const char *s, ...)
76 generic_msg(s, "Warning", ap);
81 void internal_error(const char *file, int line, const char *s, ...)
85 fprintf(stderr, "Internal error (please report) %s %d: ", file, line);
86 vfprintf(stderr, s, ap);
91 void error(const char *s, ...)
95 fprintf(stderr, "Error: ");
96 vfprintf(stderr, s, ap);
101 void warning(const char *s, ...)
105 fprintf(stderr, "Warning: ");
106 vfprintf(stderr, s, ap);
110 char *dup_basename(const char *name, const char *ext)
113 int extlen = strlen(ext);
120 slash = strrchr(name, '/');
124 namelen = strlen(name);
126 /* +4 for later extension and +1 for '\0' */
127 base = xmalloc(namelen +4 +1);
129 if(!strcasecmp(name + namelen-extlen, ext))
131 base[namelen - extlen] = '\0';
136 void *xmalloc(size_t size)
141 assert(size < 102400);
145 error("Virtual memory exhausted.\n");
147 memset(res, 0x55, size);
152 void *xrealloc(void *p, size_t size)
157 assert(size < 102400);
158 res = realloc(p, size);
161 error("Virtual memory exhausted.\n");
166 char *xstrdup(const char *str)
171 s = xmalloc(strlen(str)+1);
172 return strcpy(s, str);
175 int unistrlen(const WCHAR *s)
178 for(n = 0; *s; n++, s++)
183 WCHAR *unistrcpy(WCHAR *dst, const WCHAR *src)
192 WCHAR *xunistrdup(const WCHAR * str)
197 s = xmalloc((unistrlen(str)+1) * sizeof(WCHAR));
198 return unistrcpy(s, str);
201 int unistricmp(const WCHAR *s1, const WCHAR *s2)
205 static const char warn[] = "Don't know the uppercase equivalent of non acsii characters;"
206 "comparison might yield wrong results";
209 if((*s1 & 0xffff) > 0x7f || (*s2 & 0xffff) > 0x7f)
219 i = toupper(*s1++) - toupper(*s2++);
224 if((*s1 & 0xffff) > 0x7f || (*s2 & 0xffff) > 0x7f)
231 return toupper(*s1) - toupper(*s2);
234 int unistrcmp(const WCHAR *s1, const WCHAR *s2)