29-Feb-88 00:26:37-PST,16879;000000000001
Return-Path: <mark@comp.vuw.ac.nz>
Received: from uunet.UU.NET by SCORE.STANFORD.EDU with TCP; Mon 29 Feb 88 00:26:17-PST
Received: from comp.vuw.ac.nz by uunet.UU.NET (5.54/1.14) with UUCP 
	id AA26902; Mon, 29 Feb 88 03:30:11 EST
Received: by comp.vuw.ac.nz; Sun, 28 Feb 88 11:58:16 +1300
Date: Sun, 28 Feb 88 11:58:16 +1300
From: Mark Davies <mark@comp.vuw.ac.nz>
Message-Id: <8802272258.AA00241@comp.vuw.ac.nz>
To: TeXhax@score.stanford.edu
Subject: Rest of Common TeX patches

Here is the remainder of my Common TeX patches that apparently got
truncated in the mail system somewhere.

mark

diff -c Common.TeX.orig/page.c Common.TeX/page.c
*** Common.TeX.orig/page.c	Tue Jul 28 17:41:03 1987
--- Common.TeX/page.c	Wed Nov 25 22:41:29 1987
***************
*** 884,890
  
  help_box_255 ()
  {
! 	help2("You shouldn't use \\box255 except in output routines.",
  	"Proceed, and I'll discard its present contents.");
  }
  

--- 884,890 -----
  
  help_box_255 ()
  {
! 	help2("You shouldn't use \\box255 except in \\output routines.",
  	"Proceed, and I'll discard its present contents.");
  }
  
***************
*** 891,896
  help_dead_cycles ()
  {
  	help3("I've concluded that your \\output is awry; it never does a",
! 	"\\shipout, so I'm shipping \box255 out myself. Next time",
  	"increase \\maxdeadcycles if you want me to be more patient!");
  }

--- 892,897 -----
  help_dead_cycles ()
  {
  	help3("I've concluded that your \\output is awry; it never does a",
! 	"\\shipout, so I'm shipping \\box255 out myself. Next time",
  	"increase \\maxdeadcycles if you want me to be more patient!");
  }
