summaryrefslogtreecommitdiffstats
path: root/text-utils/parse.c
diff options
context:
space:
mode:
authorOndrej Oprala2013-09-23 15:39:11 +0200
committerKarel Zak2013-11-08 12:54:52 +0100
commit89dd9eb3b4f58a1b920c4e53a6fd0062e49f936e (patch)
tree5c0577ff83c635a9c43ee648c2d22bcaaee4063c /text-utils/parse.c
parenthexdump: cleanup of redundant symbols/repeating literals (diff)
downloadkernel-qcow2-util-linux-89dd9eb3b4f58a1b920c4e53a6fd0062e49f936e.tar.gz
kernel-qcow2-util-linux-89dd9eb3b4f58a1b920c4e53a6fd0062e49f936e.tar.xz
kernel-qcow2-util-linux-89dd9eb3b4f58a1b920c4e53a6fd0062e49f936e.zip
hexdump: rewrite addfile()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Diffstat (limited to 'text-utils/parse.c')
-rw-r--r--text-utils/parse.c14
1 files changed, 8 insertions, 6 deletions
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);
}