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