[hackers] [sbase] Properly parse numbers in od(1) || FRIGN

From: <git_AT_suckless.org>
Date: Mon, 26 Oct 2015 12:55:51 +0100 (CET)

commit ecb351f1d58f0be6bbaea73786b1c9a1b9d16151
Author: FRIGN <dev_AT_frign.de>
AuthorDate: Mon Oct 26 12:52:14 2015 +0100
Commit: sin <sin_AT_2f30.org>
CommitDate: Mon Oct 26 11:55:41 2015 +0000

    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.

diff --git a/od.c b/od.c
index 0c361e2..4b3023b 100644
--- a/od.c
+++ b/od.c
_AT_@ -224,11 +224,10 @@ main(int argc, char *argv[])
                         case 'x':
                                 t->format = *s;
                                 /* todo: allow multiple digits */
- if (*(s+1) > '0' || *(s+1) <= '9') {
- t->len = *(s+1) - '0';
- s++;
+ if (*(s+1) > '0' && *(s+1) <= '9') {
+ t->len = *(++s) - '0';
                                 } else {
- switch (*(s + 1)) {
+ switch (*(++s)) {
                                         case 'C':
                                                 t->len = sizeof(char);
                                                 break;
Received on Mon Oct 26 2015 - 12:55:51 CET

This archive was generated by hypermail 2.3.0 : Mon Oct 26 2015 - 13:00:30 CET