Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] getstrvalue() optimization
- X-seq: zsh-workers 39899
- From: Sebastian Gniazdowski <psprint@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH] getstrvalue() optimization
- Date: Thu, 10 Nov 2016 00:14:24 -0800
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=c3e1xTADnIzpZLiCtuK/PLQ8bm Y=; b=2+YOs/FZWaQ2GGS1iXY2rpmlhKnYe94jdm5URAJRLx0iV0W3toAXxQsd01 c+3BKW80X4Wwfr5Ra8OrctDpNQUmyPPegytyE/hRhfosEcIiWnvPxBu3PTa6Wj/7 D1Qtcph4DpwN3AxulF8kfMUfk5JhletaQHozuu5Hi3OO7pKuk=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=smtpout; bh=c3 e1xTADnIzpZLiCtuK/PLQ8bmY=; b=q9vAPWkoWaUDbiKnH96fjxXhlNax6nRQ3H f95qn2g4/swOGCtR8wcfxP+4Fi2N/jV9Qb5ea021q7tGlh66oeFXJ+fkcbHrQwxT BIwLmk6rZIBh2MzpA+ZgCfME6f8GA6+4ulbpEkDiXFcrr6xTU/wH+e2n6gdc3BQz C20wrXPbo=
- In-reply-to: <20161109123916.175e0bc6@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20161108133901epcas4p257eb8a5bd308d2393769c4a3a2fc3731@epcas4p2.samsung.com> <1478612273.1810945.781106353.1EF6BF52@webmail.messagingengine.com> <20161109123916.175e0bc6@pwslap01u.europe.root.pri>
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