summaryrefslogtreecommitdiff
path: root/Src/Zle/compcore.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2025-01-30 12:41:53 +0100
committerOliver Kiddle <opk@zsh.org>2025-01-30 12:42:09 +0100
commit86a0891952f8cd83138bc2b6fe760190c67c8ff9 (patch)
tree8c3ff83942f5092a30b475c21a125b4950631fdd /Src/Zle/compcore.c
parentf7b5cc431bdda1f7123aca740bf7c535b98ca616 (diff)
downloadzsh-86a0891952f8cd83138bc2b6fe760190c67c8ff9.tar.gz
zsh-86a0891952f8cd83138bc2b6fe760190c67c8ff9.zip
53335: Remove unused dupstring_glen() function
Also make use of the dupstring_wlen() variant in more places to avoid a strlen()
Diffstat (limited to 'Src/Zle/compcore.c')
-rw-r--r--Src/Zle/compcore.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 09282d42d..fb703f801 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -708,7 +708,7 @@ callcompfunc(char *s, char *fn)
sav = *ss;
*ss = '\0';
- tmp = (linwhat == IN_MATH ? dupstring(s) : multiquote(s, 0));
+ tmp = (linwhat == IN_MATH ? dupstring_wlen(s, offs) : multiquote(s, 0));
untokenize(tmp);
compprefix = ztrdup(tmp);
*ss = sav;
@@ -1820,7 +1820,7 @@ set_comp_sep(void)
*/
sav = s[(i = swb - 1 - sqq + dq)];
s[i] = '\0';
- qp = (qttype == QT_SINGLE) ? dupstring(s) : rembslash(s);
+ qp = (qttype == QT_SINGLE) ? dupstring_wlen(s, i) : rembslash(s);
s[i] = sav;
if (swe < swb)
swe = swb;
@@ -2244,10 +2244,10 @@ addmatches(Cadata dat, char **argv)
if (dat->aflags & CAF_MATCH) {
lipre = dupstring(compiprefix);
lisuf = dupstring(compisuffix);
- lpre = dupstring(compprefix);
- lsuf = dupstring(compsuffix);
- llpl = strlen(lpre);
- llsl = strlen(lsuf);
+ llpl = strlen(compprefix);
+ llsl = strlen(compsuffix);
+ lpre = dupstring_wlen(compprefix, llpl);
+ lsuf = dupstring_wlen(compsuffix, llsl);
/* This used to reference compqiprefix and compqisuffix, why? */
if (llpl + (int)strlen(qipre) + (int)strlen(lipre) != origlpre
@@ -2300,12 +2300,8 @@ addmatches(Cadata dat, char **argv)
for (p = lpre + 2; *p && *p != ')'; p++);
if (*p == ')') {
- char sav = p[1];
-
- p[1] = '\0';
- globflag = dupstring(lpre);
gfl = p - lpre + 1;
- p[1] = sav;
+ globflag = dupstring_wlen(lpre, gfl);
lpre = p + 1;
llpl -= gfl;
@@ -2731,7 +2727,7 @@ add_match_data(int alt, char *str, char *orig, Cline line,
sl = tsl;
}
if (qisl) {
- Cline qsl = bld_parts(dupstring(qisuf), qisl, qisl, NULL, NULL);
+ Cline qsl = bld_parts(dupstring_wlen(qisuf, qisl), qisl, qisl, NULL, NULL);
qsl->flags |= CLF_SUF;
qsl->suffix = qsl->prefix;
@@ -2814,7 +2810,7 @@ add_match_data(int alt, char *str, char *orig, Cline line,
line = p;
}
if (qipl) {
- Cline lp, p = bld_parts(dupstring(qipre), qipl, qipl, &lp, NULL);
+ Cline lp, p = bld_parts(dupstring_wlen(qipre, qipl), qipl, qipl, &lp, NULL);
lp->next = line;
line = p;