Remove useless stuff from utils
authorRan Benita <ran234@gmail.com>
Fri, 23 Mar 2012 21:28:24 +0000 (23:28 +0200)
committerDaniel Stone <daniel@fooishbar.org>
Tue, 27 Mar 2012 13:09:27 +0000 (14:09 +0100)
Signed-off-by: Ran Benita <ran234@gmail.com>
[daniels: fixed conflicts from strcasecmp, added includes to make
          filecomp build again]

src/XKBcommonint.h
src/utils.c
src/utils.h
src/xkbcomp/misc.c
src/xkbcomp/symbols.c
src/xkbcomp/vmod.c
src/xkbcomp/xkbcomp.c
src/xkbcomp/xkbcomp.h
src/xkbcomp/xkbpath.c
test/filecomp.c

index c2040aa..b26b56f 100644 (file)
@@ -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
index 095c2d1..a9d59c2 100644 (file)
    * 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;
index 020ed75..1cb7611 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef UTILS_H
-#define        UTILS_H 1
+#define UTILS_H 1
 
   /*\
    *
 
 /***====================================================================***/
 
-#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 */
index df1aa57..d141a80 100644 (file)
@@ -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);
index 26ee3c6..726e9d0 100644 (file)
@@ -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));
index 2fcf6a1..adf7473 100644 (file)
@@ -24,7 +24,6 @@
 
  ********************************************************/
 
-#define        DEBUG_VAR debugFlags
 #include <stdio.h>
 #include "xkbcomp.h"
 #include "xkballoc.h"
index 19ac4b8..b229688 100644 (file)
@@ -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))
index 08a32c6..650d6ce 100644 (file)
 #ifndef XKBCOMP_H
 #define        XKBCOMP_H 1
 
-#ifndef DEBUG_VAR
-#define        DEBUG_VAR debugFlags
-#endif
-
 #include <X11/X.h>
 #include <X11/Xdefs.h>
 
index 4faa5b7..505d8ba 100644 (file)
@@ -24,7 +24,6 @@
 
  ********************************************************/
 
-#define        DEBUG_VAR debugFlags
 #include "utils.h"
 #include <errno.h>
 #include <stdlib.h>
index 94c1bc1..e5538af 100644 (file)
@@ -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"