[hackers] [PATCH 09/17] Fix type of c in getrhs()

From: quinq <quinq_AT_fifth.space>
Date: Tue, 6 Mar 2018 12:58:01 +0100

From: "Roberto E. Vargas Caballero" <k0ga_AT_shike2.com>

C is compared against EOF, so it cannot be char.
---
 ed.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/ed.c b/ed.c
index fb4faf9..0f86759 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -926,15 +926,14 @@ static void
 getrhs(int delim)
 {
 	int c;
-	size_t siz, cap;
-	static char *s;
+	static String s;
 
-	free(s);
-	s = NULL;
-	siz = cap = 0;
+	free(s.str);
+	s.str = NULL;
+	s.siz = s.cap = 0;
 	while ((c = input()) != '\n' && c != EOF && c != delim)
-		s = addchar(c, s, &siz, &cap);
-	s = addchar('\0', s, &siz, &cap);
+		addchar_(c, &s);
+	addchar_('\0', &s);
 	if (c == EOF)
 		error("invalid pattern delimiter");
 	if (c == '\n') {
_AT_@ -942,15 +941,15 @@ getrhs(int delim)
 		back(c);
 	}
 
-	if (!strcmp("%", s)) {
-		free(s);
+	if (!strcmp("%", s.str)) {
+		free(s.str);
 		if (!rhs)
 			error("no previous substitution");
 	} else {
 		free(rhs);
-		rhs = s;
+		rhs = s.str;
 	}
-	s = NULL;
+	s.str = NULL;
 }
 
 static int
-- 
2.14.2
Received on Tue Mar 06 2018 - 12:58:01 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 06 2018 - 13:02:29 CET