# HG changeset patch # User Tero Marttila # Date 1397232229 -10800 # Node ID 53743ecc9150652e71a629e62b3c9e1922d8164d # Parent 0cf14786b909271531187426fc1349c2c19e6b41 dmx: bugfix argv[0] = 0 on command, limits on set diff -r 0cf14786b909 -r 53743ecc9150 src/hello-dmx.c --- a/src/hello-dmx.c Fri Apr 11 15:57:48 2014 +0300 +++ b/src/hello-dmx.c Fri Apr 11 19:03:49 2014 +0300 @@ -83,7 +83,7 @@ { byte i; - for (i = 0; i < console.argc; i++) { + for (i = 0; i < console.argc && i < DMX_COUNT; i++) { dmx.out[i] = console.argv[i]; } @@ -101,14 +101,19 @@ return '!'; } - byte i = console.argv[0]; + if (console.argv[0] == 0) { + return '!'; + } - for (byte a = 1; a < console.argc; a++) { + byte i = console.argv[0] - 1; + + for (byte a = 1; a < console.argc && i < DMX_COUNT; a++) { dmx.out[i++] = console.argv[a]; } - if (i > dmx.count) + if (i > dmx.count) { dmx.count = i; + } return 0; } @@ -187,6 +192,7 @@ if (console.state == CMD) { console.state = ARG; console.argc = 0; + console.argv[0] = 0; return ',';