diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-30 15:33:03 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-30 15:33:03 +0000 |
commit | c2a9b62fd2f5c107fcff2e21052e4e9e2294e8ce (patch) | |
tree | f6ffbb816a1fb52687c289d2e109fb02c32a5352 /string.c | |
parent | e7bb5176f67ac39add861b6539fe40898f2af6c0 (diff) | |
download | ruby-c2a9b62fd2f5c107fcff2e21052e4e9e2294e8ce.tar.gz |
* string.c (rb_str_locktmp): lock string temporarily.
* string.c (str_independent): add tmplock check.
* io.c (io_write): lock output string temporarily.
[ruby-dev:24649]
* io.c (io_write): use rb_str_locktmp().
* io.c (read_all): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -27,6 +27,7 @@ VALUE rb_cString; +#define STR_TMPLOCK FL_USER1 #define STR_ASSOC FL_USER3 #define STR_NOCAPA (ELTS_SHARED|STR_ASSOC) @@ -462,6 +463,9 @@ static int str_independent(str) VALUE str; { + if (FL_TEST(str, STR_TMPLOCK)) { + rb_raise(rb_eRuntimeError, "can't modify string; temporarily locked"); + } if (OBJ_FROZEN(str)) rb_error_frozen("string"); if (!OBJ_TAINTED(str) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify string"); @@ -633,6 +637,22 @@ rb_str_dup_frozen(str) } VALUE +rb_str_locktmp(str) + VALUE str; +{ + FL_SET(str, STR_TMPLOCK); + return str; +} + +VALUE +rb_str_unlocktmp(str) + VALUE str; +{ + FL_UNSET(str, STR_TMPLOCK); + return str; +} + +VALUE rb_str_resize(str, len) VALUE str; long len; |