From: gwk@crmunich0.cray.com (Georg-Wilhelm Koltermann)
Subject: make EMACS 8 bit clean
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 14 Apr 1992 23:13:28 GMT

The following patch makes EMACS recognize eight bit characters if you
set the (new) CHRMASK to 0377 in config.h.

Entering META sequences by marking the eightth bit with a suitable
terminal still works, if you set `meta-flag' non-nil. Of course, you
won't be able to enter any real eight bit characters as long as `meta-flag'
is t.

I am not using X11 on my machine, so I didn't check the x... files for
changes to be made. That remains to be done.

NOTE: This patch changes isearch.el. You will have to byte-compile that
      file before you dump the new EMACS in order to get the change
      incorporated. If you don't have EMACS up and running on your
      machine yet, you can first generate a version with the old
      isearch.elc, then enter EMACS, byte-compile-file lisp/isearch.el,
      and then make(1) the final dumped version.

*** lisp/OLDisearch.el	Wed Jan  9 23:01:00 1991
--- lisp/isearch.el	Sat Mar 14 14:01:50 1992
***************
*** 109,114 ****
--- 109,115 ----
  	   (setq quit-flag nil adjusted nil)
  	   ;; Meta character means exit search.
  	   (cond ((and (>= char 128)
+ 		       meta-flag
  		       search-exit-option)
  		  (setq unread-command-char char)
  		  (throw 'search-done t))
*** src/OLDxdisp.c	Tue Jan  8 19:21:59 1991
--- src/xdisp.c	Sat Mar 14 12:04:41 1992
***************
*** 1295,1301 ****
  	  p = &FETCH_CHAR (pos);
  	}
        c = *p++;
!       if (c >= 040 && c < 0177)
  	{
  	  if (p1 >= startp)
  	    *p1 = c;
--- 1295,1301 ----
  	  p = &FETCH_CHAR (pos);
  	}
        c = *p++;
!       if (c >= 040 && c <= CHRMASK)
  	{
  	  if (p1 >= startp)
  	    *p1 = c;
***************
*** 1927,1933 ****
      {
        c = *string++;
        if (!c) break;
!       if (c >= 040 && c < 0177)
  	{
  	  if (p1 >= start)
  	    *p1 = c;
--- 1927,1933 ----
      {
        c = *string++;
        if (!c) break;
!       if (c >= 040 && c <= CHRMASK)
  	{
  	  if (p1 >= start)
  	    *p1 = c;
*** src/OLDconfig.h	Sat Mar 14 00:14:46 1992
--- src/config.h	Sat Mar 14 00:36:32 1992
***************
*** 32,37 ****
--- 32,41 ----
     */
  #include "m-intel386.h"
  
+ /* Set your character size here, 0177 for 7 bit characters or
+    0377 for 8 bit characters. */
+ #define CHRMASK 0377
+ 
  /* Load in the conversion definitions if this system
     needs them and the source file being compiled has not
     said to inhibit this.  There should be no need for you
*** src/OLDkeyboard.c	Wed Jan  9 02:40:31 1991
--- src/keyboard.c	Sat Mar 14 01:15:23 1992
***************
*** 701,707 ****
  		{
  		  lose = FETCH_CHAR (point);
  		  SET_PT (point + 1);
! 		  if (lose >= ' ' && lose < 0177
  		      && (XFASTINT (XWINDOW (selected_window)->last_modified)
  			  >= MODIFF)
  		      && (XFASTINT (XWINDOW (selected_window)->last_point)
--- 701,707 ----
  		{
  		  lose = FETCH_CHAR (point);
  		  SET_PT (point + 1);
! 		  if (lose >= ' ' && lose < CHRMASK
  		      && (XFASTINT (XWINDOW (selected_window)->last_modified)
  			  >= MODIFF)
  		      && (XFASTINT (XWINDOW (selected_window)->last_point)
***************
*** 717,723 ****
  		{
  		  SET_PT (point - 1);
  		  lose = FETCH_CHAR (point);
! 		  if (lose >= ' ' && lose < 0177
  		      && (XFASTINT (XWINDOW (selected_window)->last_modified)
  			  >= MODIFF)
  		      && (XFASTINT (XWINDOW (selected_window)->last_point)
--- 717,723 ----
  		{
  		  SET_PT (point - 1);
  		  lose = FETCH_CHAR (point);
! 		  if (lose >= ' ' && lose < CHRMASK
  		      && (XFASTINT (XWINDOW (selected_window)->last_modified)
  			  >= MODIFF)
  		      && (XFASTINT (XWINDOW (selected_window)->last_point)
***************
*** 758,764 ****
  		  if (!lose
  		      && (point == ZV || FETCH_CHAR (point) == '\n')
  		      && last_command_char >= ' '
! 		      && last_command_char < 0177)
  		    no_redisplay
  		      = direct_output_for_insert (last_command_char);
  		  goto directly_done;
--- 758,764 ----
  		  if (!lose
  		      && (point == ZV || FETCH_CHAR (point) == '\n')
  		      && last_command_char >= ' '
! 		      && last_command_char < CHRMASK)
  		    no_redisplay
  		      = direct_output_for_insert (last_command_char);
  		  goto directly_done;
***************
*** 980,986 ****
  
    if (c < 0) return -1;
  
!   c &= meta_key ? 0377 : 0177;
  
    if (XTYPE (Vkeyboard_translate_table) == Lisp_String
        && XSTRING (Vkeyboard_translate_table)->size > c)
--- 980,986 ----
  
    if (c < 0) return -1;
  
!   c &= meta_key ? 0377 : CHRMASK;
  
    if (XTYPE (Vkeyboard_translate_table) == Lisp_String
        && XSTRING (Vkeyboard_translate_table)->size > c)
***************
*** 1152,1158 ****
    input_pending = --kbd_count > 0;
    c = *kbd_ptr;			/* *kbd_ptr++ would have a timing error. */
    kbd_ptr++;			/* See kbd_buffer_store_char. */
!   return (c & (meta_key ? 0377 : 0177)); /* Clean up if sign was extended. */
  }
  
  /* Force an attempt to read input regardless of what FIONREAD says.  */
--- 1152,1158 ----
    input_pending = --kbd_count > 0;
    c = *kbd_ptr;			/* *kbd_ptr++ would have a timing error. */
    kbd_ptr++;			/* See kbd_buffer_store_char. */
!   return (c & (meta_key ? 0377 : CHRMASK)); /* Clean up if sign was extended. */
  }
  
  /* Force an attempt to read input regardless of what FIONREAD says.  */
***************
*** 1421,1427 ****
  
    unread_command_char = c;
  
!   if (c < 0 || c >= 0200)
      return 0;
  
    map = current_buffer->keymap;
--- 1421,1427 ----
  
    unread_command_char = c;
  
!   if (c < 0 || c > CHRMASK)
      return 0;
  
    map = current_buffer->keymap;
***************
*** 1507,1515 ****
  
        if (c < 0)
  	return 0;
!       if (c >= 0200)
  	{
! 	  nextc = c & 0177;
  	  c = meta_prefix_char;
  	}
  
--- 1507,1515 ----
  
        if (c < 0)
  	return 0;
!       if (c >= 0200 && meta_key)
  	{
! 	  nextc = c & CHRMASK;
  	  c = meta_prefix_char;
  	}
  
***************
*** 2074,2080 ****
        CHECK_NUMBER (quit, 2);
        quit_char = XINT (quit);
        /* Don't let this value be out of range.  */
!       quit_char &= (meta_key ? 0377 : 0177);
      }
    init_sys_modes ();
    return Qnil;
--- 2074,2080 ----
        CHECK_NUMBER (quit, 2);
        quit_char = XINT (quit);
        /* Don't let this value be out of range.  */
!       quit_char &= (meta_key ? 0377 : CHRMASK);
      }
    init_sys_modes ();
    return Qnil;
*** src/OLDkeymap.c	Tue Jan  8 18:37:17 1991
--- src/keymap.c	Sat Mar 14 01:35:51 1992
***************
*** 59,72 ****
     is equivalent to prefixing with this character.  */
  
  extern int meta_prefix_char;
  
  DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 0, 0,
!   "Construct and return a new keymap, a vector of length 128.\n\
  All entries in it are nil, meaning \"command undefined\".")
    ()
  {
    register Lisp_Object val;
!   XFASTINT (val) = 0200;
    return Fmake_vector (val, Qnil);
  }
  
--- 59,76 ----
     is equivalent to prefixing with this character.  */
  
  extern int meta_prefix_char;
+ 
+ /* Nonzero if should obey 0200 bit in input chars as "Meta" */
+ int meta_key;
+ 
  
  DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 0, 0,
!   "Construct and return a new keymap, a vector of length CHRMASK+1.\n\
  All entries in it are nil, meaning \"command undefined\".")
    ()
  {
    register Lisp_Object val;
!   XFASTINT (val) = CHRMASK+1;
    return Fmake_vector (val, Qnil);
  }
  
***************
*** 110,116 ****
  
  DEFUN ("keymapp", Fkeymapp, Skeymapp, 1, 1, 0,
    "Return t if ARG is a keymap.\n\
! A keymap is a vector of length 128, or a list (keymap . ALIST),\n\
  where alist elements look like (CHAR . DEFN).")
    (object)
       Lisp_Object object;
--- 114,120 ----
  
  DEFUN ("keymapp", Fkeymapp, Skeymapp, 1, 1, 0,
    "Return t if ARG is a keymap.\n\
! A keymap is a vector of length CHRMASK+1, or a list (keymap . ALIST),\n\
  where alist elements look like (CHAR . DEFN).")
    (object)
       Lisp_Object object;
***************
*** 125,131 ****
        QUIT;
      }
  
