Require strdup and remove utils wrapper This kills a couple warnings from using the uStringDup wrapper. If you don't have strdup on your platform, you have bigger issues.
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
diff --git a/configure.ac b/configure.ac
index 307bfd6..09b45e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,7 +54,7 @@ if test "x$CC_FOR_BUILD" = x; then
fi
fi
-AC_CHECK_FUNCS([strdup strcasecmp])
+AC_CHECK_FUNCS([strcasecmp])
XORG_CHECK_MALLOC_ZERO
XORG_CWARNFLAGS
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 077ffbe..c3fdbde 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -718,7 +718,7 @@ HandleCompatMapFile(XkbFile * file,
if (merge == MergeDefault)
merge = MergeAugment;
- info->name = uStringDup(file->name);
+ info->name = _XkbDupString(file->name);
stmt = file->defs;
while (stmt)
{
diff --git a/src/xkbcomp/geometry.c b/src/xkbcomp/geometry.c
index 182c76c..92717d6 100644
--- a/src/xkbcomp/geometry.c
+++ b/src/xkbcomp/geometry.c
@@ -752,7 +752,7 @@ AddProperty(GeometryInfo * info, PropertyInfo * new)
}
if (old->value)
uFree(old->value);
- old->value = uStringDup(new->value);
+ old->value = _XkbDupString(new->value);
return True;
}
if (((old->defs.fileID == new->defs.fileID) && (warningLevel > 0))
@@ -768,8 +768,8 @@ AddProperty(GeometryInfo * info, PropertyInfo * new)
if ((new = NextProperty(info)) == NULL)
return False;
new->defs.next = NULL;
- new->name = uStringDup(old->name);
- new->value = uStringDup(old->value);
+ new->name = _XkbDupString(old->name);
+ new->value = _XkbDupString(old->value);
return True;
}
@@ -1761,7 +1761,7 @@ SetLogoDoodadField(DoodadInfo * di,
return ReportBadType(typeName, field, ddText(di),
"string");
}
- di->logoName = uStringDup(tmp.str);
+ di->logoName = _XkbDupString(tmp.str);
return True;
}
return ReportBadField(typeName, field, ddText(di));
@@ -2805,7 +2805,7 @@ HandleGeometryFile(XkbFile * file,
if (merge == MergeDefault)
merge = MergeAugment;
- info->name = uStringDup(file->name);
+ info->name = _XkbDupString(file->name);
stmt = file->defs;
while (stmt)
{
@@ -3632,7 +3632,7 @@ CompileGeometry(XkbFile *file, XkbcDescPtr xkb, unsigned merge)
}
if (info.fontSpec != None)
geom->label_font =
- uStringDup(XkbcAtomGetString(info.fontSpec));
+ _XkbDupString(XkbcAtomGetString(info.fontSpec));
else
geom->label_font = FontFromParts(info.font, info.fontWeight,
info.fontSlant,
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index e1b7028..95437b0 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -753,7 +753,7 @@ HandleKeycodesFile(XkbFile * file,
{
ParseCommon *stmt;
- info->name = uStringDup(file->name);
+ info->name = _XkbDupString(file->name);
stmt = file->defs;
while (stmt)
{
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index 377081d..d82bf47 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -131,7 +131,7 @@ InitKeyTypesInfo(KeyTypesInfo * info, XkbcDescPtr xkb, KeyTypesInfo * from)
tok_TWO_LEVEL = XkbcInternAtom("TWO_LEVEL", False);
tok_ALPHABETIC = XkbcInternAtom("ALPHABETIC", False);
tok_KEYPAD = XkbcInternAtom("KEYPAD", False);
- info->name = uStringDup("default");
+ info->name = strdup("default");
info->errorCount = 0;
info->stdPresent = 0;
info->nTypes = 0;
@@ -1066,7 +1066,7 @@ HandleKeyTypesFile(XkbFile * file,
{
ParseCommon *stmt;
- info->name = uStringDup(file->name);
+ info->name = _XkbDupString(file->name);
stmt = file->defs;
while (stmt)
{
diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c
index 1f5f172..cdf4b36 100644
--- a/src/xkbcomp/parseutils.c
+++ b/src/xkbcomp/parseutils.c
@@ -657,7 +657,7 @@ IncludeCreate(char *str, unsigned merge)
incl = first = NULL;
file = map = NULL;
tmp = str;
- stmt = uStringDup(str);
+ stmt = _XkbDupString(str);
while ((tmp) && (*tmp))
{
if (XkbParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data))
@@ -812,7 +812,7 @@ CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags)
XkbcEnsureSafeMapName(name);
bzero(file, sizeof(XkbFile));
file->type = type;
- file->topName = uStringDup(name);
+ file->topName = _XkbDupString(name);
file->name = name;
file->defs = defs;
file->id = fileID++;
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 49d912a..14f2f2f 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1637,7 +1637,7 @@ HandleSymbolsFile(XkbFile * file,
{
ParseCommon *stmt;
- info->name = uStringDup(file->name);
+ info->name = _XkbDupString(file->name);
stmt = file->defs;
while (stmt)
{
diff --git a/src/xkbcomp/utils.c b/src/xkbcomp/utils.c
index 3c4d527..7cc0049 100644
--- a/src/xkbcomp/utils.c
+++ b/src/xkbcomp/utils.c
@@ -397,20 +397,6 @@ uFinishUp(void)
/***====================================================================***/
-#ifndef HAVE_STRDUP
-char *
-uStringDup(const char *str)
-{
- char *rtrn;
-
- if (str == NULL)
- return NULL;
- rtrn = (char *) uAlloc(strlen(str) + 1);
- strcpy(rtrn, str);
- return rtrn;
-}
-#endif
-
#ifndef HAVE_STRCASECMP
int
uStrCaseCmp(const char *str1, const char *str2)
diff --git a/src/xkbcomp/utils.h b/src/xkbcomp/utils.h
index a9cb62a..de3f128 100644
--- a/src/xkbcomp/utils.h
+++ b/src/xkbcomp/utils.h
@@ -174,12 +174,6 @@ uStrCaseCmp(const char *s1, const char *s2);
extern int
uStrCasePrefix(const char *p, char *str);
#endif
-#ifdef HAVE_STRDUP
-#define uStringDup(s1) ((s1) ? strdup(s1) : NULL)
-#else
-extern char *
-uStringDup(const char *s);
-#endif
/***====================================================================***/
diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c
index d2fa522..2f3329a 100644
--- a/src/xkbcomp/xkbcomp.c
+++ b/src/xkbcomp/xkbcomp.c
@@ -27,7 +27,6 @@ authorization from the authors.
#include <limits.h>
#include "X11/extensions/XKBcommon.h"
#include <X11/extensions/XKM.h>
-#include "XKBcommonint.h"
#include "xkbcomp.h"
#include "parseutils.h"
#include "utils.h"
diff --git a/src/xkbcomp/xkbcomp.h b/src/xkbcomp/xkbcomp.h
index 0961457..30bc6b2 100644
--- a/src/xkbcomp/xkbcomp.h
+++ b/src/xkbcomp/xkbcomp.h
@@ -38,6 +38,7 @@
#include <X11/extensions/XKM.h>
#include "X11/extensions/XKBcommon.h"
+#include "XKBcommonint.h"
extern char *scanFile;
diff --git a/src/xkbcomp/xkbpath.c b/src/xkbcomp/xkbpath.c
index 36228df..45ce141 100644
--- a/src/xkbcomp/xkbpath.c
+++ b/src/xkbcomp/xkbpath.c
@@ -115,7 +115,7 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
if (tmp != NULL)
{
*tmp++ = '\0';
- *extra_data = uStringDup(tmp);
+ *extra_data = _XkbDupString(tmp);
}
else
{
@@ -124,7 +124,7 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
tmp = strchr(str, '(');
if (tmp == NULL)
{
- *file_rtrn = uStringDup(str);
+ *file_rtrn = _XkbDupString(str);
*map_rtrn = NULL;
}
else if (str[0] == '(')
@@ -135,7 +135,7 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
else
{
*tmp++ = '\0';
- *file_rtrn = uStringDup(str);
+ *file_rtrn = _XkbDupString(str);
str = tmp;
tmp = strchr(str, ')');
if ((tmp == NULL) || (tmp[1] != '\0'))
@@ -145,7 +145,7 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
return False;
}
*tmp++ = '\0';
- *map_rtrn = uStringDup(str);
+ *map_rtrn = _XkbDupString(str);
}
}
if (*nextop_rtrn == '\0')
diff --git a/src/xkbcomp/xkbscan.c b/src/xkbcomp/xkbscan.c
index 27c73da..a9eb23b 100644
--- a/src/xkbcomp/xkbscan.c
+++ b/src/xkbcomp/xkbscan.c
@@ -353,7 +353,7 @@ yyGetString(void)
buf[nInBuf++] = '\0';
if (scanStr)
uFree(scanStr);
- scanStr = (char *) uStringDup(buf);
+ scanStr = strdup(buf);
scanStrLine = lineNum;
return STRING;
}
@@ -434,7 +434,7 @@ yyGetKeyName(void)
buf[nInBuf++] = '\0';
if (scanStr)
uFree(scanStr);
- scanStr = (char *) uStringDup(buf);
+ scanStr = strdup(buf);
scanStrLine = lineNum;
return KEYNAME;
}
@@ -568,7 +568,7 @@ yyGetIdent(int first)
{
if (scanStr)
uFree(scanStr);
- scanStr = (char *) uStringDup(buf);
+ scanStr = strdup(buf);
scanStrLine = lineNum;
rtrn = IDENT;
}