summaryrefslogtreecommitdiff
path: root/systems/unix/tex-fpc/tex.ch
diff options
context:
space:
mode:
Diffstat (limited to 'systems/unix/tex-fpc/tex.ch')
-rw-r--r--systems/unix/tex-fpc/tex.ch184
1 files changed, 89 insertions, 95 deletions
diff --git a/systems/unix/tex-fpc/tex.ch b/systems/unix/tex-fpc/tex.ch
index 491307d948..c6f0087062 100644
--- a/systems/unix/tex-fpc/tex.ch
+++ b/systems/unix/tex-fpc/tex.ch
@@ -1,4 +1,4 @@
-% This is a change file of TeX, Wolfgang Helbig, Nov. 2007-Nov. 2020
+% This is a change file of TeX, Wolfgang Helbig, Nov. 2007-Feb. 2021
[0] About TeX-FPC
Strangely, the first page is page 3
@@ -19,15 +19,15 @@ Strangely, the first page is page 3
\let\maybe=\iffalse % maybe -> print all, notmaybe -> print changed modules only
% put a mark in the left margin. (see Exercise 14.28 in The TeXbook)
-\def\marke#1{\strut\vadjust{\kern-\dp\strutbox\vbox to 0pt{\vss
- \llap{\bf #1\/\quad\strut}}}\ignorespaces }
+\def\marke#1{\strut\vadjust{\vbox to 0pt
+ {\vskip-\baselineskip\moveleft 2em\hbox{\bf #1\strut}\vss}}\ignorespaces}
\def\name{\TeX}
\N0\*. \[0] About \namefpc.
-\namefpc\ is an adaption of Donald~E. Knuth's \TeX82 in
-the version 3.14159265 from January 2014 to Free~Pascal (FPC) and Unix.
-To help you identify the differences of \TeX82 and
+\namefpc\ is a port of Donald~E. Knuth's typesetting program \TeX,
+version 3.141592653 from February 2021 to Free~Pascal (FPC) and Unix.
+To help you identify the differences of \TeX\ and
\namefpc, the numbers of modified modules carry an asterisk. Letters
in the left margin indicate the reason for a change. They mean:
\medskip
@@ -47,22 +47,21 @@ recovery.
new line until it reaches a nondiscardable node. This might leave
you with an empty box resulting in an \.{Underfull box} warning.
Btw, I discovered this bug while trying to prove the line breaking
-algorithm, not through by testing. In this regard, I go with Dijkstra, not
-with Knuth.
+algorithm, not while plain testing it. If you have time, prove, if
+not test.
\item{(3)} \TeX\ fails to respect end of file (Control-D) from
-terminal oinput during debug dialog.
+terminal input during debug dialog.
-\item{(3)}
-Igor Liferenko reported an extra space in the transcript file and
-a missing last line terminator on terminal output after user switched
-to \.{/batchmode} during error recovery.
+\item{(4)}
+Igor Liferenko reported an extra space in the transcript file
+after the user switched to \.{/batchmode} during error recovery.
\medskip
\item{(1)}\marke F\namefpc\ treats the command line as the first input line;
-\item{(2)}\namefpc\ starts \.{vi} if the user types `\.{E}' during
-error recovery.
+\item{(2)}\namefpc\ starts \.{ed}, the unix system editor, if the
+user types `\.{E}' during error recovery.
\item{(3)}You can interrupt \namefpc\ by typing `\.{Control-C}'.
@@ -129,7 +128,7 @@ I'd rather maintain invariants---not software.
known as `\TeX' [cf.~Stanford Computer Science report CS1027,
November 1984].
-@d banner=='This is TeX, Version 3.14159265' {printed when \TeX\ starts}
+@d banner=='This is TeX, Version 3.141592653' {printed when \TeX\ starts}
@y
known as `\TeX' [cf.~Stanford Computer Science report CS1027,
November 1984].
@@ -137,7 +136,7 @@ November 1984].
Even though \namefpc\ does not differ from \TeX\ I proudly change
the banner! And take responsibility for any error.
-@d banner=='This is TeX-FPC, 2nd ed.'
+@d banner=='This is TeX-FPC, 3rd ed.'
@z
[4] program header
@@ -150,7 +149,7 @@ the banner! And take responsibility for any error.
@d term_in==i @& n @& p @& u @& t
@d term_out==o @& u @& t @& p @& u @& t
-@d mtype==t @& y @& p @& e
+@d mtype==t@&y@&p@&e
@z
[4] program header
@@ -183,15 +182,15 @@ to the @x line and type >} or <} to (un)indent a paragraph.
@z
[7] shift left to turn stats on, right to turn them off.
- @x stats
- @d stat==@{ {change this to `$\\{stat}\equiv\null$' when gathering
- usage statistics}
- @d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' when gathering
- usage statistics}
- @y
- @d stat== {change this to `$\\{stat}\equiv\.{@@\{}$' to turn off statistics}
- @d tats== {change this to `$\\{tats}\equiv\.{@@\}}$' to turn off statistics}
- @z
+@x stats
+@d stat==@{ {change this to `$\\{stat}\equiv\null$' when gathering
+ usage statistics}
+@d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' when gathering
+ usage statistics}
+@y
+@d stat== {change this to `$\\{stat}\equiv\.{@@\{}$' to turn off statistics}
+@d tats== {change this to `$\\{tats}\equiv\.{@@\}}$' to turn off statistics}
+@z
[8] shift left to build TEX and right to build INITEX.
@@ -256,9 +255,9 @@ to Pascal.
@z
The changes headed by trip need to be made for the trip test suite.
- For trip activate all changeblocks with the first line @x trip.
+For trip activate all changeblocks with the first line @x trip.
- [11]
+[11]
@x trip
@!mem_max=30000; {greatest index in \TeX's internal |mem| array;
@y
@@ -638,7 +637,9 @@ while argc <= fpc_param_count do
begin
if last+1>=buf_size then
@<Report overflow of the input buffer, and abort@>;
- buffer[last] := xord[arg[cc]]; incr(last); incr(cc)
+ if xord[arg[cc]] <> invalid_code then
+ buffer[last] := xord[arg[cc]];
+ incr(last); incr(cc)
end;
if (argc <= fpc_param_count) then begin
buffer[last] := " "; incr(last) {insert a space between arguments}
@@ -695,11 +696,19 @@ loop@+begin write(term_out,'**');
get_strings_started:=false; return;
@z
-[51] TANGLE would'nt help, but update
+[51] print more sensible what you can't read
+@x
+else bad_pool('! I can''t read TEX.POOL.')
+@y
+else bad_pool('! I can''t read TeXformats/tex.pool.'){\marke u Unix file name}
+@z
+
+[53] TANGLE would'nt help. Don't guess but report what does not match.
@x
done: if a<>@$ then bad_pool('! TEX.POOL doesn''t match; TANGLE me again.');
@y
-done: if a<>@$ then bad_pool('! TeXformats/tex.pool doesn''t match.');
+done: if a<>@$ then bad_pool
+('! TeXformats/tex.pool doesn''t match. Not installed?'); {\marke u Unix file name}
@z
[79] start editor
@@ -722,22 +731,9 @@ want_edit := false; {\marke F don't start \.{ed}}
[84] set edit_cmd
@x
- begin print_nl("You want to edit file ");
-@.You want to edit file x@>
- slow_print(input_stack[base_ptr].name_field);
- print(" at line "); print_int(line);
interaction:=scroll_mode; jump_out;
- end;
@y
-@^Editor@>
- begin print_nl("You want to edit file ");
-@.You want to edit file x@>
- slow_print(input_stack[base_ptr].name_field);
- print(" at line "); print_int(line);
- interaction:=scroll_mode;
- want_edit := true;
- jump_out;
- end;
+ interaction:=scroll_mode; want_edit := true; jump_out;
@z
[86] extra space in log and missing last line terminator on terminal
@@ -745,8 +741,7 @@ want_edit := false; {\marke F don't start \.{ed}}
"Q":begin print_esc("batchmode"); decr(selector);
end;
@y
-"Q":print_esc("batchmode");
-{ \marke E don't turn off terminal now }
+"Q":print_esc("batchmode"); {\marke E don't turn off terminal now}
@z
[86] continued
@@ -806,10 +801,12 @@ macros are simplified in the obvious way when |min_quarterword=0|.
[241]
@x
@p procedure fix_date_and_time;
-begin time:=12*60; {minutes since midnight}
-day:=4; {fourth day of the month}
-month:=7; {seventh month of the year}
-year:=1776; {Anno Domini}
+begin sys_time:=12*60;
+sys_day:=4; sys_month:=7; sys_year:=1776; {self-evident truths}
+time:=sys_time; {minutes since midnight}
+day:=sys_day; {day of the month}
+month:=sys_month; {month of the year}
+year:=sys_year; {Anno Domini}
end;
@y
\marke X The functions |now|, |decodedate|, and |decodetime| are provided
@@ -828,11 +825,11 @@ var yy,mm,dd: word;
hh,ss,ms: word;
begin
fpc_decode_date(fpc_now,yy,mm,dd); {current date}
-day := dd;
-month := mm;
-year := yy;@/
+sys_day := dd; day:=sys_day;
+sys_month := mm; month:=sys_month;
+sys_year := yy; year := sys_year;@/
fpc_decode_time(fpc_now,hh,mm,ss,ms); {current time}
-time := hh*60+mm; {minutes since midnight}
+sys_time := hh*60+mm; time := sys_time; {minutes since midnight}
end;
@z
@@ -897,25 +894,11 @@ to place.
@d append_to_name(#)==begin c:=#; incr(k);
@y
-\marke X With Free~Pascal you cannot set the length of a |packed
-array|. And with Unix, it does not help to blank out the rest of
-the |array|. But assigning the |name_of_file| to an |fpc_string|,
-setting the length of the |fpc_string| and then assigning it back
-to the |name_of_file| seems to work. @^FPC Pascal@>
-
-@d fpc_set_length==s@&e@&t@&l@&e@&n@&g@&t@&h
+\marke U In Unix strings are terminated by chr(0).
@d append_to_name(#)==begin c:=#; incr(k);
@z
-[519]
-@x
-@!j:pool_pointer; {index into |str_pool|}
-@y
-@!j:pool_pointer; {index into |str_pool|}
-@!s: fpc_string;
-@z
-
[519] pack file name
@x
if k<=file_name_size then name_length:=k@+else name_length:=file_name_size;
@@ -923,9 +906,7 @@ for k:=name_length+1 to file_name_size do name_of_file[k]:=' ';
end;
@y
if k<=file_name_size then name_length:=k@+else name_length:=file_name_size;
-s := name_of_file;
-fpc_set_length(s, name_length);
-name_of_file := s;
+for k:=name_length+1 to file_name_size do name_of_file[k]:=chr(0);
end;
@z
@@ -939,18 +920,17 @@ TEX_format_default:='TeXformats/plain.fmt';
[523] packed buffered name
@x
-@!j:integer; {index into |buffer| or |TEX_format_default|}
+for k:=name_length+1 to file_name_size do name_of_file[k]:=' ';
@y
@^FPC Pascal@>
-@!j:integer; {index into |buffer| or |TEX_format_default|}
-s: fpc_string;
+for k:=name_length+1 to file_name_size do name_of_file[k]:=chr(0);
@z
-[523] packed buffered name
+[524 specify better, what you cannot read:
@x
-for k:=name_length+1 to file_name_size do name_of_file[k]:=' ';
+ wterm_ln('I can''t find the PLAIN format file!');
@y
-s := name_of_file; fpc_set_length(s, name_length); name_of_file := s;
+ wterm_ln('I can''t find TeXformats/plain.fmt!'); {\marke u Unix file name}
@z
[530] Control D will help
@@ -964,26 +944,38 @@ print_nl("Please type another "); print(s); print(" or Control-D");
@x
@ Let's turn now to the procedure that is used to initiate file reading
when an `\.{\\input}' command is being processed.
-
+Beware: For historic reasons, this code foolishly conserves a tiny bit
+of string pool space; but that can confuse the interactive `\.E' option.
+@^system dependencies@>
@y
@ Let's turn now to the procedure that is used to initiate file reading
when an `\.{\\input}' command is being processed.
+Beware: For historic reasons, this code foolishly conserves a tiny bit
+of string pool space; but that can confuse the interactive `\.E' option.
+
+\marke E In fact, it breaks the `\.E' option whenever the file to be
+edited was opened after the log file.
+In that case, the last string constructed is the name of the log file,
+otherwise, the last string constructed is the name of the input file.
+If the name of the input file is the last string constructed,
+\TeX\ strips off area and extension to conserve string
+pool space. The user is shown the base name of the file he wants
+to edit to fix a bug.
+
+Sadly, Knuth doesn't dare to fix this bug, which is known for at
+least twelve years. Are we approaching the limits of ``Literate Programming''.
+It looks beautiful but does it really help to cope with complexity?
+
@^Editor@>
@^Fix@>
-
-\marke E Keep the complete file name since it might be needed to
-be passed to the system editor.
-(\TeX82 strips off area and extension to conserve string
-pool space.)
@z
[537] never flush file name
@x
-if name=str_ptr-1 then {we can conserve string pool space now}
+if name=str_ptr-1 then {conserve string pool space (but see note above)}
begin flush_string; name:=cur_name;
end;
@y
-@^Editor@>
@z
[575] Don't check eof (fpc bug: eof off by one)
@@ -1177,9 +1169,11 @@ fpc_halt(history);
[1333] print last end-of-line marker if needed
@x
-This program doesn't bother to close the input files that may still be open.
+If |final_cleanup| is bypassed, this program doesn't bother to close
+the input files that may still be open.
@y
-This program doesn't bother to close the input files that may still be open.
+If |final_cleanup| is bypassed, this program doesn't bother to close
+the input files that may still be open.
\marke u
Terminate the last line on the terminal.
@z
@@ -1235,7 +1229,7 @@ itself will get a new section number.
@y
itself will get a new section number.
-@ \marke F If the user typed |'E'| to edit a file after confronted
+@ \marke F If the user typed \.{E} to edit a file after confronted
with an error message, \TeX\ will clean up and then call |edit|
as its last feat.
@^Editor@>
@@ -1302,15 +1296,15 @@ unit. @^unix@>
@d fpc_pchar == pchar
@d edit_file == input_stack[base_ptr].name_field
@#
-@d vi==@{ {change this to `$\\{vi}\equiv\null$' when you think \.{vi}
+@d vi== {change this to `$\\{vi}\equiv\null$' when you think \.{vi}
is the system editor}
-@d iv==@t@>@} {change this to `$\\{iv}\equiv\null$' when you think \.{vi}
+@d iv== {change this to `$\\{iv}\equiv\null$' when you think \.{vi}
is the sytem editor}
@f vi == begin
@f iv == end
-@d ed== {change this to `$\\{ed}\equiv\.{@@\{}$' when you think \.{vi}
+@d ed==@{ {change this to `$\\{ed}\equiv\.{@@\{}$' when you think \.{vi}
is the system editor}
-@d de== {change this to `$\\{de}\equiv\.{@@\}}$' when you think \.{vi}
+@d de==@} {change this to `$\\{de}\equiv\.{@@\}}$' when you think \.{vi}
is the system editor}
@f ed == begin
@f de == end