]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hexdump: rewrite addfile()
authorOndrej Oprala <ooprala@redhat.com>
Mon, 23 Sep 2013 13:39:11 +0000 (15:39 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 8 Nov 2013 11:54:52 +0000 (12:54 +0100)
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
text-utils/parse.c

index 0584e022ca759386d6404e5c1cd57be84b10c2a8..bae5b877d496d0493299af1629d6e60f603c48af 100644 (file)
@@ -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);
 }