Ignore:
File:
1 edited

Legend:

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

    rdc0e41c r6b00876  
    362362                                putchar(current[position]);
    363363                       
    364                         if (position == 0)
    365                                 continue;
    366364                       
    367365                        /*
     
    370368                         */
    371369                        size_t beg;
    372                         for (beg = position - 1; (beg > 0) && (!isspace(current[beg]));
    373                             beg--);
    374                        
    375                         if (isspace(current[beg]))
    376                                 beg++;
    377                        
    378                         wstr_to_str(tmp, position - beg + 1, current + beg);
    379                        
     370                        unsigned sp = 0, narg = 0;
     371                        if (position == 0) {
     372                                tmp[0] = '\0';
     373                                beg = 0;
     374                        }
     375                        else {
     376                                for (beg = position - 1; (beg > 0) && (!isspace(current[beg]));
     377                                    beg--);
     378                               
     379                                if (isspace(current[beg]))
     380                                        beg++;
     381                               
     382                                wstr_to_str(tmp, position - beg + 1, current + beg);
     383                        }
     384                       
     385                        /* Count which argument number are we tabbing (narg=0 is cmd) */
     386                        for (; beg > 0; beg--) {
     387                                if (isspace(current[beg])) {
     388                                        if (!sp) {
     389                                                narg++;
     390                                                sp = 1;
     391                                        }
     392                                }
     393                                else
     394                                        sp = 0;
     395                        }
     396                        if (narg && isspace(current[0]))
     397                                narg--;
     398
    380399                        int found;
    381                         if (beg == 0) {
     400                        if (narg == 0) {
    382401                                /* Command completion */
    383402                                found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev,
     
    386405                                /* Arguments completion */
    387406                                cmd_info_t *cmd = parse_cmd(current);
    388                                 if (!cmd || !cmd->hints_enum)
     407                                if (!cmd || !cmd->hints_enum || cmd->argc < narg)
    389408                                        continue;
    390409                                found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev,
Note: See TracChangeset for help on using the changeset viewer.