Mercurial > emacs
diff src/data.c @ 514:626908d37dea
*** empty log message ***
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Tue, 28 Jan 1992 01:53:11 +0000 |
| parents | a54a07015253 |
| children | 7013d0e0e476 |
line wrap: on
line diff
--- a/src/data.c Mon Jan 27 22:52:05 1992 +0000 +++ b/src/data.c Tue Jan 28 01:53:11 1992 +0000 @@ -649,12 +649,14 @@ return XCONS (valcontents)->car; } -/* Note that it must not be possible to quit within this function. - Great care is required for this. */ +/* Find the value of a symbol, returning Qunbound if it's not bound. + This is helpful for code which just wants to get a variable's value + if it has one, without signalling an error. + Note that it must not be possible to quit + within this function. Great care is required for this. */ -DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, - "Return SYMBOL's value. Error if that is void.") - (sym) +Lisp_Object +find_symbol_value (sym) Lisp_Object sym; { register Lisp_Object valcontents, tem1; @@ -689,18 +691,26 @@ case Lisp_Buffer_Objfwd: return *(Lisp_Object *)(XUINT (valcontents) + (char *)current_buffer); - case Lisp_Symbol: - /* For a symbol, check whether it is 'unbound. */ - if (!EQ (valcontents, Qunbound)) - break; - /* drops through! */ case Lisp_Void: - return Fsignal (Qvoid_variable, Fcons (sym, Qnil)); + return Qunbound; } return valcontents; } +DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, + "Return SYMBOL's value. Error if that is void.") + (sym) + Lisp_Object sym; +{ + Lisp_Object val = find_symbol_value (sym); + + if (EQ (val, Qunbound)) + return Fsignal (Qvoid_variable, Fcons (sym, Qnil)); + else + return val; +} + DEFUN ("set", Fset, Sset, 2, 2, 0, "Set SYMBOL's value to NEWVAL, and return NEWVAL.") (sym, newval)
