Commit d22b8dbbd0a7e0f8bf8cc56968ea3a78692bac21

Ran Benita 2012-03-23T22:25:47

Move utils.{c,h} to be used by the entire project This is a first step for making consistent use of utils.h also outside of xkbcomp/ . Signed-off-by: Ran Benita <ran234@gmail.com>

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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
diff --git a/src/Makefile.am b/src/Makefile.am
index ef66913..2aed33d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,6 +17,8 @@ libxkbcommon_la_SOURCES = \
 	misc.c \
 	state.c \
 	text.c \
+	utils.c \
+	utils.h \
 	xkb.c \
 	xkballoc.h \
 	xkbmisc.h \
diff --git a/src/utils.c b/src/utils.c
new file mode 100644
index 0000000..0ba389b
--- /dev/null
+++ b/src/utils.c
@@ -0,0 +1,252 @@
+
+  /*\
+   *
+   *                          COPYRIGHT 1990
+   *                    DIGITAL EQUIPMENT CORPORATION
+   *                       MAYNARD, MASSACHUSETTS
+   *                        ALL RIGHTS RESERVED.
+   *
+   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
+   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
+   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
+   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
+   * WARRANTY.
+   *
+   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
+   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
+   * ADDITION TO THAT SET FORTH ABOVE.
+   *
+   * Permission to use, copy, modify, and distribute this software and its
+   * documentation for any purpose and without fee is hereby granted, provided
+   * that the above copyright notice appear in all copies and that both that
+   * copyright notice and this permission notice appear in supporting
+   * documentation, and that the name of Digital Equipment Corporation not be
+   * used in advertising or publicity pertaining to distribution of the
+   * software without specific, written prior permission.
+   \*/
+
+#include 	"utils.h"
+#include	<ctype.h>
+#include	<stdlib.h>
+#include	<stdarg.h>
+
+void *
+recalloc(void * old, unsigned nOld, unsigned nNew, unsigned itemSize)
+{
+    char *rtrn;
+
+    if (old == NULL)
+        rtrn = calloc(nNew, itemSize);
+    else
+    {
+        rtrn = realloc(old, nNew * itemSize);
+        if ((rtrn) && (nNew > nOld))
+        {
+            memset(&rtrn[nOld * itemSize], 0, (nNew - nOld) * itemSize);
+        }
+    }
+    return rtrn;
+}
+
+static FILE *errorFile = NULL;
+static int outCount = 0;
+static char *preMsg = NULL;
+static char *prefix = NULL;
+
+Boolean
+uSetErrorFile(char *name)
+{
+    if ((errorFile != NULL) && (errorFile != stderr))
+    {
+        fprintf(errorFile, "switching to %s\n", name ? name : "stderr");
+        fclose(errorFile);
+    }
+    if (name != NullString)
+        errorFile = fopen(name, "w");
+    else
+        errorFile = stderr;
+    if (errorFile == NULL)
+    {
+        errorFile = stderr;
+        return (False);
+    }
+    return (True);
+}
+
+void
+uInformation(const char *s, ...)
+{
+    va_list args;
+
+    if (!errorFile)
+        errorFile = stderr;
+
+    va_start(args, s);
+    vfprintf(errorFile, s, args);
+    va_end(args);
+    fflush(errorFile);
+}
+
+/***====================================================================***/
+
+void
+uAction(const char *s, ...)
+{
+    va_list args;
+
+    if (!errorFile)
+        errorFile = stderr;
+
+    if (prefix != NULL)
+        fprintf(errorFile, "%s", prefix);
+    fprintf(errorFile, "                  ");
+    va_start(args, s);
+    vfprintf(errorFile, s, args);
+    va_end(args);
+    fflush(errorFile);
+}
+
+/***====================================================================***/
+
+void
+uWarning(const char *s, ...)
+{
+    va_list args;
+
+    if (!errorFile)
+        errorFile = stderr;
+
+    if ((outCount == 0) && (preMsg != NULL))
+        fprintf(errorFile, "%s\n", preMsg);
+    if (prefix != NULL)
+        fprintf(errorFile, "%s", prefix);
+    fprintf(errorFile, "Warning:          ");
+    va_start(args, s);
+    vfprintf(errorFile, s, args);
+    va_end(args);
+    fflush(errorFile);
+    outCount++;
+}
+
+/***====================================================================***/
+
+void
+uError(const char *s, ...)
+{
+    va_list args;
+
+    if (!errorFile)
+        errorFile = stderr;
+
+    if ((outCount == 0) && (preMsg != NULL))
+        fprintf(errorFile, "%s\n", preMsg);
+    if (prefix != NULL)
+        fprintf(errorFile, "%s", prefix);
+    fprintf(errorFile, "Error:            ");
+    va_start(args, s);
+    vfprintf(errorFile, s, args);
+    va_end(args);
+    fflush(errorFile);
+    outCount++;
+}
+
+/***====================================================================***/
+
+void
+uFatalError(const char *s, ...)
+{
+    va_list args;
+
+    if (!errorFile)
+        errorFile = stderr;
+
+    if ((outCount == 0) && (preMsg != NULL))
+        fprintf(errorFile, "%s\n", preMsg);
+    if (prefix != NULL)
+        fprintf(errorFile, "%s", prefix);
+    fprintf(errorFile, "Fatal Error:      ");
+    va_start(args, s);
+    vfprintf(errorFile, s, args);
+    va_end(args);
+    fprintf(errorFile, "                  Exiting\n");
+    fflush(errorFile);
+    outCount++;
+    exit(1);
+    /* NOTREACHED */
+}
+
+/***====================================================================***/
+
+void
+uInternalError(const char *s, ...)
+{
+    va_list args;
+
+    if (!errorFile)
+        errorFile = stderr;
+
+    if ((outCount == 0) && (preMsg != NULL))
+        fprintf(errorFile, "%s\n", preMsg);
+    if (prefix != NULL)
+        fprintf(errorFile, "%s", prefix);
+    fprintf(errorFile, "Internal error:   ");
+    va_start(args, s);
+    vfprintf(errorFile, s, args);
+    va_end(args);
+    fflush(errorFile);
+    outCount++;
+}
+
+/***====================================================================***/
+
+#ifndef HAVE_STRCASECMP
+int
+uStrCaseCmp(const char *str1, const char *str2)
+{
+    char buf1[512], buf2[512];
+    char c, *s;
+    int n;
+
+    for (n = 0, s = buf1; (c = *str1++); n++)
+    {
+        if (isupper(c))
+            c = tolower(c);
+        if (n > 510)
+            break;
+        *s++ = c;
+    }
+    *s = '\0';
+    for (n = 0, s = buf2; (c = *str2++); n++)
+    {
+        if (isupper(c))
+            c = tolower(c);
+        if (n > 510)
+            break;
+        *s++ = c;
+    }
+    *s = '\0';
+    return (strcmp(buf1, buf2));
+}
+
+int
+uStrCasePrefix(const char *my_prefix, char *str)
+{
+    char c1;
+    char c2;
+    while (((c1 = *my_prefix) != '\0') && ((c2 = *str) != '\0'))
+    {
+        if (isupper(c1))
+            c1 = tolower(c1);
+        if (isupper(c2))
+            c2 = tolower(c2);
+        if (c1 != c2)
+            return 0;
+        my_prefix++;
+        str++;
+    }
+    if (c1 != '\0')
+        return 0;
+    return 1;
+}
+
+#endif
diff --git a/src/utils.h b/src/utils.h
new file mode 100644
index 0000000..020ed75
--- /dev/null
+++ b/src/utils.h
@@ -0,0 +1,163 @@
+#ifndef UTILS_H
+#define	UTILS_H 1
+
+  /*\
+   *
+   *                          COPYRIGHT 1990
+   *                    DIGITAL EQUIPMENT CORPORATION
+   *                       MAYNARD, MASSACHUSETTS
+   *                        ALL RIGHTS RESERVED.
+   *
+   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
+   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
+   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
+   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
+   * WARRANTY.
+   *
+   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
+   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
+   * ADDITION TO THAT SET FORTH ABOVE.
+   *
+   * Permission to use, copy, modify, and distribute this software and its
+   * documentation for any purpose and without fee is hereby granted, provided
+   * that the above copyright notice appear in all copies and that both that
+   * copyright notice and this permission notice appear in supporting
+   * documentation, and that the name of Digital Equipment Corporation not be
+   * used in advertising or publicity pertaining to distribution of the
+   * software without specific, written prior permission.
+   \*/
+
+/***====================================================================***/
+
+#include 	<stdio.h>
+#include	<X11/Xos.h>
+#include	<X11/Xfuncproto.h>
+#include	<X11/Xfuncs.h>
+
+#include <stddef.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);
+
+#define	uTypedAlloc(t)		((t *)malloc((unsigned)sizeof(t)))
+#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
+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
+uInformation(const char *s, ...);
+
+#define ACTION			uAction
+
+extern __ATTR_PRINTF(1, 2) void
+uAction(const char *s, ...);
+
+#define WARN			uWarning
+
+extern __ATTR_PRINTF(1, 2) void
+uWarning(const char *s, ...);
+
+#define ERROR			uError
+
+extern __ATTR_PRINTF(1, 2) void
+uError(const char *s, ...);
+
+#define FATAL			uFatalError
+
+extern __ATTR_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
+uInternalError(const char *s, ...);
+
+/***====================================================================***/
+
+#define	NullString	((char *)NULL)
+
+#define	uStringText(s)		((s)==NullString?"<NullString>":(s))
+#define	uStringEqual(s1,s2)	(uStringCompare(s1,s2)==Equal)
+#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/Makefile.am b/src/xkbcomp/Makefile.am
index 0866208..473f94d 100644
--- a/src/xkbcomp/Makefile.am
+++ b/src/xkbcomp/Makefile.am
@@ -23,8 +23,6 @@ libxkbcomp_la_SOURCES = \
 	parseutils.c \
 	parseutils.h \
 	symbols.c \
