From b70a9504000e702bb29a3c383f8773f2c0077b47 Mon Sep 17 00:00:00 2001
From: Luigi Scarso <luigi.scarso@gmail.com>
Date: Thu, 21 Apr 2016 12:40:43 +0000
Subject: [PATCH] some more symbolic constants to equivalents (HH)

---
 source/texk/web2c/luatexdir/lua/luatex-api.h  | 112 +++++++++---------
 source/texk/web2c/luatexdir/tex/directions.h  |   5 -
 source/texk/web2c/luatexdir/tex/equivalents.h |  26 ++++
 source/texk/web2c/luatexdir/tex/maincontrol.w |   8 +-
 source/texk/web2c/luatexdir/tex/mlist.w       |   3 -
 source/texk/web2c/luatexdir/tex/texmath.h     |  11 --
 source/texk/web2c/luatexdir/tex/texmath.w     |   4 +-
 7 files changed, 88 insertions(+), 81 deletions(-)

diff --git a/source/texk/web2c/luatexdir/lua/luatex-api.h b/source/texk/web2c/luatexdir/lua/luatex-api.h
index f671842d6..9a51ee4d8 100644
--- a/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -348,72 +348,72 @@ extern int l_dir_text_index        [DIR_TEXT_SIZE];
 #define lua_push_string_by_name(L,index)       lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(index))
 
 #define set_l_pack_type_index \
-l_pack_type_index[0] = lua_key_index(exactly); \
-l_pack_type_index[1] = lua_key_index(additional); \
-l_pack_type_index[2] = lua_key_index(cal_expand_ratio);\
-l_pack_type_index[3] = lua_key_index(subst_ex_font);
+l_pack_type_index[exactly]          = lua_key_index(exactly); \
+l_pack_type_index[additional]       = lua_key_index(additional); \
+l_pack_type_index[cal_expand_ratio] = lua_key_index(cal_expand_ratio);\
+l_pack_type_index[subst_ex_font]    = lua_key_index(subst_ex_font);
 
 #define set_l_group_code_index \
-l_group_code_index[0]  = lua_key_index(empty_string);\
-l_group_code_index[1]  = lua_key_index(simple);\
-l_group_code_index[2]  = lua_key_index(hbox);\
-l_group_code_index[3]  = lua_key_index(adjusted_hbox);\
-l_group_code_index[4]  = lua_key_index(vbox);\
-l_group_code_index[5]  = lua_key_index(vtop);\
-l_group_code_index[6]  = lua_key_index(align);\
-l_group_code_index[7]  = lua_key_index(no_align);\
-l_group_code_index[8]  = lua_key_index(output);\
-l_group_code_index[9]  = lua_key_index(math);\
-l_group_code_index[10] = lua_key_index(disc);\
-l_group_code_index[11] = lua_key_index(insert);\
-l_group_code_index[12] = lua_key_index(vcenter);\
-l_group_code_index[13] = lua_key_index(math_choice);\
-l_group_code_index[14] = lua_key_index(semi_simple);\
-l_group_code_index[15] = lua_key_index(math_shift);\
-l_group_code_index[16] = lua_key_index(math_left);\
-l_group_code_index[17] = lua_key_index(local_box);\
-l_group_code_index[18] = lua_key_index(split_off);\
-l_group_code_index[19] = lua_key_index(split_keep);\
-l_group_code_index[20] = lua_key_index(preamble);\
-l_group_code_index[21] = lua_key_index(align_set);\
-l_group_code_index[22] = lua_key_index(fin_row)
+l_group_code_index[bottom_level]        = lua_key_index(empty_string);\
+l_group_code_index[simple_group]        = lua_key_index(simple);\
+l_group_code_index[hbox_group]          = lua_key_index(hbox);\
+l_group_code_index[adjusted_hbox_group] = lua_key_index(adjusted_hbox);\
+l_group_code_index[vbox_group]          = lua_key_index(vbox);\
+l_group_code_index[vtop_group]          = lua_key_index(vtop);\
+l_group_code_index[align_group]         = lua_key_index(align);\
+l_group_code_index[no_align_group]      = lua_key_index(no_align);\
+l_group_code_index[output_group]        = lua_key_index(output);\
+l_group_code_index[math_group]          = lua_key_index(math);\
+l_group_code_index[disc_group]          = lua_key_index(disc);\
+l_group_code_index[insert_group]        = lua_key_index(insert);\
+l_group_code_index[vcenter_group]       = lua_key_index(vcenter);\
+l_group_code_index[math_choice_group]   = lua_key_index(math_choice);\
+l_group_code_index[semi_simple_group]   = lua_key_index(semi_simple);\
+l_group_code_index[math_shift_group]    = lua_key_index(math_shift);\
+l_group_code_index[math_left_group]     = lua_key_index(math_left);\
+l_group_code_index[local_box_group]     = lua_key_index(local_box);\
+l_group_code_index[split_off_group]     = lua_key_index(split_off);\
+l_group_code_index[split_keep_group]    = lua_key_index(split_keep);\
+l_group_code_index[preamble_group]      = lua_key_index(preamble);\
+l_group_code_index[align_set_group]     = lua_key_index(align_set);\
+l_group_code_index[fin_row_group]       = lua_key_index(fin_row)
 
 #define set_l_local_par_index \