diff -c Common.TeX.orig/par.c Common.TeX/par.c
*** Common.TeX.orig/par.c	Tue Jul 28 17:41:04 1987
--- Common.TeX/par.c	Sat Dec  5 13:02:54 1987
***************
*** 186,243
  	int		break_type;
  {
  	ptr		s;
! 	qword	t;
  	ptr		v;
  
  	do_all_six(set_break_width_to_background);
! 	if (break_type == UNHYPHENATED || cur_p == NULL) {
! 		for (s = cur_p; s != NULL; s = link(s)) {
! 			if (is_char_node(s))
! 				return;
! 			switch (type(s))
! 			{
! 			case GLUE_NODE:
! 				v = glue_ptr(s);
! 				break_width[1] -= width(v);
! 				break_width[2 + stretch_order(v)] -= stretch(v);
! 				break_width[6] -= shrink(v);
! 				break;
! 			
! 			case PENALTY_NODE:
! 				break;
! 			
! 			case MATH_NODE:
! 			case KERN_NODE:
! 				if (subtype(s) == ACC_KERN) 
! 					return;
! 				else break_width[1] -= width(s);
! 				break;
! 
! 			default:
! 				return;
! 				break;
! 			}
! 		}
! 	} else {
  		t = replace_count(cur_p);
! 		s = cur_p;
  		while (t > 0) {
  			decr(t);
! 			s = link(s);
! 			if (is_char_node(s))
! 				break_width[1] -= width_char(s);
  			else {
! 				switch (type(s))
  				{
  				case LIGATURE_NODE:
! 					break_width[1] -= width_lig_char(s);
  					break;
  
  				case HLIST_NODE:
  				case VLIST_NODE:
  				case RULE_NODE:
  				case KERN_NODE:
! 					break_width[1] -= width(s);
  					break;
  
  				default:

--- 186,217 -----
  	int		break_type;
  {
  	ptr		s;
! 	int		t;
  	ptr		v;
  
  	do_all_six(set_break_width_to_background);
! 	s = cur_p;
! 	if (break_type > UNHYPHENATED && cur_p != NULL) {
  		t = replace_count(cur_p);
! 		v = cur_p;
! 		s = post_break(cur_p);
  		while (t > 0) {
  			decr(t);
! 			v = link(v);
! 			if (is_char_node(v)) 
! 				break_width[1] -= width_char(v);
  			else {
! 				switch (type(v))
  				{
  				case LIGATURE_NODE:
! 					break_width[1] -= width_lig_char(v);
  					break;
  
  				case HLIST_NODE:
  				case VLIST_NODE:
  				case RULE_NODE:
  				case KERN_NODE:
! 					break_width[1] -= width(v);
  					break;
  
  				default:
***************
*** 246,252
  				}
  			}
  		}
! 		for (s = post_break(cur_p); s != NULL; s = link(s)) {
  			if (is_char_node(s))
  				break_width[1] += width_char(s);
  			else {

--- 220,226 -----
  				}
  			}
  		}
! 		for (; s != NULL; s = link(s)) {
  			if (is_char_node(s))
  				break_width[1] += width_char(s);
  			else {
***************
*** 259,276
  				case HLIST_NODE:
  				case VLIST_NODE:
  				case RULE_NODE:
- 				case KERN_NODE:
  					break_width[1] += width(s);
  					break;
  
  				default:
  					confusion("disc2");
  					break;
  				}
  			}
  		}
  		break_width[1] += disc_width;
  	}
  }
  
  try_break (pi, break_type)

--- 233,286 -----
  				case HLIST_NODE:
  				case VLIST_NODE:
  				case RULE_NODE:
  					break_width[1] += width(s);
  					break;
  
+ 				case KERN_NODE:
+ 					if (t == 0 && subtype(s) != ACC_KERN)
+ 						t = -1;	/* discardable */
+ 					else
+ 						break_width[1] += width(s);
+ 					break;
+ 					
  				default:
  					confusion("disc2");
  					break;
  				}
  			}
+ 			incr(t);
  		}
  		break_width[1] += disc_width;
+ 		if (t == 0)
+ 			s = link(v); /* more nodes may be discardable after
+ 					the break */
  	}
+ 	for (; s != NULL; s = link(s)) {
+ 		if (is_char_node(s))
+ 			return;
+ 		switch (type(s)) {
+ 		      case GLUE_NODE:
+ 			v = glue_ptr(s);
+ 			break_width[1] -= width(v);
+ 			break_width[2 + stretch_order(v)] -= stretch(v);
+ 			break_width[6] -= shrink(v);
+ 			break;
+ 			
+ 		      case PENALTY_NODE:
+ 			break;
+ 			
+ 		      case MATH_NODE:
+ 		      case KERN_NODE:
+ 			if (subtype(s) == ACC_KERN) 
+ 				return;
+ 			else break_width[1] -= width(s);
+ 			break;
+ 
+ 		      default:
+ 			return;
+ 			break;
+ 		}
+ 	}
  }
  
  try_break (pi, break_type)
***************
*** 971,980
  					}
  					link(q) = r;
  					disc_break = TRUE;
! 				}
! 				if (!is_char_node(q) && 
! 					(type(q) == MATH_NODE || type(q) == KERN_NODE))
! 					width(q) = 0;
  			}
  		} else {
  			q = temp_head; 

--- 981,990 -----
  					}
  					link(q) = r;
  					disc_break = TRUE;
! 				} else
! 					if (type(q) == MATH_NODE ||
! 					    type(q) == KERN_NODE)
! 						width(q) = 0;
  			}
  		} else {
  			q = temp_head; 
diff -c Common.TeX.orig/print.c Common.TeX/print.c
*** Common.TeX.orig/print.c	Tue Jul 28 17:41:04 1987
--- Common.TeX/print.c	Sun Nov 29 12:22:22 1987
***************
*** 304,310
  			print_char(*j);
  			n -= v;
  		}
