hexdump: formatting and variable name cleanup
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
This commit is contained in:
parent
dabfe2ad7c
commit
d6e5614e5d
|
@ -73,12 +73,12 @@ conv_c(PR *pr, u_char *p)
|
|||
}
|
||||
if (isprint(*p)) {
|
||||
*pr->cchar = 'c';
|
||||
(void)printf(pr->fmt, *p);
|
||||
printf(pr->fmt, *p);
|
||||
} else {
|
||||
(void)sprintf(buf, "%03o", (int)*p);
|
||||
sprintf(buf, "%03o", (int)*p);
|
||||
str = buf;
|
||||
strpr: *pr->cchar = 's';
|
||||
(void)printf(pr->fmt, str);
|
||||
printf(pr->fmt, str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,15 +95,15 @@ conv_u(PR *pr, u_char *p)
|
|||
/* od used nl, not lf */
|
||||
if (*p <= 0x1f) {
|
||||
*pr->cchar = 's';
|
||||
(void)printf(pr->fmt, list[*p]);
|
||||
printf(pr->fmt, list[*p]);
|
||||
} else if (*p == 0x7f) {
|
||||
*pr->cchar = 's';
|
||||
(void)printf(pr->fmt, "del");
|
||||
printf(pr->fmt, "del");
|
||||
} else if (isprint(*p)) {
|
||||
*pr->cchar = 'c';
|
||||
(void)printf(pr->fmt, *p);
|
||||
printf(pr->fmt, *p);
|
||||
} else {
|
||||
*pr->cchar = 'x';
|
||||
(void)printf(pr->fmt, (int)*p);
|
||||
printf(pr->fmt, (int)*p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,9 +162,17 @@ static void bpad(PR *pr)
|
|||
pr->flags = F_BPAD;
|
||||
pr->cchar[0] = 's';
|
||||
pr->cchar[1] = 0;
|
||||
for (p1 = pr->fmt; *p1 != '%'; ++p1);
|
||||
for (p2 = ++p1; *p1 && strchr(spec, *p1); ++p1);
|
||||
while ((*p2++ = *p1++) != 0) ;
|
||||
|
||||
p1 = pr->fmt;
|
||||
while (*p1 != '%')
|
||||
++p1;
|
||||
|
||||
p2 = ++p1;
|
||||
while (*p1 && strchr(spec, *p1))
|
||||
++p1;
|
||||
|
||||
while ((*p2++ = *p1++))
|
||||
;
|
||||
}
|
||||
|
||||
void display(void)
|
||||
|
|
|
@ -78,10 +78,8 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
/* rewrite the rules, do syntax checking */
|
||||
list_for_each(p, &fshead) {
|
||||
tfs = list_entry(p, FS, nextfs);
|
||||
rewrite(tfs);
|
||||
}
|
||||
list_for_each(p, &fshead)
|
||||
rewrite(list_entry(p, FS, nextfs));
|
||||
|
||||
next(argv);
|
||||
display();
|
||||
|
|
|
@ -56,7 +56,7 @@ newsyntax(int argc, char ***argvp)
|
|||
{
|
||||
int ch;
|
||||
char **argv;
|
||||
char *hex_offt_fmt = "\"%07.7_Ax\n\"";
|
||||
char *hex_offt = "\"%07.7_Ax\n\"";
|
||||
|
||||
static const struct option longopts[] = {
|
||||
{"one-byte-octal", no_argument, NULL, 'b'},
|
||||
|
@ -79,11 +79,11 @@ newsyntax(int argc, char ***argvp)
|
|||
while ((ch = getopt_long(argc, argv, "bcCde:f:n:os:vxhV", longopts, NULL)) != -1) {
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
add(hex_offt_fmt);
|
||||
add(hex_offt);
|
||||
add("\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"");
|
||||
break;
|
||||
case 'c':
|
||||
add(hex_offt_fmt);
|
||||
add(hex_offt);
|
||||
add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"");
|
||||
break;
|
||||
case 'C':
|
||||
|
@ -92,7 +92,7 @@ newsyntax(int argc, char ***argvp)
|
|||
add("\" |\" 16/1 \"%_p\" \"|\\n\"");
|
||||
break;
|
||||
case 'd':
|
||||
add(hex_offt_fmt);
|
||||
add(hex_offt);
|
||||
add("\"%07.7_ax \" 8/2 \" %05u \" \"\\n\"");
|
||||
break;
|
||||
case 'e':
|
||||
|
@ -105,7 +105,7 @@ newsyntax(int argc, char ***argvp)
|
|||
length = strtosize_or_err(optarg, _("failed to parse length"));
|
||||
break;
|
||||
case 'o':
|
||||
add(hex_offt_fmt);
|
||||
add(hex_offt);
|
||||
add("\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"");
|
||||
break;
|
||||
case 's':
|
||||
|
@ -115,7 +115,7 @@ newsyntax(int argc, char ***argvp)
|
|||
vflag = ALL;
|
||||
break;
|
||||
case 'x':
|
||||
add(hex_offt_fmt);
|
||||
add(hex_offt);
|
||||
add("\"%07.7_ax \" 8/2 \" %04x \" \"\\n\"");
|
||||
break;
|
||||
case 'h':
|
||||
|
@ -130,7 +130,7 @@ newsyntax(int argc, char ***argvp)
|
|||
}
|
||||
|
||||
if (list_empty(&fshead)) {
|
||||
add(hex_offt_fmt);
|
||||
add(hex_offt);
|
||||
add("\"%07.7_ax \" 8/2 \"%04x \" \"\\n\"");
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ void add(const char *fmt)
|
|||
tfu->reps = atoi((char *)savep);
|
||||
tfu->flags = F_SETREP;
|
||||
/* skip trailing white space */
|
||||
while (++p && isspace(*p))
|
||||
while (isspace(*++p))
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ void add(const char *fmt)
|
|||
badfmt(fmt);
|
||||
tfu->bcnt = atoi((char *)savep);
|
||||
/* skip trailing white space */
|
||||
while (++p && isspace(*p))
|
||||
while (isspace(*++p))
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -455,10 +455,10 @@ void rewrite(FS *fs)
|
|||
if (fu->reps > 1) {
|
||||
if (!list_empty(&fu->nextpr)) {
|
||||
pr = list_last_entry(&fu->nextpr, PR, nextpr);
|
||||
for (p1 = pr->fmt, p2 = NULL; *p1; ++p1)
|
||||
p2 = isspace(*p1) ? p1 : NULL;
|
||||
if (p2)
|
||||
pr->nospace = p2;
|
||||
for (p1 = pr->fmt, p2 = NULL; *p1; ++p1)
|
||||
p2 = isspace(*p1) ? p1 : NULL;
|
||||
if (p2)
|
||||
pr->nospace = p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue