Changes in kernel/generic/src/console/kconsole.c [aca4a04:feeac0d] in mainline
- File:
-
- 1 edited
-
kernel/generic/src/console/kconsole.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
raca4a04 rfeeac0d 53 53 #include <func.h> 54 54 #include <str.h> 55 #include <macros.h>56 55 #include <sysinfo/sysinfo.h> 57 56 #include <ddi/device.h> … … 119 118 * Make sure the command is not already listed. 120 119 */ 121 list_foreach(cmd_list, cur) { 122 cmd_info_t *hlp = list_get_instance(cur, cmd_info_t, link); 123 120 list_foreach(cmd_list, link, cmd_info_t, hlp) { 124 121 if (hlp == cmd) { 125 122 /* The command is already there. */ … … 202 199 * 203 200 */ 204 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * indev)201 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t *indev) 205 202 { 206 203 const char *name = input; 207 204 208 205 size_t found = 0; 209 /* Maximum Match Length : Length of longest matching common substring in 210 case more than one match is found */ 206 207 /* 208 * Maximum Match Length: Length of longest matching common 209 * substring in case more than one match is found. 210 */ 211 211 size_t max_match_len = size; 212 212 size_t max_match_len_tmp = size; … … 229 229 } 230 230 231 /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */ 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 */ 232 235 if (found > MAX_TAB_HINTS) { 233 236 printf("\n"); 234 continue_showing_hints = console_prompt_display_all_hints(indev, found); 237 continue_showing_hints = 238 console_prompt_display_all_hints(indev, found); 235 239 } 236 240 … … 240 244 while (cmdtab_search_one(name, &pos)) { 241 245 cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link); 242 246 243 247 if (continue_showing_hints) { 244 248 printf("%s (%s)\n", hlp->name, hlp->description); 245 249 --hints_to_show; 246 250 ++total_hints_shown; 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); 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); 250 256 } 251 257 } 252 258 253 259 pos = pos->next; 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); 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 256 266 max_match_len = max_match_len_tmp; 257 267 } 258 /* keep only the characters common in all completions */ 268 269 /* Keep only the characters common in all completions */ 259 270 output[max_match_len] = 0; 260 271 } … … 310 321 continue; 311 322 312 /* Find the beginning of the word 313 and copy it to tmp */ 323 /* 324 * Find the beginning of the word 325 * and copy it to tmp 326 */ 314 327 size_t beg; 315 328 for (beg = position - 1; (beg > 0) && (!isspace(current[beg])); … … 333 346 continue; 334 347 335 /* We have hints, may be many. In case of more than one hint, 336 tmp will contain the common prefix. */ 348 /* 349 * We have hints, possibly many. In case of more than one hint, 350 * tmp will contain the common prefix. 351 */ 337 352 size_t off = 0; 338 353 size_t i = 0; … … 340 355 if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE)) 341 356 break; 357 342 358 i++; 343 359 } … … 505 521 /* It's a number - convert it */ 506 522 uint64_t value; 507 int rc = str_uint64_t(text, NULL, 0, true, &value); 523 char *end; 524 int rc = str_uint64_t(text, &end, 0, false, &value); 525 if (end != text + len) 526 rc = EINVAL; 508 527 switch (rc) { 509 528 case EINVAL: 510 printf("Invalid number .\n");529 printf("Invalid number '%s'.\n", text); 511 530 return false; 512 531 case EOVERFLOW: 513 printf("Integer overflow .\n");532 printf("Integer overflow in '%s'.\n", text); 514 533 return false; 515 534 case EOK: … … 519 538 break; 520 539 default: 521 printf("Unknown error .\n");540 printf("Unknown error parsing '%s'.\n", text); 522 541 return false; 523 542 } … … 591 610 cmd_info_t *cmd = NULL; 592 611 593 list_foreach(cmd_list, cur) { 594 cmd_info_t *hlp = list_get_instance(cur, cmd_info_t, link); 612 list_foreach(cmd_list, link, cmd_info_t, hlp) { 595 613 spinlock_lock(&hlp->lock); 596 614
Note:
See TracChangeset
for help on using the changeset viewer.
