blob: dc44cc40cca81a3bbbd8bf8519d633f8c0028b43 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#include <stdio.h>
#include <string.h>
#include "pbc_memory.h"
char *pbc_getline(const char *prompt) {
char s[1024];
if (prompt) fputs(prompt, stdout);
if (!fgets(s, 1024, stdin)) return NULL;
if (feof(stdin)) return NULL;
/* use strdup rather than pbc_strdup. because
* 1. readline version of this function uses malloc.
* 2. pbc_malloc called by pbc_strdup may differ from malloc.
* here we keep consistency.
*/
return strdup(s);
}
|