🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #87997

emacs-19.25 display table bug in command_loop_1()

#87997
From: Tim Shepard
Date: Sat, 13 Aug 1994 03:26
144 lines
5092 bytes
I am using emacs-19.25 on a mips-dec-ultrix4.2 machine.

In emacs-19.25/src/keyboard.c there is a bug in how display tables are
handled in the fast path code for self-insert-character in command_loop_1().

how to reproduce the bug
------------------------

$ font=-Adobe-Courier-Medium-R-Normal--18-180-75-75-M-110-ISO8859-1
$ emacs -q -fn $font

and now evaluate in the *scratch* buffer:

	(setq standard-display-table (make-display-table))
  
or

	(standard-display-8bit 161 255)

or anything else which sets standard-display-table non-nil, but
leaves the display table with many nil entries.

Now, type to insert characters at the end of the buffer (or at the
end of a line), and notice that the display is not properly updated.
The display can be correced with Control-L.

The bug also seems to be reproducable with most other fonts, but for
me is most dramatic with the font above.  Characters added at the end
of a line or at the end of the buffer are displayed as a block in the
color of my cursor.  Other fonts seem to behave differently, some
leaving blanks.

The problem
-----------

In this fragment of code (from emacs-19.25/src/keyboard.c):

		    {
		      struct Lisp_Vector *dp
			= window_display_table (XWINDOW (selected_window));
		      int lose = c;

		      if (dp)
			{
			  Lisp_Object obj;

			  obj = DISP_CHAR_VECTOR (dp, lose);
			  if (NILP (obj)
			      || (XTYPE (obj) == Lisp_Vector
				  && XVECTOR (obj)->size == 1
				  && (XTYPE (obj = XVECTOR (obj)->contents[0])
				      == Lisp_Int)
				  /* Insist face not specified in glyph.  */
				  && (XINT (obj) & ((-1) << 8)) == 0))
			    no_redisplay
			      = direct_output_for_insert (XINT (obj));
			}
		      else
			{
			  if (lose >= 0x20 && lose <= 0x7e)
			    no_redisplay = direct_output_for_insert (lose);
			}
		    }

Notice that if the display table exists, but has nil entry (so obj is
nil), then direct_output_for_insert() will be called with XINT() of nil.

A patch
-------

A patch is included at the end of this message.  I've made these
changes to command_loop_1(), compiled it, and it seems to work OK for
me.  I have not thoroughly tested this code, but I do not believe my
changes introduce any new bugs.  Much of the code in command_loop_1
could use a good cleanup, but I do not currently have the time to
volunteer.

I hope someone finds this bug report useful.

			-Tim

 - - - - cut here - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

*** /tmp/RCSAa27025	Fri Aug 12 17:12:30 1994
--- keyboard.c	Fri Aug 12 17:11:36 1994
***************
*** 1153,1181 ****
  		  if (!lose &&
  		      (PT == ZV || FETCH_CHAR (PT) == '\n'))
  		    {
  		      struct Lisp_Vector *dp
  			= window_display_table (XWINDOW (selected_window));
! 		      int lose = c;
  
! 		      if (dp)
  			{
! 			  Lisp_Object obj;
! 
! 			  obj = DISP_CHAR_VECTOR (dp, lose);
! 			  if (NILP (obj)
! 			      || (XTYPE (obj) == Lisp_Vector
! 				  && XVECTOR (obj)->size == 1
! 				  && (XTYPE (obj = XVECTOR (obj)->contents[0])
! 				      == Lisp_Int)
! 				  /* Insist face not specified in glyph.  */
! 				  && (XINT (obj) & ((-1) << 8)) == 0))
! 			    no_redisplay
! 			      = direct_output_for_insert (XINT (obj));
  			}
  		      else
  			{
! 			  if (lose >= 0x20 && lose <= 0x7e)
! 			    no_redisplay = direct_output_for_insert (lose);
  			}
  		    }
  		  goto directly_done;
--- 1153,1179 ----
  		  if (!lose &&
  		      (PT == ZV || FETCH_CHAR (PT) == '\n'))
  		    {
+ 		      Lisp_Object obj;
  		      struct Lisp_Vector *dp
  			= window_display_table (XWINDOW (selected_window));
! 		      int c_as_int = c;
  
! 		      if (dp
! 			  && !NILP(obj = DISP_CHAR_VECTOR (dp, c_as_int)))
  			{
! 			  if (XTYPE (obj) == Lisp_Vector
! 			      && XVECTOR (obj)->size == 1
! 			      && (XTYPE (obj = XVECTOR (obj)->contents[0])
! 				  == Lisp_Int)
! 			      /* Insist face not specified in glyph.  */
! 			      && (XINT (obj) & ((-1) << 8)) == 0)
! 			    no_redisplay =
! 			      direct_output_for_insert (XINT (obj));
  			}
  		      else
  			{
! 			  if (c_as_int >= 0x20 && c_as_int <= 0x7e)
! 			    no_redisplay = direct_output_for_insert (c_as_int);
  			}
  		    }
  		  goto directly_done;
Technical Details
Message-ID: <9408122146.AA11128@ginger.lcs.mit.edu>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!primenet!netnews.asu.edu !asuvax!cs.utexas.edu!swrinde!howland.reston.ans.net!math.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!lcs.mit.edu!shep

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,3d53bed6b6c8783d,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1994-08-13 06:23:17 PST
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!primenet!netnews.asu.edu      !asuvax!cs.utexas.edu!swrinde!howland.reston.ans.net!math.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!lcs.mit.edu!shep
From: shep@lcs.mit.edu (Tim Shepard)
Newsgroups: gnu.emacs.bug
Subject: emacs-19.25 display table bug in command_loop_1()
Date: 12 Aug 1994 23:26:23 -0400
Organization: GNUs Not Usenet
Lines: 146
Sender: daemon@cis.ohio-state.edu
Approved: bug-gnu-emacs@prep.ai.mit.edu
Distribution: gnu
Message-ID: <9408122146.AA11128@ginger.lcs.mit.edu>