summaryrefslogtreecommitdiff
path: root/avr/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'avr/command.c')
-rw-r--r--avr/command.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/avr/command.c b/avr/command.c
index c9137ea..b4a972c 100644
--- a/avr/command.c
+++ b/avr/command.c
@@ -22,6 +22,11 @@
#include "env.h"
#include "debug.h"
+#define DEBUG_CMD 1 /* set to 1 to debug */
+
+#define debug_cmd(fmt, args...) \
+ debug_cond(DEBUG_CMD, fmt, ##args)
+
jmp_buf cmd_jbuf;
@@ -64,7 +69,7 @@ int cmd_tbl_item_count(cmd_tbl_t *p)
int count = 0;
while (p->name != NULL) {
- if (p->subcmd && p->flags & CTBL_SUBCMDAUTO) {
+ if (p->subcmd) {
cmd_tbl_t *sub = p->subcmd;
while (sub->name != NULL) {
if (sub->flags & CTBL_SUBCMDAUTO)
@@ -72,7 +77,9 @@ int cmd_tbl_item_count(cmd_tbl_t *p)
sub++;
}
}
- p++; count++;
+ if ((p->flags & CTBL_SUBCMDAUTO) == 0)
+ count++;
+ p++;
}
return count;
}
@@ -110,7 +117,7 @@ cmd_tbl_t *_find_cmd (const char *cmd, cmd_tbl_t *table, find_cmd_para_t *para)
cmdtp_ret = cmdtp; /* abbreviated command ? */
n_found++;
- } else if (cmdtp->subcmd && cmdtp->flags & CTBL_SUBCMDAUTO) {
+ } else if (cmdtp->subcmd) {
cmd_tbl_t *sub = _find_cmd(cmd, cmdtp->subcmd, para);
if (sub && sub->flags & CTBL_SUBCMDAUTO) {
cmdtp_ret = sub;
@@ -179,12 +186,11 @@ command_ret_t do_help(cmd_tbl_t *cmdtp, uint_fast8_t flag UNUSED, int argc, char
cmd_tbl_t *tp = tbl_start;
int i = 0;
while (tp->name != NULL) {
- uint_fast8_t len;
- if (tp->subcmd && tp->flags & CTBL_SUBCMDAUTO) {
+ if (tp->subcmd) {
cmd_tbl_t *sub = tp->subcmd;
while (sub->name != NULL) {
if (sub->flags & CTBL_SUBCMDAUTO) {
- len = strlen_P(sub->name);
+ uint_fast8_t len = strlen_P(sub->name);
if (len > maxlen_cmd)
maxlen_cmd = len;
cmd_list[i++] = sub;
@@ -192,10 +198,13 @@ command_ret_t do_help(cmd_tbl_t *cmdtp, uint_fast8_t flag UNUSED, int argc, char
sub++;
}
}
- len = strlen_P(tp->name);
- if (len > maxlen_cmd)
- maxlen_cmd = len;
- cmd_list[i++] = tp++;
+ if ((tp->flags & CTBL_SUBCMDAUTO) == 0) {
+ uint_fast8_t len = strlen_P(tp->name);
+ if (len > maxlen_cmd)
+ maxlen_cmd = len;
+ cmd_list[i++] = tp;
+ }
+ tp++;
}
/* Sort command list */
qsort(cmd_list, cmd_items, sizeof (cmd_tbl_t *), cmpstring_PP);