!   if ((XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == 0200)
        || (CONSP (tem) && EQ (XCONS (tem)->car, Qkeymap)))
      return Qt;
    return Qnil;
--- 129,135 ----
        QUIT;
      }
  
!   if ((XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == CHRMASK+1)
        || (CONSP (tem) && EQ (XCONS (tem)->car, Qkeymap)))
      return Qt;
    return Qnil;
***************
*** 146,152 ****
  	  tem = XSYMBOL (tem)->function;
  	  QUIT;
  	}
!       if ((XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == 0200)
  	  || (CONSP (tem) && EQ (XCONS (tem)->car, Qkeymap)))
  	return tem;
        if (error)
--- 150,156 ----
  	  tem = XSYMBOL (tem)->function;
  	  QUIT;
  	}
!       if ((XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == CHRMASK+1)
  	  || (CONSP (tem) && EQ (XCONS (tem)->car, Qkeymap)))
  	return tem;
        if (error)
***************
*** 188,195 ****
       register int idx;
  {
    register Lisp_Object val;
!   if (idx < 0 || idx >= 0200)
!     error ("Command key out of range 0-127");
  
    /* Get definition for character `idx' proper.  */
    if (CONSP (map))
--- 192,199 ----
       register int idx;
  {
    register Lisp_Object val;
!   if (idx < 0 || idx > CHRMASK)
!     error ("Command key out of range 0-CHRMASK");
  
    /* Get definition for character `idx' proper.  */
    if (CONSP (map))
***************
*** 208,215 ****
  {
    register Lisp_Object tem;
  
!   if (idx < 0 || idx >= 0200)
!     error ("Command key out of range 0-127");
  
    if (CONSP (keymap))
      {
--- 212,219 ----
  {
    register Lisp_Object tem;
  
!   if (idx < 0 || idx > CHRMASK)
!     error ("Command key out of range 0-CHRMASK");
  
    if (CONSP (keymap))
      {
***************
*** 292,298 ****
    while (1)
      {
        c = XSTRING (key)->data[idx];
!       if (c >= 0200 && !metized)
  	{
  	  c = meta_prefix_char;
  	  metized = 1;
--- 296,302 ----
    while (1)
      {
        c = XSTRING (key)->data[idx];
!       if (c >= 0200 && meta_key && !metized)
  	{
  	  c = meta_prefix_char;
  	  metized = 1;
***************
*** 299,305 ****
  	}
        else
  	{
! 	  c &= 0177;
  	  metized = 0;
  	  idx++;
  	}
--- 303,309 ----
  	}
        else
  	{
! 	  c &= CHRMASK;
  	  metized = 0;
  	  idx++;
  	}
***************
*** 352,358 ****
    while (1)
      {
        c = XSTRING (key)->data[idx];
!       if (c >= 0200 && !metized)
  	{
  	  c = meta_prefix_char;
  	  metized = 1;
--- 356,362 ----
    while (1)
      {
        c = XSTRING (key)->data[idx];
!       if (c >= 0200 && meta_key && !metized)
  	{
  	  c = meta_prefix_char;
  	  metized = 1;
***************
*** 359,365 ****
  	}
        else
  	{
! 	  c &= 0177;
  	  metized = 0;
  	  idx++;
  	}
--- 363,369 ----
  	}
        else
  	{
! 	  c &= CHRMASK;
  	  metized = 0;
  	  idx++;
  	}
***************
*** 568,574 ****
      {
        thisseq = Fcar (Fcar (tail));
        thismap = Fcdr (Fcar (tail));
!       for (i = 0; i < 0200; i++)
  	{
  	  cmd = get_keyelt (access_keymap (thismap, i));
  	  if (NULL (cmd)) continue;
--- 572,578 ----
      {
        thisseq = Fcar (Fcar (tail));
        thismap = Fcdr (Fcar (tail));
!       for (i = 0; i <= CHRMASK; i++)
  	{
  	  cmd = get_keyelt (access_keymap (thismap, i));
  	  if (NULL (cmd)) continue;
***************
*** 608,614 ****
       register unsigned int c;
       register char *p;
  {
!   if (c >= 0200)
      {
        *p++ = 'M';
        *p++ = '-';
--- 612,618 ----
       register unsigned int c;
       register char *p;
  {
!   if (c >= 0200 && meta_key)
      {
        *p++ = 'M';
        *p++ = '-';
***************
*** 689,695 ****
       register unsigned int c;
       register char *p;
  {
!   if (c >= 0200)
      {
        *p++ = 'M';
        *p++ = '-';
--- 693,699 ----
       register unsigned int c;
       register char *p;
  {
!   if (c >= 0200 && meta_key)
      {
        *p++ = 'M';
        *p++ = '-';
***************
*** 758,767 ****
        if (CONSP (map))
  	map = Fcdr (map);
  
!       /* If the MAP is a vector, I increments and eventually reaches 0200.
  	 Otherwise I remains 0; MAP is cdr'd and eventually becomes nil.  */
  
!       while (!NULL (map) && i < 0200)
  	{
  	  register Lisp_Object elt, dummy;
  
--- 762,771 ----
        if (CONSP (map))
  	map = Fcdr (map);
  
!       /* If the MAP is a vector, I increments and eventually reaches CHRMASK.
  	 Otherwise I remains 0; MAP is cdr'd and eventually becomes nil.  */
  
!       while (!NULL (map) && i <= CHRMASK)
  	{
  	  register Lisp_Object elt, dummy;
  
*** src/OLDcmds.c	Sat Jan  5 01:15:03 1991
--- src/cmds.c	Sat Mar 14 11:42:39 1992
***************
*** 333,339 ****
  
    ndefkey (Vglobal_map, Ctl('M'), "newline");
    ndefkey (Vglobal_map, Ctl('I'), "self-insert-command");
!   for (n = 040; n < 0177; n++)
      ndefkey (Vglobal_map, n, "self-insert-command");
  
    ndefkey (Vglobal_map, Ctl ('A'), "beginning-of-line");
--- 333,339 ----
  
    ndefkey (Vglobal_map, Ctl('M'), "newline");
    ndefkey (Vglobal_map, Ctl('I'), "self-insert-command");
!   for (n = 040; n <= CHRMASK; n++)
      ndefkey (Vglobal_map, n, "self-insert-command");
  
    ndefkey (Vglobal_map, Ctl ('A'), "beginning-of-line");
*** src/OLDindent.c	Tue Jan  8 18:35:21 1991
--- src/indent.c	Sat Mar 14 14:35:09 1992
***************
*** 108,114 ****
  	}
  
        c = *--ptr;
!       if (c >= 040 && c < 0177)
  	{
  	  col++;
  	}
--- 108,114 ----
  	}
  
        c = *--ptr;
!       if (c >= 040 && c <= CHRMASK)
  	{
  	  col++;
  	}
***************
*** 319,325 ****
  	}
        else if (ctl_arrow && (c < 040 || c == 0177))
          col++;
!       else if (c < 040 || c >= 0177)
          col += 3;
      }
  
--- 319,325 ----
  	}
        else if (ctl_arrow && (c < 040 || c == 0177))
          col++;
!       else if (c < 040 || c > CHRMASK)
          col += 3;
      }
  
***************
*** 377,383 ****
      {
        prevpos = cpos;
        c = FETCH_CHAR (pos);
!       if (c >= 040 && c < 0177)
  	cpos++;
        else if (c == '\t')
  	{
--- 377,383 ----
      {
        prevpos = cpos;
        c = FETCH_CHAR (pos);
!       if (c >= 040 && c <= CHRMASK)
  	cpos++;
        else if (c == '\t')
  	{

Newsgroups: gnu.emacs.bug