aboutsummaryrefslogtreecommitdiffstats
path: root/moon-abe/pbc-0.5.14/pbc/pbc_getline.c
diff options
context:
space:
mode:
Diffstat (limited to 'moon-abe/pbc-0.5.14/pbc/pbc_getline.c')
-rw-r--r--moon-abe/pbc-0.5.14/pbc/pbc_getline.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/moon-abe/pbc-0.5.14/pbc/pbc_getline.c b/moon-abe/pbc-0.5.14/pbc/pbc_getline.c
new file mode 100644
index 00000000..dc44cc40
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/pbc_getline.c
@@ -0,0 +1,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);
+}