! 		if (n == 0) return;
  		k = j + 2;
  		u = v / (*(k - 1) - '0');
  		if (*(k - 1) == '2')  {

--- 324,330 -----
  			print_char(*j);
  			n -= v;
  		}
! 		if (n <= 0) return; /* nonpositive input produces no output */
  		k = j + 2;
  		u = v / (*(k - 1) - '0');
  		if (*(k - 1) == '2')  {
diff -c Common.TeX.orig/scan.c Common.TeX/scan.c
*** Common.TeX.orig/scan.c	Tue Jul 28 17:41:05 1987
--- Common.TeX/scan.c	Mon Dec  7 12:56:32 1987
***************
*** 245,250
  		case GLUE_VAL:
  			cur_val = skip(cur_val);
  			break;
  		}
  		cur_val_level = m;
  		break;

--- 286,295 -----
  		case GLUE_VAL:
  			cur_val = skip(cur_val);
  			break;
+ 
+ 		case MU_VAL:
+ 			cur_val = mu_skip(cur_val);
+ 			break;
  		}
  		cur_val_level = m;
  		break;
***************
*** 363,369
  	scan_int();
  	if (cur_val < 0 || cur_val > 255) {
  		print_err("Bad character code");
! 		help_char();
  		int_error(cur_val);
  		cur_val = 0;
  	}

--- 408,414 -----
  	scan_int();
  	if (cur_val < 0 || cur_val > 255) {
  		print_err("Bad character code");
! 		help_char_num();
  		int_error(cur_val);
  		cur_val = 0;
  	}
***************
*** 741,748
  
  help_mathchar ()
  {
! 	help2("A numeric \\mathchar code must be between 0 and 32767.",
! 	"I changed this one to zero");
  }
  
  help_number ()

--- 841,848 -----
  
  help_mathchar ()
  {
! 	help2("A numeric math code must be between 0 and 32767.",
! 	"I changed this one to zero.");
  }
  
  help_number ()
