From 4962c5a8dee7bc2b903b9aafa27f4d0fd3c1d177 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 10:41:36 +0200 Subject: XKB: Remove a bunch of mad ifdefs commit 534fc5140b039a8c98ab715d0a6740d513b41209 Author: Daniel Stone Date: Sun Feb 3 23:30:22 2008 +1100 XKB: Remove a bunch of mad ifdefs We have SEEK_SET and size_t, seriously. Also use DebugF instead of ifdef DEBUG, and ditch a couple of random bits that were never used. --- nx-X11/programs/Xserver/xkb/maprules.c | 86 +++++++++++++--------------------- 1 file changed, 32 insertions(+), 54 deletions(-) (limited to 'nx-X11/programs/Xserver/xkb/maprules.c') diff --git a/nx-X11/programs/Xserver/xkb/maprules.c b/nx-X11/programs/Xserver/xkb/maprules.c index 295f1acf6..af6c112fe 100644 --- a/nx-X11/programs/Xserver/xkb/maprules.c +++ b/nx-X11/programs/Xserver/xkb/maprules.c @@ -48,16 +48,6 @@ #include "xkbstr.h" #include -#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 @@ -169,8 +159,8 @@ Bool endOfFile,spacePending,slashPending,inComment; } if (checkbang && ch=='!') { if (line->num_line!=0) { - PR_DEBUG("The '!' legal only at start of line\n"); - PR_DEBUG("Line containing '!' ignored\n"); + DebugF("The '!' legal only at start of line\n"); + DebugF("Line containing '!' ignored\n"); line->num_line= 0; inComment= 0; break; @@ -271,9 +261,7 @@ unsigned present, l_ndx_present, v_ndx_present; register int i; int len, ndx; _Xstrtokparams strtok_buf; -#ifdef DEBUG Bool found; -#endif l_ndx_present = v_ndx_present = present= 0; @@ -282,9 +270,7 @@ Bool found; bzero((char *)remap,sizeof(RemapSpec)); remap->number = len; while ((tok=_XStrtok(str," ",strtok_buf))!=NULL) { -#ifdef DEBUG found= False; -#endif str= NULL; if (strcmp(tok,"=")==0) continue; @@ -297,22 +283,20 @@ Bool found; *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", + DebugF("Illegal %s index: %d\n", cname[i], ndx); + DebugF("Index must be in range 1..%d\n", XkbNumKbdGroups); break; } } else { ndx = 0; } -#ifdef DEBUG found= True; -#endif if (present&(1<num_remap= 0; return; } if ((present&COMPONENT_MASK)==0) { - PR_DEBUG("Mapping needs at least one component\n"); - PR_DEBUG("Illegal mapping ignored\n"); + DebugF("Mapping needs at least one component\n"); + DebugF("Illegal mapping ignored\n"); remap->num_remap= 0; return; } if (((present&COMPONENT_MASK)&(1<num_remap= 0; return; } @@ -432,8 +412,8 @@ Bool append = False; } 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"); + DebugF("Must have a mapping before first line of data\n"); + DebugF("Illegal line of data ignored\n"); return False; } bzero((char *)&tmp,sizeof(FileSpec)); @@ -445,8 +425,8 @@ Bool append = False; continue; } if (nread>remap->num_remap) { - PR_DEBUG("Too many words on a line\n"); - PR_DEBUG1("Extra word \"%s\" ignored\n",tok); + DebugF("Too many words on a line\n"); + DebugF("Extra word \"%s\" ignored\n",tok); continue; } tmp.name[remap->remap[nread].word]= tok; @@ -454,8 +434,8 @@ Bool append = False; append = True; } if (nreadnum_remap) { - PR_DEBUG1("Too few words on a line: %s\n", line->line); - PR_DEBUG("line ignored\n"); + DebugF("Too few words on a line: %s\n", line->line); + DebugF("line ignored\n"); return False; } @@ -901,9 +881,7 @@ XkbRF_AddRule(XkbRF_RulesPtr rules) } if (!rules->rules) { rules->sz_rules= rules->num_rules= 0; -#ifdef DEBUG - fprintf(stderr,"Allocation failure in XkbRF_AddRule\n"); -#endif + DebugF("Allocation failure in XkbRF_AddRule\n"); return NULL; } bzero((char *)&rules->rules[rules->num_rules],sizeof(XkbRF_RuleRec)); @@ -1020,7 +998,7 @@ XkbRF_AddVarDesc(XkbRF_DescribeVarsPtr vars) } if (!vars->desc) { vars->sz_desc= vars->num_desc= 0; - PR_DEBUG("Allocation failure in XkbRF_AddVarDesc\n"); + DebugF("Allocation failure in XkbRF_AddVarDesc\n"); return NULL; } vars->desc[vars->num_desc].name= NULL; @@ -1057,7 +1035,7 @@ XkbRF_AddVarToDescribe(XkbRF_RulesPtr rules,char *name) XkbRF_DescribeVarsRec); } if ((!rules->extra_names)||(!rules->extra)) { - PR_DEBUG("allocation error in extra parts\n"); + DebugF("allocation error in extra parts\n"); rules->sz_extra= rules->num_extra= 0; rules->extra_names= NULL; rules->extra= NULL; @@ -1100,7 +1078,7 @@ int len,headingtype,extra_ndx = 0; } if (extra_ndx<0) { XkbRF_DescribeVarsPtr var; - PR_DEBUG1("Extra heading \"%s\" encountered\n",tok); + DebugF("Extra heading \"%s\" encountered\n",tok); var= XkbRF_AddVarToDescribe(rules,tok); if (var) extra_ndx= var-rules->extra; @@ -1111,20 +1089,20 @@ int len,headingtype,extra_ndx = 0; } if (headingtype == HEAD_NONE) { - PR_DEBUG("Must have a heading before first line of data\n"); - PR_DEBUG("Illegal line of data ignored\n"); + DebugF("Must have a heading before first line of data\n"); + DebugF("Illegal line of data ignored\n"); continue; } len = strlen(line.line); if ((tmp.name= strtok(line.line, " \t")) == NULL) { - PR_DEBUG("Huh? No token on line\n"); - PR_DEBUG("Illegal line of data ignored\n"); + DebugF("Huh? No token on line\n"); + DebugF("Illegal line of data ignored\n"); continue; } if (strlen(tmp.name) == len) { - PR_DEBUG("No description found\n"); - PR_DEBUG("Illegal line of data ignored\n"); + DebugF("No description found\n"); + DebugF("Illegal line of data ignored\n"); continue; } @@ -1132,8 +1110,8 @@ int len,headingtype,extra_ndx = 0; while ((*tok!='\n')&&isspace(*tok)) tok++; if (*tok == '\0') { - PR_DEBUG("No description found\n"); - PR_DEBUG("Illegal line of data ignored\n"); + DebugF("No description found\n"); + DebugF("Illegal line of data ignored\n"); continue; } tmp.desc= tok; -- cgit v1.2.3 From 054e906f6059366150bb7426973542203c8a0e4c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 10:57:09 +0200 Subject: xkb: Use snprintf to measure string lengths instead of manual strlen math commit a4a2e814d5d0e6152307a301eda1d6fc1c555aaa Author: Alan Coopersmith Date: Sun Feb 13 21:36:02 2011 -0800 xkb: Use snprintf to measure string lengths instead of manual strlen math Signed-off-by: Alan Coopersmith Signed-off-by: Peter Hutterer Reviewed-by: Daniel Stone --- nx-X11/programs/Xserver/xkb/maprules.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'nx-X11/programs/Xserver/xkb/maprules.c') diff --git a/nx-X11/programs/Xserver/xkb/maprules.c b/nx-X11/programs/Xserver/xkb/maprules.c index af6c112fe..6bc7e4022 100644 --- a/nx-X11/programs/Xserver/xkb/maprules.c +++ b/nx-X11/programs/Xserver/xkb/maprules.c @@ -953,9 +953,8 @@ Bool ok; if ((!base)||(!rules)) return False; if (locale) { - if (strlen(base)+strlen(locale)+2 > PATH_MAX) + if (snprintf(buf, PATH_MAX, "%s-%s", base, locale) >= PATH_MAX) return False; - sprintf(buf,"%s-%s", base, locale); } else { if (strlen(base)+1 > PATH_MAX) -- cgit v1.2.3