aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorJim Blandy1992-01-28 01:53:11 +0000
committerJim Blandy1992-01-28 01:53:11 +0000
commit14e76af946582f7151f53da1579386891c9445d8 (patch)
tree3c7fe71ed160198d8ae522f1b7fbb30ab70d3344 /src/data.c
parentc637ae6fc1d1c116567393a8493661bc9ba01de3 (diff)
downloademacs-14e76af946582f7151f53da1579386891c9445d8.tar.gz
emacs-14e76af946582f7151f53da1579386891c9445d8.zip
*** empty log message ***
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/data.c b/src/data.c
index 184cfba3a32..8906d68cabe 100644
--- a/src/data.c
+++ b/src/data.c
@@ -649,12 +649,14 @@ swap_in_symval_forwarding (sym, valcontents)
649 return XCONS (valcontents)->car; 649 return XCONS (valcontents)->car;
650} 650}
651 651
652/* Note that it must not be possible to quit within this function. 652/* Find the value of a symbol, returning Qunbound if it's not bound.
653 Great care is required for this. */ 653 This is helpful for code which just wants to get a variable's value
654 if it has one, without signalling an error.
655 Note that it must not be possible to quit
656 within this function. Great care is required for this. */
654 657
655DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, 658Lisp_Object
656 "Return SYMBOL's value. Error if that is void.") 659find_symbol_value (sym)
657 (sym)
658 Lisp_Object sym; 660 Lisp_Object sym;
659{ 661{
660 register Lisp_Object valcontents, tem1; 662 register Lisp_Object valcontents, tem1;
@@ -689,18 +691,26 @@ DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0,
689 case Lisp_Buffer_Objfwd: 691 case Lisp_Buffer_Objfwd:
690 return *(Lisp_Object *)(XUINT (valcontents) + (char *)current_buffer); 692 return *(Lisp_Object *)(XUINT (valcontents) + (char *)current_buffer);
691 693
692 case Lisp_Symbol:
693 /* For a symbol, check whether it is 'unbound. */
694 if (!EQ (valcontents, Qunbound))
695 break;
696 /* drops through! */
697 case Lisp_Void: 694 case Lisp_Void:
698 return Fsignal (Qvoid_variable, Fcons (sym, Qnil)); 695 return Qunbound;
699 } 696 }
700 697
701 return valcontents; 698 return valcontents;
702} 699}
703 700
701DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0,
702 "Return SYMBOL's value. Error if that is void.")
703 (sym)
704 Lisp_Object sym;
705{
706 Lisp_Object val = find_symbol_value (sym);
707
708 if (EQ (val, Qunbound))
709 return Fsignal (Qvoid_variable, Fcons (sym, Qnil));
710 else
711 return val;
712}
713
704DEFUN ("set", Fset, Sset, 2, 2, 0, 714DEFUN ("set", Fset, Sset, 2, 2, 0,
705 "Set SYMBOL's value to NEWVAL, and return NEWVAL.") 715 "Set SYMBOL's value to NEWVAL, and return NEWVAL.")
706 (sym, newval) 716 (sym, newval)