diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/dbm/dbm.c | 20 | ||||
-rw-r--r-- | ext/gdbm/gdbm.c | 24 | ||||
-rw-r--r-- | ext/iconv/charset_alias.rb | 4 | ||||
-rw-r--r-- | ext/sdbm/init.c | 20 |
4 files changed, 49 insertions, 19 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c index c422394405..1e4fe00fe7 100644 --- a/ext/dbm/dbm.c +++ b/ext/dbm/dbm.c @@ -280,6 +280,16 @@ fdbm_values_at(argc, argv, obj) return new; } +static void +fdbm_modify(obj) + VALUE obj; +{ + rb_secure(4); + if (OBJ_FROZEN_P(obj)) { + if (OBJ_FROZEN(obj)) rb_error_frozen("DBM"); + } +} + static VALUE fdbm_delete(obj, keystr) VALUE obj, keystr; @@ -289,7 +299,7 @@ fdbm_delete(obj, keystr) DBM *dbm; VALUE valstr; - rb_secure(4); + fdbm_modify(obj); StringValue(keystr); key.dptr = RSTRING(keystr)->ptr; key.dsize = RSTRING(keystr)->len; @@ -325,7 +335,7 @@ fdbm_shift(obj) DBM *dbm; VALUE keystr, valstr; - rb_secure(4); + fdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; dbmp->di_size = -1; @@ -351,7 +361,7 @@ fdbm_delete_if(obj) VALUE ret, ary = rb_ary_new(); int i, status = 0, n; - rb_secure(4); + fdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; n = dbmp->di_size; @@ -388,7 +398,7 @@ fdbm_clear(obj) struct dbmdata *dbmp; DBM *dbm; - rb_secure(4); + fdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; dbmp->di_size = -1; @@ -471,7 +481,7 @@ fdbm_store(obj, keystr, valstr) struct dbmdata *dbmp; DBM *dbm; - rb_secure(4); + fdbm_modify(obj); keystr = rb_obj_as_string(keystr); key.dptr = RSTRING(keystr)->ptr; diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c index ee56fbf5d1..705cecfa97 100644 --- a/ext/gdbm/gdbm.c +++ b/ext/gdbm/gdbm.c @@ -387,6 +387,16 @@ fgdbm_values_at(argc, argv, obj) return new; } +static void +rb_gdbm_modify(obj) + VALUE obj; +{ + rb_secure(4); + if (OBJ_FROZEN_P(obj)) { + if (OBJ_FROZEN(obj)) rb_error_frozen("GDBM"); + } +} + static VALUE rb_gdbm_delete(obj, keystr) VALUE obj, keystr; @@ -395,7 +405,7 @@ rb_gdbm_delete(obj, keystr) struct dbmdata *dbmp; GDBM_FILE dbm; - rb_secure(4); + rb_gdbm_modify(obj); StringValue(keystr); key.dptr = RSTRING(keystr)->ptr; key.dsize = RSTRING(keystr)->len; @@ -436,7 +446,7 @@ fgdbm_shift(obj) GDBM_FILE dbm; VALUE keystr, valstr; - rb_secure(4); + rb_gdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; @@ -458,7 +468,7 @@ fgdbm_delete_if(obj) VALUE ret, ary = rb_ary_new(); int i, status = 0, n; - rb_secure(4); + rb_gdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; n = dbmp->di_size; @@ -489,7 +499,7 @@ fgdbm_clear(obj) struct dbmdata *dbmp; GDBM_FILE dbm; - rb_secure(4); + rb_gdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; dbmp->di_size = -1; @@ -588,7 +598,7 @@ fgdbm_store(obj, keystr, valstr) struct dbmdata *dbmp; GDBM_FILE dbm; - rb_secure(4); + rb_gdbm_modify(obj); StringValue(keystr); key.dptr = RSTRING(keystr)->ptr; key.dsize = RSTRING(keystr)->len; @@ -830,7 +840,7 @@ fgdbm_reorganize(obj) struct dbmdata *dbmp; GDBM_FILE dbm; - rb_secure(4); + rb_gdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; gdbm_reorganize(dbm); @@ -844,7 +854,7 @@ fgdbm_sync(obj) struct dbmdata *dbmp; GDBM_FILE dbm; - rb_secure(4); + rb_gdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; gdbm_sync(dbm); diff --git a/ext/iconv/charset_alias.rb b/ext/iconv/charset_alias.rb index 458dc89d4a..f1563b0dff 100644 --- a/ext/iconv/charset_alias.rb +++ b/ext/iconv/charset_alias.rb @@ -43,7 +43,7 @@ def charset_alias(config_charset, mapfile, target = OS) st = Hash.new(0) map = map.sort.collect do |can, *sys| if sys.grep(/^en_us(?=.|$)/i) {break true} == true - noen = %r"^(?!en_us)\w+_\w+#{Regexp.new($')}$"i + noen = %r"^(?!en_us)\w+_\w+#{Regexp.new($')}$"i #" sys.reject! {|s| noen =~ s} end sys = sys.first @@ -67,7 +67,7 @@ def charset_alias(config_charset, mapfile, target = OS) else sys = "'#{sys}'.freeze" end - f.puts(" charset_map['#{can}'.freeze] = #{sys}") + f.puts(" charset_map['#{can}'] = #{sys}") end f.puts("end") end diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c index 4352d21f9c..77b27afe5b 100644 --- a/ext/sdbm/init.c +++ b/ext/sdbm/init.c @@ -268,6 +268,16 @@ fsdbm_values_at(argc, argv, obj) return new; } +static void +fdbm_modify(obj) + VALUE obj; +{ + rb_secure(4); + if (OBJ_FROZEN_P(obj)) { + if (OBJ_FROZEN(obj)) rb_error_frozen("SDBM"); + } +} + static VALUE fsdbm_delete(obj, keystr) VALUE obj, keystr; @@ -277,7 +287,7 @@ fsdbm_delete(obj, keystr) DBM *dbm; VALUE valstr; - rb_secure(4); + fdbm_modify(obj); StringValue(keystr); key.dptr = RSTRING(keystr)->ptr; key.dsize = RSTRING(keystr)->len; @@ -314,7 +324,7 @@ fsdbm_shift(obj) DBM *dbm; VALUE keystr, valstr; - rb_secure(4); + fdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; @@ -342,7 +352,7 @@ fsdbm_delete_if(obj) VALUE ret, ary = rb_ary_new(); int i, status = 0, n; - rb_secure(4); + fdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; n = dbmp->di_size; @@ -378,7 +388,7 @@ fsdbm_clear(obj) struct dbmdata *dbmp; DBM *dbm; - rb_secure(4); + fdbm_modify(obj); GetDBM(obj, dbmp); dbm = dbmp->di_dbm; dbmp->di_size = -1; @@ -466,7 +476,7 @@ fsdbm_store(obj, keystr, valstr) return Qnil; } - rb_secure(4); + fdbm_modify(obj); keystr = rb_obj_as_string(keystr); key.dptr = RSTRING(keystr)->ptr; |