diff options
author | Keith Packard <keithp@keithp.com> | 2012-07-10 20:32:31 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-07-10 20:32:31 -0700 |
commit | aafa8859ecb27383f697b98f6991643b44f4721a (patch) | |
tree | ba6e7a61539bf9f6253b184b23882829e31a3758 /src/core/ao_cmd.c | |
parent | a60c5a728530e4659a6750d8d5b87000735d4531 (diff) |
altos: Save some memory.
A few minor space savings in ao_cmd.c and ao_config.c. Don't build
unused conversion functions ao_altitude_to_pres and ao_temp_to_dC
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core/ao_cmd.c')
-rw-r--r-- | src/core/ao_cmd.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/core/ao_cmd.c b/src/core/ao_cmd.c index fbf0c347..05dbfb51 100644 --- a/src/core/ao_cmd.c +++ b/src/core/ao_cmd.c @@ -37,9 +37,15 @@ put_string(__code char *s) } static void +backspace(void) +{ + put_string ("\010 \010"); +} + +static void readline(void) { - __pdata char c; + char c; if (ao_echo()) put_string("> "); cmd_len = 0; @@ -50,7 +56,7 @@ readline(void) if (c == '\010' || c == '\177') { if (cmd_len != 0) { if (ao_echo()) - put_string("\010 \010"); + backspace(); --cmd_len; } continue; @@ -60,7 +66,7 @@ readline(void) if (c == '\025') { while (cmd_len != 0) { if (ao_echo()) - put_string("\010 \010"); + backspace(); --cmd_len; } continue; @@ -76,11 +82,8 @@ readline(void) break; } - if (cmd_len >= CMD_LEN - 2) { - if (ao_echo()) - putchar('\007'); + if (cmd_len >= CMD_LEN - 2) continue; - } cmd_line[cmd_len++] = c; if (ao_echo()) putchar(c); @@ -271,13 +274,12 @@ help(void) __pdata uint8_t cmds; __pdata uint8_t cmd; __code struct ao_cmds * __pdata cs; + const char *h; for (cmds = 0; cmds < ao_ncmds; cmds++) { cs = ao_cmds[cmds]; - for (cmd = 0; cs[cmd].func; cmd++) - printf("%-45s %s\n", - cs[cmd].help, - cs[cmd].help+1+strlen(cs[cmd].help)); + for (cmd = 0; (h = cs[cmd].help); cmd++) + printf("%-45s %s\n", h, h + 1 + strlen(h)); } } |