summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/mfluadir
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2015-06-12 08:45:07 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2015-06-12 08:45:07 +0000
commit4403160cd26a0ba4eb014d69bfb9dcd568f64fc6 (patch)
tree0a036c9b3654e6e7b2e73753225598980d25c54f /Build/source/texk/web2c/mfluadir
parent1dde8ab4578f370c597332ff3421097d7cb39a1a (diff)
Integrate MFLua and MFLuaJIT
git-svn-id: svn://tug.org/texlive/trunk@37504 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/mfluadir')
-rw-r--r--Build/source/texk/web2c/mfluadir/ChangeLog5
-rw-r--r--Build/source/texk/web2c/mfluadir/am/mflua.am133
-rw-r--r--Build/source/texk/web2c/mfluadir/mf-lua.ch538
-rw-r--r--Build/source/texk/web2c/mfluadir/mflua-m.ch12
-rw-r--r--Build/source/texk/web2c/mfluadir/mflua.defines25
-rw-r--r--Build/source/texk/web2c/mfluadir/mflua_version.h1
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluac.c1480
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluac.h38
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluaextra.c11
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluaextra.h23
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/begin_program.lua1
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/do_add_to.lua9
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/end_program.lua1
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/fill_envelope.lua2
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/fill_spec.lua2
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/final_cleanup.lua1
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/main_control.lua2
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/make_ellipse.lua2
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/mfluaini.lua1
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/mfluatrap.diffs203
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/offset_prep.lua2
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/print_edges.lua1
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/print_path.lua1
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/scan_direction.lua2
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/skew_line_edges.lua1
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/start_of_MF.lua1
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluatrap/texmf.cnf38
-rwxr-xr-xBuild/source/texk/web2c/mfluadir/mfluatraptest51
28 files changed, 2587 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/mfluadir/ChangeLog b/Build/source/texk/web2c/mfluadir/ChangeLog
new file mode 100644
index 00000000000..8bb01a97eab
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/ChangeLog
@@ -0,0 +1,5 @@
+2015-04-01 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ Imported MFLua into TeX Live, based on the SVN repository
+ https://foundry.supelec.fr/projects/mflua
+ from Luigi Scarso <luigi.scarso@gmail.com>.
diff --git a/Build/source/texk/web2c/mfluadir/am/mflua.am b/Build/source/texk/web2c/mfluadir/am/mflua.am
new file mode 100644
index 00000000000..e2fea0a36ad
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/am/mflua.am
@@ -0,0 +1,133 @@
+## texk/web2c/mfluadir/am/mflua.am: Makefile fragment for MFLua.
+##
+## Copyright (C) 2015 Peter Breitenlohner <tex-live@tug.org>
+## You may freely use, modify and/or distribute this file.
+
+## MFLua
+##
+if MFLUA
+bin_PROGRAMS += mflua
+if MFLUAN
+bin_PROGRAMS += mflua-nowin
+endif MFLUAN
+if WIN32
+bin_PROGRAMS += inimflua
+else !WIN32
+bin_links += mflua$(EXEEXT):inimflua
+endif !WIN32
+endif MFLUA
+EXTRA_PROGRAMS += mflua mflua-nowin
+DISTCLEANFILES += mfluatrap.diffs
+
+inimflua_CPPFLAGS = -DEXEPROG=\"mflua.exe\"
+nodist_inimflua_SOURCES = callexe.c
+inimflua_LDADD =
+
+dist_mflua_SOURCES = mfluadir/mfluaextra.c mfluadir/mfluaextra.h mfluadir/mflua_version.h
+mflua_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS) $(LUA_INCLUDES)
+mflua_LDADD = libmflua.a $(LDADD) $(windowlib) $(mf_x_libs) $(LUA_LIBS)
+mflua_LDFLAGS = -export-dynamic
+nodist_mflua_nowin_SOURCES = $(dist_mflua_SOURCES)
+mflua_nowin_CPPFLAGS = $(mflua_CPPFLAGS) -DMFNOWIN $(LUA_INCLUDES)
+mflua_nowin_LDADD = libmflua.a $(LDADD) $(windowlib) $(LUA_LIBS)
+mflua_nowin_LDFLAGS = -export-dynamic
+
+# We must create mfluad.h and mfluadir/mflua_version.h before compiling mfluaextra.c.
+$(mflua_OBJECTS) $(mflua_nowin_OBJECTS): mfluad.h mfluadir/mflua_version.h
+
+## mflua and mflua-nowin compile mfluaextra.c with different CPPFLAGS.
+## Automake, however, does not support CPPFLAGS for individual source files.
+## To avoid compiling everything twice, the common objects are in a library.
+EXTRA_LIBRARIES += libmflua.a
+
+# MFLua C sources
+mflua_c_h = mfluaini.c mflua0.c mfluacoerce.h mfluad.h
+dist_libmflua_a_SOURCES = mfluadir/mfluac.c mfluadir/mfluac.h
+nodist_libmflua_a_SOURCES = $(mflua_c_h) mflua-pool.c
+libmflua_a_CPPFLAGS = $(AM_CPPFLAGS) $(LUA_INCLUDES)
+
+# We must create mfluad.h before building the libmflua_a_OBJECTS.
+$(libmflua_a_OBJECTS): mfluad.h
+
+$(mflua_c_h): mflua-web2c $(LUA_LIBS)
+ @$(web2c) mflua
+mflua-web2c: mflua.p $(web2c_texmf) web2c/cvtmf1.sed web2c/cvtmf2.sed mfluadir/mflua.defines
+ @$(web2c) mflua
+
+mflua-pool.c: mflua.pool mfluad.h $(makecpool_stamp)
+ $(makecpool) mflua >$@ || rm -f $@
+
+# Tangling MFLua
+mflua.p mflua.pool: mflua-tangle
+ @$(texmf_tangle) mflua mflua
+mflua-tangle: tangle$(EXEEXT) mflua.web mflua.ch tangle-sh
+ @$(texmf_tangle) mflua mflua
+
+# Extract mflua version
+$(srcdir)/mfluadir/mflua_version.h: @MAINTAINER_MODE_TRUE@ mfluadir/mf-lua.ch
+ $(AM_V_GEN)grep '^@d MFLua_version_string==' $(srcdir)/mfluadir/mf-lua.ch \
+ | sed "s/^.*'-/#define MFLUA_VERSION \"/;s/'.*$$/\"/" >$@
+
+# Generate mflua.web
+mflua.web: tie$(EXEEXT) $(mflua_web_srcs)
+ $(tie) -m mflua.web $(mflua_web_srcs)
+mflua_web_srcs = \
+ mf.web \
+ mfluadir/mf-lua.ch
+
+# Generate mflua.ch
+mflua.ch: tie$(EXEEXT) mflua.web $(mflua_ch_src)
+ $(tie) -c $@ mflua.web $(mflua_ch_src)
+mflua_ch_src = \
+ mf.ch \
+ mfluadir/mflua-m.ch \
+ mf-binpool.ch
+##
+EXTRA_DIST += $(mflua_web_srcs) $(mflua_ch_src) mfluadir/mflua.defines
+
+DISTCLEANFILES += $(nodist_libmflua_a_SOURCES) mflua.web mflua.ch mflua-web2c \
+ mflua.p mflua.pool mflua-tangle
+
+EXTRA_DIST += \
+ mfluadir/ChangeLog
+
+# MFLua tests
+#
+mflua_tests = mfluadir/mfluatraptest
+EXTRA_DIST += $(mflua_tests)
+
+if MFLUA
+TESTS += $(mflua_tests)
+check_PROGRAMS += gftype tftopl
+TRIPTRAP += mfluatrap.diffs
+TRIPTRAP_CLEAN += mfluatrap-clean
+endif MFLUA
+DISTCLEANFILES += mfluatrap.diffs
+
+## mfluadir/mfluatraptest
+mfluatrap.diffs: mflua$(EXEEXT)
+ $(triptrap_diffs) $@
+.PHONY: mfluatrap-clean
+mfluatrap-clean:
+ rm -rf mfluatrapdir
+
+## Test data
+##
+EXTRA_DIST += \
+ mfluadir/mfluatrap/begin_program.lua \
+ mfluadir/mfluatrap/do_add_to.lua \
+ mfluadir/mfluatrap/end_program.lua \
+ mfluadir/mfluatrap/fill_envelope.lua \
+ mfluadir/mfluatrap/fill_spec.lua \
+ mfluadir/mfluatrap/final_cleanup.lua \
+ mfluadir/mfluatrap/main_control.lua \
+ mfluadir/mfluatrap/make_ellipse.lua \
+ mfluadir/mfluatrap/mfluaini.lua \
+ mfluadir/mfluatrap/offset_prep.lua \
+ mfluadir/mfluatrap/print_edges.lua \
+ mfluadir/mfluatrap/print_path.lua \
+ mfluadir/mfluatrap/scan_direction.lua \
+ mfluadir/mfluatrap/skew_line_edges.lua \
+ mfluadir/mfluatrap/start_of_MF.lua \
+ mfluadir/mfluatrap/texmf.cnf \
+ mfluadir/mfluatrap/mfluatrap.diffs
diff --git a/Build/source/texk/web2c/mfluadir/mf-lua.ch b/Build/source/texk/web2c/mfluadir/mf-lua.ch
new file mode 100644
index 00000000000..46f03757e83
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mf-lua.ch
@@ -0,0 +1,538 @@
+@x [0] MFLua
+% This program is copyright (C) 1984 by D. E. Knuth; all rights are reserved.
+@y
+% This program is MFLua, strictly based on the METAFONT 2.7182818 source code.
+% What follow are the original comments of METAFONT 2.7182818.
+
+% This program is copyright (C) 1984 by D. E. Knuth; all rights are reserved.
+@z
+
+@x [0] MFLua
+\def\MF{{\tenlogo META}\-{\tenlogo FONT}}
+@y
+%\def\MF{{\tenlogo META}\-{\tenlogo FONT}}
+\def\MF{{\tenlogo MF}{\mc LUA}}
+@z
+
+@x [1.2] MFLua
+@d banner=='This is METAFONT, Version 2.7182818' {printed when \MF\ starts}
+@y
+@d METAFONT_banner=='This is METAFONT, Version 2.7182818' {printed when \MF\ starts}
+@#
+@d MFLua_version_string=='-0.5'
+@#
+@d MFLua_banner=='This is MFLua, Version 2.7182818', MFLua_version_string
+ {printed when MFLua starts}
+@#
+@d banner==MFLua_banner
+@z
+
+@x [12.186] MFLua - runscript primitive
+At any rate, here is the list, for future reference.
+
+@d if_test=1 {conditional text (\&{if})}
+@d fi_or_else=2 {delimiters for conditionals (\&{elseif}, \&{else}, \&{fi})}
+@d input=3 {input a source file (\&{input}, \&{endinput})}
+@d iteration=4 {iterate (\&{for}, \&{forsuffixes}, \&{forever}, \&{endfor})}
+@d repeat_loop=5 {special command substituted for \&{endfor}}
+@d exit_test=6 {premature exit from a loop (\&{exitif})}
+@d relax=7 {do nothing (\.{\char`\\})}
+@d scan_tokens=8 {put a string into the input buffer}
+@d expand_after=9 {look ahead one token}
+@d defined_macro=10 {a macro defined by the user}
+@d min_command=defined_macro+1
+@d display_command=11 {online graphic output (\&{display})}
+@d save_command=12 {save a list of tokens (\&{save})}
+@d interim_command=13 {save an internal quantity (\&{interim})}
+@d let_command=14 {redefine a symbolic token (\&{let})}
+@d new_internal=15 {define a new internal quantity (\&{newinternal})}
+@d macro_def=16 {define a macro (\&{def}, \&{vardef}, etc.)}
+@d ship_out_command=17 {output a character (\&{shipout})}
+@d add_to_command=18 {add to edges (\&{addto})}
+@d cull_command=19 {cull and normalize edges (\&{cull})}
+@d tfm_command=20 {command for font metric info (\&{ligtable}, etc.)}
+@d protection_command=21 {set protection flag (\&{outer}, \&{inner})}
+@d show_command=22 {diagnostic output (\&{show}, \&{showvariable}, etc.)}
+@d mode_command=23 {set interaction level (\&{batchmode}, etc.)}
+@d random_seed=24 {initialize random number generator (\&{randomseed})}
+@d message_command=25 {communicate to user (\&{message}, \&{errmessage})}
+@d every_job_command=26 {designate a starting token (\&{everyjob})}
+@d delimiters=27 {define a pair of delimiters (\&{delimiters})}
+@d open_window=28 {define a window on the screen (\&{openwindow})}
+@d special_command=29 {output special info (\&{special}, \&{numspecial})}
+@d type_name=30 {declare a type (\&{numeric}, \&{pair}, etc.)}
+@d max_statement_command=type_name
+@d min_primary_command=type_name
+@d left_delimiter=31 {the left delimiter of a matching pair}
+@d begin_group=32 {beginning of a group (\&{begingroup})}
+@d nullary=33 {an operator without arguments (e.g., \&{normaldeviate})}
+@d unary=34 {an operator with one argument (e.g., \&{sqrt})}
+@d str_op=35 {convert a suffix to a string (\&{str})}
+@d cycle=36 {close a cyclic path (\&{cycle})}
+@d primary_binary=37 {binary operation taking `\&{of}' (e.g., \&{point})}
+@d capsule_token=38 {a value that has been put into a token list}
+@d string_token=39 {a string constant (e.g., |"hello"|)}
+@d internal_quantity=40 {internal numeric parameter (e.g., \&{pausing})}
+@d min_suffix_token=internal_quantity
+@d tag_token=41 {a symbolic token without a primitive meaning}
+@d numeric_token=42 {a numeric constant (e.g., \.{3.14159})}
+@d max_suffix_token=numeric_token
+@d plus_or_minus=43 {either `\.+' or `\.-'}
+@d max_primary_command=plus_or_minus {should also be |numeric_token+1|}
+@d min_tertiary_command=plus_or_minus
+@d tertiary_secondary_macro=44 {a macro defined by \&{secondarydef}}
+@d tertiary_binary=45 {an operator at the tertiary level (e.g., `\.{++}')}
+@d max_tertiary_command=tertiary_binary
+@d left_brace=46 {the operator `\.{\char`\{}'}
+@d min_expression_command=left_brace
+@d path_join=47 {the operator `\.{..}'}
+@d ampersand=48 {the operator `\.\&'}
+@d expression_tertiary_macro=49 {a macro defined by \&{tertiarydef}}
+@d expression_binary=50 {an operator at the expression level (e.g., `\.<')}
+@d equals=51 {the operator `\.='}
+@d max_expression_command=equals
+@d and_command=52 {the operator `\&{and}'}
+@d min_secondary_command=and_command
+@d secondary_primary_macro=53 {a macro defined by \&{primarydef}}
+@d slash=54 {the operator `\./'}
+@d secondary_binary=55 {an operator at the binary level (e.g., \&{shifted})}
+@d max_secondary_command=secondary_binary
+@d param_type=56 {type of parameter (\&{primary}, \&{expr}, \&{suffix}, etc.)}
+@d controls=57 {specify control points explicitly (\&{controls})}
+@d tension=58 {specify tension between knots (\&{tension})}
+@d at_least=59 {bounded tension value (\&{atleast})}
+@d curl_command=60 {specify curl at an end knot (\&{curl})}
+@d macro_special=61 {special macro operators (\&{quote}, \.{\#\AT!}, etc.)}
+@d right_delimiter=62 {the right delimiter of a matching pair}
+@d left_bracket=63 {the operator `\.['}
+@d right_bracket=64 {the operator `\.]'}
+@d right_brace=65 {the operator `\.{\char`\}}'}
+@d with_option=66 {option for filling (\&{withpen}, \&{withweight})}
+@d cull_op=67 {the operator `\&{keeping}' or `\&{dropping}'}
+@d thing_to_add=68
+ {variant of \&{addto} (\&{contour}, \&{doublepath}, \&{also})}
+@d of_token=69 {the operator `\&{of}'}
+@d from_token=70 {the operator `\&{from}'}
+@d to_token=71 {the operator `\&{to}'}
+@d at_token=72 {the operator `\&{at}'}
+@d in_window=73 {the operator `\&{inwindow}'}
+@d step_token=74 {the operator `\&{step}'}
+@d until_token=75 {the operator `\&{until}'}
+@d lig_kern_token=76
+ {the operators `\&{kern}' and `\.{=:}' and `\.{=:\char'174}', etc.}
+@d assignment=77 {the operator `\.{:=}'}
+@d skip_to=78 {the operation `\&{skipto}'}
+@d bchar_label=79 {the operator `\.{\char'174\char'174:}'}
+@d double_colon=80 {the operator `\.{::}'}
+@d colon=81 {the operator `\.:'}
+@#
+@d comma=82 {the operator `\.,', must be |colon+1|}
+@d end_of_statement==cur_cmd>comma
+@d semicolon=83 {the operator `\.;', must be |comma+1|}
+@d end_group=84 {end a group (\&{endgroup}), must be |semicolon+1|}
+@d stop=85 {end a job (\&{end}, \&{dump}), must be |end_group+1|}
+@d max_command_code=stop
+@d outer_tag=max_command_code+1 {protection code added to command code}
+@y
+At any rate, here is the list, for future reference.
+
+@d delta_code=1 {n. of new primitives added }
+@d if_test=1 {conditional text (\&{if})}
+@d fi_or_else=2 {delimiters for conditionals (\&{elseif}, \&{else}, \&{fi})}
+@d input=3 {input a source file (\&{input}, \&{endinput})}
+@d iteration=4 {iterate (\&{for}, \&{forsuffixes}, \&{forever}, \&{endfor})}
+@d repeat_loop=5 {special command substituted for \&{endfor}}
+@d exit_test=6 {premature exit from a loop (\&{exitif})}
+@d relax=7 {do nothing (\.{\char`\\})}
+@d scan_tokens=8 {put a string into the input buffer}
+@d run_script=8+delta_code {execute a Lua script}
+@d expand_after=9+delta_code {look ahead one token}
+@d defined_macro=10+delta_code {a macro defined by the user}
+@d min_command=defined_macro+1
+@d display_command=11+delta_code {online graphic output (\&{display})}
+@d save_command=12+delta_code {save a list of tokens (\&{save})}
+@d interim_command=13+delta_code {save an internal quantity (\&{interim})}
+@d let_command=14+delta_code {redefine a symbolic token (\&{let})}
+@d new_internal=15+delta_code {define a new internal quantity (\&{newinternal})}
+@d macro_def=16+delta_code {define a macro (\&{def}, \&{vardef}, etc.)}
+@d ship_out_command=17+delta_code {output a character (\&{shipout})}
+@d add_to_command=18+delta_code {add to edges (\&{addto})}
+@d cull_command=19+delta_code {cull and normalize edges (\&{cull})}
+@d tfm_command=20+delta_code {command for font metric info (\&{ligtable}, etc.)}
+@d protection_command=21+delta_code {set protection flag (\&{outer}, \&{inner})}
+@d show_command=22+delta_code {diagnostic output (\&{show}, \&{showvariable}, etc.)}
+@d mode_command=23+delta_code {set interaction level (\&{batchmode}, etc.)}
+@d random_seed=24+delta_code {initialize random number generator (\&{randomseed})}
+@d message_command=25+delta_code {communicate to user (\&{message}, \&{errmessage})}
+@d every_job_command=26+delta_code {designate a starting token (\&{everyjob})}
+@d delimiters=27+delta_code {define a pair of delimiters (\&{delimiters})}
+@d open_window=28+delta_code {define a window on the screen (\&{openwindow})}
+@d special_command=29+delta_code {output special info (\&{special}, \&{numspecial})}
+@d type_name=30+delta_code {declare a type (\&{numeric}, \&{pair}, etc.)}
+@d max_statement_command=type_name
+@d min_primary_command=type_name
+@d left_delimiter=31+delta_code {the left delimiter of a matching pair}
+@d begin_group=32+delta_code {beginning of a group (\&{begingroup})}
+@d nullary=33+delta_code {an operator without arguments (e.g., \&{normaldeviate})}
+@d unary=34+delta_code {an operator with one argument (e.g., \&{sqrt})}
+@d str_op=35+delta_code {convert a suffix to a string (\&{str})}
+@d cycle=36+delta_code {close a cyclic path (\&{cycle})}
+@d primary_binary=37+delta_code {binary operation taking `\&{of}' (e.g., \&{point})}
+@d capsule_token=38+delta_code {a value that has been put into a token list}
+@d string_token=39+delta_code {a string constant (e.g., |"hello"|)}
+@d internal_quantity=40+delta_code {internal numeric parameter (e.g., \&{pausing})}
+@d min_suffix_token=internal_quantity
+@d tag_token=41+delta_code {a symbolic token without a primitive meaning}
+@d numeric_token=42+delta_code {a numeric constant (e.g., \.{3.14159})}
+@d max_suffix_token=numeric_token
+@d plus_or_minus=43+delta_code {either `\.+' or `\.-'}
+@d max_primary_command=plus_or_minus {should also be |numeric_token+1|}
+@d min_tertiary_command=plus_or_minus
+@d tertiary_secondary_macro=44+delta_code {a macro defined by \&{secondarydef}}
+@d tertiary_binary=45+delta_code {an operator at the tertiary level (e.g., `\.{++}')}
+@d max_tertiary_command=tertiary_binary
+@d left_brace=46+delta_code {the operator `\.{\char`\{}'}
+@d min_expression_command=left_brace
+@d path_join=47+delta_code {the operator `\.{..}'}
+@d ampersand=48+delta_code {the operator `\.\&'}
+@d expression_tertiary_macro=49+delta_code {a macro defined by \&{tertiarydef}}
+@d expression_binary=50+delta_code {an operator at the expression level (e.g., `\.<')}
+@d equals=51+delta_code {the operator `\.='}
+@d max_expression_command=equals
+@d and_command=52+delta_code {the operator `\&{and}'}
+@d min_secondary_command=and_command
+@d secondary_primary_macro=53+delta_code {a macro defined by \&{primarydef}}
+@d slash=54+delta_code {the operator `\./'}
+@d secondary_binary=55+delta_code {an operator at the binary level (e.g., \&{shifted})}
+@d max_secondary_command=secondary_binary
+@d param_type=56+delta_code {type of parameter (\&{primary}, \&{expr}, \&{suffix}, etc.)}
+@d controls=57+delta_code {specify control points explicitly (\&{controls})}
+@d tension=58+delta_code {specify tension between knots (\&{tension})}
+@d at_least=59+delta_code {bounded tension value (\&{atleast})}
+@d curl_command=60+delta_code {specify curl at an end knot (\&{curl})}
+@d macro_special=61+delta_code {special macro operators (\&{quote}, \.{\#\AT!}, etc.)}
+@d right_delimiter=62+delta_code {the right delimiter of a matching pair}
+@d left_bracket=63+delta_code {the operator `\.['}
+@d right_bracket=64+delta_code {the operator `\.]'}
+@d right_brace=65+delta_code {the operator `\.{\char`\}}'}
+@d with_option=66+delta_code {option for filling (\&{withpen}, \&{withweight})}
+@d cull_op=67+delta_code {the operator `\&{keeping}' or `\&{dropping}'}
+@d thing_to_add=68+delta_code
+ {variant of \&{addto} (\&{contour}, \&{doublepath}, \&{also})}
+@d of_token=69+delta_code {the operator `\&{of}'}
+@d from_token=70+delta_code {the operator `\&{from}'}
+@d to_token=71+delta_code {the operator `\&{to}'}
+@d at_token=72+delta_code {the operator `\&{at}'}
+@d in_window=73+delta_code {the operator `\&{inwindow}'}
+@d step_token=74+delta_code {the operator `\&{step}'}
+@d until_token=75+delta_code {the operator `\&{until}'}
+@d lig_kern_token=76+delta_code
+ {the operators `\&{kern}' and `\.{=:}' and `\.{=:\char'174}', etc.}
+@d assignment=77+delta_code {the operator `\.{:=}'}
+@d skip_to=78+delta_code {the operation `\&{skipto}'}
+@d bchar_label=79+delta_code {the operator `\.{\char'174\char'174:}'}
+@d double_colon=80+delta_code {the operator `\.{::}'}
+@d colon=81+delta_code {the operator `\.:'}
+@#
+@d comma=82+delta_code {the operator `\.,', must be |colon+1|}
+@d end_of_statement==cur_cmd>comma
+@d semicolon=83+delta_code {the operator `\.;', must be |comma+1|}
+@d end_group=84+delta_code {end a group (\&{endgroup}), must be |semicolon+1|}
+@d stop=85+delta_code {end a job (\&{end}, \&{dump}), must be |end_group+1|}
+@d max_command_code=stop
+@d outer_tag=max_command_code+1 {protection code added to command code}
+@z
+
+@x [13.211] MFLua - runscript primitive
+primitive("randomseed",random_seed,0);@/
+@!@:random_seed_}{\&{randomseed} primitive@>
+@y
+primitive("randomseed",random_seed,0);@/
+@!@:random_seed_}{\&{randomseed} primitive@>
+primitive("runscript",run_script,0);@/
+@!@:run_script_}{\&{runscript} primitive@>
+@z
+
+@x [13.212] MFLua - runscript primitive
+right_bracket:print("]");
+@y
+right_bracket:print("]");
+run_script:print("runscript");
+@z
+
+@x [17.257] MFLua
+begin print_diagnostic("Path",s,nuline); print_ln;
+@y
+begin
+mflua_printpath(h,s,nuline);
+print_diagnostic("Path",s,nuline); print_ln;
+@z
+
+@x [20.332] MFLua
+begin print_diagnostic("Edge structure",s,nuline);
+@y
+begin
+{mflua\_printedges(s,nuline,x\_off,y\_off);}
+print_diagnostic("Edge structure",s,nuline);
+@z
+
+@x [22.465] MFLua
+ move_to_edges(m0,n0,m1,n1);
+@y
+ mflua_PRE_move_to_edges(p);
+ move_to_edges(m0,n0,m1,n1);
+ mflua_POST_move_to_edges(p);
+@z
+
+@x [24.491] MFLua
+begin p:=c; n:=info(h); lh:=link(h); {now |lh| points to $w_0$}
+@y
+begin
+{mflua\_offsetprep(c,h);}
+p:=c; n:=info(h); lh:=link(h); {now |lh| points to $w_0$}
+@z
+
+@x [24.506] MFLua
+offset_prep(p,h); {this may clobber node~|q|, if it becomes ``dead''}
+@y
+mfluaPRE_offset_prep(p,h);
+offset_prep(p,h); {this may clobber node~|q|, if it becomes ``dead''}
+mfluaPOST_offset_prep(p,h);
+@z
+
+@x [24.519] MFLua
+ unskew(x1,y1,octant);@/
+@y
+ unskew(x1,y1,octant);@/
+ mflua_print_retrograde_line(x0,y0,cur_x,cur_y);
+@z
+
+@x [24.515] MFLua
+begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
+@y
+begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
+mflua_print_transition_line_from(xx,yy-half_unit);
+@z
+
+@x [24.515] MFLua
+else begin decr(k); w:=knil(w);
+ xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
+ end;
+@y
+else begin decr(k); w:=knil(w);
+ xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
+ end;
+mflua_print_transition_line_to(xp,yp-half_unit);
+@z
+
+@x [24.521] MFLua
+@<Insert a line segment dually to approach the correct offset@>=
+begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
+@y
+@<Insert a line segment dually to approach the correct offset@>=
+begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
+mflua_print_transition_line_from(xx,yy-half_unit);
+@z
+
+@x [24.521] MFLua
+else begin incr(k); w:=link(w);
+ xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
+ end;
+@y
+else begin incr(k); w:=link(w);
+ xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
+ end;
+mflua_print_transition_line_to(xp,yp-half_unit);
+@z
+
+@x [31.630] MFLua - runscript primitive
+moved into the buffer by \&{scantokens}.
+@y
+moved into the buffer by \&{scantokens} or \&{runscript}.
+@z
+
+@x [31.637] MFLua - runscript primitive
+else if name=2 then print_nl("<scantokens>")
+@y
+else if name=2 then print_nl("<scantokens> or <runscript>")
+@z
+
+@x [33.679] MFLua - runscript primitive
+ {text was inserted during error recovery or by \&{scantokens}}
+@y
+ {text was inserted during error recovery or by \&{scantokens} or \&{runscript}}
+@z
+
+@x [35.706] MFLua - runscript primitive
+|exit_test|, |relax|, |scan_tokens|, |expand_after|, and |defined_macro|.
+@y
+|exit_test|, |relax|, |scan_tokens|, |run_script|, |expand_after|, and |defined_macro|.
+@z
+
+@x [35.707] MFLua - runscript primitive
+scan_tokens: @<Put a string into the input buffer@>;
+@y
+scan_tokens: @<Put a string into the input buffer@>;
+run_script: @<Pass a string to the Lua interpreter and put the result string into the input buffer@>;
+@z
+
+@x [39.796] MFLua - runscript primitive
+@!cur_exp:integer; {the value of the expression just found}
+@y
+@!cur_exp:integer; {the value of the expression just found}
+@!lua_cur_exp:integer; {the value of the Lua expression returned by runscript}
+@z
+
+@x [41.866] MFLua
+q:=make_ellipse(major_axis,minor_axis,theta);
+if (tx<>0)or(ty<>0) then @<Shift the coordinates of path |q|@>;
+@y
+mfluaPRE_make_ellipse(major_axis,minor_axis,theta,tx,ty,0);
+q:=make_ellipse(major_axis,minor_axis,theta);
+if (tx<>0)or(ty<>0) then @<Shift the coordinates of path |q|@>;
+mfluaPOST_make_ellipse(major_axis,minor_axis,theta,tx,ty,q);
+@z
+
+@x [41.891] MFLua
+make_choices(p);
+@y
+mfluaPRE_make_choices(p);
+make_choices(p);
+mfluaPOST_make_choices(p);
+@z
+
+@x [44.1064] MFLua
+ if max_offset(cur_pen)=0 then fill_spec(rhs)
+ else fill_envelope(rhs);
+ if lhs<>null then
+ begin rev_turns:=true;
+ lhs:=make_spec(lhs,max_offset(cur_pen),internal[tracing_specs]);
+ rev_turns:=false;
+ if max_offset(cur_pen)=0 then fill_spec(lhs)
+ else fill_envelope(lhs);
+@y
+ if max_offset(cur_pen)=0 then begin mfluaPRE_fill_spec_rhs(rhs); fill_spec(rhs); mfluaPOST_fill_spec_rhs(rhs);end
+ else begin mfluaPRE_fill_envelope_rhs(rhs); fill_envelope(rhs); mfluaPOST_fill_envelope_rhs(rhs); end ;
+ if lhs<>null then
+ begin rev_turns:=true;
+ lhs:=make_spec(lhs,max_offset(cur_pen),internal[tracing_specs]);
+ rev_turns:=false;
+ if max_offset(cur_pen)=0 then begin mfluaPRE_fill_spec_lhs(lhs); fill_spec(lhs); mfluaPOST_fill_spec_lhs(lhs); end
+ else begin mfluaPRE_fill_envelope_lhs(lhs); fill_envelope(lhs); mfluaPOST_fill_envelope_lhs(lhs); end;
+@z
+
+@x [47.1165] MFLua
+print_char("]"); update_terminal; {progress report}
+@y
+print_char("]"); update_terminal; {progress report}
+mflua_printedges(" (just shipped out)",true,x_off,y_off);
+@z
+
+@x [49.1204] MFLua
+@p begin @!{|start_here|}
+@y
+@p begin @!{|start_here|}
+mflua_begin_program;
+@z
+
+@x [49.1204] MFLua
+start_of_MF: @<Initialize the output routines@>;
+@<Get the first line of input and prepare to start@>;
+history:=spotless; {ready to go!}
+if start_sym>0 then {insert the `\&{everyjob}' symbol}
+ begin cur_sym:=start_sym; back_input;
+ end;
+main_control; {come to life}
+final_cleanup; {prepare for death}
+@y
+mfluaPRE_start_of_MF;
+start_of_MF: @<Initialize the output routines@>;
+@<Get the first line of input and prepare to start@>;
+history:=spotless; {ready to go!}
+{This was the first sensor. Original comment: "remember to modify web2c/texmf.defines by adding mfuainitialize and then texmfmp.h and lib/texmfmp.c". Now obsolete}
+mflua_initialize;
+if start_sym>0 then {insert the `\&{everyjob}' symbol}
+ begin cur_sym:=start_sym; back_input;
+ end;
+mfluaPRE_main_control;
+main_control; {come to life}
+mfluaPOST_main_control;
+final_cleanup; {prepare for death}
+mfluaPOST_final_cleanup;
+@z
+
+@x [49.1205] MFLua
+ end;
+end;
+@y
+ end;
+mflua_end_program;
+end;
+@z
+
+@x [51.1214] MFLua - additional sections to handle runscript
+@* \[51] System-dependent changes.
+@y
+@ @<Pass a string to the Lua interpreter and put the result string into the input buffer@>=
+begin get_x_next; scan_primary;
+if cur_type<>string_type then
+ begin disp_err(null,"Not a string");
+@.Not a string@>
+ help2("I'm going to flush this expression, since")@/
+ ("runscript should be followed by a known string.");
+ put_get_flush_error(0);
+ end
+else begin back_input;
+ if length(cur_exp)>0 then @<As for scantokens, pretend we're reading a new one-line file@>;
+ end;
+end
+
+@ @<As for scantokens, pretend we're reading a new one-line file@>=
+begin {begin\_file\_reading;} name:=2; {should be name:=3 but for the moment we keep 2}
+k:=first+length(cur_exp);
+{print(" k=");print\_int(k);print\_ln;}
+{print(" first=");print\_int(first);print\_ln;}
+{print(" length(cur\_exp)=");print\_int(length(cur\_exp));print\_ln;}
+{ Will be removed as soon as we have tested that it's ok}
+{if k>=max\_buf\_stack then}
+{ begin if k>=buf\_size then}
+{ begin max\_buf\_stack:=buf\_size;}
+{ overflow("buffer size",buf\_size);}
+{ end;}
+{ max\_buf\_stack:=k+1;}
+{ end;}
+j:=str_start[cur_exp]; limit:=k;
+mflua_runscript(j,first,limit);
+lua_cur_exp:=make_string;
+if length(lua_cur_exp)> 0 then
+begin
+ begin_file_reading;
+ add_str_ref(lua_cur_exp);
+ j:=str_start[lua_cur_exp]; k:=first+length(lua_cur_exp);limit:=k;
+{ Will be removed as soon as we have tested that it's ok}
+{print("=============BEGIN TEST===============");print\_ln;}
+{print(" k=");print\_int(k);print\_ln;}
+{print(" first=");print\_int(first);print\_ln;}
+{print(" limit=");print\_int(limit);print\_ln;}
+{print(" length(lua\_cur\_exp)=");print\_int(length(lua\_cur\_exp));print\_ln;}
+ if k>=max_buf_stack then
+ begin if k>=buf_size then
+ begin max_buf_stack:=buf_size;
+ overflow("buffer size",buf_size);
+@:METAFONT capacity exceeded buffer size}{\quad buffer size@>
+ end;
+ max_buf_stack:=k+1;
+ end;
+ while first<limit do
+ begin
+ {print(" loop");print\_ln;}
+ buffer[first]:=so(str_pool[j]); {print(so(str\_pool[j]));} incr(j); incr(first);
+ end;
+ buffer[limit]:="%"; first:=limit+1; loc:=start;
+ {print("=============END TEST=================");print\_ln;}
+ delete_str_ref(lua_cur_exp);
+end;
+flush_cur_exp(0);
+end
+@* \[51] System-dependent changes.
+@z \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mflua-m.ch b/Build/source/texk/web2c/mfluadir/mflua-m.ch
new file mode 100644
index 00000000000..c915d72e12b
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mflua-m.ch
@@ -0,0 +1,12 @@
+@x [1.11]
+@!max_strings=7500; {maximum number of strings; must not exceed |max_halfword|}
+@y
+@!max_strings=75000; {maximum number of strings; must not exceed |max_halfword|}
+@z
+
+@x [1.11]
+@!pool_size=100000; {maximum number of characters in strings, including all
+@y
+@!pool_size=1000000; {maximum number of characters in strings, including all
+@z
+
diff --git a/Build/source/texk/web2c/mfluadir/mflua.defines b/Build/source/texk/web2c/mfluadir/mflua.defines
new file mode 100644
index 00000000000..383f1def95b
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mflua.defines
@@ -0,0 +1,25 @@
+{ Additional symbols for MFLua. Public domain.}
+
+@define procedure mfluainitialize;
+@define procedure mfluaprintpath();
+@define procedure mfluaprintedges();
+@define procedure mfluaPREoffsetprep();
+@define procedure mfluaPOSToffsetprep();
+@define procedure mfluaPREfillenveloperhs();
+@define procedure mfluaPOSTfillenveloperhs();
+@define procedure mfluaPREfillenvelopelhs();
+@define procedure mfluaPOSTfillenvelopelhs();
+@define procedure mfluaPREfillspecrhs();
+@define procedure mfluaPOSTfillspecrhs();
+@define procedure mfluaPREfillspeclhs();
+@define procedure mfluaPOSTfillspeclhs();
+@define procedure mfluaPREmovetoedges();
+@define procedure mfluaPOSTmovetoedges();
+@define procedure mfluaPREmakechoices();
+@define procedure mfluaPOSTmakechoices();
+@define procedure mfluaprintretrogradeline();
+@define procedure mfluaprinttransitionlinefrom();
+@define procedure mfluaprinttransitionlineto();
+@define procedure mfluaPREmakeellipse();
+@define procedure mfluaPOSTmakeellipse();
+@define procedure mfluarunscript();
diff --git a/Build/source/texk/web2c/mfluadir/mflua_version.h b/Build/source/texk/web2c/mfluadir/mflua_version.h
new file mode 100644
index 00000000000..9b0b575ceab
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mflua_version.h
@@ -0,0 +1 @@
+#define MFLUA_VERSION "0.5"
diff --git a/Build/source/texk/web2c/mfluadir/mfluac.c b/Build/source/texk/web2c/mfluadir/mfluac.c
new file mode 100644
index 00000000000..5c1ddd5f66a
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluac.c
@@ -0,0 +1,1480 @@
+#define EXTERN extern
+
+#if defined(JIT)
+#include "mfluajitd.h"
+#else
+#include "mfluad.h"
+#endif
+
+#include <lua.h>
+#include <lualib.h>
+#include <lauxlib.h>
+
+/**************************************************************/
+/* */
+/* private functions */
+/* */
+/**************************************************************/
+static lua_State *Luas[1];
+
+static void priv_lua_reporterrors(lua_State *L, int status)
+{
+ if ( status!=0 ) {
+ fprintf(stderr,"\n! %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* remove error message */
+ }
+}
+
+#define link_field(p) mem[p].hhfield.rh /* {the |link| field of a memory word} */
+static int priv_mfweb_link(lua_State *L)
+{
+ halfword p,q;
+ p = (halfword) lua_tonumber(L,1);
+ q = link_field(p);
+ lua_pushnumber(L,q);
+ return 1;
+}
+
+#define info_field(p) mem[p].hhfield.lhfield /* {the |info| field of a memory word} */
+static int priv_mfweb_info(lua_State *L)
+{
+ halfword p,q;
+ p = (halfword) lua_tonumber(L,1);
+ q = info_field(p);
+ lua_pushnumber(L,q);
+ return 1;
+}
+
+
+#define x_coord(p) mem[p+1].cint /* {the |x| coordinate of this knot} */
+static int priv_mfweb_x_coord(lua_State *L)
+{
+ halfword p;
+ int q;
+ p = (halfword) lua_tonumber(L,1);
+ q = x_coord(p);
+ lua_pushnumber(L,q);
+ return 1;
+}
+
+#define y_coord(p) mem[p+2].cint /* {the |y| coordinate of this knot} */
+static int priv_mfweb_y_coord(lua_State *L)
+{
+ halfword p,q;
+ p = (halfword) lua_tonumber(L,1);
+ q = y_coord(p);
+ lua_pushnumber(L,q);
+ return 1;
+}
+
+
+#define left_type(p) mem[p].hhfield.b0 /* {characterizes the path entering this knot} */
+static int priv_mfweb_left_type(lua_State *L)
+{
+ halfword p,q;
+ p = (halfword) lua_tonumber(L,1);
+ q = left_type(p);
+ lua_pushnumber(L,q);
+ return 1;
+}
+
+#define right_type(p) mem[p].hhfield.b1 /* {characterizes the path leaving this knot} */
+static int priv_mfweb_right_type(lua_State *L)
+{
+ halfword p,q;
+ p = (halfword) lua_tonumber(L,1);
+ q = right_type(p);
+ lua_pushnumber(L,q);
+ return 1;
+}
+
+
+#define left_x(p) mem[p+3].cint /* {the |x| coordinate of previous control point} */
+static int priv_mfweb_left_x(lua_State *L)
+{
+ halfword p;
+ integer q ;
+ p = (halfword) lua_tonumber(L,1);
+ q = left_x(p);
+ lua_pushnumber(L,q);
+ return 1;
+}
+
+
+#define left_y(p) mem[p+4].cint /* {the |y| coordinate of previous control point} */
+static int priv_mfweb_left_y(lua_State *L)
+{
+ halfword p;
+ integer q ;
+ p = (halfword) lua_tonumber(L,1);
+ q = left_y(p);
+ lua_pushnumber(L,q);
+ return 1;
+}
+
+
+#define right_x(p) mem[p+5].cint /* {the |x| coordinate of next control point} */
+static int priv_mfweb_right_x(lua_State *L)
+{
+ halfword p;
+ integer q ;
+ p = (halfword) lua_tonumber(L,1);
+ q = right_x(p);
+ lua_pushnumber(L,q);
+ return 1;
+}
+
+#define right_y(p) mem[p+6].cint /* {the |y| coordinate of next control point} */
+static int priv_mfweb_right_y(lua_State *L)
+{
+ halfword p;
+ integer q;
+ p = (halfword) lua_tonumber(L,1);
+ q = right_y(p);
+ lua_pushnumber(L,q);
+ return 1;
+}
+
+/* @ Conversely, the |n_sin_cos| routine takes an |angle| and produces the sine */
+/* and cosine of that angle. The results of this routine are */
+/* stored in global integer variables |n_sin| and |n_cos|. */
+
+/* @<Glob...@>= */
+/* @!n_sin,@!n_cos:fraction; {results computed by |n_sin_cos|} */
+
+/* @ Given an integer |z| that is $2^{20}$ times an angle $\theta$ in degrees, */
+/* the purpose of |n_sin_cos(z)| is to set */
+/* |x=@t$r\cos\theta$@>| and |y=@t$r\sin\theta$@>| (approximately), */
+/* for some rather large number~|r|. The maximum of |x| and |y| */
+/* will be between $2^{28}$ and $2^{30}$, so that there will be hardly */
+/* any loss of accuracy. Then |x| and~|y| are divided by~|r|. */
+static int priv_mfweb_n_sin_cos(lua_State *L)
+{
+ nsincos(lua_tonumber(L,1));
+ return 0;
+}
+
+
+/* @ When a lot of work is being done on a particular edge structure, we plant */
+/* a pointer to its main header in the global variable |cur_edges|. */
+/* This saves us from having to pass this pointer as a parameter over and */
+/* over again between subroutines. */
+
+/* Similarly, |cur_wt| is a global weight that is being used by several */
+/* procedures at once. */
+
+/* @<Glob...@>= */
+/* @!cur_edges:pointer; {the edge structure of current interest} */
+/* @!cur_wt:integer; {the edge weight of current interest} */
+static int priv_mfweb_LUAGLOBALGET_cur_edges(lua_State *L)
+{
+ halfword p = curedges;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+
+/* @<Glob...@>= */
+/* @!cur_type:small_number; {the type of the expression just found} */
+/* @!cur_exp:integer; {the value of the expression just found} */
+static int priv_mfweb_LUAGLOBALGET_cur_exp(lua_State *L)
+{
+ halfword p = curexp;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+
+
+
+
+
+/* @d mem_top==30000 {largest index in the |mem| array dumped by \.{INIMF}; */
+/* must be substantially larger than |mem_min| */
+/* and not greater than |mem_max|} */
+static int priv_mfweb_LUAGLOBALGET_mem_top(lua_State *L)
+{
+ integer p = memtop;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+
+
+/* And there are two global variables that affect the rounding */
+/* decisions, as we'll see later; they are called |cur_pen| and |cur_path_type|. */
+/* The latter will be |double_path_code| if |make_spec| is being */
+/* applied to a double path.*/
+/* @!cur_pen:pointer; {an implicit input of |make_spec|, used in autorounding} */
+static int priv_mfweb_LUAGLOBALGET_cur_pen(lua_State *L)
+{
+ halfword p = curpen;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+
+/* @ The current octant code appears in a global variable. If, for example, */
+/* we have |octant=third_octant|, it means that a curve traveling in a north to */
+/* north-westerly direction has been rotated for the purposes of internal */
+/* calculations so that the |move| data travels in an east to north-easterly */
+/* direction. We want to unrotate as we update the edge structure. */
+/* */
+/* @<Glob...@>= */
+/* @!octant:first_octant..sixth_octant; {the current octant of interest} */
+static int priv_mfweb_LUAGLOBALGET_octant(lua_State *L)
+{
+ char p = octant;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+
+
+
+
+/* @ \MF\ also has a bunch of internal parameters that a user might want to */
+/* fuss with. Every such parameter has an identifying code number, defined here. */
+/* Warning: these parameters must be the same of the original MF !! */
+#define tracing_titles 1 /*show titles online when they appear} */
+#define tracing_equations 2 /*show each variable when it becomes known} */
+#define tracing_capsules 3 /*show capsules too} */
+#define tracing_choices 4 /*show the control points chosen for paths} */
+#define tracing_specs 5 /*show subdivision of paths into octants before digitizing} */
+#define tracing_pens 6 /*show details of pens that are made} */
+#define tracing_commands 7 /*show commands and operations before they are performed} */
+#define tracing_restores 8 /*show when a variable or internal is restored} */
+#define tracing_macros 9 /*show macros before they are expanded} */
+#define tracing_edges 10 /*show digitized edges as they are computed} */
+#define tracing_output 11 /*show digitized edges as they are output} */
+#define tracing_stats 12 /*show memory usage at end of job} */
+#define tracing_online 13 /*show long diagnostics on terminal and in the log file} */
+#define year 14 /*the current year (e.g., 1984)} */
+#define month 15 /*the current month (e.g., 3 $\equiv$ March)} */
+#define day 16 /*the current day of the month} */
+#define time 17 /*the number of minutes past midnight when this job started} */
+#define char_code 18 /*the number of the next character to be output} */
+#define char_ext 19 /*the extension code of the next character to be output} */
+#define char_wd 20 /*the width of the next character to be output} */
+#define char_ht 21 /*the height of the next character to be output} */
+#define char_dp 22 /*the depth of the next character to be output} */
+#define char_ic 23 /*the italic correction of the next character to be output} */
+#define char_dx 24 /*the device's $x$ movement for the next character, in pixels} */
+#define char_dy 25 /*the device's $y$ movement for the next character, in pixels} */
+#define design_size 26 /*the unit of measure used for |char_wd..char_ic|, in points} */
+#define hppp 27 /*the number of horizontal pixels per point} */
+#define vppp 28 /*the number of vertical pixels per point} */
+#define x_offset 29 /*horizontal displacement of shipped-out characters} */
+#define y_offset 30 /*vertical displacement of shipped-out characters} */
+#define pausing 31 /*positive to display lines on the terminal before they are read} */
+#define showstopping 32 /*positive to stop after each \&{show} command} */
+#define fontmaking 33 /*positive if font metric output is to be produced} */
+#define proofing 34 /*positive for proof mode, negative to suppress output} */
+#define smoothing 35 /*positive if moves are to be ``smoothed''} */
+#define autorounding 36 /*controls path modification to ``good'' points} */
+#define granularity 37 /*autorounding uses this pixel size} */
+#define fillin 38 /*extra darkness of diagonal lines} */
+#define turning_check 39 /*controls reorientation of clockwise paths} */
+#define warning_check 40 /*controls error message when variable value is large} */
+#define boundary_char 41 /*the right boundary character for ligatures} */
+/* @d max_given_internal=41 */
+
+static int priv_mfweb_LUAGLOBALGET_char_code(lua_State *L)
+{
+ integer p = roundunscaled ( internal [char_code]) % 256 ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+static int priv_mfweb_LUAGLOBALGET_char_ext(lua_State *L)
+{
+ integer p = roundunscaled ( internal [char_ext]) ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+
+static int priv_mfweb_LUAGLOBALGET_char_wd(lua_State *L)
+{
+ integer p = internal [char_wd] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+static int priv_mfweb_LUAGLOBALGET_char_ht(lua_State *L)
+{
+ integer p = internal [char_ht] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+static int priv_mfweb_LUAGLOBALGET_char_dp(lua_State *L)
+{
+ integer p = internal [char_dp] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+static int priv_mfweb_LUAGLOBALGET_char_ic(lua_State *L)
+{
+ integer p = internal [char_ic] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_char_dx(lua_State *L)
+{
+ integer p = internal [char_dx] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_char_dy(lua_State *L)
+{
+ integer p = internal [char_dy] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_designsize(lua_State *L)
+{
+ integer p = internal [design_size] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_hppp(lua_State *L)
+{
+ integer p = internal [hppp] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_vppp(lua_State *L)
+{
+ integer p = internal [vppp] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_x_offset(lua_State *L)
+{
+ integer p = internal [x_offset] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_y_offset(lua_State *L)
+{
+ integer p = internal [y_offset] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_granularity(lua_State *L)
+{
+ integer p = internal [granularity] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_fillin(lua_State *L)
+{
+ integer p = internal [fillin] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_turning_check(lua_State *L)
+{
+ integer p = internal [turning_check] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+static int priv_mfweb_LUAGLOBALGET_boundary_char(lua_State *L)
+{
+ integer p = internal [boundary_char] ;
+ lua_pushnumber(L,p);
+ return 1;
+}
+
+
+
+
+
+
+/**************************************************************/
+/* */
+/* mflua layer */
+/* */
+/**************************************************************/
+int mfluabeginprogram(void)
+{
+ lua_State *L = luaL_newstate();
+ const char* luafile = "begin_program.lua";
+ int res ;
+ luaL_openlibs(L);
+ Luas[0] = L;
+ /* execute Lua external "begin_program.lua" */
+ res = luaL_loadfile(L, luafile);
+ if ( res==0 ) {
+ res = lua_pcall(L, 0, 0, 0);
+ }
+ /* stackdump_g(L); */
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+int mfluaendprogram(void)
+{
+ lua_State *L = Luas[0];
+ /* execute Lua external "end_program.lua" */
+ const char* file = "end_program.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ) {
+ res = lua_pcall(L, 0, 0, 0);
+ }
+ /* stackdump_g(L); */
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+int mfluaPREstartofMF(void)
+{
+ lua_State *L = Luas[0];
+ const char* file = "start_of_MF.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "PRE_start_of_MF"); /* function to be called */
+ /* do the call (0 arguments, 1 result) */
+ res = lua_pcall(L, 0, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_start_of_MF number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /* stackdump_g(L); */
+ priv_lua_reporterrors(L, res);
+ return 0;
+
+}
+
+
+int mfluaPREmaincontrol(void)
+{
+ lua_State *L = Luas[0];
+ const char* file = "main_control.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "PRE_main_control"); /* function to be called */
+ /* do the call (0 arguments, 1 result) */
+ res = lua_pcall(L, 0, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_main_control called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+
+}
+
+
+int mfluaPOSTmaincontrol(void)
+{
+ lua_State *L = Luas[0];
+ const char* file = "main_control.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "POST_main_control"); /* function to be called */
+ /* do the call (0 arguments, 1 result) */
+ res = lua_pcall(L, 0, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `POST_main_control called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+
+}
+
+
+
+int mfluainitialize(void)
+{
+ /* execute Lua external "mfluaini.lua" */
+ lua_State *L = Luas[0];
+ const char* file = "mfluaini.lua";
+ int res ;
+ /* register lua functions */
+ lua_pushcfunction(L, priv_mfweb_link);lua_setglobal(L, "link");
+ lua_pushcfunction(L, priv_mfweb_info);lua_setglobal(L, "info");
+ lua_pushcfunction(L, priv_mfweb_x_coord);lua_setglobal(L, "x_coord");
+ lua_pushcfunction(L, priv_mfweb_y_coord);lua_setglobal(L, "y_coord");
+ lua_pushcfunction(L, priv_mfweb_left_type);lua_setglobal(L, "left_type");
+ lua_pushcfunction(L, priv_mfweb_right_type);lua_setglobal(L, "right_type");
+ lua_pushcfunction(L, priv_mfweb_left_x);lua_setglobal(L, "left_x");
+ lua_pushcfunction(L, priv_mfweb_left_y);lua_setglobal(L, "left_y");
+ lua_pushcfunction(L, priv_mfweb_right_x);lua_setglobal(L, "right_x");
+ lua_pushcfunction(L, priv_mfweb_right_y);lua_setglobal(L, "right_y");
+ lua_pushcfunction(L, priv_mfweb_n_sin_cos);lua_setglobal(L, "n_sin_cos");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_cur_edges);lua_setglobal(L, "LUAGLOBALGET_cur_edges");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_cur_exp);lua_setglobal(L, "LUAGLOBALGET_cur_exp");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_mem_top);lua_setglobal(L, "LUAGLOBALGET_mem_top");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_cur_pen);lua_setglobal(L, "LUAGLOBALGET_cur_pen");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_octant);lua_setglobal(L, "LUAGLOBALGET_octant");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_code);lua_setglobal(L, "LUAGLOBALGET_char_code");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_ext);lua_setglobal(L, "LUAGLOBALGET_char_ext");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_wd);lua_setglobal(L, "LUAGLOBALGET_char_wd");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_ht);lua_setglobal(L, "LUAGLOBALGET_char_ht");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_dp);lua_setglobal(L, "LUAGLOBALGET_char_dp");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_ic);lua_setglobal(L, "LUAGLOBALGET_char_ic");
+ /* */
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_dx);lua_setglobal(L,"LUAGLOBALGET_char_dx");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_dy);lua_setglobal(L,"LUAGLOBALGET_char_dy");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_designsize);lua_setglobal(L,"LUAGLOBALGET_designsize");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_hppp);lua_setglobal(L,"LUAGLOBALGET_hppp");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_vppp);lua_setglobal(L,"LUAGLOBALGET_vppp");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_x_offset);lua_setglobal(L,"LUAGLOBALGET_x_offset");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_y_offset);lua_setglobal(L,"LUAGLOBALGET_y_offset");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_granularity);lua_setglobal(L,"LUAGLOBALGET_granularity");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_fillin);lua_setglobal(L,"LUAGLOBALGET_fillin");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_turning_check);lua_setglobal(L,"LUAGLOBALGET_turning_check");
+ lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_boundary_char);lua_setglobal(L,"LUAGLOBALGET_boundary_char");
+
+ /*lua_pushcfunction(L, priv_mfweb_SKELETON);lua_setglobal(L, "SKELETON");*/
+ /* execute Lua external "mfluaini.lua" */
+ res = luaL_loadfile(L, file);
+ if ( res==0 ) {
+ res = lua_pcall(L, 0, 0, 0);
+ }
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+int mfluaPOSTfinalcleanup(void)
+{
+ lua_State *L = Luas[0];
+ const char* file = "final_cleanup.lua";
+ int res = luaL_loadfile(L, file);
+ /*if (res!=0) {fprintf(stderr,"\n! Warning: file final_cleanup not loaded\n",lua_tostring(L, -1)); return res;}*/
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ /*if (res!=0) {fprintf(stderr,"\n! Error: final_cleanup lua_pcall fails\n",lua_tostring(L, -1)); return res;}*/
+ if (res==0){
+ lua_getglobal(L, "POST_final_cleanup"); /* function to be called */
+ /* do the call (0 arguments, 1 result) */
+ res = lua_pcall(L, 0, 1, 0) ;
+ /*if (res!=0) {fprintf(stderr,"\n! Error:function `POST_final_cleanup called fails\n",lua_tostring(L, -1)); return res;}*/
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `POST_final_cleanup called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+
+/* Not a good way: */
+/* 1) these definitions are taken from mfcoerc.h which is generated at run-time */
+/* 2) too much coupling with webc2c translation of mf.web*/
+/* */
+/* #define printdiagnostic(s, t, nuline) zprintdiagnostic((strnumber) (s), (strnumber) (t), (boolean) (nuline)) */
+/* #define print(s) zprint((integer) (s)) */
+/* #define printarg(q, n, b) zprintarg((halfword) (q), (integer) (n), (halfword) (b) */
+/* int mfluaprintpath P3C(halfword, h , strnumber, s , boolean, nuline) */
+/* { */
+/* fprintf(stderr,"\n! %d \n",s); */
+/* printdiagnostic ( 517 , s , nuline ) ; */
+/* println () ; */
+/* print ( 518 ) ; */
+/* println () ; */
+/* fprintf(stderr,"\n! %s\n","*end***************"); */
+
+/* lua_State *L = Luas[0]; */
+/* const char* file = "print_path.lua"; */
+/* int res = luaL_loadfile(L, file); */
+/* if ( res==0 ) { */
+/* res = lua_pcall(L, 0, 0, 0); */
+/* } */
+/* // */
+/* //stackdump_g(L); */
+
+/* // */
+/* priv_lua_reporterrors(L, res); */
+/* return 0; */
+
+/* } */
+
+int mfluaprintpath(halfword h, strnumber s, boolean nuline)
+{
+ lua_State *L = Luas[0];
+ const char* file = "print_path.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "print_path"); /* function to be called */
+ lua_pushnumber(L, h); /* push 1st argument */
+ lua_pushnumber(L, s); /* push 2nd argument */
+ lua_pushnumber(L, nuline); /* push 3nd argument */
+ /* do the call (3 arguments, 1 result) */
+ res = lua_pcall(L, 3, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `print_path' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L); */
+ priv_lua_reporterrors(L, res);
+ return 0;
+
+}
+
+
+int mfluaprintedges(strnumber s, boolean nuline, integer xoff, integer yoff)
+{
+
+ lua_State *L = Luas[0];
+ const char* file = "print_edges.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "print_edges"); /* function to be called */
+ lua_pushnumber(L, s); /* push 1st argument */
+ lua_pushnumber(L, nuline); /* push 2nd argument */
+ lua_pushnumber(L, xoff); /* push 3nd argument */
+ lua_pushnumber(L, yoff); /* push 4nd argument */
+ /* do the call (4 arguments, 1 result) */
+ res = lua_pcall(L, 4, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `print_edges' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+
+}
+
+
+/* int mfluaoffsetprep(halfword c, halfword h) */
+/* { */
+
+/* lua_State *L = Luas[0]; */
+/* const char* file = "offset_prep.lua"; */
+/* int res = luaL_loadfile(L, file); */
+/* if ( res==0 ){ */
+/* res = lua_pcall(L, 0, 0, 0); */
+/* if (res==0){ */
+/* lua_getglobal(L, "offset_prep"); /\* function to be called *\/ */
+/* lua_pushnumber(L, c); /\* push 1st argument *\/ */
+/* lua_pushnumber(L, h); /\* push 2nd argument *\/ */
+/* /\* do the call (2 arguments, 1 result) *\/ */
+/* res = lua_pcall(L, 2, 1, 0) ; */
+/* if (res==0) { */
+/* /\* retrieve result *\/ */
+/* int z = 0; */
+/* if (!lua_isnumber(L, -1)){ */
+/* fprintf(stderr,"\n! Error:function `offset_prep' must return a number\n",lua_tostring(L, -1)); */
+/* lua_pop(L, 1); /\* pop returned value *\/ */
+/* return z; */
+/* }else { */
+/* z = lua_tonumber(L, -1); */
+/* lua_pop(L, 1); /\* pop returned value *\/ */
+/* return z; */
+/* } */
+/* } */
+/* } */
+/* } */
+/* // */
+/* //stackdump_g(L); */
+/* // */
+/* priv_lua_reporterrors(L, res); */
+/* return 0; */
+
+/* } */
+
+
+/* */
+/* Sensor before and after offset_prep */
+/* */
+int mfluaPREoffsetprep(halfword c, halfword h)
+{
+
+ lua_State *L = Luas[0];
+ const char* file = "offset_prep.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "PRE_offset_prep"); /* function to be called */
+ lua_pushnumber(L, c); /* push 1st argument */
+ lua_pushnumber(L, h); /* push 2nd argument */
+ /* do the call (2 arguments, 1 result) */
+ res = lua_pcall(L, 2, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_offset_prep' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+
+}
+
+int mfluaPOSToffsetprep(halfword c, halfword h)
+{
+
+ lua_State *L = Luas[0];
+ const char* file = "offset_prep.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "POST_offset_prep"); /* function to be called */
+ lua_pushnumber(L, c); /* push 1st argument */
+ lua_pushnumber(L, h); /* push 2nd argument */
+ /* do the call (2 arguments, 1 result) */
+ res = lua_pcall(L, 2, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_offset_prep' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+
+}
+
+
+int mfluaPREfillenveloperhs(halfword rhs)
+{
+ lua_State *L = Luas[0];
+ const char* file = "do_add_to.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "PRE_fill_envelope_rhs"); /* function to be called */
+ lua_pushnumber(L, rhs); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_fill_envelope_rhs' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+int mfluaPOSTfillenveloperhs(halfword rhs)
+{
+ lua_State *L = Luas[0];
+ const char* file = "do_add_to.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "POST_fill_envelope_rhs"); /* function to be called */
+ lua_pushnumber(L, rhs); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `POST_fill_envelope_rhs' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L); */
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+
+int mfluaPREfillenvelopelhs(halfword lhs)
+{
+ lua_State *L = Luas[0];
+ const char* file = "do_add_to.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "PRE_fill_envelope_lhs"); /* function to be called */
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_fill_envelope_lhs' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+int mfluaPOSTfillenvelopelhs(halfword lhs)
+{
+ lua_State *L = Luas[0];
+ const char* file = "do_add_to.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "POST_fill_envelope_lhs"); /* function to be called */
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `POST_fill_envelope_lhs' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+
+int mfluaPREfillspecrhs(halfword rhs)
+{
+ lua_State *L = Luas[0];
+ const char* file = "do_add_to.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "PRE_fill_spec_rhs"); /* function to be called */
+ lua_pushnumber(L, rhs); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_fill_spec_rhs' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+int mfluaPOSTfillspecrhs(halfword rhs)
+{
+ lua_State *L = Luas[0];
+ const char* file = "do_add_to.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "POST_fill_spec_rhs"); /* function to be called */
+ lua_pushnumber(L, rhs); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `POST_fill_spec_rhs' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+int mfluaPREfillspeclhs(halfword lhs)
+{
+ lua_State *L = Luas[0];
+ const char* file = "do_add_to.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "PRE_fill_spec_lhs"); /* function to be called */
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_fill_spec_lhs' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+int mfluaPOSTfillspeclhs(halfword lhs)
+{
+ lua_State *L = Luas[0];
+ const char* file = "do_add_to.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "POST_fill_spec_lhs"); /* function to be called */
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `POST_fill_spec_lhs' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+int mfluaPREmovetoedges(halfword lhs)
+{
+ lua_State *L = Luas[0];
+ const char* file = "fill_spec.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "PRE_move_to_edges"); /* function to be called */
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_move_to_edges' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+
+int mfluaPOSTmovetoedges(halfword lhs)
+{
+ lua_State *L = Luas[0];
+ const char* file = "fill_spec.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "POST_move_to_edges"); /* function to be called */
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `POST_move_to_edges' must return a number called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+
+int mfluaPREmakechoices(halfword p)
+{
+ lua_State *L = Luas[0];
+ const char* file = "scan_direction.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "PRE_make_choices"); /* function to be called */
+ lua_pushnumber(L, p); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_make_choices' must return a number and not %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+int mfluaPOSTmakechoices(halfword p)
+{
+ lua_State *L = Luas[0];
+ const char* file = "scan_direction.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "POST_make_choices"); /* function to be called */
+ lua_pushnumber(L, p); /* push 1st argument */
+ /* do the call (1 arguments, 1 result) */
+ res = lua_pcall(L, 1, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `POST_make_choices' must return a number and not %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+
+
+
+
+
+int mfluaprintretrogradeline(integer x0, integer y0, integer cur_x, integer cur_y)
+{
+ lua_State *L = Luas[0];
+ const char* file = "skew_line_edges.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "print_retrograde_line"); /* function to be called */
+ lua_pushnumber(L, x0); /* push 1st argument */
+ lua_pushnumber(L, y0); /* push 2nd argument */
+ lua_pushnumber(L, cur_x); /* push 3th argument */
+ lua_pushnumber(L, cur_y); /* push 4th argument */
+ /* do the call (4 arguments, 1 result) */
+ res = lua_pcall(L, 4, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `print_retrograde_line called with %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+
+}
+
+
+int mfluaPREmakeellipse(integer major_axis, integer minor_axis, integer theta , integer tx, integer ty,integer q)
+{
+ lua_State *L = Luas[0];
+ const char* file = "make_ellipse.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "PRE_make_ellipse"); /* function to be called */
+ lua_pushnumber(L, major_axis); /* push 1st argument */
+ lua_pushnumber(L, minor_axis); /* push 2nd argument */
+ lua_pushnumber(L, theta); /* push 3th argument */
+ lua_pushnumber(L, tx); /* push 4th argument */
+ lua_pushnumber(L, ty); /* push 5th argument */
+ lua_pushnumber(L, q); /* push 6th argument */
+ /* do the call (6 arguments, 1 result) */
+ res = lua_pcall(L, 6, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_make_ellipse returns %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+
+}
+
+
+int mfluaPOSTmakeellipse(integer major_axis, integer minor_axis, integer theta , integer tx, integer ty,integer q)
+{
+ lua_State *L = Luas[0];
+ const char* file = "make_ellipse.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "POST_make_ellipse"); /* function to be called */
+ lua_pushnumber(L, major_axis); /* push 1st argument */
+ lua_pushnumber(L, minor_axis); /* push 2nd argument */
+ lua_pushnumber(L, theta); /* push 3th argument */
+ lua_pushnumber(L, tx); /* push 4th argument */
+ lua_pushnumber(L, ty); /* push 5th argument */
+ lua_pushnumber(L, q); /* push 6th argument */
+ /* do the call (6 arguments, 1 result) */
+ res = lua_pcall(L, 6, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `PRE_make_ellipse returns %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+
+}
+
+
+
+
+
+
+
+
+int mfluaprinttransitionlinefrom(integer x, integer y)
+{
+ lua_State *L = Luas[0];
+ const char* file = "fill_envelope.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "print_transition_line_from"); /* function to be called */
+ lua_pushnumber(L, x); /* push 1st argument */
+ lua_pushnumber(L, y); /* push 2nd argument */
+ /* do the call (2 arguments, 1 result) */
+ res = lua_pcall(L, 2, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `print_transition_from' must return a number and nt %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+int mfluaprinttransitionlineto(integer x, integer y)
+{
+ lua_State *L = Luas[0];
+ const char* file = "fill_envelope.lua";
+ int res = luaL_loadfile(L, file);
+ if ( res==0 ){
+ res = lua_pcall(L, 0, 0, 0);
+ if (res==0){
+ lua_getglobal(L, "print_transition_line_to"); /* function to be called */
+ lua_pushnumber(L, x); /* push 1st argument */
+ lua_pushnumber(L, y); /* push 2nd argument */
+ /* do the call (2 arguments, 1 result) */
+ res = lua_pcall(L, 2, 1, 0) ;
+ if (res==0) {
+ /* retrieve result */
+ int z = 0;
+ if (!lua_isnumber(L, -1)){
+ fprintf(stderr,"\n! Error:function `print_transition_to' must return a number and not %s\n",lua_tostring(L, -1));
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }else {
+ z = lua_tonumber(L, -1);
+ lua_pop(L, 1); /* pop returned value */
+ return z;
+ }
+ }
+ }
+ }
+ /*stackdump_g(L);*/
+ priv_lua_reporterrors(L, res);
+ return 0;
+}
+
+#define priv_append_char(c) do { \
+ strpool[poolptr]=c; \
+ poolptr++; \
+} while(0)
+
+#define priv_str_room(l) do { \
+ if ((poolptr + l) > maxpoolptr) { \
+ if ((poolptr + l) > poolsize) { \
+ fprintf(stderr,"\n! (Lua) MFLua capacity exceeded, sorry [pool size=%ld]\nIf you really absolutely need more capacity,\nyou can ask a wizard to enlarge me.\n",poolsize-initpoolptr); \
+ exit(1); \
+ } \
+ maxpoolptr = poolptr + l; \
+ } \
+} while (0)
+
+int mfluarunscript(halfword j, halfword first, halfword limit)
+{
+ int i ;
+ lua_State *L ;
+ unsigned char last_char;
+ int error;
+ const char *str;
+ size_t len;
+ L = Luas[0];
+ last_char = strpool[j+limit-first] ;
+ /* end of a C string */
+ strpool[j+limit-first] = '\0';
+ str = (const char *)(strpool+j) ;
+ /*fprintf(stderr,"\n! str=%s\n",str);*/
+ /* do the call (0 arguments, 1 result) */
+ error = (luaL_loadstring(L, str) || lua_pcall(L, 0, 1, 0)) ;
+ strpool[j+limit-first] = last_char;
+ if(error) {
+ priv_lua_reporterrors(L,error);
+ } else {
+ /* retrieve result */
+ str = lua_tolstring(L, -1,&len);
+ priv_str_room(len);
+ for(i=0;i<len;i++){
+ priv_append_char( (unsigned char)(*(str+i))) ;
+ }
+ lua_pop(L, 1); /* pop returned value */
+ }
+ return 0;
+}
diff --git a/Build/source/texk/web2c/mfluadir/mfluac.h b/Build/source/texk/web2c/mfluadir/mfluac.h
new file mode 100644
index 00000000000..4f870a46d78
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluac.h
@@ -0,0 +1,38 @@
+extern int mfluabeginprogram(void);
+extern int mfluaPREstartofMF(void);
+extern int mfluaPREmaincontrol(void);
+extern int mfluaPOSTmaincontrol(void);
+extern int mfluainitialize(void);
+extern int mfluaPOSTfinalcleanup(void);
+extern int mfluaendprogram(void);
+
+extern int mfluaprintpath(halfword, strnumber, boolean);
+extern int mfluarunscript(halfword, halfword, halfword);
+extern int mfluaprintedges(strnumber, boolean, integer, integer);
+
+extern int mfluaPREoffsetprep(halfword, halfword);
+extern int mfluaPOSToffsetprep(halfword, halfword);
+
+extern int mfluaPREfillenveloperhs(halfword);
+extern int mfluaPOSTfillenveloperhs(halfword);
+extern int mfluaPREfillenvelopelhs(halfword);
+extern int mfluaPOSTfillenvelopelhs(halfword);
+
+extern int mfluaPREfillspecrhs(halfword);
+extern int mfluaPOSTfillspecrhs(halfword);
+extern int mfluaPREfillspeclhs(halfword);
+extern int mfluaPOSTfillspeclhs(halfword);
+
+extern int mfluaPREmakechoices(halfword);
+extern int mfluaPOSTmakechoices(halfword);
+
+extern int mfluaPREmovetoedges(halfword);
+extern int mfluaPOSTmovetoedges(halfword);
+
+extern int mfluaprintretrogradeline(integer, integer, integer, integer);
+
+extern int mfluaprinttransitionlinefrom(integer, integer);
+extern int mfluaprinttransitionlineto(integer, integer);
+
+extern int mfluaPREmakeellipse(integer, integer, integer, integer, integer, integer);
+extern int mfluaPOSTmakeellipse(integer, integer, integer, integer, integer, integer);
diff --git a/Build/source/texk/web2c/mfluadir/mfluaextra.c b/Build/source/texk/web2c/mfluadir/mfluaextra.c
new file mode 100644
index 00000000000..3ec9db1060a
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluaextra.c
@@ -0,0 +1,11 @@
+/* mfluaextra.c: Hand-coded routines for MFLua.
+
+ This file is public domain. */
+
+#define EXTERN /* Instantiate data from mfluad.h here. */
+
+/* This file defines MFLua. */
+#include <mfluad.h>
+
+/* Hand-coded routines for TeX or Metafont in C. */
+#include <lib/texmfmp.c>
diff --git a/Build/source/texk/web2c/mfluadir/mfluaextra.h b/Build/source/texk/web2c/mfluadir/mfluaextra.h
new file mode 100644
index 00000000000..6e3d7994e7d
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluaextra.h
@@ -0,0 +1,23 @@
+/* mfluaextra.h: banner etc. for MFLua.
+
+ This is included by MFLua, from mfluaextra.c
+*/
+
+#include <mfluadir/mflua_version.h> /* for MFLUA_VERSION */
+
+#define BANNER "This is MFLua, Version 2.7182818-" MFLUA_VERSION
+#define COPYRIGHT_HOLDER "L. Scarso"
+#define AUTHOR NULL
+#define PROGRAM_HELP MFLUAHELP
+#define BUG_ADDRESS "luigi.scarso@gmail.com"
+#define DUMP_VAR MFbasedefault
+#define DUMP_LENGTH_VAR basedefaultlength
+#define DUMP_OPTION "base"
+#ifdef DOS
+#define DUMP_EXT ".bas"
+#else
+#define DUMP_EXT ".base"
+#endif
+#define INPUT_FORMAT kpse_mf_format
+#define INI_PROGRAM "inimflua"
+#define VIR_PROGRAM "virmflua"
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/begin_program.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/begin_program.lua
new file mode 100644
index 00000000000..0711ed9dddb
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/begin_program.lua
@@ -0,0 +1 @@
+-- empty
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/do_add_to.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/do_add_to.lua
new file mode 100644
index 00000000000..98dd9750722
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/do_add_to.lua
@@ -0,0 +1,9 @@
+function PRE_fill_envelope_rhs(rhs) return 0 end
+function POST_fill_envelope_rhs(rhs) return 0 end
+function PRE_fill_envelope_lhs(rhs) return 0 end
+function POST_fill_envelope_lhs(rhs) return 0 end
+
+function PRE_fill_spec_rhs(rhs) return 0 end
+function POST_fill_spec_rhs(rhs) return 0 end
+function PRE_fill_spec_lhs(rhs) return 0 end
+function POST_fill_spec_lhs(rhs) return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/end_program.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/end_program.lua
new file mode 100644
index 00000000000..0711ed9dddb
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/end_program.lua
@@ -0,0 +1 @@
+-- empty
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/fill_envelope.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/fill_envelope.lua
new file mode 100644
index 00000000000..cbd9b2841be
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/fill_envelope.lua
@@ -0,0 +1,2 @@
+function print_transition_line_from(x,y) return 0 end
+function print_transition_line_to(x,y) return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/fill_spec.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/fill_spec.lua
new file mode 100644
index 00000000000..54367f46110
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/fill_spec.lua
@@ -0,0 +1,2 @@
+function PRE_move_to_edges(lhs) return 0 end
+function POST_move_to_edges(lhs) return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/final_cleanup.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/final_cleanup.lua
new file mode 100644
index 00000000000..627d09c0fec
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/final_cleanup.lua
@@ -0,0 +1 @@
+function POST_final_cleanup() return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/main_control.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/main_control.lua
new file mode 100644
index 00000000000..bf6c5784959
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/main_control.lua
@@ -0,0 +1,2 @@
+function PRE_main_control() return 0 end
+function POST_main_control() return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/make_ellipse.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/make_ellipse.lua
new file mode 100644
index 00000000000..7c094499b88
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/make_ellipse.lua
@@ -0,0 +1,2 @@
+function PRE_make_ellipse(major_axis,minor_axis,theta,tx,ty) return 0 end
+function POST_make_ellipse(major_axis,minor_axis,theta,tx,ty) return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/mfluaini.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/mfluaini.lua
new file mode 100644
index 00000000000..0711ed9dddb
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/mfluaini.lua
@@ -0,0 +1 @@
+-- empty
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/mfluatrap.diffs b/Build/source/texk/web2c/mfluadir/mfluatrap/mfluatrap.diffs
new file mode 100644
index 00000000000..a8176a88ce7
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/mfluatrap.diffs
@@ -0,0 +1,203 @@
+>>> Running TRAP test for MFLua.
+>>> See SRCDIR/mfluadir/mfluatrap/mfluatrap.diffs for example of acceptable diffs.
++ ln -s SRCDIR/triptrap/trap.mf .
++ ./mflua --progname=inimflua
++ test '!' -s trap.base
++ mv trap.log mftrapin.log
++ diff SRCDIR/triptrap/mftrapin.log mftrapin.log
+1c1
+< This is METAFONT, Version 2.7182818 (INIMF) 7 JAN 2014 17:51
+---
+> This is MFLua, Version 2.7182818-0.5 (TeX Live 2015) (INIMF) 17 APR 2015 11:16
+150c150
+< String usage 26&83 (891&11438 still untouched)
+---
+> String usage 30&98 (6384&979377 still untouched)
+176,177c176,177
+< (preloaded base=trap 2014.1.7)
+< 1117 strings of total length 20614
+---
+> (preloaded base=trap 2015.4.17)
+> 1125 strings of total length 20684
+179c179
+< 265 symbolic tokens
+---
+> 266 symbolic tokens
++ ./mflua --progname=inimflua
++ mv trap.log mftrap.log
++ mv trap.tfm mftrap.tfm
++ diff SRCDIR/triptrap/mftrap.fot mftrap.fot
+1,3c1,2
+< This is METAFONT, Version 2.7182818 (INIMF)
+< ** &trap trap
+< (trap.mf
+---
+> This is MFLua, Version 2.7182818-0.5 (TeX Live 2015) (INIMF)
+> **(trap.mf
+39c38
+< String usage 41&161 (815&7634 still untouched)
+---
+> String usage 50&202 (6298&975523 still untouched)
++ diff SRCDIR/triptrap/mftrap.log mftrap.log
+1c1
+< This is METAFONT, Version 2.7182818 (preloaded base=trap 2014.1.7) 7 JAN 2014 18:11
+---
+> This is MFLua, Version 2.7182818-0.5 (TeX Live 2015) (preloaded base=trap 2015.4.17) 17 APR 2015 11:16
+133,134c133,134
+< <scantokens> pair
+< p[],';^^ff
+---
+> <scantokens> or <runscript> pair
+> p[],';^^ff
+145,146c145,146
+< <scantokens> pair
+< p[],';^^ff
+---
+> <scantokens> or <runscript> pair
+> p[],';^^ff
+158,159c158,159
+< <scantokens> pair
+< p[],';^^ff
+---
+> <scantokens> or <runscript> pair
+> p[],';^^ff
+169,170c169,170
+< <scantokens> pair p[],';^^ff
+<
+---
+> <scantokens> or <runscript> ...f
+>
+1825c1825
+< String usage 24&92 (858&11309 still untouched)
+---
+> String usage 30&119 (6344&979191 still untouched)
+3693,3695c3693,3695
+< xpart %CAPSULE1359=xx
+< %CAPSULE1367=2yy-2
+< %CAPSULE1375 = 3.3333xx+3.3333
+---
+> xpart %CAPSULE1370=xx
+> %CAPSULE1378=2yy-2
+> %CAPSULE1386 = 3.3333xx+3.3333
+3755,3757c3755,3757
+< xpart %CAPSULE1049 = 8000o2-4000o1+1000o3+9
+< xpart %CAPSULE1383=xpart '
+< ypart %CAPSULE1383=ypart '
+---
+> xpart %CAPSULE604 = 8000o2-4000o1+1000o3+9
+> xpart %CAPSULE1394=xpart '
+> ypart %CAPSULE1394=ypart '
+3760,3761c3760,3761
+< ### 4000o1 = -xpart %CAPSULE1049+8000o2+1000o3+9
+< ### -4.87383o2 = -oo-0.0004xpart %CAPSULE1049+0.39673o3-17.99643
+---
+> ### 4000o1 = -xpart %CAPSULE604+8000o2+1000o3+9
+> ### -4.87383o2 = -oo-0.0004xpart %CAPSULE604+0.39673o3-17.99643
+3768c3768
+< ### -alfa=-xpart %CAPSULE1494
+---
+> ### -alfa=-xpart %CAPSULE368
+3770,3771c3770,3771
+< {xpart((xpart %CAPSULE1494,0))}
+< ### -xpart %CAPSULE17=-%CAPSULE1176
+---
+> {xpart((xpart %CAPSULE368,0))}
+> ### -xpart %CAPSULE17=-%CAPSULE1376
+3773,3775c3773,3775
+< {(%CAPSULE382)+(%CAPSULE1176)}
+< ### -%CAPSULE382=-%CAPSULE1893+%CAPSULE1176
+< ### -%CAPSULE1893=-ypart %CAPSULE1049
+---
+> {(%CAPSULE382)+(%CAPSULE1376)}
+> ### -%CAPSULE382=-%CAPSULE1364+%CAPSULE1376
+> ### -%CAPSULE1364=-ypart %CAPSULE604
+3780c3780
+< ### p$=-ypart %CAPSULE604+1
+---
+> ### p$=-ypart %CAPSULE1360+1
+3782,3793c3782,3793
+< {(2/3)*((-ypart %CAPSULE604+1,ypart %CAPSULE604))}
+< ### ypart %CAPSULE604=-xpart %CAPSULE604+1
+< ### -0.66667xpart %CAPSULE604=-xpart %CAPSULE1889
+< {-((xpart %CAPSULE1889,-xpart %CAPSULE1889+0.66667))}
+< ### xpart %CAPSULE1889=-xpart %CAPSULE1172
+< {((xpart %CAPSULE1049,ypart %CAPSULE1049))=((xpart %CAPSULE1172,-xpart %
+< CAPSULE1172-0.66667))}
+< ## xpart %CAPSULE1172=-ypart %CAPSULE1049-0.66667
+< ## ypart %CAPSULE1049=-xpart %CAPSULE1049-0.66667
+< ### -xpart %CAPSULE1049=-xpart %CAPSULE1172
+< {((xpart ',ypart '))=((xpart %CAPSULE1172,-xpart %CAPSULE1172-0.66667))}
+< ## xpart %CAPSULE1172=-ypart '-0.66667
+---
+> {(2/3)*((-ypart %CAPSULE1360+1,ypart %CAPSULE1360))}
+> ### ypart %CAPSULE1360=-xpart %CAPSULE1360+1
+> ### -0.66667xpart %CAPSULE1360=-xpart %CAPSULE1744
+> {-((xpart %CAPSULE1744,-xpart %CAPSULE1744+0.66667))}
+> ### xpart %CAPSULE1744=-xpart %CAPSULE1675
+> {((xpart %CAPSULE604,ypart %CAPSULE604))=((xpart %CAPSULE1675,-xpart %CA
+> PSULE1675-0.66667))}
+> ## xpart %CAPSULE1675=-ypart %CAPSULE604-0.66667
+> ## ypart %CAPSULE604=-xpart %CAPSULE604-0.66667
+> ### -xpart %CAPSULE604=-xpart %CAPSULE1675
+> {((xpart ',ypart '))=((xpart %CAPSULE1675,-xpart %CAPSULE1675-0.66667))}
+> ## xpart %CAPSULE1675=-ypart '-0.66667
+3799c3799
+< ### -ooo=-%CAPSULE1494
+---
+> ### -ooo=-%CAPSULE1051
+3801,3810c3801,3810
+< {(%CAPSULE1494)+(1)}
+< ### -%CAPSULE1494=-%CAPSULE1350+1
+< {(1/2)*(%CAPSULE1350)}
+< ### -0.5%CAPSULE1350=-%CAPSULE1367
+< {-(%CAPSULE1367)}
+< ### %CAPSULE1367=-%CAPSULE1893
+< {(2)*(%CAPSULE1893)}
+< ### -2%CAPSULE1893=-%CAPSULE1885
+< {(-0.5%CAPSULE1885-0.5)=(%CAPSULE1885)}
+< ## %CAPSULE1885=-0.33333
+---
+> {(%CAPSULE1051)+(1)}
+> ### -%CAPSULE1051=-%CAPSULE1378+1
+> {(1/2)*(%CAPSULE1378)}
+> ### -0.5%CAPSULE1378=-%CAPSULE1370
+> {-(%CAPSULE1370)}
+> ### %CAPSULE1370=-%CAPSULE1362
+> {(2)*(%CAPSULE1362)}
+> ### -2%CAPSULE1362=-%CAPSULE1354
+> {(-0.5%CAPSULE1354-0.5)=(%CAPSULE1354)}
+> ## %CAPSULE1354=-0.33333
+4235c4235
+< String usage 41&161 (815&7634 still untouched)
+---
+> String usage 50&202 (6298&975523 still untouched)
+4251,4252c4251,4252
+< 68 strings out of 883
+< 3752 string characters out of 11386
+---
+> 77 strings out of 6375
+> 3793 string characters out of 979316
+4254,4255c4254,4255
+< 289 symbolic tokens out of 2100
+< 8i,43n,14r,8p,167b stack positions out of 30i,100n,300r,150p,500b
+---
+> 290 symbolic tokens out of 9500
+> 8i,43n,14r,8p,167b stack positions out of 300i,300n,1000r,150p,3000b
+4263c4263
+< out of 256w,16h,16d,64i,5000l,500k,256e,50p)
+---
+> out of 256w,16h,16d,64i,15000l,2500k,256e,60p)
++ ./tftopl ./mftrap.tfm mftrap.pl
++ diff SRCDIR/triptrap/mftrap.pl mftrap.pl
++ ./gftype -m -i ./trap.72270gf
++ diff SRCDIR/triptrap/trap.typ trap.typ
+1c1
+< This is GFtype, Version 3.1
+---
+> This is GFtype, Version 3.1 (TeX Live 2015)
+3c3
+< ' METAFONT output 2014.01.07:1811'
+---
+> ' METAFONT output 2015.04.17:1116'
++ :
+PASS: mfluadir/mfluatraptest
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/offset_prep.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/offset_prep.lua
new file mode 100644
index 00000000000..1452e0325cd
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/offset_prep.lua
@@ -0,0 +1,2 @@
+function PRE_offset_prep(c,h) return 0 end
+function POST_offset_prep(c,h) return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/print_edges.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/print_edges.lua
new file mode 100644
index 00000000000..ae35ce6585e
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/print_edges.lua
@@ -0,0 +1 @@
+function print_edges(s,nuline,xoff,yoff) return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/print_path.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/print_path.lua
new file mode 100644
index 00000000000..1733bc9d2cd
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/print_path.lua
@@ -0,0 +1 @@
+function print_path(h,s,nuline) return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/scan_direction.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/scan_direction.lua
new file mode 100644
index 00000000000..6c896677f6c
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/scan_direction.lua
@@ -0,0 +1,2 @@
+function PRE_make_choices(p) return 0 end
+function POST_make_choices(p) return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/skew_line_edges.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/skew_line_edges.lua
new file mode 100644
index 00000000000..2ae9dc20a6a
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/skew_line_edges.lua
@@ -0,0 +1 @@
+function print_retrograde_line(x0,y0,cur_x,cur_y) return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/start_of_MF.lua b/Build/source/texk/web2c/mfluadir/mfluatrap/start_of_MF.lua
new file mode 100644
index 00000000000..7c24087ca5d
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/start_of_MF.lua
@@ -0,0 +1 @@
+function PRE_start_of_MF() return 0 end \ No newline at end of file
diff --git a/Build/source/texk/web2c/mfluadir/mfluatrap/texmf.cnf b/Build/source/texk/web2c/mfluadir/mfluatrap/texmf.cnf
new file mode 100644
index 00000000000..04165594719
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatrap/texmf.cnf
@@ -0,0 +1,38 @@
+% mfluadir/mfluatrap/texmf.cnf -- configuration for the MFLua and MFLuaJIT trap tests.
+
+% These values apply to all the programs, and they are necessary for any
+% kind of reasonable diff.
+error_line = 64
+half_error_line = 32
+max_print_line = 72
+
+% Metafont
+main_memory = 3001
+
+% Actually, Metafont currently ignores the settings for max_strings,
+% string_vacancies and pool_size specified here, but it doesn't hurt
+% to supply the correct values, just in case this changes one day.
+
+max_strings = 2000
+string_vacancies = 8000
+pool_size = 40000
+
+gf_buf_size = 8 % trapman.tex says to use this.
+MFTERM = trap % get the right screen output
+screen_width = 100
+screen_depth = 200
+
+% Search paths.
+% trap.mf:
+MFINPUTS = .
+% trip.tfm, trap.tfm, trapf.tfm:
+TFMFONTS = .
+% trap.base:
+MFBASES = .
+% mf.pool:
+MFPOOL = .
+
+% GFtype only.
+line_length.gftype = 79
+max_rows.gftype = 79
+max_cols.gftype = 79
diff --git a/Build/source/texk/web2c/mfluadir/mfluatraptest b/Build/source/texk/web2c/mfluadir/mfluatraptest
new file mode 100755
index 00000000000..92866a869ad
--- /dev/null
+++ b/Build/source/texk/web2c/mfluadir/mfluatraptest
@@ -0,0 +1,51 @@
+#! /bin/sh
+
+# Copyright (C) 2015 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+testdir=$abs_srcdir/triptrap
+ltestdir=$abs_srcdir/mfluadir/mfluatrap
+
+TEXMFCNF=$ltestdir; export TEXMFCNF
+
+rm -rf mfluatrapdir
+mkdir mfluatrapdir
+cd mfluatrapdir
+
+cp $ltestdir/*.lua .
+
+echo ">>> Running TRAP test for MFLua." >&2
+echo ">>> See $ltestdir/mfluatrap.diffs for example of acceptable diffs." >&2
+
+is_OK=:
+
+set -x
+
+# get same filename in log
+$LN_S $testdir/trap.mf .
+
+../mflua --progname=inimflua <$testdir/mftrap1.in >mftrapin.fot
+if test ! -s trap.base; then
+ echo "*** trap.base not created by mftrap1.in, investigate!" >&2
+ exit 1
+fi
+mv trap.log mftrapin.log || exit 1
+diff $testdir/mftrapin.log mftrapin.log
+
+../mflua --progname=inimflua <$testdir/mftrap2.in >mftrap.fot
+mv trap.log mftrap.log || exit 1
+mv trap.tfm mftrap.tfm || exit 1
+diff $testdir/mftrap.fot mftrap.fot
+diff $testdir/mftrap.log mftrap.log
+
+../tftopl ./mftrap.tfm mftrap.pl || exit 1
+diff $testdir/mftrap.pl mftrap.pl || is_OK=false
+
+../gftype -m -i ./trap.72270gf >trap.typ || exit 1
+diff $testdir/trap.typ trap.typ
+
+$is_OK || {
+ echo ">>> There were some errors." >&2
+ exit 1
+}
+