aboutsummaryrefslogtreecommitdiff
path: root/xkbcomp
diff options
context:
space:
mode:
Diffstat (limited to 'xkbcomp')
-rw-r--r--xkbcomp/action.c8
-rw-r--r--xkbcomp/action.h4
-rw-r--r--xkbcomp/compat.c2
-rw-r--r--xkbcomp/expr.c14
-rw-r--r--xkbcomp/geometry.c36
-rw-r--r--xkbcomp/indicators.c2
-rw-r--r--xkbcomp/indicators.h2
-rw-r--r--xkbcomp/keytypes.c2
-rw-r--r--xkbcomp/listing.c9
-rw-r--r--xkbcomp/symbols.c8
-rw-r--r--xkbcomp/utils.c59
-rw-r--r--xkbcomp/utils.h69
-rw-r--r--xkbcomp/xkbcomp.c5
13 files changed, 46 insertions, 174 deletions
diff --git a/xkbcomp/action.c b/xkbcomp/action.c
index 3b82e647e..4623c0caf 100644
--- a/xkbcomp/action.c
+++ b/xkbcomp/action.c
@@ -41,7 +41,7 @@ static ExprDef constFalse;
/***====================================================================***/
static Bool
-stringToAction(char *str, unsigned *type_rtrn)
+stringToAction(const char *str, unsigned *type_rtrn)
{
if (str == NULL)
return False;
@@ -134,7 +134,7 @@ stringToAction(char *str, unsigned *type_rtrn)
}
static Bool
-stringToField(char *str, unsigned *field_rtrn)
+stringToField(const char *str, unsigned *field_rtrn)
{
if (str == NULL)
@@ -1397,8 +1397,8 @@ HandleActionDef(ExprDef * def,
int
SetActionField(XkbDescPtr xkb,
- char *elem,
- char *field,
+ const char *elem,
+ const char *field,
ExprDef * array_ndx, ExprDef * value, ActionInfo ** info_rtrn)
{
ActionInfo *new, *old;
diff --git a/xkbcomp/action.h b/xkbcomp/action.h
index 2fb7a5eb9..983b06e20 100644
--- a/xkbcomp/action.h
+++ b/xkbcomp/action.h
@@ -72,8 +72,8 @@ extern int HandleActionDef(ExprDef * /* def */ ,
);
extern int SetActionField(XkbDescPtr /* xkb */ ,
- char * /* elem */ ,
- char * /* field */ ,
+ const char * /* elem */ ,
+ const char * /* field */ ,
ExprDef * /* index */ ,
ExprDef * /* value */ ,
ActionInfo ** /* info_rtrn */
diff --git a/xkbcomp/compat.c b/xkbcomp/compat.c
index ab84eb4d3..3dd76581c 100644
--- a/xkbcomp/compat.c
+++ b/xkbcomp/compat.c
@@ -494,7 +494,7 @@ static LookupEntry useModMapValues[] = {
static int
SetInterpField(SymInterpInfo * si,
XkbDescPtr xkb,
- char *field,
+ const char *field,
ExprDef * arrayNdx, ExprDef * value, CompatInfo * info)
{
int ok = 1;
diff --git a/xkbcomp/expr.c b/xkbcomp/expr.c
index 96fd95675..e0f957c15 100644
--- a/xkbcomp/expr.c
+++ b/xkbcomp/expr.c
@@ -292,7 +292,7 @@ ExprResolveModIndex(ExprDef * expr,
IdentLookupFunc lookup, XPointer lookupPriv)
{
int ok = 0;
- char *bogus = NULL;
+ const char *bogus = NULL;
switch (expr->op)
{
@@ -382,7 +382,7 @@ ExprResolveBoolean(ExprDef * expr,
IdentLookupFunc lookup, XPointer lookupPriv)
{
int ok = 0;
- char *bogus = NULL;
+ const char *bogus = NULL;
switch (expr->op)
{
@@ -715,7 +715,7 @@ ExprResolveString(ExprDef * expr,
ExprResult leftRtrn, rightRtrn;
ExprDef *left;
ExprDef *right;
- char *bogus = NULL;
+ const char *bogus = NULL;
switch (expr->op)
{
@@ -729,7 +729,7 @@ ExprResolveString(ExprDef * expr,
val_rtrn->str = XkbAtomGetString(NULL, expr->value.str);
if (val_rtrn->str == NULL)
{
- static char *empty = "";
+ static const char *empty = "";
val_rtrn->str = empty;
}
return True;
@@ -767,7 +767,7 @@ ExprResolveString(ExprDef * expr,
new = (char *) uAlloc(len);
if (new)
{
- sprintf(new, "%s%s", leftRtrn.str, rightRtrn.str);
+ snprintf(new, len, "%s%s", leftRtrn.str, rightRtrn.str);
val_rtrn->str = new;
return True;
}
@@ -822,7 +822,7 @@ ExprResolveKeyName(ExprDef * expr,
int ok = 0;
ExprDef *left;
ExprResult leftRtrn;
- char *bogus = NULL;
+ const char *bogus = NULL;
switch (expr->op)
{
@@ -941,7 +941,7 @@ ExprResolveMask(ExprDef * expr,
int ok = 0;
ExprResult leftRtrn, rightRtrn;
ExprDef *left, *right;
- char *bogus = NULL;
+ const char *bogus = NULL;
switch (expr->op)
{
diff --git a/xkbcomp/geometry.c b/xkbcomp/geometry.c
index 7f65c3af4..2daa213ac 100644
--- a/xkbcomp/geometry.c
+++ b/xkbcomp/geometry.c
@@ -258,9 +258,9 @@ ddText(Display * dpy, DoodadInfo * di)
}
if (di->section)
{
- sprintf(buf, "%s in section %s",
- XkbAtomText(dpy, di->name, XkbMessage), scText(dpy,
- di->section));
+ snprintf(buf, sizeof(buf), "%s in section %s",
+ XkbAtomText(dpy, di->name, XkbMessage),
+ scText(dpy, di->section));
return buf;
}
return XkbAtomText(dpy, di->name, XkbMessage);
@@ -967,7 +967,7 @@ AddDoodad(SectionInfo * si, GeometryInfo * info, DoodadInfo * new)
}
static DoodadInfo *
-FindDfltDoodadByTypeName(char *name, SectionInfo * si, GeometryInfo * info)
+FindDfltDoodadByTypeName(const char *name, SectionInfo *si, GeometryInfo *info)
{
DoodadInfo *dflt;
unsigned type;
@@ -1408,7 +1408,7 @@ HandleIncludeGeometry(IncludeStmt * stmt, XkbDescPtr xkb, GeometryInfo * info,
static int
SetShapeField(ShapeInfo * si,
- char *field,
+ const char *field,
ExprDef * arrayNdx, ExprDef * value, GeometryInfo * info)
{
ExprResult tmp;
@@ -1440,7 +1440,7 @@ SetShapeField(ShapeInfo * si,
static int
SetShapeDoodadField(DoodadInfo * di,
- char *field,
+ const char *field,
ExprDef * arrayNdx,
ExprDef * value, SectionInfo * si, GeometryInfo * info)
{
@@ -1510,14 +1510,14 @@ SetShapeDoodadField(DoodadInfo * di,
static int
SetTextDoodadField(DoodadInfo * di,
- char *field,
+ const char *field,
ExprDef * arrayNdx,
ExprDef * value, SectionInfo * si, GeometryInfo * info)
{
ExprResult tmp;
unsigned def;
unsigned type;
- char *typeName = "text doodad";
+ const char *typeName = "text doodad";
union
{
Atom *str;
@@ -1660,7 +1660,7 @@ SetTextDoodadField(DoodadInfo * di,
static int
SetIndicatorDoodadField(DoodadInfo * di,
- char *field,
+ const char *field,
ExprDef * arrayNdx,
ExprDef * value,
SectionInfo * si, GeometryInfo * info)
@@ -1705,12 +1705,12 @@ SetIndicatorDoodadField(DoodadInfo * di,
static int
SetLogoDoodadField(DoodadInfo * di,
- char *field,
+ const char *field,
ExprDef * arrayNdx,
ExprDef * value, SectionInfo * si, GeometryInfo * info)
{
ExprResult tmp;
- char *typeName = "logo doodad";
+ const char *typeName = "logo doodad";
if ((!uStrCaseCmp(field, "corner"))
|| (!uStrCaseCmp(field, "cornerradius")))
@@ -1786,7 +1786,7 @@ SetLogoDoodadField(DoodadInfo * di,
static int
SetDoodadField(DoodadInfo * di,
- char *field,
+ const char *field,
ExprDef * arrayNdx,
ExprDef * value, SectionInfo * si, GeometryInfo * info)
{
@@ -1889,7 +1889,7 @@ SetDoodadField(DoodadInfo * di,
static int
SetSectionField(SectionInfo * si,
- char *field,
+ const char *field,
ExprDef * arrayNdx, ExprDef * value, GeometryInfo * info)
{
unsigned short *pField;
@@ -1977,7 +1977,7 @@ SetSectionField(SectionInfo * si,
static int
SetRowField(RowInfo * row,
- char *field,
+ const char *field,
ExprDef * arrayNdx, ExprDef * value, GeometryInfo * info)
{
ExprResult tmp;
@@ -2841,7 +2841,7 @@ HandleGeometryFile(XkbFile * file,
XkbDescPtr xkb, unsigned merge, GeometryInfo * info)
{
ParseCommon *stmt;
- char *failWhat;
+ const char *failWhat;
if (merge == MergeDefault)
merge = MergeAugment;
@@ -3273,7 +3273,7 @@ FontFromParts(Atom fontTok,
Atom setWidthTok, Atom varTok, int size, Atom encodingTok)
{
int totalSize;
- char *font, *weight, *slant, *setWidth, *variant, *encoding;
+ const char *font, *weight, *slant, *setWidth, *variant, *encoding;
char *rtrn;
font = (fontTok != None ? XkbAtomGetString(NULL, fontTok) : DFLT_FONT);
@@ -3297,8 +3297,8 @@ FontFromParts(Atom fontTok,
rtrn = uCalloc(totalSize, 1);
if (rtrn)
{
- sprintf(rtrn, FONT_TEMPLATE, font, weight, slant, setWidth, variant,
- size, encoding);
+ snprintf(rtrn, totalSize, FONT_TEMPLATE, font, weight, slant,
+ setWidth, variant, size, encoding);
}
return rtrn;
}
diff --git a/xkbcomp/indicators.c b/xkbcomp/indicators.c
index d4a362fb8..421ad583d 100644
--- a/xkbcomp/indicators.c
+++ b/xkbcomp/indicators.c
@@ -200,7 +200,7 @@ static LookupEntry groupComponentNames[] = {
int
SetIndicatorMapField(LEDInfo * led,
XkbDescPtr xkb,
- char *field, ExprDef * arrayNdx, ExprDef * value)
+ const char *field, ExprDef *arrayNdx, ExprDef *value)
{
ExprResult rtrn;
Bool ok;
diff --git a/xkbcomp/indicators.h b/xkbcomp/indicators.h
index 35ae38a4c..8e7884d7c 100644
--- a/xkbcomp/indicators.h
+++ b/xkbcomp/indicators.h
@@ -62,7 +62,7 @@ extern LEDInfo *AddIndicatorMap(LEDInfo * /* oldLEDs */ ,
extern int SetIndicatorMapField(LEDInfo * /* led */ ,
XkbDescPtr /* xkb */ ,
- char * /* field */ ,
+ const char * /* field */ ,
ExprDef * /* arrayNdx */ ,
ExprDef * /* value */
);
diff --git a/xkbcomp/keytypes.c b/xkbcomp/keytypes.c
index da55d755d..375ca3e0d 100644
--- a/xkbcomp/keytypes.c
+++ b/xkbcomp/keytypes.c
@@ -879,7 +879,7 @@ SetLevelName(KeyTypeInfo * type, ExprDef * arrayNdx, ExprDef * value)
static Bool
SetKeyTypeField(KeyTypeInfo * type,
XkbDescPtr xkb,
- char *field,
+ const char *field,
ExprDef * arrayNdx, ExprDef * value, KeyTypesInfo * info)
{
ExprResult tmp;
diff --git a/xkbcomp/listing.c b/xkbcomp/listing.c
index c05c3c65c..86c1dfb8b 100644
--- a/xkbcomp/listing.c
+++ b/xkbcomp/listing.c
@@ -312,18 +312,19 @@ AddDirectory(char *head, char *ptrn, char *rest, char *map)
{
char *tmp, *filename;
struct stat sbuf;
+ size_t tmpsize;
filename = FileName(file);
if (!filename || filename[0] == '.')
continue;
if (ptrn && (!XkbNameMatchesPattern(filename, ptrn)))
continue;
- tmp =
- (char *) uAlloc((head ? strlen(head) : 0) + strlen(filename) + 2);
+ tmpsize = (head ? strlen(head) : 0) + strlen(filename) + 2;
+ tmp = uAlloc(tmpsize);
if (!tmp)
continue;
- sprintf(tmp, "%s%s%s", (head ? head : ""), (head ? "/" : ""),
- filename);
+ snprintf(tmp, tmpsize, "%s%s%s",
+ (head ? head : ""), (head ? "/" : ""), filename);
if (stat(tmp, &sbuf) < 0)
{
uFree(tmp);
diff --git a/xkbcomp/symbols.c b/xkbcomp/symbols.c
index 5547999b5..d43ba9ffb 100644
--- a/xkbcomp/symbols.c
+++ b/xkbcomp/symbols.c
@@ -928,7 +928,7 @@ GetGroupIndex(KeyInfo * key,
static Bool
AddSymbolsToKey(KeyInfo * key,
XkbDescPtr xkb,
- char *field,
+ const char *field,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
{
unsigned ndx, nSyms;
@@ -982,7 +982,7 @@ AddSymbolsToKey(KeyInfo * key,
static Bool
AddActionsToKey(KeyInfo * key,
XkbDescPtr xkb,
- char *field,
+ const char *field,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
{
register int i;
@@ -1118,7 +1118,7 @@ static LookupEntry rgEntries[] = {
static Bool
SetSymbolsField(KeyInfo * key,
XkbDescPtr xkb,
- char *field,
+ const char *field,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
{
Bool ok = True;
@@ -1235,7 +1235,7 @@ SetSymbolsField(KeyInfo * key,
uStrCasePrefix("permanentoverlay", field))
{
Bool permanent = False;
- char *which;
+ const char *which;
int overlayNdx;
if (uStrCasePrefix("permanent", field))
{
diff --git a/xkbcomp/utils.c b/xkbcomp/utils.c
index 55efbe11f..541c33e14 100644
--- a/xkbcomp/utils.c
+++ b/xkbcomp/utils.c
@@ -88,65 +88,6 @@ uFree(Opaque ptr)
}
/***====================================================================***/
-/*** FUNCTION ENTRY TRACKING ***/
-/***====================================================================***/
-
-static FILE *entryFile = NULL;
-int uEntryLevel;
-
-Boolean
-uSetEntryFile(char *name)
-{
- if ((entryFile != NULL) && (entryFile != stderr))
- {
- fprintf(entryFile, "switching to %s\n", name ? name : "stderr");
- fclose(entryFile);
- }
- if (name != NullString)
- entryFile = fopen(name, "w");
- else
- entryFile = stderr;
- if (entryFile == NULL)
- {
- entryFile = stderr;
- return (False);
- }
- return (True);
-}
-
-void
-uEntry(int l, char *s, ...)
-{
- int i;
- va_list args;
-
- for (i = 0; i < uEntryLevel; i++)
- {
- putc(' ', entryFile);
- }
- va_start(args, s);
- vfprintf(entryFile, s, args);
- va_end(args);
- uEntryLevel += l;
-}
-
-void
-uExit(int l, char *rtVal)
-{
- int i;
-
- uEntryLevel -= l;
- if (uEntryLevel < 0)
- uEntryLevel = 0;
- for (i = 0; i < uEntryLevel; i++)
- {
- putc(' ', entryFile);
- }
- fprintf(entryFile, "---> %p\n", rtVal);
- return;
-}
-
-/***====================================================================***/
/*** PRINT FUNCTIONS ***/
/***====================================================================***/
diff --git a/xkbcomp/utils.h b/xkbcomp/utils.h
index ea9d1deaa..b644f7d3a 100644
--- a/xkbcomp/utils.h
+++ b/xkbcomp/utils.h
@@ -223,15 +223,6 @@ uInformation(const char * /* s */ , ...
/***====================================================================***/
-#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
@@ -281,64 +272,4 @@ extern
#define uDEBUG_NOI5(f,s,a,b,c,d,e)
#endif
- extern Boolean uSetEntryFile(char *name);
- extern void uEntry(int /* l */ ,
- char * /* s */ , ...
- ) _X_ATTRIBUTE_PRINTF(2, 3);
-
- extern void uExit(int l, char *rtVal);
-#ifdef ENTRY_TRACKING_ON
-#define ENTRY_BIT 0x10
-#define LOW_ENTRY_BIT 0x1000
-#define ENTER (DEBUG_VAR&ENTRY_BIT)
-#define FLAG(fLag) (DEBUG_VAR&(fLag))
-
- extern int uEntryLevel;
-
-#define uENTRY(s) { if (ENTER) uEntry(1,s);}
-#define uENTRY1(s,a) { if (ENTER) uEntry(1,s,a);}
-#define uENTRY2(s,a,b) { if (ENTER) uEntry(1,s,a,b);}
-#define uENTRY3(s,a,b,c) { if (ENTER) uEntry(1,s,a,b,c);}
-#define uENTRY4(s,a,b,c,d) { if (ENTER) uEntry(1,s,a,b,c,d);}
-#define uENTRY5(s,a,b,c,d,e) { if (ENTER) uEntry(1,s,a,b,c,d,e);}
-#define uENTRY6(s,a,b,c,d,e,f) { if (ENTER) uEntry(1,s,a,b,c,d,e,f);}
-#define uENTRY7(s,a,b,c,d,e,f,g) { if (ENTER) uEntry(1,s,a,b,c,d,e,f,g);}
-#define uRETURN(v) { if (ENTER) uEntryLevel--; return(v); }
-#define uVOIDRETURN { if (ENTER) uEntryLevel--; return; }
-
-#define uFLAG_ENTRY(w,s) { if (FLAG(w)) uEntry(0,s);}
-#define uFLAG_ENTRY1(w,s,a) { if (FLAG(w)) uEntry(0,s,a);}
-#define uFLAG_ENTRY2(w,s,a,b) { if (FLAG(w)) uEntry(0,s,a,b);}
-#define uFLAG_ENTRY3(w,s,a,b,c) { if (FLAG(w)) uEntry(0,s,a,b,c);}
-#define uFLAG_ENTRY4(w,s,a,b,c,d) { if (FLAG(w)) uEntry(0,s,a,b,c,d);}
-#define uFLAG_ENTRY5(w,s,a,b,c,d,e) { if (FLAG(w)) uEntry(0,s,a,b,c,d,e);}
-#define uFLAG_ENTRY6(w,s,a,b,c,d,e,f) { if (FLAG(w)) uEntry(0,s,a,b,c,d,e,f);}
-#define uFLAG_ENTRY7(w,s,a,b,c,d,e,f,g) { if(FLAG(w))uEntry(0,s,a,b,c,d,e,f,g);}
-#define uFLAG_RETURN(v) { return(v);}
-#define uFLAG_VOIDRETURN { return; }
-#else
-#define uENTRY(s)
-#define uENTRY1(s,a)
-#define uENTRY2(s,a1,a2)
-#define uENTRY3(s,a1,a2,a3)
-#define uENTRY4(s,a1,a2,a3,a4)
-#define uENTRY5(s,a1,a2,a3,a4,a5)
-#define uENTRY6(s,a1,a2,a3,a4,a5,a6)
-#define uENTRY7(s,a1,a2,a3,a4,a5,a6,a7)
-#define uRETURN(v) { return(v); }
-#define uVOIDRETURN { return; }
-
-#define uFLAG_ENTRY(f,s)
-#define uFLAG_ENTRY1(f,s,a)
-#define uFLAG_ENTRY2(f,s,a,b)
-#define uFLAG_ENTRY3(f,s,a,b,c)
-#define uFLAG_ENTRY4(f,s,a,b,c,d)
-#define uFLAG_ENTRY5(f,s,a,b,c,d,e)
-#define uFLAG_ENTRY6(f,s,a,b,c,d,e,g)
-#define uFLAG_ENTRY7(f,s,a,b,c,d,e,g,h)
-#define uFLAG_RETURN(v) { return(v);}
-#define uFLAG_VOIDRETURN { return; }
-#endif
-
-
#endif /* UTILS_H */
diff --git a/xkbcomp/xkbcomp.c b/xkbcomp/xkbcomp.c
index 4e00c2ad6..7947ad417 100644
--- a/xkbcomp/xkbcomp.c
+++ b/xkbcomp/xkbcomp.c
@@ -745,7 +745,7 @@ parseArgs(int argc, char *argv[])
ACTION("Exiting\n");
exit(1);
}
- sprintf(outputFile, "stdin.%s", fileTypeExt[outputFormat]);
+ snprintf(outputFile, len, "stdin.%s", fileTypeExt[outputFormat]);
}
else if ((outputFile == NULL) && (inputFile != NULL))
{
@@ -773,7 +773,7 @@ parseArgs(int argc, char *argv[])
}
ext = strrchr(base, '.');
if (ext == NULL)
- sprintf(outputFile, "%s.%s", base, fileTypeExt[outputFormat]);
+ snprintf(outputFile, len, "%s.%s", base, fileTypeExt[outputFormat]);
else
{
strcpy(outputFile, base);
@@ -881,7 +881,6 @@ main(int argc, char *argv[])
Status status;
scan_set_file(stdin);
- uSetEntryFile(NullString);
uSetDebugFile(NullString);
uSetErrorFile(NullString);