summaryrefslogtreecommitdiff
path: root/hw/xfree86/parser/scan.c
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.de>2004-04-23 19:54:30 +0000
committerEgbert Eich <eich@suse.de>2004-04-23 19:54:30 +0000
commit2fb588620030ad393f8500d60e16144d59e4effe (patch)
tree07262cbe15a40e5aeae54f62751260f83243ab79 /hw/xfree86/parser/scan.c
parent0664db19bf37f9dd69cca6adff4e238e310c3092 (diff)
Merging XORG-CURRENT into trunk
Diffstat (limited to 'hw/xfree86/parser/scan.c')
-rw-r--r--hw/xfree86/parser/scan.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 4dc2e0dd1..d97954d2e 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -440,11 +440,11 @@ xf86pathIsSafe(const char *path)
* %A cmdline argument as an absolute path (must be absolute to match)
* %R cmdline argument as a relative path
* %S cmdline argument as a "safe" path (relative, and no ".." elements)
- * %X default config file name ("XF86Config")
+ * %X default config file name ("xorg.conf")
* %H hostname
- * %E config file environment ($XF86CONFIG) as an absolute path
- * %F config file environment ($XF86CONFIG) as a relative path
- * %G config file environment ($XF86CONFIG) as a safe path
+ * %E config file environment ($XORGCONFIG) as an absolute path
+ * %F config file environment ($XORGCONFIG) as a relative path
+ * %G config file environment ($XORGCONFIG) as a safe path
* %D $HOME
* %P projroot
* %M major version number
@@ -453,14 +453,15 @@ xf86pathIsSafe(const char *path)
*/
#ifndef XCONFIGFILE
-#define XCONFIGFILE "XF86Config"
+#define XCONFIGFILE "xorg.conf"
#endif
#ifndef PROJECTROOT
#define PROJECTROOT "/usr/X11R6"
#endif
#ifndef XCONFENV
-#define XCONFENV "XF86CONFIG"
+#define XCONFENV "XORGCONFIG"
#endif
+#define XFREE86CFGFILE "XF86Config"
#ifndef XF86_VERSION_MAJOR
#ifdef XVERSION
#if XVERSION > 40000000
@@ -495,7 +496,7 @@ xf86pathIsSafe(const char *path)
static char *
DoSubstitution(const char *template, const char *cmdline, const char *projroot,
- int *cmdlineUsed, int *envUsed)
+ int *cmdlineUsed, int *envUsed, char *XConfigFile)
{
char *result;
int i, l;
@@ -547,7 +548,7 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
BAIL_OUT;
break;
case 'X':
- APPEND_STR(XCONFIGFILE);
+ APPEND_STR(XConfigFile);
break;
case 'H':
if (!hostname) {
@@ -701,7 +702,8 @@ xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
/* First, search for a config file. */
while (template && !configFile) {
if ((configPath = DoSubstitution(template, cmdline, projroot,
- &cmdlineUsed, NULL))) {
+ &cmdlineUsed, NULL,
+ XCONFIGFILE))) {
if ((configFile = fopen(configPath, "r")) != 0) {
if (cmdline && !cmdlineUsed) {
fclose(configFile);
@@ -715,6 +717,31 @@ xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
}
template = strtok(NULL, ",");
}
+
+ /* Then search for fallback */
+ if (!configFile) {
+ strcpy(pathcopy, path);
+ template = strtok(pathcopy, ",");
+
+ while (template && !configFile) {
+ if ((configPath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL,
+ XFREE86CFGFILE))) {
+ if ((configFile = fopen(configPath, "r")) != 0) {
+ if (cmdline && !cmdlineUsed) {
+ fclose(configFile);
+ configFile = NULL;
+ }
+ }
+ }
+ if (configPath && !configFile) {
+ xf86conffree(configPath);
+ configPath = NULL;
+ }
+ template = strtok(NULL, ",");
+ }
+ }
+
xf86conffree(pathcopy);
if (!configFile) {