[prev in list] [next in list] [prev in thread] [next in thread] 

List:       monetdb-checkins
Subject:    MonetDB: port-monetdblite - Use mnstr_* instead of stdio functions.
From:       Pedro Ferreira <commits+pedro.ferreira=monetdbsolutions.com () monetdb ! org>
Date:       2019-01-30 15:32:46
Message-ID: hg.9d63efa61173.1548862366.6315528441665844383 () monetdb-vm0 ! spin-off ! cwi ! nl
[Download RAW message or body]

Changeset: 9d63efa61173 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9d63efa61173
Modified Files:
	monetdb5/mal/mal_readline.c
Branch: port-monetdblite
Log Message:

Use mnstr_* instead of stdio functions.


diffs (40 lines):

diff --git a/monetdb5/mal/mal_readline.c b/monetdb5/mal/mal_readline.c
--- a/monetdb5/mal/mal_readline.c
+++ b/monetdb5/mal/mal_readline.c
@@ -24,8 +24,8 @@
 static void
 showCommands(void)
 {
-	printf("?\t - show this message\n");
-	printf("\\q\t- terminate session\n");
+	mnstr_printf(GDKout, "?\t - show this message\n");
+	mnstr_printf(GDKout, "\\q\t- terminate session\n");
 }
 
 char *
@@ -40,8 +40,8 @@ getConsoleInput(Client c, const char *pr
 
 	do {
 		if (prompt) {
-			fputs(prompt, stdout);
-			fflush(stdout);
+			mnstr_writeStr(GDKout, prompt);
+			mnstr_flush(GDKout);
 		}
 		if (buf == NULL) {
 			buf= malloc(BUFSIZ);
@@ -50,9 +50,11 @@ getConsoleInput(Client c, const char *pr
 				return NULL;
 			}
 		}
-		line = fgets(buf, BUFSIZ, stdin);
-
-		if (line == NULL) {
+		if (mnstr_read(GDKin, buf, 1, BUFSIZ) > 0)
+			line = buf;
+		else
+			line = NULL;
+		if (line == NULL || *line == '\0') {
 			/* end of file */
 			if (buf)
 				free(buf);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic