Ignore:
File:
1 edited

Legend:

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

    r9b11a971 raca4a04  
    202202 *
    203203 */
    204 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t *indev)
     204NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * indev)
    205205{
    206206        const char *name = input;
    207207       
    208208        size_t found = 0;
    209        
    210         /*
    211          * Maximum Match Length: Length of longest matching common
    212          * substring in case more than one match is found.
    213          */
     209        /* Maximum Match Length : Length of longest matching common substring in
     210           case more than one match is found */
    214211        size_t max_match_len = size;
    215212        size_t max_match_len_tmp = size;
     
    232229        }
    233230       
    234         /*
    235          * If the number of possible completions is more than MAX_TAB_HINTS,
    236          * ask the user whether to display them or not.
    237          */
     231        /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */
    238232        if (found > MAX_TAB_HINTS) {
    239233                printf("\n");
    240                 continue_showing_hints =
    241                     console_prompt_display_all_hints(indev, found);
     234                continue_showing_hints = console_prompt_display_all_hints(indev, found);
    242235        }
    243236       
     
    247240                while (cmdtab_search_one(name, &pos)) {
    248241                        cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link);
    249                        
     242
    250243                        if (continue_showing_hints) {
    251244                                printf("%s (%s)\n", hlp->name, hlp->description);
    252245                                --hints_to_show;
    253246                                ++total_hints_shown;
    254                                
    255                                 if ((hints_to_show == 0) && (total_hints_shown != found)) {
    256                                         /* Ask user to continue */
    257                                         continue_showing_hints =
    258                                             console_prompt_more_hints(indev, &hints_to_show);
     247
     248                                if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */
     249                                        continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show);
    259250                                }
    260251                        }
    261                        
     252
    262253                        pos = pos->next;
    263                        
    264                         for (max_match_len_tmp = 0;
    265                             (output[max_match_len_tmp] ==
    266                             hlp->name[input_len + max_match_len_tmp]) &&
    267                             (max_match_len_tmp < max_match_len); ++max_match_len_tmp);
    268                        
     254                        for(max_match_len_tmp = 0; output[max_match_len_tmp] == hlp->name[input_len + max_match_len_tmp]
     255                                        && max_match_len_tmp < max_match_len; ++max_match_len_tmp);
    269256                        max_match_len = max_match_len_tmp;
    270257                }
    271                
    272                 /* Keep only the characters common in all completions */
     258                /* keep only the characters common in all completions */
    273259                output[max_match_len] = 0;
    274260        }
     
    324310                                continue;
    325311                       
    326                         /*
    327                          * Find the beginning of the word
    328                          * and copy it to tmp
    329                          */
     312                        /* Find the beginning of the word
     313                           and copy it to tmp */
    330314                        size_t beg;
    331315                        for (beg = position - 1; (beg > 0) && (!isspace(current[beg]));
     
    349333                                continue;
    350334
    351                         /*
    352                          * We have hints, possibly many. In case of more than one hint,
    353                          * tmp will contain the common prefix.
    354                          */
     335                        /* We have hints, may be many. In case of more than one hint,
     336                           tmp will contain the common prefix. */
    355337                        size_t off = 0;
    356338                        size_t i = 0;
     
    358340                                if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE))
    359341                                        break;
    360                                
    361342                                i++;
    362343                        }
     
    524505                /* It's a number - convert it */
    525506                uint64_t value;
    526                 char *end;
    527                 int rc = str_uint64_t(text, &end, 0, false, &value);
    528                 if (end != text + len)
    529                         rc = EINVAL;
     507                int rc = str_uint64_t(text, NULL, 0, true, &value);
    530508                switch (rc) {
    531509                case EINVAL:
    532                         printf("Invalid number '%s'.\n", text);
     510                        printf("Invalid number.\n");
    533511                        return false;
    534512                case EOVERFLOW:
    535                         printf("Integer overflow in '%s'.\n", text);
     513                        printf("Integer overflow.\n");
    536514                        return false;
    537515                case EOK:
     
    541519                        break;
    542520                default:
    543                         printf("Unknown error parsing '%s'.\n", text);
     521                        printf("Unknown error.\n");
    544522                        return false;
    545523                }
Note: See TracChangeset for help on using the changeset viewer.