Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] getstrvalue() optimization



Hello,
I thought to make some things clear, not sure if without this any
problems are possible (tried to obtain bad behavior but Zsh worked
normally).

-- 
  Sebastian Gniazdowski
  psprint@xxxxxxxxxxxx
diff --git a/Src/params.c b/Src/params.c
index ef72cba..0d17047 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2060,7 +2060,7 @@ getstrvalue(Value v)
 {
     char *s, **ss;
     char buf[BDIGBUFSIZE];
-    int len;
+    int len, zerol=0;
 
     if (!v)
 	return hcalloc(1);
@@ -2255,9 +2255,12 @@ getstrvalue(Value v)
     s = (v->start > len) ? dupstring("") :
 	dupstring_wlen(s + v->start, len - v->start);
 
+    if (s[0] == '\0')
+        zerol = 1;
+
     if (v->end <= v->start)
 	s[0] = '\0';
-    else if (v->end - v->start <= len - v->start)
+    else if (!zerol && v->end - v->start <= len - v->start)
 	s[v->end - v->start] = '\0';
 
     return s;


Messages sorted by: Reverse Date, Date, Thread, Author