Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit fb3a112122b6406e88adbff2299aacc5230cc8ec 1 parent bbd1281
Mark H Weaver authored

Showing 1 changed file with 50 additions and 38 deletions. Show diff stats Hide diff stats

  1. +50 38 libguile/srcprop.c
88 libguile/srcprop.c
... ... @@ -1,4 +1,5 @@
1   -/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002, 2006, 2008, 2009, 2010, 2011 Free Software Foundation
  1 +/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2006,
  2 + * 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
2 3 *
3 4 * This library is free software; you can redistribute it and/or
4 5 * modify it under the terms of the GNU Lesser General Public License
@@ -164,18 +165,22 @@ SCM_DEFINE (scm_source_properties, "source-properties", 1, 0, 0,
164 165 "Return the source property association list of @var{obj}.")
165 166 #define FUNC_NAME s_scm_source_properties
166 167 {
167   - SCM p;
168   - SCM_VALIDATE_NIM (1, obj);
  168 + if (SCM_IMP (obj))
  169 + return SCM_EOL;
  170 + else
  171 + {
  172 + SCM p;
169 173
170   - scm_i_pthread_mutex_lock (&source_lock);
171   - p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
172   - scm_i_pthread_mutex_unlock (&source_lock);
  174 + scm_i_pthread_mutex_lock (&source_lock);
  175 + p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
  176 + scm_i_pthread_mutex_unlock (&source_lock);
173 177
174   - if (SRCPROPSP (p))
175   - return scm_srcprops_to_alist (p);
176   - else
177   - /* list from set-source-properties!, or SCM_EOL for not found */
178   - return p;
  178 + if (SRCPROPSP (p))
  179 + return scm_srcprops_to_alist (p);
  180 + else
  181 + /* list from set-source-properties!, or SCM_EOL for not found */
  182 + return p;
  183 + }
179 184 }
180 185 #undef FUNC_NAME
181 186
@@ -201,15 +206,18 @@ int
201 206 scm_i_has_source_properties (SCM obj)
202 207 #define FUNC_NAME "%set-source-properties"
203 208 {
204   - int ret;
205   -
206   - SCM_VALIDATE_NIM (1, obj);
  209 + if (SCM_IMP (obj))
  210 + return 0;
  211 + else
  212 + {
  213 + int ret;
207 214
208   - scm_i_pthread_mutex_lock (&source_lock);
209   - ret = scm_is_true (scm_hashq_ref (scm_source_whash, obj, SCM_BOOL_F));
210   - scm_i_pthread_mutex_unlock (&source_lock);
  215 + scm_i_pthread_mutex_lock (&source_lock);
  216 + ret = scm_is_true (scm_hashq_ref (scm_source_whash, obj, SCM_BOOL_F));
  217 + scm_i_pthread_mutex_unlock (&source_lock);
211 218
212   - return ret;
  219 + return ret;
  220 + }
213 221 }
214 222 #undef FUNC_NAME
215 223
@@ -237,29 +245,33 @@ SCM_DEFINE (scm_source_property, "source-property", 2, 0, 0,
237 245 "@var{obj}'s source property list.")
238 246 #define FUNC_NAME s_scm_source_property
239 247 {
240   - SCM p;
241   - SCM_VALIDATE_NIM (1, obj);
242   -
243   - scm_i_pthread_mutex_lock (&source_lock);
244   - p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
245   - scm_i_pthread_mutex_unlock (&source_lock);
246   -
247   - if (!SRCPROPSP (p))
248   - goto alist;
249   - if (scm_is_eq (scm_sym_line, key))
250   - p = scm_from_int (SRCPROPLINE (p));
251   - else if (scm_is_eq (scm_sym_column, key))
252   - p = scm_from_int (SRCPROPCOL (p));
253   - else if (scm_is_eq (scm_sym_copy, key))
254   - p = SRCPROPCOPY (p);
  248 + if (SCM_IMP (obj))
  249 + return SCM_BOOL_F;
255 250 else
256 251 {
257   - p = SRCPROPALIST (p);
258   - alist:
259   - p = scm_assoc (key, p);
260   - return (SCM_NIMP (p) ? SCM_CDR (p) : SCM_BOOL_F);
  252 + SCM p;
  253 +
  254 + scm_i_pthread_mutex_lock (&source_lock);
  255 + p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
  256 + scm_i_pthread_mutex_unlock (&source_lock);
  257 +
  258 + if (!SRCPROPSP (p))
  259 + goto alist;
  260 + if (scm_is_eq (scm_sym_line, key))
  261 + p = scm_from_int (SRCPROPLINE (p));
  262 + else if (scm_is_eq (scm_sym_column, key))
  263 + p = scm_from_int (SRCPROPCOL (p));
  264 + else if (scm_is_eq (scm_sym_copy, key))
  265 + p = SRCPROPCOPY (p);
  266 + else
  267 + {
  268 + p = SRCPROPALIST (p);
  269 + alist:
  270 + p = scm_assoc (key, p);
  271 + return (SCM_NIMP (p) ? SCM_CDR (p) : SCM_BOOL_F);
  272 + }
  273 + return SCM_UNBNDP (p) ? SCM_BOOL_F : p;
261 274 }
262   - return SCM_UNBNDP (p) ? SCM_BOOL_F : p;
263 275 }
264 276 #undef FUNC_NAME
265 277

0 comments on commit fb3a112

Please sign in to comment.
Something went wrong with that request. Please try again.