|
|
|
@ -11,7 +11,7 @@ struct cmd main_cmds[] = { |
|
|
|
|
|
|
|
|
|
static char *prompt(const char *prefix) |
|
|
|
|
{ |
|
|
|
|
char *alloc, *line, *s; |
|
|
|
|
char *alloc, *line; |
|
|
|
|
size_t nbytes = 0, nalloc_bytes = 16; |
|
|
|
|
char c; |
|
|
|
|
|
|
|
|
@ -20,8 +20,6 @@ static char *prompt(const char *prefix) |
|
|
|
|
if (!(line = malloc(nalloc_bytes))) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
s = line; |
|
|
|
|
|
|
|
|
|
while ((c = getchar()) && c != '\n') { |
|
|
|
|
putchar(c); |
|
|
|
|
|
|
|
|
@ -34,12 +32,11 @@ static char *prompt(const char *prefix) |
|
|
|
|
line = alloc; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
*s++ = c; |
|
|
|
|
nbytes++; |
|
|
|
|
line[nbytes++] = c; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
printf("\n"); |
|
|
|
|
*s = '\0'; |
|
|
|
|
line[nbytes] = '\0'; |
|
|
|
|
|
|
|
|
|
return line; |
|
|
|
|
|
|
|
|
|