zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <psprint@fastmail.com>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] getstrvalue() optimization
Date: Thu, 10 Nov 2016 00:14:24 -0800	[thread overview]
Message-ID: <1478765664.2345819.783251825.66CA877B@webmail.messagingengine.com> (raw)
In-Reply-To: <20161109123916.175e0bc6@pwslap01u.europe.root.pri>

[-- Attachment #1: Type: text/plain, Size: 203 bytes --]

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@fastmail.com

[-- Attachment #2: string_fix.diff --]
[-- Type: text/plain, Size: 663 bytes --]

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;

  reply	other threads:[~2016-11-10  8:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161108133901epcas4p257eb8a5bd308d2393769c4a3a2fc3731@epcas4p2.samsung.com>
2016-11-08 13:37 ` Sebastian Gniazdowski
2016-11-09 12:39   ` Peter Stephenson
2016-11-10  8:14     ` Sebastian Gniazdowski [this message]
2016-11-10 10:44       ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1478765664.2345819.783251825.66CA877B@webmail.messagingengine.com \
    --to=psprint@fastmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).