shithub: nvi

Download patch

ref: d81d2b35559fea6684cee44a5d4f494fc585e38d
parent: 785d0c9f871d6d89d551ffb2184937264c6eec1f
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Jul 30 16:53:06 EDT 2022

jstrdup: remove 

--- a/util.c
+++ b/util.c
@@ -191,10 +191,25 @@
 	return (j == nil || (type >= 0 && j->t != type)) ? nil : j;
 }
 
+static char *
+strclean(char *s)
+{
+	char *s₀, *o;
+
+	s₀ = s;
+	for(o = s; *s; s++){
+		if(*s != 0xd)
+			*o++ = *s;
+	}
+	*o = 0;
+
+	return s₀;
+}
+
 char *
 jstrdup(JSON *j, char *name)
 {
-	return estrdup(jsonstr(jsonbyname(j, name)));
+	return strclean(estrdup(jsonstr(jsonbyname(j, name))));
 }
 
 vlong