From: Ondrej Oprala Date: Mon, 23 Sep 2013 13:39:11 +0000 (+0200) Subject: hexdump: rewrite addfile() X-Git-Tag: v2.25-rc1~769 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89dd9eb3b4f58a1b920c4e53a6fd0062e49f936e;p=thirdparty%2Futil-linux.git hexdump: rewrite addfile() Signed-off-by: Ondrej Oprala --- diff --git a/text-utils/parse.c b/text-utils/parse.c index 0584e022ca..bae5b877d4 100644 --- a/text-utils/parse.c +++ b/text-utils/parse.c @@ -55,7 +55,7 @@ FU *endfu; /* format at end-of-data */ void addfile(char *name) { - unsigned char *p; + char *p; FILE *fp; int ch; char buf[2048 + 1]; @@ -63,16 +63,18 @@ void addfile(char *name) if ((fp = fopen(name, "r")) == NULL) err(EXIT_FAILURE, _("can't read %s"), name); while (fgets(buf, sizeof(buf), fp)) { - if ((p = (unsigned char *)strchr(buf, '\n')) == NULL) { + if ((p = strchr(buf, '\n')) == NULL) { warnx(_("line too long")); - while ((ch = getchar()) != '\n' && ch != EOF); + while ((ch = getchar()) != '\n' && ch != EOF) + ; continue; } - *p = '\0'; - for (p = (unsigned char *)buf; *p && isspace(*p); ++p); + p = buf; + while (*p && isspace(*p)) + ++p; if (!*p || *p == '#') continue; - add((char *)p); + add(p); } fclose(fp); }