***************
*** 753,762
  
  help_char ()
  {
! 	help2("The numeric code following \\char must be between 0 and 255.",
  	"I changed this one to zero.");
  }
  
  help_char_const ()
  {
  	help2("A one-character control sequence belongs after a ` mark.",

--- 853,868 -----
  
  help_char ()
  {
! 	help2("The numeric code for a character must be between 0 and 127.",
  	"I changed this one to zero.");
  }
  
+ help_char_num ()
+ {
+ 	help2("A character number must be between 0 and 255.",
+ 	"I changed this one to zero.");
+ }
+ 
  help_char_const ()
  {
  	help2("A one-character control sequence belongs after a ` mark.",
***************
*** 772,779
  help_missing_number ()
  {
  	help3("A number should have been here; I inserted `0'.",
! 	"(If you can't figure out why I needed a number,",
! 	"look up `weird error' in the TeX manual index.)");
  }
  
  help_filll ()

--- 878,885 -----
  help_missing_number ()
  {
  	help3("A number should have been here; I inserted `0'.",
! 	"(If you can't figure out why I needed to see a number,",
! 	"look up `weird error' in the index to The TeXbook.)");
  }
  
  help_filll ()
***************
*** 783,792
  
  help_mu ()
  {
! 	help4("The unit of measurement in \\mskip glue must be mu.",
  	"To recover gracefully from this error, it's best to",
! 	"delete the erroneous units; e.g. type `2' to delete",
! 	"two letters. (See Chapter 27 of the manual.)");
  }
  
  help_mu_error ()

--- 889,898 -----
  
  help_mu ()
  {
! 	help4("The unit of measurement in math glue must be mu.",
  	"To recover gracefully from this error, it's best to",
! 	"delete the erroneous units; e.g., type `2' to delete",
! 	"two letters. (See Chapter 27 of The TeXbook.)");
  }
  
  help_mu_error ()
***************
*** 812,819
  
  help_thee ()
  {
! 	help2("I'm forgetting what you said",
! 	"and using zero for this \\the.");
  }
  
  help_left ()

--- 918,924 -----
  
  help_thee ()
  {
! 	help1("I'm forgetting what you said and using zero instead.");
  }
  
  help_left ()
***************
*** 840,844
  
  help_reg ()
  {
! 	help1("I'm forgetting what you said and not changing anything.");
  }

--- 945,950 -----
  
  help_reg ()
  {
! 	help2("A register number must be between 0 and 255.",
! 	      "I changed this one to zero.");
  }
diff -c Common.TeX.orig/tex.c Common.TeX/tex.c
*** Common.TeX.orig/tex.c	Tue Jul 28 17:41:06 1987
--- Common.TeX/tex.c	Fri Dec  4 15:38:58 1987
***************
*** 35,41
  #include "print.h"
  #include "page.h"
  
! char		banner[] = "This is Common TeX, Version 2.1";
  int			ready_already;
  
  main (argc, argv)

--- 35,41 -----
  #include "print.h"
  #include "page.h"
  
! char		banner[] = "This is Common TeX, Version 2.1.1";
  int			ready_already;
  
  main (argc, argv)
diff -c Common.TeX.orig/texext.c Common.TeX/texext.c
*** Common.TeX.orig/texext.c	Tue Jul 28 17:41:06 1987
--- Common.TeX/texext.c	Mon Dec  7 16:19:42 1987
***************
*** 124,130
  	 
  	case CLOSE_NODE: 
  		print_write("closeout", p); 
- 		print_int(write_stream(p)); 
  		break; 
  	
  	case SPECIAL_NODE: 

--- 124,129 -----
  	 
  	case CLOSE_NODE: 
  		print_write("closeout", p); 
  		break; 
  	
  	case SPECIAL_NODE: 
***************
*** 353,358
  
  help_unbal_write ()
  {
! 	help2("On this page there's a \\write with fewer real {'s than }'s",
  	"I can't handle that very well; good luck.");
  }

--- 358,363 -----
  
  help_unbal_write ()
  {
! 	help2("On this page there's a \\write with fewer real {'s than }'s.",
  	"I can't handle that very well; good luck.");
  }
diff -c Common.TeX.orig/tfm.c Common.TeX/tfm.c
*** Common.TeX.orig/tfm.c	Tue Jul 28 17:41:07 1987
--- Common.TeX/tfm.c	Fri Dec  4 15:24:42 1987
***************
*** 68,74
  	{print_err("Font "); sprint_cs(u); \
  	print_char('='); print_file_name(nom, aire, null_str); \
  	if (s >= 0) {print(" at "); print_scaled(s); print("pt");} \
! 	else if (s != -1000) {print(" scaled "); print_scaled(-s);}}
  
  #define	get_font_byte() \
  	(font_byte = getc(tfm_file))

--- 68,74 -----
  	{print_err("Font "); sprint_cs(u); \
  	print_char('='); print_file_name(nom, aire, null_str); \
  	if (s >= 0) {print(" at "); print_scaled(s); print("pt");} \
! 	else if (s != -1000) {print(" scaled "); print_int(-s);}}
  
  #define	get_font_byte() \
  	(font_byte = getc(tfm_file))
***************
*** 416,422
  {
  	if (tracing_lost_chars > 0) {
  		begin_diagnostic();
! 		print("Missing character: There is no ");
  		print_ASCII(c);
  		print(" in font ");
  		print_str(font_name[f]);

--- 447,453 -----
  {
  	if (tracing_lost_chars > 0) {
  		begin_diagnostic();
! 		print_nl("Missing character: There is no ");
  		print_ASCII(c);
  		print(" in font ");
  		print_str(font_name[f]);
***************
*** 479,485
  help_font_param ()
  {
  	help2("To increase the number of font parameters, you must",
! 	"use \\fontdimen immediately after the font code is defined.");
  }
  
  help_font_cs ()

--- 516,522 -----
  help_font_param ()
  {
  	help2("To increase the number of font parameters, you must",
! 	"use \\fontdimen immediately after the \\font is loaded.");
  }
  
  help_font_cs ()
diff -c Common.TeX.orig/token.c Common.TeX/token.c
*** Common.TeX.orig/token.c	Tue Jul 28 17:41:07 1987
--- Common.TeX/token.c	Wed Dec  2 14:09:58 1987
***************
*** 508,515
  {
  	help4("I suspect you have forgotten a `}', causing me",
  	"to read past where you wanted me to stop.",
! 	"Either type `I}' to try recovering,",
! 	"or type 'X' and fix your file.");
  }
  
  help_funny ()

--- 535,542 -----
  {
  	help4("I suspect you have forgotten a `}', causing me",
  	"to read past where you wanted me to stop.",
! 	"I'll try to recover; but if the error is serious,",
! 	"you'd better type `E' or `X' now and fix your file.");
  }
  
  help_funny ()
diff -c Common.TeX.orig/tokenlists.c Common.TeX/tokenlists.c
*** Common.TeX.orig/tokenlists.c	Tue Jul 28 17:41:08 1987
--- Common.TeX/tokenlists.c	Sat Dec  5 15:31:25 1987
***************
*** 400,406
  		else {
  			m = token(p) / 0400;
  			c = token(p) % 0400;
! 			if (m < 0 || c > 127)
  				print_esc("BAD.");
  			else {
  				switch (m)

--- 492,498 -----
  		else {
  			m = token(p) / 0400;
  			c = token(p) % 0400;
! 			if (token(p) < 0 || c > 127)
  				print_esc("BAD.");
  			else {
  				switch (m)
***************
*** 418,429
  					break;
  				
  				case MAC_PARAM:
! 					print_char(c);
! 					print_char(c);
  					break;
  				
  				case OUT_PARAM:
! 					print_char(match_chr);
  					if (c <= 9)
  						print_char(c + '0');
  					else {

--- 510,521 -----
  					break;
  				
  				case MAC_PARAM:
! 					print_str(c);
! 					print_str(c);
  					break;
  				
  				case OUT_PARAM:
! 					print_str(match_chr);
  					if (c <= 9)
  						print_char(c + '0');
  					else {
***************
*** 434,440
  				
  				case MATCH:
  					match_chr = c;
! 					print_char(c);
  					incr(n);
  					print_char(n);
  					if (n > '9')

--- 526,532 -----
  				
  				case MATCH:
  					match_chr = c;
! 					print_str(c);
  					incr(n);
  					print_char(n);
  					if (n > '9')
diff -c Common.TeX.orig/tokenstack.c Common.TeX/tokenstack.c
*** Common.TeX.orig/tokenstack.c	Tue Jul 28 17:41:08 1987
--- Common.TeX/tokenstack.c	Fri Dec  4 16:45:50 1987
***************
*** 282,288
  					for (i = start; i < j; incr(i)) {
  						if (i == loc)
  							set_trick_count();
! 						print_char(buffer[i]);
  					}
  				}
  			} else {

--- 337,343 -----
  					for (i = start; i < j; incr(i)) {
  						if (i == loc)
  							set_trick_count();
! 						print_str(buffer[i]);
  					}
  				}
  			} else {
--
and here is Joe Weenings patch
Also, we recently discovered a bug in Common TeX apparently not caught by
the trip test.  It's just a transcription error from the Pascal code, and
occurs when you add glue with different stretch order.  Here's the fix,
which I've also sent to Pat Monardo:

diff -c def.c.bad def.c 
*** def.c.bad	Mon Jul 27 22:40:56 1987
--- def.c	Fri Feb 19 18:33:11 1988
***************
*** 514,520
  				width(q) += width(r);
  				if (stretch(q) == 0)
  					stretch_order(q) = NORMAL;
! 				else if (stretch_order(q) == stretch_order(r))
  					stretch(q) += stretch(r);
  				else if (stretch_order(q) < stretch_order(r) &&
  						stretch_order(r) != 0) {

--- 514,520 -----
  				width(q) += width(r);
  				if (stretch(q) == 0)
  					stretch_order(q) = NORMAL;
! 				if (stretch_order(q) == stretch_order(r))
  					stretch(q) += stretch(r);
  				else if (stretch_order(q) < stretch_order(r) &&
  						stretch_order(r) != 0) {


--
Domainised:  mark@comp.vuw.ac.nz	Bang form: ...!uunet!vuwcomp!mark
