texlive[56013] Build/source/texk/web2c: Purge non-local 'goto' labels

commits+ascherer at tug.org commits+ascherer at tug.org
Sat Aug 1 14:01:34 CEST 2020


Revision: 56013
          http://tug.org/svn/texlive?view=revision&revision=56013
Author:   ascherer
Date:     2020-08-01 14:01:34 +0200 (Sat, 01 Aug 2020)
Log Message:
-----------
Purge non-local 'goto' labels in WEB programs.

If code and comment disagree, most likely they both are wrong. ;o)

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/ChangeLog
    trunk/Build/source/texk/web2c/dvicopy.ch
    trunk/Build/source/texk/web2c/dvitype.ch
    trunk/Build/source/texk/web2c/gftopk.ch
    trunk/Build/source/texk/web2c/gftype.ch
    trunk/Build/source/texk/web2c/mf.ch
    trunk/Build/source/texk/web2c/mft.ch
    trunk/Build/source/texk/web2c/pktogf.ch
    trunk/Build/source/texk/web2c/pktype.ch

Modified: trunk/Build/source/texk/web2c/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/ChangeLog	2020-08-01 00:03:15 UTC (rev 56012)
+++ trunk/Build/source/texk/web2c/ChangeLog	2020-08-01 12:01:34 UTC (rev 56013)
@@ -1,3 +1,14 @@
+2020-08-01  Andreas Scherer  <https://ascherer.github.io>
+
+	* dvicopy.ch,
+	* dvitype.ch,
+	* gftopk.ch,
+	* gftype.ch,
+	* mf.ch,
+	* mft.ch,
+	* pktogf.ch,
+	* pktype.ch: Purge non-local 'goto' labels.
+
 2020-07-25  Andreas Scherer  <https://ascherer.github.io>
 
 	* mft.ch: Swap \MF and \MP to match meaning of 'metapost' flag.

Modified: trunk/Build/source/texk/web2c/dvicopy.ch
===================================================================
--- trunk/Build/source/texk/web2c/dvicopy.ch	2020-08-01 00:03:15 UTC (rev 56012)
+++ trunk/Build/source/texk/web2c/dvicopy.ch	2020-08-01 12:01:34 UTC (rev 56013)
@@ -29,6 +29,18 @@
 @!random_reading:boolean; {should we skip around in the file?}
 @z
 
+ at x [3] Purge non-local 'goto'.
+calls the `|jump_out|' procedure, which goes to the label |final_end|.
+
+ at d final_end = 9999 {go here to wrap it up}
+ at y
+calls the `|jump_out|' procedure.
+ at z
+ at x
+label final_end;
+ at y
+ at z
+
 @x [3] Set up kpathsea.
 procedure initialize; {this procedure gets things started properly}
   var @<Local variables for initialization@>@/
@@ -121,6 +133,17 @@
 @z
 
 @x [23] Remove non-local goto, declare jump_out as noreturn
