Ignore:
File:
1 edited

Legend:

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

    rfeeac0d raca4a04  
    5353#include <func.h>
    5454#include <str.h>
     55#include <macros.h>
    5556#include <sysinfo/sysinfo.h>
    5657#include <ddi/device.h>
     
    118119         * Make sure the command is not already listed.
    119120         */
    120         list_foreach(cmd_list, link, cmd_info_t, hlp) {
     121        list_foreach(cmd_list, cur) {
     122                cmd_info_t *hlp = list_get_instance(cur, cmd_info_t, link);
     123               
    121124                if (hlp == cmd) {
    122125                        /* The command is already there. */
     
    199202 *
    200203 */
    201 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)
    202205{
    203206        const char *name = input;
    204207       
    205208        size_t found = 0;
    206        
    207         /*
    208          * Maximum Match Length: Length of longest matching common
    209          * substring in case more than one match is found.
    210          */
     209        /* Maximum Match Length : Length of longest matching common substring in
     210           case more than one match is found */
    211211        size_t max_match_len = size;
    212212        size_t max_match_len_tmp = size;
     
    229229        }
    230230       
    231         /*
    232          * If the number of possible completions is more than MAX_TAB_HINTS,
    233          * ask the user whether to display them or not.
    234          */
     231        /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */
    235232        if (found > MAX_TAB_HINTS) {
    236233                printf("\n");
    237                 continue_showing_hints =
    238                     console_prompt_display_all_hints(indev, found);
     234                continue_showing_hints = console_prompt_display_all_hints(indev, found);
    239235        }
    240236       
     
    244240                while (cmdtab_search_one(name, &pos)) {
    245241                        cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link);
    246                        
     242
    247243                        if (continue_showing_hints) {
    248244                                printf("%s (%s)\n", hlp->name, hlp->description);
    249245                                --hints_to_show;
    250246                                ++total_hints_shown;
    251                                
    252                                 if ((hints_to_show == 0) && (total_hints_shown != found)) {
    253                                         /* Ask user to continue */
    254                                         continue_showing_hints =
    255                                             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);
    256250                                }
    257251                        }
    258                        
     252
    259253                        pos = pos->next;
    260                        
    261                         for (max_match_len_tmp = 0;
    262                             (output[max_match_len_tmp] ==
    263                             hlp->name[input_len + max_match_len_tmp]) &&
    264                             (max_match_len_tmp < max_match_len); ++max_match_len_tmp);
    265                        
     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);
    266256                        max_match_len = max_match_len_tmp;
    267257                }
    268                
    269                 /* Keep only the characters common in all completions */
     258                /* keep only the characters common in all completions */
    270259                output[max_match_len] = 0;
    271260        }
     
    321310                                continue;
    322311                       
    323                         /*
    324                          * Find the beginning of the word
    325                          * and copy it to tmp
    326                          */
     312                        /* Find the beginning of the word
     313                           and copy it to tmp */
    327314                        size_t beg;
    328315                        for (beg = position - 1; (beg > 0) && (!isspace(current[beg]));
     
    346333                                continue;
    347334
    348                         /*
    349                          * We have hints, possibly many. In case of more than one hint,
    350                          * tmp will contain the common prefix.
    351                          */
     335                        /* We have hints, may be many. In case of more than one hint,
     336                           tmp will contain the common prefix. */
    352337                        size_t off = 0;
    353338                        size_t i = 0;
     
    355340                                if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE))
    356341                                        break;
    357                                
    358342                                i++;
    359343                        }
     
    521505                /* It's a number - convert it */
    522506                uint64_t value;
    523                 char *end;
    524                 int rc = str_uint64_t(text, &end, 0, false, &value);
    525                 if (end != text + len)
    526                         rc = EINVAL;
     507                int rc = str_uint64_t(text, NULL, 0, true, &value);
    527508                switch (rc) {
    528509                case EINVAL:
    529                         printf("Invalid number '%s'.\n", text);
     510                        printf("Invalid number.\n");
    530511                        return false;
    531512                case EOVERFLOW:
    532                         printf("Integer overflow in '%s'.\n", text);
     513                        printf("Integer overflow.\n");
    533514                        return false;
    534515                case EOK:
     
    538519                        break;
    539520                default:
    540                         printf("Unknown error parsing '%s'.\n", text);
     521                        printf("Unknown error.\n");
    541522                        return false;
    542523                }
     
    610591        cmd_info_t *cmd = NULL;
    611592       
    612         list_foreach(cmd_list, link, cmd_info_t, hlp) {
     593        list_foreach(cmd_list, cur) {
     594                cmd_info_t *hlp = list_get_instance(cur, cmd_info_t, link);
    613595                spinlock_lock(&hlp->lock);
    614596               
Note: See TracChangeset for help on using the changeset viewer.