-l_local_par_index[0] = lua_key_index(new_graf);\
-l_local_par_index[1] = lua_key_index(local_box);\
-l_local_par_index[2] = lua_key_index(hmode_par);\
-l_local_par_index[3] = lua_key_index(penalty);\
-l_local_par_index[4] = lua_key_index(math);
+l_local_par_index[new_graf_par_code]  = lua_key_index(new_graf);\
+l_local_par_index[local_box_par_code] = lua_key_index(local_box);\
+l_local_par_index[hmode_par_par_code] = lua_key_index(hmode_par);\
+l_local_par_index[penalty_par_code]   = lua_key_index(penalty);\
+l_local_par_index[math_par_code]      = lua_key_index(math);
 
 #define set_l_math_style_name_index \
-l_math_style_name_index[0] = lua_key_index(display);\
-l_math_style_name_index[1] = lua_key_index(crampeddisplay);\
-l_math_style_name_index[2] = lua_key_index(text);\
-l_math_style_name_index[3] = lua_key_index(crampedtext);\
-l_math_style_name_index[4] = lua_key_index(script);\
-l_math_style_name_index[5] = lua_key_index(crampedscript);\
-l_math_style_name_index[6] = lua_key_index(scriptscript);\
-l_math_style_name_index[7] = lua_key_index(crampedscriptscript)
+l_math_style_name_index[display_style]               = lua_key_index(display);\
+l_math_style_name_index[cramped_display_style]       = lua_key_index(crampeddisplay);\
+l_math_style_name_index[text_style]                  = lua_key_index(text);\
+l_math_style_name_index[cramped_text_style]          = lua_key_index(crampedtext);\
+l_math_style_name_index[script_style]                = lua_key_index(script);\
+l_math_style_name_index[cramped_script_style]        = lua_key_index(crampedscript);\
+l_math_style_name_index[script_script_style]         = lua_key_index(scriptscript);\
+l_math_style_name_index[cramped_script_script_style] = lua_key_index(crampedscriptscript)
 
 #define set_l_dir_par_index \
-l_dir_par_index[0] = lua_key_index(TLT);\
-l_dir_par_index[1] = lua_key_index(TRT);\
-l_dir_par_index[2] = lua_key_index(LTL);\
-l_dir_par_index[3] = lua_key_index(RTT);\
-l_dir_par_index[4] = lua_key_index(TLT);\
-l_dir_par_index[5] = lua_key_index(TRT);\
-l_dir_par_index[6] = lua_key_index(LTL);\
-l_dir_par_index[7] = lua_key_index(RTT);\
+l_dir_par_index[dir_TLT]   = lua_key_index(TLT);\
+l_dir_par_index[dir_TRT]   = lua_key_index(TRT);\
+l_dir_par_index[dir_LTL]   = lua_key_index(LTL);\
+l_dir_par_index[dir_RTT]   = lua_key_index(RTT);\
+l_dir_par_index[dir_TLT+3] = lua_key_index(TLT);\
+l_dir_par_index[dir_TRT+3] = lua_key_index(TRT);\
+l_dir_par_index[dir_LTL+3] = lua_key_index(LTL);\
+l_dir_par_index[dir_RTT+3] = lua_key_index(RTT);\
 
 #define set_l_dir_text_index \
