[PATCH] Don't return newline from VMS-specific readline.

"Craig A. Berry" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
readline is documented to return a line without the trailing
newline, but we haven't been doing this in our homegrown version
so would sometimes see doubled newlines in fisql.
---
 vms/getpass.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/vms/getpass.c b/vms/getpass.c
index b7d1ecb..d11c744 100644
--- a/vms/getpass.c
+++ b/vms/getpass.c
@@ -279,7 +279,7 @@ getpass(const char *prompt)
 char *
 readline(char *prompt)
 {
-	char *buf = NULL, *s = NULL, *p = NULL;
+	char *buf = NULL, *s = NULL, *p = NULL, *newline = NULL;
 	if (tds_rl_instream == NULL)
 		s = readpassphrase((const char *) prompt, passbuf, sizeof(passbuf),
 					 RPP_ECHO_ON | RPP_TIMEOUT_OFF);
@@ -290,6 +290,13 @@ readline(char *prompt)
 		buf = (char *) malloc(strlen(s) + 1);
 		strcpy(buf, s);
 	}
+	/* readline is documented to eat the newline. */
+	if (buf) {
+		newline = strchr(buf, '\n');
+		if (newline)
+			*newline = '\0';
+	}
+
 	return buf;

 }				/* readline */
--
1.8.4.2
________________________________________
Craig A. Berry
mailto:[email protected]

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
0002-Don-t-return-newline-from-VMS-specific-readline.patch (application/octet-stream, 1.2 KB)
From 01cfdafc72eb60f4fa99cedbe8894d1dafd262c2 Mon Sep 17 00:00:00 2001
From: "Craig A. Berry" <[email protected]>
Date: Fri, 30 May 2014 10:56:35 -0500
Subject: [PATCH 2/3] Don't return newline from VMS-specific readline.

readline is documented to return a line without the trailing
newline, but we haven't been doing this in our homegrown version
so would sometimes see doubled newlines in fisql.
---
 vms/getpass.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/vms/getpass.c b/vms/getpass.c
index b7d1ecb..d11c744 100644
--- a/vms/getpass.c
+++ b/vms/getpass.c
@@ -279,7 +279,7 @@ getpass(const char *prompt)
 char *
 readline(char *prompt)
 {
-	char *buf = NULL, *s = NULL, *p = NULL;
+	char *buf = NULL, *s = NULL, *p = NULL, *newline = NULL;
 	if (tds_rl_instream == NULL)
 		s = readpassphrase((const char *) prompt, passbuf, sizeof(passbuf),
 					 RPP_ECHO_ON | RPP_TIMEOUT_OFF);
@@ -290,6 +290,13 @@ readline(char *prompt)
 		buf = (char *) malloc(strlen(s) + 1);
 		strcpy(buf, s);
 	}
+	/* readline is documented to eat the newline. */
+	if (buf) {
+		newline = strchr(buf, '\n');
+		if (newline)
+			*newline = '\0';
+	}
+
 	return buf;
 
 }				/* readline */
-- 
1.8.4.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.