-	utils.c \
-	utils.h \
 	vmod.c \
 	vmod.h \
 	xkbcomp.c \
diff --git a/src/xkbcomp/utils.c b/src/xkbcomp/utils.c
deleted file mode 100644
index 0ba389b..0000000
--- a/src/xkbcomp/utils.c
+++ /dev/null
@@ -1,252 +0,0 @@
-
-  /*\
-   *
-   *                          COPYRIGHT 1990
-   *                    DIGITAL EQUIPMENT CORPORATION
-   *                       MAYNARD, MASSACHUSETTS
-   *                        ALL RIGHTS RESERVED.
-   *
-   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
-   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
-   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
-   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
-   * WARRANTY.
-   *
-   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
-   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
-   * ADDITION TO THAT SET FORTH ABOVE.
-   *
-   * Permission to use, copy, modify, and distribute this software and its
-   * documentation for any purpose and without fee is hereby granted, provided
-   * that the above copyright notice appear in all copies and that both that
-   * copyright notice and this permission notice appear in supporting
-   * documentation, and that the name of Digital Equipment Corporation not be
-   * used in advertising or publicity pertaining to distribution of the
-   * software without specific, written prior permission.
-   \*/
-
-#include 	"utils.h"
-#include	<ctype.h>
-#include	<stdlib.h>
-#include	<stdarg.h>
-
-void *
-recalloc(void * old, unsigned nOld, unsigned nNew, unsigned itemSize)
-{
-    char *rtrn;
-
-    if (old == NULL)
-        rtrn = calloc(nNew, itemSize);
-    else
-    {
-        rtrn = realloc(old, nNew * itemSize);
-        if ((rtrn) && (nNew > nOld))
-        {
-            memset(&rtrn[nOld * itemSize], 0, (nNew - nOld) * itemSize);
-        }
-    }
-    return rtrn;
-}
-
-static FILE *errorFile = NULL;
-static int outCount = 0;
-static char *preMsg = NULL;
-static char *prefix = NULL;
-
-Boolean
-uSetErrorFile(char *name)
-{
-    if ((errorFile != NULL) && (errorFile != stderr))
-    {
-        fprintf(errorFile, "switching to %s\n", name ? name : "stderr");
-        fclose(errorFile);
-    }
-    if (name != NullString)
-        errorFile = fopen(name, "w");
-    else
-        errorFile = stderr;
-    if (errorFile == NULL)
-    {
-        errorFile = stderr;
-        return (False);
-    }
-    return (True);
-}
-
-void
-uInformation(const char *s, ...)
-{
-    va_list args;
-
-    if (!errorFile)
-        errorFile = stderr;
-
-    va_start(args, s);
-    vfprintf(errorFile, s, args);
-    va_end(args);
-    fflush(errorFile);
-}
-
-/***====================================================================***/
-
-void
-uAction(const char *s, ...)
-{
-    va_list args;
-
-    if (!errorFile)
-        errorFile = stderr;
-
-    if (prefix != NULL)
-        fprintf(errorFile, "%s", prefix);
-    fprintf(errorFile, "                  ");
-    va_start(args, s);
-    vfprintf(errorFile, s, args);
-    va_end(args);
-    fflush(errorFile);
-}
-
-/***====================================================================***/
-
-void
-uWarning(const char *s, ...)
-{
-    va_list args;
-
-    if (!errorFile)
-        errorFile = stderr;
-
-    if ((outCount == 0) && (preMsg != NULL))
-        fprintf(errorFile, "%s\n", preMsg);
-    if (prefix != NULL)
-        fprintf(errorFile, "%s", prefix);
-    fprintf(errorFile, "Warning:          ");
-    va_start(args, s);
-    vfprintf(errorFile, s, args);
-    va_end(args);
-    fflush(errorFile);
-    outCount++;
-}
-
-/***====================================================================***/
-
-void
-uError(const char *s, ...)
-{
-    va_list args;
-
-    if (!errorFile)
-        errorFile = stderr;
-
-    if ((outCount == 0) && (preMsg != NULL))
-        fprintf(errorFile, "%s\n", preMsg);
-    if (prefix != NULL)
-        fprintf(errorFile, "%s", prefix);
-    fprintf(errorFile, "Error:            ");
-    va_start(args, s);
-    vfprintf(errorFile, s, args);
-    va_end(args);
-    fflush(errorFile);
-    outCount++;
-}
-
-/***====================================================================***/
-
-void
-uFatalError(const char *s, ...)
-{
-    va_list args;
-
-    if (!errorFile)
-        errorFile = stderr;
-
-    if ((outCount == 0) && (preMsg != NULL))
-        fprintf(errorFile, "%s\n", preMsg);
-    if (prefix != NULL)
-        fprintf(errorFile, "%s", prefix);
-    fprintf(errorFile, "Fatal Error:      ");
-    va_start(args, s);
-    vfprintf(errorFile, s, args);
-    va_end(args);
-    fprintf(errorFile, "                  Exiting\n");
-    fflush(errorFile);
-    outCount++;
-    exit(1);
-    /* NOTREACHED */
-}
-
-/***====================================================================***/
-
-void
-uInternalError(const char *s, ...)
-{
-    va_list args;
-
-    if (!errorFile)
-        errorFile = stderr;
-
-    if ((outCount == 0) && (preMsg != NULL))
-        fprintf(errorFile, "%s\n", preMsg);
-    if (prefix != NULL)
-        fprintf(errorFile, "%s", prefix);
-    fprintf(errorFile, "Internal error:   ");
-    va_start(args, s);
-    vfprintf(errorFile, s, args);
-    va_end(args);
-    fflush(errorFile);
-    outCount++;
-}
-
-/***====================================================================***/
-
-#ifndef HAVE_STRCASECMP
-int
-uStrCaseCmp(const char *str1, const char *str2)
-{
-    char buf1[512], buf2[512];
-    char c, *s;
-    int n;
-
-    for (n = 0, s = buf1; (c = *str1++); n++)
-    {
-        if (isupper(c))
-            c = tolower(c);
-        if (n > 510)
-            break;
-        *s++ = c;
-    }
-    *s = '\0';
-    for (n = 0, s = buf2; (c = *str2++); n++)
-    {
-        if (isupper(c))
-            c = tolower(c);
-        if (n > 510)
-            break;
-        *s++ = c;
-    }
-    *s = '\0';
-    return (strcmp(buf1, buf2));
-}
-
-int
-uStrCasePrefix(const char *my_prefix, char *str)
-{
-    char c1;
-    char c2;
-    while (((c1 = *my_prefix) != '\0') && ((c2 = *str) != '\0'))
-    {
-        if (isupper(c1))
-            c1 = tolower(c1);
-        if (isupper(c2))
-            c2 = tolower(c2);
-        if (c1 != c2)
-            return 0;
-        my_prefix++;
-        str++;
-    }
-    if (c1 != '\0')
-        return 0;
-    return 1;
-}
-
-#endif
diff --git a/src/xkbcomp/utils.h b/src/xkbcomp/utils.h
deleted file mode 100644
index 020ed75..0000000
--- a/src/xkbcomp/utils.h
+++ /dev/null
@@ -1,163 +0,0 @@
-#ifndef UTILS_H
-#define	UTILS_H 1
-
-  /*\
-   *
-   *                          COPYRIGHT 1990
-   *                    DIGITAL EQUIPMENT CORPORATION
-   *                       MAYNARD, MASSACHUSETTS
-   *                        ALL RIGHTS RESERVED.
-   *
-   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
-   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
-   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
-   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
-   * WARRANTY.
-   *
-   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
-   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
-   * ADDITION TO THAT SET FORTH ABOVE.
-   *
-   * Permission to use, copy, modify, and distribute this software and its
-   * documentation for any purpose and without fee is hereby granted, provided
-   * that the above copyright notice appear in all copies and that both that
-   * copyright notice and this permission notice appear in supporting
-   * documentation, and that the name of Digital Equipment Corporation not be
-   * used in advertising or publicity pertaining to distribution of the
-   * software without specific, written prior permission.
-   \*/
-
-/***====================================================================***/
-
-#include 	<stdio.h>
-#include	<X11/Xos.h>
-#include	<X11/Xfuncproto.h>
-#include	<X11/Xfuncs.h>
-
-#include <stddef.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);
-
-#define	uTypedAlloc(t)		((t *)malloc((unsigned)sizeof(t)))
-#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
-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
-uInformation(const char *s, ...);
-
-#define ACTION			uAction
-
-extern __ATTR_PRINTF(1, 2) void
-uAction(const char *s, ...);
-
-#define WARN			uWarning
-
-extern __ATTR_PRINTF(1, 2) void
-uWarning(const char *s, ...);
-
-#define ERROR			uError
-
-extern __ATTR_PRINTF(1, 2) void
-uError(const char *s, ...);
-
-#define FATAL			uFatalError
-
-extern __ATTR_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
-uInternalError(const char *s, ...);
-
-/***====================================================================***/
-
-#define	NullString	((char *)NULL)
-
-#define	uStringText(s)		((s)==NullString?"<NullString>":(s))
-#define	uStringEqual(s1,s2)	(uStringCompare(s1,s2)==Equal)
-#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/test/filecomp.c b/test/filecomp.c
index facc02f..94c1bc1 100644
--- a/test/filecomp.c
+++ b/test/filecomp.c
@@ -31,7 +31,7 @@ authorization from the authors.
 #include <X11/X.h>
 #include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
