Changes in kernel/generic/src/console/kconsole.c [feeac0d:aca4a04] in mainline
- File:
-
- 1 edited
-
kernel/generic/src/console/kconsole.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
rfeeac0d raca4a04 53 53 #include <func.h> 54 54 #include <str.h> 55 #include <macros.h> 55 56 #include <sysinfo/sysinfo.h> 56 57 #include <ddi/device.h> … … 118 119 * Make sure the command is not already listed. 119 120 */ 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 121 124 if (hlp == cmd) { 122 125 /* The command is already there. */ … … 199 202 * 200 203 */ 201 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * indev)204 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * indev) 202 205 { 203 206 const char *name = input; 204 207 205 208 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 */ 211 211 size_t max_match_len = size; 212 212 size_t max_match_len_tmp = size; … … 229 229 } 230 230 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. */ 235 232 if (found > MAX_TAB_HINTS) { 236 233 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); 239 235 } 240 236 … … 244 240 while (cmdtab_search_one(name, &pos)) { 245 241 cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link); 246 242 247 243 if (continue_showing_hints) { 248 244 printf("%s (%s)\n", hlp->name, hlp->description); 249 245 --hints_to_show; 250 246 ++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); 256 250 } 257 251 } 258 252 259 253 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); 266 256 max_match_len = max_match_len_tmp; 267 257 } 268 269 /* Keep only the characters common in all completions */ 258 /* keep only the characters common in all completions */ 270 259 output[max_match_len] = 0; 271 260 } … … 321 310 continue; 322 311 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 */ 327 314 size_t beg; 328 315 for (beg = position - 1; (beg > 0) && (!isspace(current[beg])); … … 346 333 continue; 347 334 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. */ 352 337 size_t off = 0; 353 338 size_t i = 0; … … 355 340 if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE)) 356 341 break; 357 358 342 i++; 359 343 } … … 521 505 /* It's a number - convert it */ 522 506 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); 527 508 switch (rc) { 528 509 case EINVAL: 529 printf("Invalid number '%s'.\n", text);510 printf("Invalid number.\n"); 530 511 return false; 531 512 case EOVERFLOW: 532 printf("Integer overflow in '%s'.\n", text);513 printf("Integer overflow.\n"); 533 514 return false; 534 515 case EOK: … … 538 519 break; 539 520 default: 540 printf("Unknown error parsing '%s'.\n", text);521 printf("Unknown error.\n"); 541 522 return false; 542 523 } … … 610 591 cmd_info_t *cmd = NULL; 611 592 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); 613 595 spinlock_lock(&hlp->lock); 614 596
Note:
See TracChangeset
for help on using the changeset viewer.
