From a2a581c24dcf2c77900b770475cfc466fae504a1 Mon Sep 17 00:00:00 2001 From: Arne Goedeke <el@laramies.com> Date: Sun, 25 Aug 2013 09:32:15 +0200 Subject: [PATCH] Revert "propagate CLEAR_ON_EXIT flag in string operations" This reverts commit c39be4e9c6787f7a03bdb7ab7f1506fdacaf972c. --- src/builtin_functions.c | 6 ------ src/operators.c | 25 +++++++++++-------------- src/stralloc.c | 12 ++++-------- src/stralloc.h | 2 -- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/builtin_functions.c b/src/builtin_functions.c index 05189fa8e7..15dcd69efc 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -706,7 +706,6 @@ PMOD_EXPORT void f_lower_case(INT32 args) ret = end_shared_string(ret); ret->flags |= STRING_IS_LOWERCASE; - ret->flags |= orig->flags & STRING_CLEAR_ON_EXIT; pop_n_elems(args); push_string(ret); } @@ -814,7 +813,6 @@ PMOD_EXPORT void f_upper_case(INT32 args) pop_n_elems(args); ret = end_shared_string(ret); ret->flags |= STRING_IS_UPPERCASE; - ret->flags |= orig->flags & STRING_CLEAR_ON_EXIT; push_string(ret); } @@ -1781,7 +1779,6 @@ PMOD_EXPORT void f_string_to_unicode(INT32 args) #endif } pop_n_elems(args); - out->flags |= in->flags & STRING_CLEAR_ON_EXIT; push_string(out); } @@ -1941,7 +1938,6 @@ PMOD_EXPORT void f_unicode_to_string(INT32 args) } out = end_shared_string(out); pop_n_elems(args); - out->flags |= in->flags & STRING_CLEAR_ON_EXIT; push_string(out); } @@ -2086,7 +2082,6 @@ PMOD_EXPORT void f_string_to_utf8(INT32 args) #endif /* PIKE_DEBUG */ out = end_shared_string(out); pop_n_elems(args); - out->flags |= in->flags & STRING_CLEAR_ON_EXIT; push_string(out); } @@ -2440,7 +2435,6 @@ PMOD_EXPORT void f_utf8_to_string(INT32 args) check_string (out); #endif pop_n_elems(args); - out->flags |= in->flags & STRING_CLEAR_ON_EXIT; push_string(out); } diff --git a/src/operators.c b/src/operators.c index 43808e9858..2dcbc8019b 100644 --- a/src/operators.c +++ b/src/operators.c @@ -2741,31 +2741,28 @@ PMOD_EXPORT void o_and(void) #define STRING_BITOP(OP,STROP) \ case T_STRING: \ { \ - struct pike_string *s, *a, *b; \ + struct pike_string *s; \ ptrdiff_t len, i; \ - a = sp[-2].u.string; \ - b = sp[-1].u.string; \ - len = a->len; \ - if (len != b->len) \ + \ + len = sp[-2].u.string->len; \ + if (len != sp[-1].u.string->len) \ PIKE_ERROR("`" #OP, "Bitwise "STROP \ " on strings of different lengths.\n", sp, 2); \ - if(!a->size_shift && !b->size_shift) \ + if(!sp[-2].u.string->size_shift && !sp[-1].u.string->size_shift) \ { \ s = begin_shared_string(len); \ for (i=0; i<len; i++) \ - s->str[i] = a->str[i] OP b->str[i]; \ + s->str[i] = sp[-2].u.string->str[i] OP sp[-1].u.string->str[i]; \ }else{ \ s = begin_wide_shared_string(len, \ - MAXIMUM(a->size_shift, \ - b->size_shift)); \ + MAXIMUM(sp[-2].u.string->size_shift, \ + sp[-1].u.string->size_shift)); \ for (i=0; i<len; i++) \ - low_set_index(s,i,index_shared_string(a,i) OP \ - index_shared_string(b,i)); \ + low_set_index(s,i,index_shared_string(sp[-2].u.string,i) OP \ + index_shared_string(sp[-1].u.string,i)); \ } \ - s = end_shared_string(s); \ - s->flags |= (a->flags | b->flags) & STRING_CLEAR_ON_EXIT; \ pop_n_elems(2); \ - push_string(s); \ + push_string(end_shared_string(s)); \ return; \ } diff --git a/src/stralloc.c b/src/stralloc.c index 91da878185..5d97026659 100644 --- a/src/stralloc.c +++ b/src/stralloc.c @@ -1778,8 +1778,7 @@ struct pike_string *realloc_unlinked_string(struct pike_string *a, if(!r) { r=begin_wide_shared_string(size, a->size_shift); - /* we keep both content information and the clear flags */ - r->flags |= a->flags & (STRING_CONTENT_MASK|STRING_CLEAR_ON_EXIT); + r->flags |= a->flags & ~15; r->min = a->min; r->max = a->max; if (a->len <= size) { @@ -1807,8 +1806,7 @@ static struct pike_string *realloc_shared_string(struct pike_string *a, }else{ r=begin_wide_shared_string(size,a->size_shift); MEMCPY(r->str, a->str, a->len<<a->size_shift); - /* we keep both content information and the clear flags */ - r->flags |= a->flags & (STRING_CONTENT_MASK|STRING_CLEAR_ON_EXIT); + r->flags |= a->flags & ~15; r->min = a->min; r->max = a->max; free_string(a); @@ -1823,7 +1821,7 @@ struct pike_string *new_realloc_shared_string(struct pike_string *a, INT32 size, r=begin_wide_shared_string(size,shift); pike_string_cpy(MKPCHARP_STR(r),a); - r->flags |= (a->flags & (STRING_CONTENT_MASK|STRING_CLEAR_ON_EXIT)); + r->flags |= (a->flags & ~15); r->min = a->min; r->max = a->max; free_string(a); @@ -1996,7 +1994,7 @@ PMOD_EXPORT void set_flags_for_add( struct pike_string *ret, struct pike_string *b) { if( !b->len ) { - ret->flags |= aflags & (STRING_CONTENT_MASK|STRING_CLEAR_ON_EXIT); + ret->flags |= aflags & ~15; ret->min = amin; ret->max = amax; return; @@ -2012,7 +2010,6 @@ PMOD_EXPORT void set_flags_for_add( struct pike_string *ret, ret->flags &= ~(STRING_IS_LOWERCASE | STRING_IS_UPPERCASE); ret->flags |= (aflags & b->flags & (STRING_IS_LOWERCASE | STRING_IS_UPPERCASE)); - ret->flags |= (aflags | b->flags) & STRING_CLEAR_ON_EXIT; } PMOD_EXPORT void update_flags_for_add( struct pike_string *a, struct pike_string *b) @@ -2030,7 +2027,6 @@ PMOD_EXPORT void update_flags_for_add( struct pike_string *a, struct pike_string } a->flags &= ~(STRING_IS_LOWERCASE | STRING_IS_UPPERCASE) | b->flags; - a->flags |= b->flags & STRING_CLEAR_ON_EXIT; } /*** Add strings ***/ diff --git a/src/stralloc.h b/src/stralloc.h index 2f90e6629f..951d3f6c6d 100644 --- a/src/stralloc.h +++ b/src/stralloc.h @@ -62,8 +62,6 @@ struct string_builder #define STRING_IS_LOWERCASE 32 #define STRING_IS_UPPERCASE 64 -#define STRING_CONTENT_MASK (STRING_CONTENT_CHECKED|STRING_IS_LOWERCASE|STRING_IS_UPPERCASE) - #define CLEAR_STRING_CHECKED(X) do{(X)->flags &= 15;}while(0) /* Flags used by string_builder_append_integer() */ -- GitLab