aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/xkb
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/xkb')
-rw-r--r--xorg-server/xkb/ddxList.c2
-rw-r--r--xorg-server/xkb/ddxLoad.c6
-rw-r--r--xorg-server/xkb/maprules.c5
-rw-r--r--xorg-server/xkb/xkbInit.c25
-rw-r--r--xorg-server/xkb/xkbfmisc.c2
-rw-r--r--xorg-server/xkb/xkbout.c6
-rw-r--r--xorg-server/xkb/xkbtext.c189
7 files changed, 109 insertions, 126 deletions
diff --git a/xorg-server/xkb/ddxList.c b/xorg-server/xkb/ddxList.c
index e599f9169..db34c8df5 100644
--- a/xorg-server/xkb/ddxList.c
+++ b/xorg-server/xkb/ddxList.c
@@ -60,7 +60,7 @@ extern int Win32System(const char *cmdline);
/***====================================================================***/
-static char *componentDirs[_XkbListNumComponents] = {
+static const char *componentDirs[_XkbListNumComponents] = {
"keycodes", "types", "compat", "symbols", "geometry"
};
diff --git a/xorg-server/xkb/ddxLoad.c b/xorg-server/xkb/ddxLoad.c
index 219d39c9a..196142318 100644
--- a/xorg-server/xkb/ddxLoad.c
+++ b/xorg-server/xkb/ddxLoad.c
@@ -263,8 +263,7 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
if (xkbDebugFlags)
DebugF("[xkb] xkb executes: %s\n",buf);
if (nameRtrn) {
- strncpy(nameRtrn,keymap,nameRtrnLen);
- nameRtrn[nameRtrnLen-1]= '\0';
+ strlcpy(nameRtrn,keymap,nameRtrnLen);
}
free(buf);
#ifdef WIN32
@@ -322,8 +321,7 @@ FILE * file;
}
else file= NULL;
if ((fileNameRtrn!=NULL)&&(fileNameRtrnLen>0)) {
- strncpy(fileNameRtrn,buf,fileNameRtrnLen);
- buf[fileNameRtrnLen-1]= '\0';
+ strlcpy(fileNameRtrn,buf,fileNameRtrnLen);
}
return file;
}
diff --git a/xorg-server/xkb/maprules.c b/xorg-server/xkb/maprules.c
index f94089982..66800478c 100644
--- a/xorg-server/xkb/maprules.c
+++ b/xorg-server/xkb/maprules.c
@@ -200,7 +200,7 @@ Bool endOfFile,spacePending,slashPending,inComment;
#define PART_MASK 0x000F
#define COMPONENT_MASK 0x03F0
-static char * cname[MAX_WORDS] = {
+static const char * cname[MAX_WORDS] = {
"model", "layout", "variant", "option",
"keycodes", "symbols", "types", "compat", "geometry"
};
@@ -250,8 +250,7 @@ get_index(char *str, int *ndx)
*ndx = -1;
return end + 1;
}
- strncpy(ndx_buf, str, end - str);
- ndx_buf[end - str] = '\0';
+ strlcpy(ndx_buf, str, 1 + end - str);
*ndx = atoi(ndx_buf);
return end + 1;
}
diff --git a/xorg-server/xkb/xkbInit.c b/xorg-server/xkb/xkbInit.c
index 3d3febb4f..f578f1679 100644
--- a/xorg-server/xkb/xkbInit.c
+++ b/xorg-server/xkb/xkbInit.c
@@ -88,8 +88,8 @@ typedef struct _SrvXkmInfo {
#define XKB_DFLT_RULES_PROP TRUE
#endif
-char * XkbBaseDirectory= XKB_BASE_DIRECTORY;
-char * XkbBinDirectory= XKB_BIN_DIRECTORY;
+const char * XkbBaseDirectory= XKB_BASE_DIRECTORY;
+const char * XkbBinDirectory= XKB_BIN_DIRECTORY;
static int XkbWantAccessX= 0;
static char * XkbRulesDflt= NULL;
@@ -117,22 +117,11 @@ static Bool XkbWantRulesProp= XKB_DFLT_RULES_PROP;
void
XkbGetRulesDflts(XkbRMLVOSet *rmlvo)
{
- if (XkbRulesDflt) rmlvo->rules = XkbRulesDflt;
- else rmlvo->rules = XKB_DFLT_RULES;
- if (XkbModelDflt) rmlvo->model= XkbModelDflt;
- else rmlvo->model= XKB_DFLT_MODEL;
- if (XkbLayoutDflt) rmlvo->layout= XkbLayoutDflt;
- else rmlvo->layout= XKB_DFLT_LAYOUT;
- if (XkbVariantDflt) rmlvo->variant= XkbVariantDflt;
- else rmlvo->variant= XKB_DFLT_VARIANT;
- if (XkbOptionsDflt) rmlvo->options= XkbOptionsDflt;
- else rmlvo->options= XKB_DFLT_OPTIONS;
-
- rmlvo->rules = strdup(rmlvo->rules);
- rmlvo->model = strdup(rmlvo->model);
- rmlvo->layout = strdup(rmlvo->layout);
- rmlvo->variant = strdup(rmlvo->variant);
- rmlvo->options = strdup(rmlvo->options);
+ rmlvo->rules = strdup(XkbRulesDflt ? XkbRulesDflt : XKB_DFLT_RULES);
+ rmlvo->model = strdup(XkbModelDflt ? XkbModelDflt : XKB_DFLT_MODEL);
+ rmlvo->layout = strdup(XkbLayoutDflt ? XkbLayoutDflt : XKB_DFLT_LAYOUT);
+ rmlvo->variant= strdup(XkbVariantDflt ? XkbVariantDflt : XKB_DFLT_VARIANT);
+ rmlvo->options= strdup(XkbOptionsDflt ? XkbOptionsDflt : XKB_DFLT_OPTIONS);
}
void
diff --git a/xorg-server/xkb/xkbfmisc.c b/xorg-server/xkb/xkbfmisc.c
index d8202b496..782b823bb 100644
--- a/xorg-server/xkb/xkbfmisc.c
+++ b/xorg-server/xkb/xkbfmisc.c
@@ -146,7 +146,7 @@ unsigned set,rtrn;
/***===================================================================***/
static Bool
-XkbWriteSectionFromName(FILE *file,char *sectionName,char *name)
+XkbWriteSectionFromName(FILE *file,const char *sectionName,const char *name)
{
fprintf(file," xkb_%-20s { include \"%s\" };\n",sectionName,name);
return TRUE;
diff --git a/xorg-server/xkb/xkbout.c b/xorg-server/xkb/xkbout.c
index 082c85ee9..889d5cc39 100644
--- a/xorg-server/xkb/xkbout.c
+++ b/xorg-server/xkb/xkbout.c
@@ -108,7 +108,7 @@ XkbWriteXKBKeycodes( FILE * file,
{
Atom kcName;
register unsigned i;
-char * alternate;
+const char * alternate;
if ((!xkb)||(!xkb->names)||(!xkb->names->keys)) {
_XkbLibError(_XkbErrMissingNames,"XkbWriteXKBKeycodes",0);
@@ -133,7 +133,7 @@ char * alternate;
}
if (xkb->indicators!=NULL) {
for (i=0;i<XkbNumIndicators;i++) {
- char *type;
+ const char *type;
if (xkb->indicators->phys_indicators&(1<<i))
type= " ";
else type= " virtual ";
@@ -395,7 +395,7 @@ Bool showActions;
(showImplicit)) {
int typeNdx,g;
Bool multi;
- char * comment=" ";
+ const char * comment=" ";
if ((srv->explicit[i]&XkbExplicitKeyTypesMask)==0)
comment= "//";
diff --git a/xorg-server/xkb/xkbtext.c b/xorg-server/xkb/xkbtext.c
index 9f49d59ff..8ef2b05b0 100644
--- a/xorg-server/xkb/xkbtext.c
+++ b/xorg-server/xkb/xkbtext.c
@@ -81,8 +81,7 @@ char *rtrn,*tmp;
if (len>BUFFER_SIZE)
len= BUFFER_SIZE-2;
rtrn= tbGetBuffer(len);
- strncpy(rtrn,atmstr,len);
- rtrn[len]= '\0';
+ strlcpy(rtrn,atmstr,len);
}
else {
rtrn= tbGetBuffer(1);
@@ -120,7 +119,7 @@ char numBuf[20];
else if (vmodNames&&(vmodNames[ndx]!=None))
tmp= NameForAtom(vmodNames[ndx]);
if (tmp==NULL) {
- sprintf(numBuf,"%d",ndx);
+ snprintf(numBuf,sizeof(numBuf),"%d",ndx);
tmp = numBuf;
}
@@ -216,7 +215,7 @@ char *str,buf[BUFFER_SIZE];
return rtrn;
}
-static char *modNames[XkbNumModifiers] = {
+static const char *modNames[XkbNumModifiers] = {
"Shift", "Lock", "Control", "Mod1", "Mod2", "Mod3", "Mod4", "Mod5"
};
@@ -228,17 +227,17 @@ char buf[100];
if (format==XkbCFile) {
if (ndx<XkbNumModifiers)
- sprintf(buf,"%sMapIndex",modNames[ndx]);
+ snprintf(buf,sizeof(buf),"%sMapIndex",modNames[ndx]);
else if (ndx==XkbNoModifier)
- sprintf(buf,"XkbNoModifier");
- else sprintf(buf,"0x%02x",ndx);
+ snprintf(buf,sizeof(buf),"XkbNoModifier");
+ else snprintf(buf,sizeof(buf),"0x%02x",ndx);
}
else {
if (ndx<XkbNumModifiers)
strcpy(buf,modNames[ndx]);
else if (ndx==XkbNoModifier)
strcpy(buf,"none");
- else sprintf(buf,"ILLEGAL_%02x",ndx);
+ else snprintf(buf,sizeof(buf),"ILLEGAL_%02x",ndx);
}
rtrn= tbGetBuffer(strlen(buf)+1);
strcpy(rtrn,buf);
@@ -335,12 +334,12 @@ static char *buf;
char *
XkbKeysymText(KeySym sym,unsigned format)
{
-static char buf[32],*rtrn;
+static char buf[32];
if (sym==NoSymbol)
- strcpy(rtrn=buf,"NoSymbol");
- else sprintf(rtrn=buf, "0x%lx", (long)sym);
- return rtrn;
+ strcpy(buf,"NoSymbol");
+ else snprintf(buf, sizeof(buf), "0x%lx", (long)sym);
+ return buf;
}
char *
@@ -368,15 +367,15 @@ char *buf;
/***====================================================================***/
-static char *siMatchText[5] = {
+static const char *siMatchText[5] = {
"NoneOf", "AnyOfOrNone", "AnyOf", "AllOf", "Exactly"
};
-char *
+const char *
XkbSIMatchText(unsigned type,unsigned format)
{
static char buf[40];
-char *rtrn;
+const char *rtrn;
switch (type&XkbSI_OpMask) {
case XkbSI_NoneOf: rtrn= siMatchText[0]; break;
@@ -384,13 +383,13 @@ char *rtrn;
case XkbSI_AnyOf: rtrn= siMatchText[2]; break;
case XkbSI_AllOf: rtrn= siMatchText[3]; break;
case XkbSI_Exactly: rtrn= siMatchText[4]; break;
- default: sprintf(buf,"0x%x",type&XkbSI_OpMask);
+ default: snprintf(buf,sizeof(buf),"0x%x",type&XkbSI_OpMask);
return buf;
}
if (format==XkbCFile) {
if (type&XkbSI_LevelOneOnly)
- sprintf(buf,"XkbSI_LevelOneOnly|XkbSI_%s",rtrn);
- else sprintf(buf,"XkbSI_%s",rtrn);
+ snprintf(buf,sizeof(buf),"XkbSI_LevelOneOnly|XkbSI_%s",rtrn);
+ else snprintf(buf,sizeof(buf),"XkbSI_%s",rtrn);
rtrn= buf;
}
return rtrn;
@@ -398,7 +397,7 @@ char *rtrn;
/***====================================================================***/
-static char *imWhichNames[]= {
+static const char *imWhichNames[]= {
"base",
"latched",
"locked",
@@ -449,7 +448,7 @@ char * buf;
return buf;
}
-static char *ctrlNames[] = {
+static const char *ctrlNames[] = {
"repeatKeys",
"slowKeys",
"bounceKeys",
@@ -617,7 +616,7 @@ char * buf;
return buf;
}
-static char *actionTypeNames[XkbSA_NumActions]= {
+static const char *actionTypeNames[XkbSA_NumActions]= {
"NoAction",
"SetMods", "LatchMods", "LockMods",
"SetGroup", "LatchGroup", "LockGroup",
@@ -632,28 +631,28 @@ static char *actionTypeNames[XkbSA_NumActions]= {
"DeviceBtn", "LockDeviceBtn"
};
-char *
+const char *
XkbActionTypeText(unsigned type,unsigned format)
{
static char buf[32];
-char *rtrn;
+const char *rtrn;
if (type<=XkbSA_LastAction) {
rtrn= actionTypeNames[type];
if (format==XkbCFile) {
- sprintf(buf,"XkbSA_%s",rtrn);
+ snprintf(buf,sizeof(buf),"XkbSA_%s",rtrn);
return buf;
}
return rtrn;
}
- sprintf(buf,"Private");
+ snprintf(buf,sizeof(buf),"Private");
return buf;
}
/***====================================================================***/
static int
-TryCopyStr(char *to,char *from,int *pLeft)
+TryCopyStr(char *to,const char *from,int *pLeft)
{
register int len;
if (*pLeft>0) {
@@ -713,10 +712,10 @@ char tbuf[32];
act= &action->group;
TryCopyStr(buf,"group=",sz);
if (act->flags&XkbSA_GroupAbsolute)
- sprintf(tbuf,"%d",XkbSAGroup(act)+1);
+ snprintf(tbuf,sizeof(tbuf),"%d",XkbSAGroup(act)+1);
else if (XkbSAGroup(act)<0)
- sprintf(tbuf,"%d",XkbSAGroup(act));
- else sprintf(tbuf,"+%d",XkbSAGroup(act));
+ snprintf(tbuf,sizeof(tbuf),"%d",XkbSAGroup(act));
+ else snprintf(tbuf,sizeof(tbuf),"+%d",XkbSAGroup(act));
TryCopyStr(buf,tbuf,sz);
if (act->type==XkbSA_LockGroup)
return TRUE;
@@ -739,13 +738,13 @@ char tbuf[32];
x= XkbPtrActionX(act);
y= XkbPtrActionY(act);
if ((act->flags&XkbSA_MoveAbsoluteX)||(x<0))
- sprintf(tbuf,"x=%d",x);
- else sprintf(tbuf,"x=+%d",x);
+ snprintf(tbuf,sizeof(tbuf),"x=%d",x);
+ else snprintf(tbuf,sizeof(tbuf),"x=+%d",x);
TryCopyStr(buf,tbuf,sz);
if ((act->flags&XkbSA_MoveAbsoluteY)||(y<0))
- sprintf(tbuf,",y=%d",y);
- else sprintf(tbuf,",y=+%d",y);
+ snprintf(tbuf,sizeof(tbuf),",y=%d",y);
+ else snprintf(tbuf,sizeof(tbuf),",y=+%d",y);
TryCopyStr(buf,tbuf,sz);
if (act->flags&XkbSA_NoAcceleration)
TryCopyStr(buf,",!accel",sz);
@@ -762,26 +761,25 @@ char tbuf[32];
act= &action->btn;
TryCopyStr(buf,"button=",sz);
if ((act->button>0)&&(act->button<6)) {
- sprintf(tbuf,"%d",act->button);
+ snprintf(tbuf,sizeof(tbuf),"%d",act->button);
TryCopyStr(buf,tbuf,sz);
}
else TryCopyStr(buf,"default",sz);
if (act->count>0) {
- sprintf(tbuf,",count=%d",act->count);
+ snprintf(tbuf,sizeof(tbuf),",count=%d",act->count);
TryCopyStr(buf,tbuf,sz);
}
if (action->type==XkbSA_LockPtrBtn) {
switch (act->flags&(XkbSA_LockNoUnlock|XkbSA_LockNoLock)) {
case XkbSA_LockNoLock:
- sprintf(tbuf,",affect=unlock"); break;
+ TryCopyStr(buf,",affect=unlock",sz); break;
case XkbSA_LockNoUnlock:
- sprintf(tbuf,",affect=lock"); break;
+ TryCopyStr(buf,",affect=lock",sz); break;
case XkbSA_LockNoUnlock|XkbSA_LockNoLock:
- sprintf(tbuf,",affect=neither"); break;
+ TryCopyStr(buf,",affect=neither",sz); break;
default:
- sprintf(tbuf,",affect=both"); break;
+ TryCopyStr(buf,",affect=both",sz); break;
}
- TryCopyStr(buf,tbuf,sz);
}
return TRUE;
}
@@ -798,8 +796,8 @@ char tbuf[32];
if (act->affect==XkbSA_AffectDfltBtn) {
TryCopyStr(buf,"affect=button,button=",sz);
if ((act->flags&XkbSA_DfltBtnAbsolute)||(XkbSAPtrDfltValue(act)<0))
- sprintf(tbuf,"%d",XkbSAPtrDfltValue(act));
- else sprintf(tbuf,"+%d",XkbSAPtrDfltValue(act));
+ snprintf(tbuf,sizeof(tbuf),"%d",XkbSAPtrDfltValue(act));
+ else snprintf(tbuf,sizeof(tbuf),"+%d",XkbSAPtrDfltValue(act));
TryCopyStr(buf,tbuf,sz);
}
return TRUE;
@@ -815,10 +813,10 @@ char tbuf[64];
if (act->flags&XkbSA_ISODfltIsGroup) {
TryCopyStr(tbuf,"group=",sz);
if (act->flags&XkbSA_GroupAbsolute)
- sprintf(tbuf,"%d",XkbSAGroup(act)+1);
+ snprintf(tbuf,sizeof(tbuf),"%d",XkbSAGroup(act)+1);
else if (XkbSAGroup(act)<0)
- sprintf(tbuf,"%d",XkbSAGroup(act));
- else sprintf(tbuf,"+%d",XkbSAGroup(act));
+ snprintf(tbuf,sizeof(tbuf),"%d",XkbSAGroup(act));
+ else snprintf(tbuf,sizeof(tbuf),"+%d",XkbSAGroup(act));
TryCopyStr(buf,tbuf,sz);
}
else {
@@ -848,17 +846,17 @@ char tbuf[64];
nOut++;
}
if ((act->affect&XkbSA_ISONoAffectGroup)==0) {
- sprintf(tbuf,"%sgroups",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sgroups",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if ((act->affect&XkbSA_ISONoAffectPtr)==0) {
- sprintf(tbuf,"%spointer",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%spointer",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if ((act->affect&XkbSA_ISONoAffectCtrls)==0) {
- sprintf(tbuf,"%scontrols",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%scontrols",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
@@ -876,8 +874,8 @@ char tbuf[32];
act= &action->screen;
if ((act->flags&XkbSA_SwitchAbsolute)||(XkbSAScreen(act)<0))
- sprintf(tbuf,"screen=%d",XkbSAScreen(act));
- else sprintf(tbuf,"screen=+%d",XkbSAScreen(act));
+ snprintf(tbuf,sizeof(tbuf),"screen=%d",XkbSAScreen(act));
+ else snprintf(tbuf,sizeof(tbuf),"screen=+%d",XkbSAScreen(act));
TryCopyStr(buf,tbuf,sz);
if (act->flags&XkbSA_SwitchApplication)
TryCopyStr(buf,",!same",sz);
@@ -904,67 +902,67 @@ char tbuf[32];
else {
int nOut= 0;
if (tmp&XkbRepeatKeysMask) {
- sprintf(tbuf,"%sRepeatKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sRepeatKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbSlowKeysMask) {
- sprintf(tbuf,"%sSlowKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sSlowKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbBounceKeysMask) {
- sprintf(tbuf,"%sBounceKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sBounceKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbStickyKeysMask) {
- sprintf(tbuf,"%sStickyKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sStickyKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbMouseKeysMask) {
- sprintf(tbuf,"%sMouseKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sMouseKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbMouseKeysAccelMask) {
- sprintf(tbuf,"%sMouseKeysAccel",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sMouseKeysAccel",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbAccessXKeysMask) {
- sprintf(tbuf,"%sAccessXKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sAccessXKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbAccessXTimeoutMask) {
- sprintf(tbuf,"%sAccessXTimeout",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sAccessXTimeout",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbAccessXFeedbackMask) {
- sprintf(tbuf,"%sAccessXFeedback",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sAccessXFeedback",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbAudibleBellMask) {
- sprintf(tbuf,"%sAudibleBell",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sAudibleBell",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbOverlay1Mask) {
- sprintf(tbuf,"%sOverlay1",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sOverlay1",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbOverlay2Mask) {
- sprintf(tbuf,"%sOverlay2",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sOverlay2",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbIgnoreGroupLockMask) {
- sprintf(tbuf,"%sIgnoreGroupLock",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sIgnoreGroupLock",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
@@ -991,12 +989,12 @@ char tbuf[32];
else if (act->flags&XkbSA_MessageOnPress)
TryCopyStr(buf,"KeyPress",sz);
else TryCopyStr(buf,"KeyRelease",sz);
- sprintf(tbuf,",data[0]=0x%02x",act->message[0]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[1]=0x%02x",act->message[1]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[2]=0x%02x",act->message[2]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[3]=0x%02x",act->message[3]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[4]=0x%02x",act->message[4]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[5]=0x%02x",act->message[5]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[0]=0x%02x",act->message[0]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[1]=0x%02x",act->message[1]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[2]=0x%02x",act->message[2]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[3]=0x%02x",act->message[3]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[4]=0x%02x",act->message[4]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[5]=0x%02x",act->message[5]); TryCopyStr(buf,tbuf,sz);
return TRUE;
}
@@ -1017,9 +1015,9 @@ unsigned vmods,vmods_mask;
(xkb->names->keys[kc].name[0]!='\0')) {
char *kn;
kn= XkbKeyNameText(xkb->names->keys[kc].name,XkbXKBFile);
- sprintf(tbuf,"key=%s",kn);
+ snprintf(tbuf,sizeof(tbuf),"key=%s",kn);
}
- else sprintf(tbuf,"key=%d",kc);
+ else snprintf(tbuf,sizeof(tbuf),"key=%d",kc);
TryCopyStr(buf,tbuf,sz);
if ((act->mods_mask==0)&&(vmods_mask==0))
return TRUE;
@@ -1055,26 +1053,25 @@ XkbDeviceBtnAction * act;
char tbuf[32];
act= &action->devbtn;
- sprintf(tbuf,"device= %d",act->device); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),"device= %d",act->device); TryCopyStr(buf,tbuf,sz);
TryCopyStr(buf,",button=",sz);
- sprintf(tbuf,"%d",act->button);
+ snprintf(tbuf,sizeof(tbuf),"%d",act->button);
TryCopyStr(buf,tbuf,sz);
if (act->count>0) {
- sprintf(tbuf,",count=%d",act->count);
+ snprintf(tbuf,sizeof(tbuf),",count=%d",act->count);
TryCopyStr(buf,tbuf,sz);
}
if (action->type==XkbSA_LockDeviceBtn) {
switch (act->flags&(XkbSA_LockNoUnlock|XkbSA_LockNoLock)) {
case XkbSA_LockNoLock:
- sprintf(tbuf,",affect=unlock"); break;
+ TryCopyStr(buf,",affect=unlock",sz); break;
case XkbSA_LockNoUnlock:
- sprintf(tbuf,",affect=lock"); break;
+ TryCopyStr(buf,",affect=lock",sz); break;
case XkbSA_LockNoUnlock|XkbSA_LockNoLock:
- sprintf(tbuf,",affect=neither"); break;
+ TryCopyStr(buf,",affect=neither",sz); break;
default:
- sprintf(tbuf,",affect=both"); break;
+ TryCopyStr(buf,",affect=both",sz); break;
}
- TryCopyStr(buf,tbuf,sz);
}
return TRUE;
}
@@ -1087,14 +1084,14 @@ XkbAnyAction * act;
char tbuf[32];
act= &action->any;
- sprintf(tbuf,"type=0x%02x",act->type); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[0]=0x%02x",act->data[0]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[1]=0x%02x",act->data[1]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[2]=0x%02x",act->data[2]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[3]=0x%02x",act->data[3]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[4]=0x%02x",act->data[4]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[5]=0x%02x",act->data[5]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[6]=0x%02x",act->data[6]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),"type=0x%02x",act->type); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[0]=0x%02x",act->data[0]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[1]=0x%02x",act->data[1]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[2]=0x%02x",act->data[2]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[3]=0x%02x",act->data[3]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[4]=0x%02x",act->data[4]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[5]=0x%02x",act->data[5]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[6]=0x%02x",act->data[6]); TryCopyStr(buf,tbuf,sz);
return TRUE;
}
@@ -1136,7 +1133,7 @@ char buf[ACTION_SZ],*tmp;
int sz;
if (format==XkbCFile) {
- sprintf(buf,
+ snprintf(buf,sizeof(buf),
"{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }",
XkbActionTypeText(action->type,XkbCFile),
action->any.data[0],action->any.data[1],action->any.data[2],
@@ -1144,7 +1141,7 @@ int sz;
action->any.data[6]);
}
else {
- sprintf(buf,"%s(",XkbActionTypeText(action->type,XkbXKBFile));
+ snprintf(buf,sizeof(buf),"%s(",XkbActionTypeText(action->type,XkbXKBFile));
sz= ACTION_SZ-strlen(buf)+2; /* room for close paren and NULL */
if (action->type<(unsigned)XkbSA_NumActions)
(*copyActionArgs[action->type])(xkb,action,buf,&sz);
@@ -1164,8 +1161,8 @@ char buf[256],*tmp;
if (format==XkbCFile) {
if (behavior->type==XkbKB_Default)
- sprintf(buf,"{ 0, 0 }");
- else sprintf(buf,"{ %3d, 0x%02x }",behavior->type,behavior->data);
+ snprintf(buf,sizeof(buf),"{ 0, 0 }");
+ else snprintf(buf,sizeof(buf),"{ %3d, 0x%02x }",behavior->type,behavior->data);
}
else {
unsigned type,permanent;
@@ -1173,14 +1170,14 @@ char buf[256],*tmp;
permanent=((behavior->type&XkbKB_Permanent)!=0);
if (type==XkbKB_Lock) {
- sprintf(buf,"lock= %s",(permanent?"Permanent":"TRUE"));
+ snprintf(buf,sizeof(buf),"lock= %s",(permanent?"Permanent":"TRUE"));
}
else if (type==XkbKB_RadioGroup) {
int g;
char *tmp;
g= ((behavior->data)&(~XkbKB_RGAllowNone))+1;
if (XkbKB_RGAllowNone&behavior->data) {
- sprintf(buf,"allowNone,");
+ snprintf(buf,sizeof(buf),"allowNone,");
tmp= &buf[strlen(buf)];
}
else tmp= buf;
@@ -1198,12 +1195,12 @@ char buf[256],*tmp;
kn= XkbKeyNameText(xkb->names->keys[kc].name,XkbXKBFile);
else {
static char tbuf[8];
- sprintf(tbuf,"%d",kc);
+ snprintf(tbuf,sizeof(tbuf),"%d",kc);
kn= tbuf;
}
if (permanent)
- sprintf(buf,"permanentOverlay%d= %s",ndx,kn);
- else sprintf(buf,"overlay%d= %s",ndx,kn);
+ snprintf(buf,sizeof(buf),"permanentOverlay%d= %s",ndx,kn);
+ else snprintf(buf,sizeof(buf),"overlay%d= %s",ndx,kn);
}
}
tmp= tbGetBuffer(strlen(buf)+1);