Use strtoul() instead of atoi() and cast arg of remaining ctype fns

to unsigned char.
This commit is contained in:
dsl 2004-11-11 20:14:02 +00:00
parent ba1f693b99
commit 9dbf8d89fe

View File

@ -1,4 +1,4 @@
/* $NetBSD: txtwalk.c,v 1.10 2003/11/30 14:36:44 dsl Exp $ */ /* $NetBSD: txtwalk.c,v 1.11 2004/11/11 20:14:02 dsl Exp $ */
/* /*
* Copyright 1997 Piermont Information Systems Inc. * Copyright 1997 Piermont Information Systems Inc.
@ -131,6 +131,7 @@ process(struct lookfor *item, char *line)
struct data found[MAXDATA]; struct data found[MAXDATA];
size_t numfound = 0; size_t numfound = 0;
const char *p; const char *p;
char *np;
size_t i, j; size_t i, j;
int error; int error;
@ -158,8 +159,11 @@ process(struct lookfor *item, char *line)
p++; p++;
if (*p) if (*p)
p++; p++;
while (*p && isdigit(*p)) { for (;;) {
i = atoi(p); i = strtoul(p, &np, 10);
if (p == np)
break;
p = np;
switch (found[i].what) { switch (found[i].what) {
case INT: case INT:
*((int *)item->var+j) *((int *)item->var+j)
@ -171,8 +175,6 @@ process(struct lookfor *item, char *line)
item->size); item->size);
break; break;
} }
while (isdigit(*p))
p++;
while (*p && *p != '$') while (*p && *p != '$')
p++; p++;
if (*p) if (*p)
@ -204,6 +206,8 @@ finddata(struct lookfor *item, char *line, struct data *found, size_t *numfound)
{ {
const char *fmt; const char *fmt;
size_t len; size_t len;
char *np;
int i;
*numfound = 0; *numfound = 0;
for (fmt = item->fmt; *fmt; fmt++) { for (fmt = item->fmt; *fmt; fmt++) {
@ -223,23 +227,23 @@ finddata(struct lookfor *item, char *line, struct data *found, size_t *numfound)
if (!fmt[1]) if (!fmt[1])
return 1; return 1;
if (fmt[1] == ' ') if (fmt[1] == ' ')
while (*line && !isspace(*line)) while (*line && !isspace((unsigned char)*line))
line++; line++;
else else
while (*line && *line != fmt[1]) while (*line && *line != fmt[1])
line++; line++;
break; break;
case 'd': /* Nextoken should be an integer. */ case 'd': /* Nextoken should be an integer. */
if (!isdigit(*line)) i = strtoul(line, &np, 10);
if (line == np)
return 0; return 0;
found[*numfound].what = INT; found[*numfound].what = INT;
found[(*numfound)++].u.i_val = atoi(line); found[(*numfound)++].u.i_val = i;
while (*line && isdigit(*line)) line = np;
line++;
break; break;
case 's': /* Matches a 'space' separated string. */ case 's': /* Matches a 'space' separated string. */
len = 0; len = 0;
while (line[len] && !isspace(line[len]) while (line[len] && !isspace((unsigned char)line[len])
&& line[len] != fmt[1]) && line[len] != fmt[1])
len++; len++;
found[*numfound].what = STR; found[*numfound].what = STR;
@ -254,7 +258,7 @@ finddata(struct lookfor *item, char *line, struct data *found, size_t *numfound)
} }
if (*fmt == ' ') { if (*fmt == ' ') {
while (*line && isspace(*line)) while (isspace((unsigned char)*line))
line++; line++;
continue; continue;
} }