+so a procedure called |jump_out| has been introduced. This procedure, which
+transfers control to the label |final_end| at the end of the program,
+contains the only non-local |@!goto| statement in \.{\title}.
+@^system dependencies@>
+Some \PASCAL\ compilers do not implement non-local |goto| statements. In
+such cases the |goto final_end| in |jump_out| should simply be replaced
+by a call on some system procedure that quietly terminates the program.
+ at y
+so a procedure called |jump_out| has been introduced.
+ at z
+ at x
 @d abort(#)==begin print_ln(' ',#,'.'); jump_out;
     end
 

Modified: trunk/Build/source/texk/web2c/dvitype.ch
===================================================================
--- trunk/Build/source/texk/web2c/dvitype.ch	2020-08-01 00:03:15 UTC (rev 56012)
+++ trunk/Build/source/texk/web2c/dvitype.ch	2020-08-01 12:01:34 UTC (rev 56013)
@@ -60,6 +60,22 @@
   print_ln (version_string);
 @z
 
+ at x [4] Purge non-local 'goto'.
+@ If the program has to stop prematurely, it goes to the
+`|final_end|'. Another label, |done|, is used when stopping normally.
+
+ at d final_end=9999 {label for the end of it all}
+ at d done=30 {go here when finished with a subtask}
+
+@<Labels...@>=final_end,done;
+ at y
+@ Label |done| is used when stopping normally.
+
+ at d done=30 {go here when finished with a subtask}
+
+@<Labels...@>=done;
+ at z
+
 % There were no complaints that these values are too small, and adjusting
 % them dynamically requires to resize a large number of arrays and is not
 % worth the effort (if necessary one can recompile with larger values).
@@ -83,6 +99,13 @@
 @z
 
 @x [7] Remove non-local goto.
+so a procedure called |jump_out| has been introduced. This procedure, which
+simply transfers control to the label |final_end| at the end of the program,
+contains the only non-local |goto| statement in \.{DVItype}.
+ at y
+so a procedure called |jump_out| has been introduced.
+ at z
+ at x
 @d abort(#)==begin print(' ',#); jump_out;
     end
 @d bad_dvi(#)==abort('Bad DVI file: ',#,'!')

Modified: trunk/Build/source/texk/web2c/gftopk.ch
===================================================================
--- trunk/Build/source/texk/web2c/gftopk.ch	2020-08-01 00:03:15 UTC (rev 56012)
+++ trunk/Build/source/texk/web2c/gftopk.ch	2020-08-01 12:01:34 UTC (rev 56013)
@@ -87,6 +87,13 @@
 @z
 
 @x [8] Make `abort' end with a newline, and remove the nonlocal goto.
+so a procedure called |jump_out| has been introduced. This procedure, which
+simply transfers control to the label |final_end| at the end of the program,
+contains the only non-local |goto| statement in \.{GFtoPK}.
+ at y
+so a procedure called |jump_out| has been introduced.
+ at z
+ at x
 @d abort(#)==begin print(' ',#); jump_out;
     end
 @d bad_gf(#)==abort('Bad GF file: ',#,'!')

Modified: trunk/Build/source/texk/web2c/gftype.ch
===================================================================
--- trunk/Build/source/texk/web2c/gftype.ch	2020-08-01 00:03:15 UTC (rev 56012)
+++ trunk/Build/source/texk/web2c/gftype.ch	2020-08-01 12:01:34 UTC (rev 56013)
@@ -134,6 +134,14 @@
 image_array := nil;
 @z
 
+ at x [7] Purge 'final_end' label.
+so a procedure called |jump_out| has been introduced. This procedure, which
+simply transfers control to the label |final_end| at the end of the program,
+contains the only non-local |goto| statement in \.{GFtype}.
+ at y
+so a procedure called |jump_out| has been introduced.
+ at z
+
 @x [7] Remove jump_out, and make `abort' end with a newline.
 @d abort(#)==begin print(' ',#); jump_out;
     end

Modified: trunk/Build/source/texk/web2c/mf.ch
===================================================================
--- trunk/Build/source/texk/web2c/mf.ch	2020-08-01 00:03:15 UTC (rev 56012)
+++ trunk/Build/source/texk/web2c/mf.ch	2020-08-01 12:01:34 UTC (rev 56013)
@@ -30,6 +30,16 @@
 \def\glob{13}\def\gglob{20, 25} % these are defined in module 1
 @z
 
+ at x [1.6] Purge non-local 'goto' label.
+ at d end_of_MF=9998 {go here to close files and terminate gracefully}
+ at y
+ at z
+ at x
+start_of_MF at t\hskip-2pt@>, end_of_MF at t\hskip-2pt@>,@,final_end;
+ at y
+start_of_MF at t\hskip-2pt@>,@,final_end;
+ at z
+
 @x [1.7] Convert `debug..gubed' and `stat..tats' into #ifdefs.
 @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
 @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
@@ -621,11 +631,27 @@
 @z
 
 @x [6.76] Eliminate non-local goto.
+@ The |jump_out| procedure just cuts across all active procedure levels and
+goes to |end_of_MF|. This is the only nontrivial |@!goto| statement in the
+whole program. It is used when there is no recovery from a particular error.
+
+Some \PASCAL\ compilers do not implement non-local |goto| statements.
+@^system dependencies@>
+In such cases the body of |jump_out| should simply be
+`|close_files_and_terminate|;\thinspace' followed by a call on some system
+procedure that quietly terminates the program.
+
 @<Error hand...@>=
 procedure jump_out;
 begin goto end_of_MF;
 end;
 @y
+@ The |jump_out| procedure just cuts across all active procedure levels and
+simply calls
+`|close_files_and_terminate|;\thinspace' followed by a call on some system
+procedure that quietly terminates the program.
+@^system dependencies@>
+
 @d do_final_end==begin
    update_terminal;
    ready_already:=0;

Modified: trunk/Build/source/texk/web2c/mft.ch
===================================================================
--- trunk/Build/source/texk/web2c/mft.ch	2020-08-01 00:03:15 UTC (rev 56012)
+++ trunk/Build/source/texk/web2c/mft.ch	2020-08-01 12:01:34 UTC (rev 56013)
@@ -47,8 +47,12 @@
 % AIX defines `class' in <math.h>, so let's take this opportunity to
 % define that away.
 @x
+calls the `|jump_out|' procedure, which goes to the label |end_of_MFT|.
+
 @d end_of_MFT = 9999 {go here to wrap it up}
 @y
+calls the `|jump_out|' procedure.
+
 @d class == class_var
 @z
 

Modified: trunk/Build/source/texk/web2c/pktogf.ch
===================================================================
--- trunk/Build/source/texk/web2c/pktogf.ch	2020-08-01 00:03:15 UTC (rev 56012)
+++ trunk/Build/source/texk/web2c/pktogf.ch	2020-08-01 12:01:34 UTC (rev 56013)
@@ -94,6 +94,9 @@
 @z
 
 @x [8] Just exit, instead of doing a nonlocal goto.
+nested procedure, so the procedure called |jump_out| has been added to transfer
+to the very end of the program with an error message.
+
 @d abort(#)==begin print_ln(' ',#); jump_out; end
 
 @p procedure jump_out;
@@ -100,6 +103,9 @@
 begin goto final_end;
 end;
 @y
+nested procedure, so we might want to |abort|
+the program with an error message.
+
 @d abort(#)==begin verbose:=true; print_ln(#); uexit(1);
     end
 @z

Modified: trunk/Build/source/texk/web2c/pktype.ch
===================================================================
--- trunk/Build/source/texk/web2c/pktype.ch	2020-08-01 00:03:15 UTC (rev 56012)
+++ trunk/Build/source/texk/web2c/pktype.ch	2020-08-01 12:01:34 UTC (rev 56013)
@@ -52,10 +52,15 @@
 @z
 
 @x [5] Remove the unused label.
+@ If the program has to stop prematurely, it goes to the
+`|final_end|'.
+
 @d final_end=9999 {label for the end of it all}
 
 @<Labels...@>=final_end;
 @y
+@ This module is deleted, because it is only useful for
+a non-local goto, which we don't use in C.
 @z
 
 % [6] No need for |name_length| or |terminal_line_length|.  Since these



More information about the tex-live-commits mailing list.