diff options
author | Ludovic Courtès <ludo@gnu.org> | 2010-04-08 19:17:25 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2010-04-09 00:32:14 +0200 |
commit | 1606312f9a1200950336d485bd29866c0f8e3942 (patch) | |
tree | 7f4d60ef88ca1059c5c5b24f5418fcb7521ae2a4 /libguile/modules.c | |
parent | 6c76da4c32dd8a2c1f38d51df6e58dcc0b7cee11 (diff) | |
download | guile-1606312f9a1200950336d485bd29866c0f8e3942.tar.gz |
Fix `module-reverse-lookup'.
* libguile/modules.c (scm_module_reverse_lookup): Type-check VARIABLE.
Don't traverse the `uses' list when MODULE is #f.
* test-suite/tests/modules.test ("foundations")["module-reverse-lookup
[pre-module-obarray]", "module-reverse-lookup [wrong-type-arg]"]: New
tests.
Diffstat (limited to 'libguile/modules.c')
-rw-r--r-- | libguile/modules.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/libguile/modules.c b/libguile/modules.c index 545281a18..fc6ff3b47 100644 --- a/libguile/modules.c +++ b/libguile/modules.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998,2000,2001,2002,2003,2004,2006,2007,2008,2009 Free Software Foundation, Inc. +/* Copyright (C) 1998,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -801,6 +801,8 @@ SCM_DEFINE (scm_module_reverse_lookup, "module-reverse-lookup", 2, 0, 0, obarray = SCM_MODULE_OBARRAY (module); } + SCM_VALIDATE_VARIABLE (SCM_ARG2, variable); + if (!SCM_HASHTABLE_P (obarray)) return SCM_BOOL_F; @@ -830,17 +832,18 @@ SCM_DEFINE (scm_module_reverse_lookup, "module-reverse-lookup", 2, 0, 0, } } - /* Try the `uses' list. */ - { - SCM uses = SCM_MODULE_USES (module); - while (scm_is_pair (uses)) - { - SCM sym = scm_module_reverse_lookup (SCM_CAR (uses), variable); - if (scm_is_true (sym)) - return sym; - uses = SCM_CDR (uses); - } - } + if (!scm_is_false (module)) + { + /* Try the `uses' list. */ + SCM uses = SCM_MODULE_USES (module); + while (scm_is_pair (uses)) + { + SCM sym = scm_module_reverse_lookup (SCM_CAR (uses), variable); + if (scm_is_true (sym)) + return sym; + uses = SCM_CDR (uses); + } + } return SCM_BOOL_F; } |