Simplify filename generation code for Xorg -configure
This commit is contained in:
parent
75784e1e53
commit
5bf2c88d23
|
@ -662,12 +662,17 @@ configureDDCMonitorSection (int screennum)
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(PATH_MAX)
|
||||||
|
# define PATH_MAX 1024
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
DoConfigure()
|
DoConfigure(void)
|
||||||
{
|
{
|
||||||
int i,j, screennum = -1;
|
int i,j, screennum = -1;
|
||||||
char *home = NULL;
|
char *home = NULL;
|
||||||
char *filename = NULL;
|
char filename[PATH_MAX];
|
||||||
|
char *addslash = "";
|
||||||
XF86ConfigPtr xf86config = NULL;
|
XF86ConfigPtr xf86config = NULL;
|
||||||
char **vlist, **vl;
|
char **vlist, **vl;
|
||||||
int *dev2screen;
|
int *dev2screen;
|
||||||
|
@ -765,29 +770,21 @@ DoConfigure()
|
||||||
xf86config->conf_input_lst = configureInputSection();
|
xf86config->conf_input_lst = configureInputSection();
|
||||||
xf86config->conf_layout_lst = configureLayoutSection();
|
xf86config->conf_layout_lst = configureLayoutSection();
|
||||||
|
|
||||||
if (!(home = getenv("HOME")))
|
home = getenv("HOME");
|
||||||
|
if ((home == NULL) || (home[0] = '\0')) {
|
||||||
home = "/";
|
home = "/";
|
||||||
{
|
} else {
|
||||||
#if !defined(PATH_MAX)
|
/* Determine if trailing slash is present or needed */
|
||||||
#define PATH_MAX 1024
|
int l = strlen(home);
|
||||||
#endif
|
|
||||||
const char* configfile = XF86CONFIGFILE".new";
|
|
||||||
char homebuf[PATH_MAX];
|
|
||||||
/* getenv might return R/O memory, as with OS/2 */
|
|
||||||
strncpy(homebuf,home,PATH_MAX-1);
|
|
||||||
homebuf[PATH_MAX-1] = '\0';
|
|
||||||
home = homebuf;
|
|
||||||
if (!(filename =
|
|
||||||
(char *)xalloc(strlen(home) +
|
|
||||||
strlen(configfile) + 3)))
|
|
||||||
goto bail;
|
|
||||||
|
|
||||||
if (home[0] == '/' && home[1] == '\0')
|
if (home[l-1] != '/') {
|
||||||
home[0] = '\0';
|
addslash = "/";
|
||||||
sprintf(filename, "%s/%s", home,configfile);
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf(filename, sizeof(filename), "%s%s" XF86CONFIGFILE ".new",
|
||||||
|
home, addslash);
|
||||||
|
|
||||||
xf86writeConfigFile(filename, xf86config);
|
xf86writeConfigFile(filename, xf86config);
|
||||||
|
|
||||||
xf86DoConfigurePass1 = FALSE;
|
xf86DoConfigurePass1 = FALSE;
|
||||||
|
|
Loading…
Reference in New Issue