-#include "xkbcomp/utils.h"
+#include "utils.h"
 
 static char buffer[8192];
 
diff --git a/test/namescomp.c b/test/namescomp.c
index b98ac7a..95dcecc 100644
--- a/test/namescomp.c
+++ b/test/namescomp.c
@@ -29,7 +29,7 @@ authorization from the authors.
 #include <X11/X.h>
 #include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
-#include "xkbcomp/utils.h"
+#include "utils.h"
 
 int main(int argc, char *argv[])
 {
diff --git a/test/rulescomp.c b/test/rulescomp.c
index fa0890a..0a84c94 100644
--- a/test/rulescomp.c
+++ b/test/rulescomp.c
@@ -29,7 +29,7 @@ authorization from the authors.
 #include <X11/X.h>
 #include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
-#include "xkbcomp/utils.h"
+#include "utils.h"
 
 int main(int argc, char *argv[])
 {
diff --git a/test/state.c b/test/state.c
index bc02148..476ee18 100644
--- a/test/state.c
+++ b/test/state.c
@@ -31,7 +31,7 @@
 #include <X11/keysym.h>
 #include <linux/input.h>
 #include "xkbcommon/xkbcommon.h"
-#include "xkbcomp/utils.h"
+#include "utils.h"
 #include "XKBcommonint.h"
 
 /* Offset between evdev keycodes (where KEY_ESCAPE is 1), and the evdev XKB