rules: don't use custom logging functions 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
diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c
index 48a3693..24e964e 100644
--- a/src/xkbcomp/rules.c
+++ b/src/xkbcomp/rules.c
@@ -30,18 +30,6 @@
#include "rules.h"
#include "path.h"
-#ifdef DEBUG
-#define PR_DEBUG(s) fprintf(stderr,s)
-#define PR_DEBUG1(s,a) fprintf(stderr,s,a)
-#define PR_DEBUG2(s,a,b) fprintf(stderr,s,a,b)
-#else
-#define PR_DEBUG(s)
-#define PR_DEBUG1(s,a)
-#define PR_DEBUG2(s,a,b)
-#endif
-
-/***====================================================================***/
-
#define DFLT_LINE_SIZE 128
typedef struct {
@@ -145,8 +133,8 @@ GetInputLine(FILE *file,InputLine *line,bool checkbang)
}
if (checkbang && ch=='!') {
if (line->num_line!=0) {
- PR_DEBUG("The '!' legal only at start of line\n");
- PR_DEBUG("Line containing '!' ignored\n");
+ WARN("The '!' legal only at start of line\n");
+ ACTION("Line containing '!' ignored\n");
line->num_line= 0;
break;
}
@@ -308,10 +296,7 @@ SetUpRemap(InputLine *line,RemapSpec *remap)
size_t len;
int ndx;
char *strtok_buf;
-#ifdef DEBUG
bool found;
-#endif
-
l_ndx_present = v_ndx_present = present= 0;
str= &line->line[1];
@@ -319,9 +304,7 @@ SetUpRemap(InputLine *line,RemapSpec *remap)
memset(remap, 0, sizeof(RemapSpec));
remap->number = len;
while ((tok = strtok_r(str, " ", &strtok_buf)) != NULL) {
-#ifdef DEBUG
found= false;
-#endif
str= NULL;
if (strcmp(tok,"=")==0)
continue;
@@ -334,22 +317,21 @@ SetUpRemap(InputLine *line,RemapSpec *remap)
*end != '\0' || ndx == -1)
break;
if (ndx < 1 || ndx > XkbNumKbdGroups) {
- PR_DEBUG2("Illegal %s index: %d\n", cname[i], ndx);
- PR_DEBUG1("Index must be in range 1..%d\n",
- XkbNumKbdGroups);
+ WARN("Illegal %s index: %d\n", cname[i], ndx);
+ WARN("Index must be in range 1..%d\n", XkbNumKbdGroups);
break;
}
} else {
ndx = 0;
}
-#ifdef DEBUG
+
found= true;
-#endif
+
if (present&(1<<i)) {
if ((i == LAYOUT && l_ndx_present&(1<<ndx)) ||
(i == VARIANT && v_ndx_present&(1<<ndx)) ) {
- PR_DEBUG1("Component \"%s\" listed twice\n",tok);
- PR_DEBUG("Second definition ignored\n");
+ WARN("Component \"%s\" listed twice\n", tok);
+ ACTION("Second definition ignored\n");
break;
}
}
@@ -363,16 +345,17 @@ SetUpRemap(InputLine *line,RemapSpec *remap)
break;
}
}
-#ifdef DEBUG
+
if (!found) {
- fprintf(stderr,"Unknown component \"%s\" ignored\n",tok);
+ WARN("Unknown component \"%s\"\n", tok);
+ ACTION("ignored\n");
}
-#endif
}
if ((present&PART_MASK)==0) {
-#ifdef DEBUG
unsigned mask= PART_MASK;
- fprintf(stderr,"Mapping needs at least one of ");
+
+ /* FIXME: Use log function instead of fprintf. */
+ WARN("Mapping needs at least one of ");
for (i=0; (i<MAX_WORDS); i++) {
if ((1L<<i)&mask) {
mask&= ~(1L<<i);
@@ -380,21 +363,21 @@ SetUpRemap(InputLine *line,RemapSpec *remap)
else fprintf(stderr,"or \"%s\"\n",cname[i]);
}
}
- fprintf(stderr,"Illegal mapping ignored\n");
-#endif
+ ACTION("Illegal mapping ignored\n");
+
remap->num_remap= 0;
return;
}
if ((present&COMPONENT_MASK)==0) {
- PR_DEBUG("Mapping needs at least one component\n");
- PR_DEBUG("Illegal mapping ignored\n");
+ WARN("Mapping needs at least one component\n");
+ ACTION("Illegal mapping ignored\n");
remap->num_remap= 0;
return;
}
if (((present&COMPONENT_MASK)&(1<<KEYMAP))&&
((present&COMPONENT_MASK)!=(1<<KEYMAP))) {
- PR_DEBUG("Keymap cannot appear with other components\n");
- PR_DEBUG("Illegal mapping ignored\n");
+ WARN("Keymap cannot appear with other components\n");
+ ACTION("Illegal mapping ignored\n");
remap->num_remap= 0;
return;
}
@@ -468,8 +451,8 @@ CheckLine( InputLine * line,
}
if (remap->num_remap==0) {
- PR_DEBUG("Must have a mapping before first line of data\n");
- PR_DEBUG("Illegal line of data ignored\n");
+ WARN("Must have a mapping before first line of data\n");
+ ACTION("Illegal line of data ignored\n");
return false;
}
memset(&tmp, 0, sizeof(FileSpec));
@@ -481,8 +464,8 @@ CheckLine( InputLine * line,
continue;
}
if (nread>remap->num_remap) {
- PR_DEBUG("Too many words on a line\n");
- PR_DEBUG1("Extra word \"%s\" ignored\n",tok);
+ WARN("Too many words on a line\n");
+ ACTION("Extra word \"%s\" ignored\n",tok);
continue;
}
tmp.name[remap->remap[nread].word]= tok;
@@ -490,8 +473,8 @@ CheckLine( InputLine * line,
append = true;
}
if (nread<remap->num_remap) {
- PR_DEBUG1("Too few words on a line: %s\n", line->line);
- PR_DEBUG("line ignored\n");
+ WARN("Too few words on a line: %s\n", line->line);
+ ACTION("line ignored\n");
return false;
}