mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-25 17:20:25 +02:00
39887: no need to conditionalise assignment of strlen()
This commit is contained in:
parent
a1633e09a7
commit
65ea1a033b
2 changed files with 5 additions and 6 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
2016-11-09 Peter Stephenson <p.stephenson@samsung.com>
|
2016-11-09 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
|
* 39887: Src/params.c: no need to conditionalise assignment of
|
||||||
|
strlen in getstrvalue().
|
||||||
|
|
||||||
* 39886 based on 39877 (Sebastian): Src/params.c, Src/utils.c:
|
* 39886 based on 39877 (Sebastian): Src/params.c, Src/utils.c:
|
||||||
add arrdup_max() so as not to duplicate entire arrays unnecessarily.
|
add arrdup_max() so as not to duplicate entire arrays unnecessarily.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2060,7 +2060,7 @@ getstrvalue(Value v)
|
||||||
{
|
{
|
||||||
char *s, **ss;
|
char *s, **ss;
|
||||||
char buf[BDIGBUFSIZE];
|
char buf[BDIGBUFSIZE];
|
||||||
int len = -1;
|
int len;
|
||||||
|
|
||||||
if (!v)
|
if (!v)
|
||||||
return hcalloc(1);
|
return hcalloc(1);
|
||||||
|
|
@ -2237,15 +2237,13 @@ getstrvalue(Value v)
|
||||||
if (v->start == 0 && v->end == -1)
|
if (v->start == 0 && v->end == -1)
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
|
len = strlen(s);
|
||||||
if (v->start < 0) {
|
if (v->start < 0) {
|
||||||
len = strlen(s);
|
|
||||||
v->start += len;
|
v->start += len;
|
||||||
if (v->start < 0)
|
if (v->start < 0)
|
||||||
v->start = 0;
|
v->start = 0;
|
||||||
}
|
}
|
||||||
if (v->end < 0) {
|
if (v->end < 0) {
|
||||||
if (len < 0)
|
|
||||||
len = strlen(s);
|
|
||||||
v->end += len;
|
v->end += len;
|
||||||
if (v->end >= 0) {
|
if (v->end >= 0) {
|
||||||
char *eptr = s + v->end;
|
char *eptr = s + v->end;
|
||||||
|
|
@ -2254,8 +2252,6 @@ getstrvalue(Value v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len < 0)
|
|
||||||
len = strlen(s);
|
|
||||||
s = (v->start > len) ? dupstring("") :
|
s = (v->start > len) ? dupstring("") :
|
||||||
dupstring_wlen(s + v->start, len - v->start);
|
dupstring_wlen(s + v->start, len - v->start);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue