X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=test_src%2Fserial-tools.c;h=7bfd25d747e4cea3c121368a7e9ece1db9bb0bdd;hb=bce0505abf49276430f7439960829683b4daf53b;hp=47b64396985d5c448c3427bed1c38eb82c780d3c;hpb=2159c273c9d3361571a6ff1ab63d9bc76582fbab;p=avr-crypto-lib.git diff --git a/test_src/serial-tools.c b/test_src/serial-tools.c index 47b6439..7bfd25d 100644 --- a/test_src/serial-tools.c +++ b/test_src/serial-tools.c @@ -1,6 +1,6 @@ /* serial-tools.c */ /* - This file is part of the Crypto-avr-lib/microcrypt-lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -30,13 +30,15 @@ #include #include -int getnextwordn(char *s, int n){ /* words are seperated by spaces */ +int getnextwordn(char *s, int n){ /* words are seperated by spaces, lf or cr */ char c = ' '; - while ((c=uart_getc()) == ' ') - ; + do{ + c=uart_getc(); + }while(c==' ' || c=='\r' || c=='\n'); *s++ = c; - while (n && (*s++=uart_getc())!=' ') - ; + do{ + *s++ = c = uart_getc(); + }while(c!=' ' && c!='\r' && c!='\n' && --n); *(s-1) = '\0'; return n; }