Correct misfeature with quoting, better error reporting.
This commit is contained in:
parent
29b4135e6e
commit
e87fd2716b
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: config.c,v 1.106 1998/03/09 08:39:46 jkh Exp $
|
||||
* $Id: config.c,v 1.107 1998/03/09 15:00:43 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -320,7 +320,8 @@ configEnvironmentRC_conf(char *config)
|
||||
/* If valid quotes, use it */
|
||||
if (cp2) {
|
||||
*cp2 = '\0';
|
||||
if (strlen(cp))
|
||||
/* If we have a legit value and it's not already set, set it */
|
||||
if (strlen(cp) && !variable_get(lines[i]))
|
||||
variable_set2(lines[i], cp);
|
||||
}
|
||||
free(lines[i]);
|
||||
@ -338,9 +339,9 @@ configEnvironmentResolv(char *config)
|
||||
if (nlines == -1)
|
||||
return;
|
||||
for (i = 0; i < nlines; i++) {
|
||||
Boolean name_set = FALSE;
|
||||
Boolean name_set = (Boolean)variable_get(VAR_NAMESERVER);
|
||||
|
||||
if (!strncmp(lines[i], "domain", 6))
|
||||
if (!strncmp(lines[i], "domain", 6) && !variable_get(VAR_DOMAINNAME))
|
||||
variable_set2(VAR_DOMAINNAME, string_skipwhite(string_prune(lines[i] + 6)));
|
||||
else if (!strncmp(lines[i], "nameserver", 10) && !name_set) {
|
||||
/* Only take the first nameserver setting - we're lame */
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last attempt in the `sysinstall' line, the next
|
||||
* generation being slated for what's essentially a complete rewrite.
|
||||
*
|
||||
* $Id: dmenu.c,v 1.34 1997/09/17 16:18:14 pst Exp $
|
||||
* $Id: dmenu.c,v 1.35 1997/10/14 18:17:29 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -130,10 +130,16 @@ dmenuSetKmapVariable(dialogMenuItem *tmp)
|
||||
int
|
||||
dmenuToggleVariable(dialogMenuItem *tmp)
|
||||
{
|
||||
if (!variable_get((char *)tmp->data))
|
||||
variable_set((char *)tmp->data);
|
||||
char *var;
|
||||
|
||||
if (!(var = (char *)tmp->data)) {
|
||||
msgConfirm("Incorrect data field for `%s'!", tmp->title);
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
if (!variable_get(var))
|
||||
variable_set(var);
|
||||
else
|
||||
variable_unset((char *)tmp->data);
|
||||
variable_unset(var);
|
||||
return DITEM_SUCCESS;
|
||||
}
|
||||
|
||||
@ -201,8 +207,6 @@ dmenuVarCheck(dialogMenuItem *item)
|
||||
w = (char *)item->aux;
|
||||
if (!w)
|
||||
w = (char *)item->data;
|
||||
if (!w)
|
||||
return FALSE;
|
||||
return variable_check(w);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: variable.c,v 1.20 1997/06/13 14:21:22 jkh Exp $
|
||||
* $Id: variable.c,v 1.21 1997/10/12 16:21:21 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -171,14 +171,18 @@ variable_get_value(char *var, char *prompt)
|
||||
int
|
||||
variable_check(char *data)
|
||||
{
|
||||
char *w, *cp, *cp2, *cp3, tmp[256];
|
||||
char *cp, *cp2, *cp3, tmp[256];
|
||||
|
||||
w = data;
|
||||
if (!w)
|
||||
if (!data)
|
||||
return FALSE;
|
||||
SAFE_STRCPY(tmp, w);
|
||||
SAFE_STRCPY(tmp, data);
|
||||
if ((cp = index(tmp, '=')) != NULL) {
|
||||
*(cp++) = '\0';
|
||||
if (*cp == '"') { /* smash quotes if present */
|
||||
++cp;
|
||||
if ((cp3 = index(cp, '"')) != NULL)
|
||||
*cp3 = '\0';
|
||||
}
|
||||
if ((cp3 = index(cp, ',')) != NULL)
|
||||
*cp3 = '\0';
|
||||
cp2 = getenv(tmp);
|
||||
@ -189,5 +193,5 @@ variable_check(char *data)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return (int)getenv(tmp);
|
||||
return getenv(tmp) ? 1 : 0;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: config.c,v 1.106 1998/03/09 08:39:46 jkh Exp $
|
||||
* $Id: config.c,v 1.107 1998/03/09 15:00:43 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -320,7 +320,8 @@ configEnvironmentRC_conf(char *config)
|
||||
/* If valid quotes, use it */
|
||||
if (cp2) {
|
||||
*cp2 = '\0';
|
||||
if (strlen(cp))
|
||||
/* If we have a legit value and it's not already set, set it */
|
||||
if (strlen(cp) && !variable_get(lines[i]))
|
||||
variable_set2(lines[i], cp);
|
||||
}
|
||||
free(lines[i]);
|
||||
@ -338,9 +339,9 @@ configEnvironmentResolv(char *config)
|
||||
if (nlines == -1)
|
||||
return;
|
||||
for (i = 0; i < nlines; i++) {
|
||||
Boolean name_set = FALSE;
|
||||
Boolean name_set = (Boolean)variable_get(VAR_NAMESERVER);
|
||||
|
||||
if (!strncmp(lines[i], "domain", 6))
|
||||
if (!strncmp(lines[i], "domain", 6) && !variable_get(VAR_DOMAINNAME))
|
||||
variable_set2(VAR_DOMAINNAME, string_skipwhite(string_prune(lines[i] + 6)));
|
||||
else if (!strncmp(lines[i], "nameserver", 10) && !name_set) {
|
||||
/* Only take the first nameserver setting - we're lame */
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last attempt in the `sysinstall' line, the next
|
||||
* generation being slated for what's essentially a complete rewrite.
|
||||
*
|
||||
* $Id: dmenu.c,v 1.34 1997/09/17 16:18:14 pst Exp $
|
||||
* $Id: dmenu.c,v 1.35 1997/10/14 18:17:29 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -130,10 +130,16 @@ dmenuSetKmapVariable(dialogMenuItem *tmp)
|
||||
int
|
||||
dmenuToggleVariable(dialogMenuItem *tmp)
|
||||
{
|
||||
if (!variable_get((char *)tmp->data))
|
||||
variable_set((char *)tmp->data);
|
||||
char *var;
|
||||
|
||||
if (!(var = (char *)tmp->data)) {
|
||||
msgConfirm("Incorrect data field for `%s'!", tmp->title);
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
if (!variable_get(var))
|
||||
variable_set(var);
|
||||
else
|
||||
variable_unset((char *)tmp->data);
|
||||
variable_unset(var);
|
||||
return DITEM_SUCCESS;
|
||||
}
|
||||
|
||||
@ -201,8 +207,6 @@ dmenuVarCheck(dialogMenuItem *item)
|
||||
w = (char *)item->aux;
|
||||
if (!w)
|
||||
w = (char *)item->data;
|
||||
if (!w)
|
||||
return FALSE;
|
||||
return variable_check(w);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: variable.c,v 1.20 1997/06/13 14:21:22 jkh Exp $
|
||||
* $Id: variable.c,v 1.21 1997/10/12 16:21:21 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -171,14 +171,18 @@ variable_get_value(char *var, char *prompt)
|
||||
int
|
||||
variable_check(char *data)
|
||||
{
|
||||
char *w, *cp, *cp2, *cp3, tmp[256];
|
||||
char *cp, *cp2, *cp3, tmp[256];
|
||||
|
||||
w = data;
|
||||
if (!w)
|
||||
if (!data)
|
||||
return FALSE;
|
||||
SAFE_STRCPY(tmp, w);
|
||||
SAFE_STRCPY(tmp, data);
|
||||
if ((cp = index(tmp, '=')) != NULL) {
|
||||
*(cp++) = '\0';
|
||||
if (*cp == '"') { /* smash quotes if present */
|
||||
++cp;
|
||||
if ((cp3 = index(cp, '"')) != NULL)
|
||||
*cp3 = '\0';
|
||||
}
|
||||
if ((cp3 = index(cp, ',')) != NULL)
|
||||
*cp3 = '\0';
|
||||
cp2 = getenv(tmp);
|
||||
@ -189,5 +193,5 @@ variable_check(char *data)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return (int)getenv(tmp);
|
||||
return getenv(tmp) ? 1 : 0;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: config.c,v 1.106 1998/03/09 08:39:46 jkh Exp $
|
||||
* $Id: config.c,v 1.107 1998/03/09 15:00:43 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -320,7 +320,8 @@ configEnvironmentRC_conf(char *config)
|
||||
/* If valid quotes, use it */
|
||||
if (cp2) {
|
||||
*cp2 = '\0';
|
||||
if (strlen(cp))
|
||||
/* If we have a legit value and it's not already set, set it */
|
||||
if (strlen(cp) && !variable_get(lines[i]))
|
||||
variable_set2(lines[i], cp);
|
||||
}
|
||||
free(lines[i]);
|
||||
@ -338,9 +339,9 @@ configEnvironmentResolv(char *config)
|
||||
if (nlines == -1)
|
||||
return;
|
||||
for (i = 0; i < nlines; i++) {
|
||||
Boolean name_set = FALSE;
|
||||
Boolean name_set = (Boolean)variable_get(VAR_NAMESERVER);
|
||||
|
||||
if (!strncmp(lines[i], "domain", 6))
|
||||
if (!strncmp(lines[i], "domain", 6) && !variable_get(VAR_DOMAINNAME))
|
||||
variable_set2(VAR_DOMAINNAME, string_skipwhite(string_prune(lines[i] + 6)));
|
||||
else if (!strncmp(lines[i], "nameserver", 10) && !name_set) {
|
||||
/* Only take the first nameserver setting - we're lame */
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last attempt in the `sysinstall' line, the next
|
||||
* generation being slated for what's essentially a complete rewrite.
|
||||
*
|
||||
* $Id: dmenu.c,v 1.34 1997/09/17 16:18:14 pst Exp $
|
||||
* $Id: dmenu.c,v 1.35 1997/10/14 18:17:29 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -130,10 +130,16 @@ dmenuSetKmapVariable(dialogMenuItem *tmp)
|
||||
int
|
||||
dmenuToggleVariable(dialogMenuItem *tmp)
|
||||
{
|
||||
if (!variable_get((char *)tmp->data))
|
||||
variable_set((char *)tmp->data);
|
||||
char *var;
|
||||
|
||||
if (!(var = (char *)tmp->data)) {
|
||||
msgConfirm("Incorrect data field for `%s'!", tmp->title);
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
if (!variable_get(var))
|
||||
variable_set(var);
|
||||
else
|
||||
variable_unset((char *)tmp->data);
|
||||
variable_unset(var);
|
||||
return DITEM_SUCCESS;
|
||||
}
|
||||
|
||||
@ -201,8 +207,6 @@ dmenuVarCheck(dialogMenuItem *item)
|
||||
w = (char *)item->aux;
|
||||
if (!w)
|
||||
w = (char *)item->data;
|
||||
if (!w)
|
||||
return FALSE;
|
||||
return variable_check(w);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: variable.c,v 1.20 1997/06/13 14:21:22 jkh Exp $
|
||||
* $Id: variable.c,v 1.21 1997/10/12 16:21:21 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -171,14 +171,18 @@ variable_get_value(char *var, char *prompt)
|
||||
int
|
||||
variable_check(char *data)
|
||||
{
|
||||
char *w, *cp, *cp2, *cp3, tmp[256];
|
||||
char *cp, *cp2, *cp3, tmp[256];
|
||||
|
||||
w = data;
|
||||
if (!w)
|
||||
if (!data)
|
||||
return FALSE;
|
||||
SAFE_STRCPY(tmp, w);
|
||||
SAFE_STRCPY(tmp, data);
|
||||
if ((cp = index(tmp, '=')) != NULL) {
|
||||
*(cp++) = '\0';
|
||||
if (*cp == '"') { /* smash quotes if present */
|
||||
++cp;
|
||||
if ((cp3 = index(cp, '"')) != NULL)
|
||||
*cp3 = '\0';
|
||||
}
|
||||
if ((cp3 = index(cp, ',')) != NULL)
|
||||
*cp3 = '\0';
|
||||
cp2 = getenv(tmp);
|
||||
@ -189,5 +193,5 @@ variable_check(char *data)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return (int)getenv(tmp);
|
||||
return getenv(tmp) ? 1 : 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user