From 0480f427adcc745c139841a23c80d15a3d44f4db Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 23 Mar 2012 23:28:24 +0200 Subject: [PATCH] Remove useless stuff from utils Signed-off-by: Ran Benita [daniels: fixed conflicts from strcasecmp, added includes to make filecomp build again] --- src/XKBcommonint.h | 2 ++ src/utils.c | 15 ++++---- src/utils.h | 98 ++++++++------------------------------------------- src/xkbcomp/misc.c | 4 +-- src/xkbcomp/symbols.c | 2 +- src/xkbcomp/vmod.c | 1 - src/xkbcomp/xkbcomp.c | 3 +- src/xkbcomp/xkbcomp.h | 4 --- src/xkbcomp/xkbpath.c | 1 - test/filecomp.c | 4 +++ 10 files changed, 32 insertions(+), 102 deletions(-) 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 #include +#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 -#include -#include +#include "utils.h" +#include "XKBcommonint.h" + +#include +#include +#include +#include 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 -#include -#include -#include +#include +#include +#include -#include +#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?"":(s)) -#define uStringEqual(s1,s2) (uStringCompare(s1,s2)==Equal) +#define uStringText(s) ((s) == NULL ? "" : (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 #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 #include 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 #include 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 +#include +#include #include #include #include #include +#include #include #include #include "xkbcommon/xkbcommon.h" -- 2.7.4