diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-27 09:29:26 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-27 09:29:26 +0000 |
commit | 018837b84f26adf1dd43ff0f41b211a41f5289e8 (patch) | |
tree | 4e552ee5749181b14dd80da1eb05d0dc9ed86645 /string.c | |
parent | 6ffdbac5edcdeb0a9c916735cab125674c5a693d (diff) | |
download | ruby-018837b84f26adf1dd43ff0f41b211a41f5289e8.tar.gz |
* node.h (NODE_TYPESHIFT): allow 4 more bits for line numbers.
[ruby-talk:117841]
* ruby.h (FL_ABLE): nodes are not subject for flag operations.
* io.c (ARGF_FORWARD): should have specified argv explicitly,
since we no longer have frame->argv saved. [ruby-dev:24602]
* string.c (RESIZE_CAPA): check string attribute before modifying
capacity member of string structure. [ruby-dev:24594]
* ext/zlib/zlib.c (gzreader_gets): use memchr() to to gain
performance. [ruby-talk:117701]
* sprintf.c (rb_f_sprintf): raise ArgumentError for extra
arguments, unless (digit)$ style used.
* io.c (rb_io_fptr_finalize): leave stdin/stdout/stderr open in
interpreter termination. [ruby-dev:24579]
* eval.c (frame_free): Guy Decoux solved the leak problem.
Thanks. [ruby-core:03549]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -28,10 +28,12 @@ VALUE rb_cString; #define STR_ASSOC FL_USER3 +#define STR_NOCAPA (ELTS_SHARED|STR_ASSOC) #define RESIZE_CAPA(str,capacity) do {\ REALLOC_N(RSTRING(str)->ptr, char, (capacity)+1);\ - RSTRING(str)->aux.capa = (capacity);\ + if (!FL_TEST(str, STR_NOCAPA))\ + RSTRING(str)->aux.capa = (capacity);\ } while (0) VALUE rb_fs; @@ -253,14 +255,14 @@ rb_str_shared_replace(str, str2) RSTRING(str)->ptr = 0; RSTRING(str)->len = 0; RSTRING(str)->aux.capa = 0; - FL_UNSET(str, ELTS_SHARED|STR_ASSOC); + FL_UNSET(str, STR_NOCAPA); return; } RSTRING(str)->ptr = RSTRING(str2)->ptr; RSTRING(str)->len = RSTRING(str2)->len; - FL_UNSET(str, ELTS_SHARED|STR_ASSOC); - if (FL_TEST(str2, ELTS_SHARED|STR_ASSOC)) { - FL_SET(str, RBASIC(str2)->flags & (ELTS_SHARED|STR_ASSOC)); + FL_UNSET(str, STR_NOCAPA); + if (FL_TEST(str2, STR_NOCAPA)) { + FL_SET(str, RBASIC(str2)->flags & STR_NOCAPA); RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared; } else { @@ -269,7 +271,7 @@ rb_str_shared_replace(str, str2) RSTRING(str2)->ptr = 0; /* abandon str2 */ RSTRING(str2)->len = 0; RSTRING(str2)->aux.capa = 0; - FL_UNSET(str2, ELTS_SHARED|STR_ASSOC); + FL_UNSET(str2, STR_NOCAPA); if (OBJ_TAINTED(str2)) OBJ_TAINT(str); } @@ -480,7 +482,7 @@ str_make_independent(str) ptr[RSTRING(str)->len] = 0; RSTRING(str)->ptr = ptr; RSTRING(str)->aux.capa = RSTRING(str)->len; - FL_UNSET(str, ELTS_SHARED|STR_ASSOC); + FL_UNSET(str, STR_NOCAPA); } void @@ -643,7 +645,7 @@ rb_str_resize(str, len) rb_str_modify(str); if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) { REALLOC_N(RSTRING(str)->ptr, char, len+1); - if (!FL_TEST(str, STR_ASSOC|ELTS_SHARED)) { + if (!FL_TEST(str, STR_NOCAPA)) { RSTRING(str)->aux.capa = len; } } @@ -1615,7 +1617,7 @@ rb_str_splice(str, beg, len, val) StringValue(val); if (len < RSTRING(val)->len) { /* expand string */ - RESIZE_CAPA(str, RSTRING(str)->len + RSTRING(val)->len - len); + RESIZE_CAPA(str, RSTRING(str)->len + RSTRING(val)->len - len + 1); } if (RSTRING(val)->len != len) { @@ -2252,7 +2254,7 @@ rb_str_clear(str) free(RSTRING(str)->ptr); } RSTRING(str)->aux.shared = 0; - FL_UNSET(str, ELTS_SHARED|STR_ASSOC); + FL_UNSET(str, STR_NOCAPA); RSTRING(str)->ptr = 0; RARRAY(str)->len = 0; return str; |