aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2012-12-01 21:12:41 +0200
committerArnold D. Robbins <arnold@skeeve.com>2012-12-01 21:12:41 +0200
commit787d93719e61e44aa1ab66c8ecca9cd6ff4fddbf (patch)
tree4d3dea2825e530b502cf1ef7cc67488d33c3ba4b
parenta4891bca3e5b9cd33bdb8857e233042efdf77412 (diff)
downloadegawk-787d93719e61e44aa1ab66c8ecca9cd6ff4fddbf.tar.gz
egawk-787d93719e61e44aa1ab66c8ecca9cd6ff4fddbf.tar.bz2
egawk-787d93719e61e44aa1ab66c8ecca9cd6ff4fddbf.zip
Apply realloc optimization to wide string values.
-rw-r--r--ChangeLog8
-rw-r--r--eval.c16
2 files changed, 22 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6dd4c394..0b2b7f41 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-12-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * eval.c (r_interpret): For op_assign_concat, if both strings
+ have WSTRCUR, then do the realloc() and append for the
+ wide string too. Thanks to Janis Papanagnou
+ <janis_papanagnou@hotmail.com> for the discussion in
+ comp.lang.awk.
+
2012-11-10 Arnold D. Robbins <arnold@skeeve.com>
* Update to bison 2.6.5. Various files regenerated.
diff --git a/eval.c b/eval.c
index 2421aea1..57411afc 100644
--- a/eval.c
+++ b/eval.c
@@ -2160,14 +2160,26 @@ post:
t1 = force_string(*lhs);
t2 = POP_STRING();
- free_wstr(*lhs);
-
if (t1 != t2 && t1->valref == 1 && (t1->flags & PERM) == 0) {
size_t nlen = t1->stlen + t2->stlen;
erealloc(t1->stptr, char *, nlen + 2, "r_interpret");
memcpy(t1->stptr + t1->stlen, t2->stptr, t2->stlen);
t1->stlen = nlen;
t1->stptr[nlen] = '\0';
+
+#if MBS_SUPPORT
+ if ((t1->flags & WSTRCUR) != 0 && (t2->flags & WSTRCUR) != 0) {
+ size_t wlen = t1->wstlen + t2->wstlen;
+
+ erealloc(t1->wstptr, wchar_t *,
+ sizeof(wchar_t) * (wlen + 2), "r_interpret");
+ memcpy(t1->wstptr + t1->wstlen, t2->wstptr, t2->wstlen);
+ t1->wstlen = wlen;
+ t1->wstptr[wlen] = L'\0';
+ t1->flags |= WSTRCUR;
+ } else
+ free_wstr(*lhs);
+#endif
} else {
size_t nlen = t1->stlen + t2->stlen;
char *p;