comparison src/buffer.c @ 104280:52ff955e0cc5

* buffer.c (set_buffer_internal_1) (swap_out_buffer_local_variables): Check for unbound local variables (Bug#4138).
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 15 Aug 2009 14:06:02 +0000
parents aa5e8ff5a9c4
children e5f506a6a59d
comparison
equal deleted inserted replaced
104279:de38a863010a 104280:52ff955e0cc5
1919 /* Look down buffer's list of local Lisp variables 1919 /* Look down buffer's list of local Lisp variables
1920 to find and update any that forward into C variables. */ 1920 to find and update any that forward into C variables. */
1921 1921
1922 for (tail = b->local_var_alist; CONSP (tail); tail = XCDR (tail)) 1922 for (tail = b->local_var_alist; CONSP (tail); tail = XCDR (tail))
1923 { 1923 {
1924 valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))); 1924 if (CONSP (XCAR (tail))
1925 if ((BUFFER_LOCAL_VALUEP (valcontents)) 1925 && SYMBOLP (XCAR (XCAR (tail)))
1926 && (valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))),
1927 (BUFFER_LOCAL_VALUEP (valcontents)))
1926 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue, 1928 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
1927 (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem)))) 1929 (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem))))
1928 /* Just reference the variable 1930 /* Just reference the variable to cause it to become set for
1929 to cause it to become set for this buffer. */ 1931 this buffer. */
1930 Fsymbol_value (XCAR (XCAR (tail))); 1932 Fsymbol_value (XCAR (XCAR (tail)));
1931 } 1933 }
1932 1934
1933 /* Do the same with any others that were local to the previous buffer */ 1935 /* Do the same with any others that were local to the previous buffer */
1934 1936
1935 if (old_buf) 1937 if (old_buf)
1936 for (tail = old_buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) 1938 for (tail = old_buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
1937 { 1939 {
1938 valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))); 1940 if (CONSP (tail)
1939 if ((BUFFER_LOCAL_VALUEP (valcontents)) 1941 && SYMBOLP (XCAR (XCAR (tail)))
1942 && (valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))),
1943 (BUFFER_LOCAL_VALUEP (valcontents)))
1940 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue, 1944 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
1941 (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem)))) 1945 (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem))))
1942 /* Just reference the variable 1946 /* Just reference the variable to cause it to become set for
1943 to cause it to become set for this buffer. */ 1947 this buffer. */
1944 Fsymbol_value (XCAR (XCAR (tail))); 1948 Fsymbol_value (XCAR (XCAR (tail)));
1945 } 1949 }
1946 } 1950 }
1947 1951
1948 /* Switch to buffer B temporarily for redisplay purposes. 1952 /* Switch to buffer B temporarily for redisplay purposes.
2651 2655
2652 static void 2656 static void
2653 swap_out_buffer_local_variables (b) 2657 swap_out_buffer_local_variables (b)
2654 struct buffer *b; 2658 struct buffer *b;
2655 { 2659 {
2656 Lisp_Object oalist, alist, sym, tem, buffer; 2660 Lisp_Object oalist, alist, sym, buffer;
2657 2661
2658 XSETBUFFER (buffer, b); 2662 XSETBUFFER (buffer, b);
2659 oalist = b->local_var_alist; 2663 oalist = b->local_var_alist;
2660 2664
2661 for (alist = oalist; CONSP (alist); alist = XCDR (alist)) 2665 for (alist = oalist; CONSP (alist); alist = XCDR (alist))
2662 { 2666 {
2663 sym = XCAR (XCAR (alist)); 2667 if (CONSP (XCAR (alist))
2664 2668 && (sym = XCAR (XCAR (alist)), SYMBOLP (sym))
2665 /* Need not do anything if some other buffer's binding is now encached. */ 2669 /* Need not do anything if some other buffer's binding is
2666 tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer; 2670 now encached. */
2667 if (EQ (tem, buffer)) 2671 && EQ (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer,
2672 buffer))
2668 { 2673 {
2669 /* Symbol is set up for this buffer's old local value: 2674 /* Symbol is set up for this buffer's old local value:
2670 swap it out! */ 2675 swap it out! */
2671 swap_in_global_binding (sym); 2676 swap_in_global_binding (sym);
2672 } 2677 }