nausea

curses audio visualizer
git clone git://git.2f30.org/nausea
Log | Files | Refs | README | LICENSE

commit 3e70c5f4f3767f8efb55093c5050e651447a3165
parent 05dcd091e4ed6b514c50c118002dae0b992ac90b
Author: lostd <lostd@2f30.org>
Date:   Tue, 16 Jun 2015 19:20:50 +0100

Convert arg to number and check bounds

Diffstat:
Mnausea.c | 20+++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/nausea.c b/nausea.c @@ -622,23 +622,9 @@ main(int argc, char *argv[]) if (*++argv == NULL) usage(); argc--; - switch (*argv[0]) { - case '1': - vidx = 0; - break; - case '2': - vidx = 1; - break; - case '3': - vidx = 2; - break; - case '4': - vidx = 3; - break; - case '5': - vidx = 4; - break; - } + vidx = *argv[0] - '0' - 1; + if (vidx < 0 || vidx > LEN(visuals) - 1) + errx(1, "illegal visual index"); break; case 'c': colors = 1;