1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-16 08:40:19 +02:00

Relax validation of source property accessors

* libguile/srcprop.c (scm_source_properties, scm_source_property,
  scm_i_has_source_properties): Relax validation to allow _any_ object
  to be queried for source properties.
This commit is contained in:
Mark H Weaver 2012-02-14 01:54:15 -05:00
parent bbd1281ae5
commit fb3a112122

View file

@ -1,4 +1,5 @@
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002, 2006, 2008, 2009, 2010, 2011 Free Software Foundation /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2006,
* 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -164,8 +165,11 @@ SCM_DEFINE (scm_source_properties, "source-properties", 1, 0, 0,
"Return the source property association list of @var{obj}.") "Return the source property association list of @var{obj}.")
#define FUNC_NAME s_scm_source_properties #define FUNC_NAME s_scm_source_properties
{ {
if (SCM_IMP (obj))
return SCM_EOL;
else
{
SCM p; SCM p;
SCM_VALIDATE_NIM (1, obj);
scm_i_pthread_mutex_lock (&source_lock); scm_i_pthread_mutex_lock (&source_lock);
p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL); p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
@ -176,6 +180,7 @@ SCM_DEFINE (scm_source_properties, "source-properties", 1, 0, 0,
else else
/* list from set-source-properties!, or SCM_EOL for not found */ /* list from set-source-properties!, or SCM_EOL for not found */
return p; return p;
}
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -201,15 +206,18 @@ int
scm_i_has_source_properties (SCM obj) scm_i_has_source_properties (SCM obj)
#define FUNC_NAME "%set-source-properties" #define FUNC_NAME "%set-source-properties"
{ {
if (SCM_IMP (obj))
return 0;
else
{
int ret; int ret;
SCM_VALIDATE_NIM (1, obj);
scm_i_pthread_mutex_lock (&source_lock); scm_i_pthread_mutex_lock (&source_lock);
ret = scm_is_true (scm_hashq_ref (scm_source_whash, obj, SCM_BOOL_F)); ret = scm_is_true (scm_hashq_ref (scm_source_whash, obj, SCM_BOOL_F));
scm_i_pthread_mutex_unlock (&source_lock); scm_i_pthread_mutex_unlock (&source_lock);
return ret; return ret;
}
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -237,8 +245,11 @@ SCM_DEFINE (scm_source_property, "source-property", 2, 0, 0,
"@var{obj}'s source property list.") "@var{obj}'s source property list.")
#define FUNC_NAME s_scm_source_property #define FUNC_NAME s_scm_source_property
{ {
if (SCM_IMP (obj))
return SCM_BOOL_F;
else
{
SCM p; SCM p;
SCM_VALIDATE_NIM (1, obj);
scm_i_pthread_mutex_lock (&source_lock); scm_i_pthread_mutex_lock (&source_lock);
p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL); p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
@ -260,6 +271,7 @@ SCM_DEFINE (scm_source_property, "source-property", 2, 0, 0,
return (SCM_NIMP (p) ? SCM_CDR (p) : SCM_BOOL_F); return (SCM_NIMP (p) ? SCM_CDR (p) : SCM_BOOL_F);
} }
return SCM_UNBNDP (p) ? SCM_BOOL_F : p; return SCM_UNBNDP (p) ? SCM_BOOL_F : p;
}
} }
#undef FUNC_NAME #undef FUNC_NAME