diff options
author | Andreas Scherer <andreas_tex@freenet.de> | 2020-08-01 12:01:34 +0000 |
---|---|---|
committer | Andreas Scherer <andreas_tex@freenet.de> | 2020-08-01 12:01:34 +0000 |
commit | 2b48c58a3269e00f95e2769500c0230b2b7f397a (patch) | |
tree | c318c9368cdcf720af8624d45c0579b23e0635cd | |
parent | 33b2e31d6d3f08f67bad4a8a66b6c38eeea3ab02 (diff) |
Purge non-local 'goto' labels in WEB programs.
If code and comment disagree, most likely they both are wrong. ;o)
git-svn-id: svn://tug.org/texlive/trunk@56013 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/web2c/ChangeLog | 11 | ||||
-rw-r--r-- | Build/source/texk/web2c/dvicopy.ch | 23 | ||||
-rw-r--r-- | Build/source/texk/web2c/dvitype.ch | 23 | ||||
-rw-r--r-- | Build/source/texk/web2c/gftopk.ch | 7 | ||||
-rw-r--r-- | Build/source/texk/web2c/gftype.ch | 8 | ||||
-rw-r--r-- | Build/source/texk/web2c/mf.ch | 26 | ||||
-rw-r--r-- | Build/source/texk/web2c/mft.ch | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/pktogf.ch | 6 | ||||
-rw-r--r-- | Build/source/texk/web2c/pktype.ch | 5 |
9 files changed, 113 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog index e946fee420c..8eca662546e 100644 --- a/Build/source/texk/web2c/ChangeLog +++ b/Build/source/texk/web2c/ChangeLog @@ -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. diff --git a/Build/source/texk/web2c/dvicopy.ch b/Build/source/texk/web2c/dvicopy.ch index 84639fb017d..838402b6400 100644 --- a/Build/source/texk/web2c/dvicopy.ch +++ b/Build/source/texk/web2c/dvicopy.ch @@ -29,6 +29,18 @@ @!random_reading:boolean; {should we skip around in the file?} @z +@x [3] Purge non-local 'goto'. +calls the `|jump_out|' procedure, which goes to the label |final_end|. + +@d final_end = 9999 {go here to wrap it up} +@y +calls the `|jump_out|' procedure. +@z +@x +label final_end; +@y +@z + @x [3] Set up kpathsea. procedure initialize; {this procedure gets things started properly} var @<Local variables for initialization@>@/ @@ -121,6 +133,17 @@ procedure initialize; {this procedure gets things started properly} @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. +@y +so a procedure called |jump_out| has been introduced. +@z +@x @d abort(#)==begin print_ln(' ',#,'.'); jump_out; end diff --git a/Build/source/texk/web2c/dvitype.ch b/Build/source/texk/web2c/dvitype.ch index 661a4b7bdd0..7c0155943b1 100644 --- a/Build/source/texk/web2c/dvitype.ch +++ b/Build/source/texk/web2c/dvitype.ch @@ -60,6 +60,22 @@ procedure initialize; {this procedure gets things started properly} print_ln (version_string); @z +@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. + +@d final_end=9999 {label for the end of it all} +@d done=30 {go here when finished with a subtask} + +@<Labels...@>=final_end,done; +@y +@ Label |done| is used when stopping normally. + +@d done=30 {go here when finished with a subtask} + +@<Labels...@>=done; +@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 @@ procedure initialize; {this procedure gets things started properly} @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}. +@y +so a procedure called |jump_out| has been introduced. +@z +@x @d abort(#)==begin print(' ',#); jump_out; end @d bad_dvi(#)==abort('Bad DVI file: ',#,'!') diff --git a/Build/source/texk/web2c/gftopk.ch b/Build/source/texk/web2c/gftopk.ch index 80f333e77e4..28f20a83b3a 100644 --- a/Build/source/texk/web2c/gftopk.ch +++ b/Build/source/texk/web2c/gftopk.ch @@ -87,6 +87,13 @@ a non-local goto, which we can't use in C. @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}. +@y +so a procedure called |jump_out| has been introduced. +@z +@x @d abort(#)==begin print(' ',#); jump_out; end @d bad_gf(#)==abort('Bad GF file: ',#,'!') diff --git a/Build/source/texk/web2c/gftype.ch b/Build/source/texk/web2c/gftype.ch index 18357b3f475..a0fa00b686d 100644 --- a/Build/source/texk/web2c/gftype.ch +++ b/Build/source/texk/web2c/gftype.ch @@ -134,6 +134,14 @@ if max_cols > max_image then max_cols := max_image; image_array := nil; @z +@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}. +@y +so a procedure called |jump_out| has been introduced. +@z + @x [7] Remove jump_out, and make `abort' end with a newline. @d abort(#)==begin print(' ',#); jump_out; end diff --git a/Build/source/texk/web2c/mf.ch b/Build/source/texk/web2c/mf.ch index 5712b459458..bfd297440e8 100644 --- a/Build/source/texk/web2c/mf.ch +++ b/Build/source/texk/web2c/mf.ch @@ -30,6 +30,16 @@ \def\glob{13}\def\gglob{20, 25} % these are defined in module 1 @z +@x [1.6] Purge non-local 'goto' label. +@d end_of_MF=9998 {go here to close files and terminate gracefully} +@y +@z +@x +start_of_MF@t\hskip-2pt@>, end_of_MF@t\hskip-2pt@>,@,final_end; +@y +start_of_MF@t\hskip-2pt@>,@,final_end; +@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 @@ else @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; diff --git a/Build/source/texk/web2c/mft.ch b/Build/source/texk/web2c/mft.ch index b5de55d6f9f..ed18c7391f9 100644 --- a/Build/source/texk/web2c/mft.ch +++ b/Build/source/texk/web2c/mft.ch @@ -47,8 +47,12 @@ Changes for \MP\ by W.~Bzyl in July, 2001. % 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 diff --git a/Build/source/texk/web2c/pktogf.ch b/Build/source/texk/web2c/pktogf.ch index f8a03595d72..edce6bfe7f4 100644 --- a/Build/source/texk/web2c/pktogf.ch +++ b/Build/source/texk/web2c/pktogf.ch @@ -94,12 +94,18 @@ a non-local goto, which we don't use in C. @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; 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 diff --git a/Build/source/texk/web2c/pktype.ch b/Build/source/texk/web2c/pktype.ch index d6fd34353a9..96096eddc95 100644 --- a/Build/source/texk/web2c/pktype.ch +++ b/Build/source/texk/web2c/pktype.ch @@ -52,10 +52,15 @@ begin @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 |