Remove useless stuff from utils Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: fixed conflicts from strcasecmp, added includes to make filecomp build again]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
diff --git a/src/XKBcommonint.h b/src/XKBcommonint.h
index c2040aa..b26b56f 100644
--- a/src/XKBcommonint.h
+++ b/src/XKBcommonint.h
@@ -82,6 +82,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdlib.h>
#include <string.h>
+#include "xkbcommon/xkbcommon.h"
+
#ifndef True
#define True 1
#define False 0
diff --git a/src/utils.c b/src/utils.c
index 095c2d1..a9d59c2 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -25,10 +25,13 @@
* software without specific, written prior permission.
\*/
-#include "utils.h"
-#include <ctype.h>
-#include <stdlib.h>
-#include <stdarg.h>
+#include "utils.h"
+#include "XKBcommonint.h"
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
void *
recalloc(void * old, unsigned nOld, unsigned nNew, unsigned itemSize)
@@ -53,7 +56,7 @@ static int outCount = 0;
static char *preMsg = NULL;
static char *prefix = NULL;
-Boolean
+Bool
uSetErrorFile(char *name)
{
if ((errorFile != NULL) && (errorFile != stderr))
@@ -61,7 +64,7 @@ uSetErrorFile(char *name)
fprintf(errorFile, "switching to %s\n", name ? name : "stderr");
fclose(errorFile);
}
- if (name != NullString)
+ if (name != NULL)
errorFile = fopen(name, "w");
else
errorFile = stderr;
diff --git a/src/utils.h b/src/utils.h
index 020ed75..1cb7611 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1,5 +1,5 @@
#ifndef UTILS_H
-#define UTILS_H 1
+#define UTILS_H 1
/*\
*
@@ -29,42 +29,14 @@
/***====================================================================***/
-#include <stdio.h>
-#include <X11/Xos.h>
-#include <X11/Xfuncproto.h>
-#include <X11/Xfuncs.h>
+#include <stdio.h>
+#include <X11/Xdefs.h>
+#include <X11/Xfuncproto.h>
-#include <stddef.h>
+#ifdef HAVE_CONFIG_H
#include "config.h"
-
-#ifndef NUL
-#define NUL '\0'
-#endif
-
-/***====================================================================***/
-
-#ifndef BOOLEAN_DEFINED
-typedef char Boolean;
-#endif
-
-#ifndef True
-#define True ((Boolean)1)
-#define False ((Boolean)0)
-#endif /* ndef True */
-#define booleanText(b) ((b)?"True":"False")
-
-#ifndef COMPARISON_DEFINED
-typedef int Comparison;
-
-#define Greater ((Comparison)1)
-#define Equal ((Comparison)0)
-#define Less ((Comparison)-1)
-#define CannotCompare ((Comparison)-37)
-#define comparisonText(c) ((c)?((c)<0?"Less":"Greater"):"Equal")
#endif
-/***====================================================================***/
-
extern void *
recalloc(void * old, unsigned nOld, unsigned nNew, unsigned newSize);
@@ -72,92 +44,50 @@ recalloc(void * old, unsigned nOld, unsigned nNew, unsigned newSize);
#define uTypedCalloc(n,t) ((t *)calloc((unsigned)n,(unsigned)sizeof(t)))
#define uTypedRealloc(pO,n,t) ((t *)realloc(pO,((unsigned)n)*sizeof(t)))
#define uTypedRecalloc(pO,o,n,t) ((t *)recalloc(pO,((unsigned)o),((unsigned)n),sizeof(t)))
-#if (defined mdHasAlloca) && (mdHasAlloca)
-#define uTmpAlloc(n) alloca((unsigned)n)
-#define uTmpFree(p)
-#else
-#define uTmpAlloc(n) malloc(n)
-#define uTmpFree(p) free(p)
-#endif
/***====================================================================***/
-extern Boolean
+extern Bool
uSetErrorFile(char *name);
-#if defined(__GNUC__) && \
- ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 6)))
-#define __ATTR_PRINTF(i, f) __attribute__ ((format(printf, (i), (f))))
-#else
-#define __ATTR_PRINTF(i, f)
-#endif
#define INFO uInformation
-extern __ATTR_PRINTF(1, 2) void
+extern _X_ATTRIBUTE_PRINTF(1, 2) void
uInformation(const char *s, ...);
#define ACTION uAction
-extern __ATTR_PRINTF(1, 2) void
+extern _X_ATTRIBUTE_PRINTF(1, 2) void
uAction(const char *s, ...);
#define WARN uWarning
-extern __ATTR_PRINTF(1, 2) void
+extern _X_ATTRIBUTE_PRINTF(1, 2) void
uWarning(const char *s, ...);
#define ERROR uError
-extern __ATTR_PRINTF(1, 2) void
+extern _X_ATTRIBUTE_PRINTF(1, 2) void
uError(const char *s, ...);
#define FATAL uFatalError
-extern __ATTR_PRINTF(1, 2) _X_NORETURN void
+extern _X_ATTRIBUTE_PRINTF(1, 2) _X_NORETURN void
uFatalError(const char *s, ...);
/* WSGO stands for "Weird Stuff Going On" (wtf???) */
#define WSGO uInternalError
-extern __ATTR_PRINTF(1, 2) void
+extern _X_ATTRIBUTE_PRINTF(1, 2) void
uInternalError(const char *s, ...);
/***====================================================================***/
-#define NullString ((char *)NULL)
-
-#define uStringText(s) ((s)==NullString?"<NullString>":(s))
-#define uStringEqual(s1,s2) (uStringCompare(s1,s2)==Equal)
+#define uStringText(s) ((s) == NULL ? "<NullString>" : (s))
+#define uStringEqual(s1,s2) (strcmp(s1,s2) == 0)
#define uStringPrefix(p,s) (strncmp(p,s,strlen(p))==0)
-#define uStringCompare(s1,s2) (((s1)==NullString||(s2)==NullString)?\
- (s1)!=(s2):strcmp(s1,s2))
-#define uStrCaseEqual(s1,s2) (uStrCaseCmp(s1,s2)==0)
-#ifdef HAVE_STRCASECMP
#define uStrCaseCmp(s1,s2) (strcasecmp(s1,s2))
#define uStrCasePrefix(p,s) (strncasecmp(p,s,strlen(p))==0)
-#else
-extern int
-uStrCaseCmp(const char *s1, const char *s2);
-extern int
-uStrCasePrefix(const char *p, char *str);
-#endif
-
-/***====================================================================***/
-
-#ifdef ASSERTIONS_ON
-#define uASSERT(where,why) \
- {if (!(why)) uFatalError("assertion botched in %s ( why )\n",where);}
-#else
-#define uASSERT(where,why)
-#endif
-
-/***====================================================================***/
-
-#ifndef DEBUG_VAR
-#define DEBUG_VAR debugFlags
-#endif
-
-extern unsigned int DEBUG_VAR;
#endif /* UTILS_H */
diff --git a/src/xkbcomp/misc.c b/src/xkbcomp/misc.c
index df1aa57..d141a80 100644
--- a/src/xkbcomp/misc.c
+++ b/src/xkbcomp/misc.c
@@ -70,8 +70,6 @@ ProcessIncludeFile(IncludeStmt * stmt,
memset(oldFile, 0, sizeof(oldFile));
oldLine = lineNum;
setScanState(stmt->file, 1);
- if (debugFlags & 2)
- INFO("About to parse include file %s\n", stmt->file);
/* parse the file */
if ((XKBParseFile(file, &rtrn) == 0) || (rtrn == NULL))
{
@@ -89,7 +87,7 @@ ProcessIncludeFile(IncludeStmt * stmt,
{
next = (XkbFile *)mapToUse->common.next;
mapToUse->common.next = NULL;
- if (uStringEqual(mapToUse->name, stmt->map) &&
+ if (strcmp(mapToUse->name, stmt->map) == 0 &&
mapToUse->type == file_type)
{
FreeXKBFile(next);
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 26ee3c6..726e9d0 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1095,7 +1095,7 @@ SetSymbolsField(KeyInfo * key,
}
else if ((uStrCaseCmp(field, "radiogroup") == 0) ||
(uStrCaseCmp(field, "permanentradiogroup") == 0) ||
- (uStrCaseEqual(field, "allownone")))
+ (uStrCaseCmp(field, "allownone") == 0))
{
ERROR("Radio groups not supported\n");
ACTION("Ignoring radio group specification for key %s\n", longText(key->name));
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index 2fcf6a1..adf7473 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -24,7 +24,6 @@
********************************************************/
-#define DEBUG_VAR debugFlags
#include <stdio.h>
#include "xkbcomp.h"
#include "xkballoc.h"
diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c
index 19ac4b8..b229688 100644
--- a/src/xkbcomp/xkbcomp.c
+++ b/src/xkbcomp/xkbcomp.c
@@ -33,8 +33,7 @@ authorization from the authors.
#include "parseutils.h"
#include "utils.h"
-/* Global debugging flags */
-unsigned int debugFlags = 0;
+/* Global warning level */
unsigned int warningLevel = 0;
#define ISEMPTY(str) (!(str) || (strlen(str) == 0))
diff --git a/src/xkbcomp/xkbcomp.h b/src/xkbcomp/xkbcomp.h
index 08a32c6..650d6ce 100644
--- a/src/xkbcomp/xkbcomp.h
+++ b/src/xkbcomp/xkbcomp.h
@@ -27,10 +27,6 @@
#ifndef XKBCOMP_H
#define XKBCOMP_H 1
-#ifndef DEBUG_VAR
-#define DEBUG_VAR debugFlags
-#endif
-
#include <X11/X.h>
#include <X11/Xdefs.h>
diff --git a/src/xkbcomp/xkbpath.c b/src/xkbcomp/xkbpath.c
index 4faa5b7..505d8ba 100644
--- a/src/xkbcomp/xkbpath.c
+++ b/src/xkbcomp/xkbpath.c
@@ -24,7 +24,6 @@
********************************************************/
-#define DEBUG_VAR debugFlags
#include "utils.h"
#include <errno.h>
#include <stdlib.h>
diff --git a/test/filecomp.c b/test/filecomp.c
index 94c1bc1..e5538af 100644
--- a/test/filecomp.c
+++ b/test/filecomp.c
@@ -24,10 +24,14 @@ sale, use or other dealings in this Software without prior written
authorization from the authors.
*/
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <fcntl.h>
#include <X11/X.h>
#include <X11/Xdefs.h>
#include "xkbcommon/xkbcommon.h"