Changes in kernel/generic/src/console/kconsole.c [4ce914d4:a7199c2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
r4ce914d4 ra7199c2 160 160 161 161 /** Print count times a character */ 162 static void print_cc(wchar_t ch, size_t count)162 NO_TRACE static void print_cc(wchar_t ch, size_t count) 163 163 { 164 164 size_t i; … … 168 168 169 169 /** Try to find a command beginning with prefix */ 170 static const char *cmdtab_search_one(const char *name, link_t **startpos) 170 NO_TRACE static const char *cmdtab_search_one(const char *name, 171 link_t **startpos) 171 172 { 172 173 size_t namelen = str_length(name); … … 202 203 * 203 204 */ 204 static int cmdtab_compl(char *input, size_t size)205 NO_TRACE static int cmdtab_compl(char *input, size_t size) 205 206 { 206 207 const char *name = input; … … 209 210 link_t *pos = NULL; 210 211 const char *hint; 211 char output[MAX_CMDLINE];212 char *output = malloc(MAX_CMDLINE, 0); 212 213 213 214 output[0] = 0; … … 234 235 str_cpy(input, size, output); 235 236 237 free(output); 236 238 return found; 237 239 } 238 240 239 static wchar_t *clever_readline(const char *prompt, indev_t *indev)241 NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev) 240 242 { 241 243 printf("%s> ", prompt); … … 244 246 wchar_t *current = history[history_pos]; 245 247 current[0] = 0; 248 char *tmp = malloc(STR_BOUNDS(MAX_CMDLINE), 0); 246 249 247 250 while (true) { … … 288 291 beg++; 289 292 290 char tmp[STR_BOUNDS(MAX_CMDLINE)];291 293 wstr_to_str(tmp, position - beg + 1, current + beg); 292 294 … … 414 416 } 415 417 418 free(tmp); 416 419 return current; 417 420 } … … 422 425 } 423 426 424 static bool parse_int_arg(const char *text, size_t len, unative_t *result) 427 NO_TRACE static bool parse_int_arg(const char *text, size_t len, 428 unative_t *result) 425 429 { 426 430 bool isaddr = false; … … 507 511 * 508 512 */ 509 static bool parse_argument(const char *cmdline, size_t size, size_t *start, size_t *end) 513 NO_TRACE static bool parse_argument(const char *cmdline, size_t size, 514 size_t *start, size_t *end) 510 515 { 511 516 ASSERT(start != NULL); … … 543 548 * 544 549 */ 545 static cmd_info_t *parse_cmdline(const char *cmdline, size_t size)550 NO_TRACE static cmd_info_t *parse_cmdline(const char *cmdline, size_t size) 546 551 { 547 552 size_t start = 0; … … 590 595 size_t i; 591 596 for (i = 0; i < cmd->argc; i++) { 597 char *buf; 598 592 599 start = end; 593 600 if (!parse_argument(cmdline, size, &start, &end)) { 601 if (cmd->argv[i].type == ARG_TYPE_STRING_OPTIONAL) { 602 buf = (char *) cmd->argv[i].buffer; 603 str_cpy(buf, cmd->argv[i].len, ""); 604 continue; 605 } 606 594 607 printf("Too few arguments.\n"); 595 608 spinlock_unlock(&cmd->lock); … … 597 610 } 598 611 599 char *buf;600 612 switch (cmd->argv[i].type) { 601 613 case ARG_TYPE_STRING: 614 case ARG_TYPE_STRING_OPTIONAL: 602 615 buf = (char *) cmd->argv[i].buffer; 603 616 str_ncpy(buf, cmd->argv[i].len, cmdline + start, … … 619 632 cmd->argv[i].vartype = ARG_TYPE_STRING; 620 633 } else { 621 printf("Wrong syn xtax.\n");634 printf("Wrong syntax.\n"); 622 635 error = true; 623 636 } … … 677 690 printf("Type \"exit\" to leave the console.\n"); 678 691 692 char *cmdline = malloc(STR_BOUNDS(MAX_CMDLINE), 0); 679 693 while (true) { 680 694 wchar_t *tmp = clever_readline((char *) prompt, stdin); … … 683 697 continue; 684 698 685 char cmdline[STR_BOUNDS(MAX_CMDLINE)];686 699 wstr_to_str(cmdline, STR_BOUNDS(MAX_CMDLINE), tmp); 687 700 … … 695 708 (void) cmd_info->func(cmd_info->argv); 696 709 } 710 free(cmdline); 697 711 } 698 712
Note:
See TracChangeset
for help on using the changeset viewer.