Properly parse numbers in od(1)
Previously, it'd drop right through in the number case and return crazy-long numbers (like 28 for L), resulting in unexpected behaviour.
This commit is contained in:
parent
1eff1e8214
commit
ecb351f1d5
7
od.c
7
od.c
@ -224,11 +224,10 @@ main(int argc, char *argv[])
|
|||||||
case 'x':
|
case 'x':
|
||||||
t->format = *s;
|
t->format = *s;
|
||||||
/* todo: allow multiple digits */
|
/* todo: allow multiple digits */
|
||||||
if (*(s+1) > '0' || *(s+1) <= '9') {
|
if (*(s+1) > '0' && *(s+1) <= '9') {
|
||||||
t->len = *(s+1) - '0';
|
t->len = *(++s) - '0';
|
||||||
s++;
|
|
||||||
} else {
|
} else {
|
||||||
switch (*(s + 1)) {
|
switch (*(++s)) {
|
||||||
case 'C':
|
case 'C':
|
||||||
t->len = sizeof(char);
|
t->len = sizeof(char);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user