-l_dir_text_index[0] = lua_key_index(mTLT);\
-l_dir_text_index[1] = lua_key_index(mTRT);\
-l_dir_text_index[2] = lua_key_index(mLTL);\
-l_dir_text_index[3] = lua_key_index(mRTT);\
-l_dir_text_index[4] = lua_key_index(pTLT);\
-l_dir_text_index[5] = lua_key_index(pTRT);\
-l_dir_text_index[6] = lua_key_index(pLTL);\
-l_dir_text_index[7] = lua_key_index(pRTT);\
+l_dir_text_index[dir_TLT]   = lua_key_index(mTLT);\
+l_dir_text_index[dir_TRT]   = lua_key_index(mTRT);\
+l_dir_text_index[dir_LTL]   = lua_key_index(mLTL);\
+l_dir_text_index[dir_RTT]   = lua_key_index(mRTT);\
+l_dir_text_index[dir_TLT+3] = lua_key_index(pTLT);\
+l_dir_text_index[dir_TRT+3] = lua_key_index(pTRT);\
+l_dir_text_index[dir_LTL+3] = lua_key_index(pLTL);\
+l_dir_text_index[dir_RTT+3] = lua_key_index(pRTT);\
 
 #define img_parms_max     25
 #define img_pageboxes_max  6
diff --git a/source/texk/web2c/luatexdir/tex/directions.h b/source/texk/web2c/luatexdir/tex/directions.h
index 8fe126bdb..7ab524a1e 100644
--- a/source/texk/web2c/luatexdir/tex/directions.h
+++ b/source/texk/web2c/luatexdir/tex/directions.h
@@ -30,11 +30,6 @@
     extern const char *dir_strings[128];
 */
 
-#  define dir_TLT  0 /* maybe use this one as unset value */
-#  define dir_TRT  1 /* or should we avoid that one because it's a signal too */
-#  define dir_LTL  2
-#  define dir_RTT  3
-
 extern const char *dir_strings[8];
 
 extern int dir_swap;
diff --git a/source/texk/web2c/luatexdir/tex/equivalents.h b/source/texk/web2c/luatexdir/tex/equivalents.h
index ba4b40428..1289ab70c 100644
--- a/source/texk/web2c/luatexdir/tex/equivalents.h
+++ b/source/texk/web2c/luatexdir/tex/equivalents.h
@@ -478,6 +478,32 @@ typedef enum {
     fin_row_group        /* box code for a provisory line in an alignment */
 } tex_group_codes;
 
+typedef enum {
+    new_graf_par_code = 0,
+    local_box_par_code,
+    hmode_par_par_code,
+    penalty_par_code,
+    math_par_code,
+} tex_par_codes ;
+
+typedef enum {
+    display_style = 0,           /* |subtype| for \.{\\displaystyle} */
+    cramped_display_style,       /* |subtype| for \.{\\crampeddisplaystyle} */
+    text_style,                  /* |subtype| for \.{\\textstyle} */
+    cramped_text_style,          /* |subtype| for \.{\\crampedtextstyle} */
+    script_style,                /* |subtype| for \.{\\scriptstyle} */
+    cramped_script_style,        /* |subtype| for \.{\\crampedscriptstyle} */
+    script_script_style,         /* |subtype| for \.{\\scriptscriptstyle} */
+    cramped_script_script_style, /* |subtype| for \.{\\crampedscriptscriptstyle} */
+} math_style_subtypes;
+
+typedef enum {
+    dir_TLT = 0,
+    dir_TRT,
+    dir_LTL,
+    dir_RTT,
+} dir_codes;
+
 #  define max_group_code local_box_group                        /* which is wrong, but is what the web says */
 
 extern int cur_cmd;                                             /* current command set by |get_next| */
diff --git a/source/texk/web2c/luatexdir/tex/maincontrol.w b/source/texk/web2c/luatexdir/tex/maincontrol.w
index 8f423c63a..690952b2b 100644
--- a/source/texk/web2c/luatexdir/tex/maincontrol.w
+++ b/source/texk/web2c/luatexdir/tex/maincontrol.w
@@ -1499,7 +1499,7 @@ void new_graf(boolean indented)
     mode = hmode;
     space_factor = 1000;
     /* LOCAL: Add local paragraph node */
