1 --- gawk-3.1.5/field.c.freewstr 2007-01-15 11:02:51.000000000 +0100
2 +++ gawk-3.1.5/field.c 2007-01-15 11:21:56.000000000 +0100
4 ofs = force_string(OFS_node->var_value);
6 for (i = NF; i > 0; i--) {
7 + free_wstr(fields_arr[i]);
9 tmp = force_string(tmp);
14 unsigned long int tmp;
15 - if (i >= fw_alloc) {
16 + if (i + 1 >= fw_alloc) {
18 erealloc(FIELDWIDTHS, int *, fw_alloc * sizeof(int), "set_FIELDWIDTHS");
20 --- gawk-3.1.5/builtin.c.freewstr 2005-07-26 20:07:43.000000000 +0200
21 +++ gawk-3.1.5/builtin.c 2007-01-15 11:12:52.000000000 +0100
26 - if (wc_indices != NULL)
29 + if (wc_indices != NULL)
31 } else { /* match failed */
39 + t->flags &= ~(NUMCUR|NUMBER);
42 if (matches > 0 && lhs) {
45 if (after_assign != NULL)
47 - t->flags &= ~(NUMCUR|NUMBER);
49 if (mb_indices != NULL)
51 --- gawk-3.1.5/awk.h.freewstr 2005-07-26 20:07:43.000000000 +0200
52 +++ gawk-3.1.5/awk.h 2007-01-15 11:02:51.000000000 +0100
54 #define force_wstring(n) str2wstr(n, NULL)
55 extern const wchar_t *wstrstr P((const wchar_t *haystack, size_t hs_len, const wchar_t *needle, size_t needle_len));
56 extern const wchar_t *wcasestrstr P((const wchar_t *haystack, size_t hs_len, const wchar_t *needle, size_t needle_len));
57 +extern void free_wstr P((NODE *n));
59 +#define free_wstr(NODE) /* empty */
62 extern Regexp *make_regexp P((const char *s, size_t len, int ignorecase, int dfa));
63 --- gawk-3.1.5/node.c.freewstr 2007-01-15 11:02:51.000000000 +0100
64 +++ gawk-3.1.5/node.c 2007-01-15 11:33:44.000000000 +0100
66 if (! do_traditional && isnondecimal(cp, TRUE)) {
67 n->numbr = nondec2awknum(cp, cpend - cp);
77 -#if defined MBS_SUPPORT
78 - if ((s->flags & WSTRCUR) != 0) {
79 - assert(s->wstptr != NULL);
83 - s->flags &= ~WSTRCUR;
92 r->flags &= ~(PERM|TEMP|FIELD);
94 -#if defined MBS_SUPPORT
97 + * DON'T call free_wstr(r) here!
98 + * r->wstptr still points at n->wstptr's value, and we
99 + * don't want to free it!
103 #endif /* defined MBS_SUPPORT */
104 if (n->type == Node_val && (n->flags & STRCUR) != 0) {
110 -#if defined MBS_SUPPORT
113 - r->flags &= ~WSTRCUR;
114 -#endif /* MBS_SUPPORT */
116 #endif /* GAWKDEBUG */
119 @@ -365,10 +360,11 @@
122 r->flags = (STRING|STRCUR|MALLOC);
123 -#if defined MBS_SUPPORT
128 +#endif /* defined MBS_SUPPORT */
130 if (flags & ALREADY_MALLOCED)
133 @@ -512,20 +508,13 @@
137 -#if defined MBS_SUPPORT
138 - if (tmp->wstptr != NULL) {
139 - assert((tmp->flags & WSTRCUR) != 0);
142 - tmp->flags &= ~WSTRCUR;
143 - tmp->wstptr = NULL;
151 if ((tmp->flags & FIELD) != 0) {
159 fall through and recompute to fill in the array */
162 - if (n->wstptr != NULL) {
166 + if (n->wstptr != NULL)
186 +/* free_wstr --- release the wide string part of a node */
191 + if ((n->flags & WSTRCUR) != 0) {
192 + assert(n->wstptr != NULL);
197 + n->flags &= ~WSTRCUR;
202 dump_wstr(FILE *fp, const wchar_t *str, size_t len)
203 --- gawk-3.1.5/dfa.c.freewstr 2007-01-15 11:13:19.000000000 +0100
204 +++ gawk-3.1.5/dfa.c 2007-01-15 11:17:44.000000000 +0100
207 work_mbc->nchars = work_mbc->nranges = work_mbc->nch_classes = 0;
208 work_mbc->nequivs = work_mbc->ncoll_elems = 0;
209 - work_mbc->chars = NULL;
210 work_mbc->ch_classes = NULL;
211 work_mbc->range_sts = work_mbc->range_ends = NULL;
212 work_mbc->equivs = work_mbc->coll_elems = NULL;
213 @@ -1602,8 +1601,8 @@
214 d->states[i].constraint = 0;
215 d->states[i].first_end = 0;
217 - if (MB_CUR_MAX > 1)
218 - d->states[i].mbps.nelem = 0;
219 + d->states[i].mbps.nelem = 0;
220 + d->states[i].mbps.elems = NULL;
222 for (j = 0; j < s->nelem; ++j)
223 if (d->tokens[s->elems[j].index] < 0)
224 @@ -3136,8 +3135,13 @@
226 #endif /* MBS_SUPPORT */
228 - for (i = 0; i < d->sindex; ++i)
229 + for (i = 0; i < d->sindex; ++i) {
230 free((ptr_t) d->states[i].elems.elems);
232 + if (d->states[i].mbps.nelem > 0)
233 + free((ptr_t) d->states[i].mbps.elems);
234 +#endif /* MBS_SUPPORT */
236 free((ptr_t) d->states);
237 for (i = 0; i < d->tindex; ++i)
238 if (d->follows[i].elems)
239 --- gawk-3.1.5/eval.c.freewstr 2007-01-15 11:02:51.000000000 +0100
240 +++ gawk-3.1.5/eval.c 2007-01-15 11:02:51.000000000 +0100
241 @@ -1176,13 +1176,7 @@
242 memcpy(l->stptr + l->stlen, r->stptr, r->stlen);
243 l->stlen += r->stlen;
244 l->stptr[l->stlen] = '\0';
245 -#if defined MBS_SUPPORT
246 - if (r->wstptr != NULL)
250 - r->flags &= ~WSTRCUR;
251 -#endif /* MBS_SUPPORT */
255 size_t nlen = l->stlen + r->stlen + 2;