Changeset 0cfc18d3 in mainline


Ignore:
Timestamp:
2016-03-16T09:10:42Z (8 years ago)
Author:
Aurelio Colosimo <aurelio@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6b00876
Parents:
722bb5a
Message:

kconsole tab completion: count arguments while tabbing them

This avoids tab completion hints when current argument exceeds arguments
count (argc) declared by current command.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/kconsole.c

    r722bb5a r0cfc18d3  
    370370                         */
    371371                        size_t beg;
     372                        unsigned sp = 0, narg = 0;
    372373                        for (beg = position - 1; (beg > 0) && (!isspace(current[beg]));
    373374                            beg--);
     
    378379                        wstr_to_str(tmp, position - beg + 1, current + beg);
    379380                       
     381                        /* Count which argument number are we tabbing (narg=0 is cmd) */
     382                        for (; beg > 0; beg--) {
     383                                if (isspace(current[beg])) {
     384                                        if (!sp) {
     385                                                narg++;
     386                                                sp = 1;
     387                                        }
     388                                }
     389                                else
     390                                        sp = 0;
     391                        }
     392                        if (narg && isspace(current[0]))
     393                                narg--;
     394
    380395                        int found;
    381                         if (beg == 0) {
     396                        if (narg == 0) {
    382397                                /* Command completion */
    383398                                found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev,
     
    386401                                /* Arguments completion */
    387402                                cmd_info_t *cmd = parse_cmd(current);
    388                                 if (!cmd || !cmd->hints_enum)
     403                                if (!cmd || !cmd->hints_enum || cmd->argc < narg)
    389404                                        continue;
    390405                                found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev,
Note: See TracChangeset for help on using the changeset viewer.