diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | interpret.h | 16 |
2 files changed, 22 insertions, 2 deletions
@@ -1,3 +1,11 @@ +2012-12-01 Arnold D. Robbins <arnold@skeeve.com> + + * interpret.h: 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-30 Arnold D. Robbins <arnold@skeeve.com> * regcomp.c, regex.c, regex_internal.h, regexec.c: Sync diff --git a/interpret.h b/interpret.h index 26725a21..21cd9a80 100644 --- a/interpret.h +++ b/interpret.h @@ -622,8 +622,6 @@ mod: t1 = force_string(*lhs); t2 = POP_STRING(); - free_wstr(*lhs); - if (t1 != *lhs) { unref(*lhs); *lhs = dupnode(t1); @@ -637,6 +635,20 @@ mod: t1->stlen = nlen; t1->stptr[nlen] = '\0'; t1->flags &= ~(NUMCUR|NUMBER|NUMINT); + +#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; |