-    tail_append(make_local_par_node(0));
+    tail_append(make_local_par_node(new_graf_par_code));
     if (indented) {
         p = new_null_box();
         box_dir(p) = par_direction;
@@ -1869,7 +1869,7 @@ void build_local_box(void)
         eq_define(local_right_box_base, box_ref_cmd, p);
     if (abs(mode) == hmode) {
         /* LOCAL: Add local paragraph node */
-        tail_append(make_local_par_node(1));
+        tail_append(make_local_par_node(local_box_par_code));
     }
     eq_word_define(int_base + no_local_whatsits_code, no_local_whatsits + 1);
 }
@@ -2830,7 +2830,7 @@ void fixup_directions(void)
         }
         if (temp_no_whatsits != 0) {
             /* LOCAL: Add local paragraph node */
-            tail_append(make_local_par_node(2));
+            tail_append(make_local_par_node(hmode_par_par_code));
         }
     }
 }
@@ -2940,7 +2940,7 @@ void assign_internal_value(int a, halfword p, int val)
             ((p == (int_base + local_inter_line_penalty_code)) ||
              (p == (int_base + local_broken_penalty_code)))) {
             /* LOCAL: Add local paragraph node */
-            tail_append(make_local_par_node(3));
+            tail_append(make_local_par_node(penalty_par_code));
 
             eq_word_define(int_base + no_local_whatsits_code,
                            no_local_whatsits + 1);
diff --git a/source/texk/web2c/luatexdir/tex/mlist.w b/source/texk/web2c/luatexdir/tex/mlist.w
index 32a8c9b61..bceb4e88a 100644
--- a/source/texk/web2c/luatexdir/tex/mlist.w
+++ b/source/texk/web2c/luatexdir/tex/mlist.w
@@ -1610,9 +1610,6 @@ void run_mlist_to_hlist(halfword p, boolean penalties, int mstyle)
         }
         alink(p) = null ;
         nodelist_to_lua(L, p);
-        /*
-            lua_pushstring(L, math_style_names[mstyle]);
-        */
         lua_push_math_style_name(L,mstyle);
         lua_pushboolean(L, penalties);
         if (lua_pcall(L, 3, 1, 0) != 0) {            /* 3 args, 1 result */
diff --git a/source/texk/web2c/luatexdir/tex/texmath.h b/source/texk/web2c/luatexdir/tex/texmath.h
index 90ae5f20a..f36644e99 100644
--- a/source/texk/web2c/luatexdir/tex/texmath.h
+++ b/source/texk/web2c/luatexdir/tex/texmath.h
@@ -91,17 +91,6 @@ void unsave_math_data(int lvl);
   or |denom_style|).
 */
 
-typedef enum {
-    display_style = 0,          /* |subtype| for \.{\\displaystyle} */
-    cramped_display_style,      /* |subtype| for \.{\\crampeddisplaystyle} */
-    text_style,                 /* |subtype| for \.{\\textstyle} */
-    cramped_text_style,         /* |subtype| for \.{\\crampedtextstyle} */
-    script_style,               /* |subtype| for \.{\\scriptstyle} */
-    cramped_script_style,       /* |subtype| for \.{\\crampedscriptstyle} */
-    script_script_style,        /* |subtype| for \.{\\scriptscriptstyle} */
-    cramped_script_script_style,        /* |subtype| for \.{\\crampedscriptscriptstyle} */
-} math_style_subtypes;
-
 extern const char *math_style_names[];
 
 #  define cramped 1             /* add this to an uncramped style if you want to cramp it */
diff --git a/source/texk/web2c/luatexdir/tex/texmath.w b/source/texk/web2c/luatexdir/tex/texmath.w
index abfd08db5..32bc134a4 100644
--- a/source/texk/web2c/luatexdir/tex/texmath.w
+++ b/source/texk/web2c/luatexdir/tex/texmath.w
@@ -2137,8 +2137,8 @@ static void resume_after_display(void)
     push_nest();
     mode = hmode;
     space_factor = 1000;
-    tail_append(make_local_par_node(4)); /* this needs to be intercepted in
-                                            the display math start ! */
+    /* this needs to be intercepted in the display math start ! */
+    tail_append(make_local_par_node(penalty_par_code));
     get_x_token();
     if (cur_cmd != spacer_cmd)
         back_input();
-- 
GitLab