aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/parser
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-11-25 08:32:21 +0100
committermarha <marha@users.sourceforge.net>2011-11-25 08:32:21 +0100
commit849d328b25c2f3c87d539e1fe7af38e7580a0409 (patch)
tree349c425a87ddb3aaa1d7832d5a8e68252fc73ddb /xorg-server/hw/xfree86/parser
parenta8a12d4c8be177f63cae7dc96c2b52f09e228a76 (diff)
parenta0b4a1330be6a36ad095222d2ea83927cd33514d (diff)
downloadvcxsrv-849d328b25c2f3c87d539e1fe7af38e7580a0409.tar.gz
vcxsrv-849d328b25c2f3c87d539e1fe7af38e7580a0409.tar.bz2
vcxsrv-849d328b25c2f3c87d539e1fe7af38e7580a0409.zip
Merge remote-tracking branch 'origin/released'
Conflicts: xorg-server/glx/glxdriswrast.c xorg-server/glx/single2.c xorg-server/hw/xwin/winconfig.c xorg-server/os/osinit.c xorg-server/os/xdmcp.c xorg-server/xkb/xkbInit.c
Diffstat (limited to 'xorg-server/hw/xfree86/parser')
-rw-r--r--xorg-server/hw/xfree86/parser/Flags.c2
-rw-r--r--xorg-server/hw/xfree86/parser/InputClass.c15
-rw-r--r--xorg-server/hw/xfree86/parser/configProcs.h6
-rw-r--r--xorg-server/hw/xfree86/parser/scan.c52
-rw-r--r--xorg-server/hw/xfree86/parser/xf86Optrec.h2
-rw-r--r--xorg-server/hw/xfree86/parser/xf86Parser.h10
6 files changed, 49 insertions, 38 deletions
diff --git a/xorg-server/hw/xfree86/parser/Flags.c b/xorg-server/hw/xfree86/parser/Flags.c
index f0a61707b..87fd3edf6 100644
--- a/xorg-server/hw/xfree86/parser/Flags.c
+++ b/xorg-server/hw/xfree86/parser/Flags.c
@@ -330,7 +330,7 @@ xf86findOption (XF86OptionPtr list, const char *name)
* returned. If the option is not found, a NULL is returned.
*/
-char *
+const char *
xf86findOptionValue (XF86OptionPtr list, const char *name)
{
XF86OptionPtr p = xf86findOption (list, name);
diff --git a/xorg-server/hw/xfree86/parser/InputClass.c b/xorg-server/hw/xfree86/parser/InputClass.c
index 3f801700e..2cdc9125a 100644
--- a/xorg-server/hw/xfree86/parser/InputClass.c
+++ b/xorg-server/hw/xfree86/parser/InputClass.c
@@ -128,60 +128,70 @@ xf86parseInputClassSection(void)
Error(QUOTE_MSG, "MatchProduct");
add_group_entry(&ptr->match_product,
xstrtokenize(val.str, TOKEN_SEP));
+ free(val.str);
break;
case MATCH_VENDOR:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchVendor");
add_group_entry(&ptr->match_vendor,
xstrtokenize(val.str, TOKEN_SEP));
+ free(val.str);
break;
case MATCH_DEVICE_PATH:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchDevicePath");
add_group_entry(&ptr->match_device,
xstrtokenize(val.str, TOKEN_SEP));
+ free(val.str);
break;
case MATCH_OS:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchOS");
add_group_entry(&ptr->match_os,
xstrtokenize(val.str, TOKEN_SEP));
+ free(val.str);
break;
case MATCH_PNPID:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchPnPID");
add_group_entry(&ptr->match_pnpid,
xstrtokenize(val.str, TOKEN_SEP));
+ free(val.str);
break;
case MATCH_USBID:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchUSBID");
add_group_entry(&ptr->match_usbid,
xstrtokenize(val.str, TOKEN_SEP));
+ free(val.str);
break;
case MATCH_DRIVER:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchDriver");
add_group_entry(&ptr->match_driver,
xstrtokenize(val.str, TOKEN_SEP));
+ free(val.str);
break;
case MATCH_TAG:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchTag");
add_group_entry(&ptr->match_tag,
xstrtokenize(val.str, TOKEN_SEP));
+ free(val.str);
break;
case MATCH_LAYOUT:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchLayout");
add_group_entry(&ptr->match_layout,
xstrtokenize(val.str, TOKEN_SEP));
+ free(val.str);
break;
case MATCH_IS_KEYBOARD:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchIsKeyboard");
ptr->is_keyboard.set = xf86getBoolValue(&ptr->is_keyboard.val,
val.str);
+ free(val.str);
if (!ptr->is_keyboard.set)
Error(BOOL_MSG, "MatchIsKeyboard");
break;
@@ -190,6 +200,7 @@ xf86parseInputClassSection(void)
Error(QUOTE_MSG, "MatchIsPointer");
ptr->is_pointer.set = xf86getBoolValue(&ptr->is_pointer.val,
val.str);
+ free(val.str);
if (!ptr->is_pointer.set)
Error(BOOL_MSG, "MatchIsPointer");
break;
@@ -198,6 +209,7 @@ xf86parseInputClassSection(void)
Error(QUOTE_MSG, "MatchIsJoystick");
ptr->is_joystick.set = xf86getBoolValue(&ptr->is_joystick.val,
val.str);
+ free(val.str);
if (!ptr->is_joystick.set)
Error(BOOL_MSG, "MatchIsJoystick");
break;
@@ -206,6 +218,7 @@ xf86parseInputClassSection(void)
Error(QUOTE_MSG, "MatchIsTablet");
ptr->is_tablet.set = xf86getBoolValue(&ptr->is_tablet.val,
val.str);
+ free(val.str);
if (!ptr->is_tablet.set)
Error(BOOL_MSG, "MatchIsTablet");
break;
@@ -214,6 +227,7 @@ xf86parseInputClassSection(void)
Error(QUOTE_MSG, "MatchIsTouchpad");
ptr->is_touchpad.set = xf86getBoolValue(&ptr->is_touchpad.val,
val.str);
+ free(val.str);
if (!ptr->is_touchpad.set)
Error(BOOL_MSG, "MatchIsTouchpad");
break;
@@ -222,6 +236,7 @@ xf86parseInputClassSection(void)
Error(QUOTE_MSG, "MatchIsTouchscreen");
ptr->is_touchscreen.set = xf86getBoolValue(&ptr->is_touchscreen.val,
val.str);
+ free(val.str);
if (!ptr->is_touchscreen.set)
Error(BOOL_MSG, "MatchIsTouchscreen");
break;
diff --git a/xorg-server/hw/xfree86/parser/configProcs.h b/xorg-server/hw/xfree86/parser/configProcs.h
index 7d8a8e53a..114cdfe33 100644
--- a/xorg-server/hw/xfree86/parser/configProcs.h
+++ b/xorg-server/hw/xfree86/parser/configProcs.h
@@ -95,9 +95,9 @@ int xf86getSubToken(char **comment);
int xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec *tab);
void xf86unGetToken(int token);
char *xf86tokenString(void);
-void xf86parseError(char *format, ...);
-void xf86validationError(char *format, ...);
-void xf86setSection(char *section);
+void xf86parseError(const char *format, ...);
+void xf86validationError(const char *format, ...);
+void xf86setSection(const char *section);
int xf86getStringToken(xf86ConfigSymTabRec *tab);
/* write.c */
/* DRI.c */
diff --git a/xorg-server/hw/xfree86/parser/scan.c b/xorg-server/hw/xfree86/parser/scan.c
index 99b325717..9099227bb 100644
--- a/xorg-server/hw/xfree86/parser/scan.c
+++ b/xorg-server/hw/xfree86/parser/scan.c
@@ -90,7 +90,7 @@
#define CONFIG_BUF_LEN 1024
#define CONFIG_MAX_FILES 64
-static int StringToToken (char *, xf86ConfigSymTabRec *);
+static int StringToToken (const char *, xf86ConfigSymTabRec *);
static struct {
FILE *file;
@@ -101,8 +101,6 @@ static int builtinIndex = 0;
static int configPos = 0; /* current readers position */
static int configLineNo = 0; /* linenumber */
static char *configBuf, *configRBuf; /* buffer for lines */
-static char *configPath; /* path to config file */
-static char *configDirPath; /* path to config dir */
static char *configSection = NULL; /* name of current section being parsed */
static int numFiles = 0; /* number of config files */
static int curFileIndex = 0; /* index of current config file */
@@ -281,8 +279,10 @@ again:
if (builtinConfig[builtinIndex] == NULL)
ret = NULL;
else {
- ret = strncpy(configBuf, builtinConfig[builtinIndex],
- CONFIG_BUF_LEN);
+ strlcpy(configBuf,
+ builtinConfig[builtinIndex],
+ CONFIG_BUF_LEN);
+ ret = configBuf;
builtinIndex++;
}
}
@@ -800,14 +800,12 @@ AddConfigDirFiles(const char *dirpath, struct dirent **list, int num)
"files opened\n");
warnOnce = TRUE;
}
- free(list[i]);
continue;
}
path = malloc(PATH_MAX + 1);
snprintf(path, PATH_MAX + 1, "%s/%s", dirpath,
list[i]->d_name);
- free(list[i]);
file = fopen(path, "r");
if (!file) {
free(path);
@@ -858,8 +856,10 @@ OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
if (!found) {
free(dirpath);
dirpath = NULL;
- free(list);
}
+ while (num--)
+ free(list[num]);
+ free(list);
}
free(pathcopy);
@@ -892,7 +892,8 @@ xf86initConfigFiles(void)
* of the located files.
*
* The return value is a pointer to the actual name of the file that was
- * opened. When no file is found, the return value is NULL.
+ * opened. When no file is found, the return value is NULL. The caller should
+ * free() the returned value.
*
* The escape sequences allowed in the search path are defined above.
*
@@ -914,7 +915,7 @@ xf86initConfigFiles(void)
"%P/lib/X11/%X"
#endif
-const char *
+char *
xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
{
if (!path || !path[0])
@@ -923,8 +924,7 @@ xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
projroot = PROJECTROOT;
/* Search for a config file */
- configPath = OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
- return configPath;
+ return OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
}
/*
@@ -937,12 +937,13 @@ xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
* fails if it is not found.
*
* The return value is a pointer to the actual name of the direcoty that was
- * opened. When no directory is found, the return value is NULL.
+ * opened. When no directory is found, the return value is NULL. The caller
+ * should free() the returned value.
*
* The escape sequences allowed in the search path are defined above.
*
*/
-const char *
+char *
xf86openConfigDirFiles(const char *path, const char *cmdline,
const char *projroot)
{
@@ -952,8 +953,7 @@ xf86openConfigDirFiles(const char *path, const char *cmdline,
projroot = PROJECTROOT;
/* Search for the multiconf directory */
- configDirPath = OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
- return configDirPath;
+ return OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
}
void
@@ -961,10 +961,6 @@ xf86closeConfigFile (void)
{
int i;
- free (configPath);
- configPath = NULL;
- free (configDirPath);
- configDirPath = NULL;
free (configRBuf);
configRBuf = NULL;
free (configBuf);
@@ -990,11 +986,11 @@ xf86setBuiltinConfig(const char *config[])
}
void
-xf86parseError (char *format,...)
+xf86parseError (const char *format,...)
{
va_list ap;
- char *filename = numFiles ? configFiles[curFileIndex].path :
- "<builtin configuration>";
+ const char *filename = numFiles ? configFiles[curFileIndex].path
+ : "<builtin configuration>";
ErrorF ("Parse error on line %d of section %s in file %s\n\t",
configLineNo, configSection, filename);
@@ -1006,11 +1002,11 @@ xf86parseError (char *format,...)
}
void
-xf86validationError (char *format,...)
+xf86validationError (const char *format,...)
{
va_list ap;
- char *filename = numFiles ? configFiles[curFileIndex].path :
- "<builtin configuration>";
+ const char *filename = numFiles ? configFiles[curFileIndex].path
+ : "<builtin configuration>";
ErrorF ("Data incomplete in file %s\n\t", filename);
va_start (ap, format);
@@ -1021,7 +1017,7 @@ xf86validationError (char *format,...)
}
void
-xf86setSection (char *section)
+xf86setSection (const char *section)
{
free(configSection);
configSection = strdup(section);
@@ -1038,7 +1034,7 @@ xf86getStringToken (xf86ConfigSymTabRec * tab)
}
static int
-StringToToken (char *str, xf86ConfigSymTabRec * tab)
+StringToToken (const char *str, xf86ConfigSymTabRec * tab)
{
int i;
diff --git a/xorg-server/hw/xfree86/parser/xf86Optrec.h b/xorg-server/hw/xfree86/parser/xf86Optrec.h
index 61a8c5ff5..b8e9d6192 100644
--- a/xorg-server/hw/xfree86/parser/xf86Optrec.h
+++ b/xorg-server/hw/xfree86/parser/xf86Optrec.h
@@ -77,7 +77,7 @@ extern _X_EXPORT char *xf86optionValue(XF86OptionPtr opt);
extern _X_EXPORT XF86OptionPtr xf86newOption(char *name, char *value);
extern _X_EXPORT XF86OptionPtr xf86nextOption(XF86OptionPtr list);
extern _X_EXPORT XF86OptionPtr xf86findOption(XF86OptionPtr list, const char *name);
-extern _X_EXPORT char *xf86findOptionValue(XF86OptionPtr list, const char *name);
+extern _X_EXPORT const char *xf86findOptionValue(XF86OptionPtr list, const char *name);
extern _X_EXPORT XF86OptionPtr xf86optionListCreate(const char **options, int count, int used);
extern _X_EXPORT XF86OptionPtr xf86optionListMerge(XF86OptionPtr head, XF86OptionPtr tail);
extern _X_EXPORT int xf86nameCompare (const char *s1, const char *s2);
diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h
index a8785c5fa..7d4662b98 100644
--- a/xorg-server/hw/xfree86/parser/xf86Parser.h
+++ b/xorg-server/hw/xfree86/parser/xf86Parser.h
@@ -479,7 +479,7 @@ XF86ConfigRec, *XF86ConfigPtr;
typedef struct
{
int token; /* id of the token */
- char *name; /* pointer to the LOWERCASED name */
+ const char *name; /* pointer to the LOWERCASED name */
}
xf86ConfigSymTabRec, *xf86ConfigSymTabPtr;
@@ -487,10 +487,10 @@ xf86ConfigSymTabRec, *xf86ConfigSymTabPtr;
* prototypes for public functions
*/
extern void xf86initConfigFiles(void);
-extern const char *xf86openConfigFile(const char *path, const char *cmdline,
- const char *projroot);
-extern const char *xf86openConfigDirFiles(const char *path, const char *cmdline,
- const char *projroot);
+extern char *xf86openConfigFile(const char *path, const char *cmdline,
+ const char *projroot);
+extern char *xf86openConfigDirFiles(const char *path, const char *cmdline,
+ const char *projroot);
extern void xf86setBuiltinConfig(const char *config[]);
extern XF86ConfigPtr xf86readConfigFile(void);
extern void xf86closeConfigFile(void);