summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-24 08:06:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-24 08:06:16 +0000
commitefed292c4311c8c182a32ac2afe70c6969815b2d (patch)
treecd4a9818f14ddd88f1995a8a0e5761d9d3dd34bc /st.c
parent68a66351a73b8801968262bdfa96a447ee4d1503 (diff)
* load.c (rb_feature_p): returns loading path name too.
* load.c (search_required): returns path too if feature is being loaded. [ruby-dev:32048] [TODO: refactoring] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r--st.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/st.c b/st.c
index 4d21016..a0e6692 100644
--- a/st.c
+++ b/st.c
@@ -302,6 +302,35 @@ st_lookup(st_table *table, register st_data_t key, st_data_t *value)
}
}
+int
+st_get_key(st_table *table, register st_data_t key, st_data_t *result)
+{
+ unsigned int hash_val, bin_pos;
+ register st_table_entry *ptr;
+
+ if (table->entries_packed) {
+ int i;
+ for (i = 0; i < table->num_entries; i++) {
+ if ((st_data_t)table->bins[i*2] == key) {
+ if (result !=0) *result = (st_data_t)table->bins[i*2];
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+ hash_val = do_hash(key, table);
+ FIND_ENTRY(table, ptr, hash_val, bin_pos);
+
+ if (ptr == 0) {
+ return 0;
+ }
+ else {
+ if (result != 0) *result = ptr->key;
+ return 1;
+ }
+}
+
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
do {\
st_table_entry *entry, *head;\