diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2021-04-04 22:48:27 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2021-04-04 22:48:27 +0000 |
commit | fe85a3d5271c4e3aeda42ec32e9c3f9ee02b6897 (patch) | |
tree | 1af9fe86f23c7a58b696821abad97275351968dd /hash.c | |
parent | b98aa3aaaee29f86518cf3b70f3611bdc346ea17 (diff) |
merge revision(s) 08529a61153e5c40f57a65272211357511d6e6db: [Backport #16798]
Compare environment variable names in those manor [Bug #16798]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -5652,13 +5652,29 @@ env_invert(void) return rb_hash_invert(env_to_hash()); } +static void +keylist_delete(VALUE keys, VALUE key) +{ + long keylen, elen; + const char *keyptr, *eptr; + RSTRING_GETMEM(key, keyptr, keylen); + for (long i=0; i<RARRAY_LEN(keys); i++) { + VALUE e = RARRAY_AREF(keys, i); + RSTRING_GETMEM(e, eptr, elen); + if (elen != keylen) continue; + if (!ENVNMATCH(keyptr, eptr, elen)) continue; + rb_ary_delete_at(keys, i); + return; + } +} + static int env_replace_i(VALUE key, VALUE val, VALUE keys) { + env_name(key); env_aset(Qnil, key, val); - if (rb_ary_includes(keys, key)) { - rb_ary_delete(keys, key); - } + + keylist_delete(keys, key); return ST_CONTINUE; } |