(parse_binding): handle line with no whitespace before =

(krb5_config_parse_file_debug): set lineno earlier so that we don't
use it unitialized


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7193 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-10-19 22:15:11 +00:00
parent 909077443f
commit 5c3b3dfe12

View File

@@ -151,25 +151,17 @@ parse_binding(FILE *f, unsigned *lineno, char *p,
char **error_message) char **error_message)
{ {
krb5_config_binding *tmp; krb5_config_binding *tmp;
char *p1; char *p1, *p2;
int ret = 0; int ret = 0;
p1 = p; p1 = p;
while (*p && !isspace((unsigned char)*p)) while (*p && *p != '=' && !isspace((unsigned char)*p))
++p; ++p;
if (*p == '\0') { if (*p == '\0') {
*error_message = "no ="; *error_message = "no =";
return -1; return -1;
} }
*p = '\0'; p2 = p;
tmp = malloc(sizeof(*tmp));
if (tmp == NULL) {
*error_message = "out of memory";
return -1;
}
tmp->name = strdup(p1);
tmp->next = NULL;
++p;
while (isspace((unsigned char)*p)) while (isspace((unsigned char)*p))
++p; ++p;
if (*p != '=') { if (*p != '=') {
@@ -179,6 +171,14 @@ parse_binding(FILE *f, unsigned *lineno, char *p,
++p; ++p;
while(isspace((unsigned char)*p)) while(isspace((unsigned char)*p))
++p; ++p;
tmp = malloc(sizeof(*tmp));
if (tmp == NULL) {
*error_message = "out of memory";
return -1;
}
*p2 = '\0';
tmp->name = strdup(p1);
tmp->next = NULL;
if (*p == '{') { if (*p == '{') {
tmp->type = krb5_config_list; tmp->type = krb5_config_list;
tmp->u.list = NULL; tmp->u.list = NULL;
@@ -219,13 +219,13 @@ krb5_config_parse_file_debug (const char *fname,
s = NULL; s = NULL;
b = NULL; b = NULL;
*lineno = 0;
f = fopen (fname, "r"); f = fopen (fname, "r");
if (f == NULL) { if (f == NULL) {
*error_message = "cannot open file"; *error_message = "cannot open file";
return -1; return -1;
} }
*res = NULL; *res = NULL;
*lineno = 0;
while (fgets(buf, sizeof(buf), f) != NULL) { while (fgets(buf, sizeof(buf), f) != NULL) {
char *p; char *p;