From 89dd9eb3b4f58a1b920c4e53a6fd0062e49f936e Mon Sep 17 00:00:00 2001 From: Ondrej Oprala Date: Mon, 23 Sep 2013 15:39:11 +0200 Subject: hexdump: rewrite addfile() Signed-off-by: Ondrej Oprala --- text-utils/parse.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'text-utils/parse.c') diff --git a/text-utils/parse.c b/text-utils/parse.c index 0584e022c..bae5b877d 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); } -- cgit v1.2.3-55-g7522