Use strtok_r rather than strtok. Saves a stack frame, two bytes of global, and fixes backwards compatibility with older avr-libc versions.

Fixes issue #131

git-svn-id: https://arducopter.googlecode.com/svn/trunk@554 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
DrZiplok@gmail.com 2010-09-25 18:13:08 +00:00
parent 4b09c9fade
commit 6838829428
1 changed files with 3 additions and 2 deletions

View File

@ -32,6 +32,7 @@ Menu::run(void)
uint8_t len, i, ret;
uint8_t argc;
int c;
char *s;
// loop performing commands
for (;;) {
@ -74,10 +75,10 @@ Menu::run(void)
// split the input line into tokens
argc = 0;
_argv[argc++].str = strtok(_inbuf, " ");
_argv[argc++].str = strtok_r(_inbuf, " ", &s);
// XXX should an empty line by itself back out of the current menu?
while (argc <= MENU_ARGS_MAX) {
_argv[argc].str = strtok(NULL, " ");
_argv[argc].str = strtok_r(NULL, " ", &s);
if ('\0' == _argv[argc].str)
break;
_argv[argc].i = atol(_argv[argc].str);