diff options
Diffstat (limited to 'source')
95 files changed, 3182 insertions, 2873 deletions
diff --git a/source/luametatex/CMakeLists.txt b/source/luametatex/CMakeLists.txt index a5021595f..13a7770c5 100644 --- a/source/luametatex/CMakeLists.txt +++ b/source/luametatex/CMakeLists.txt @@ -14,7 +14,7 @@ include(GNUInstallDirs) # optionals at some time, but for now we enable them (there is not not much code involved). The # idea behind thes eoptionals is that we have very simple (!) interfaces, delegating as much as # possible to Lua. We will *not* add interfaces with many bindings because that will introduce -# dependencies (and looking at e.g. LuaTeX build updates shows thatc clearly: a no-go). +# dependencies (and looking at e.g. LuaTeX build updates shows that clearly: a no-go). set(LMT_KPSE_TOO 1) # In case we want to manage MKII scripts (etc) with mtxrun. set(LMT_HB_TOO 1) # Maybe handy for Idris' font development (old converted ffi stuff) @@ -177,6 +177,10 @@ if (CMAKE_C_COMPILER_ID STREQUAL "Clang") -Wno-missing-noreturn -Wno-implicit-fallthrough # -Wno-format + -Wno-reserved-identifier + -Wno-date-time + -Wno-format-nonliteral + -Wno-float-equal ) endif() diff --git a/source/luametatex/cmake/luasocket.cmake b/source/luametatex/cmake/luasocket.cmake index 8489b0a80..e36f1f7e6 100644 --- a/source/luametatex/cmake/luasocket.cmake +++ b/source/luametatex/cmake/luasocket.cmake @@ -51,6 +51,14 @@ if (WIN32) ) endif() +# It seems to depend on the mingw installation: + +if (__MINGW64_TOOLCHAIN_) + target_compile_definitions(luasocket PRIVATE + LUASOCKET_INET_PTON + ) +endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_definitions(luasocket PRIVATE LUASOCKET_INET_PTON diff --git a/source/luametatex/cmake/mingw-32.cmake b/source/luametatex/cmake/mingw-32.cmake index ef5001226..6a06431d5 100644 --- a/source/luametatex/cmake/mingw-32.cmake +++ b/source/luametatex/cmake/mingw-32.cmake @@ -1,6 +1,6 @@ -if (NOT __MINGW64_TOOLCHAIN_) - add_compile_options(-DLUASOCKET_INET_PTON) -endif() +# if (NOT __MINGW64_TOOLCHAIN_) +# add_compile_options(-DLUASOCKET_INET_PTON) +# endif() set(CMAKE_SYSTEM_NAME Windows) set(TOOLCHAIN_PREFIX i686-w64-mingw32) diff --git a/source/luametatex/cmake/mingw-64.cmake b/source/luametatex/cmake/mingw-64.cmake index c57bed871..294ef5e55 100644 --- a/source/luametatex/cmake/mingw-64.cmake +++ b/source/luametatex/cmake/mingw-64.cmake @@ -1,6 +1,6 @@ -if (NOT __MINGW64_TOOLCHAIN_) - add_compile_options(-DLUASOCKET_INET_PTON) -endif() +# if (NOT __MINGW64_TOOLCHAIN_) +# add_compile_options(-DLUASOCKET_INET_PTON) +# endif() set(CMAKE_SYSTEM_NAME Windows) set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) diff --git a/source/luametatex/cmake/mp.cmake b/source/luametatex/cmake/mp.cmake index 1d064101d..22680cdb7 100644 --- a/source/luametatex/cmake/mp.cmake +++ b/source/luametatex/cmake/mp.cmake @@ -38,6 +38,12 @@ target_compile_definitions(mp PUBLIC DECNUMDIGITS=1000 ) +if (CMAKE_C_COMPILER_ID STREQUAL "Clang") + target_compile_options(mp PRIVATE + -Wno-unreachable-code-break + ) +endif() + if (NOT MSVC) target_compile_options(mp PRIVATE -Wno-unused-parameter @@ -46,5 +52,5 @@ if (NOT MSVC) -Wno-cast-align # for decnumber with lto -fno-strict-aliasing -) + ) endif() diff --git a/source/luametatex/source/libraries/avl/avl.c b/source/luametatex/source/libraries/avl/avl.c index 46e0bcd50..e1c18ceb5 100644 --- a/source/luametatex/source/libraries/avl/avl.c +++ b/source/luametatex/source/libraries/avl/avl.c @@ -1442,7 +1442,7 @@ avl_code_t avl_del_first(avl_tree t, void **backup) if (t && t->root) { avl_code_t rv; if (backup) { - ptr_handler h = { NULL, OP_BACKUP }; + ptr_handler h = { NULL, OP_BACKUP, 0 }; rv = node_del_first(t, &h); *backup = h.ptr; } else { @@ -1460,7 +1460,7 @@ avl_code_t avl_del_last(avl_tree t, void **backup) if (backup == NULL) { return node_del_last(t, NULL); } else { - ptr_handler h = { NULL, OP_BACKUP }; + ptr_handler h = { NULL, OP_BACKUP, 0 }; avl_code_t rv = node_del_last(t, &h); *backup = h.ptr; return rv; @@ -1527,7 +1527,7 @@ void avl_cat(avl_tree t0, avl_tree t1) return; } else if (t0->root) { int delta = depth(t1->root) - depth(t0->root); - ptr_handler h = { NULL, OP_DETACH }; + ptr_handler h = { NULL, OP_DETACH, 0 }; if (delta <= 0) { if (node_del_first (t1, &h) == 2) { --delta; @@ -1559,13 +1559,13 @@ void avl_cat(avl_tree t0, avl_tree t1) avl_code_t avl_split(const void *item, avl_tree t, avl_tree t0, avl_tree t1) { if (t && t->root) { + avl_compare_func cmp = t->compare; + avl_node *a, *p, *sn; /* sn: split node */ + int k, na, an[AVL_STACK_CAPACITY]; t0->root = NULL; t1->root = NULL; t0->count = 0; t1->count = 0; - avl_compare_func cmp = t->compare; - avl_node *a, *p, *sn; /* sn: split node */ - int k, na, an[AVL_STACK_CAPACITY]; /* invariant: [na]= size of tree rooted at [a] plus one */ for (a = t->root, na = (int) (t->count + 1), k = 0;;) { int d_ = item_compare(cmp, t, item, get_item(a)); diff --git a/source/luametatex/source/libraries/hnj/hnjhyphen.c b/source/luametatex/source/libraries/hnj/hnjhyphen.c index ad9d87683..cde68cb93 100644 --- a/source/luametatex/source/libraries/hnj/hnjhyphen.c +++ b/source/luametatex/source/libraries/hnj/hnjhyphen.c @@ -552,7 +552,7 @@ void hnj_dictionary_load(hjn_dictionary *dict, const unsigned char *f, int trace char *newpat_pat = lookup_pattern(dict->merged, word, l1); if (! newpat_pat) { char *neworg; - unsigned char *newword = (unsigned char *) hnj_malloc((size_t) (l1 + 1)); + unsigned char *newword = (unsigned char *) hnj_malloc(l1 + 1); int e1 = 0; strncpy((char *) newword, (char *) word, (size_t) l1); newword[l1] = 0; @@ -561,7 +561,7 @@ void hnj_dictionary_load(hjn_dictionary *dict, const unsigned char *f, int trace e1++; } } - neworg = hnj_malloc((size_t) (l1 + 2 - e1)); + neworg = hnj_malloc(l1 + 2 - e1); /*tex Fill with right amount of zeros: */ sprintf(neworg, "%0*d", l1 + 1 - e1, 0); insert_pattern(dict->merged, newword, combine_patterns(neworg, subpat_pat), trace); diff --git a/source/luametatex/source/lua/lmtcallbacklib.c b/source/luametatex/source/lua/lmtcallbacklib.c index 8724cdd6f..a971b5e57 100644 --- a/source/luametatex/source/lua/lmtcallbacklib.c +++ b/source/luametatex/source/lua/lmtcallbacklib.c @@ -151,8 +151,8 @@ static int callbacklib_aux_run(lua_State *L, int id, int special, const char *va } else if (special == 2) { narg++; } + lmt_lua_state.saved_callback_count++; { - lmt_lua_state.saved_callback_count++; int i = lua_pcall(L, narg, nres, base); if (i) { /*tex diff --git a/source/luametatex/source/lua/lmtenginelib.c b/source/luametatex/source/lua/lmtenginelib.c index f8df06657..fef2ed819 100644 --- a/source/luametatex/source/lua/lmtenginelib.c +++ b/source/luametatex/source/lua/lmtenginelib.c @@ -320,8 +320,8 @@ static void enginelib_show_credits(void) "and has been extended in many aspects.\n" "\n" "There is a lightweight subsystem for optional libraries but here we also delegate as much\n" - "as possibe to Lua. A few interfaces are provided bny default, others can be added using a\n" - "simple foreign interface subsystem. Although this is provided an dconsidered part of the\n" + "as possible to Lua. A few interfaces are provided by default, others can be added using a\n" + "simple foreign interface subsystem. Although this is provided and considered part of the\n" "LuaMetaTeX engine it is not something ConTeXt depends (and will) depend on.\n" "\n" "version : " luametatex_version_string " | " LMT_TOSTRING(luametatex_development_id) "\n" @@ -433,7 +433,7 @@ static void enginelib_check_option(char **options, int i) */ -const char *suffixes[] = { "lmt", "lua", NULL }; +static const char *suffixes[] = { "lmt", "lua", NULL }; static void enginelib_parse_options(void) { diff --git a/source/luametatex/source/lua/lmtfontlib.c b/source/luametatex/source/lua/lmtfontlib.c index 5004a9710..953d3bcd1 100644 --- a/source/luametatex/source/lua/lmtfontlib.c +++ b/source/luametatex/source/lua/lmtfontlib.c @@ -248,11 +248,13 @@ static void fontlib_aux_font_char_from_lua(lua_State *L, halfword f, int i, int { if (lua_istable(L, -1)) { /*tex We need an intermediate veriable: */ - scaled target; - int state; + int target; + const char *starget; charinfo *co = tex_get_charinfo(f, i); - set_any_field_by_index(state, callback); - set_charinfo_tag(co, state ? callback_tag : 0); + set_numeric_field_by_index(target, tag, 0); + set_charinfo_tag(co, target ? tex_char_checked_tag(target) : 0); + set_any_field_by_index(target, callback); + set_charinfo_tag(co, target ? callback_tag : 0); set_numeric_field_by_index(target, width, 0); set_charinfo_width(co, target); set_numeric_field_by_index(target, height, 0); @@ -263,19 +265,20 @@ static void fontlib_aux_font_char_from_lua(lua_State *L, halfword f, int i, int set_charinfo_italic(co, target); set_numeric_field_by_index(target, expansion, 1000); set_charinfo_expansion(co, target); + set_numeric_field_by_index(target, compression, target); + set_charinfo_compression(co, target); set_numeric_field_by_index(target, leftprotrusion, 0); set_charinfo_leftprotrusion(co, target); set_numeric_field_by_index(target, rightprotrusion, 0); set_charinfo_rightprotrusion(co, target); - set_charinfo_tag(co, 0); if (has_math) { tex_char_malloc_mathinfo(co); set_numeric_field_by_index(target, smaller, 0); set_charinfo_smaller(co, target); set_numeric_field_by_index(target, mirror, 0); set_charinfo_mirror(co, target); - set_numeric_field_by_index(target, vitalic, 0); - set_charinfo_vertical_italic(co, target); + set_numeric_field_by_index(target, flataccent, INT_MIN); + set_charinfo_flat_accent(co, target); /* */ set_numeric_field_by_index(target, topleft, 0); set_charinfo_top_left_kern(co, target); @@ -304,83 +307,58 @@ static void fontlib_aux_font_char_from_lua(lua_State *L, halfword f, int i, int set_charinfo_top_anchor(co, target); set_numeric_field_by_index(target, bottomanchor, INT_MIN); set_charinfo_bottom_anchor(co, target); - set_numeric_field_by_index(target, flataccent, INT_MIN); - set_charinfo_flat_accent(co, target); + /* */ + set_string_field_by_index(starget, innerlocation); + if (lua_key_eq(starget, left)) { + set_charinfo_tag(co, inner_left_tag); + } else if (lua_key_eq(starget, right)) { + set_charinfo_tag(co, inner_right_tag); + } + set_numeric_field_by_index(target, innerxoffset, INT_MIN); + set_charinfo_inner_x_offset(co, target); + set_numeric_field_by_index(target, inneryoffset, INT_MIN); + set_charinfo_inner_y_offset(co, target); + /* */ set_numeric_field_by_index(target, next, -1); if (target >= 0) { set_charinfo_tag(co, list_tag); - set_charinfo_remainder(co, target); + set_charinfo_next(co, target); } - lua_push_key(extensible); - switch (lua_rawget(L, -2)) { - case LUA_TTABLE: - { - int top, bottom, middle, extender; - set_numeric_field_by_index(top, top, 0); - set_numeric_field_by_index(bottom, bottom, 0); - set_numeric_field_by_index(middle, middle, 0); - set_numeric_field_by_index(extender, extender, 0); - if (top || bottom || middle || extender) { - set_charinfo_tag(co, extension_tag); - tex_set_charinfo_extensible(co, top, bottom, middle, extender); - } else { - tex_formatted_warning("font", "lua-loaded font %s char U+%X has an invalid extensible field", font_name(f), (int) i); - } - } - break; - case LUA_TBOOLEAN: - if (lua_toboolean(L, -2)) { - set_charinfo_tag(co, extend_last_tag); - } - break; - } - lua_pop(L, 1); - lua_push_key(hparts); + set_boolean_field_by_index(target, extensible, 0); + if (target) { + set_charinfo_tag(co, extend_last_tag); + } + lua_push_key(parts); if (lua_rawget(L, -2) == LUA_TTABLE) { - set_charinfo_tag(co, extension_tag); - tex_set_charinfo_horizontal_parts(co, NULL); + set_charinfo_tag(co, extensible_tag); + tex_set_charinfo_extensible_recipe(co, NULL); for (lua_Integer k = 1; ; k++) { if (lua_rawgeti(L, -1, k) == LUA_TTABLE) { int glyph, startconnect, endconnect, advance, extender; - extinfo *h; set_numeric_field_by_index(glyph, glyph, 0); set_numeric_field_by_index(extender, extender, 0); set_numeric_field_by_index(startconnect, start, 0); set_numeric_field_by_index(endconnect, end, 0); set_numeric_field_by_index(advance, advance, 0); - h = tex_new_charinfo_part(glyph, startconnect, endconnect, advance, extender); - tex_add_charinfo_horizontal_part(co, h); - lua_pop(L, 1); - } else { - lua_pop(L, 1); - break; - } - } - } - lua_pop(L, 1); - lua_push_key(vparts); - if (lua_rawget(L, -2) == LUA_TTABLE) { - set_charinfo_tag(co, extension_tag); - tex_set_charinfo_vertical_parts(co, NULL); - for (lua_Integer k = 1; ; k++) { - if (lua_rawgeti(L, -1, k) == LUA_TTABLE) { - int glyph, startconnect, endconnect, advance, extender; - extinfo *h; - set_numeric_field_by_index(glyph, glyph, 0); - set_numeric_field_by_index(extender, extender, 0); - set_numeric_field_by_index(startconnect, start, 0); - set_numeric_field_by_index(endconnect, end, 0); - set_numeric_field_by_index(advance, advance, 0); - h = tex_new_charinfo_part(glyph, startconnect, endconnect, advance, extender); - tex_add_charinfo_vertical_part(co, h); + tex_append_charinfo_extensible_recipe(co, glyph, startconnect, endconnect, advance, extender); lua_pop(L, 1); } else { lua_pop(L, 1); break; } } + lua_pop(L, 1); + set_numeric_field_by_index(target, partsitalic, 0); + set_charinfo_extensible_italic(co, target); + set_string_field_by_index(starget, partsorientation); + if (lua_key_eq(starget, horizontal)) { + set_charinfo_tag(co, horizontal_tag); + } else if (lua_key_eq(starget, vertical)) { + set_charinfo_tag(co, vertical_tag); + } + } else { + lua_pop(L, 1); } - lua_pop(L, 1); lua_push_key(mathkerns); if (lua_rawget(L, -2) == LUA_TTABLE) { fontlib_aux_store_math_kerns(L, lua_key_index(topleft), co, top_left_kern); @@ -399,6 +377,7 @@ static void fontlib_aux_font_char_from_lua(lua_State *L, halfword f, int i, int kerninfo *ckerns = lmt_memory_calloc((size_t) count + 1, sizeof(kerninfo)); if (ckerns) { int ctr = 0; + set_charinfo_tag(co, kerns_tag); /*tex Traverse the hash. */ lua_pushnil(L); while (lua_next(L, -2)) { @@ -454,6 +433,7 @@ static void fontlib_aux_font_char_from_lua(lua_State *L, halfword f, int i, int ligatureinfo *cligs = lmt_memory_calloc((size_t) count + 1, sizeof(ligatureinfo)); if (cligs) { int ctr = 0; + set_charinfo_tag(co, ligatures_tag); /*tex Traverse the hash. */ lua_pushnil(L); while (lua_next(L, -2)) { @@ -702,7 +682,7 @@ static int lmt_characters_from_lua(lua_State *L, int f) int i = lmt_tointeger(L, -2); if (i >= 0 && lua_istable(L, -1)) { todo++; - if (! quick_char_exists(f, i)) { + if (! tex_char_exists(f, i)) { num++; if (i > ec) { ec = i; @@ -728,13 +708,12 @@ static int lmt_characters_from_lua(lua_State *L, int f) if (lua_type(L, -2) == LUA_TNUMBER) { int i = lmt_tointeger(L, -2); if (i >= 0) { - if (quick_char_exists(f, i)) { + if (tex_char_exists(f, i)) { charinfo *co = tex_get_charinfo(f, i); set_charinfo_ligatures(co, NULL); set_charinfo_kerns(co, NULL); set_charinfo_math(co, NULL); - tex_set_charinfo_vertical_parts(co, NULL); - tex_set_charinfo_horizontal_parts(co, NULL); + tex_set_charinfo_extensible_recipe(co, NULL); } fontlib_aux_font_char_from_lua(L, f, i, ! no_math); } diff --git a/source/luametatex/source/lua/lmtinterface.h b/source/luametatex/source/lua/lmtinterface.h index e761252a8..707d3aefb 100644 --- a/source/luametatex/source/lua/lmtinterface.h +++ b/source/luametatex/source/lua/lmtinterface.h @@ -392,33 +392,29 @@ make_lua_key(L, above);\ make_lua_key(L, abovedisplayshortskip);\ make_lua_key(L, abovedisplayskip);\ make_lua_key(L, accent);\ -make_lua_key(L, AccentBaseHeight);\ +make_lua_key(L, accentbasedepth);\ make_lua_key(L, AccentBaseDepth);\ make_lua_key(L, accentbaseheight);\ -make_lua_key(L, accentbasedepth);\ -make_lua_key(L, AccentTopShiftUp);\ -make_lua_key(L, accenttopshiftup);\ -make_lua_key(L, AccentTopOvershoot);\ -make_lua_key(L, accenttopovershoot);\ -make_lua_key(L, adapted);\ -make_lua_key(L, FlattenedAccentTopShiftUp);\ -make_lua_key(L, flattenedaccenttopshiftup);\ -make_lua_key(L, AccentBottomShiftDown);\ -make_lua_key(L, accentbottomshiftdown);\ -make_lua_key(L, AccentBottomOvershoot);\ +make_lua_key(L, AccentBaseHeight);\ make_lua_key(L, accentbottomovershoot);\ -make_lua_key(L, AccentSuperscriptDrop);\ -make_lua_key(L, accentsuperscriptdrop);\ -make_lua_key(L, AccentSuperscriptPercent);\ -make_lua_key(L, accentsuperscriptpercent);\ -make_lua_key(L, AccentExtendMargin);\ +make_lua_key(L, AccentBottomOvershoot);\ +make_lua_key(L, accentbottomshiftdown);\ +make_lua_key(L, AccentBottomShiftDown);\ make_lua_key(L, accentextendmargin);\ -make_lua_key(L, FlattenedAccentBottomShiftDown);\ -make_lua_key(L, flattenedaccentbottomshiftdown);\ +make_lua_key(L, AccentExtendMargin);\ make_lua_key(L, accentkern);\ +make_lua_key(L, accentsuperscriptdrop);\ +make_lua_key(L, AccentSuperscriptDrop);\ +make_lua_key(L, accentsuperscriptpercent);\ +make_lua_key(L, AccentSuperscriptPercent);\ +make_lua_key(L, accenttopovershoot);\ +make_lua_key(L, AccentTopOvershoot);\ +make_lua_key(L, accenttopshiftup);\ +make_lua_key(L, AccentTopShiftUp);\ make_lua_key(L, accentvariant);\ make_lua_key(L, active);\ make_lua_key(L, active_char);\ +make_lua_key(L, adapted);\ make_lua_key(L, adapttoleftsize);\ make_lua_key(L, adapttorightsize);\ make_lua_key(L, additional);\ @@ -437,12 +433,12 @@ make_lua_key(L, afterdisplaypenalty);\ make_lua_key(L, afteroutput);\ make_lua_key(L, aliased);\ make_lua_key(L, align);\ -make_lua_key(L, alignrecord);\ -make_lua_key(L, alignstack);\ make_lua_key(L, alignhead);\ make_lua_key(L, alignment);\ make_lua_key(L, alignment_tab);\ +make_lua_key(L, alignrecord);\ make_lua_key(L, alignset);\ +make_lua_key(L, alignstack);\ make_lua_key(L, alsosimple);\ make_lua_key(L, anchor);\ make_lua_key(L, argument);\ @@ -483,16 +479,16 @@ make_lua_key(L, binpunctspacing);\ make_lua_key(L, binradspacing);\ make_lua_key(L, binrelspacing);\ make_lua_key(L, boolean);\ -make_lua_key(L, bottomaccent);\ -make_lua_key(L, bottomanchor);\ -make_lua_key(L, bottomaccentvariant);\ make_lua_key(L, bothflexible);\ make_lua_key(L, bottom);\ +make_lua_key(L, bottomaccent);\ +make_lua_key(L, bottomaccentvariant);\ +make_lua_key(L, bottomanchor);\ make_lua_key(L, bottomleft);\ make_lua_key(L, bottomlevel);\ make_lua_key(L, bottommargin);\ -make_lua_key(L, bottomright);\ make_lua_key(L, bottomovershoot);\ +make_lua_key(L, bottomright);\ make_lua_key(L, boundary);\ make_lua_key(L, box);\ make_lua_key(L, broken);\ @@ -504,8 +500,8 @@ make_lua_key(L, callback);\ make_lua_key(L, cancel);\ make_lua_key(L, cardinal);\ make_lua_key(L, case_shift);\ -make_lua_key(L, catalog);\ make_lua_key(L, Catalog);\ +make_lua_key(L, catalog);\ make_lua_key(L, catcode_table);\ make_lua_key(L, category);\ make_lua_key(L, cell);\ @@ -539,6 +535,7 @@ make_lua_key(L, command);\ make_lua_key(L, comment);\ make_lua_key(L, compactmath);\ make_lua_key(L, compound);\ +make_lua_key(L, compression);\ make_lua_key(L, condition);\ make_lua_key(L, conditional);\ make_lua_key(L, conditionalmathskip);\ @@ -567,16 +564,16 @@ make_lua_key(L, define_font);\ make_lua_key(L, define_lua_call);\ make_lua_key(L, degree);\ make_lua_key(L, degreevariant);\ +make_lua_key(L, delimited);\ make_lua_key(L, DelimitedSubFormulaMinHeight);\ make_lua_key(L, delimiter);\ -make_lua_key(L, delimited);\ make_lua_key(L, delimiter_number);\ -make_lua_key(L, delimiterpercent);\ -make_lua_key(L, DelimiterPercent);\ -make_lua_key(L, delimitershortfall);\ -make_lua_key(L, DelimiterShortfall);\ make_lua_key(L, delimiterover);\ make_lua_key(L, delimiterovervariant);\ +make_lua_key(L, DelimiterPercent);\ +make_lua_key(L, delimiterpercent);\ +make_lua_key(L, DelimiterShortfall);\ +make_lua_key(L, delimitershortfall);\ make_lua_key(L, delimiterunder);\ make_lua_key(L, delimiterundervariant);\ make_lua_key(L, delta);\ @@ -657,11 +654,15 @@ make_lua_key(L, fixedboth);\ make_lua_key(L, fixedbottom);\ make_lua_key(L, fixedtop);\ make_lua_key(L, flags);\ -make_lua_key(L, FlattenedAccentBaseHeight);\ -make_lua_key(L, flattenedaccentbaseheight);\ -make_lua_key(L, FlattenedAccentBaseDepth);\ -make_lua_key(L, flattenedaccentbasedepth);\ make_lua_key(L, flataccent);\ +make_lua_key(L, flattenedaccentbasedepth);\ +make_lua_key(L, FlattenedAccentBaseDepth);\ +make_lua_key(L, flattenedaccentbaseheight);\ +make_lua_key(L, FlattenedAccentBaseHeight);\ +make_lua_key(L, flattenedaccentbottomshiftdown);\ +make_lua_key(L, FlattenedAccentBottomShiftDown);\ +make_lua_key(L, flattenedaccenttopshiftup);\ +make_lua_key(L, FlattenedAccentTopShiftUp);\ make_lua_key(L, float);\ make_lua_key(L, followedbyspace);\ make_lua_key(L, font);\ @@ -735,15 +736,14 @@ make_lua_key(L, horizontalmathkern);\ make_lua_key(L, hrule);\ make_lua_key(L, hsize);\ make_lua_key(L, hskip);\ -make_lua_key(L, hparts);\ make_lua_key(L, hyphenate);\ make_lua_key(L, hyphenated);\ make_lua_key(L, hyphenation);\ make_lua_key(L, hyphenationmode);\ make_lua_key(L, hyphenchar);\ make_lua_key(L, id);\ -make_lua_key(L, ifstack);\ make_lua_key(L, if_test);\ +make_lua_key(L, ifstack);\ make_lua_key(L, ignore);\ make_lua_key(L, ignore_something);\ make_lua_key(L, ignorebounds);\ @@ -754,13 +754,14 @@ make_lua_key(L, immutable);\ make_lua_key(L, indent);\ make_lua_key(L, indentskip);\ make_lua_key(L, index);\ -make_lua_key(L, Info);\ make_lua_key(L, info);\ +make_lua_key(L, Info);\ make_lua_key(L, inner);\ make_lua_key(L, innerbinspacing);\ make_lua_key(L, innerclosespacing);\ make_lua_key(L, innerfracspacing);\ make_lua_key(L, innerinnerspacing);\ +make_lua_key(L, innerlocation);\ make_lua_key(L, innermiddlespacing);\ make_lua_key(L, inneropenspacing);\ make_lua_key(L, inneropspacing);\ @@ -768,6 +769,8 @@ make_lua_key(L, innerordspacing);\ make_lua_key(L, innerpunctspacing);\ make_lua_key(L, innerradspacing);\ make_lua_key(L, innerrelspacing);\ +make_lua_key(L, innerxoffset);\ +make_lua_key(L, inneryoffset);\ make_lua_key(L, input);\ make_lua_key(L, insert);\ make_lua_key(L, insertheights);\ @@ -791,8 +794,8 @@ make_lua_key(L, internal_mu_glue_reference);\ make_lua_key(L, internal_toks);\ make_lua_key(L, internal_toks_reference);\ make_lua_key(L, internaldimension);\ -make_lua_key(L, internalinteger);\ make_lua_key(L, internalgluespec);\ +make_lua_key(L, internalinteger);\ make_lua_key(L, internalmugluespec);\ make_lua_key(L, invalid_char);\ make_lua_key(L, italic);\ @@ -801,7 +804,6 @@ make_lua_key(L, italiccorrection);\ make_lua_key(L, iterator_value);\ make_lua_key(L, kern);\ make_lua_key(L, kerns);\ -make_lua_key(L, noadstate);\ make_lua_key(L, language);\ make_lua_key(L, largechar);\ make_lua_key(L, largefamily);\ @@ -863,7 +865,6 @@ make_lua_key(L, make_box);\ make_lua_key(L, mark);\ make_lua_key(L, match);\ make_lua_key(L, math);\ -make_lua_key(L, mathspec);\ make_lua_key(L, math_accent);\ make_lua_key(L, math_char_number);\ make_lua_key(L, math_choice);\ @@ -876,7 +877,6 @@ make_lua_key(L, math_script);\ make_lua_key(L, math_shift);\ make_lua_key(L, math_shift_cs);\ make_lua_key(L, math_style);\ -make_lua_key(L, mathtextchar);\ make_lua_key(L, mathchar);\ make_lua_key(L, mathchoice);\ make_lua_key(L, mathcomponent);\ @@ -885,20 +885,22 @@ make_lua_key(L, mathcontrol);\ make_lua_key(L, mathdir);\ make_lua_key(L, mathfence);\ make_lua_key(L, mathfraction);\ -make_lua_key(L, mathradical);\ make_lua_key(L, mathkerns);\ make_lua_key(L, MathLeading);\ make_lua_key(L, mathoperator);\ make_lua_key(L, mathpack);\ make_lua_key(L, mathpostpenalty);\ make_lua_key(L, mathprepenalty);\ +make_lua_key(L, mathradical);\ make_lua_key(L, mathshapekern);\ make_lua_key(L, mathshift);\ make_lua_key(L, mathsimple);\ make_lua_key(L, mathskip);\ +make_lua_key(L, mathspec);\ make_lua_key(L, mathstack);\ -make_lua_key(L, mathsubformula);\ make_lua_key(L, mathstyle);\ +make_lua_key(L, mathsubformula);\ +make_lua_key(L, mathtextchar);\ make_lua_key(L, medmuskip);\ make_lua_key(L, message);\ make_lua_key(L, middle);\ @@ -934,21 +936,22 @@ make_lua_key(L, nil);\ make_lua_key(L, no);\ make_lua_key(L, no_expand);\ make_lua_key(L, noad);\ +make_lua_key(L, noadstate);\ make_lua_key(L, noalign);\ make_lua_key(L, noaligned);\ make_lua_key(L, noaxis);\ make_lua_key(L, nocheck);\ -make_lua_key(L, nooverflow);\ make_lua_key(L, node);\ make_lua_key(L, nodelist);\ make_lua_key(L, noindent);\ make_lua_key(L, nolimits);\ -make_lua_key(L, nolimitsubfactor);\ make_lua_key(L, NoLimitSubFactor);\ -make_lua_key(L, nolimitsupfactor);\ +make_lua_key(L, nolimitsubfactor);\ make_lua_key(L, NoLimitSupFactor);\ +make_lua_key(L, nolimitsupfactor);\ make_lua_key(L, nomath);\ make_lua_key(L, none);\ +make_lua_key(L, nooverflow);\ make_lua_key(L, normal);\ make_lua_key(L, norule);\ make_lua_key(L, noruling);\ @@ -1024,26 +1027,29 @@ make_lua_key(L, overlayaccent);\ make_lua_key(L, overlayaccentvariant);\ make_lua_key(L, overlinevariant);\ make_lua_key(L, overloaded);\ -make_lua_key(L, page);\ make_lua_key(L, package);\ +make_lua_key(L, page);\ make_lua_key(L, pagediscardshead);\ make_lua_key(L, pagehead);\ make_lua_key(L, pageinserthead);\ -make_lua_key(L, Pages);\ make_lua_key(L, pages);\ +make_lua_key(L, Pages);\ make_lua_key(L, par);\ make_lua_key(L, parameter);\ make_lua_key(L, parameter_reference);\ make_lua_key(L, parameters);\ make_lua_key(L, parfillleftskip);\ make_lua_key(L, parfillrightskip);\ -make_lua_key(L, parinitleftskip);\ -make_lua_key(L, parinitrightskip);\ make_lua_key(L, parfillskip);\ make_lua_key(L, parindent);\ +make_lua_key(L, parinitleftskip);\ +make_lua_key(L, parinitrightskip);\ make_lua_key(L, parshape);\ make_lua_key(L, parskip);\ make_lua_key(L, passive);\ +make_lua_key(L, parts);\ +make_lua_key(L, partsitalic);\ +make_lua_key(L, partsorientation);\ make_lua_key(L, pdfe);\ make_lua_key(L, penalty);\ make_lua_key(L, permanent);\ @@ -1080,25 +1086,25 @@ make_lua_key(L, prevgraf);\ make_lua_key(L, prime);\ make_lua_key(L, PrimeBaselineDropMax);\ make_lua_key(L, primeraise);\ -make_lua_key(L, PrimeRaisePercent);\ make_lua_key(L, primeraisecomposed);\ make_lua_key(L, PrimeRaiseComposedPercent);\ +make_lua_key(L, PrimeRaisePercent);\ make_lua_key(L, primeshiftdrop);\ -make_lua_key(L, PrimeShiftUp);\ make_lua_key(L, primeshiftup);\ +make_lua_key(L, PrimeShiftUp);\ make_lua_key(L, PrimeShiftUpCramped);\ -make_lua_key(L, primespaceafter);\ make_lua_key(L, PrimeSpaceAfter);\ +make_lua_key(L, primespaceafter);\ +make_lua_key(L, primevariant);\ make_lua_key(L, primewidth);\ make_lua_key(L, PrimeWidthPercent);\ -make_lua_key(L, primevariant);\ make_lua_key(L, primitive);\ +make_lua_key(L, properties);\ +make_lua_key(L, proportional);\ make_lua_key(L, protected);\ make_lua_key(L, protected_call);\ make_lua_key(L, protrudechars);\ make_lua_key(L, protrusion);\ -make_lua_key(L, properties);\ -make_lua_key(L, proportional);\ make_lua_key(L, ptr);\ make_lua_key(L, punct);\ make_lua_key(L, punctbinspacing);\ @@ -1119,17 +1125,17 @@ make_lua_key(L, radfracspacing);\ make_lua_key(L, radical);\ make_lua_key(L, radicaldegreeafter);\ make_lua_key(L, radicaldegreebefore);\ -make_lua_key(L, radicalextensibleafter);\ -make_lua_key(L, radicalextensiblebefore);\ -make_lua_key(L, RadicalKernAfterExtensible);\ -make_lua_key(L, RadicalKernBeforeExtensible);\ make_lua_key(L, RadicalDegreeBottomRaisePercent);\ make_lua_key(L, radicaldegreeraise);\ make_lua_key(L, RadicalDisplayStyleVerticalGap);\ +make_lua_key(L, radicalextensibleafter);\ +make_lua_key(L, radicalextensiblebefore);\ make_lua_key(L, RadicalExtraAscender);\ make_lua_key(L, radicalkern);\ make_lua_key(L, RadicalKernAfterDegree);\ +make_lua_key(L, RadicalKernAfterExtensible);\ make_lua_key(L, RadicalKernBeforeDegree);\ +make_lua_key(L, RadicalKernBeforeExtensible);\ make_lua_key(L, radicalrule);\ make_lua_key(L, RadicalRuleThickness);\ make_lua_key(L, radicalvariant);\ @@ -1160,8 +1166,8 @@ make_lua_key(L, register_mu_glue_reference);\ make_lua_key(L, register_toks);\ make_lua_key(L, register_toks_reference);\ make_lua_key(L, registerdimension);\ -make_lua_key(L, registerinteger);\ make_lua_key(L, registergluespec);\ +make_lua_key(L, registerinteger);\ make_lua_key(L, registermugluespec);\ make_lua_key(L, regular);\ make_lua_key(L, rel);\ @@ -1227,18 +1233,18 @@ make_lua_key(L, set_specification);\ make_lua_key(L, shapingpenaltiesmode);\ make_lua_key(L, shapingpenalty);\ make_lua_key(L, shift);\ -make_lua_key(L, shiftedsubscript);\ -make_lua_key(L, shiftedsuperscript);\ make_lua_key(L, shiftedsubprescript);\ +make_lua_key(L, shiftedsubscript);\ make_lua_key(L, shiftedsuperprescript);\ +make_lua_key(L, shiftedsuperscript);\ make_lua_key(L, shorthand_def);\ make_lua_key(L, shrink);\ make_lua_key(L, shrinkorder);\ make_lua_key(L, simple);\ make_lua_key(L, size);\ make_lua_key(L, skewchar);\ -make_lua_key(L, skeweddelimitertolerance);\ make_lua_key(L, SkewedDelimiterTolerance);\ +make_lua_key(L, skeweddelimitertolerance);\ make_lua_key(L, skewedfractionhgap);\ make_lua_key(L, SkewedFractionHorizontalGap);\ make_lua_key(L, SkewedFractionVerticalGap);\ @@ -1252,10 +1258,10 @@ make_lua_key(L, smallfamily);\ make_lua_key(L, some_item);\ make_lua_key(L, source);\ make_lua_key(L, space);\ -make_lua_key(L, SpaceAfterScript);\ make_lua_key(L, spaceafterscript);\ -make_lua_key(L, spacebeforescript);\ +make_lua_key(L, SpaceAfterScript);\ make_lua_key(L, SpaceBeforeScript);\ +make_lua_key(L, spacebeforescript);\ make_lua_key(L, spacefactor);\ make_lua_key(L, spacer);\ make_lua_key(L, spaceshrink);\ @@ -1333,6 +1339,7 @@ make_lua_key(L, supshiftup);\ make_lua_key(L, supsubbottommax);\ make_lua_key(L, surround);\ make_lua_key(L, syllable);\ +make_lua_key(L, tag);\ make_lua_key(L, tabskip);\ make_lua_key(L, tail);\ make_lua_key(L, target);\ @@ -1357,17 +1364,17 @@ make_lua_key(L, tolerant_call);\ make_lua_key(L, tolerant_protected_call);\ make_lua_key(L, top);\ make_lua_key(L, topaccent);\ -make_lua_key(L, topanchor);\ make_lua_key(L, topaccentvariant);\ +make_lua_key(L, topanchor);\ make_lua_key(L, topleft);\ make_lua_key(L, topmargin);\ +make_lua_key(L, topovershoot);\ make_lua_key(L, topright);\ make_lua_key(L, topskip);\ -make_lua_key(L, topovershoot);\ make_lua_key(L, total);\ make_lua_key(L, tracingparagraphs);\ -make_lua_key(L, trailer);\ make_lua_key(L, Trailer);\ +make_lua_key(L, trailer);\ make_lua_key(L, type);\ make_lua_key(L, uchyph);\ make_lua_key(L, uleaders);\ @@ -1413,7 +1420,6 @@ make_lua_key(L, vertical);\ make_lua_key(L, verticalmathkern);\ make_lua_key(L, vextensible);\ make_lua_key(L, vextensiblevariant);\ -make_lua_key(L, vitalic);\ make_lua_key(L, vlist);\ make_lua_key(L, vmode);\ make_lua_key(L, vmodepar);\ @@ -1422,7 +1428,6 @@ make_lua_key(L, void);\ make_lua_key(L, vrule);\ make_lua_key(L, vskip);\ make_lua_key(L, vtop);\ -make_lua_key(L, vparts);\ make_lua_key(L, whatsit);\ make_lua_key(L, widowpenalties);\ make_lua_key(L, widowpenalty);\ @@ -1605,7 +1610,6 @@ extern lmt_keys_info lmt_keys; # define lmt_rounded(d) (lua_Integer) (llround(d)) # define lmt_roundedfloat(f) (lua_Integer) (llround((double) f)) - # define lmt_tolong(L,i) (long) lua_tointeger(L,i) # define lmt_checklong(L,i) (long) luaL_checkinteger(L,i) # define lmt_optlong(L,i,j) (long) luaL_optinteger(L,i,j) diff --git a/source/luametatex/source/lua/lmtlibrary.c b/source/luametatex/source/lua/lmtlibrary.c index ff6822a02..cb51273b5 100644 --- a/source/luametatex/source/lua/lmtlibrary.c +++ b/source/luametatex/source/lua/lmtlibrary.c @@ -71,7 +71,7 @@ int lmt_library_okay(lmt_library lib) /* experiment */ -int librarylib_load(lua_State *L) +static int librarylib_load(lua_State *L) { /* So we permit it in mtxrun (for now, when we test). */ if (lmt_engine_state.lua_only || lmt_engine_state.permit_loadlib) { diff --git a/source/luametatex/source/lua/lmtlibrary.h b/source/luametatex/source/lua/lmtlibrary.h index 40f5f47f4..8367d66ea 100644 --- a/source/luametatex/source/lua/lmtlibrary.h +++ b/source/luametatex/source/lua/lmtlibrary.h @@ -18,7 +18,7 @@ /* void : dlclose(lib) | string: dlerror() */ -typedef void (*lmt_library_function); +typedef void *lmt_library_function; # ifdef _WIN32 diff --git a/source/luametatex/source/lua/lmtluaclib.c b/source/luametatex/source/lua/lmtluaclib.c index 797585aba..bf8888add 100644 --- a/source/luametatex/source/lua/lmtluaclib.c +++ b/source/luametatex/source/lua/lmtluaclib.c @@ -31,7 +31,7 @@ static TString **tmname = NULL; -# define toproto(L,i) getproto(s2v(L->top+(i))) +# define toproto(L,i) getproto(s2v(L->top.p+(i))) # define UPVALNAME(x) ((f->upvalues[x].name) ? getstr(f->upvalues[x].name) : "-") # define LUACVOID(p) ((const void*)(p)) # define eventname(i) (getstr(tmname[i])) diff --git a/source/luametatex/source/lua/lmtmplib.c b/source/luametatex/source/lua/lmtmplib.c index 74d684c3f..ecbfd46b6 100644 --- a/source/luametatex/source/lua/lmtmplib.c +++ b/source/luametatex/source/lua/lmtmplib.c @@ -765,7 +765,7 @@ static char *mplib_aux_run_script(MP mp, const char *str, size_t len, int n) return NULL; } -void mplib_aux_run_internal(MP mp, int action, int n, int type, const char *name) +static void mplib_aux_run_internal(MP mp, int action, int n, int type, const char *name) { if (mp->run_internal_id) { lua_State *L = (lua_State *) mp_userdata(mp); @@ -2754,13 +2754,6 @@ static int mplib_getcallbackstate(lua_State *L) This assumes that the top of the stack is a table or nil already in the case. */ -# define mplib_set_color_objects(pq) \ -object_color_model = pq->color_model; \ -object_color_a = pq->color.a_val; \ -object_color_b = pq->color.b_val; \ -object_color_c = pq->color.c_val; \ -object_color_d = pq->color.d_val; - static void mplib_aux_push_color(lua_State *L, struct mp_graphic_object *p) { if (p) { @@ -2771,11 +2764,19 @@ static void mplib_aux_push_color(lua_State *L, struct mp_graphic_object *p) case mp_stroked_code: { mp_shape_object *h = (mp_shape_object *) p; - mplib_set_color_objects(h); + object_color_model = h->color_model; + object_color_a = h->color.a_val; + object_color_b = h->color.b_val; + object_color_c = h->color.c_val; + object_color_d = h->color.d_val; } break; default: object_color_model = mp_no_model; + object_color_a = 0.0; + object_color_b = 0.0; + object_color_c = 0.0; + object_color_d = 0.0; break; } switch (object_color_model) { diff --git a/source/luametatex/source/lua/lmtnodelib.c b/source/luametatex/source/lua/lmtnodelib.c index eb29611e2..caa9da065 100644 --- a/source/luametatex/source/lua/lmtnodelib.c +++ b/source/luametatex/source/lua/lmtnodelib.c @@ -231,7 +231,7 @@ static void nodelib_push_attribute_data(lua_State* L, halfword n) inline static singleword nodelib_getdirection(lua_State *L, int i) { - return ((lua_type(L, i) == LUA_TNUMBER) ? checked_direction_value(lmt_tohalfword(L, i)) : direction_def_value); + return ((lua_type(L, i) == LUA_TNUMBER) ? (singleword) checked_direction_value(lmt_tohalfword(L, i)) : direction_def_value); } /*tex @@ -1892,7 +1892,7 @@ static int nodelib_direct_getdisc(lua_State *L) if (lua_isboolean(L, 2) && lua_toboolean(L, 2)) { nodelib_push_direct_or_nil(L, tex_tail_of_node_list(choice_pre_break(n))); nodelib_push_direct_or_nil(L, tex_tail_of_node_list(choice_post_break(n))); - nodelib_push_direct_or_nil(L, tex_tail_of_node_list(choice_post_break(n))); + nodelib_push_direct_or_nil(L, tex_tail_of_node_list(choice_no_break(n))); return 6; } else { return 3; @@ -4504,7 +4504,7 @@ static int nodelib_direct_dimensions(lua_State *L) { int top = lua_gettop(L); if (top > 0) { - scaledwhd siz = { 0, 0, 0 }; + scaledwhd siz = { 0, 0, 0, 0 }; glueratio g_mult = normal_glue_multiplier; int vertical = 0; int g_sign = normal_glue_sign; @@ -4545,7 +4545,7 @@ static int nodelib_direct_rangedimensions(lua_State *L) /* parent, first, last * { int top = lua_gettop(L); if (top > 1) { - scaledwhd siz = { 0, 0, 0 }; + scaledwhd siz = { 0, 0, 0, 0 }; int vertical = 0; halfword l = nodelib_valid_direct_from_index(L, 1); /* parent */ halfword n = nodelib_valid_direct_from_index(L, 2); /* first */ @@ -5379,8 +5379,8 @@ static int nodelib_direct_setglue(lua_State *L) case vlist_node: case unset_node: box_glue_set(n) = ((top > 1 && lua_type(L, 2) == LUA_TNUMBER)) ? (glueratio) lua_tonumber(L, 2) : 0; - box_glue_order(n) = tex_checked_glue_sign((top > 2 && lua_type(L, 3) == LUA_TNUMBER) ? (halfword) lua_tointeger(L, 3) : 0); - box_glue_sign(n) = tex_checked_glue_order((top > 3 && lua_type(L, 4) == LUA_TNUMBER) ? (halfword) lua_tointeger(L, 4) : 0); + box_glue_order(n) = tex_checked_glue_order((top > 2 && lua_type(L, 3) == LUA_TNUMBER) ? (halfword) lua_tointeger(L, 3) : 0); + box_glue_sign(n) = tex_checked_glue_sign((top > 3 && lua_type(L, 4) == LUA_TNUMBER) ? (halfword) lua_tointeger(L, 4) : 0); break; case math_node: math_amount(n) = ((top > 1 && lua_type(L, 2) == LUA_TNUMBER)) ? (halfword) lmt_roundnumber(L, 2) : 0; @@ -7117,9 +7117,9 @@ static int nodelib_common_setfield(lua_State *L, int direct, halfword n) } else if (lua_key_eq(s, shrink)) { glue_shrink(n) = (halfword) lmt_roundnumber(L, 3); } else if (lua_key_eq(s, stretchorder)) { - glue_stretch_order(n) = lmt_tohalfword(L, 3); + glue_stretch_order(n) = tex_checked_glue_order(lmt_tohalfword(L, 3)); } else if (lua_key_eq(s, shrinkorder)) { - glue_shrink_order(n) = lmt_tohalfword(L, 3); + glue_shrink_order(n) = tex_checked_glue_order(lmt_tohalfword(L, 3)); } else if (lua_key_eq(s, leader)) { glue_leader_ptr(n) = nodelib_direct_or_node_from_index(L, direct, 3); } else if (lua_key_eq(s, font)) { @@ -7265,9 +7265,9 @@ static int nodelib_common_setfield(lua_State *L, int direct, halfword n) } else if (lua_key_eq(s, shrink)) { math_shrink(n) = (halfword) lmt_roundnumber(L, 3); } else if (lua_key_eq(s, stretchorder)) { - math_stretch_order(n) = lmt_tohalfword(L, 3); + math_stretch_order(n) = tex_checked_glue_order(lmt_tohalfword(L, 3)); } else if (lua_key_eq(s, shrinkorder)) { - math_shrink_order(n) = lmt_tohalfword(L, 3); + math_shrink_order(n) = tex_checked_glue_order(lmt_tohalfword(L, 3)); } else if (lua_key_eq(s, penalty)) { math_penalty(n) = lmt_tohalfword(L, 3); } else { @@ -7320,7 +7320,7 @@ static int nodelib_common_setfield(lua_State *L, int direct, halfword n) } else if (lua_key_eq(s, options)) { noad_options(n) = lmt_tohalfword(L, 3); } else if (lua_key_eq(s, scriptorder)) { - noad_script_order(n) = lmt_tohalfword(L, 3); + noad_script_order(n) = lmt_tosingleword(L, 3); } else if (lua_key_eq(s, class)) { halfword c = lmt_tohalfword(L, 3); set_noad_main_class(n, c); @@ -7469,7 +7469,7 @@ static int nodelib_common_setfield(lua_State *L, int direct, halfword n) /* just ignored */ return 0; } - break; + // break; case adjust_node: if (lua_key_eq(s, list) || lua_key_eq(s, head)) { adjust_list(n) = nodelib_direct_or_node_from_index(L, direct, 3); @@ -7522,9 +7522,9 @@ static int nodelib_common_setfield(lua_State *L, int direct, halfword n) } else if (lua_key_eq(s, shrink)) { glue_shrink(n) = (halfword) lmt_roundnumber(L, 3); } else if (lua_key_eq(s, stretchorder)) { - glue_stretch_order(n) = lmt_tohalfword(L, 3); + glue_stretch_order(n) = tex_checked_glue_order(lmt_tohalfword(L, 3)); } else if (lua_key_eq(s, shrinkorder)) { - glue_shrink_order(n) = lmt_tohalfword(L, 3); + glue_shrink_order(n) = tex_checked_glue_order(lmt_tohalfword(L, 3)); } else { goto CANTSET; } @@ -9093,8 +9093,9 @@ static halfword lmt_direct_migrate_locate(halfword head, halfword *first, halfwo case insert_node: { if (inserts) { + halfword list; head = nodelib_aux_migrate_decouple(head, current, next, first, last); - halfword list = insert_list(current); + list = insert_list(current); if (list) { insert_list(current) = lmt_direct_migrate_locate(list, first, last, inserts, marks); } @@ -9196,7 +9197,7 @@ static int nodelib_direct_hasglyphoption(lua_State *L) halfword current = nodelib_valid_direct_from_index(L, 1); int result = 0; if (current && node_type(current) == glyph_node) { - int option = lua_tointeger(L, 2); + int option = lmt_tointeger(L, 2); switch (option) { case glyph_option_normal_glyph: // 0x00 break; @@ -9332,9 +9333,9 @@ static int nodelib_direct_getnodes(lua_State *L) /* maybe count */ lua_newtable(L); if (lua_type(L, 2) == LUA_TNUMBER) { - int t = lua_tonumber(L, 2); + int t = lmt_tointeger(L, 2); if (lua_type(L, 3) == LUA_TNUMBER) { - int s = lua_tonumber(L, 3); + int s = lmt_tointeger(L, 3); while (n) { if (node_type(n) == t && node_subtype(n) == s) { lua_pushinteger(L, n); diff --git a/source/luametatex/source/lua/lmttexlib.c b/source/luametatex/source/lua/lmttexlib.c index afafb068b..c88d13490 100644 --- a/source/luametatex/source/lua/lmttexlib.c +++ b/source/luametatex/source/lua/lmttexlib.c @@ -1402,9 +1402,9 @@ static halfword texlib_aux_make_glue(lua_State *L, int top, int slot) if (slot <= top) { glue_shrink(value) = lmt_toroundnumber(L, slot++); if (slot <= top) { - glue_stretch_order(value) = lmt_tohalfword(L, slot++); + glue_stretch_order(value) = tex_checked_glue_order(lmt_tohalfword(L, slot++)); if (slot <= top) { - glue_shrink_order(value) = lmt_tohalfword(L, slot++); + glue_shrink_order(value) = tex_checked_glue_order(lmt_tohalfword(L, slot++)); } } } @@ -2466,9 +2466,9 @@ static int texlib_set_item(lua_State* L, int index, int prefixes) if (slot <= top) { glue_shrink(value) = lmt_toroundnumber(L, slot++); if (slot <= top) { - glue_stretch_order(value) = lmt_tohalfword(L, slot++); + glue_stretch_order(value) = tex_checked_glue_order(lmt_tohalfword(L, slot++)); if (slot <= top) { - glue_shrink_order(value) = lmt_tohalfword(L, slot); + glue_shrink_order(value) = tex_checked_glue_order(lmt_tohalfword(L, slot)); } } } @@ -2877,8 +2877,8 @@ static int texlib_setmath(lua_State *L) glue_amount(p) = lmt_optroundnumber(L, slot++, 0); glue_stretch(p) = lmt_optroundnumber(L, slot++, 0); glue_shrink(p) = lmt_optroundnumber(L, slot++, 0); - glue_stretch_order(p) = lmt_optroundnumber(L, slot++, 0); - glue_shrink_order(p) = lmt_optroundnumber(L, slot, 0); + glue_stretch_order(p) = tex_checked_glue_order(lmt_optroundnumber(L, slot++, 0)); + glue_shrink_order(p) = tex_checked_glue_order(lmt_optroundnumber(L, slot, 0)); tex_def_math_parameter(style, param, (scaled) p, level, indirect_math_regular); break; } @@ -4385,7 +4385,7 @@ static int texlib_setboxdir(lua_State *L) { int index = lmt_tointeger(L, 1); if (index >= 0 && index <= max_box_register_index) { - tex_set_box_dir(index, lmt_tointeger(L, 2)); + tex_set_box_dir(index, lmt_tosingleword(L, 2)); } else { texlib_aux_show_box_index_error(L); } @@ -4536,8 +4536,8 @@ static int texlib_mathchardef(lua_State *L) if (tex_define_permitted(cs, flags)) { mathcodeval m; mathdictval d; - m.class_value = lmt_tointeger(L, 2); - m.family_value = lmt_tointeger(L, 3); + m.class_value = (short) lmt_tointeger(L, 2); + m.family_value = (short) lmt_tointeger(L, 3); m.character_value = lmt_tointeger(L, 4); d.properties = lmt_optquarterword(L, 6, 0); d.group = lmt_optquarterword(L, 7, 0); @@ -5002,6 +5002,27 @@ static int texlib_getkerneloptionvalues(lua_State *L) return 1; } +static int texlib_getcharactertagvalues(lua_State *L) +{ + lua_createtable(L, 2, 12); + lua_set_string_by_index(L, no_tag, "normal"); + lua_set_string_by_index(L, ligatures_tag, "ligatures"); + lua_set_string_by_index(L, kerns_tag, "kerns"); + lua_set_string_by_index(L, list_tag, "list"); + lua_set_string_by_index(L, callback_tag, "callback"); + lua_set_string_by_index(L, extensible_tag, "extensible"); + lua_set_string_by_index(L, horizontal_tag, "horizontal"); + lua_set_string_by_index(L, vertical_tag, "vertical"); + lua_set_string_by_index(L, extend_last_tag, "extendlast"); + lua_set_string_by_index(L, inner_left_tag, "innerleft"); + lua_set_string_by_index(L, inner_right_tag, "innerright"); + lua_set_string_by_index(L, italic_tag, "italic"); + lua_set_string_by_index(L, n_ary_tag, "nary"); + lua_set_string_by_index(L, radical_tag, "radical"); + lua_set_string_by_index(L, punctuation_tag, "punctuation"); + return 1; +} + static int texlib_getshapingpenaltiesvalues(lua_State *L) { lua_createtable(L, 2, 2); @@ -5139,7 +5160,7 @@ static int texlib_getdiscstatevalues(lua_State *L) static int texlib_getmathcontrolvalues(lua_State *L) { - lua_createtable(L, 2, 21); + lua_createtable(L, 2, 23); lua_set_string_by_index(L, math_control_use_font_control, "usefontcontrol"); lua_set_string_by_index(L, math_control_over_rule, "overrule"); lua_set_string_by_index(L, math_control_under_rule, "underrule"); @@ -5163,6 +5184,8 @@ static int texlib_getmathcontrolvalues(lua_State *L) lua_set_string_by_index(L, math_control_analyze_script_nucleus_box, "analyzescriptnucleusbox"); lua_set_string_by_index(L, math_control_accent_top_skew_with_offset, "accenttopskewwithoffset"); lua_set_string_by_index(L, math_control_ignore_kern_dimensions, "ignorekerndimensions"); + lua_set_string_by_index(L, math_control_ignore_flat_accents, "ignoreflataccents"); + lua_set_string_by_index(L, math_control_extend_accents, "extendaccents"); return 1; } @@ -5462,6 +5485,7 @@ static const struct luaL_Reg texlib_function_list[] = { { "getprimitiveorigins", texlib_getprimitiveorigins }, { "getfrozenparvalues", texlib_getfrozenparvalues }, { "getshapingpenaltiesvalues", texlib_getshapingpenaltiesvalues }, + { "getcharactertagvalues", texlib_getcharactertagvalues }, { "getkerneloptionvalues", texlib_getkerneloptionvalues }, { "getspecialmathclassvalues", texlib_getspecialmathclassvalues }, { "getlargestusedmark", texlib_getlargestusedmark }, diff --git a/source/luametatex/source/lua/lmttokenlib.c b/source/luametatex/source/lua/lmttokenlib.c index feac7cd46..e15b2de5a 100644 --- a/source/luametatex/source/lua/lmttokenlib.c +++ b/source/luametatex/source/lua/lmttokenlib.c @@ -347,23 +347,16 @@ inline static int tokenlib_aux_to_valid_index(int cmd, int chr) case internal_command_item: case reference_command_item: case data_command_item: - { - halfword c = chr; - switch (item.base) { - case ignore_entry: - return 0; - case direct_entry: - break; - default: - chr -= item.base; - break; - } - if (c >= item.min && c <= item.max) { - return c; - } else { - return item.min; - } + switch (item.base) { + case ignore_entry: + return 0; + case direct_entry: + break; + default: + chr -= item.base; + break; } + return (chr >= item.min && chr <= item.max) ? chr : item.min; case token_command_item: case node_command_item: return item.fixedvalue; @@ -2147,7 +2140,7 @@ static int tokenlib_future_expand(lua_State *L) return 0; } } - return 0; + // return 0; } static int tokenlib_scan_code(lua_State *L) @@ -2735,8 +2728,9 @@ static int tokenlib_get_fields(lua_State *L) size_t l; const char *str = lua_tolstring(L, 1, &l); if (l > 0) { + halfword cs; lua_createtable(L, 0, onlyflags ? 0 : 5); - halfword cs = tex_string_locate(str, l, 0); + cs = tex_string_locate(str, l, 0); cmd = eq_type(cs); chr = eq_value(cs); flags = eq_flag(cs); @@ -3174,10 +3168,11 @@ static int tokenlib_set_lua(lua_State *L) size_t lname = 0; const char *name = lua_tolstring(L, 1, &lname); if (name) { + halfword cs; int flags = 0; int funct = lmt_tointeger(L, 2); /*tex todo: check range */ lmt_check_for_flags(L, 3, &flags, 1, 1); - halfword cs = tex_string_locate(name, lname, 1); + cs = tex_string_locate(name, lname, 1); if (tex_define_permitted(cs, flags)) { if (is_value(flags)) { tex_define(flags, cs, lua_value_cmd, funct); diff --git a/source/luametatex/source/luacore/lua54/src/Makefile b/source/luametatex/source/luacore/lua54/src/Makefile index d46e650cb..ee56c6720 100644 --- a/source/luametatex/source/luacore/lua54/src/Makefile +++ b/source/luametatex/source/luacore/lua54/src/Makefile @@ -57,8 +57,13 @@ CWARNS= $(CWARNSCPP) $(CWARNSC) $(CWARNGCC) # -pg -malign-double # -DLUA_USE_CTYPE -DLUA_USE_APICHECK -# ('-ftrapv' for runtime checks of integer overflows) -# -fsanitize=undefined -ftrapv -fno-inline + +# The following options help detect "undefined behavior"s that seldom +# create problems; some are only available in newer gcc versions. To +# use some of them, we also have to define an enrivonment variable +# ASAN_OPTIONS="detect_invalid_pointer_pairs=2". +# -fsanitize=undefined +# -fsanitize=pointer-subtract -fsanitize=address -fsanitize=pointer-compare # TESTS= -DLUA_USER_H='"ltests.h"' -O0 -g diff --git a/source/luametatex/source/luacore/lua54/src/lapi.c b/source/luametatex/source/luacore/lua54/src/lapi.c index 5833c7b0a..34e64af14 100644 --- a/source/luametatex/source/luacore/lua54/src/lapi.c +++ b/source/luametatex/source/luacore/lua54/src/lapi.c @@ -60,27 +60,28 @@ const char lua_ident[] = static TValue *index2value (lua_State *L, int idx) { CallInfo *ci = L->ci; if (idx > 0) { - StkId o = ci->func + idx; - api_check(L, idx <= L->ci->top - (ci->func + 1), "unacceptable index"); - if (o >= L->top) return &G(L)->nilvalue; + StkId o = ci->func.p + idx; + api_check(L, idx <= ci->top.p - (ci->func.p + 1), "unacceptable index"); + if (o >= L->top.p) return &G(L)->nilvalue; else return s2v(o); } else if (!ispseudo(idx)) { /* negative index */ - api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); - return s2v(L->top + idx); + api_check(L, idx != 0 && -idx <= L->top.p - (ci->func.p + 1), + "invalid index"); + return s2v(L->top.p + idx); } else if (idx == LUA_REGISTRYINDEX) return &G(L)->l_registry; else { /* upvalues */ idx = LUA_REGISTRYINDEX - idx; api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large"); - if (ttisCclosure(s2v(ci->func))) { /* C closure? */ - CClosure *func = clCvalue(s2v(ci->func)); + if (ttisCclosure(s2v(ci->func.p))) { /* C closure? */ + CClosure *func = clCvalue(s2v(ci->func.p)); return (idx <= func->nupvalues) ? &func->upvalue[idx-1] : &G(L)->nilvalue; } else { /* light C function or Lua function (through a hook)?) */ - api_check(L, ttislcf(s2v(ci->func)), "caller not a C function"); + api_check(L, ttislcf(s2v(ci->func.p)), "caller not a C function"); return &G(L)->nilvalue; /* no upvalues */ } } @@ -94,14 +95,15 @@ static TValue *index2value (lua_State *L, int idx) { l_sinline StkId index2stack (lua_State *L, int idx) { CallInfo *ci = L->ci; if (idx > 0) { - StkId o = ci->func + idx; - api_check(L, o < L->top, "invalid index"); + StkId o = ci->func.p + idx; + api_check(L, o < L->top.p, "invalid index"); return o; } else { /* non-positive index */ - api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); + api_check(L, idx != 0 && -idx <= L->top.p - (ci->func.p + 1), + "invalid index"); api_check(L, !ispseudo(idx), "invalid index"); - return L->top + idx; + return L->top.p + idx; } } @@ -112,12 +114,12 @@ LUA_API int lua_checkstack (lua_State *L, int n) { lua_lock(L); ci = L->ci; api_check(L, n >= 0, "negative 'n'"); - if (L->stack_last - L->top > n) /* stack large enough? */ + if (L->stack_last.p - L->top.p > n) /* stack large enough? */ res = 1; /* yes; check is OK */ else /* need to grow stack */ res = luaD_growstack(L, n, 0); - if (res && ci->top < L->top + n) - ci->top = L->top + n; /* adjust frame top */ + if (res && ci->top.p < L->top.p + n) + ci->top.p = L->top.p + n; /* adjust frame top */ lua_unlock(L); return res; } @@ -129,11 +131,11 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { lua_lock(to); api_checknelems(from, n); api_check(from, G(from) == G(to), "moving among independent states"); - api_check(from, to->ci->top - to->top >= n, "stack overflow"); - from->top -= n; + api_check(from, to->ci->top.p - to->top.p >= n, "stack overflow"); + from->top.p -= n; for (i = 0; i < n; i++) { - setobjs2s(to, to->top, from->top + i); - to->top++; /* stack already checked by previous 'api_check' */ + setobjs2s(to, to->top.p, from->top.p + i); + to->top.p++; /* stack already checked by previous 'api_check' */ } lua_unlock(to); } @@ -167,12 +169,12 @@ LUA_API lua_Number lua_version (lua_State *L) { LUA_API int lua_absindex (lua_State *L, int idx) { return (idx > 0 || ispseudo(idx)) ? idx - : cast_int(L->top - L->ci->func) + idx; + : cast_int(L->top.p - L->ci->func.p) + idx; } LUA_API int lua_gettop (lua_State *L) { - return cast_int(L->top - (L->ci->func + 1)); + return cast_int(L->top.p - (L->ci->func.p + 1)); } @@ -182,24 +184,24 @@ LUA_API void lua_settop (lua_State *L, int idx) { ptrdiff_t diff; /* difference for new top */ lua_lock(L); ci = L->ci; - func = ci->func; + func = ci->func.p; if (idx >= 0) { - api_check(L, idx <= ci->top - (func + 1), "new top too large"); - diff = ((func + 1) + idx) - L->top; + api_check(L, idx <= ci->top.p - (func + 1), "new top too large"); + diff = ((func + 1) + idx) - L->top.p; for (; diff > 0; diff--) - setnilvalue(s2v(L->top++)); /* clear new slots */ + setnilvalue(s2v(L->top.p++)); /* clear new slots */ } else { - api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top"); + api_check(L, -(idx+1) <= (L->top.p - (func + 1)), "invalid new top"); diff = idx + 1; /* will "subtract" index (as it is negative) */ } - api_check(L, L->tbclist < L->top, "previous pop of an unclosed slot"); - newtop = L->top + diff; - if (diff < 0 && L->tbclist >= newtop) { + api_check(L, L->tbclist.p < L->top.p, "previous pop of an unclosed slot"); + newtop = L->top.p + diff; + if (diff < 0 && L->tbclist.p >= newtop) { lua_assert(hastocloseCfunc(ci->nresults)); newtop = luaF_close(L, newtop, CLOSEKTOP, 0); } - L->top = newtop; /* correct top only after closing any upvalue */ + L->top.p = newtop; /* correct top only after closing any upvalue */ lua_unlock(L); } @@ -208,7 +210,7 @@ LUA_API void lua_closeslot (lua_State *L, int idx) { StkId level; lua_lock(L); level = index2stack(L, idx); - api_check(L, hastocloseCfunc(L->ci->nresults) && L->tbclist == level, + api_check(L, hastocloseCfunc(L->ci->nresults) && L->tbclist.p == level, "no variable to close at given level"); level = luaF_close(L, level, CLOSEKTOP, 0); setnilvalue(s2v(level)); @@ -239,7 +241,7 @@ l_sinline void reverse (lua_State *L, StkId from, StkId to) { LUA_API void lua_rotate (lua_State *L, int idx, int n) { StkId p, t, m; lua_lock(L); - t = L->top - 1; /* end of stack segment being rotated */ + t = L->top.p - 1; /* end of stack segment being rotated */ p = index2stack(L, idx); /* start of segment */ api_check(L, (n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'"); m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */ @@ -258,7 +260,7 @@ LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) { api_check(L, isvalid(L, to), "invalid index"); setobj(L, to, fr); if (isupvalue(toidx)) /* function upvalue? */ - luaC_barrier(L, clCvalue(s2v(L->ci->func)), fr); + luaC_barrier(L, clCvalue(s2v(L->ci->func.p)), fr); /* LUA_REGISTRYINDEX does not need gc barrier (collector revisits it before finishing collection) */ lua_unlock(L); @@ -267,7 +269,7 @@ LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) { LUA_API void lua_pushvalue (lua_State *L, int idx) { lua_lock(L); - setobj2s(L, L->top, index2value(L, idx)); + setobj2s(L, L->top.p, index2value(L, idx)); api_incr_top(L); lua_unlock(L); } @@ -336,12 +338,12 @@ LUA_API void lua_arith (lua_State *L, int op) { api_checknelems(L, 2); /* all other operations expect two operands */ else { /* for unary operations, add fake 2nd operand */ api_checknelems(L, 1); - setobjs2s(L, L->top, L->top - 1); + setobjs2s(L, L->top.p, L->top.p - 1); api_incr_top(L); } /* first operand at top - 2, second at top - 1; result go to top - 2 */ - luaO_arith(L, op, s2v(L->top - 2), s2v(L->top - 1), L->top - 2); - L->top--; /* remove second operand */ + luaO_arith(L, op, s2v(L->top.p - 2), s2v(L->top.p - 1), L->top.p - 2); + L->top.p--; /* remove second operand */ lua_unlock(L); } @@ -367,7 +369,7 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { LUA_API size_t lua_stringtonumber (lua_State *L, const char *s) { - size_t sz = luaO_str2num(s, s2v(L->top)); + size_t sz = luaO_str2num(s, s2v(L->top.p)); if (sz != 0) api_incr_top(L); return sz; @@ -494,7 +496,7 @@ LUA_API const void *lua_topointer (lua_State *L, int idx) { LUA_API void lua_pushnil (lua_State *L) { lua_lock(L); - setnilvalue(s2v(L->top)); + setnilvalue(s2v(L->top.p)); api_incr_top(L); lua_unlock(L); } @@ -502,7 +504,7 @@ LUA_API void lua_pushnil (lua_State *L) { LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { lua_lock(L); - setfltvalue(s2v(L->top), n); + setfltvalue(s2v(L->top.p), n); api_incr_top(L); lua_unlock(L); } @@ -510,7 +512,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { lua_lock(L); - setivalue(s2v(L->top), n); + setivalue(s2v(L->top.p), n); api_incr_top(L); lua_unlock(L); } @@ -525,7 +527,7 @@ LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) { TString *ts; lua_lock(L); ts = (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len); - setsvalue2s(L, L->top, ts); + setsvalue2s(L, L->top.p, ts); api_incr_top(L); luaC_checkGC(L); lua_unlock(L); @@ -536,11 +538,11 @@ LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) { LUA_API const char *lua_pushstring (lua_State *L, const char *s) { lua_lock(L); if (s == NULL) - setnilvalue(s2v(L->top)); + setnilvalue(s2v(L->top.p)); else { TString *ts; ts = luaS_new(L, s); - setsvalue2s(L, L->top, ts); + setsvalue2s(L, L->top.p, ts); s = getstr(ts); /* internal copy's address */ } api_incr_top(L); @@ -577,7 +579,7 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { lua_lock(L); if (n == 0) { - setfvalue(s2v(L->top), fn); + setfvalue(s2v(L->top.p), fn); api_incr_top(L); } else { @@ -586,13 +588,13 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { api_check(L, n <= MAXUPVAL, "upvalue index too large"); cl = luaF_newCclosure(L, n); cl->f = fn; - L->top -= n; + L->top.p -= n; while (n--) { - setobj2n(L, &cl->upvalue[n], s2v(L->top + n)); + setobj2n(L, &cl->upvalue[n], s2v(L->top.p + n)); /* does not need barrier because closure is white */ lua_assert(iswhite(cl)); } - setclCvalue(L, s2v(L->top), cl); + setclCvalue(L, s2v(L->top.p), cl); api_incr_top(L); luaC_checkGC(L); } @@ -603,9 +605,9 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { LUA_API void lua_pushboolean (lua_State *L, int b) { lua_lock(L); if (b) - setbtvalue(s2v(L->top)); + setbtvalue(s2v(L->top.p)); else - setbfvalue(s2v(L->top)); + setbfvalue(s2v(L->top.p)); api_incr_top(L); lua_unlock(L); } @@ -613,7 +615,7 @@ LUA_API void lua_pushboolean (lua_State *L, int b) { LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { lua_lock(L); - setpvalue(s2v(L->top), p); + setpvalue(s2v(L->top.p), p); api_incr_top(L); lua_unlock(L); } @@ -621,7 +623,7 @@ LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { LUA_API int lua_pushthread (lua_State *L) { lua_lock(L); - setthvalue(L, s2v(L->top), L); + setthvalue(L, s2v(L->top.p), L); api_incr_top(L); lua_unlock(L); return (G(L)->mainthread == L); @@ -638,16 +640,16 @@ l_sinline int auxgetstr (lua_State *L, const TValue *t, const char *k) { const TValue *slot; TString *str = luaS_new(L, k); if (luaV_fastget(L, t, str, slot, luaH_getstr)) { - setobj2s(L, L->top, slot); + setobj2s(L, L->top.p, slot); api_incr_top(L); } else { - setsvalue2s(L, L->top, str); + setsvalue2s(L, L->top.p, str); api_incr_top(L); - luaV_finishget(L, t, s2v(L->top - 1), L->top - 1, slot); + luaV_finishget(L, t, s2v(L->top.p - 1), L->top.p - 1, slot); } lua_unlock(L); - return ttype(s2v(L->top - 1)); + return ttype(s2v(L->top.p - 1)); } @@ -674,13 +676,13 @@ LUA_API int lua_gettable (lua_State *L, int idx) { TValue *t; lua_lock(L); t = index2value(L, idx); - if (luaV_fastget(L, t, s2v(L->top - 1), slot, luaH_get)) { - setobj2s(L, L->top - 1, slot); + if (luaV_fastget(L, t, s2v(L->top.p - 1), slot, luaH_get)) { + setobj2s(L, L->top.p - 1, slot); } else - luaV_finishget(L, t, s2v(L->top - 1), L->top - 1, slot); + luaV_finishget(L, t, s2v(L->top.p - 1), L->top.p - 1, slot); lua_unlock(L); - return ttype(s2v(L->top - 1)); + return ttype(s2v(L->top.p - 1)); } @@ -696,27 +698,27 @@ LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) { lua_lock(L); t = index2value(L, idx); if (luaV_fastgeti(L, t, n, slot)) { - setobj2s(L, L->top, slot); + setobj2s(L, L->top.p, slot); } else { TValue aux; setivalue(&aux, n); - luaV_finishget(L, t, &aux, L->top, slot); + luaV_finishget(L, t, &aux, L->top.p, slot); } api_incr_top(L); lua_unlock(L); - return ttype(s2v(L->top - 1)); + return ttype(s2v(L->top.p - 1)); } l_sinline int finishrawget (lua_State *L, const TValue *val) { if (isempty(val)) /* avoid copying empty items to the stack */ - setnilvalue(s2v(L->top)); + setnilvalue(s2v(L->top.p)); else - setobj2s(L, L->top, val); + setobj2s(L, L->top.p, val); api_incr_top(L); lua_unlock(L); - return ttype(s2v(L->top - 1)); + return ttype(s2v(L->top.p - 1)); } @@ -733,8 +735,8 @@ LUA_API int lua_rawget (lua_State *L, int idx) { lua_lock(L); api_checknelems(L, 1); t = gettable(L, idx); - val = luaH_get(t, s2v(L->top - 1)); - L->top--; /* remove key */ + val = luaH_get(t, s2v(L->top.p - 1)); + L->top.p--; /* remove key */ return finishrawget(L, val); } @@ -761,7 +763,7 @@ LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { Table *t; lua_lock(L); t = luaH_new(L); - sethvalue2s(L, L->top, t); + sethvalue2s(L, L->top.p, t); api_incr_top(L); if (narray > 0 || nrec > 0) luaH_resize(L, t, narray, nrec); @@ -788,7 +790,7 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) { break; } if (mt != NULL) { - sethvalue2s(L, L->top, mt); + sethvalue2s(L, L->top.p, mt); api_incr_top(L); res = 1; } @@ -804,12 +806,12 @@ LUA_API int lua_getiuservalue (lua_State *L, int idx, int n) { o = index2value(L, idx); api_check(L, ttisfulluserdata(o), "full userdata expected"); if (n <= 0 || n > uvalue(o)->nuvalue) { - setnilvalue(s2v(L->top)); + setnilvalue(s2v(L->top.p)); t = LUA_TNONE; } else { - setobj2s(L, L->top, &uvalue(o)->uv[n - 1].uv); - t = ttype(s2v(L->top)); + setobj2s(L, L->top.p, &uvalue(o)->uv[n - 1].uv); + t = ttype(s2v(L->top.p)); } api_incr_top(L); lua_unlock(L); @@ -829,14 +831,14 @@ static void auxsetstr (lua_State *L, const TValue *t, const char *k) { TString *str = luaS_new(L, k); api_checknelems(L, 1); if (luaV_fastget(L, t, str, slot, luaH_getstr)) { - luaV_finishfastset(L, t, slot, s2v(L->top - 1)); - L->top--; /* pop value */ + luaV_finishfastset(L, t, slot, s2v(L->top.p - 1)); + L->top.p--; /* pop value */ } else { - setsvalue2s(L, L->top, str); /* push 'str' (to make it a TValue) */ + setsvalue2s(L, L->top.p, str); /* push 'str' (to make it a TValue) */ api_incr_top(L); - luaV_finishset(L, t, s2v(L->top - 1), s2v(L->top - 2), slot); - L->top -= 2; /* pop value and key */ + luaV_finishset(L, t, s2v(L->top.p - 1), s2v(L->top.p - 2), slot); + L->top.p -= 2; /* pop value and key */ } lua_unlock(L); /* lock done by caller */ } @@ -856,12 +858,12 @@ LUA_API void lua_settable (lua_State *L, int idx) { lua_lock(L); api_checknelems(L, 2); t = index2value(L, idx); - if (luaV_fastget(L, t, s2v(L->top - 2), slot, luaH_get)) { - luaV_finishfastset(L, t, slot, s2v(L->top - 1)); + if (luaV_fastget(L, t, s2v(L->top.p - 2), slot, luaH_get)) { + luaV_finishfastset(L, t, slot, s2v(L->top.p - 1)); } else - luaV_finishset(L, t, s2v(L->top - 2), s2v(L->top - 1), slot); - L->top -= 2; /* pop index and value */ + luaV_finishset(L, t, s2v(L->top.p - 2), s2v(L->top.p - 1), slot); + L->top.p -= 2; /* pop index and value */ lua_unlock(L); } @@ -879,14 +881,14 @@ LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) { api_checknelems(L, 1); t = index2value(L, idx); if (luaV_fastgeti(L, t, n, slot)) { - luaV_finishfastset(L, t, slot, s2v(L->top - 1)); + luaV_finishfastset(L, t, slot, s2v(L->top.p - 1)); } else { TValue aux; setivalue(&aux, n); - luaV_finishset(L, t, &aux, s2v(L->top - 1), slot); + luaV_finishset(L, t, &aux, s2v(L->top.p - 1), slot); } - L->top--; /* pop value */ + L->top.p--; /* pop value */ lua_unlock(L); } @@ -896,16 +898,16 @@ static void aux_rawset (lua_State *L, int idx, TValue *key, int n) { lua_lock(L); api_checknelems(L, n); t = gettable(L, idx); - luaH_set(L, t, key, s2v(L->top - 1)); + luaH_set(L, t, key, s2v(L->top.p - 1)); invalidateTMcache(t); - luaC_barrierback(L, obj2gco(t), s2v(L->top - 1)); - L->top -= n; + luaC_barrierback(L, obj2gco(t), s2v(L->top.p - 1)); + L->top.p -= n; lua_unlock(L); } LUA_API void lua_rawset (lua_State *L, int idx) { - aux_rawset(L, idx, s2v(L->top - 2), 2); + aux_rawset(L, idx, s2v(L->top.p - 2), 2); } @@ -921,9 +923,9 @@ LUA_API void lua_rawseti (lua_State *L, int idx, lua_Integer n) { lua_lock(L); api_checknelems(L, 1); t = gettable(L, idx); - luaH_setint(L, t, n, s2v(L->top - 1)); - luaC_barrierback(L, obj2gco(t), s2v(L->top - 1)); - L->top--; + luaH_setint(L, t, n, s2v(L->top.p - 1)); + luaC_barrierback(L, obj2gco(t), s2v(L->top.p - 1)); + L->top.p--; lua_unlock(L); } @@ -934,11 +936,11 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { lua_lock(L); api_checknelems(L, 1); obj = index2value(L, objindex); - if (ttisnil(s2v(L->top - 1))) + if (ttisnil(s2v(L->top.p - 1))) mt = NULL; else { - api_check(L, ttistable(s2v(L->top - 1)), "table expected"); - mt = hvalue(s2v(L->top - 1)); + api_check(L, ttistable(s2v(L->top.p - 1)), "table expected"); + mt = hvalue(s2v(L->top.p - 1)); } switch (ttype(obj)) { case LUA_TTABLE: { @@ -962,7 +964,7 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { break; } } - L->top--; + L->top.p--; lua_unlock(L); return 1; } @@ -978,11 +980,11 @@ LUA_API int lua_setiuservalue (lua_State *L, int idx, int n) { if (!(cast_uint(n) - 1u < cast_uint(uvalue(o)->nuvalue))) res = 0; /* 'n' not in [1, uvalue(o)->nuvalue] */ else { - setobj(L, &uvalue(o)->uv[n - 1].uv, s2v(L->top - 1)); - luaC_barrierback(L, gcvalue(o), s2v(L->top - 1)); + setobj(L, &uvalue(o)->uv[n - 1].uv, s2v(L->top.p - 1)); + luaC_barrierback(L, gcvalue(o), s2v(L->top.p - 1)); res = 1; } - L->top--; + L->top.p--; lua_unlock(L); return res; } @@ -994,7 +996,8 @@ LUA_API int lua_setiuservalue (lua_State *L, int idx, int n) { #define checkresults(L,na,nr) \ - api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \ + api_check(L, (nr) == LUA_MULTRET \ + || (L->ci->top.p - L->top.p >= (nr) - (na)), \ "results from function overflow current stack size") @@ -1007,7 +1010,7 @@ LUA_API void lua_callk (lua_State *L, int nargs, int nresults, api_checknelems(L, nargs+1); api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); checkresults(L, nargs, nresults); - func = L->top - (nargs+1); + func = L->top.p - (nargs+1); if (k != NULL && yieldable(L)) { /* need to prepare continuation? */ L->ci->u.c.k = k; /* save continuation */ L->ci->u.c.ctx = ctx; /* save context */ @@ -1055,7 +1058,7 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, api_check(L, ttisfunction(s2v(o)), "error handler must be a function"); func = savestack(L, o); } - c.func = L->top - (nargs+1); /* function to be called */ + c.func = L->top.p - (nargs+1); /* function to be called */ if (k == NULL || !yieldable(L)) { /* no continuation or no yieldable? */ c.nresults = nresults; /* do a 'conventional' protected call */ status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); @@ -1090,12 +1093,12 @@ LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, luaZ_init(L, &z, reader, data); status = luaD_protectedparser(L, &z, chunkname, mode); if (status == LUA_OK) { /* no errors? */ - LClosure *f = clLvalue(s2v(L->top - 1)); /* get newly created function */ + LClosure *f = clLvalue(s2v(L->top.p - 1)); /* get new function */ if (f->nupvalues >= 1) { /* does it have an upvalue? */ /* get global table from registry */ const TValue *gt = getGtable(L); /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ - setobj(L, f->upvals[0]->v, gt); + setobj(L, f->upvals[0]->v.p, gt); luaC_barrier(L, f->upvals[0], gt); } } @@ -1109,7 +1112,7 @@ LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip) { TValue *o; lua_lock(L); api_checknelems(L, 1); - o = s2v(L->top - 1); + o = s2v(L->top.p - 1); if (isLfunction(o)) status = luaU_dump(L, getproto(o), writer, data, strip); else @@ -1235,7 +1238,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { LUA_API int lua_error (lua_State *L) { TValue *errobj; lua_lock(L); - errobj = s2v(L->top - 1); + errobj = s2v(L->top.p - 1); api_checknelems(L, 1); /* error object is the memory error message? */ if (ttisshrstring(errobj) && eqshrstr(tsvalue(errobj), G(L)->memerrmsg)) @@ -1253,12 +1256,12 @@ LUA_API int lua_next (lua_State *L, int idx) { lua_lock(L); api_checknelems(L, 1); t = gettable(L, idx); - more = luaH_next(L, t, L->top - 1); + more = luaH_next(L, t, L->top.p - 1); if (more) { api_incr_top(L); } else /* no more elements */ - L->top -= 1; /* remove key */ + L->top.p -= 1; /* remove key */ lua_unlock(L); return more; } @@ -1270,7 +1273,7 @@ LUA_API void lua_toclose (lua_State *L, int idx) { lua_lock(L); o = index2stack(L, idx); nresults = L->ci->nresults; - api_check(L, L->tbclist < o, "given index below or equal a marked one"); + api_check(L, L->tbclist.p < o, "given index below or equal a marked one"); luaF_newtbcupval(L, o); /* create new to-be-closed upvalue */ if (!hastocloseCfunc(nresults)) /* function not marked yet? */ L->ci->nresults = codeNresults(nresults); /* mark it */ @@ -1285,7 +1288,7 @@ LUA_API void lua_concat (lua_State *L, int n) { if (n > 0) luaV_concat(L, n); else { /* nothing to concatenate */ - setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); /* push empty string */ + setsvalue2s(L, L->top.p, luaS_newlstr(L, "", 0)); /* push empty string */ api_incr_top(L); } luaC_checkGC(L); @@ -1297,7 +1300,7 @@ LUA_API void lua_len (lua_State *L, int idx) { TValue *t; lua_lock(L); t = index2value(L, idx); - luaV_objlen(L, L->top, t); + luaV_objlen(L, L->top.p, t); api_incr_top(L); lua_unlock(L); } @@ -1342,7 +1345,7 @@ LUA_API void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue) { lua_lock(L); api_check(L, 0 <= nuvalue && nuvalue < USHRT_MAX, "invalid value"); u = luaS_newudata(L, size, nuvalue); - setuvalue(L, s2v(L->top), u); + setuvalue(L, s2v(L->top.p), u); api_incr_top(L); luaC_checkGC(L); lua_unlock(L); @@ -1368,7 +1371,7 @@ static const char *aux_upvalue (TValue *fi, int n, TValue **val, Proto *p = f->p; if (!(cast_uint(n) - 1u < cast_uint(p->sizeupvalues))) return NULL; /* 'n' not in [1, p->sizeupvalues] */ - *val = f->upvals[n-1]->v; + *val = f->upvals[n-1]->v.p; if (owner) *owner = obj2gco(f->upvals[n - 1]); name = p->upvalues[n-1].name; return (name == NULL) ? "(no name)" : getstr(name); @@ -1384,7 +1387,7 @@ LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { lua_lock(L); name = aux_upvalue(index2value(L, funcindex), n, &val, NULL); if (name) { - setobj2s(L, L->top, val); + setobj2s(L, L->top.p, val); api_incr_top(L); } lua_unlock(L); @@ -1402,8 +1405,8 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { api_checknelems(L, 1); name = aux_upvalue(fi, n, &val, &owner); if (name) { - L->top--; - setobj(L, val, s2v(L->top)); + L->top.p--; + setobj(L, val, s2v(L->top.p)); luaC_barrier(L, owner, val); } lua_unlock(L); diff --git a/source/luametatex/source/luacore/lua54/src/lapi.h b/source/luametatex/source/luacore/lua54/src/lapi.h index 9e99cc448..a742427cd 100644 --- a/source/luametatex/source/luacore/lua54/src/lapi.h +++ b/source/luametatex/source/luacore/lua54/src/lapi.h @@ -12,23 +12,26 @@ #include "lstate.h" -/* Increments 'L->top', checking for stack overflows */ -#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ - "stack overflow");} +/* Increments 'L->top.p', checking for stack overflows */ +#define api_incr_top(L) {L->top.p++; \ + api_check(L, L->top.p <= L->ci->top.p, \ + "stack overflow");} /* ** If a call returns too many multiple returns, the callee may not have ** stack space to accommodate all results. In this case, this macro -** increases its stack space ('L->ci->top'). +** increases its stack space ('L->ci->top.p'). */ #define adjustresults(L,nres) \ - { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } + { if ((nres) <= LUA_MULTRET && L->ci->top.p < L->top.p) \ + L->ci->top.p = L->top.p; } /* Ensure the stack has at least 'n' elements */ -#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ - "not enough elements in the stack") +#define api_checknelems(L,n) \ + api_check(L, (n) < (L->top.p - L->ci->func.p), \ + "not enough elements in the stack") /* diff --git a/source/luametatex/source/luacore/lua54/src/lcorolib.c b/source/luametatex/source/luacore/lua54/src/lcorolib.c index 785a1e81a..40b880b14 100644 --- a/source/luametatex/source/luacore/lua54/src/lcorolib.c +++ b/source/luametatex/source/luacore/lua54/src/lcorolib.c @@ -76,7 +76,7 @@ static int luaB_auxwrap (lua_State *L) { if (l_unlikely(r < 0)) { /* error? */ int stat = lua_status(co); if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ - stat = lua_resetthread(co); /* close its tbc variables */ + stat = lua_resetthread(co, L); /* close its tbc variables */ lua_assert(stat != LUA_OK); lua_xmove(co, L, 1); /* move error message to the caller */ } @@ -172,7 +172,7 @@ static int luaB_close (lua_State *L) { int status = auxstatus(L, co); switch (status) { case COS_DEAD: case COS_YIELD: { - status = lua_resetthread(co); + status = lua_resetthread(co, L); if (status == LUA_OK) { lua_pushboolean(L, 1); return 1; diff --git a/source/luametatex/source/luacore/lua54/src/ldebug.c b/source/luametatex/source/luacore/lua54/src/ldebug.c index fa15eaf68..3fae5cf25 100644 --- a/source/luametatex/source/luacore/lua54/src/ldebug.c +++ b/source/luametatex/source/luacore/lua54/src/ldebug.c @@ -182,10 +182,10 @@ static const char *upvalname (const Proto *p, int uv) { static const char *findvararg (CallInfo *ci, int n, StkId *pos) { - if (clLvalue(s2v(ci->func))->p->is_vararg) { + if (clLvalue(s2v(ci->func.p))->p->is_vararg) { int nextra = ci->u.l.nextraargs; if (n >= -nextra) { /* 'n' is negative */ - *pos = ci->func - nextra - (n + 1); + *pos = ci->func.p - nextra - (n + 1); return "(vararg)"; /* generic name for any vararg */ } } @@ -194,7 +194,7 @@ static const char *findvararg (CallInfo *ci, int n, StkId *pos) { const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) { - StkId base = ci->func + 1; + StkId base = ci->func.p + 1; const char *name = NULL; if (isLua(ci)) { if (n < 0) /* access to vararg values? */ @@ -203,7 +203,7 @@ const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) { name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); } if (name == NULL) { /* no 'standard' name? */ - StkId limit = (ci == L->ci) ? L->top : ci->next->func; + StkId limit = (ci == L->ci) ? L->top.p : ci->next->func.p; if (limit - base >= n && n > 0) { /* is 'n' inside 'ci' stack? */ /* generic name for any valid slot */ name = isLua(ci) ? "(temporary)" : "(C temporary)"; @@ -221,16 +221,16 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { const char *name; lua_lock(L); if (ar == NULL) { /* information about non-active function? */ - if (!isLfunction(s2v(L->top - 1))) /* not a Lua function? */ + if (!isLfunction(s2v(L->top.p - 1))) /* not a Lua function? */ name = NULL; else /* consider live variables at function start (parameters) */ - name = luaF_getlocalname(clLvalue(s2v(L->top - 1))->p, n, 0); + name = luaF_getlocalname(clLvalue(s2v(L->top.p - 1))->p, n, 0); } else { /* active function; get information through 'ar' */ StkId pos = NULL; /* to avoid warnings */ name = luaG_findlocal(L, ar->i_ci, n, &pos); if (name) { - setobjs2s(L, L->top, pos); + setobjs2s(L, L->top.p, pos); api_incr_top(L); } } @@ -245,8 +245,8 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { lua_lock(L); name = luaG_findlocal(L, ar->i_ci, n, &pos); if (name) { - setobjs2s(L, pos, L->top - 1); - L->top--; /* pop value */ + setobjs2s(L, pos, L->top.p - 1); + L->top.p--; /* pop value */ } lua_unlock(L); return name; @@ -289,7 +289,7 @@ static int nextline (const Proto *p, int currentline, int pc) { static void collectvalidlines (lua_State *L, Closure *f) { if (noLuaClosure(f)) { - setnilvalue(s2v(L->top)); + setnilvalue(s2v(L->top.p)); api_incr_top(L); } else { @@ -298,7 +298,7 @@ static void collectvalidlines (lua_State *L, Closure *f) { const Proto *p = f->l.p; int currentline = p->linedefined; Table *t = luaH_new(L); /* new table to store active lines */ - sethvalue2s(L, L->top, t); /* push it on stack */ + sethvalue2s(L, L->top.p, t); /* push it on stack */ api_incr_top(L); setbtvalue(&v); /* boolean 'true' to be the value of all indices */ if (!p->is_vararg) /* regular function? */ @@ -388,20 +388,20 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { lua_lock(L); if (*what == '>') { ci = NULL; - func = s2v(L->top - 1); + func = s2v(L->top.p - 1); api_check(L, ttisfunction(func), "function expected"); what++; /* skip the '>' */ - L->top--; /* pop function */ + L->top.p--; /* pop function */ } else { ci = ar->i_ci; - func = s2v(ci->func); + func = s2v(ci->func.p); lua_assert(ttisfunction(func)); } cl = ttisclosure(func) ? clvalue(func) : NULL; status = auxgetinfo(L, what, ar, cl, ci); if (strchr(what, 'f')) { - setobj2s(L, L->top, func); + setobj2s(L, L->top.p, func); api_incr_top(L); } if (strchr(what, 'L')) @@ -663,7 +663,7 @@ static const char *funcnamefromcall (lua_State *L, CallInfo *ci, */ static int isinstack (CallInfo *ci, const TValue *o) { StkId pos; - for (pos = ci->func + 1; pos < ci->top; pos++) { + for (pos = ci->func.p + 1; pos < ci->top.p; pos++) { if (o == s2v(pos)) return 1; } @@ -681,7 +681,7 @@ static const char *getupvalname (CallInfo *ci, const TValue *o, LClosure *c = ci_func(ci); int i; for (i = 0; i < c->nupvalues; i++) { - if (c->upvals[i]->v == o) { + if (c->upvals[i]->v.p == o) { *name = upvalname(c->p, i); return "upvalue"; } @@ -710,7 +710,7 @@ static const char *varinfo (lua_State *L, const TValue *o) { kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ if (!kind && isinstack(ci, o)) /* no? try a register */ kind = getobjname(ci_func(ci)->p, currentpc(ci), - cast_int(cast(StkId, o) - (ci->func + 1)), &name); + cast_int(cast(StkId, o) - (ci->func.p + 1)), &name); } return formatvarinfo(L, kind, name); } @@ -807,10 +807,10 @@ l_noret luaG_errormsg (lua_State *L) { if (L->errfunc != 0) { /* is there an error handling function? */ StkId errfunc = restorestack(L, L->errfunc); lua_assert(ttisfunction(s2v(errfunc))); - setobjs2s(L, L->top, L->top - 1); /* move argument */ - setobjs2s(L, L->top - 1, errfunc); /* push function */ - L->top++; /* assume EXTRA_STACK */ - luaD_callnoyield(L, L->top - 2, 1); /* call it */ + setobjs2s(L, L->top.p, L->top.p - 1); /* move argument */ + setobjs2s(L, L->top.p - 1, errfunc); /* push function */ + L->top.p++; /* assume EXTRA_STACK */ + luaD_callnoyield(L, L->top.p - 2, 1); /* call it */ } luaD_throw(L, LUA_ERRRUN); } @@ -826,8 +826,8 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { va_end(argp); if (isLua(ci)) { /* if Lua function, add source:line information */ luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci)); - setobjs2s(L, L->top - 2, L->top - 1); /* remove 'msg' from the stack */ - L->top--; + setobjs2s(L, L->top.p - 2, L->top.p - 1); /* remove 'msg' */ + L->top.p--; } luaG_errormsg(L); } @@ -872,7 +872,7 @@ static int changedline (const Proto *p, int oldpc, int newpc) { ** invalid; if so, use zero as a valid value. (A wrong but valid 'oldpc' ** at most causes an extra call to a line hook.) ** This function is not "Protected" when called, so it should correct -** 'L->top' before calling anything that can run the GC. +** 'L->top.p' before calling anything that can run the GC. */ int luaG_traceexec (lua_State *L, const Instruction *pc) { CallInfo *ci = L->ci; @@ -895,7 +895,7 @@ int luaG_traceexec (lua_State *L, const Instruction *pc) { return 1; /* do not call hook again (VM yielded, so it did not move) */ } if (!isIT(*(ci->u.l.savedpc - 1))) /* top not being used? */ - L->top = ci->top; /* correct top */ + L->top.p = ci->top.p; /* correct top */ if (counthook) luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */ if (mask & LUA_MASKLINE) { diff --git a/source/luametatex/source/luacore/lua54/src/ldebug.h b/source/luametatex/source/luacore/lua54/src/ldebug.h index 974960e99..2c3074c61 100644 --- a/source/luametatex/source/luacore/lua54/src/ldebug.h +++ b/source/luametatex/source/luacore/lua54/src/ldebug.h @@ -15,7 +15,7 @@ /* Active Lua function (given call info) */ -#define ci_func(ci) (clLvalue(s2v((ci)->func))) +#define ci_func(ci) (clLvalue(s2v((ci)->func.p))) #define resethookcount(L) (L->hookcount = L->basehookcount) diff --git a/source/luametatex/source/luacore/lua54/src/ldo.c b/source/luametatex/source/luacore/lua54/src/ldo.c index 419b3db93..c30cde76f 100644 --- a/source/luametatex/source/luacore/lua54/src/ldo.c +++ b/source/luametatex/source/luacore/lua54/src/ldo.c @@ -104,11 +104,11 @@ void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { } default: { lua_assert(errorstatus(errcode)); /* real error */ - setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + setobjs2s(L, oldtop, L->top.p - 1); /* error message on current top */ break; } } - L->top = oldtop + 1; + L->top.p = oldtop + 1; } @@ -121,7 +121,7 @@ l_noret luaD_throw (lua_State *L, int errcode) { global_State *g = G(L); errcode = luaE_resetthread(L, errcode); /* close all upvalues */ if (g->mainthread->errorJmp) { /* main thread has a handler? */ - setobjs2s(L, g->mainthread->top++, L->top - 1); /* copy error obj. */ + setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */ luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ } else { /* no handler at all; abort */ @@ -157,16 +157,38 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { ** Stack reallocation ** =================================================================== */ -static void correctstack (lua_State *L, StkId oldstack, StkId newstack) { + + +/* +** Change all pointers to the stack into offsets. +*/ +static void relstack (lua_State *L) { CallInfo *ci; UpVal *up; - L->top = (L->top - oldstack) + newstack; - L->tbclist = (L->tbclist - oldstack) + newstack; + L->top.offset = savestack(L, L->top.p); + L->tbclist.offset = savestack(L, L->tbclist.p); for (up = L->openupval; up != NULL; up = up->u.open.next) - up->v = s2v((uplevel(up) - oldstack) + newstack); + up->v.offset = savestack(L, uplevel(up)); for (ci = L->ci; ci != NULL; ci = ci->previous) { - ci->top = (ci->top - oldstack) + newstack; - ci->func = (ci->func - oldstack) + newstack; + ci->top.offset = savestack(L, ci->top.p); + ci->func.offset = savestack(L, ci->func.p); + } +} + + +/* +** Change back all offsets into pointers. +*/ +static void correctstack (lua_State *L) { + CallInfo *ci; + UpVal *up; + L->top.p = restorestack(L, L->top.offset); + L->tbclist.p = restorestack(L, L->tbclist.offset); + for (up = L->openupval; up != NULL; up = up->u.open.next) + up->v.p = s2v(restorestack(L, up->v.offset)); + for (ci = L->ci; ci != NULL; ci = ci->previous) { + ci->top.p = restorestack(L, ci->top.offset); + ci->func.p = restorestack(L, ci->func.offset); if (isLua(ci)) ci->u.l.trap = 1; /* signal to update 'trap' in 'luaV_execute' */ } @@ -176,38 +198,39 @@ static void correctstack (lua_State *L, StkId oldstack, StkId newstack) { /* some space for error handling */ #define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) - /* -** Reallocate the stack to a new size, correcting all pointers into -** it. (There are pointers to a stack from its upvalues, from its list -** of call infos, plus a few individual pointers.) The reallocation is -** done in two steps (allocation + free) because the correction must be -** done while both addresses (the old stack and the new one) are valid. -** (In ISO C, any pointer use after the pointer has been deallocated is -** undefined behavior.) +** Reallocate the stack to a new size, correcting all pointers into it. +** In ISO C, any pointer use after the pointer has been deallocated is +** undefined behavior. So, before the reallocation, all pointers are +** changed to offsets, and after the reallocation they are changed back +** to pointers. As during the reallocation the pointers are invalid, the +** reallocation cannot run emergency collections. +** ** In case of allocation error, raise an error or return false according ** to 'raiseerror'. */ int luaD_reallocstack (lua_State *L, int newsize, int raiseerror) { int oldsize = stacksize(L); int i; - StkId newstack = luaM_reallocvector(L, NULL, 0, - newsize + EXTRA_STACK, StackValue); + StkId newstack; + int oldgcstop = G(L)->gcstopem; lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); + relstack(L); /* change pointers to offsets */ + G(L)->gcstopem = 1; /* stop emergency collection */ + newstack = luaM_reallocvector(L, L->stack.p, oldsize + EXTRA_STACK, + newsize + EXTRA_STACK, StackValue); + G(L)->gcstopem = oldgcstop; /* restore emergency collection */ if (l_unlikely(newstack == NULL)) { /* reallocation failed? */ + correctstack(L); /* change offsets back to pointers */ if (raiseerror) luaM_error(L); else return 0; /* do not raise an error */ } - /* number of elements to be copied to the new stack */ - i = ((oldsize <= newsize) ? oldsize : newsize) + EXTRA_STACK; - memcpy(newstack, L->stack, i * sizeof(StackValue)); - for (; i < newsize + EXTRA_STACK; i++) + L->stack.p = newstack; + correctstack(L); /* change offsets back to pointers */ + L->stack_last.p = L->stack.p + newsize; + for (i = oldsize + EXTRA_STACK; i < newsize + EXTRA_STACK; i++) setnilvalue(s2v(newstack + i)); /* erase new segment */ - correctstack(L, L->stack, newstack); - luaM_freearray(L, L->stack, oldsize + EXTRA_STACK); - L->stack = newstack; - L->stack_last = L->stack + newsize; return 1; } @@ -229,7 +252,7 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) { } else if (n < LUAI_MAXSTACK) { /* avoids arithmetic overflows */ int newsize = 2 * size; /* tentative new size */ - int needed = cast_int(L->top - L->stack) + n; + int needed = cast_int(L->top.p - L->stack.p) + n; if (newsize > LUAI_MAXSTACK) /* cannot cross the limit */ newsize = LUAI_MAXSTACK; if (newsize < needed) /* but must respect what was asked for */ @@ -253,12 +276,12 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) { static int stackinuse (lua_State *L) { CallInfo *ci; int res; - StkId lim = L->top; + StkId lim = L->top.p; for (ci = L->ci; ci != NULL; ci = ci->previous) { - if (lim < ci->top) lim = ci->top; + if (lim < ci->top.p) lim = ci->top.p; } - lua_assert(lim <= L->stack_last + EXTRA_STACK); - res = cast_int(lim - L->stack) + 1; /* part of stack in use */ + lua_assert(lim <= L->stack_last.p + EXTRA_STACK); + res = cast_int(lim - L->stack.p) + 1; /* part of stack in use */ if (res < LUA_MINSTACK) res = LUA_MINSTACK; /* ensure a minimum size */ return res; @@ -295,7 +318,7 @@ void luaD_shrinkstack (lua_State *L) { void luaD_inctop (lua_State *L) { luaD_checkstack(L, 1); - L->top++; + L->top.p++; } /* }================================================================== */ @@ -312,8 +335,8 @@ void luaD_hook (lua_State *L, int event, int line, if (hook && L->allowhook) { /* make sure there is a hook */ int mask = CIST_HOOKED; CallInfo *ci = L->ci; - ptrdiff_t top = savestack(L, L->top); /* preserve original 'top' */ - ptrdiff_t ci_top = savestack(L, ci->top); /* idem for 'ci->top' */ + ptrdiff_t top = savestack(L, L->top.p); /* preserve original 'top' */ + ptrdiff_t ci_top = savestack(L, ci->top.p); /* idem for 'ci->top' */ lua_Debug ar; ar.event = event; ar.currentline = line; @@ -323,11 +346,11 @@ void luaD_hook (lua_State *L, int event, int line, ci->u2.transferinfo.ftransfer = ftransfer; ci->u2.transferinfo.ntransfer = ntransfer; } - if (isLua(ci) && L->top < ci->top) - L->top = ci->top; /* protect entire activation register */ + if (isLua(ci) && L->top.p < ci->top.p) + L->top.p = ci->top.p; /* protect entire activation register */ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ - if (ci->top < L->top + LUA_MINSTACK) - ci->top = L->top + LUA_MINSTACK; + if (ci->top.p < L->top.p + LUA_MINSTACK) + ci->top.p = L->top.p + LUA_MINSTACK; L->allowhook = 0; /* cannot call hooks inside a hook */ ci->callstatus |= mask; lua_unlock(L); @@ -335,8 +358,8 @@ void luaD_hook (lua_State *L, int event, int line, lua_lock(L); lua_assert(!L->allowhook); L->allowhook = 1; - ci->top = restorestack(L, ci_top); - L->top = restorestack(L, top); + ci->top.p = restorestack(L, ci_top); + L->top.p = restorestack(L, top); ci->callstatus &= ~mask; } } @@ -367,7 +390,7 @@ void luaD_hookcall (lua_State *L, CallInfo *ci) { */ static void rethook (lua_State *L, CallInfo *ci, int nres) { if (L->hookmask & LUA_MASKRET) { /* is return hook on? */ - StkId firstres = L->top - nres; /* index of first result */ + StkId firstres = L->top.p - nres; /* index of first result */ int delta = 0; /* correction for vararg functions */ int ftransfer; if (isLua(ci)) { @@ -375,10 +398,10 @@ static void rethook (lua_State *L, CallInfo *ci, int nres) { if (p->is_vararg) delta = ci->u.l.nextraargs + p->numparams + 1; } - ci->func += delta; /* if vararg, back to virtual 'func' */ - ftransfer = cast(unsigned short, firstres - ci->func); + ci->func.p += delta; /* if vararg, back to virtual 'func' */ + ftransfer = cast(unsigned short, firstres - ci->func.p); luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */ - ci->func -= delta; + ci->func.p -= delta; } if (isLua(ci = ci->previous)) L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p); /* set 'oldpc' */ @@ -397,9 +420,9 @@ StkId luaD_tryfuncTM (lua_State *L, StkId func) { tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */ if (l_unlikely(ttisnil(tm))) luaG_callerror(L, s2v(func)); /* nothing to call */ - for (p = L->top; p > func; p--) /* open space for metamethod */ + for (p = L->top.p; p > func; p--) /* open space for metamethod */ setobjs2s(L, p, p-1); - L->top++; /* stack space pre-allocated by the caller */ + L->top.p++; /* stack space pre-allocated by the caller */ setobj2s(L, func, tm); /* metamethod is the new function to be called */ return func; } @@ -416,14 +439,14 @@ l_sinline void moveresults (lua_State *L, StkId res, int nres, int wanted) { int i; switch (wanted) { /* handle typical cases separately */ case 0: /* no values needed */ - L->top = res; + L->top.p = res; return; case 1: /* one value needed */ if (nres == 0) /* no results? */ setnilvalue(s2v(res)); /* adjust with nil */ else /* at least one result */ - setobjs2s(L, res, L->top - nres); /* move it to proper place */ - L->top = res + 1; + setobjs2s(L, res, L->top.p - nres); /* move it to proper place */ + L->top.p = res + 1; return; case LUA_MULTRET: wanted = nres; /* we want all results */ @@ -446,14 +469,14 @@ l_sinline void moveresults (lua_State *L, StkId res, int nres, int wanted) { break; } /* generic case */ - firstresult = L->top - nres; /* index of first result */ + firstresult = L->top.p - nres; /* index of first result */ if (nres > wanted) /* extra results? */ nres = wanted; /* don't need them */ for (i = 0; i < nres; i++) /* move all results to correct place */ setobjs2s(L, res + i, firstresult + i); for (; i < wanted; i++) /* complete wanted number of results */ setnilvalue(s2v(res + i)); - L->top = res + wanted; /* top points after the last result */ + L->top.p = res + wanted; /* top points after the last result */ } @@ -468,7 +491,7 @@ void luaD_poscall (lua_State *L, CallInfo *ci, int nres) { if (l_unlikely(L->hookmask && !hastocloseCfunc(wanted))) rethook(L, ci, nres); /* move results to proper place */ - moveresults(L, ci->func, nres, wanted); + moveresults(L, ci->func.p, nres, wanted); /* function cannot be in any of these cases when returning */ lua_assert(!(ci->callstatus & (CIST_HOOKED | CIST_YPCALL | CIST_FIN | CIST_TRAN | CIST_CLSRET))); @@ -483,10 +506,10 @@ void luaD_poscall (lua_State *L, CallInfo *ci, int nres) { l_sinline CallInfo *prepCallInfo (lua_State *L, StkId func, int nret, int mask, StkId top) { CallInfo *ci = L->ci = next_ci(L); /* new frame */ - ci->func = func; + ci->func.p = func; ci->nresults = nret; ci->callstatus = mask; - ci->top = top; + ci->top.p = top; return ci; } @@ -500,10 +523,10 @@ l_sinline int precallC (lua_State *L, StkId func, int nresults, CallInfo *ci; checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ L->ci = ci = prepCallInfo(L, func, nresults, CIST_C, - L->top + LUA_MINSTACK); - lua_assert(ci->top <= L->stack_last); + L->top.p + LUA_MINSTACK); + lua_assert(ci->top.p <= L->stack_last.p); if (l_unlikely(L->hookmask & LUA_MASKCALL)) { - int narg = cast_int(L->top - func) - 1; + int narg = cast_int(L->top.p - func) - 1; luaD_hook(L, LUA_HOOKCALL, -1, 1, narg); } lua_unlock(L); @@ -535,17 +558,17 @@ int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int nfixparams = p->numparams; int i; checkstackGCp(L, fsize - delta, func); - ci->func -= delta; /* restore 'func' (if vararg) */ + ci->func.p -= delta; /* restore 'func' (if vararg) */ for (i = 0; i < narg1; i++) /* move down function and arguments */ - setobjs2s(L, ci->func + i, func + i); - func = ci->func; /* moved-down function */ + setobjs2s(L, ci->func.p + i, func + i); + func = ci->func.p; /* moved-down function */ for (; narg1 <= nfixparams; narg1++) setnilvalue(s2v(func + narg1)); /* complete missing arguments */ - ci->top = func + 1 + fsize; /* top for new function */ - lua_assert(ci->top <= L->stack_last); + ci->top.p = func + 1 + fsize; /* top for new function */ + lua_assert(ci->top.p <= L->stack_last.p); ci->u.l.savedpc = p->code; /* starting point */ ci->callstatus |= CIST_TAIL; - L->top = func + narg1; /* set top */ + L->top.p = func + narg1; /* set top */ return -1; } default: { /* not a function */ @@ -578,15 +601,15 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { case LUA_VLCL: { /* Lua function */ CallInfo *ci; Proto *p = clLvalue(s2v(func))->p; - int narg = cast_int(L->top - func) - 1; /* number of real arguments */ + int narg = cast_int(L->top.p - func) - 1; /* number of real arguments */ int nfixparams = p->numparams; int fsize = p->maxstacksize; /* frame size */ checkstackGCp(L, fsize, func); L->ci = ci = prepCallInfo(L, func, nresults, 0, func + 1 + fsize); ci->u.l.savedpc = p->code; /* starting point */ for (; narg < nfixparams; narg++) - setnilvalue(s2v(L->top++)); /* complete missing arguments */ - lua_assert(ci->top <= L->stack_last); + setnilvalue(s2v(L->top.p++)); /* complete missing arguments */ + lua_assert(ci->top.p <= L->stack_last.p); return ci; } default: { /* not a function */ @@ -748,8 +771,8 @@ static CallInfo *findpcall (lua_State *L) { ** coroutine error handler and should not kill the coroutine.) */ static int resume_error (lua_State *L, const char *msg, int narg) { - L->top -= narg; /* remove args from the stack */ - setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ + L->top.p -= narg; /* remove args from the stack */ + setsvalue2s(L, L->top.p, luaS_new(L, msg)); /* push error message */ api_incr_top(L); lua_unlock(L); return LUA_ERRRUN; @@ -765,7 +788,7 @@ static int resume_error (lua_State *L, const char *msg, int narg) { */ static void resume (lua_State *L, void *ud) { int n = *(cast(int*, ud)); /* number of arguments */ - StkId firstArg = L->top - n; /* first argument */ + StkId firstArg = L->top.p - n; /* first argument */ CallInfo *ci = L->ci; if (L->status == LUA_OK) /* starting a coroutine? */ ccall(L, firstArg - 1, LUA_MULTRET, 0); /* just call its body */ @@ -773,7 +796,7 @@ static void resume (lua_State *L, void *ud) { lua_assert(L->status == LUA_YIELD); L->status = LUA_OK; /* mark that it is running (again) */ if (isLua(ci)) { /* yielded inside a hook? */ - L->top = firstArg; /* discard arguments */ + L->top.p = firstArg; /* discard arguments */ luaV_execute(L, ci); /* just continue running Lua code */ } else { /* 'common' yield */ @@ -816,7 +839,7 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, if (L->status == LUA_OK) { /* may be starting a coroutine */ if (L->ci != &L->base_ci) /* not in base level? */ return resume_error(L, "cannot resume non-suspended coroutine", nargs); - else if (L->top - (L->ci->func + 1) == nargs) /* no function? */ + else if (L->top.p - (L->ci->func.p + 1) == nargs) /* no function? */ return resume_error(L, "cannot resume dead coroutine", nargs); } else if (L->status != LUA_YIELD) /* ended with errors? */ @@ -834,11 +857,11 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, lua_assert(status == L->status); /* normal end or yield */ else { /* unrecoverable error */ L->status = cast_byte(status); /* mark thread as 'dead' */ - luaD_seterrorobj(L, status, L->top); /* push error message */ - L->ci->top = L->top; + luaD_seterrorobj(L, status, L->top.p); /* push error message */ + L->ci->top.p = L->top.p; } *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield - : cast_int(L->top - (L->ci->func + 1)); + : cast_int(L->top.p - (L->ci->func.p + 1)); lua_unlock(L); return status; } @@ -993,7 +1016,7 @@ int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, p.dyd.gt.arr = NULL; p.dyd.gt.size = 0; p.dyd.label.arr = NULL; p.dyd.label.size = 0; luaZ_initbuffer(L, &p.buff); - status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top.p), L->errfunc); luaZ_freebuffer(L, &p.buff); luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size); luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size); diff --git a/source/luametatex/source/luacore/lua54/src/ldo.h b/source/luametatex/source/luacore/lua54/src/ldo.h index 4661aa007..1aa446ad0 100644 --- a/source/luametatex/source/luacore/lua54/src/ldo.h +++ b/source/luametatex/source/luacore/lua54/src/ldo.h @@ -8,6 +8,7 @@ #define ldo_h +#include "llimits.h" #include "lobject.h" #include "lstate.h" #include "lzio.h" @@ -23,7 +24,7 @@ ** at every check. */ #define luaD_checkstackaux(L,n,pre,pos) \ - if (l_unlikely(L->stack_last - L->top <= (n))) \ + if (l_unlikely(L->stack_last.p - L->top.p <= (n))) \ { pre; luaD_growstack(L, n, 1); pos; } \ else { condmovestack(L,pre,pos); } @@ -32,8 +33,8 @@ -#define savestack(L,p) ((char *)(p) - (char *)L->stack) -#define restorestack(L,n) ((StkId)((char *)L->stack + (n))) +#define savestack(L,pt) (cast_charp(pt) - cast_charp(L->stack.p)) +#define restorestack(L,n) cast(StkId, cast_charp(L->stack.p) + (n)) /* macro to check stack size, preserving 'p' */ diff --git a/source/luametatex/source/luacore/lua54/src/lfunc.c b/source/luametatex/source/luacore/lua54/src/lfunc.c index daba0abf5..0945f241d 100644 --- a/source/luametatex/source/luacore/lua54/src/lfunc.c +++ b/source/luametatex/source/luacore/lua54/src/lfunc.c @@ -50,8 +50,8 @@ void luaF_initupvals (lua_State *L, LClosure *cl) { for (i = 0; i < cl->nupvalues; i++) { GCObject *o = luaC_newobj(L, LUA_VUPVAL, sizeof(UpVal)); UpVal *uv = gco2upv(o); - uv->v = &uv->u.value; /* make it closed */ - setnilvalue(uv->v); + uv->v.p = &uv->u.value; /* make it closed */ + setnilvalue(uv->v.p); cl->upvals[i] = uv; luaC_objbarrier(L, cl, uv); } @@ -62,12 +62,11 @@ void luaF_initupvals (lua_State *L, LClosure *cl) { ** Create a new upvalue at the given level, and link it to the list of ** open upvalues of 'L' after entry 'prev'. **/ -static UpVal *newupval (lua_State *L, int tbc, StkId level, UpVal **prev) { +static UpVal *newupval (lua_State *L, StkId level, UpVal **prev) { GCObject *o = luaC_newobj(L, LUA_VUPVAL, sizeof(UpVal)); UpVal *uv = gco2upv(o); UpVal *next = *prev; - uv->v = s2v(level); /* current value lives in the stack */ - uv->tbc = tbc; + uv->v.p = s2v(level); /* current value lives in the stack */ uv->u.open.next = next; /* link it to list of open upvalues */ uv->u.open.previous = prev; if (next) @@ -96,7 +95,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) { pp = &p->u.open.next; } /* not found: create a new upvalue after 'pp' */ - return newupval(L, 0, level, pp); + return newupval(L, level, pp); } @@ -106,12 +105,12 @@ UpVal *luaF_findupval (lua_State *L, StkId level) { ** (This function assumes EXTRA_STACK.) */ static void callclosemethod (lua_State *L, TValue *obj, TValue *err, int yy) { - StkId top = L->top; + StkId top = L->top.p; const TValue *tm = luaT_gettmbyobj(L, obj, TM_CLOSE); setobj2s(L, top, tm); /* will call metamethod... */ setobj2s(L, top + 1, obj); /* with 'self' as the 1st argument */ setobj2s(L, top + 2, err); /* and error msg. as 2nd argument */ - L->top = top + 3; /* add function and arguments */ + L->top.p = top + 3; /* add function and arguments */ if (yy) luaD_call(L, top, 0); else @@ -126,7 +125,7 @@ static void callclosemethod (lua_State *L, TValue *obj, TValue *err, int yy) { static void checkclosemth (lua_State *L, StkId level) { const TValue *tm = luaT_gettmbyobj(L, s2v(level), TM_CLOSE); if (ttisnil(tm)) { /* no metamethod? */ - int idx = cast_int(level - L->ci->func); /* variable index */ + int idx = cast_int(level - L->ci->func.p); /* variable index */ const char *vname = luaG_findlocal(L, L->ci, idx, NULL); if (vname == NULL) vname = "?"; luaG_runerror(L, "variable '%s' got a non-closable value", vname); @@ -160,23 +159,23 @@ static void prepcallclosemth (lua_State *L, StkId level, int status, int yy) { ** is used.) */ #define MAXDELTA \ - ((256ul << ((sizeof(L->stack->tbclist.delta) - 1) * 8)) - 1) + ((256ul << ((sizeof(L->stack.p->tbclist.delta) - 1) * 8)) - 1) /* ** Insert a variable in the list of to-be-closed variables. */ void luaF_newtbcupval (lua_State *L, StkId level) { - lua_assert(level > L->tbclist); + lua_assert(level > L->tbclist.p); if (l_isfalse(s2v(level))) return; /* false doesn't need to be closed */ checkclosemth(L, level); /* value must have a close method */ - while (cast_uint(level - L->tbclist) > MAXDELTA) { - L->tbclist += MAXDELTA; /* create a dummy node at maximum delta */ - L->tbclist->tbclist.delta = 0; + while (cast_uint(level - L->tbclist.p) > MAXDELTA) { + L->tbclist.p += MAXDELTA; /* create a dummy node at maximum delta */ + L->tbclist.p->tbclist.delta = 0; } - level->tbclist.delta = cast(unsigned short, level - L->tbclist); - L->tbclist = level; + level->tbclist.delta = cast(unsigned short, level - L->tbclist.p); + L->tbclist.p = level; } @@ -196,10 +195,10 @@ void luaF_closeupval (lua_State *L, StkId level) { StkId upl; /* stack index pointed by 'uv' */ while ((uv = L->openupval) != NULL && (upl = uplevel(uv)) >= level) { TValue *slot = &uv->u.value; /* new position for value */ - lua_assert(uplevel(uv) < L->top); + lua_assert(uplevel(uv) < L->top.p); luaF_unlinkupval(uv); /* remove upvalue from 'openupval' list */ - setobj(L, slot, uv->v); /* move value to upvalue slot */ - uv->v = slot; /* now current value lives here */ + setobj(L, slot, uv->v.p); /* move value to upvalue slot */ + uv->v.p = slot; /* now current value lives here */ if (!iswhite(uv)) { /* neither white nor dead? */ nw2black(uv); /* closed upvalues cannot be gray */ luaC_barrier(L, uv, slot); @@ -212,12 +211,12 @@ void luaF_closeupval (lua_State *L, StkId level) { ** Remove first element from the tbclist plus its dummy nodes. */ static void poptbclist (lua_State *L) { - StkId tbc = L->tbclist; + StkId tbc = L->tbclist.p; lua_assert(tbc->tbclist.delta > 0); /* first element cannot be dummy */ tbc -= tbc->tbclist.delta; - while (tbc > L->stack && tbc->tbclist.delta == 0) + while (tbc > L->stack.p && tbc->tbclist.delta == 0) tbc -= MAXDELTA; /* remove dummy nodes */ - L->tbclist = tbc; + L->tbclist.p = tbc; } @@ -228,8 +227,8 @@ static void poptbclist (lua_State *L) { StkId luaF_close (lua_State *L, StkId level, int status, int yy) { ptrdiff_t levelrel = savestack(L, level); luaF_closeupval(L, level); /* first, close the upvalues */ - while (L->tbclist >= level) { /* traverse tbc's down to that level */ - StkId tbc = L->tbclist; /* get variable index */ + while (L->tbclist.p >= level) { /* traverse tbc's down to that level */ + StkId tbc = L->tbclist.p; /* get variable index */ poptbclist(L); /* remove it from list */ prepcallclosemth(L, tbc, status, yy); /* close variable */ level = restorestack(L, levelrel); diff --git a/source/luametatex/source/luacore/lua54/src/lfunc.h b/source/luametatex/source/luacore/lua54/src/lfunc.h index 3d296971e..3be265efb 100644 --- a/source/luametatex/source/luacore/lua54/src/lfunc.h +++ b/source/luametatex/source/luacore/lua54/src/lfunc.h @@ -29,10 +29,10 @@ #define MAXUPVAL 255 -#define upisopen(up) ((up)->v != &(up)->u.value) +#define upisopen(up) ((up)->v.p != &(up)->u.value) -#define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v)) +#define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v.p)) /* diff --git a/source/luametatex/source/luacore/lua54/src/lgc.c b/source/luametatex/source/luacore/lua54/src/lgc.c index 317ea4508..2e7499025 100644 --- a/source/luametatex/source/luacore/lua54/src/lgc.c +++ b/source/luametatex/source/luacore/lua54/src/lgc.c @@ -252,12 +252,13 @@ void luaC_fix (lua_State *L, GCObject *o) { /* -** create a new collectable object (with given type and size) and link -** it to 'allgc' list. +** create a new collectable object (with given type, size, and offset) +** and link it to 'allgc' list. */ -GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { +GCObject *luaC_newobjdt (lua_State *L, int tt, size_t sz, size_t offset) { global_State *g = G(L); - GCObject *o = cast(GCObject *, luaM_newobject(L, novariant(tt), sz)); + char *p = cast_charp(luaM_newobject(L, novariant(tt), sz)); + GCObject *o = cast(GCObject *, p + offset); o->marked = luaC_white(g); o->tt = tt; o->next = g->allgc; @@ -265,6 +266,11 @@ GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { return o; } + +GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { + return luaC_newobjdt(L, tt, sz, 0); +} + /* }====================================================== */ @@ -301,7 +307,7 @@ static void reallymarkobject (global_State *g, GCObject *o) { set2gray(uv); /* open upvalues are kept gray */ else set2black(uv); /* closed upvalues are visited here */ - markvalue(g, uv->v); /* mark its content */ + markvalue(g, uv->v.p); /* mark its content */ break; } case LUA_VUSERDATA: { @@ -376,7 +382,7 @@ static int remarkupvals (global_State *g) { work++; if (!iswhite(uv)) { /* upvalue already visited? */ lua_assert(upisopen(uv) && isgray(uv)); - markvalue(g, uv->v); /* mark its value */ + markvalue(g, uv->v.p); /* mark its value */ } } } @@ -620,19 +626,19 @@ static int traverseLclosure (global_State *g, LClosure *cl) { */ static int traversethread (global_State *g, lua_State *th) { UpVal *uv; - StkId o = th->stack; + StkId o = th->stack.p; if (isold(th) || g->gcstate == GCSpropagate) linkgclist(th, g->grayagain); /* insert into 'grayagain' list */ if (o == NULL) return 1; /* stack not completely built yet */ lua_assert(g->gcstate == GCSatomic || th->openupval == NULL || isintwups(th)); - for (; o < th->top; o++) /* mark live elements in the stack */ + for (; o < th->top.p; o++) /* mark live elements in the stack */ markvalue(g, s2v(o)); for (uv = th->openupval; uv != NULL; uv = uv->u.open.next) markobject(g, uv); /* open upvalues cannot be collected */ if (g->gcstate == GCSatomic) { /* final traversal? */ - for (; o < th->stack_last + EXTRA_STACK; o++) + for (; o < th->stack_last.p + EXTRA_STACK; o++) setnilvalue(s2v(o)); /* clear dead stack slice */ /* 'remarkupvals' may have removed thread from 'twups' list */ if (!isintwups(th) && th->openupval != NULL) { @@ -892,7 +898,7 @@ static GCObject *udata2finalize (global_State *g) { static void dothecall (lua_State *L, void *ud) { UNUSED(ud); - luaD_callnoyield(L, L->top - 2, 0); + luaD_callnoyield(L, L->top.p - 2, 0); } @@ -909,16 +915,16 @@ static void GCTM (lua_State *L) { int oldgcstp = g->gcstp; g->gcstp |= GCSTPGC; /* avoid GC steps */ L->allowhook = 0; /* stop debug hooks during GC metamethod */ - setobj2s(L, L->top++, tm); /* push finalizer... */ - setobj2s(L, L->top++, &v); /* ... and its argument */ + setobj2s(L, L->top.p++, tm); /* push finalizer... */ + setobj2s(L, L->top.p++, &v); /* ... and its argument */ L->ci->callstatus |= CIST_FIN; /* will run a finalizer */ - status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); + status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top.p - 2), 0); L->ci->callstatus &= ~CIST_FIN; /* not running a finalizer anymore */ L->allowhook = oldah; /* restore hooks */ g->gcstp = oldgcstp; /* restore state */ if (l_unlikely(status != LUA_OK)) { /* error while running __gc? */ luaE_warnerror(L, "__gc"); - L->top--; /* pops error object */ + L->top.p--; /* pops error object */ } } } diff --git a/source/luametatex/source/luacore/lua54/src/lgc.h b/source/luametatex/source/luacore/lua54/src/lgc.h index 4a125634b..c960e7064 100644 --- a/source/luametatex/source/luacore/lua54/src/lgc.h +++ b/source/luametatex/source/luacore/lua54/src/lgc.h @@ -190,6 +190,8 @@ LUAI_FUNC void luaC_step (lua_State *L); LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz); +LUAI_FUNC GCObject *luaC_newobjdt (lua_State *L, int tt, size_t sz, + size_t offset); LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v); LUAI_FUNC void luaC_barrierback_ (lua_State *L, GCObject *o); LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt); diff --git a/source/luametatex/source/luacore/lua54/src/llex.c b/source/luametatex/source/luacore/lua54/src/llex.c index e99151787..b0dc0acc2 100644 --- a/source/luametatex/source/luacore/lua54/src/llex.c +++ b/source/luametatex/source/luacore/lua54/src/llex.c @@ -138,12 +138,12 @@ TString *luaX_newstring (LexState *ls, const char *str, size_t l) { if (!ttisnil(o)) /* string already present? */ ts = keystrval(nodefromval(o)); /* get saved copy */ else { /* not in use yet */ - TValue *stv = s2v(L->top++); /* reserve stack space for string */ + TValue *stv = s2v(L->top.p++); /* reserve stack space for string */ setsvalue(L, stv, ts); /* temporarily anchor the string */ luaH_finishset(L, ls->h, stv, o, stv); /* t[string] = string */ /* table is not a metatable, so it does not need to invalidate cache */ luaC_checkGC(L); - L->top--; /* remove string from stack */ + L->top.p--; /* remove string from stack */ } return ts; } diff --git a/source/luametatex/source/luacore/lua54/src/lobject.c b/source/luametatex/source/luacore/lua54/src/lobject.c index 03e2798ca..f73ffc6d9 100644 --- a/source/luametatex/source/luacore/lua54/src/lobject.c +++ b/source/luametatex/source/luacore/lua54/src/lobject.c @@ -413,8 +413,8 @@ typedef struct BuffFS { */ static void pushstr (BuffFS *buff, const char *str, size_t lstr) { lua_State *L = buff->L; - setsvalue2s(L, L->top, luaS_newlstr(L, str, lstr)); - L->top++; /* may use one slot from EXTRA_STACK */ + setsvalue2s(L, L->top.p, luaS_newlstr(L, str, lstr)); + L->top.p++; /* may use one slot from EXTRA_STACK */ if (!buff->pushed) /* no previous string on the stack? */ buff->pushed = 1; /* now there is one */ else /* join previous string with new one */ @@ -542,7 +542,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { addstr2buff(&buff, fmt, strlen(fmt)); /* rest of 'fmt' */ clearbuff(&buff); /* empty buffer into the stack */ lua_assert(buff.pushed == 1); - return svalue(s2v(L->top - 1)); + return svalue(s2v(L->top.p - 1)); } diff --git a/source/luametatex/source/luacore/lua54/src/lobject.h b/source/luametatex/source/luacore/lua54/src/lobject.h index 77cc606f5..556608e4a 100644 --- a/source/luametatex/source/luacore/lua54/src/lobject.h +++ b/source/luametatex/source/luacore/lua54/src/lobject.h @@ -157,6 +157,17 @@ typedef union StackValue { /* index to stack elements */ typedef StackValue *StkId; + +/* +** When reallocating the stack, change all pointers to the stack into +** proper offsets. +*/ +typedef union { + StkId p; /* actual pointer */ + ptrdiff_t offset; /* used while the stack is being reallocated */ +} StkIdRel; + + /* convert a 'StackValue' to a 'TValue' */ #define s2v(o) (&(o)->val) @@ -617,8 +628,10 @@ typedef struct Proto { */ typedef struct UpVal { CommonHeader; - lu_byte tbc; /* true if it represents a to-be-closed variable */ - TValue *v; /* points to stack or to its own value */ + union { + TValue *p; /* points to stack or to its own value */ + ptrdiff_t offset; /* used while the stack is being reallocated */ + } v; union { struct { /* (when open) */ struct UpVal *next; /* linked list */ diff --git a/source/luametatex/source/luacore/lua54/src/lparser.c b/source/luametatex/source/luacore/lua54/src/lparser.c index fe693b571..24668c248 100644 --- a/source/luametatex/source/luacore/lua54/src/lparser.c +++ b/source/luametatex/source/luacore/lua54/src/lparser.c @@ -1944,10 +1944,10 @@ LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, LexState lexstate; FuncState funcstate; LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */ - setclLvalue2s(L, L->top, cl); /* anchor it (to avoid being collected) */ + setclLvalue2s(L, L->top.p, cl); /* anchor it (to avoid being collected) */ luaD_inctop(L); lexstate.h = luaH_new(L); /* create table for scanner */ - sethvalue2s(L, L->top, lexstate.h); /* anchor it */ + sethvalue2s(L, L->top.p, lexstate.h); /* anchor it */ luaD_inctop(L); funcstate.f = cl->p = luaF_newproto(L); luaC_objbarrier(L, cl, cl->p); @@ -1961,7 +1961,7 @@ LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); /* all scopes should be correctly finished */ lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); - L->top--; /* remove scanner's table */ + L->top.p--; /* remove scanner's table */ return cl; /* closure is on the stack, too */ } diff --git a/source/luametatex/source/luacore/lua54/src/lstate.c b/source/luametatex/source/luacore/lua54/src/lstate.c index 1ffe1a0f7..1fbefb4b1 100644 --- a/source/luametatex/source/luacore/lua54/src/lstate.c +++ b/source/luametatex/source/luacore/lua54/src/lstate.c @@ -180,33 +180,33 @@ LUAI_FUNC void luaE_incCstack (lua_State *L) { static void stack_init (lua_State *L1, lua_State *L) { int i; CallInfo *ci; /* initialize stack array */ - L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue); - L1->tbclist = L1->stack; + L1->stack.p = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue); + L1->tbclist.p = L1->stack.p; for (i = 0; i < BASIC_STACK_SIZE + EXTRA_STACK; i++) - setnilvalue(s2v(L1->stack + i)); /* erase new stack */ - L1->top = L1->stack; - L1->stack_last = L1->stack + BASIC_STACK_SIZE; + setnilvalue(s2v(L1->stack.p + i)); /* erase new stack */ + L1->top.p = L1->stack.p; + L1->stack_last.p = L1->stack.p + BASIC_STACK_SIZE; /* initialize first ci */ ci = &L1->base_ci; ci->next = ci->previous = NULL; ci->callstatus = CIST_C; - ci->func = L1->top; + ci->func.p = L1->top.p; ci->u.c.k = NULL; ci->nresults = 0; - setnilvalue(s2v(L1->top)); /* 'function' entry for this 'ci' */ - L1->top++; - ci->top = L1->top + LUA_MINSTACK; + setnilvalue(s2v(L1->top.p)); /* 'function' entry for this 'ci' */ + L1->top.p++; + ci->top.p = L1->top.p + LUA_MINSTACK; L1->ci = ci; } static void freestack (lua_State *L) { - if (L->stack == NULL) + if (L->stack.p == NULL) return; /* stack not completely built yet */ L->ci = &L->base_ci; /* free the entire 'ci' list */ luaE_freeCI(L); lua_assert(L->nci == 0); - luaM_freearray(L, L->stack, stacksize(L) + EXTRA_STACK); /* free stack */ + luaM_freearray(L, L->stack.p, stacksize(L) + EXTRA_STACK); /* free stack */ } @@ -248,7 +248,7 @@ static void f_luaopen (lua_State *L, void *ud) { */ static void preinit_thread (lua_State *L, global_State *g) { G(L) = g; - L->stack = NULL; + L->stack.p = NULL; L->ci = NULL; L->nci = 0; L->twups = L; /* thread has no upvalues */ @@ -284,20 +284,16 @@ static void close_state (lua_State *L) { LUA_API lua_State *lua_newthread (lua_State *L) { - global_State *g; + global_State *g = G(L); + GCObject *o; lua_State *L1; lua_lock(L); - g = G(L); luaC_checkGC(L); /* create new thread */ - L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; - L1->marked = luaC_white(g); - L1->tt = LUA_VTHREAD; - /* link it on list 'allgc' */ - L1->next = g->allgc; - g->allgc = obj2gco(L1); + o = luaC_newobjdt(L, LUA_TTHREAD, sizeof(LX), offsetof(LX, l)); + L1 = gco2th(o); /* anchor it on L stack */ - setthvalue2s(L, L->top, L1); + setthvalue2s(L, L->top.p, L1); api_incr_top(L); preinit_thread(L1, g); L1->hookmask = L->hookmask; @@ -316,7 +312,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) { void luaE_freethread (lua_State *L, lua_State *L1) { LX *l = fromstate(L1); - luaF_closeupval(L1, L1->stack); /* close all upvalues */ + luaF_closeupval(L1, L1->stack.p); /* close all upvalues */ lua_assert(L1->openupval == NULL); luai_userstatefree(L, L1); freestack(L1); @@ -326,26 +322,27 @@ void luaE_freethread (lua_State *L, lua_State *L1) { int luaE_resetthread (lua_State *L, int status) { CallInfo *ci = L->ci = &L->base_ci; /* unwind CallInfo list */ - setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */ - ci->func = L->stack; + setnilvalue(s2v(L->stack.p)); /* 'function' entry for basic 'ci' */ + ci->func.p = L->stack.p; ci->callstatus = CIST_C; if (status == LUA_YIELD) status = LUA_OK; L->status = LUA_OK; /* so it can run __close metamethods */ status = luaD_closeprotected(L, 1, status); if (status != LUA_OK) /* errors? */ - luaD_seterrorobj(L, status, L->stack + 1); + luaD_seterrorobj(L, status, L->stack.p + 1); else - L->top = L->stack + 1; - ci->top = L->top + LUA_MINSTACK; - luaD_reallocstack(L, cast_int(ci->top - L->stack), 0); + L->top.p = L->stack.p + 1; + ci->top.p = L->top.p + LUA_MINSTACK; + luaD_reallocstack(L, cast_int(ci->top.p - L->stack.p), 0); return status; } -LUA_API int lua_resetthread (lua_State *L) { +LUA_API int lua_resetthread (lua_State *L, lua_State *from) { int status; lua_lock(L); + L->nCcalls = (from) ? getCcalls(from) : 0; status = luaE_resetthread(L, L->status); lua_unlock(L); return status; @@ -426,7 +423,7 @@ void luaE_warning (lua_State *L, const char *msg, int tocont) { ** Generate a warning from an error message */ void luaE_warnerror (lua_State *L, const char *where) { - TValue *errobj = s2v(L->top - 1); /* error object */ + TValue *errobj = s2v(L->top.p - 1); /* error object */ const char *msg = (ttisstring(errobj)) ? svalue(errobj) : "error object is not a string"; diff --git a/source/luametatex/source/luacore/lua54/src/lstate.h b/source/luametatex/source/luacore/lua54/src/lstate.h index 61e82cde7..2e9078187 100644 --- a/source/luametatex/source/luacore/lua54/src/lstate.h +++ b/source/luametatex/source/luacore/lua54/src/lstate.h @@ -139,7 +139,7 @@ struct lua_longjmp; /* defined in ldo.c */ #define BASIC_STACK_SIZE (2*LUA_MINSTACK) -#define stacksize(th) cast_int((th)->stack_last - (th)->stack) +#define stacksize(th) cast_int((th)->stack_last.p - (th)->stack.p) /* kinds of Garbage Collection */ @@ -170,8 +170,8 @@ typedef struct stringtable { ** before the function starts or after it ends. */ typedef struct CallInfo { - StkId func; /* function index in the stack */ - StkId top; /* top for this function */ + StkIdRel func; /* function index in the stack */ + StkIdRel top; /* top for this function */ struct CallInfo *previous, *next; /* dynamic call link */ union { struct { /* only for Lua functions */ @@ -306,13 +306,13 @@ struct lua_State { lu_byte status; lu_byte allowhook; unsigned short nci; /* number of items in 'ci' list */ - StkId top; /* first free slot in the stack */ + StkIdRel top; /* first free slot in the stack */ global_State *l_G; CallInfo *ci; /* call info for current function */ - StkId stack_last; /* end of stack (last element + 1) */ - StkId stack; /* stack base */ + StkIdRel stack_last; /* end of stack (last element + 1) */ + StkIdRel stack; /* stack base */ UpVal *openupval; /* list of open upvalues in this stack */ - StkId tbclist; /* list of to-be-closed variables */ + StkIdRel tbclist; /* list of to-be-closed variables */ GCObject *gclist; struct lua_State *twups; /* list of threads with open upvalues */ struct lua_longjmp *errorJmp; /* current error recover point */ diff --git a/source/luametatex/source/luacore/lua54/src/ltable.c b/source/luametatex/source/luacore/lua54/src/ltable.c index d03e74865..cc7993e08 100644 --- a/source/luametatex/source/luacore/lua54/src/ltable.c +++ b/source/luametatex/source/luacore/lua54/src/ltable.c @@ -975,6 +975,4 @@ Node *luaH_mainposition (const Table *t, const TValue *key) { return mainpositionTV(t, key); } -int luaH_isdummy (const Table *t) { return isdummy(t); } - #endif diff --git a/source/luametatex/source/luacore/lua54/src/ltable.h b/source/luametatex/source/luacore/lua54/src/ltable.h index 7bbbcb213..75dd9e26e 100644 --- a/source/luametatex/source/luacore/lua54/src/ltable.h +++ b/source/luametatex/source/luacore/lua54/src/ltable.h @@ -59,7 +59,6 @@ LUAI_FUNC unsigned int luaH_realasize (const Table *t); #if defined(LUA_DEBUG) LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); -LUAI_FUNC int luaH_isdummy (const Table *t); #endif diff --git a/source/luametatex/source/luacore/lua54/src/ltm.c b/source/luametatex/source/luacore/lua54/src/ltm.c index b657b783a..07a060811 100644 --- a/source/luametatex/source/luacore/lua54/src/ltm.c +++ b/source/luametatex/source/luacore/lua54/src/ltm.c @@ -102,12 +102,12 @@ const char *luaT_objtypename (lua_State *L, const TValue *o) { void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, const TValue *p3) { - StkId func = L->top; + StkId func = L->top.p; setobj2s(L, func, f); /* push function (assume EXTRA_STACK) */ setobj2s(L, func + 1, p1); /* 1st argument */ setobj2s(L, func + 2, p2); /* 2nd argument */ setobj2s(L, func + 3, p3); /* 3rd argument */ - L->top = func + 4; + L->top.p = func + 4; /* metamethod may yield only when called from Lua code */ if (isLuacode(L->ci)) luaD_call(L, func, 0); @@ -119,18 +119,18 @@ void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, void luaT_callTMres (lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, StkId res) { ptrdiff_t result = savestack(L, res); - StkId func = L->top; + StkId func = L->top.p; setobj2s(L, func, f); /* push function (assume EXTRA_STACK) */ setobj2s(L, func + 1, p1); /* 1st argument */ setobj2s(L, func + 2, p2); /* 2nd argument */ - L->top += 3; + L->top.p += 3; /* metamethod may yield only when called from Lua code */ if (isLuacode(L->ci)) luaD_call(L, func, 1); else luaD_callnoyield(L, func, 1); res = restorestack(L, result); - setobjs2s(L, res, --L->top); /* move result to its place */ + setobjs2s(L, res, --L->top.p); /* move result to its place */ } @@ -165,7 +165,7 @@ void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, void luaT_tryconcatTM (lua_State *L) { - StkId top = L->top; + StkId top = L->top.p; if (l_unlikely(!callbinTM(L, s2v(top - 2), s2v(top - 1), top - 2, TM_CONCAT))) luaG_concaterror(L, s2v(top - 2), s2v(top - 1)); @@ -200,15 +200,15 @@ void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2, */ int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, TMS event) { - if (callbinTM(L, p1, p2, L->top, event)) /* try original event */ - return !l_isfalse(s2v(L->top)); + if (callbinTM(L, p1, p2, L->top.p, event)) /* try original event */ + return !l_isfalse(s2v(L->top.p)); #if defined(LUA_COMPAT_LT_LE) else if (event == TM_LE) { /* try '!(p2 < p1)' for '(p1 <= p2)' */ L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ - if (callbinTM(L, p2, p1, L->top, TM_LT)) { + if (callbinTM(L, p2, p1, L->top.p, TM_LT)) { L->ci->callstatus ^= CIST_LEQ; /* clear mark */ - return l_isfalse(s2v(L->top)); + return l_isfalse(s2v(L->top.p)); } /* else error will remove this 'ci'; no need to clear mark */ } @@ -238,20 +238,20 @@ int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci, const Proto *p) { int i; - int actual = cast_int(L->top - ci->func) - 1; /* number of arguments */ + int actual = cast_int(L->top.p - ci->func.p) - 1; /* number of arguments */ int nextra = actual - nfixparams; /* number of extra arguments */ ci->u.l.nextraargs = nextra; luaD_checkstack(L, p->maxstacksize + 1); /* copy function to the top of the stack */ - setobjs2s(L, L->top++, ci->func); + setobjs2s(L, L->top.p++, ci->func.p); /* move fixed parameters to the top of the stack */ for (i = 1; i <= nfixparams; i++) { - setobjs2s(L, L->top++, ci->func + i); - setnilvalue(s2v(ci->func + i)); /* erase original parameter (for GC) */ + setobjs2s(L, L->top.p++, ci->func.p + i); + setnilvalue(s2v(ci->func.p + i)); /* erase original parameter (for GC) */ } - ci->func += actual + 1; - ci->top += actual + 1; - lua_assert(L->top <= ci->top && ci->top <= L->stack_last); + ci->func.p += actual + 1; + ci->top.p += actual + 1; + lua_assert(L->top.p <= ci->top.p && ci->top.p <= L->stack_last.p); } @@ -261,10 +261,10 @@ void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) { if (wanted < 0) { wanted = nextra; /* get all extra arguments available */ checkstackGCp(L, nextra, where); /* ensure stack space */ - L->top = where + nextra; /* next instruction will need top */ + L->top.p = where + nextra; /* next instruction will need top */ } for (i = 0; i < wanted && i < nextra; i++) - setobjs2s(L, where + i, ci->func - nextra + i); + setobjs2s(L, where + i, ci->func.p - nextra + i); for (; i < wanted; i++) /* complete required results with nil */ setnilvalue(s2v(where + i)); } diff --git a/source/luametatex/source/luacore/lua54/src/lua.h b/source/luametatex/source/luacore/lua54/src/lua.h index 219784cc0..bfba4d1e1 100644 --- a/source/luametatex/source/luacore/lua54/src/lua.h +++ b/source/luametatex/source/luacore/lua54/src/lua.h @@ -153,7 +153,7 @@ extern const char lua_ident[]; LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); LUA_API void (lua_close) (lua_State *L); LUA_API lua_State *(lua_newthread) (lua_State *L); -LUA_API int (lua_resetthread) (lua_State *L); +LUA_API int (lua_resetthread) (lua_State *L, lua_State *from); LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); diff --git a/source/luametatex/source/luacore/lua54/src/lundump.c b/source/luametatex/source/luacore/lua54/src/lundump.c index 5aa55c445..aba93f828 100644 --- a/source/luametatex/source/luacore/lua54/src/lundump.c +++ b/source/luametatex/source/luacore/lua54/src/lundump.c @@ -120,10 +120,10 @@ static TString *loadStringN (LoadState *S, Proto *p) { } else { /* long string */ ts = luaS_createlngstrobj(L, size); /* create string */ - setsvalue2s(L, L->top, ts); /* anchor it ('loadVector' can GC) */ + setsvalue2s(L, L->top.p, ts); /* anchor it ('loadVector' can GC) */ luaD_inctop(L); loadVector(S, getstr(ts), size); /* load directly in final place */ - L->top--; /* pop string */ + L->top.p--; /* pop string */ } luaC_objbarrier(L, p, ts); return ts; @@ -321,7 +321,7 @@ LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) { S.Z = Z; checkHeader(&S); cl = luaF_newLclosure(L, loadByte(&S)); - setclLvalue2s(L, L->top, cl); + setclLvalue2s(L, L->top.p, cl); luaD_inctop(L); cl->p = luaF_newproto(L); luaC_objbarrier(L, cl, cl->p); diff --git a/source/luametatex/source/luacore/lua54/src/lvm.c b/source/luametatex/source/luacore/lua54/src/lvm.c index 73a19ba9b..2e84dc63c 100644 --- a/source/luametatex/source/luacore/lua54/src/lvm.c +++ b/source/luametatex/source/luacore/lua54/src/lvm.c @@ -608,8 +608,8 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { if (tm == NULL) /* no TM? */ return 0; /* objects are different */ else { - luaT_callTMres(L, tm, t1, t2, L->top); /* call TM */ - return !l_isfalse(s2v(L->top)); + luaT_callTMres(L, tm, t1, t2, L->top.p); /* call TM */ + return !l_isfalse(s2v(L->top.p)); } } @@ -633,13 +633,13 @@ static void copy2buff (StkId top, int n, char *buff) { /* ** Main operation for concatenation: concat 'total' values in the stack, -** from 'L->top - total' up to 'L->top - 1'. +** from 'L->top.p - total' up to 'L->top.p - 1'. */ void luaV_concat (lua_State *L, int total) { if (total == 1) return; /* "all" values already concatenated */ do { - StkId top = L->top; + StkId top = L->top.p; int n = 2; /* number of elements handled in this pass (at least 2) */ if (!(ttisstring(s2v(top - 2)) || cvt2str(s2v(top - 2))) || !tostring(L, s2v(top - 1))) @@ -657,7 +657,7 @@ void luaV_concat (lua_State *L, int total) { for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { size_t l = vslen(s2v(top - n - 1)); if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) { - L->top = top - total; /* pop strings to avoid wasting stack */ + L->top.p = top - total; /* pop strings to avoid wasting stack */ luaG_runerror(L, "string length overflow"); } tl += l; @@ -674,7 +674,7 @@ void luaV_concat (lua_State *L, int total) { setsvalue2s(L, top - n, ts); /* create result */ } total -= n - 1; /* got 'n' strings to create one new */ - L->top -= n - 1; /* popped 'n' strings and pushed one */ + L->top.p -= n - 1; /* popped 'n' strings and pushed one */ } while (total > 1); /* repeat until only 1 result left */ } @@ -808,26 +808,26 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, */ void luaV_finishOp (lua_State *L) { CallInfo *ci = L->ci; - StkId base = ci->func + 1; + StkId base = ci->func.p + 1; Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */ OpCode op = GET_OPCODE(inst); switch (op) { /* finish its execution */ case OP_MMBIN: case OP_MMBINI: case OP_MMBINK: { - setobjs2s(L, base + GETARG_A(*(ci->u.l.savedpc - 2)), --L->top); + setobjs2s(L, base + GETARG_A(*(ci->u.l.savedpc - 2)), --L->top.p); break; } case OP_UNM: case OP_BNOT: case OP_LEN: case OP_GETTABUP: case OP_GETTABLE: case OP_GETI: case OP_GETFIELD: case OP_SELF: { - setobjs2s(L, base + GETARG_A(inst), --L->top); + setobjs2s(L, base + GETARG_A(inst), --L->top.p); break; } case OP_LT: case OP_LE: case OP_LTI: case OP_LEI: case OP_GTI: case OP_GEI: case OP_EQ: { /* note that 'OP_EQI'/'OP_EQK' cannot yield */ - int res = !l_isfalse(s2v(L->top - 1)); - L->top--; + int res = !l_isfalse(s2v(L->top.p - 1)); + L->top.p--; #if defined(LUA_COMPAT_LT_LE) if (ci->callstatus & CIST_LEQ) { /* "<=" using "<" instead? */ ci->callstatus ^= CIST_LEQ; /* clear mark */ @@ -840,11 +840,11 @@ void luaV_finishOp (lua_State *L) { break; } case OP_CONCAT: { - StkId top = L->top - 1; /* top when 'luaT_tryconcatTM' was called */ + StkId top = L->top.p - 1; /* top when 'luaT_tryconcatTM' was called */ int a = GETARG_A(inst); /* first element to concatenate */ int total = cast_int(top - 1 - (base + a)); /* yet to concatenate */ setobjs2s(L, top - 2, top); /* put TM result in proper position */ - L->top = top - 1; /* top is one after last element (at top-2) */ + L->top.p = top - 1; /* top is one after last element (at top-2) */ luaV_concat(L, total); /* concat them (may yield again) */ break; } @@ -856,7 +856,7 @@ void luaV_finishOp (lua_State *L) { StkId ra = base + GETARG_A(inst); /* adjust top to signal correct number of returns, in case the return is "up to top" ('isIT') */ - L->top = ra + ci->u2.nres; + L->top.p = ra + ci->u2.nres; /* repeat instruction to close other vars. and complete the return */ ci->u.l.savedpc--; break; @@ -1069,7 +1069,7 @@ void luaV_finishOp (lua_State *L) { #define updatetrap(ci) (trap = ci->u.l.trap) -#define updatebase(ci) (base = ci->func + 1) +#define updatebase(ci) (base = ci->func.p + 1) #define updatestack(ci) \ @@ -1104,7 +1104,7 @@ void luaV_finishOp (lua_State *L) { ** Whenever code can raise errors, the global 'pc' and the global ** 'top' must be correct to report occasional errors. */ -#define savestate(L,ci) (savepc(L), L->top = ci->top) +#define savestate(L,ci) (savepc(L), L->top.p = ci->top.p) /* @@ -1124,7 +1124,7 @@ void luaV_finishOp (lua_State *L) { /* 'c' is the limit of live values in the stack */ #define checkGC(L,c) \ - { luaC_condGC(L, (savepc(L), L->top = (c)), \ + { luaC_condGC(L, (savepc(L), L->top.p = (c)), \ updatetrap(ci)); \ luai_threadyield(L); } @@ -1155,7 +1155,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { startfunc: trap = L->hookmask; returning: /* trap already set */ - cl = clLvalue(s2v(ci->func)); + cl = clLvalue(s2v(ci->func.p)); k = cl->p->k; pc = ci->u.l.savedpc; if (l_unlikely(trap)) { @@ -1167,7 +1167,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { } ci->u.l.trap = 1; /* assume trap is on, for now */ } - base = ci->func + 1; + base = ci->func.p + 1; /* main loop of interpreter */ for (;;) { Instruction i; /* instruction being executed */ @@ -1176,10 +1176,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { /* low-level line tracing for debugging Lua */ printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p))); #endif - lua_assert(base == ci->func + 1); - lua_assert(base <= L->top && L->top <= L->stack_last); + lua_assert(base == ci->func.p + 1); + lua_assert(base <= L->top.p && L->top.p <= L->stack_last.p); /* invalidate top for instructions not expecting it */ - lua_assert(isIT(i) || (cast_void(L->top = base), 1)); + lua_assert(isIT(i) || (cast_void(L->top.p = base), 1)); vmdispatch (GET_OPCODE(i)) { vmcase(OP_MOVE) { StkId ra = RA(i); @@ -1238,20 +1238,20 @@ void luaV_execute (lua_State *L, CallInfo *ci) { vmcase(OP_GETUPVAL) { StkId ra = RA(i); int b = GETARG_B(i); - setobj2s(L, ra, cl->upvals[b]->v); + setobj2s(L, ra, cl->upvals[b]->v.p); vmbreak; } vmcase(OP_SETUPVAL) { StkId ra = RA(i); UpVal *uv = cl->upvals[GETARG_B(i)]; - setobj(L, uv->v, s2v(ra)); + setobj(L, uv->v.p, s2v(ra)); luaC_barrier(L, uv, s2v(ra)); vmbreak; } vmcase(OP_GETTABUP) { StkId ra = RA(i); const TValue *slot; - TValue *upval = cl->upvals[GETARG_B(i)]->v; + TValue *upval = cl->upvals[GETARG_B(i)]->v.p; TValue *rc = KC(i); TString *key = tsvalue(rc); /* key must be a string */ if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) { @@ -1306,7 +1306,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { } vmcase(OP_SETTABUP) { const TValue *slot; - TValue *upval = cl->upvals[GETARG_A(i)]->v; + TValue *upval = cl->upvals[GETARG_A(i)]->v.p; TValue *rb = KB(i); TValue *rc = RKC(i); TString *key = tsvalue(rb); /* key must be a string */ @@ -1371,7 +1371,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { if (TESTARG_k(i)) /* non-zero extra argument? */ c += GETARG_Ax(*pc) * (MAXARG_C + 1); /* add it to size */ pc++; /* skip extra argument */ - L->top = ra + 1; /* correct top in case of emergency GC */ + L->top.p = ra + 1; /* correct top in case of emergency GC */ t = luaH_new(L); /* memory allocation */ sethvalue2s(L, ra, t); if (b != 0 || c != 0) @@ -1578,9 +1578,9 @@ void luaV_execute (lua_State *L, CallInfo *ci) { vmcase(OP_CONCAT) { StkId ra = RA(i); int n = GETARG_B(i); /* number of elements to concatenate */ - L->top = ra + n; /* mark the end of concat operands */ + L->top.p = ra + n; /* mark the end of concat operands */ ProtectNT(luaV_concat(L, n)); - checkGC(L, L->top); /* 'luaV_concat' ensures correct top */ + checkGC(L, L->top.p); /* 'luaV_concat' ensures correct top */ vmbreak; } vmcase(OP_CLOSE) { @@ -1674,7 +1674,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { int b = GETARG_B(i); int nresults = GETARG_C(i) - 1; if (b != 0) /* fixed number of arguments? */ - L->top = ra + b; /* top signals number of arguments */ + L->top.p = ra + b; /* top signals number of arguments */ /* else previous instruction set top */ savepc(L); /* in case of errors */ if ((newci = luaD_precall(L, ra, nresults)) == NULL) @@ -1693,19 +1693,19 @@ void luaV_execute (lua_State *L, CallInfo *ci) { /* delta is virtual 'func' - real 'func' (vararg functions) */ int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0; if (b != 0) - L->top = ra + b; + L->top.p = ra + b; else /* previous instruction set top */ - b = cast_int(L->top - ra); + b = cast_int(L->top.p - ra); savepc(ci); /* several calls here can raise errors */ if (TESTARG_k(i)) { luaF_closeupval(L, base); /* close upvalues from current call */ - lua_assert(L->tbclist < base); /* no pending tbc variables */ - lua_assert(base == ci->func + 1); + lua_assert(L->tbclist.p < base); /* no pending tbc variables */ + lua_assert(base == ci->func.p + 1); } if ((n = luaD_pretailcall(L, ci, ra, b, delta)) < 0) /* Lua function? */ goto startfunc; /* execute the callee */ else { /* C function? */ - ci->func -= delta; /* restore 'func' (if vararg) */ + ci->func.p -= delta; /* restore 'func' (if vararg) */ luaD_poscall(L, ci, n); /* finish caller */ updatetrap(ci); /* 'luaD_poscall' can change hooks */ goto ret; /* caller returns after the tail call */ @@ -1716,19 +1716,19 @@ void luaV_execute (lua_State *L, CallInfo *ci) { int n = GETARG_B(i) - 1; /* number of results */ int nparams1 = GETARG_C(i); if (n < 0) /* not fixed? */ - n = cast_int(L->top - ra); /* get what is available */ + n = cast_int(L->top.p - ra); /* get what is available */ savepc(ci); if (TESTARG_k(i)) { /* may there be open upvalues? */ ci->u2.nres = n; /* save number of returns */ - if (L->top < ci->top) - L->top = ci->top; + if (L->top.p < ci->top.p) + L->top.p = ci->top.p; luaF_close(L, base, CLOSEKTOP, 1); updatetrap(ci); updatestack(ci); } if (nparams1) /* vararg function? */ - ci->func -= ci->u.l.nextraargs + nparams1; - L->top = ra + n; /* set call for 'luaD_poscall' */ + ci->func.p -= ci->u.l.nextraargs + nparams1; + L->top.p = ra + n; /* set call for 'luaD_poscall' */ luaD_poscall(L, ci, n); updatetrap(ci); /* 'luaD_poscall' can change hooks */ goto ret; @@ -1736,7 +1736,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { vmcase(OP_RETURN0) { if (l_unlikely(L->hookmask)) { StkId ra = RA(i); - L->top = ra; + L->top.p = ra; savepc(ci); luaD_poscall(L, ci, 0); /* no hurry... */ trap = 1; @@ -1744,16 +1744,16 @@ void luaV_execute (lua_State *L, CallInfo *ci) { else { /* do the 'poscall' here */ int nres; L->ci = ci->previous; /* back to caller */ - L->top = base - 1; + L->top.p = base - 1; for (nres = ci->nresults; l_unlikely(nres > 0); nres--) - setnilvalue(s2v(L->top++)); /* all results are nil */ + setnilvalue(s2v(L->top.p++)); /* all results are nil */ } goto ret; } vmcase(OP_RETURN1) { if (l_unlikely(L->hookmask)) { StkId ra = RA(i); - L->top = ra + 1; + L->top.p = ra + 1; savepc(ci); luaD_poscall(L, ci, 1); /* no hurry... */ trap = 1; @@ -1762,13 +1762,13 @@ void luaV_execute (lua_State *L, CallInfo *ci) { int nres = ci->nresults; L->ci = ci->previous; /* back to caller */ if (nres == 0) - L->top = base - 1; /* asked for no results */ + L->top.p = base - 1; /* asked for no results */ else { StkId ra = RA(i); setobjs2s(L, base - 1, ra); /* at least this result */ - L->top = base; + L->top.p = base; for (; l_unlikely(nres > 1); nres--) - setnilvalue(s2v(L->top++)); /* complete missing results */ + setnilvalue(s2v(L->top.p++)); /* complete missing results */ } } ret: /* return from a Lua function */ @@ -1824,7 +1824,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { */ /* push function, state, and control variable */ memcpy(ra + 4, ra, 3 * sizeof(*ra)); - L->top = ra + 4 + 3; + L->top.p = ra + 4 + 3; ProtectNT(luaD_call(L, ra + 4, GETARG_C(i))); /* do the call */ updatestack(ci); /* stack may have changed */ i = *(pc++); /* go to next instruction */ @@ -1846,9 +1846,9 @@ void luaV_execute (lua_State *L, CallInfo *ci) { unsigned int last = GETARG_C(i); Table *h = hvalue(s2v(ra)); if (n == 0) - n = cast_int(L->top - ra) - 1; /* get up to the top */ + n = cast_int(L->top.p - ra) - 1; /* get up to the top */ else - L->top = ci->top; /* correct top in case of emergency GC */ + L->top.p = ci->top.p; /* correct top in case of emergency GC */ last += n; if (TESTARG_k(i)) { last += GETARG_Ax(*pc) * (MAXARG_C + 1); diff --git a/source/luametatex/source/luacore/luac/luac.c b/source/luametatex/source/luacore/luac/luac.c index 56ddc4148..39b63f855 100644 --- a/source/luametatex/source/luacore/luac/luac.c +++ b/source/luametatex/source/luacore/luac/luac.c @@ -138,7 +138,7 @@ static const char* reader(lua_State* L, void* ud, size_t* size) } } -#define toproto(L,i) getproto(s2v(L->top+(i))) +#define toproto(L,i) getproto(s2v(L->top.p+(i))) static const Proto* combine(lua_State* L, int n) { diff --git a/source/luametatex/source/luacore/luasocket/src/options.c b/source/luametatex/source/luacore/luasocket/src/options.c index 2b53c67b7..e68a2bcb0 100644 --- a/source/luametatex/source/luacore/luasocket/src/options.c +++ b/source/luametatex/source/luacore/luasocket/src/options.c @@ -2,6 +2,9 @@ * Common option interface * LuaSocket toolkit \*=========================================================================*/ + +# define _WIN32_WINNT _WIN32_WINNT_WIN8 + #include "luasocket.h" #include "auxiliar.h" #include "options.h" diff --git a/source/luametatex/source/luametatex.h b/source/luametatex/source/luametatex.h index 736d21173..514eb191d 100644 --- a/source/luametatex/source/luametatex.h +++ b/source/luametatex/source/luametatex.h @@ -89,7 +89,7 @@ # define luametatex_version 210 # define luametatex_revision 02 # define luametatex_version_string "2.10.02" -# define luametatex_development_id 20221019 +# define luametatex_development_id 20221105 # define luametatex_name_camelcase "LuaMetaTeX" # define luametatex_name_lowercase "luametatex" @@ -313,6 +313,7 @@ extern version_state_info lmt_version_state; # include "lua/lmtlanguagelib.h" # include "lua/lmtfontlib.h" # include "lua/lmtlualib.h" +# include "lua/lmtluaclib.h" # include "lua/lmttexlib.h" # include "lua/lmtenginelib.h" diff --git a/source/luametatex/source/luaoptional/lmtcurl.c b/source/luametatex/source/luaoptional/lmtcurl.c index 6a54174e5..d6a5dcf26 100644 --- a/source/luametatex/source/luaoptional/lmtcurl.c +++ b/source/luametatex/source/luaoptional/lmtcurl.c @@ -383,6 +383,7 @@ static int curllib_fetch(lua_State * L) if (lua_type(L,1) == LUA_TTABLE) { curl_instance *curl = curllib_state.curl_easy_init(); if (curl) { + int result; luaL_Buffer buffer; luaL_buffinit(L, &buffer); curllib_state.curl_easy_setopt(curl, curl_object_base + curl_option_writedata, &buffer); @@ -422,7 +423,7 @@ static int curllib_fetch(lua_State * L) } lua_pop(L, 1); /* removes 'value' and keeps 'key' for next iteration */ } - int result = curllib_state.curl_easy_perform(curl); + result = curllib_state.curl_easy_perform(curl); if (result) { lua_pushboolean(L, 0); lua_pushstring(L, curllib_state.curl_easy_strerror(result)); diff --git a/source/luametatex/source/luaoptional/lmtforeign.c b/source/luametatex/source/luaoptional/lmtforeign.c index da04eca12..b4cf014a8 100644 --- a/source/luametatex/source/luaoptional/lmtforeign.c +++ b/source/luametatex/source/luaoptional/lmtforeign.c @@ -918,7 +918,7 @@ static int foreignlib_function_call(lua_State *L) case foreign_type_ulong : { unsigned long r; foreign_state.ffi_call(cif, function->function, &r, arguments); lua_pushinteger(L, (unsigned long) r); break; } case foreign_type_longlong : { long long r; foreign_state.ffi_call(cif, function->function, &r, arguments); lua_pushinteger(L, (lua_Integer) r); break; } case foreign_type_ulonglong: { unsigned long long r; foreign_state.ffi_call(cif, function->function, &r, arguments); lua_pushinteger(L, (lua_Integer) r); break; } - case foreign_type_float : { float r; foreign_state.ffi_call(cif, function->function, &r, arguments); lua_pushnumber (L, r); break; } + case foreign_type_float : { float r; foreign_state.ffi_call(cif, function->function, &r, arguments); lua_pushnumber (L, (lua_Number) r); break; } case foreign_type_double : { double r; foreign_state.ffi_call(cif, function->function, &r, arguments); lua_pushnumber (L, r); break; } case foreign_type_size_t : { size_t r; foreign_state.ffi_call(cif, function->function, &r, arguments); lua_pushinteger(L, r); break; } case foreign_type_string : diff --git a/source/luametatex/source/luaoptional/lmtgraphicsmagick.c b/source/luametatex/source/luaoptional/lmtgraphicsmagick.c index c71c68c8c..51b30a745 100644 --- a/source/luametatex/source/luaoptional/lmtgraphicsmagick.c +++ b/source/luametatex/source/luaoptional/lmtgraphicsmagick.c @@ -147,7 +147,7 @@ static int gmlib_execute(lua_State * L) } if (lua_getfield(L, -1, "noise" ) == LUA_TTABLE) { lua_getfield(L, -1, "type"); - gmlib_state.gm_MagickAddNoiseImage(wand, lua_tointeger(L, -1)); + gmlib_state.gm_MagickAddNoiseImage(wand, lmt_tointeger(L, -1)); lua_pop(L, 2); } else { lua_pop(L, 1); diff --git a/source/luametatex/source/luaoptional/lmthb.c b/source/luametatex/source/luaoptional/lmthb.c index d853256cf..03c4a1720 100644 --- a/source/luametatex/source/luaoptional/lmthb.c +++ b/source/luametatex/source/luaoptional/lmthb.c @@ -3,6 +3,7 @@ */ # include "luametatex.h" +# include "lmtoptional.h" /*tex @@ -473,9 +474,9 @@ static int hblib_load_font(lua_State * L) hb_face_t *face = hblib_state.hb_face_create(blob, id); unsigned int scale = hblib_state.hb_face_get_upem(face); hb_font_t *font = hblib_state.hb_font_create(face); + hblib_data *data = lua_newuserdatauv(L, sizeof(data), 0); hblib_state.hb_font_set_scale(font, scale, scale); hblib_state.hb_ot_font_set_funcs(font); - hblib_data *data = lua_newuserdatauv(L, sizeof(data), 0); data->font = font; luaL_getmetatable(L, HBLIB_METATABLE); lua_setmetatable(L, -2); diff --git a/source/luametatex/source/luaoptional/lmtlz4.c b/source/luametatex/source/luaoptional/lmtlz4.c index d54442635..4d4542ac3 100644 --- a/source/luametatex/source/luaoptional/lmtlz4.c +++ b/source/luametatex/source/luaoptional/lmtlz4.c @@ -5,6 +5,7 @@ # include <stdlib.h> # include "luametatex.h" +# include "lmtoptional.h" # define LZ4F_VERSION 100 /* used to check for an incompatible API breaking change */ diff --git a/source/luametatex/source/luaoptional/lmtlzma.c b/source/luametatex/source/luaoptional/lmtlzma.c index 6ffe6fedf..e7b7db5b5 100644 --- a/source/luametatex/source/luaoptional/lmtlzma.c +++ b/source/luametatex/source/luaoptional/lmtlzma.c @@ -5,6 +5,7 @@ # include <stdlib.h> # include "luametatex.h" +# include "lmtoptional.h" /* We only need a few definitions and it's nice that they are already prepared for extensions. diff --git a/source/luametatex/source/luaoptional/lmtlzo.c b/source/luametatex/source/luaoptional/lmtlzo.c index 766e824ca..375a54bcb 100644 --- a/source/luametatex/source/luaoptional/lmtlzo.c +++ b/source/luametatex/source/luaoptional/lmtlzo.c @@ -5,6 +5,7 @@ # include <stdlib.h> # include "luametatex.h" +# include "lmtoptional.h" # define lzo_output_length(n) (n + n / 16 + 64 + 64) /* we add 64 instead of 3 */ diff --git a/source/luametatex/source/luarest/lmtiolibext.c b/source/luametatex/source/luarest/lmtiolibext.c index 319eb40c6..b78735504 100644 --- a/source/luametatex/source/luarest/lmtiolibext.c +++ b/source/luametatex/source/luarest/lmtiolibext.c @@ -1095,7 +1095,7 @@ static int fiolib_readcline(lua_State *L) FILE *f = lmt_valid_file(L); if (f) { luaL_Buffer buf; - int c; + int c = 0; int n = 0; luaL_buffinit(L, &buf); do { @@ -1178,7 +1178,7 @@ static int fiolib_readcstring(lua_State *L) FILE *f = lmt_valid_file(L); if (f) { luaL_Buffer buf; - int c; + int c = 0; int n = 0; luaL_buffinit(L, &buf); do { diff --git a/source/luametatex/source/luarest/lmtsparselib.c b/source/luametatex/source/luarest/lmtsparselib.c index a5b599cea..74ecb63f4 100644 --- a/source/luametatex/source/luarest/lmtsparselib.c +++ b/source/luametatex/source/luarest/lmtsparselib.c @@ -52,17 +52,17 @@ static int sparselib_new(lua_State *L) switch (bytes) { case 1: { - unsigned char d = (defval < 0 ? 0 : (defval > 0xFF ? 0xFF : defval)); + int d = defval < 0 ? 0 : (defval > 0xFF ? 0xFF : defval); for (int i = 0; i <= 3; i++) { - item.uchar_value[i] = d ; + item.uchar_value[i] = (unsigned char) d; } break; } case 2: { - unsigned short d = (defval < 0 ? 0 : (defval > 0xFFFF ? 0xFFFF : defval)); + int d = defval < 0 ? 0 : (defval > 0xFFFF ? 0xFFFF : defval); for (int i = 0; i <= 1; i++) { - item.ushort_value[i] = d ; + item.ushort_value[i] = (unsigned short) d; } break; } diff --git a/source/luametatex/source/mp/mpc/mp.c b/source/luametatex/source/mp/mpc/mp.c index 993bf98fb..beb836de6 100644 --- a/source/luametatex/source/mp/mpc/mp.c +++ b/source/luametatex/source/mp/mpc/mp.c @@ -54,9 +54,9 @@ # define max_num_knot_nodes 1000 # define max_num_value_nodes 1000 # define max_num_symbolic_nodes 1000 -# define mp_link(A) (A)->link -# define mp_type(A) (A)->type -# define mp_name_type(A) (A)->name_type +//define mp_link(A) (A)->link +//define mp_type(A) (A)->type +//define mp_name_type(A) (A)->name_type # define mp_set_link(A,B) (A)->link = (mp_node) (B) # define mp_max_command_code mp_stop # define mp_max_pre_command mp_etex_command @@ -143,8 +143,6 @@ # define one_third_inf_t mp->math->md_one_third_inf_t # define mp_copy_pen(mp,A) mp_make_pen(mp, mp_copy_path(mp, (A)),0) # define mp_pen_is_elliptical(A) ((A)==mp_next_knot((A))) -# define mp_fraction mp_number -# define mp_angle mp_number # define new_number(A) mp->math->md_allocate(mp, &(A), mp_scaled_type) # define new_fraction(A) mp->math->md_allocate(mp, &(A), mp_fraction_type) # define new_angle(A) mp->math->md_allocate(mp, &(A), mp_angle_type) @@ -243,8 +241,8 @@ # define mp_line_cap(A) ((mp_shape_node) (A))->linecap # define mp_line_join(A) ((mp_shape_node) (A))->linejoin # define mp_miterlimit(A) ((mp_shape_node) (A))->miterlimit -# define mp_set_linecap(A,B) ((mp_shape_node) (A))->linecap = (short) (B) -# define mp_set_linejoin(A,B) ((mp_shape_node) (A))->linejoin = (short) (B) +# define mp_set_linecap(A,B) ((mp_shape_node) (A))->linecap = (unsigned char) (B) +# define mp_set_linejoin(A,B) ((mp_shape_node) (A))->linejoin = (unsigned char) (B) # define mp_pre_script(A) ((mp_shape_node) (A))->pre_script # define mp_post_script(A) ((mp_shape_node) (A))->post_script # define mp_color_model(A) ((mp_shape_node) (A))->color_model @@ -259,11 +257,11 @@ # define mp_blue_color(A) ((mp_shape_node) (A))->blue # define mp_gray_color(A) ((mp_shape_node) (A))->grey # define mp_grey_color(A) ((mp_shape_node) (A))->grey -# define mp_has_color(A) (mp_type((A))<mp_start_clip_node_type) -# define mp_has_script(A) (mp_type((A))<=mp_start_bounds_node_type) -# define mp_has_pen(A) (mp_type((A))<=mp_stroked_node_type) -# define mp_is_start_or_stop(A) (mp_type((A))>=mp_start_clip_node_type) -# define mp_is_stop(A) (mp_type((A))>=mp_stop_clip_node_type) +# define mp_has_color(A) ((A)->type < mp_start_clip_node_type) +# define mp_has_script(A) ((A)->type <= mp_start_bounds_node_type) +# define mp_has_pen(A) ((A)->type <= mp_stroked_node_type) +# define mp_is_start_or_stop(A) ((A)->type >= mp_start_clip_node_type) +# define mp_is_stop(A) ((A)->type >= mp_stop_clip_node_type) # define mp_get_dash_list(A) (mp_dash_node) (((mp_dash_node) (A))->link) # define mp_set_dash_list(A,B) ((mp_dash_node) (A))->link = (mp_node) ((B)) # define mp_bblast(A) ((mp_edge_header_node) (A))->bblast @@ -413,7 +411,7 @@ if (mp_has_color(cp)) { \ break; \ } else { \ - cp = mp_link(cp); \ + cp = cp->link; \ } \ } \ } while (0) @@ -458,13 +456,13 @@ # define gr_dash_ptr(A) (A)->dash # define mp_gr_export_color(q,p) \ if (mp_color_model(p) == mp_uninitialized_model) { \ - gr_color_model(q) = number_to_scaled(internal_value(mp_default_color_model_internal))/65536; \ + gr_color_model(q) = (unsigned char) (number_to_scaled(internal_value(mp_default_color_model_internal))/65536); \ gr_cyan_val(q) = 0; \ gr_magenta_val(q) = 0; \ gr_yellow_val(q) = 0; \ gr_black_val(q) = gr_color_model(q) == mp_cmyk_model ? (number_to_scaled(unity_t)/65536.0) : 0; \ } else { \ - gr_color_model(q) = mp_color_model(p); \ + gr_color_model(q) = (unsigned char) mp_color_model(p); \ gr_cyan_val(q) = number_to_double(p->cyan); \ gr_magenta_val(q) = number_to_double(p->magenta); \ gr_yellow_val(q) = number_to_double(p->yellow); \ @@ -1655,7 +1653,7 @@ static void mp_free_node (MP mp, mp_node p, size_t siz) if (p->hasnumber == 2 && is_number(((mp_value_node) p)->subscript)) { free_number(((mp_value_node) p)->subscript); } - if (mp_type(p) == mp_dash_node_type) { + if (p->type == mp_dash_node_type) { free_number(((mp_dash_node) p)->start_x); free_number(((mp_dash_node) p)->stop_x); free_number(((mp_dash_node) p)->dash_y); @@ -2211,8 +2209,8 @@ static void mp_flush_token_list (MP mp, mp_node p) { while (p != NULL) { mp_node q = p; - p = mp_link(p); - switch (mp_type(q)) { + p = p->link; + switch (q->type) { case mp_symbol_node_type: mp_free_symbolic_node(mp, q); continue; @@ -2255,9 +2253,9 @@ void mp_show_token_list (MP mp, mp_node p, mp_node q) (void) q; while (p != NULL) { int c = mp_letter_class; - if (mp_type(p) != mp_symbol_node_type) { - if (mp_name_type(p) == mp_token_operation) { - if (mp_type(p) == mp_known_type) { + if (p->type != mp_symbol_node_type) { + if (p->name_type == mp_token_operation) { + if (p->type == mp_known_type) { if (cclass == mp_digit_class) { mp_print_chr(mp, ' '); } @@ -2273,7 +2271,7 @@ void mp_show_token_list (MP mp, mp_node p, mp_node q) print_number(mp_get_value_number(p)); c = mp_digit_class; } - } else if (mp_type(p) == mp_string_type) { + } else if (p->type == mp_string_type) { mp_print_chr(mp, '"'); mp_print_mp_str(mp, mp_get_value_str(p)); mp_print_chr(mp, '"'); @@ -2281,17 +2279,17 @@ void mp_show_token_list (MP mp, mp_node p, mp_node q) } else { mp_print_str(mp, " BAD"); } - } else if ((mp_name_type(p) != mp_capsule_operation) || (mp_type(p) < mp_vacuous_type) || (mp_type(p) > mp_independent_type)) { + } else if ((p->name_type != mp_capsule_operation) || (p->type < mp_vacuous_type) || (p->type > mp_independent_type)) { mp_print_str(mp, " BAD"); } else { mp_print_capsule(mp, p); c = mp_right_parenthesis_class; } - } else if (mp_name_type(p) == mp_expr_operation || mp_name_type(p) == mp_suffix_operation || mp_name_type(p) == mp_text_operation) { + } else if (p->name_type == mp_expr_operation || p->name_type == mp_suffix_operation || p->name_type == mp_text_operation) { int r = mp_get_sym_info(p); - if (mp_name_type(p) == mp_expr_operation) { + if (p->name_type == mp_expr_operation) { mp_print_str(mp, "(EXPR"); - } else if (mp_name_type(p) == mp_suffix_operation) { + } else if (p->name_type == mp_suffix_operation) { mp_print_str(mp, "(SUFFIX"); } else { mp_print_str(mp, "(TEXT"); @@ -2333,7 +2331,7 @@ void mp_show_token_list (MP mp, mp_node p, mp_node q) } } cclass = c; - p = mp_link(p); + p = p->link; } return; } @@ -2342,9 +2340,9 @@ void mp_show_token_list_space (MP mp, mp_node p, mp_node q) { (void) q; while (p != NULL) { - if (mp_type(p) != mp_symbol_node_type) { - if (mp_name_type(p) == mp_token_operation) { - if (mp_type(p) == mp_known_type) { + if (p->type != mp_symbol_node_type) { + if (p->name_type == mp_token_operation) { + if (p->type == mp_known_type) { if (number_negative(mp_get_value_number(p))) { mp_print_str(mp, "[ "); print_number(mp_get_value_number(p)); @@ -2352,23 +2350,23 @@ void mp_show_token_list_space (MP mp, mp_node p, mp_node q) } else { print_number(mp_get_value_number(p)); } - } else if (mp_type(p) == mp_string_type) { + } else if (p->type == mp_string_type) { mp_print_chr(mp, '"'); mp_print_mp_str(mp, mp_get_value_str(p)); mp_print_chr(mp, '"'); } else { mp_print_str(mp, "BAD"); } - } else if ((mp_name_type(p) != mp_capsule_operation) || (mp_type(p) < mp_vacuous_type) || (mp_type(p) > mp_independent_type)) { + } else if ((p->name_type != mp_capsule_operation) || (p->type < mp_vacuous_type) || (p->type > mp_independent_type)) { mp_print_str(mp, "BAD"); } else { mp_print_capsule(mp, p); } - } else if (mp_name_type(p) == mp_expr_operation || mp_name_type(p) == mp_suffix_operation || mp_name_type(p) == mp_text_operation) { + } else if (p->name_type == mp_expr_operation || p->name_type == mp_suffix_operation || p->name_type == mp_text_operation) { int r = mp_get_sym_info(p); - if (mp_name_type(p) == mp_expr_operation) { + if (p->name_type == mp_expr_operation) { mp_print_str(mp, "(EXPR "); - } else if (mp_name_type(p) == mp_suffix_operation) { + } else if (p->name_type == mp_suffix_operation) { mp_print_str(mp, "(SUFFIX "); } else { mp_print_str(mp, "(TEXT "); @@ -2388,7 +2386,7 @@ void mp_show_token_list_space (MP mp, mp_node p, mp_node q) } } } - p = mp_link(p); + p = p->link; if (p) { mp_print_chr(mp, ' '); } @@ -2407,12 +2405,12 @@ static void mp_delete_mac_ref (MP mp, mp_node p) static void mp_show_macro (MP mp, mp_node p, mp_node q) { - p = mp_link(p); - while (mp_name_type(p) != mp_macro_operation) { - mp_node r = mp_link(p); - mp_link(p) = NULL; + p = p->link; + while (p->name_type != mp_macro_operation) { + mp_node r = p->link; + p->link = NULL; mp_show_token_list(mp, p, NULL); - mp_link(p) = r; + p->link = r; p = r; } switch (mp_get_sym_info(p)) { @@ -2439,7 +2437,7 @@ static void mp_show_macro (MP mp, mp_node p, mp_node q) mp_print_str(mp, "<text> -> "); break; } - mp_show_token_list(mp, mp_link(p), q); + mp_show_token_list(mp, p->link, q); } static mp_node mp_do_get_attribute_head (MP mp, mp_value_node A) @@ -2480,7 +2478,7 @@ static mp_node mp_new_value_node (MP mp) new_number(p->subscript); p->hasnumber = 2; } - mp_type(p) = mp_value_node_type; + p->type = mp_value_node_type; return (mp_node) p; } @@ -2492,14 +2490,14 @@ static mp_node mp_new_value_node (MP mp) static mp_value_node mp_get_attribute_node (MP mp) { mp_value_node p = (mp_value_node) mp_new_value_node(mp); - mp_type(p) = mp_attribute_node_type; + p->type = mp_attribute_node_type; return p; } static mp_value_node mp_get_subscr_node (MP mp) { mp_value_node p = (mp_value_node) mp_new_value_node(mp); - mp_type(p) = mp_subscript_node_type; + p->type = mp_subscript_node_type; return p; } @@ -2514,7 +2512,7 @@ static mp_node mp_get_pair_node (MP mp) } else { p = mp_allocate_node(mp, sizeof(mp_pair_node_data)); } - mp_type(p) = mp_pair_node_type; + p->type = mp_pair_node_type; return (mp_node) p; } @@ -2535,97 +2533,96 @@ static void mp_free_pair_node (MP mp, mp_node p) static void mp_init_pair_node (MP mp, mp_node p) { mp_node q; - mp_type(p) = mp_pair_type; + p->type = mp_pair_type; q = mp_get_pair_node(mp); mp_y_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_y_part(q)); - mp_name_type(mp_y_part(q)) = mp_y_part_operation; - mp_link(mp_y_part(q)) = p; + mp_y_part(q)->name_type = mp_y_part_operation; + mp_y_part(q)->link = p; mp_x_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_x_part(q)); - mp_name_type(mp_x_part(q)) = mp_x_part_operation; - mp_link(mp_x_part(q)) = p; + mp_x_part(q)->name_type = mp_x_part_operation; + mp_x_part(q)->link = p; mp_set_value_node(p, q); } static mp_node mp_get_transform_node (MP mp) { mp_transform_node p = (mp_transform_node) mp_allocate_node(mp, sizeof(mp_transform_node_data)); - mp_type(p) = mp_transform_node_type; + p->type = mp_transform_node_type; return (mp_node) p; } static void mp_init_transform_node (MP mp, mp_node p) { mp_node q; - mp_type(p) = mp_transform_type; + p->type = mp_transform_type; q = mp_get_transform_node(mp); mp_yy_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_yy_part(q)); - mp_name_type(mp_yy_part(q)) = mp_yy_part_operation; - mp_link(mp_yy_part(q)) = p; + mp_yy_part(q)->name_type = mp_yy_part_operation; + mp_yy_part(q)->link = p; mp_yx_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_yx_part(q)); - mp_name_type(mp_yx_part(q)) = mp_yx_part_operation; - mp_link(mp_yx_part(q)) = p; + mp_yx_part(q)->name_type = mp_yx_part_operation; + mp_yx_part(q)->link = p; mp_xy_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_xy_part(q)); - mp_name_type(mp_xy_part(q)) = mp_xy_part_operation; - mp_link(mp_xy_part(q)) = p; + mp_xy_part(q)->name_type = mp_xy_part_operation; + mp_xy_part(q)->link = p; mp_xx_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_xx_part(q)); - mp_name_type(mp_xx_part(q)) = mp_xx_part_operation; - mp_link(mp_xx_part(q)) = p; + mp_xx_part(q)->name_type = mp_xx_part_operation; + mp_xx_part(q)->link = p; mp_ty_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_ty_part(q)); - mp_name_type(mp_ty_part(q)) = mp_y_part_operation; - mp_link(mp_ty_part(q)) = p; + mp_ty_part(q)->name_type = mp_y_part_operation; + mp_ty_part(q)->link = p; mp_tx_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_tx_part(q)); - mp_name_type(mp_tx_part(q)) = mp_x_part_operation; - mp_link(mp_tx_part(q)) = p; + mp_tx_part(q)->name_type = mp_x_part_operation; + mp_tx_part(q)->link = p; mp_set_value_node(p, q); } static void mp_init_color_node (MP mp, mp_node p, int type) { mp_node q = (mp_node) mp_allocate_node(mp, sizeof(mp_color_node_data)); - q->link = NULL; - mp_type(p) = type; + p->type = type; switch (type) { case mp_color_type: - mp_type(q) = mp_color_node_type; + q->type = mp_color_node_type; mp_red_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_red_part(q)); - mp_name_type(mp_red_part(q)) = mp_red_part_operation; - mp_link(mp_red_part(q)) = p; + mp_red_part(q)->name_type = mp_red_part_operation; + mp_red_part(q)->link = p; mp_green_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_green_part(q)); - mp_name_type(mp_green_part(q)) = mp_green_part_operation; - mp_link(mp_green_part(q)) = p; + mp_green_part(q)->name_type = mp_green_part_operation; + mp_green_part(q)->link = p; mp_blue_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_blue_part(q)); - mp_name_type(mp_blue_part(q)) = mp_blue_part_operation; - mp_link(mp_blue_part(q)) = p; + mp_blue_part(q)->name_type = mp_blue_part_operation; + mp_blue_part(q)->link = p; break; case mp_cmykcolor_type: - mp_type(q) = mp_cmykcolor_node_type; + q->type = mp_cmykcolor_node_type; mp_cyan_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_cyan_part(q)); - mp_name_type(mp_cyan_part(q)) = mp_cyan_part_operation; - mp_link(mp_cyan_part(q)) = p; + mp_cyan_part(q)->name_type = mp_cyan_part_operation; + mp_cyan_part(q)->link = p; mp_magenta_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_magenta_part(q)); - mp_name_type(mp_magenta_part(q)) = mp_magenta_part_operation; - mp_link(mp_magenta_part(q)) = p; + mp_magenta_part(q)->name_type = mp_magenta_part_operation; + mp_magenta_part(q)->link = p; mp_yellow_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_yellow_part(q)); - mp_name_type(mp_yellow_part(q)) = mp_yellow_part_operation; - mp_link(mp_yellow_part(q)) = p; + mp_yellow_part(q)->name_type = mp_yellow_part_operation; + mp_yellow_part(q)->link = p; mp_black_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_black_part(q)); - mp_name_type(mp_black_part(q)) = mp_black_part_operation; - mp_link(mp_black_part(q)) = p; + mp_black_part(q)->name_type = mp_black_part_operation; + mp_black_part(q)->link = p; break; } mp_set_value_node(p, q); @@ -2635,21 +2632,21 @@ static mp_node mp_id_transform (MP mp) { mp_node q; mp_node p = mp_new_value_node(mp); - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp_set_value_number(p, zero_t); mp_init_transform_node(mp, p); q = mp_get_value_node(p); - mp_type(mp_tx_part(q)) = mp_known_type; + mp_tx_part(q)->type = mp_known_type; mp_set_value_number(mp_tx_part(q), zero_t); - mp_type(mp_ty_part(q)) = mp_known_type; + mp_ty_part(q)->type = mp_known_type; mp_set_value_number(mp_ty_part(q), zero_t); - mp_type(mp_xy_part(q)) = mp_known_type; + mp_xy_part(q)->type = mp_known_type; mp_set_value_number(mp_xy_part(q), zero_t); - mp_type(mp_yx_part(q)) = mp_known_type; + mp_yx_part(q)->type = mp_known_type; mp_set_value_number(mp_yx_part(q), zero_t); - mp_type(mp_xx_part(q)) = mp_known_type; + mp_xx_part(q)->type = mp_known_type; mp_set_value_number(mp_xx_part(q), unity_t); - mp_type(mp_yy_part(q)) = mp_known_type; + mp_yy_part(q)->type = mp_known_type; mp_set_value_number(mp_yy_part(q), unity_t); return p; } @@ -2657,8 +2654,8 @@ static mp_node mp_id_transform (MP mp) static void mp_new_root (MP mp, mp_sym x) { mp_node p = mp_new_value_node(mp); - mp_type(p) = mp_undefined_type; - mp_name_type(p) = mp_root_operation; + p->type = mp_undefined_type; + p->name_type = mp_root_operation; mp_set_value_sym(p, x); set_equiv_node(x, p); } @@ -2667,8 +2664,8 @@ void mp_print_variable_name (MP mp, mp_node p) { mp_node q = NULL; mp_node r = NULL; - while (mp_name_type(p) >= mp_x_part_operation) { - switch (mp_name_type(p)) { + while (p->name_type >= mp_x_part_operation) { + switch (p->name_type) { case mp_x_part_operation : mp_print_str(mp, "xpart "); break; case mp_y_part_operation : mp_print_str(mp, "ypart "); break; case mp_xx_part_operation : mp_print_str(mp, "xxpart "); break; @@ -2686,18 +2683,18 @@ void mp_print_variable_name (MP mp, mp_node p) case mp_capsule_operation : mp_print_fmt(mp, "%%CAPSULE%p", p); return; default : break; } - p = mp_link(p); + p = p->link; } - while (mp_name_type(p) > mp_saved_root_operation) { - if (mp_name_type(p) == mp_subscript_operation) { + while (p->name_type > mp_saved_root_operation) { + if (p->name_type == mp_subscript_operation) { r = mp_new_num_tok(mp, &(mp_subscript(p))); do { - p = mp_link(p); - } while (mp_name_type(p) != mp_attribute_operation); - } else if (mp_name_type(p) == mp_structured_root_operation) { - p = mp_link(p); + p = p->link; + } while (p->name_type != mp_attribute_operation); + } else if (p->name_type == mp_structured_root_operation) { + p = p->link; goto FOUND; - } else if (mp_name_type(p) != mp_attribute_operation) { + } else if (p->name_type != mp_attribute_operation) { mp_confusion(mp, "variable"); } else { r = mp_new_symbolic_node(mp); @@ -2710,8 +2707,8 @@ void mp_print_variable_name (MP mp, mp_node p) } r = mp_new_symbolic_node(mp); mp_set_sym_sym(r, mp_get_value_sym(p)); - mp_link(r) = q; - if (mp_name_type(p) == mp_saved_root_operation) { + r->link = q; + if (p->name_type == mp_saved_root_operation) { mp_print_str(mp, "(SAVED)"); } mp_show_token_list(mp, r, NULL); @@ -2723,25 +2720,25 @@ static int mp_interesting (MP mp, mp_node p) if (number_positive(internal_value(mp_tracing_capsules_internal))) { return 1; } else { - mp_name_type_type t = mp_name_type(p); + mp_name_type_type t = p->name_type; if (t >= mp_x_part_operation && t != mp_capsule_operation) { - mp_node tt = mp_get_value_node(mp_link(p)); + mp_node tt = mp_get_value_node(p->link); switch (t) { - case mp_x_part_operation: t = mp_name_type(mp_x_part (tt)); break; - case mp_y_part_operation: t = mp_name_type(mp_y_part (tt)); break; - case mp_xx_part_operation: t = mp_name_type(mp_xx_part (tt)); break; - case mp_xy_part_operation: t = mp_name_type(mp_xy_part (tt)); break; - case mp_yx_part_operation: t = mp_name_type(mp_yx_part (tt)); break; - case mp_yy_part_operation: t = mp_name_type(mp_yy_part (tt)); break; - case mp_red_part_operation: t = mp_name_type(mp_red_part (tt)); break; - case mp_green_part_operation: t = mp_name_type(mp_green_part (tt)); break; - case mp_blue_part_operation: t = mp_name_type(mp_blue_part (tt)); break; - case mp_cyan_part_operation: t = mp_name_type(mp_cyan_part (tt)); break; - case mp_magenta_part_operation: t = mp_name_type(mp_magenta_part(tt)); break; - case mp_yellow_part_operation: t = mp_name_type(mp_yellow_part (tt)); break; - case mp_black_part_operation: t = mp_name_type(mp_black_part (tt)); break; - case mp_grey_part_operation: t = mp_name_type(mp_grey_part (tt)); break; - default: break; + case mp_x_part_operation: t = mp_x_part (tt)->name_type; break; + case mp_y_part_operation: t = mp_y_part (tt)->name_type; break; + case mp_xx_part_operation: t = mp_xx_part (tt)->name_type; break; + case mp_xy_part_operation: t = mp_xy_part (tt)->name_type; break; + case mp_yx_part_operation: t = mp_yx_part (tt)->name_type; break; + case mp_yy_part_operation: t = mp_yy_part (tt)->name_type; break; + case mp_red_part_operation: t = mp_red_part (tt)->name_type; break; + case mp_green_part_operation: t = mp_green_part (tt)->name_type; break; + case mp_blue_part_operation: t = mp_blue_part (tt)->name_type; break; + case mp_cyan_part_operation: t = mp_cyan_part (tt)->name_type; break; + case mp_magenta_part_operation: t = mp_magenta_part(tt)->name_type; break; + case mp_yellow_part_operation: t = mp_yellow_part (tt)->name_type; break; + case mp_black_part_operation: t = mp_black_part (tt)->name_type; break; + case mp_grey_part_operation: t = mp_grey_part (tt)->name_type; break; + default: break; } } return (t != mp_capsule_operation); @@ -2751,7 +2748,7 @@ static int mp_interesting (MP mp, mp_node p) static mp_node mp_new_structure (MP mp, mp_node p) { mp_node r = NULL; - switch (mp_name_type(p)) { + switch (p->name_type) { case mp_root_operation: { mp_sym q = mp_get_value_sym(p); @@ -2764,14 +2761,14 @@ static mp_node mp_new_structure (MP mp, mp_node p) mp_node q_new; mp_node q = p; do { - q = mp_link(q); - } while (mp_name_type(q) != mp_attribute_operation); + q = q->link; + } while (q->name_type != mp_attribute_operation); q = mp_get_parent((mp_value_node) q); r = mp->temp_head; mp_set_link(r, mp_get_subscr_head(q)); do { q_new = r; - r = mp_link(r); + r = r->link; } while (r != p); r = (mp_node) mp_get_subscr_node(mp); if (q_new == mp->temp_head) { @@ -2789,7 +2786,7 @@ static mp_node mp_new_structure (MP mp, mp_node p) r = mp_get_attribute_head(q); do { q = r; - r = mp_link(r); + r = r->link; } while (r != p); rr = mp_get_attribute_node(mp); r = (mp_node) rr; @@ -2799,8 +2796,8 @@ static mp_node mp_new_structure (MP mp, mp_node p) if (mp_get_hashloc(p) == mp_collective_subscript) { q = mp->temp_head; mp_set_link(q, mp_get_subscr_head(mp_get_parent((mp_value_node) p))); - while (mp_link(q) != p) { - q = mp_link(q); + while (q->link != p) { + q = q->link; } if (q == mp->temp_head) { mp_set_subscr_head(mp_get_parent((mp_value_node) p), (mp_node) rr); @@ -2816,18 +2813,18 @@ static mp_node mp_new_structure (MP mp, mp_node p) } if (r) { mp_value_node q; - mp_set_link(r, mp_link(p)); + mp_set_link(r, p->link); mp_set_value_sym(r, mp_get_value_sym(p)); - mp_type(r) = mp_structured_type; - mp_name_type(r) = mp_name_type(p); + r->type = mp_structured_type; + r->name_type = p->name_type; mp_set_attribute_head(r, p); - mp_name_type(p) = mp_structured_root_operation; + p->name_type = mp_structured_root_operation; q = mp_get_attribute_node(mp); mp_set_link(p, q); mp_set_subscr_head(r, (mp_node) q); mp_set_parent(q, r); - mp_type(q) = mp_undefined_type; - mp_name_type(q) = mp_attribute_operation; + q->type = mp_undefined_type; + q->name_type = mp_attribute_operation; mp_set_link(q, mp->end_attr); mp_set_hashloc(q, mp_collective_subscript); } @@ -2843,15 +2840,15 @@ static mp_node mp_find_variable (MP mp, mp_node t) } else { mp_node p, q, r, s; mp_node pp, qq, rr, ss; - t = mp_link(t); + t = t->link; if (equiv_node(p_sym) == NULL) { mp_new_root (mp, p_sym); } p = equiv_node(p_sym); pp = p; while (t != NULL) { - if (mp_type(pp) != mp_structured_type) { - if (mp_type(pp) > mp_structured_type) { + if (pp->type != mp_structured_type) { + if (pp->type > mp_structured_type) { return NULL; } else { ss = mp_new_structure(mp, pp); @@ -2861,21 +2858,21 @@ static mp_node mp_find_variable (MP mp, mp_node t) pp = ss; } } - if (mp_type(p) != mp_structured_type) { + if (p->type != mp_structured_type) { p = mp_new_structure(mp, p); } - if (mp_type(t) != mp_symbol_node_type) { + if (t->type != mp_symbol_node_type) { mp_number nn, save_subscript; new_number_clone(nn, mp_get_value_number(t)); - pp = mp_link(mp_get_attribute_head(pp)); - q = mp_link(mp_get_attribute_head(p)); + pp = mp_get_attribute_head(pp)->link; + q = mp_get_attribute_head(p)->link; new_number_clone(save_subscript, mp_subscript(q)); set_number_to_inf(mp_subscript(q)); s = mp->temp_head; mp_set_link(s, mp_get_subscr_head(p)); do { r = s; - s = mp_link(s); + s = s->link; } while (number_greater(nn, mp_subscript(s))); if (number_equal(nn, mp_subscript(s))) { p = s; @@ -2888,8 +2885,8 @@ static mp_node mp_find_variable (MP mp, mp_node t) } mp_set_link(p1, s); number_clone(mp_subscript(p1), nn); - mp_name_type(p1) = mp_subscript_operation; - mp_type(p1) = mp_undefined_type; + p1->name_type = mp_subscript_operation; + p1->type = mp_undefined_type; p = (mp_node) p1; } number_clone(mp_subscript(q), save_subscript); @@ -2900,15 +2897,15 @@ static mp_node mp_find_variable (MP mp, mp_node t) ss = mp_get_attribute_head(pp); do { rr = ss; - ss = mp_link(ss); + ss = ss->link; } while (nn1 > mp_get_hashloc(ss)); if (nn1 < mp_get_hashloc(ss)) { qq = (mp_node) mp_get_attribute_node(mp); mp_set_link(rr, qq); mp_set_link(qq, ss); mp_set_hashloc(qq, nn1); - mp_name_type(qq) = mp_attribute_operation; - mp_type(qq) = mp_undefined_type; + qq->name_type = mp_attribute_operation; + qq->type = mp_undefined_type; mp_set_parent((mp_value_node) qq, pp); ss = qq; } @@ -2920,7 +2917,7 @@ static mp_node mp_find_variable (MP mp, mp_node t) s = mp_get_attribute_head(p); do { r = s; - s = mp_link(s); + s = s->link; } while (nn1 > mp_get_hashloc(s)); if (nn1 == mp_get_hashloc(s)) { p = s; @@ -2929,31 +2926,31 @@ static mp_node mp_find_variable (MP mp, mp_node t) mp_set_link(r, q); mp_set_link(q, s); mp_set_hashloc(q, nn1); - mp_name_type(q) = mp_attribute_operation; - mp_type(q) = mp_undefined_type; + q->name_type = mp_attribute_operation; + q->type = mp_undefined_type; mp_set_parent((mp_value_node) q, p); p = q; } } } - t = mp_link(t); + t = t->link; } - if (mp_type(pp) >= mp_structured_type) { - if (mp_type(pp) == mp_structured_type) { + if (pp->type >= mp_structured_type) { + if (pp->type == mp_structured_type) { pp = mp_get_attribute_head(pp); } else { return NULL; } } - if (mp_type(p) == mp_structured_type) { + if (p->type == mp_structured_type) { p = mp_get_attribute_head(p); } - if (mp_type(p) == mp_undefined_type) { - if (mp_type(pp) == mp_undefined_type) { - mp_type(pp) = mp_numeric_type; + if (p->type == mp_undefined_type) { + if (pp->type == mp_undefined_type) { + pp->type = mp_numeric_type; mp_set_value_number(pp, zero_t); } - mp_type(p) = mp_type(pp); + p->type = pp->type; mp_set_value_number(p, zero_t); } return p; @@ -2963,34 +2960,34 @@ static mp_node mp_find_variable (MP mp, mp_node t) static void mp_flush_variable (MP mp, mp_node p, mp_node t, int discard_suffixes) { while (t != NULL) { - if (mp_type(p) != mp_structured_type) { + if (p->type != mp_structured_type) { return; } else { mp_sym n = mp_get_sym_sym(t); - t = mp_link(t); + t = t->link; if (n == mp_collective_subscript) { mp_node q = mp_get_subscr_head(p); mp_node r = NULL; - while (mp_name_type(q) == mp_subscript_operation) { + while (q->name_type == mp_subscript_operation) { mp_flush_variable(mp, q, t, discard_suffixes); if (t != NULL) { r = q; - } else if (mp_type(q) == mp_structured_type) { + } else if (q->type == mp_structured_type) { r = q; } else { if (r == NULL) { - mp_set_subscr_head(p, mp_link(q)); + mp_set_subscr_head(p, q->link); } else { - mp_set_link(r, mp_link(q)); + mp_set_link(r, q->link); } mp_free_value_node(mp, q); } - q = r == NULL ? mp_get_subscr_head(p) : mp_link(r); + q = r == NULL ? mp_get_subscr_head(p) : r->link; } } p = mp_get_attribute_head(p); do { - p = mp_link(p); + p = p->link; } while (mp_get_hashloc(p) < n); if (mp_get_hashloc(p) != n) { return; @@ -3000,7 +2997,7 @@ static void mp_flush_variable (MP mp, mp_node p, mp_node t, int discard_suffixes if (discard_suffixes) { mp_flush_below_variable(mp, p); } else { - if (mp_type(p) == mp_structured_type) { + if (p->type == mp_structured_type) { p = mp_get_attribute_head(p); } mp_recycle_value(mp, p); @@ -3009,35 +3006,35 @@ static void mp_flush_variable (MP mp, mp_node p, mp_node t, int discard_suffixes void mp_flush_below_variable (MP mp, mp_node p) { - if (mp_type(p) != mp_structured_type) { + if (p->type != mp_structured_type) { mp_recycle_value(mp, p); } else { mp_node r; mp_node q = mp_get_subscr_head(p); - while (mp_name_type(q) == mp_subscript_operation) { + while (q->name_type == mp_subscript_operation) { mp_flush_below_variable(mp, q); r = q; - q = mp_link(q); + q = q->link; mp_free_value_node(mp, r); } r = mp_get_attribute_head(p); - q = mp_link(r); + q = r->link; mp_recycle_value(mp, r); mp_free_value_node(mp, r); do { mp_flush_below_variable(mp, q); r = q; - q = mp_link(q); + q = q->link; mp_free_value_node(mp, r); } while (q != mp->end_attr); - mp_type(p) = mp_undefined_type; + p->type = mp_undefined_type; } } static int mp_und_type (MP mp, mp_node p) { (void) mp; - switch (mp_type(p)) { + switch (p->type) { case mp_vacuous_type: return mp_undefined_type; case mp_boolean_type: @@ -3063,7 +3060,7 @@ static int mp_und_type (MP mp, mp_node p) case mp_cmykcolor_type: case mp_pair_type: case mp_numeric_type: - return mp_type(p); + return p->type; case mp_known_type: case mp_dependent_type: case mp_proto_dependent_type: @@ -3092,7 +3089,7 @@ static void mp_clear_symbol (MP mp, mp_sym p, int saving) case mp_tag_command: if (q != NULL) { if (saving) { - mp_name_type(q) = mp_saved_root_operation; + q->name_type = mp_saved_root_operation; } else { mp_flush_below_variable(mp, q); mp_free_value_node(mp, q); @@ -3147,7 +3144,7 @@ static void mp_unsave_variable (MP mp) if (eq_type(q) == mp_tag_command) { mp_node pp = q->v.data.node; if (pp != NULL) { - mp_name_type(pp) = mp_root_operation; + pp->name_type = mp_root_operation; } } } @@ -5809,9 +5806,9 @@ void mp_move_knot (MP mp, mp_knot p, mp_knot q) static void mp_find_offset (MP mp, mp_number *x_orig, mp_number *y_orig, mp_knot h) { if (mp_pen_is_elliptical(h)) { - mp_fraction xx, yy; + mp_number xx, yy; mp_number wx, wy, hx, hy; - mp_fraction d; + mp_number d; new_fraction(xx); new_fraction(yy); new_number(wx); @@ -5970,7 +5967,7 @@ static void mp_pen_bbox (MP mp, mp_knot h) static mp_node mp_new_shape_node (MP mp, mp_knot p, int type) { mp_shape_node t = mp_allocate_node(mp, sizeof(mp_shape_node_data)); - mp_type(t) = type; + t->type = type; mp_path_ptr(t) = p; mp_pen_ptr(t) = NULL; mp_dash_ptr(t) = NULL; @@ -6114,9 +6111,8 @@ static mp_node mp_new_bounds_node (MP mp, mp_knot p, int c) case mp_start_bounds_node_type: { mp_start_node t = (mp_start_node) mp_allocate_node(mp, sizeof(mp_start_node_data)); - mp_type(t) = c; + t->type = c; t->path = p; - t->link = NULL; t->stacking = round_unscaled(internal_value(mp_stacking_internal)); mp_pre_script(t) = NULL; mp_post_script(t) = NULL; @@ -6128,8 +6124,7 @@ static mp_node mp_new_bounds_node (MP mp, mp_knot p, int c) case mp_stop_bounds_node_type: { mp_stop_node t = (mp_stop_node) mp_allocate_node(mp, sizeof(mp_stop_node_data)); - mp_type(t) = c; - t->link = NULL; + t->type = c; t->stacking = round_unscaled(internal_value(mp_stacking_internal)); return (mp_node) t; } @@ -6164,7 +6159,7 @@ static mp_dash_node mp_get_dash_node (MP mp) new_number(p->start_x); new_number(p->stop_x); new_number(p->dash_y); - mp_type(p) = mp_dash_node_type; + p->type = mp_dash_node_type; return p; } @@ -6182,7 +6177,7 @@ static void mp_init_bbox (MP mp, mp_edge_header_node h) static mp_edge_header_node mp_get_edge_header_node (MP mp) { mp_edge_header_node p = (mp_edge_header_node) mp_allocate_node(mp, sizeof(mp_edge_header_node_data)); - mp_type(p) = mp_edge_header_node_type; + p->type = mp_edge_header_node_type; new_number(p->start_x); new_number(p->stop_x); new_number(p->dash_y); @@ -6198,7 +6193,7 @@ static void mp_init_edges (MP mp, mp_edge_header_node h) { mp_set_dash_list(h, mp->null_dash); mp_obj_tail(h) = mp_edge_list(h); - mp_link(mp_edge_list(h)) = NULL; + mp_edge_list(h)->link = NULL; mp_edge_ref_count(h) = 0; mp_init_bbox(mp, h); } @@ -6208,10 +6203,10 @@ void mp_toss_edges (MP mp, mp_edge_header_node h) mp_node q; mp_edge_header_node r; mp_flush_dash_list(mp, h); - q = mp_link(mp_edge_list(h)); + q = mp_edge_list(h)->link; while (q != NULL) { mp_node p = q; - q = mp_link(q); + q = q->link; r = mp_toss_gr_object(mp, p); if (r != NULL) { mp_delete_edge_ref(mp, r); @@ -6233,7 +6228,7 @@ void mp_flush_dash_list (MP mp, mp_edge_header_node h) mp_dash_node q = mp_get_dash_list(h); while (q != mp->null_dash) { mp_dash_node p = q; - q = (mp_dash_node) mp_link(q); + q = (mp_dash_node) q->link; mp_free_node(mp, (mp_node) p, sizeof(mp_dash_node_data)); } mp_set_dash_list(h, mp->null_dash); @@ -6241,7 +6236,7 @@ void mp_flush_dash_list (MP mp, mp_edge_header_node h) mp_edge_header_node mp_toss_gr_object (MP mp, mp_node p) { - switch (mp_type(p)) { + switch (p->type) { case mp_fill_node_type: case mp_stroked_node_type: return mp_free_shape_node(mp, (mp_shape_node) p); @@ -6268,17 +6263,17 @@ static mp_edge_header_node mp_private_edges (MP mp, mp_edge_header_node h) mp_edge_header_node hh; mp_dash_node p, pp; mp_edge_ref_count(h) -= 1; - hh = (mp_edge_header_node) mp_copy_objects (mp, mp_link(mp_edge_list(h)), NULL); + hh = (mp_edge_header_node) mp_copy_objects (mp, mp_edge_list(h)->link, NULL); pp = (mp_dash_node) hh; p = mp_get_dash_list(h); while ((p != mp->null_dash)) { - mp_link(pp) = (mp_node) mp_get_dash_node(mp); - pp = (mp_dash_node) mp_link(pp); + pp->link = (mp_node) mp_get_dash_node(mp); + pp = (mp_dash_node) pp->link; number_clone(pp->start_x, p->start_x); number_clone(pp->stop_x, p->stop_x); - p = (mp_dash_node) mp_link(p); + p = (mp_dash_node) p->link; } - mp_link(pp) = (mp_node) mp->null_dash; + pp->link = (mp_node) mp->null_dash; number_clone(hh->dash_y, h->dash_y); number_clone(hh->minx, h->minx); @@ -6292,8 +6287,8 @@ static mp_edge_header_node mp_private_edges (MP mp, mp_edge_header_node h) if (p == NULL) { mp_confusion(mp, "boundingbox last"); } else { - p = (mp_dash_node) mp_link(p); - pp = (mp_dash_node) mp_link(pp); + p = (mp_dash_node) p->link; + pp = (mp_dash_node) pp->link; } } mp_bblast(hh) = (mp_node) pp; @@ -6344,12 +6339,12 @@ static mp_dash_object *mp_export_dashes (MP mp, mp_shape_node q, mp_number *w) set_number_from_subtraction(arg1, p->stop_x, p->start_x); take_scaled(ret, arg1, scf); dashes[(num_dashes - 1)] = number_to_double(ret); - set_number_from_subtraction(arg1, ((mp_dash_node) mp_link(p))->start_x, p->stop_x); + set_number_from_subtraction(arg1, ((mp_dash_node) p->link)->start_x, p->stop_x); take_scaled(ret, arg1, scf); dashes[(num_dashes)] = number_to_double(ret); dashes[(num_dashes + 1)] = -1.0; num_dashes += 2; - p = (mp_dash_node) mp_link(p); + p = (mp_dash_node) p->link; } d->array = dashes; mp_dash_offset(mp, &dashoff, h); @@ -6373,7 +6368,7 @@ mp_edge_header_node mp_copy_objects (MP mp, mp_node p, mp_node q) { pp = mp_edge_list(hh); while (p != q) { { - switch (mp_type(p)) { + switch (p->type) { case mp_fill_node_type: case mp_stroked_node_type: k = sizeof(mp_shape_node_data); @@ -6391,11 +6386,11 @@ mp_edge_header_node mp_copy_objects (MP mp, mp_node p, mp_node q) { default: break; } - mp_link(pp) = mp_allocate_node(mp, (size_t) k); - pp = mp_link(pp); + pp->link = mp_allocate_node(mp, (size_t) k); + pp = pp->link; memcpy(pp, p, (size_t) k); pp->link = NULL; - switch (mp_type(p)) { + switch (p->type) { case mp_fill_node_type: case mp_stroked_node_type: { @@ -6444,11 +6439,11 @@ mp_edge_header_node mp_copy_objects (MP mp, mp_node p, mp_node q) { default: break; } - p = mp_link(p); + p = p->link; } } mp_obj_tail(hh) = pp; - mp_link(pp) = NULL; + pp->link = NULL; return hh; } @@ -6464,7 +6459,7 @@ static mp_node mp_skip_1component (MP mp, mp_node p) ++lev; } } - p = mp_link(p); + p = p->link; } while (lev != 0); return p; } @@ -6475,10 +6470,10 @@ void mp_print_edges (MP mp, mp_node h, const char *s, int nuline) mp_number scf; new_number(scf); mp_print_diagnostic(mp, "Edge structure", s, nuline); - while (mp_link(p) != NULL) { - p = mp_link(p); + while (p->link != NULL) { + p = p->link; mp_print_ln(mp); - switch (mp_type(p)) { + switch (p->type) { case mp_fill_node_type: mp_print_str(mp, "Filled contour "); mp_print_obj_color (mp, p); @@ -6539,10 +6534,10 @@ void mp_print_edges (MP mp, mp_node h, const char *s, int nuline) take_scaled(ret, arg1, scf); print_number( ret); mp_print_str(mp, " off "); - set_number_from_subtraction(arg1, ((mp_dash_node) mp_link(ppd))->start_x, ppd->stop_x); + set_number_from_subtraction(arg1, ((mp_dash_node) ppd->link)->start_x, ppd->stop_x); take_scaled(ret, arg1, scf); print_number(ret); - ppd = (mp_dash_node) mp_link(ppd); + ppd = (mp_dash_node) ppd->link; if (ppd != mp->null_dash) { mp_print_chr(mp, ' '); } @@ -6711,9 +6706,9 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) new_number(y0); p0 = NULL; - p = mp_link(mp_edge_list(h)); + p = mp_edge_list(h)->link; while (p != NULL) { - if (mp_type(p) != mp_stroked_node_type) { + if (p->type != mp_stroked_node_type) { mp_back_error( mp, "Picture is too complicated to use as a dash pattern", @@ -6812,17 +6807,17 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) } number_clone(mp->null_dash->start_x, d->stop_x); dd = (mp_dash_node) h; - while (number_less(((mp_dash_node) mp_link(dd))->start_x, d->stop_x)) { - dd = (mp_dash_node) mp_link(dd); + while (number_less(((mp_dash_node) dd->link)->start_x, d->stop_x)) { + dd = (mp_dash_node) dd->link; } if ((dd != (mp_dash_node) h) && number_greater(dd->stop_x, d->start_x)) { mp_x_retrace_error(mp); goto NOT_FOUND; } - mp_link(d) = mp_link(dd); - mp_link(dd) = (mp_node) d; + d->link = dd->link; + dd->link = (mp_node) d; - p = mp_link(p); + p = p->link; } if (mp_get_dash_list(h) == mp->null_dash) { goto NOT_FOUND; @@ -6831,10 +6826,10 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) mp_number hsf; new_number(hsf); d = (mp_dash_node) h; - while (mp_link(d) != (mp_node) mp->null_dash) { - ds = mp_dash_info(mp_link(d)); + while (d->link != (mp_node) mp->null_dash) { + ds = mp_dash_info(d->link); if (ds == NULL) { - d = (mp_dash_node) mp_link(d); + d = (mp_dash_node) d->link; } else { hh = (mp_edge_header_node) mp_dash_ptr(ds); number_clone(hsf, ((mp_shape_node) ds)->dashscale); @@ -6842,7 +6837,7 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) mp_confusion(mp, "dash pattern"); return NULL; } else if (number_zero(((mp_dash_node) hh)->dash_y )) { - d = (mp_dash_node) mp_link(d); + d = (mp_dash_node) d->link; } else if (mp_get_dash_list (hh) == NULL) { mp_confusion(mp, "dash list"); return NULL; @@ -6852,7 +6847,7 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) mp_number r1, r2; new_number(r1); new_number(r2); - dln = (mp_dash_node) mp_link(d); + dln = (mp_dash_node) d->link; dd = mp_get_dash_list(hh); new_number(xoff); new_number(dashoff); @@ -6872,7 +6867,7 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) take_scaled(r1, hsf, dd->stop_x); number_add(r1, xoff); while (number_less(r1, dln->start_x)) { - dd = (mp_dash_node) mp_link(dd); + dd = (mp_dash_node) dd->link; take_scaled(r1, hsf, dd->stop_x); number_add(r1, xoff); } @@ -6893,9 +6888,9 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) take_scaled(r1, hsf, dd->start_x); number_add(r1, xoff); if (number_lessequal(r1, dln->stop_x)) { - mp_link(d) = (mp_node) mp_get_dash_node(mp); - d = (mp_dash_node) mp_link(d); - mp_link(d) = (mp_node) dln; + d->link = (mp_node) mp_get_dash_node(mp); + d = (mp_dash_node) d->link; + d->link = (mp_node) dln; take_scaled(r1, hsf, dd->start_x ); number_add(r1, xoff); if (number_greater(dln->start_x, r1)) { @@ -6913,14 +6908,14 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) } free_number(r1); } - dd = (mp_dash_node) mp_link(dd); + dd = (mp_dash_node) dd->link; take_scaled(r1, hsf, dd->start_x); set_number_from_addition(dln->start_x , xoff, r1); } free_number(xoff); free_number(r1); free_number(r2); - mp_link(d) = mp_link(dln); + d->link = dln->link; mp_free_node(mp, (mp_node) dln, sizeof(mp_dash_node_data)); } } @@ -6928,8 +6923,8 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) free_number(hsf); } d = mp_get_dash_list(h); - while (mp_link(d) != (mp_node) mp->null_dash) { - d = (mp_dash_node) mp_link(d); + while (d->link != (mp_node) mp->null_dash) { + d = (mp_dash_node) d->link; } dd = mp_get_dash_list(h); set_number_from_subtraction(h->dash_y, d->stop_x, dd->start_x); @@ -6940,7 +6935,7 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) if (number_greater(absval, h->dash_y) ) { number_clone(h->dash_y, absval); } else if (d != dd) { - mp_set_dash_list(h, mp_link(dd)); + mp_set_dash_list(h, dd->link); set_number_from_addition(d->stop_x, dd->stop_x, h->dash_y); mp_free_node(mp, (mp_node) dd, sizeof(mp_dash_node_data)); } @@ -6987,7 +6982,7 @@ static void mp_adjust_bbox (MP mp, mp_edge_header_node h) static void mp_box_ends (MP mp, mp_knot p, mp_knot pp, mp_edge_header_node h) { if (mp_right_type(p) != mp_endpoint_knot) { - mp_fraction dx, dy; + mp_number dx, dy; mp_number d; mp_number z; mp_number xx, yy; @@ -7108,10 +7103,10 @@ void mp_set_bbox (MP mp, mp_edge_header_node h, int top_level) } break; } - while (mp_link(mp_bblast(h)) != NULL) { - mp_node p = mp_link(mp_bblast(h)); + while (mp_bblast(h)->link != NULL) { + mp_node p = mp_bblast(h)->link; mp_bblast(h) = p; - switch (mp_type(p)) { + switch (p->type) { case mp_stop_clip_node_type: if (top_level) { mp_confusion(mp, "clip"); @@ -7129,13 +7124,13 @@ void mp_set_bbox (MP mp, mp_edge_header_node h, int top_level) { int lev = 1; while (lev != 0) { - if (mp_link(p) == NULL) { + if (p->link == NULL) { mp_confusion(mp, "bounds"); } else { - p = mp_link(p); - if (mp_type(p) == mp_start_bounds_node_type) { + p = p->link; + if (p->type == mp_start_bounds_node_type) { ++lev; - } else if (mp_type(p) == mp_stop_bounds_node_type) { + } else if (p->type == mp_stop_bounds_node_type) { --lev; } } @@ -8015,7 +8010,7 @@ static mp_knot mp_make_envelope (MP mp, mp_knot c, mp_knot h, int linejoin, int mp_knot w, w0; int k, k0; mp_number qx, qy; - mp_fraction dxin, dyin, dxout, dyout; + mp_number dxin, dyin, dxout, dyout; int join_type = 0; mp_number tmp; mp_number max_ht; @@ -9074,7 +9069,7 @@ static void mp_new_indep (MP mp, mp_node p) if (mp->serial_no >= max_integer) { mp_fatal_error(mp, "Variable instance identifiers exhausted"); } - mp_type(p) = mp_independent_type; + p->type = mp_independent_type; mp->serial_no = mp->serial_no + 1; mp_set_indep_scale(p, 0); mp_set_indep_value(p, mp->serial_no); @@ -9098,7 +9093,7 @@ inline static void do_set_dep_value (MP mp, mp_value_node p, mp_number *q) static mp_value_node mp_get_dep_node (MP mp) { mp_value_node p = (mp_value_node) mp_new_value_node(mp); - mp_type(p) = mp_dep_node_type; + p->type = mp_dep_node_type; return p; } @@ -9136,7 +9131,7 @@ void mp_print_dependency (MP mp, mp_value_node p, int t) if (! number_equal(v, unity_t)) { print_number(v); } - if (mp_type(q) != mp_independent_type) { + if (q->type != mp_independent_type) { mp_confusion(mp, "dependency"); } else { mp_print_variable_name(mp, q); @@ -9145,14 +9140,14 @@ void mp_print_dependency (MP mp, mp_value_node p, int t) mp_print_str(mp, "*4"); number_add_scaled(v, -2); } - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; } } } static void mp_max_coef (MP mp, mp_number *x, mp_value_node p) { - mp_number(absv); + mp_number absv; new_number(absv); set_number_to_zero(*x); while (mp_get_dep_info(p) != NULL) { @@ -9160,7 +9155,7 @@ static void mp_max_coef (MP mp, mp_number *x, mp_value_node p) if (number_greater(absv, *x)) { number_clone(*x, absv); } - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; } free_number(absv); } @@ -9206,13 +9201,13 @@ static mp_value_node mp_p_plus_fq (MP mp, free_number(r1); mp_set_dep_value(p, v); s = p; - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; number_abs_clone(absv, v); if (number_less(absv, threshold)) { mp_free_dep_node(mp, s); } else { if (number_greaterequal(absv, coef_bound_k) && mp->watch_coefs) { - mp_type(qq) = independent_needing_fix; + qq->type = independent_needing_fix; mp->fix_needed = 1; } mp_set_link(r, s); @@ -9220,20 +9215,20 @@ static mp_value_node mp_p_plus_fq (MP mp, } free_number(absv); pp = mp_get_dep_info(p); - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; qq = mp_get_dep_info(q); } } else { if (pp == NULL) { set_number_to_negative_inf(v); - } else if (mp_type(pp) == mp_independent_type || (mp_type(pp) == independent_needing_fix && mp->fix_needed)) { + } else if (pp->type == mp_independent_type || (pp->type == independent_needing_fix && mp->fix_needed)) { set_number_from_scaled(v, mp_get_indep_value(pp)); } else { number_clone(v, mp_get_value_number(pp)); } if (qq == NULL) { set_number_to_negative_inf(vv); - } else if (mp_type(qq) == mp_independent_type || (mp_type(qq) == independent_needing_fix && mp->fix_needed)) { + } else if (qq->type == mp_independent_type || (qq->type == independent_needing_fix && mp->fix_needed)) { set_number_from_scaled(vv, mp_get_indep_value(qq)); } else { number_clone(vv, mp_get_value_number(qq)); @@ -9262,19 +9257,19 @@ static mp_value_node mp_p_plus_fq (MP mp, mp_set_dep_info(s, qq); mp_set_dep_value(s, v); if (number_greaterequal(absv, coef_bound_k) && mp->watch_coefs) { - mp_type(qq) = independent_needing_fix; + qq->type = independent_needing_fix; mp->fix_needed = 1; } mp_set_link(r, s); r = s; } - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; qq = mp_get_dep_info(q); free_number(absv); } else { mp_set_link(r, p); r = p; - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; pp = mp_get_dep_info(p); } } @@ -9304,7 +9299,7 @@ static mp_value_node mp_p_plus_fq (MP mp, free_number(half_threshold); free_number(v); free_number(vv); - return (mp_value_node) mp_link(mp->temp_head); + return (mp_value_node) mp->temp_head->link; } static mp_value_node mp_p_plus_q (MP mp, mp_value_node p, mp_value_node q, mp_variable_type t) @@ -9335,34 +9330,34 @@ static mp_value_node mp_p_plus_q (MP mp, mp_value_node p, mp_value_node q, mp_va set_number_from_addition(v, mp_get_dep_value(p), mp_get_dep_value(q)); mp_set_dep_value(p, v); s = p; - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; pp = mp_get_dep_info(p); number_abs_clone(test, v); if (number_less(test, threshold)) { mp_free_dep_node(mp, s); } else { if (number_greaterequal(test, coef_bound_k) && mp->watch_coefs) { - mp_type(qq) = independent_needing_fix; + qq->type = independent_needing_fix; mp->fix_needed = 1; } mp_set_link(r, s); r = s; } free_number(test); - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; qq = mp_get_dep_info(q); } } else { if (pp == NULL) { set_number_to_zero(v); - } else if (mp_type(pp) == mp_independent_type || (mp_type(pp) == independent_needing_fix && mp->fix_needed)) { + } else if (pp->type == mp_independent_type || (pp->type == independent_needing_fix && mp->fix_needed)) { set_number_from_scaled(v, mp_get_indep_value(pp)); } else { number_clone(v, mp_get_value_number(pp)); } if (qq == NULL) { set_number_to_zero(vv); - } else if (mp_type(qq) == mp_independent_type || (mp_type(qq) == independent_needing_fix && mp->fix_needed)) { + } else if (qq->type == mp_independent_type || (qq->type == independent_needing_fix && mp->fix_needed)) { set_number_from_scaled(vv, mp_get_indep_value(qq)); } else { number_clone(vv, mp_get_value_number(qq)); @@ -9371,14 +9366,14 @@ static mp_value_node mp_p_plus_q (MP mp, mp_value_node p, mp_value_node q, mp_va s = mp_get_dep_node(mp); mp_set_dep_info(s, qq); mp_set_dep_value(s, mp_get_dep_value(q)); - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; qq = mp_get_dep_info(q); mp_set_link(r, s); r = s; } else { mp_set_link(r, p); r = p; - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; pp = mp_get_dep_info(p); } } @@ -9395,7 +9390,7 @@ static mp_value_node mp_p_plus_q (MP mp, mp_value_node p, mp_value_node q, mp_va free_number(v); free_number(vv); free_number(threshold); - return (mp_value_node) mp_link(mp->temp_head); + return (mp_value_node) mp->temp_head->link; } static mp_value_node mp_p_times_v (MP mp, mp_value_node p, mp_number *v, int t0, int t1, int v_is_scaled) @@ -9422,18 +9417,18 @@ static mp_value_node mp_p_times_v (MP mp, mp_value_node p, mp_number *v, int t0, } number_abs_clone(test, w); if (number_lessequal(test, threshold)) { - s = (mp_value_node) mp_link(p); + s = (mp_value_node) p->link; mp_free_dep_node(mp, p); p = s; } else { if (number_greaterequal(test, coef_bound_k)) { mp->fix_needed = 1; - mp_type(mp_get_dep_info(p)) = independent_needing_fix; + mp_get_dep_info(p)->type = independent_needing_fix; } mp_set_link(r, p); r = p; mp_set_dep_value(p, w); - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; } free_number(test); } @@ -9451,7 +9446,7 @@ static mp_value_node mp_p_times_v (MP mp, mp_value_node p, mp_number *v, int t0, } free_number(w); free_number(threshold); - return (mp_value_node) mp_link(mp->temp_head); + return (mp_value_node) mp->temp_head->link; } mp_value_node mp_p_over_v (MP mp, mp_value_node p, mp_number *v_orig, int t0, int t1) @@ -9493,18 +9488,18 @@ mp_value_node mp_p_over_v (MP mp, mp_value_node p, mp_number *v_orig, int t0, in new_number(test); number_abs_clone(test, w); if (number_lessequal(test, threshold)) { - s = (mp_value_node) mp_link(p); + s = (mp_value_node) p->link; mp_free_dep_node(mp, p); p = s; } else { if (number_greaterequal(test, coef_bound_k)) { mp->fix_needed = 1; - mp_type(mp_get_dep_info(p)) = independent_needing_fix; + mp_get_dep_info(p)->type = independent_needing_fix; } mp_set_link(r, p); r = p; mp_set_dep_value(p, w); - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; } free_number(test); } @@ -9520,7 +9515,7 @@ mp_value_node mp_p_over_v (MP mp, mp_value_node p, mp_number *v_orig, int t0, in free_number(v); free_number(w); free_number(threshold); - return (mp_value_node) mp_link(mp->temp_head); + return (mp_value_node) mp->temp_head->link; } static mp_value_node mp_p_with_x_becoming_q (MP mp, mp_value_node p, mp_node x, mp_node q, int t) @@ -9530,7 +9525,7 @@ static mp_value_node mp_p_with_x_becoming_q (MP mp, mp_value_node p, mp_node x, int sx = mp_get_indep_value(x); while (mp_get_dep_info(s) != NULL && mp_get_indep_value(mp_get_dep_info(s)) > sx) { r = s; - s = (mp_value_node) mp_link(s); + s = (mp_value_node) s->link; } if (mp_get_dep_info(s) == NULL || mp_get_dep_info(s) != x) { return p; @@ -9538,10 +9533,10 @@ static mp_value_node mp_p_with_x_becoming_q (MP mp, mp_value_node p, mp_node x, mp_value_node ret; mp_number v1; mp_set_link(mp->temp_head, p); - mp_set_link(r, mp_link(s)); + mp_set_link(r, s->link); new_number_clone(v1, mp_get_dep_value(s)); mp_free_dep_node(mp, s); - ret = mp_p_plus_fq(mp, (mp_value_node) mp_link(mp->temp_head), &v1, (mp_value_node) q, t, mp_dependent_type); + ret = mp_p_plus_fq(mp, (mp_value_node) mp->temp_head->link, &v1, (mp_value_node) q, t, mp_dependent_type); free_number(v1); return ret; } @@ -9564,12 +9559,12 @@ static void mp_val_too_big (MP mp, mp_number *x) void mp_make_known (MP mp, mp_value_node p, mp_value_node q) { - mp_variable_type t = mp_type(p); + mp_variable_type t = p->type; mp_number absp; new_number(absp); - mp_set_prev_dep(mp_link(q), mp_get_prev_dep(p)); - mp_set_link(mp_get_prev_dep(p), mp_link(q)); - mp_type(p) = mp_known_type; + mp_set_prev_dep(q->link, mp_get_prev_dep(p)); + mp_set_link(mp_get_prev_dep(p), q->link); + p->type = mp_known_type; mp_set_value_number(p, mp_get_dep_value(q)); mp_free_dep_node(mp, q); number_abs_clone(absp, mp_get_value_number(p)); @@ -9594,7 +9589,7 @@ void mp_make_known (MP mp, mp_value_node p, mp_value_node q) static void mp_fix_dependencies (MP mp) { - mp_value_node r = (mp_value_node) mp_link(mp->dep_head); + mp_value_node r = (mp_value_node) mp->dep_head->link; mp_value_node s = NULL; while (r != mp->dep_head) { mp_value_node t = r; @@ -9604,40 +9599,40 @@ static void mp_fix_dependencies (MP mp) if (t == r) { q = (mp_value_node) mp_get_dep_list(t); } else { - q = (mp_value_node) mp_link(r); + q = (mp_value_node) r->link; } x = mp_get_dep_info(q); if (x == NULL) { break; - } else if (mp_type(x) <= independent_being_fixed) { - if (mp_type(x) < independent_being_fixed) { + } else if (x->type <= independent_being_fixed) { + if (x->type < independent_being_fixed) { mp_value_node p = mp_get_dep_node(mp); mp_set_link(p, s); s = p; mp_set_dep_info(s, x); - mp_type(x) = independent_being_fixed; + x->type = independent_being_fixed; } mp_set_dep_value(q, mp_get_dep_value(q)); number_divide_int(mp_get_dep_value(q), 4); if (number_zero(mp_get_dep_value(q))) { - mp_set_link(r, mp_link(q)); + mp_set_link(r, q->link); mp_free_dep_node(mp, q); q = r; } } r = q; } - r = (mp_value_node) mp_link(q); + r = (mp_value_node) q->link; if (q == (mp_value_node) mp_get_dep_list(t)) { mp_make_known(mp, t, q); } } while (s != NULL) { - mp_value_node p = (mp_value_node) mp_link(s); + mp_value_node p = (mp_value_node) s->link; mp_node x = mp_get_dep_info(s); mp_free_dep_node(mp, s); s = p; - mp_type(x) = mp_independent_type; + x->type = mp_independent_type; mp_set_indep_scale(x, mp_get_indep_scale(x) + 2); } mp->fix_needed = 0; @@ -9646,10 +9641,10 @@ static void mp_fix_dependencies (MP mp) static void mp_new_dep (MP mp, mp_node q, mp_variable_type newtype, mp_value_node p) { mp_node r; - mp_type(q) = newtype; + q->type = newtype; mp_set_dep_list(q, p); mp_set_prev_dep(q, (mp_node) mp->dep_head); - r = mp_link(mp->dep_head); + r = mp->dep_head->link; mp_set_link(mp->dep_final, r); mp_set_prev_dep(r, (mp_node) mp->dep_final); mp_set_link(mp->dep_head, q); @@ -9692,8 +9687,8 @@ static mp_value_node mp_copy_dep_list (MP mp, mp_value_node p) break; } else { mp_set_link(mp->dep_final, mp_get_dep_node(mp)); - mp->dep_final = (mp_value_node) mp_link(mp->dep_final); - p = (mp_value_node) mp_link(p); + mp->dep_final = (mp_value_node) mp->dep_final->link; + p = (mp_value_node) p->link; } } return q; @@ -9730,20 +9725,20 @@ static void mp_linear_eq (MP mp, mp_value_node p, int t) display_new_dependency(mp, p, (mp_node) x, n); } prev_r = (mp_value_node) mp->dep_head; - r = (mp_value_node) mp_link(mp->dep_head); + r = (mp_value_node) mp->dep_head->link; while (r != mp->dep_head) { mp_value_node s = (mp_value_node) mp_get_dep_list(r); - mp_value_node q = mp_p_with_x_becoming_q(mp, s, x, (mp_node) p, mp_type(r)); + mp_value_node q = mp_p_with_x_becoming_q(mp, s, x, (mp_node) p, r->type); if (mp_get_dep_info(q) == NULL) { mp_make_known(mp, r, q); } else { mp_set_dep_list(r, q); do { - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; } while (mp_get_dep_info(q) != NULL); prev_r = q; } - r = (mp_value_node) mp_link(prev_r); + r = (mp_value_node) prev_r->link; } if (n > 0) { p = divide_p_by_2_n(mp, p, n); @@ -9760,7 +9755,7 @@ static mp_value_node find_node_with_largest_coefficient (MP mp, mp_value_node p, mp_number vabs; mp_number rabs; mp_value_node q = p; - mp_value_node r = (mp_value_node) mp_link(p); + mp_value_node r = (mp_value_node) p->link; new_number(vabs); new_number(rabs); number_clone(*v, mp_get_dep_value(q)); @@ -9771,7 +9766,7 @@ static mp_value_node find_node_with_largest_coefficient (MP mp, mp_value_node p, q = r; number_clone(*v, mp_get_dep_value(r)); } - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; } free_number(vabs); free_number(rabs); @@ -9788,7 +9783,7 @@ static mp_value_node divide_p_by_minusv_removing_q (MP mp, mp_set_link(s, p); do { if (r == q) { - mp_set_link(s, mp_link(r)); + mp_set_link(s, r->link); mp_free_dep_node(mp, r); } else { mp_number w; @@ -9798,7 +9793,7 @@ static mp_value_node divide_p_by_minusv_removing_q (MP mp, make_fraction(w, mp_get_dep_value(r), *v); number_abs_clone(absw, w); if (number_lessequal(absw, half_fraction_threshold_k)) { - mp_set_link(s, mp_link(r)); + mp_set_link(s, r->link); mp_free_dep_node(mp, r); } else { number_negate(w); @@ -9808,7 +9803,7 @@ static mp_value_node divide_p_by_minusv_removing_q (MP mp, free_number(w); free_number(absw); } - r = (mp_value_node) mp_link(s); + r = (mp_value_node) s->link; } while (mp_get_dep_info(r) != NULL); if (t == mp_proto_dependent_type) { mp_number ret; @@ -9826,7 +9821,7 @@ static mp_value_node divide_p_by_minusv_removing_q (MP mp, free_number(ret); } *final_node = r; - return (mp_value_node) mp_link(mp->temp_head); + return (mp_value_node) mp->temp_head->link; } static void display_new_dependency (MP mp, mp_value_node p, mp_node x, int n) @@ -9867,15 +9862,15 @@ static mp_value_node divide_p_by_2_n (MP mp, mp_value_node p, int n) } number_abs_clone(absw, w); if (number_lessequal(absw, half_fraction_threshold_k) && (mp_get_dep_info(r) != NULL)) { - mp_set_link(s, mp_link(r)); + mp_set_link(s, r->link); mp_free_dep_node(mp, r); } else { mp_set_dep_value(r, w); s = r; } - r = (mp_value_node) mp_link(s); + r = (mp_value_node) s->link; } while (mp_get_dep_info(s) != NULL); - pp = (mp_value_node) mp_link(mp->temp_head); + pp = (mp_value_node) mp->temp_head->link; free_number(absw); free_number(w); } @@ -9887,7 +9882,7 @@ static void change_to_known (MP mp, mp_value_node p, mp_node x, mp_value_node fi (void) n; if (mp_get_dep_info(p) == NULL) { mp_number absx; - mp_type(x) = mp_known_type; + x->type = mp_known_type; mp_set_value_number(x, mp_get_dep_value(p)); new_number_abs(absx, mp_get_value_number(x)); if (number_greaterequal(absx, warning_limit_t)) { @@ -9912,8 +9907,8 @@ static void change_to_known (MP mp, mp_value_node p, mp_node x, mp_value_node fi static mp_node mp_new_ring_entry (MP mp, mp_node p) { mp_node q = mp_new_value_node(mp); - mp_name_type(q) = mp_capsule_operation; - mp_type(q) = mp_type(p); + q->name_type = mp_capsule_operation; + q->type = p->type; if (mp_get_value_node(p) == NULL) { mp_set_value_node(q, p); } else { @@ -9937,16 +9932,16 @@ void mp_ring_delete (MP mp, mp_node p) static void mp_nonlinear_eq (MP mp, mp_value v, mp_node p, int flush_p) { - mp_variable_type t = mp_type(p) - unknown_tag; + mp_variable_type t = p->type - unknown_tag; mp_node q = mp_get_value_node(p); if (flush_p) { - mp_type(p) = mp_vacuous_type; + p->type = mp_vacuous_type; } else { p = q; } do { mp_node r = mp_get_value_node(q); - mp_type(q) = t; + q->type = t; switch (t) { case mp_boolean_type: mp_set_value_number(q, v.data.n); @@ -10215,7 +10210,7 @@ static void mp_show_cmd_mod (MP mp, int c, int m) mp_print_cmd_mod(mp, mp_macro_def_command, c); mp_print_str(mp, "'d macro:"); mp_print_ln(mp); - mp_show_token_list(mp, mp_link(mp_link(cur_mod_node)),0); + mp_show_token_list(mp, cur_mod_node->link->link,0); break; default: mp_print_cmd_mod(mp, c, m); @@ -10302,7 +10297,7 @@ void mp_show_context (MP mp) mp_node pp = mp->param_stack[param_start]; mp_print_nl(mp, "<for("); if (pp != NULL) { - if (mp_link(pp) == MP_VOID) { + if (pp->link == MP_VOID) { mp_print_exp(mp, pp, 0); } else { mp_show_token_list(mp, pp, NULL); @@ -10332,12 +10327,12 @@ void mp_show_context (MP mp) mp_show_token_list(mp, mp->param_stack[param_start + 1], NULL); } else { mp_node qq = pp; - while (mp_link(qq) != NULL) { - qq = mp_link(qq); + while (qq->link != NULL) { + qq = qq->link; } - mp_link(qq) = mp->param_stack[param_start + 1]; + qq->link = mp->param_stack[param_start + 1]; mp_show_token_list(mp, pp, NULL); - mp_link(qq) = NULL; + qq->link = NULL; } } } @@ -10419,7 +10414,7 @@ static void mp_end_token_list (MP mp) --mp->param_ptr; p = mp->param_stack[mp->param_ptr]; if (p != NULL) { - if (mp_link(p) == MP_VOID) { + if (p->link == MP_VOID) { mp_recycle_value(mp, p); mp_free_value_node(mp, p); } else { @@ -10434,33 +10429,33 @@ static void mp_end_token_list (MP mp) static void mp_encapsulate (MP mp, mp_value_node p) { mp_node q = mp_new_value_node(mp); - mp_name_type(q) = mp_capsule_operation; + q->name_type = mp_capsule_operation; mp_new_dep(mp, q, mp->cur_exp.type, p); mp_set_cur_exp_node(mp, q); } static void mp_install (MP mp, mp_node r, mp_node q) { - if (mp_type(q) == mp_known_type) { - mp_type(r) = mp_known_type; + if (q->type == mp_known_type) { + r->type = mp_known_type; mp_set_value_number(r, mp_get_value_number(q)); - } else if (mp_type(q) == mp_independent_type) { + } else if (q->type == mp_independent_type) { mp_value_node p = mp_single_dependency(mp, q); if (p == mp->dep_final) { - mp_type(r) = mp_known_type; + r->type = mp_known_type; mp_set_value_number(r, zero_t); mp_free_dep_node(mp, p); } else { mp_new_dep(mp, r, mp_dependent_type, p); } } else { - mp_new_dep(mp, r, mp_type(q), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list((mp_value_node) q))); + mp_new_dep(mp, r, q->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list((mp_value_node) q))); } } static void mp_make_exp_copy (MP mp, mp_node p) { RESTART: - mp->cur_exp.type = mp_type(p); + mp->cur_exp.type = p->type; switch (mp->cur_exp.type) { case mp_vacuous_type: case mp_boolean_type: @@ -10500,7 +10495,7 @@ static void mp_make_exp_copy (MP mp, mp_node p) mp_node t; mp_value_node q; if (mp_get_value_node(p) == NULL) { - switch (mp_type(p)) { + switch (p->type) { case mp_pair_type: mp_init_pair_node(mp, p); break; @@ -10518,7 +10513,7 @@ static void mp_make_exp_copy (MP mp, mp_node p) } } t = mp_new_value_node(mp); - mp_name_type(t) = mp_capsule_operation; + t->name_type = mp_capsule_operation; q = (mp_value_node) mp_get_value_node(p); switch (mp->cur_exp.type) { case mp_pair_type: @@ -10594,25 +10589,25 @@ static mp_node mp_cur_tok (MP mp) number_clone(save_exp_num, cur_exp_value_number); mp_make_exp_copy(mp, cur_mod_node); p = mp_stash_cur_exp(mp); - mp_link(p) = NULL; + p->link = NULL; mp->cur_exp = save_exp; number_clone(mp->cur_exp.data.n, save_exp_num); free_number(save_exp_num); } else { p = mp_new_token_node(mp); - mp_name_type(p) = mp_token_operation; + p->name_type = mp_token_operation; if (cur_cmd == mp_numeric_command) { mp_set_value_number(p, cur_mod_number); - mp_type(p) = mp_known_type; + p->type = mp_known_type; } else { mp_set_value_str(p, cur_mod_str); - mp_type(p) = mp_string_type; + p->type = mp_string_type; } } } else { p = mp_new_symbolic_node(mp); mp_set_sym_sym(p, cur_sym); - mp_name_type(p) = cur_sym_mod; + p->name_type = cur_sym_mod; } return p; } @@ -10809,7 +10804,7 @@ void mp_runaway (MP mp) break; } mp_print_ln(mp); - mp_show_token_list(mp, mp_link(mp->hold_head), NULL); + mp_show_token_list(mp, mp->hold_head->link, NULL); } } @@ -10875,7 +10870,7 @@ void mp_get_next (MP mp) ); goto RESTART; } - mp_str_room(mp, (size_t) (loc - k)); + mp_str_room(mp, loc - k); do { mp_append_char(mp, mp->buffer[k]); ++k; @@ -10914,12 +10909,12 @@ void mp_get_next (MP mp) FOUND: set_cur_sym(mp_id_lookup(mp, (char *) (mp->buffer + k), (size_t) (loc - k), 1)); } else { - if (nloc != NULL && mp_type(nloc) == mp_symbol_node_type) { - int cur_sym_mod_ = mp_name_type(nloc); + if (nloc != NULL && nloc->type == mp_symbol_node_type) { + int cur_sym_mod_ = nloc->name_type; int cur_info = mp_get_sym_info(nloc); set_cur_sym(mp_get_sym_sym(nloc)); set_cur_sym_mod(cur_sym_mod_); - nloc = mp_link(nloc); + nloc = nloc->link; if (cur_sym_mod_ == mp_expr_operation) { set_cur_cmd(mp_capsule_command); set_cur_mod_node(mp->param_stack[param_start + cur_info]); @@ -10931,8 +10926,8 @@ void mp_get_next (MP mp) goto RESTART; } } else if (nloc != NULL) { - if (mp_name_type(nloc) == mp_token_operation) { - if (mp_type(nloc) == mp_known_type) { + if (nloc->name_type == mp_token_operation) { + if (nloc->type == mp_known_type) { set_cur_mod_number(mp_get_value_number(nloc)); set_cur_cmd(mp_numeric_command); } else { @@ -10944,7 +10939,7 @@ void mp_get_next (MP mp) set_cur_mod_node(nloc); set_cur_cmd(mp_capsule_command); } - nloc = mp_link(nloc); + nloc = nloc->link; return; } else { mp_end_token_list(mp); @@ -11153,7 +11148,7 @@ static mp_node mp_scan_toks (MP mp, mp_command_code terminator, mp_subst_list_it int cur_data_mod = 0; mp_node p = mp->hold_head; int balance = 1; - mp_link(mp->hold_head) = NULL; + mp->hold_head->link = NULL; while (1) { get_t_next(mp); cur_data = -1; @@ -11190,20 +11185,20 @@ static mp_node mp_scan_toks (MP mp, mp_command_code terminator, mp_subst_list_it if (cur_data != -1) { mp_node pp = mp_new_symbolic_node(mp); mp_set_sym_info(pp, cur_data); - mp_name_type(pp) = cur_data_mod; - mp_link(p) = pp; + pp->name_type = cur_data_mod; + p->link = pp; } else { - mp_link(p) = mp_cur_tok(mp); + p->link = mp_cur_tok(mp); } - p = mp_link(p); + p = p->link; } - mp_link(p) = tail_end; + p->link = tail_end; while (subst_list) { mp_subst_list_item *q = subst_list->link; mp_memory_free(subst_list); subst_list = q; } - return mp_link(mp->hold_head); + return mp->hold_head->link; } static void mp_get_symbol (MP mp) @@ -11280,10 +11275,10 @@ static void mp_make_op_def (MP mp, int code) q = mp_new_symbolic_node(mp); mp_set_ref_count(q, 0); r = mp_new_symbolic_node(mp); - mp_link(q) = r; + q->link = r; mp_set_sym_info(r, mp_general_macro); - mp_name_type(r) = mp_macro_operation; - mp_link(r) = mp_scan_toks(mp, mp_macro_def_command, qn, NULL, 0); + r->name_type = mp_macro_operation; + r->link = mp_scan_toks(mp, mp_macro_def_command, qn, NULL, 0); mp->scanner_status = mp_normal_state; set_eq_type(mp->warning_info, m); set_equiv_node(mp->warning_info, q); @@ -11301,7 +11296,7 @@ static void mp_scan_def (MP mp, int code) int sym_type; mp_sym l_delim, r_delim; int c = mp_general_macro; - mp_link(mp->hold_head) = NULL; + mp->hold_head->link = NULL; q = mp_new_symbolic_node(mp); mp_set_ref_count(q, 0); r = NULL; @@ -11315,7 +11310,7 @@ static void mp_scan_def (MP mp, int code) set_equiv_node(mp->warning_info, q); } else { p = mp_scan_declared_variable(mp); - mp_flush_variable(mp, equiv_node(mp_get_sym_sym(p)), mp_link(p), 1); + mp_flush_variable(mp, equiv_node(mp_get_sym_sym(p)), p->link, 1); mp->warning_info_node = mp_find_variable(mp, p); mp_flush_node_list(mp, p); if (mp->warning_info_node == NULL) { @@ -11333,7 +11328,7 @@ static void mp_scan_def (MP mp, int code) n = 3; get_t_next(mp); } - mp_type(mp->warning_info_node) = mp_unsuffixed_macro_type - 2 + n; + mp->warning_info_node->type = mp_unsuffixed_macro_type - 2 + n; mp_set_value_node(mp->warning_info_node, q); } k = n; @@ -11368,9 +11363,9 @@ static void mp_scan_def (MP mp, int code) sym_type = mp_expr_operation; OKAY: do { - mp_link(q) = mp_new_symbolic_node(mp); - q = mp_link(q); - mp_name_type(q) = sym_type; + q->link = mp_new_symbolic_node(mp); + q = q->link; + q->name_type = sym_type; mp_set_sym_info(q, k); mp_get_symbol(mp); rp = mp_memory_allocate(sizeof(mp_subst_list_item)); @@ -11438,17 +11433,17 @@ static void mp_scan_def (MP mp, int code) mp_check_equals(mp); p = mp_new_symbolic_node(mp); mp_set_sym_info(p, c); - mp_name_type(p) = mp_macro_operation; - mp_link(q) = p; + p->name_type = mp_macro_operation; + q->link = p; if (code == mp_def_code) { - mp_link(p) = mp_scan_toks(mp, mp_macro_def_command, r, NULL, (int) n); + p->link = mp_scan_toks(mp, mp_macro_def_command, r, NULL, (int) n); } else { mp_node qq = mp_new_symbolic_node(mp); mp_set_sym_sym(qq, mp->bg_loc); - mp_link(p) = qq; + p->link = qq; p = mp_new_symbolic_node(mp); mp_set_sym_sym(p, mp->eg_loc); - mp_link(qq) = mp_scan_toks(mp, mp_macro_def_command, r, p, (int) n); + qq->link = mp_scan_toks(mp, mp_macro_def_command, r, p, (int) n); } if (mp->warning_info_node == mp->bad_vardef) { mp_flush_token_list(mp, mp_get_value_node(mp->bad_vardef)); @@ -11797,16 +11792,16 @@ static void mp_macro_call (MP mp, mp_node def_ref, mp_node arg_list, mp_sym macr mp_node tail = 0; mp_sym l_delim = NULL; mp_sym r_delim = NULL; - mp_node r = mp_link(def_ref); + mp_node r = def_ref->link; mp_add_mac_ref(def_ref); if (arg_list == NULL) { n = 0; } else { n = 1; tail = arg_list; - while (mp_link(tail) != NULL) { + while (tail->link != NULL) { ++n; - tail = mp_link(tail); + tail = tail->link; } } if (number_positive(internal_value(mp_tracing_macros_internal))) { @@ -11824,13 +11819,13 @@ static void mp_macro_call (MP mp, mp_node def_ref, mp_node arg_list, mp_sym macr mp_node q = (mp_node) mp_get_sym_sym(p); mp_print_arg(mp, q, n, 0, 0); ++n; - p = mp_link(p); + p = p->link; } while (p != NULL); } mp_end_diagnostic(mp, 0); } set_cur_cmd(mp_comma_command + 1); - while (mp_name_type(r) == mp_expr_operation || mp_name_type(r) == mp_suffix_operation || mp_name_type(r) == mp_text_operation) { + while (r->name_type == mp_expr_operation || r->name_type == mp_suffix_operation || r->name_type == mp_text_operation) { if (cur_cmd != mp_comma_command) { mp_get_x_next(mp); if (cur_cmd != mp_left_delimiter_command) { @@ -11843,7 +11838,7 @@ static void mp_macro_call (MP mp, mp_node def_ref, mp_node arg_list, mp_sym macr mp->selector = selector; mp_snprintf(msg, 256, "Missing argument to %s", mp_str(mp, sname)); delete_str_ref(sname); - if (mp_name_type(r) == mp_suffix_operation || mp_name_type(r) == mp_text_operation) { + if (r->name_type == mp_suffix_operation || r->name_type == mp_text_operation) { mp_set_cur_exp_value_number(mp, &zero_t); mp->cur_exp.type = mp_token_list_type; } else { @@ -11862,18 +11857,18 @@ static void mp_macro_call (MP mp, mp_node def_ref, mp_node arg_list, mp_sym macr l_delim = cur_sym; r_delim = equiv_sym(cur_sym); } - if (mp_name_type(r) == mp_text_operation) { + if (r->name_type == mp_text_operation) { mp_scan_text_arg(mp, l_delim, r_delim); } else { mp_get_x_next(mp); - if (mp_name_type(r) == mp_suffix_operation) { + if (r->name_type == mp_suffix_operation) { mp_scan_suffix(mp); } else { mp_scan_expression(mp); } } if ((cur_cmd != mp_comma_command) && ((cur_cmd != mp_right_delimiter_command) || (equiv_sym(cur_sym) != l_delim))) { - switch (mp_name_type(mp_link(r))) { + switch (r->link->name_type) { case mp_expr_operation: case mp_suffix_operation: case mp_text_operation: @@ -11906,19 +11901,19 @@ static void mp_macro_call (MP mp, mp_node def_ref, mp_node arg_list, mp_sym macr } if (number_positive(internal_value(mp_tracing_macros_internal))) { mp_begin_diagnostic(mp); - mp_print_arg(mp, (mp_node) mp_get_sym_sym(p), n, mp_get_sym_info(r), mp_name_type(r)); + mp_print_arg(mp, (mp_node) mp_get_sym_sym(p), n, mp_get_sym_info(r), r->name_type); mp_end_diagnostic(mp, 0); } if (arg_list == NULL) { arg_list = p; } else { - mp_link(tail) = p; + tail->link = p; } tail = p; ++n; } - r = mp_link(r); + r = r->link; } if (cur_cmd == mp_comma_command) { char msg[256]; @@ -11975,7 +11970,7 @@ static void mp_macro_call (MP mp, mp_node def_ref, mp_node arg_list, mp_sym macr if (arg_list == NULL) { arg_list = p; } else { - mp_link(tail) = p; + tail->link = p; } tail = p; ++n; @@ -12029,20 +12024,20 @@ static void mp_macro_call (MP mp, mp_node def_ref, mp_node arg_list, mp_sym macr } if (number_positive(internal_value(mp_tracing_macros_internal))) { mp_begin_diagnostic(mp); - mp_print_arg(mp, (mp_node) mp_get_sym_sym(p), n, mp_get_sym_info(r), mp_name_type(r)); + mp_print_arg(mp, (mp_node) mp_get_sym_sym(p), n, mp_get_sym_info(r), r->name_type); mp_end_diagnostic(mp, 0); } if (arg_list == NULL) { arg_list = p; } else { - mp_link(tail) = p; + tail->link = p; } tail = p; ++n; } } - r = mp_link(r); + r = r->link; while (token_state && (nloc == NULL)) { mp_end_token_list(mp); @@ -12059,7 +12054,7 @@ static void mp_macro_call (MP mp, mp_node def_ref, mp_node arg_list, mp_sym macr do { mp->param_stack[mp->param_ptr] = (mp_node) mp_get_sym_sym(p); ++mp->param_ptr; - p = mp_link(p); + p = p->link; } while (p != NULL); mp_flush_node_list(mp, arg_list); } @@ -12073,21 +12068,21 @@ static void mp_print_macro_name (MP mp, mp_node a, mp_sym n) mp_node p = (mp_node) mp_get_sym_sym(a); if (p) { mp_node q = p; - while (mp_link(q) != NULL) { - q = mp_link(q); + while (q->link != NULL) { + q = q->link; } - mp_link(q) = (mp_node) mp_get_sym_sym(mp_link(a)); + q->link = (mp_node) mp_get_sym_sym(a->link); mp_show_token_list(mp, p, NULL); - mp_link(q) = NULL; + q->link = NULL; } else { - mp_print_mp_str(mp,text(mp_get_sym_sym((mp_node) mp_get_sym_sym(mp_link(a))))); + mp_print_mp_str(mp,text(mp_get_sym_sym((mp_node) mp_get_sym_sym(a->link)))); } } } static void mp_print_arg (MP mp, mp_node q, int n, int b, int bb) { - if (q && mp_link(q) == MP_VOID) { + if (q && q->link == MP_VOID) { mp_print_nl(mp, "(EXPR"); } else if ((bb < mp_text_operation) && (b != mp_text_macro)) { mp_print_nl(mp, "(SUFFIX"); @@ -12096,7 +12091,7 @@ static void mp_print_arg (MP mp, mp_node q, int n, int b, int bb) } mp_print_int(mp, n); mp_print_str(mp, ")<-"); - if (q && mp_link(q) == MP_VOID) { + if (q && q->link == MP_VOID) { mp_print_exp(mp, q, 1); } else { mp_show_token_list(mp, q, NULL); @@ -12109,7 +12104,7 @@ void mp_scan_text_arg (MP mp, mp_sym l_delim, mp_sym r_delim) mp->warning_info = l_delim; mp->scanner_status = mp_absorbing_state; mp_node p = mp->hold_head; - mp_link(mp->hold_head) = NULL; + mp->hold_head->link = NULL; while (1) { get_t_next(mp); if (l_delim == NULL) { @@ -12136,10 +12131,10 @@ void mp_scan_text_arg (MP mp, mp_sym l_delim, mp_sym r_delim) } } } - mp_link(p) = mp_cur_tok(mp); - p = mp_link(p); + p->link = mp_cur_tok(mp); + p = p->link; } - mp_set_cur_exp_node(mp, mp_link(mp->hold_head)); + mp_set_cur_exp_node(mp, mp->hold_head->link); mp->cur_exp.type = mp_token_list_type; mp->scanner_status = mp_normal_state; } @@ -12156,7 +12151,7 @@ static void mp_stack_argument (MP mp, mp_node p) static mp_node mp_get_if_node (MP mp) { mp_if_node p = (mp_if_node) mp_allocate_node(mp, sizeof(mp_if_node_data)); - mp_type(p) = mp_if_node_type; + p->type = mp_if_node_type; return (mp_node) p; } @@ -12187,9 +12182,9 @@ void mp_pass_text (MP mp) static void mp_push_condition_stack (MP mp) { mp_node p = mp_get_if_node(mp); - mp_link(p) = mp->cond_ptr; - mp_type(p) = (int) mp->if_limit; - mp_name_type(p) = mp->cur_if; + p->link = mp->cond_ptr; + p->type = (int) mp->if_limit; + p->name_type = mp->cur_if; mp_if_line_field(p) = mp->if_line; mp->cond_ptr = p; mp->if_limit = mp_if_code; @@ -12201,9 +12196,9 @@ static void mp_pop_condition_stack (MP mp) { mp_node p = mp->cond_ptr; mp->if_line = mp_if_line_field(p); - mp->cur_if = mp_name_type(p); - mp->if_limit = mp_type(p); - mp->cond_ptr = mp_link(p); + mp->cur_if = p->name_type; + mp->if_limit = p->type; + mp->cond_ptr = p->link; mp_free_node(mp, p, sizeof(mp_if_node_data)); } @@ -12217,11 +12212,11 @@ static void mp_change_if_limit (MP mp, int l, mp_node p) if (q == NULL) { mp_confusion(mp, "if"); return; - } else if (mp_link(q) == p) { - mp_type(q) = l; + } else if (q->link == p) { + q->type = l; return; } else { - q = mp_link(q); + q = q->link; } } } @@ -12386,9 +12381,9 @@ void mp_begin_iteration (MP mp) } s->type = mp->cur_exp.data.node; mp->cur_exp.type = mp_vacuous_type; - q = mp_link(mp_edge_list(mp->cur_exp.data.node)); + q = mp_edge_list(mp->cur_exp.data.node)->link; if (q != NULL && mp_is_start_or_stop (q) && mp_skip_1component(mp, q) == NULL) { - q = mp_link(q); + q = q->link; } s->list = q; } @@ -12447,13 +12442,13 @@ void mp_begin_iteration (MP mp) } mp_set_cur_exp_node(mp, mp_stash_cur_exp(mp)); } - mp_link(q) = mp_new_symbolic_node(mp); - q = mp_link(q); + q->link = mp_new_symbolic_node(mp); + q = q->link; mp_set_sym_sym(q, mp->cur_exp.data.node); if (m == mp_start_for_code) { - mp_name_type(q) = mp_expr_operation; + q->name_type = mp_expr_operation; } else if (m == mp_start_forsuffixes_code) { - mp_name_type(q) = mp_suffix_operation; + q->name_type = mp_suffix_operation; } mp->cur_exp.type = mp_vacuous_type; CONTINUE: @@ -12520,7 +12515,7 @@ void mp_resume_iteration (MP mp) p = mp->loop_ptr->list; if (p != NULL && p == mp->loop_ptr->list_start) { q = p; - p = mp_link(p); + p = p->link; mp_free_symbolic_node(mp, q); mp->loop_ptr->list = p; } @@ -12528,7 +12523,7 @@ void mp_resume_iteration (MP mp) mp_stop_iteration(mp); return; } - mp->loop_ptr->list = mp_link(p); + mp->loop_ptr->list = p->link; q = (mp_node) mp_get_sym_sym(p); if (q) { number_clone(mp->loop_ptr->old_value, q->data.n); @@ -12542,7 +12537,7 @@ void mp_resume_iteration (MP mp) if (q == NULL) { goto NOT_FOUND; } else if (! mp_is_start_or_stop(q)) { - q = mp_link(q); + q = q->link; } else if (! mp_is_stop(q)) { q = mp_skip_1component(mp, q); } else { @@ -12559,7 +12554,7 @@ void mp_resume_iteration (MP mp) if (number_greater(internal_value(mp_tracing_commands_internal), unity_t)) { mp_begin_diagnostic(mp); mp_print_nl(mp, "{loop value="); - if ((q != NULL) && (mp_link(q) == MP_VOID)) { + if ((q != NULL) && (q->link == MP_VOID)) { mp_print_exp(mp, q, 1); } else { mp_show_token_list(mp, q, NULL); @@ -12585,7 +12580,7 @@ void mp_stop_iteration (MP mp) while (q != NULL) { p = (mp_node) mp_get_sym_sym(q); if (p != NULL) { - if (mp_link(p) == MP_VOID) { + if (p->link == MP_VOID) { mp_recycle_value(mp, p); mp_free_value_node(mp, p); } else { @@ -12593,7 +12588,7 @@ void mp_stop_iteration (MP mp) } } p = q; - q = mp_link(q); + q = q->link; mp_free_symbolic_node(mp, p); } } else if (p > MP_PROGRESSION_FLAG) { @@ -12857,8 +12852,8 @@ static mp_node mp_stash_cur_exp (MP mp) break; default: p = mp_new_value_node(mp); - mp_name_type(p) = mp_capsule_operation; - mp_type(p) = mp->cur_exp.type; + p->name_type = mp_capsule_operation; + p->type = mp->cur_exp.type; mp_set_value_number(p, cur_exp_value_number); if (cur_exp_str) { mp_set_value_str(p, cur_exp_str); @@ -12870,13 +12865,13 @@ static mp_node mp_stash_cur_exp (MP mp) break; } mp->cur_exp.type = mp_vacuous_type; - mp_link(p) = MP_VOID; + p->link = MP_VOID; return p; } void mp_unstash_cur_exp (MP mp, mp_node p) { - mp->cur_exp.type = mp_type(p); + mp->cur_exp.type = p->type; switch (mp->cur_exp.type) { case mp_unknown_boolean_type: case mp_unknown_string_type: @@ -12943,7 +12938,7 @@ void mp_print_exp (MP mp, mp_node p, int verbosity) p = mp_stash_cur_exp(mp); restore_cur_exp = 1; } - t = mp_type(p); + t = p->type; if (t < mp_dependent_type) { if (t != mp_vacuous_type && t != mp_known_type && mp_get_value_node(p) != NULL) { v = mp_get_value_node(p); @@ -12972,7 +12967,7 @@ void mp_print_exp (MP mp, mp_node p, int verbosity) mp_print_type(mp, t); if (v != NULL) { mp_print_chr(mp, ' '); - while ((mp_name_type(v) == mp_capsule_operation) && (v != p)) { + while ((v->name_type == mp_capsule_operation) && (v != p)) { v = mp_get_value_node(v); } mp_print_variable_name(mp, v); @@ -13097,7 +13092,7 @@ void mp_print_exp (MP mp, mp_node p, int verbosity) void mp_print_big_node (MP mp, mp_node v, int verbosity) { - switch (mp_type(v)) { + switch (v->type) { case mp_known_type: print_number(mp_get_value_number(v)); break; @@ -13105,14 +13100,14 @@ void mp_print_big_node (MP mp, mp_node v, int verbosity) mp_print_variable_name(mp, v); break; default: - mp_print_dp(mp, mp_type(v), (mp_value_node) mp_get_dep_list((mp_value_node) v), verbosity); + mp_print_dp(mp, v->type, (mp_value_node) mp_get_dep_list((mp_value_node) v), verbosity); break; } } static void mp_print_dp (MP mp, int t, mp_value_node p, int verbosity) { - mp_value_node q = (mp_value_node) mp_link(p); + mp_value_node q = (mp_value_node) p->link; if ((mp_get_dep_info(q) == NULL) || (verbosity > 0)) { mp_print_dependency(mp, p, t); } else { @@ -13172,7 +13167,7 @@ void mp_flush_cur_exp (MP mp, mp_value v) static void mp_recycle_value (MP mp, mp_node p) { if (p != NULL && p != MP_VOID) { - mp_variable_type t = mp_type(p); + mp_variable_type t = p->type; switch (t) { case mp_vacuous_type: case mp_boolean_type: @@ -13253,10 +13248,10 @@ static void mp_recycle_value (MP mp, mp_node p) { mp_value_node qq = (mp_value_node) mp_get_dep_list((mp_value_node) p); while (mp_get_dep_info(qq) != NULL) { - qq = (mp_value_node) mp_link(qq); + qq = (mp_value_node) qq->link; } - mp_set_link(mp_get_prev_dep((mp_value_node) p), mp_link(qq)); - mp_set_prev_dep(mp_link(qq), mp_get_prev_dep((mp_value_node) p)); + mp_set_link(mp_get_prev_dep((mp_value_node) p), qq->link); + mp_set_prev_dep(qq->link, mp_get_prev_dep((mp_value_node) p)); mp_set_link(qq, NULL); mp_flush_node_list(mp, (mp_node) mp_get_dep_list((mp_value_node) p)); } @@ -13275,7 +13270,7 @@ static void mp_recycle_value (MP mp, mp_node p) default: break; } - mp_type(p) = mp_undefined_type; + p->type = mp_undefined_type; } } @@ -13285,7 +13280,7 @@ static void mp_recycle_independent_value (MP mp, mp_node p) mp_node pp; mp_number v ; mp_number test; - mp_variable_type t = mp_type(p); + mp_variable_type t = p->type; new_number(test); new_number(v); if (t < mp_dependent_type) { @@ -13295,22 +13290,22 @@ static void mp_recycle_independent_value (MP mp, mp_node p) set_number_to_zero(mp->max_c[mp_proto_dependent_type]); mp->max_link[mp_dependent_type] = NULL; mp->max_link[mp_proto_dependent_type] = NULL; - q = (mp_value_node) mp_link(mp->dep_head); + q = (mp_value_node) mp->dep_head->link; while (q != mp->dep_head) { s = (mp_value_node) mp->temp_head; mp_set_link(s, mp_get_dep_list(q)); while (1) { - r = (mp_value_node) mp_link(s); + r = (mp_value_node) s->link; if (mp_get_dep_info(r) == NULL) { break; } else if (mp_get_dep_info(r) != p) { s = r; } else { - t = mp_type(q); - if (mp_link(s) == mp_get_dep_list(q)) { - mp_set_dep_list(q, mp_link(r)); + t = q->type; + if (s->link == mp_get_dep_list(q)) { + mp_set_dep_list(q, r->link); } - mp_set_link(s, mp_link(r)); + mp_set_link(s, r->link); mp_set_dep_info(r, (mp_node) q); number_abs_clone(test, mp_get_dep_value(r)); if (number_greater(test, mp->max_c[t])) { @@ -13326,7 +13321,7 @@ static void mp_recycle_independent_value (MP mp, mp_node p) } } } - q = (mp_value_node) mp_link(r); + q = (mp_value_node) r->link; } if (number_positive(mp->max_c[mp_dependent_type]) || number_positive(mp->max_c[mp_proto_dependent_type])) { mp_number test, ret; @@ -13350,9 +13345,9 @@ static void mp_recycle_independent_value (MP mp, mp_node p) r = (mp_value_node) mp_get_dep_list((mp_value_node) pp); mp_set_link(s, r); while (mp_get_dep_info(r) != NULL) { - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; } - q = (mp_value_node) mp_link(r); + q = (mp_value_node) r->link; mp_set_link(r, NULL); mp_set_prev_dep(q, mp_get_prev_dep((mp_value_node) pp)); mp_set_link(mp_get_prev_dep((mp_value_node) pp), (mp_node) q); @@ -13383,7 +13378,7 @@ static void mp_recycle_independent_value (MP mp, mp_node p) mp_make_known(mp, q, mp->dep_final); } q = r; - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; mp_free_dep_node(mp, q); } } @@ -13397,7 +13392,7 @@ static void mp_recycle_independent_value (MP mp, mp_node p) mp->cur_exp.type = mp_proto_dependent_type; } mp_set_dep_list(q, mp_p_over_v(mp, (mp_value_node) mp_get_dep_list(q), &unity_t, mp_dependent_type, mp_proto_dependent_type)); - mp_type(q) = mp_proto_dependent_type; + q->type = mp_proto_dependent_type; fraction_to_round_scaled(mp_get_dep_value(r)); } number_negated_clone(test, v); @@ -13407,7 +13402,7 @@ static void mp_recycle_independent_value (MP mp, mp_node p) mp_make_known(mp, q, mp->dep_final); } q = r; - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; mp_free_dep_node(mp, q); } } @@ -13484,13 +13479,13 @@ static void mp_bad_exp (MP mp, const char *s) static void mp_stash_in (MP mp, mp_node p) { - mp_type(p) = mp->cur_exp.type; + p->type = mp->cur_exp.type; if (mp->cur_exp.type == mp_known_type) { mp_set_value_number(p, cur_exp_value_number); } else if (mp->cur_exp.type == mp_independent_type) { mp_value_node q = mp_single_dependency(mp, cur_exp_node); if (q == mp->dep_final) { - mp_type(p) = mp_known_type; + p->type = mp_known_type; mp_set_value_number(p, zero_t); mp_free_dep_node(mp, q); } else { @@ -13510,7 +13505,7 @@ static void mp_stash_in (MP mp, mp_node p) static void mp_back_expr (MP mp) { mp_node p = mp_stash_cur_exp(mp); - mp_link(p) = NULL; + p->link = NULL; mp_begin_token_list(mp, p, mp_backed_up_text); } @@ -13548,7 +13543,7 @@ static void mp_binary_mac (MP mp, mp_node p, mp_node c, mp_sym n) { mp_node q = mp_new_symbolic_node(mp); mp_node r = mp_new_symbolic_node(mp); - mp_link(q) = r; + q->link = r; mp_set_sym_sym(q, p); mp_set_sym_sym(r, mp_stash_cur_exp(mp)); mp_macro_call(mp, c, q, n); @@ -13588,7 +13583,7 @@ void mp_known_pair (MP mp) set_number_to_zero(mp->cur_y); } else { mp_node p = mp_get_value_node(cur_exp_node); - if (mp_type(mp_x_part(p)) == mp_known_type) { + if (mp_x_part(p)->type == mp_known_type) { number_clone(mp->cur_x, mp_get_value_number(mp_x_part(p))); } else { mp_disp_err(mp, mp_x_part(p)); @@ -13602,7 +13597,7 @@ void mp_known_pair (MP mp) mp_recycle_value(mp, mp_x_part(p)); set_number_to_zero(mp->cur_x); } - if (mp_type(mp_y_part(p)) == mp_known_type) { + if (mp_y_part(p)->type == mp_known_type) { number_clone(mp->cur_y, mp_get_value_number(mp_y_part(p))); } else { mp_disp_err(mp, mp_y_part(p)); @@ -13826,16 +13821,16 @@ static void mp_do_nullary (MP mp, int c) static int mp_pict_color_type (MP mp, int c) { return ( - (mp_link(mp_edge_list(cur_exp_node)) != NULL) + (mp_edge_list(cur_exp_node)->link != NULL) && ( - (! mp_has_color(mp_link(mp_edge_list(cur_exp_node)))) + (! mp_has_color(mp_edge_list(cur_exp_node)->link)) || (( - (mp_color_model(mp_link(mp_edge_list(cur_exp_node))) == c) + (mp_color_model(mp_edge_list(cur_exp_node)->link) == c) || ( - (mp_color_model(mp_link(mp_edge_list(cur_exp_node))) == mp_uninitialized_model) + (mp_color_model(mp_edge_list(cur_exp_node)->link) == mp_uninitialized_model) && (number_to_scaled(internal_value(mp_default_color_model_internal))/number_to_scaled(unity_t)) == c ) @@ -13881,7 +13876,7 @@ static int mp_nice_pair (MP mp, mp_node p, int t) (void) mp; if (t == mp_pair_type) { p = mp_get_value_node(p); - if (mp_type(mp_x_part(p)) == mp_known_type && mp_type(mp_y_part(p)) == mp_known_type) + if (mp_x_part(p)->type == mp_known_type && mp_y_part(p)->type == mp_known_type) return 1; } return 0; @@ -13893,23 +13888,25 @@ static int mp_nice_color_or_pair (MP mp, mp_node p, int t) switch (t) { case mp_pair_type: q = mp_get_value_node(p); - if (mp_type(mp_x_part(q)) == mp_known_type - && mp_type(mp_y_part(q)) == mp_known_type) + if (mp_x_part(q)->type == mp_known_type + && mp_y_part(q)->type == mp_known_type) { return 1; - break; + } else { + break; + } case mp_color_type: q = mp_get_value_node(p); - if (mp_type(mp_red_part (q)) == mp_known_type - && mp_type(mp_green_part(q)) == mp_known_type - && mp_type(mp_blue_part (q)) == mp_known_type) + if (mp_red_part (q)->type == mp_known_type + && mp_green_part(q)->type == mp_known_type + && mp_blue_part (q)->type == mp_known_type) return 1; break; case mp_cmykcolor_type: q = mp_get_value_node(p); - if (mp_type(mp_cyan_part (q)) == mp_known_type - && mp_type(mp_magenta_part(q)) == mp_known_type - && mp_type(mp_yellow_part (q)) == mp_known_type - && mp_type(mp_black_part (q)) == mp_known_type) + if (mp_cyan_part (q)->type == mp_known_type + && mp_magenta_part(q)->type == mp_known_type + && mp_yellow_part (q)->type == mp_known_type + && mp_black_part (q)->type == mp_known_type) return 1; break; } @@ -13963,12 +13960,12 @@ static void mp_negate_dep_list (MP mp, mp_value_node p) number_negate(mp_get_dep_value(p)); if (mp_get_dep_info(p) == NULL) return; - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; } } static void mp_negate_value(MP mp, mp_node r) { - if (mp_type(r) == mp_known_type) { + if (r->type == mp_known_type) { mp_set_value_number(r, mp_get_value_number(r)); number_negate(mp_get_value_number(r)); } else { @@ -14036,8 +14033,8 @@ static void mp_take_part (MP mp, int c) { mp_node p = mp_get_value_node(cur_exp_node); mp_set_value_node(mp->temp_val, p); - mp_type(mp->temp_val) = mp->cur_exp.type; - mp_link(p) = mp->temp_val; + mp->temp_val->type = mp->cur_exp.type; + p->link= mp->temp_val; mp_free_value_node(mp, cur_exp_node); switch (c) { case mp_x_part_operation: @@ -14099,7 +14096,7 @@ static void mp_take_pict_part (MP mp, int c) mp_value new_expr; memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); - p = mp_link(mp_edge_list(cur_exp_node)); + p = mp_edge_list(cur_exp_node)->link; if (p != NULL) { switch (c) { case mp_x_part_operation: @@ -14212,7 +14209,7 @@ static void mp_take_pict_part (MP mp, int c) mp_confusion(mp, "picture"); } else { new_expr.data.node = NULL; - switch (mp_type(p)) { + switch (p->type) { case mp_fill_node_type: case mp_stroked_node_type: new_expr.data.p = mp_copy_path(mp, mp_path_ptr((mp_shape_node) p)); @@ -14233,7 +14230,7 @@ static void mp_take_pict_part (MP mp, int c) if (! mp_has_pen(p)) { goto NOT_FOUND; } else { - switch (mp_type(p)) { + switch (p->type) { case mp_fill_node_type: case mp_stroked_node_type: if (mp_pen_ptr((mp_shape_node) p) == NULL) { @@ -14250,7 +14247,7 @@ static void mp_take_pict_part (MP mp, int c) } break; case mp_dash_part_operation: - if (mp_type(p) != mp_stroked_node_type) { + if (p->type != mp_stroked_node_type) { goto NOT_FOUND; } else if (mp_dash_ptr(p) == NULL) { goto NOT_FOUND; @@ -14330,15 +14327,15 @@ static void mp_path_length (MP mp, mp_number *n) } static void mp_picture_length (MP mp, mp_number *n) { - mp_node p = mp_link(mp_edge_list(cur_exp_node)); + mp_node p = mp_edge_list(cur_exp_node)->link; int l = 0; if (p != NULL) { if (mp_is_start_or_stop(p) && mp_skip_1component(mp, p) == NULL) { - p = mp_link(p); + p = p->link; } while (p != NULL) { if (! mp_is_start_or_stop(p)) { - p = mp_link(p); + p = p->link; } else if (! mp_is_stop(p)) { p = mp_skip_1component(mp, p); } else { @@ -14364,13 +14361,13 @@ static void mp_bezier_slope (MP mp, static void mp_turn_cycles (MP mp, mp_number *turns, mp_knot c) { int selector; - mp_angle res, ang; + mp_number res, ang; mp_knot p; mp_number xp, yp; mp_number x, y; mp_number arg1, arg2; - mp_angle in_angle, out_angle; - mp_angle seven_twenty_deg_t; + mp_number in_angle, out_angle; + mp_number seven_twenty_deg_t; set_number_to_zero(*turns); new_number(arg1); new_number(arg2); @@ -14492,12 +14489,12 @@ static int mp_test_known (MP mp, int c) case mp_transform_type: { mp_node p = mp_get_value_node(cur_exp_node); - if ( (mp_type(mp_tx_part(p)) == mp_known_type) && - (mp_type(mp_ty_part(p)) == mp_known_type) && - (mp_type(mp_xx_part(p)) == mp_known_type) && - (mp_type(mp_xy_part(p)) == mp_known_type) && - (mp_type(mp_yx_part(p)) == mp_known_type) && - (mp_type(mp_yy_part(p)) == mp_known_type) ) { + if ( (mp_tx_part(p)->type == mp_known_type) && + (mp_ty_part(p)->type == mp_known_type) && + (mp_xx_part(p)->type == mp_known_type) && + (mp_xy_part(p)->type== mp_known_type) && + (mp_yx_part(p)->type == mp_known_type) && + (mp_yy_part(p)->type == mp_known_type) ) { b = mp_true_operation; } } @@ -14505,9 +14502,9 @@ static int mp_test_known (MP mp, int c) case mp_color_type: { mp_node p = mp_get_value_node(cur_exp_node); - if ( (mp_type(mp_red_part(p)) == mp_known_type) && - (mp_type(mp_green_part(p)) == mp_known_type) && - (mp_type(mp_blue_part(p)) == mp_known_type) ) { + if ( (mp_red_part (p)->type == mp_known_type) && + (mp_green_part(p)->type == mp_known_type) && + (mp_blue_part (p)->type == mp_known_type) ) { b = mp_true_operation; } } @@ -14515,10 +14512,10 @@ static int mp_test_known (MP mp, int c) case mp_cmykcolor_type: { mp_node p = mp_get_value_node(cur_exp_node); - if ( (mp_type(mp_cyan_part(p)) == mp_known_type) && - (mp_type(mp_magenta_part(p)) == mp_known_type) && - (mp_type(mp_yellow_part(p)) == mp_known_type) && - (mp_type(mp_black_part(p)) == mp_known_type) ) { + if ( (mp_cyan_part (p)->type == mp_known_type) && + (mp_magenta_part(p)->type == mp_known_type) && + (mp_yellow_part (p)->type == mp_known_type) && + (mp_black_part (p)->type == mp_known_type) ) { b = mp_true_operation; } } @@ -14526,8 +14523,8 @@ static int mp_test_known (MP mp, int c) case mp_pair_type: { mp_node p = mp_get_value_node(cur_exp_node); - if ( (mp_type(mp_x_part(p)) == mp_known_type) && - (mp_type(mp_y_part(p)) == mp_known_type) ) { + if ( (mp_x_part(p)->type == mp_known_type) && + (mp_y_part(p)->type == mp_known_type) ) { b = mp_true_operation; } } @@ -14551,16 +14548,16 @@ static void mp_pair_value (MP mp, mp_number *x, mp_number *y) memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); p = mp_new_value_node(mp); - new_expr.type = mp_type(p); + new_expr.type = p->type; new_expr.data.node = p; mp_flush_cur_exp(mp, new_expr); mp->cur_exp.type = mp_pair_type; - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp_init_pair_node(mp, p); p = mp_get_value_node(p); - mp_type(mp_x_part(p)) = mp_known_type; + mp_x_part(p)->type = mp_known_type; mp_set_value_number(mp_x_part(p), x1); - mp_type(mp_y_part(p)) = mp_known_type; + mp_y_part(p)->type = mp_known_type; mp_set_value_number(mp_y_part(p), y1); free_number(x1); free_number(y1); @@ -15147,11 +15144,11 @@ static void mp_do_unary (MP mp, int c) new_number(expr.data.n); if (mp->cur_exp.type != mp_picture_type) { set_number_from_boolean(expr.data.n, mp_false_operation); - } else if (mp_link(mp_edge_list(cur_exp_node)) == NULL) { + } else if (mp_edge_list(cur_exp_node)->link == NULL) { set_number_from_boolean(expr.data.n, mp_false_operation); } else { int type = c - mp_filled_operation + mp_fill_node_type; - set_number_from_boolean(expr.data.n, mp_type(mp_link(mp_edge_list(cur_exp_node))) == type ? mp_true_operation: mp_false_operation); + set_number_from_boolean(expr.data.n, mp_edge_list(cur_exp_node)->link->type == type ? mp_true_operation: mp_false_operation); } mp_flush_cur_exp(mp, expr); mp->cur_exp.type = mp_boolean_type; @@ -15383,7 +15380,7 @@ static void mp_bad_color_part (MP mp, int c) mp_string sname; memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); - p = mp_link(mp_edge_list(cur_exp_node)); + p = mp_edge_list(cur_exp_node)->link; mp_disp_err(mp, NULL); selector = mp->selector; mp->selector = mp_new_string_selector; @@ -15526,7 +15523,7 @@ static void mp_bad_binary (MP mp, mp_node p, int c) if (c >= mp_min_of_operation) { mp_print_op(mp, c); } - mp_print_known_or_unknown_type(mp, mp_type(p), p); + mp_print_known_or_unknown_type(mp, p->type, p); if (c >= mp_min_of_operation) { mp_print_str(mp, "of"); } else { @@ -15565,33 +15562,33 @@ static mp_node mp_tarnished (MP mp, mp_node p) { mp_node q = mp_get_value_node(p); (void) mp; - switch (mp_type(p)) { + switch (p->type) { case mp_pair_type: return ( - (mp_type(mp_x_part(q)) == mp_independent_type) || - (mp_type(mp_y_part(q)) == mp_independent_type) + (mp_x_part(q)->type == mp_independent_type) || + (mp_y_part(q)->type == mp_independent_type) ) ? MP_VOID : NULL; case mp_color_type: return ( - (mp_type(mp_red_part(q)) == mp_independent_type) || - (mp_type(mp_green_part(q)) == mp_independent_type) || - (mp_type(mp_blue_part(q)) == mp_independent_type) + (mp_red_part (q)->type == mp_independent_type) || + (mp_green_part(q)->type == mp_independent_type) || + (mp_blue_part (q)->type == mp_independent_type) ) ? MP_VOID : NULL; case mp_cmykcolor_type: return ( - (mp_type(mp_cyan_part(q)) == mp_independent_type) || - (mp_type(mp_magenta_part(q)) == mp_independent_type) || - (mp_type(mp_yellow_part(q)) == mp_independent_type) || - (mp_type(mp_black_part(q)) == mp_independent_type) + (mp_cyan_part (q)->type == mp_independent_type) || + (mp_magenta_part(q)->type == mp_independent_type) || + (mp_yellow_part (q)->type == mp_independent_type) || + (mp_black_part (q)->type == mp_independent_type) ) ? MP_VOID : NULL; case mp_transform_type: return ( - (mp_type(mp_tx_part(q)) == mp_independent_type) || - (mp_type(mp_ty_part(q)) == mp_independent_type) || - (mp_type(mp_xx_part(q)) == mp_independent_type) || - (mp_type(mp_xy_part(q)) == mp_independent_type) || - (mp_type(mp_yx_part(q)) == mp_independent_type) || - (mp_type(mp_yy_part(q)) == mp_independent_type) + (mp_tx_part(q)->type == mp_independent_type) || + (mp_ty_part(q)->type == mp_independent_type) || + (mp_xx_part(q)->type == mp_independent_type) || + (mp_xy_part(q)->type == mp_independent_type) || + (mp_yx_part(q)->type == mp_independent_type) || + (mp_yy_part(q)->type == mp_independent_type) ) ? MP_VOID : NULL; default: return NULL; @@ -15601,7 +15598,7 @@ static void mp_dep_finish (MP mp, mp_value_node v, mp_value_node q, int t) { mp_value_node p = (q == NULL) ? (mp_value_node) cur_exp_node : q; mp_set_dep_list(p, v); - mp_type(p) = t; + p->type = t; if (mp_get_dep_info(v) == NULL) { mp_number vv; new_number_clone(vv, mp_get_value_number(v)); @@ -15612,7 +15609,7 @@ static void mp_dep_finish (MP mp, mp_value_node v, mp_value_node q, int t) mp_flush_cur_exp(mp, new_expr); } else { mp_recycle_value(mp, (mp_node) p); - mp_type(q) = mp_known_type; + q->type = mp_known_type; mp_set_value_number(q, vv); } free_number(vv); @@ -15639,7 +15636,7 @@ static void mp_add_or_subtract (MP mp, mp_node p, mp_node q, int c) v = (mp_value_node) mp_get_dep_list((mp_value_node) cur_exp_node); } } else { - t = mp_type(q); + t = q->type; if (t < mp_dependent_type) { number_clone(vv, mp_get_value_number(q)); } else { @@ -15651,7 +15648,7 @@ static void mp_add_or_subtract (MP mp, mp_node p, mp_node q, int c) if (c == mp_minus_operation) { number_negate(vv); } - if (mp_type(p) == mp_known_type) { + if (p->type == mp_known_type) { slow_add(vv, mp_get_value_number(p), vv); if (q == NULL) { mp_set_cur_exp_value_number(mp, &vv); @@ -15663,34 +15660,34 @@ static void mp_add_or_subtract (MP mp, mp_node p, mp_node q, int c) } else { r = (mp_value_node) mp_get_dep_list((mp_value_node) p); while (mp_get_dep_info(r) != NULL) { - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; } slow_add(vv, mp_get_dep_value(r), vv); mp_set_dep_value(r, vv); if (qq == NULL) { qq = mp_get_dep_node(mp); mp_set_cur_exp_node(mp, (mp_node) qq); - mp->cur_exp.type = mp_type(p); - mp_name_type(qq) = mp_capsule_operation; + mp->cur_exp.type = p->type; + qq->name_type = mp_capsule_operation; } mp_set_dep_list(qq, mp_get_dep_list((mp_value_node) p)); - mp_type(qq) = mp_type(p); + qq->type = p->type; mp_set_prev_dep(qq, mp_get_prev_dep((mp_value_node) p)); - mp_link(mp_get_prev_dep((mp_value_node) p)) = (mp_node) qq; - mp_type(p) = mp_known_type; + mp_get_prev_dep((mp_value_node) p)->link = (mp_node) qq; + p->type = mp_known_type; } } else { if (c == mp_minus_operation) { mp_negate_dep_list(mp, v); } - if (mp_type(p) == mp_known_type) { + if (p->type == mp_known_type) { while (mp_get_dep_info(v) != NULL) { - v = (mp_value_node) mp_link(v); + v = (mp_value_node) v->link; } slow_add(vv, mp_get_value_number(p), mp_get_dep_value(v)); mp_set_dep_value(v, vv); } else { - s = mp_type(p); + s = p->type; r = (mp_value_node) mp_get_dep_list((mp_value_node) p); if (t == mp_dependent_type) { if (s == mp_dependent_type) { @@ -15734,7 +15731,7 @@ static void mp_dep_mult (MP mp, mp_value_node p, mp_number *v, int v_is_scaled) int s, t; if (p == NULL) { q = (mp_value_node) cur_exp_node; - } else if (mp_type(p) != mp_known_type) { + } else if (p->type != mp_known_type) { q = p; } else { mp_number r1, arg1; @@ -15751,7 +15748,7 @@ static void mp_dep_mult (MP mp, mp_value_node p, mp_number *v, int v_is_scaled) free_number(arg1); return; } - t = mp_type(q); + t = q->type; q = (mp_value_node) mp_get_dep_list(q); s = t; if (t == mp_dependent_type && v_is_scaled) { @@ -15774,7 +15771,7 @@ static void mp_hard_times (MP mp, mp_node p) mp_value_node pp; mp_number v; new_number(v); - if (mp_type(p) <= mp_pair_type) { + if (p->type <= mp_pair_type) { q = (mp_value_node) mp_stash_cur_exp(mp); mp_unstash_cur_exp(mp, p); p = (mp_node) q; @@ -15785,11 +15782,11 @@ static void mp_hard_times (MP mp, mp_node p) { mp_node r = mp_x_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_y_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); } break; @@ -15797,15 +15794,15 @@ static void mp_hard_times (MP mp, mp_node p) { mp_node r = mp_red_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_green_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_blue_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); } break; @@ -15813,19 +15810,19 @@ static void mp_hard_times (MP mp, mp_node p) { mp_node r = mp_cyan_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_yellow_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_magenta_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_black_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); } break; @@ -15840,7 +15837,7 @@ static void mp_dep_div (MP mp, mp_value_node p, mp_number *v) int s, t; if (p == NULL) { q = (mp_value_node) cur_exp_node; - } else if (mp_type(p) != mp_known_type) { + } else if (p->type != mp_known_type) { q = p; } else { mp_number ret; @@ -15850,7 +15847,7 @@ static void mp_dep_div (MP mp, mp_value_node p, mp_number *v) free_number(ret); return; } - t = mp_type(q); + t = q->type; q = (mp_value_node) mp_get_dep_list(q); s = t; if (t == mp_dependent_type) { @@ -15880,7 +15877,7 @@ static void mp_set_up_trans (MP mp, int c) q = mp_get_value_node(cur_exp_node); switch (c) { case mp_rotated_operation: - if (mp_type(p) == mp_known_type) { + if (p->type == mp_known_type) { mp_number n_sin, n_cos, arg1, arg2; new_fraction(n_sin); new_fraction(n_cos); @@ -15905,20 +15902,20 @@ static void mp_set_up_trans (MP mp, int c) } break; case mp_slanted_operation: - if (mp_type(p) > mp_pair_type) { + if (p->type > mp_pair_type) { mp_install(mp, mp_xy_part(q), p); goto DONE; } break; case mp_scaled_operation: - if (mp_type(p) > mp_pair_type) { + if (p->type > mp_pair_type) { mp_install(mp, mp_xx_part(q), p); mp_install(mp, mp_yy_part(q), p); goto DONE; } break; case mp_shifted_operation: - if (mp_type(p) == mp_pair_type) { + if (p->type == mp_pair_type) { r = mp_get_value_node(p); mp_install(mp, mp_tx_part(q), mp_x_part(r)); mp_install(mp, mp_ty_part(q), mp_y_part(r)); @@ -15926,25 +15923,25 @@ static void mp_set_up_trans (MP mp, int c) } break; case mp_x_scaled_operation: - if (mp_type(p) > mp_pair_type) { + if (p->type > mp_pair_type) { mp_install(mp, mp_xx_part(q), p); goto DONE; } break; case mp_y_scaled_operation: - if (mp_type(p) > mp_pair_type) { + if (p->type > mp_pair_type) { mp_install(mp, mp_yy_part(q), p); goto DONE; } break; case mp_z_scaled_operation: - if (mp_type(p) == mp_pair_type) { + if (p->type == mp_pair_type) { { r = mp_get_value_node(p); mp_install(mp, mp_xx_part(q), mp_x_part(r)); mp_install(mp, mp_yy_part(q), mp_x_part(r)); mp_install(mp, mp_yx_part(q), mp_y_part(r)); - if (mp_type(mp_y_part(r)) == mp_known_type) { + if (mp_y_part(r)->type == mp_known_type) { mp_set_value_number(mp_y_part(r), mp_get_value_number(mp_y_part(r))); number_negate(mp_get_value_number(mp_y_part(r))); } else { @@ -15971,12 +15968,12 @@ static void mp_set_up_trans (MP mp, int c) mp_free_value_node(mp, p); } q = mp_get_value_node(cur_exp_node); - if ( (mp_type(mp_tx_part(q)) == mp_known_type) && - (mp_type(mp_ty_part(q)) == mp_known_type) && - (mp_type(mp_xx_part(q)) == mp_known_type) && - (mp_type(mp_xy_part(q)) == mp_known_type) && - (mp_type(mp_yx_part(q)) == mp_known_type) && - (mp_type(mp_yy_part(q)) == mp_known_type) ) { + if ( (mp_tx_part(q)->type == mp_known_type) && + (mp_ty_part(q)->type == mp_known_type) && + (mp_xx_part(q)->type == mp_known_type) && + (mp_xy_part(q)->type == mp_known_type) && + (mp_yx_part(q)->type == mp_known_type) && + (mp_yy_part(q)->type == mp_known_type) ) { number_clone(mp->txx, mp_get_value_number(mp_xx_part(q))); number_clone(mp->txy, mp_get_value_number(mp_xy_part(q))); number_clone(mp->tyx, mp_get_value_number(mp_yx_part(q))); @@ -16065,7 +16062,7 @@ static void mp_do_path_pen_trans (MP mp, mp_shape_node p, mp_number *sqdet, int set_number_to_zero(mp->tx); set_number_to_zero(mp->ty); mp_do_pen_trans(mp, mp_pen_ptr(p)); - if (number_nonzero(*sqdet) && ((mp_type(p) == mp_stroked_node_type) && (mp_dash_ptr(p) != NULL))) { + if (number_nonzero(*sqdet) && ((p->type == mp_stroked_node_type) && (mp_dash_ptr(p) != NULL))) { mp_number ret; new_number(ret); take_scaled(ret, ((mp_shape_node) p)->dashscale, *sqdet); @@ -16103,9 +16100,9 @@ static mp_edge_header_node mp_edges_trans (MP mp, mp_edge_header_node h) mp_set_dash_list(h, mp->null_dash); while (r != mp->null_dash) { s = r; - r = (mp_dash_node) mp_link(r); + r = (mp_dash_node) r->link; number_swap(s->start_x, s->stop_x ); - mp_link(s) = (mp_node) mp_get_dash_list(h); + s->link = (mp_node) mp_get_dash_list(h); mp_set_dash_list(h, s); } } @@ -16119,7 +16116,7 @@ static mp_edge_header_node mp_edges_trans (MP mp, mp_edge_header_node h) set_number_from_addition(r->start_x, arg1, mp->tx); take_scaled(arg1, r->stop_x, mp->txx); set_number_from_addition(r->stop_x, arg1, mp->tx); - r = (mp_dash_node) mp_link(r); + r = (mp_dash_node) r->link; } free_number(arg1); } @@ -16164,9 +16161,9 @@ static mp_edge_header_node mp_edges_trans (MP mp, mp_edge_header_node h) free_number(tot); } DONE1: - q = mp_link(mp_edge_list(h)); + q = mp_edge_list(h)->link; while (q != NULL) { - switch (mp_type(q)) { + switch (q->type) { case mp_fill_node_type: case mp_stroked_node_type: mp_do_path_trans(mp, mp_path_ptr((mp_shape_node) q)); @@ -16184,7 +16181,7 @@ static mp_edge_header_node mp_edges_trans (MP mp, mp_edge_header_node h) default: break; } - q = mp_link(q); + q = q->link; } free_number(sqdet); return h; @@ -16213,39 +16210,39 @@ static void mp_bilin1 (MP mp, mp_node p, mp_number *t, mp_node q, mp_number *u, mp_dep_mult(mp, (mp_value_node) p, t, 1); } if (number_nonzero(*u)) { - if (mp_type(q) == mp_known_type) { + if (q->type == mp_known_type) { mp_number tmp; new_number(tmp); take_scaled(tmp, mp_get_value_number(q), *u); number_add(delta, tmp); free_number(tmp); } else { - if (mp_type(p) != mp_proto_dependent_type) { - if (mp_type(p) == mp_known_type) { - mp_new_dep(mp, p, mp_type(p), mp_const_dependency(mp, &(mp_get_value_number(p)))); + if (p->type != mp_proto_dependent_type) { + if (p->type == mp_known_type) { + mp_new_dep(mp, p, p->type, mp_const_dependency(mp, &(mp_get_value_number(p)))); } else { mp_set_dep_list((mp_value_node) p, mp_p_times_v(mp, (mp_value_node) mp_get_dep_list((mp_value_node) p), &unity_t, mp_dependent_type, mp_proto_dependent_type, 1)); } - mp_type(p) = mp_proto_dependent_type; + p->type = mp_proto_dependent_type; } mp_set_dep_list((mp_value_node) p, mp_p_plus_fq(mp, (mp_value_node) mp_get_dep_list((mp_value_node) p), u, (mp_value_node) mp_get_dep_list((mp_value_node) q), - mp_proto_dependent_type, mp_type(q))); + mp_proto_dependent_type, q->type)); } } - if (mp_type(p) == mp_known_type) { + if (p->type == mp_known_type) { mp_set_value_number(p, mp_get_value_number(p)); number_add(mp_get_value_number(p), delta); } else { mp_number tmp; mp_value_node r = (mp_value_node) mp_get_dep_list((mp_value_node) p); while (mp_get_dep_info(r) != NULL) { - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; } new_number_clone(tmp, mp_get_value_number(r)); number_add(delta, tmp); @@ -16254,7 +16251,7 @@ static void mp_bilin1 (MP mp, mp_node p, mp_number *t, mp_node q, mp_number *u, mp_set_value_number(r, delta); } else { mp_recycle_value(mp, p); - mp_type(p) = mp_known_type; + p->type = mp_known_type; mp_set_value_number(p, delta); } free_number(tmp); @@ -16266,7 +16263,7 @@ static void mp_bilin1 (MP mp, mp_node p, mp_number *t, mp_node q, mp_number *u, } static void mp_add_mult_dep (MP mp, mp_value_node p, mp_number *v, mp_node r) { - if (mp_type(r) == mp_known_type) { + if (r->type == mp_known_type) { mp_number ret; new_number(ret); take_scaled(ret, mp_get_value_number(r), *v); @@ -16274,7 +16271,7 @@ static void mp_add_mult_dep (MP mp, mp_value_node p, mp_number *v, mp_node r) number_add(mp_get_dep_value(mp->dep_final), ret); free_number(ret); } else { - mp_set_dep_list(p, mp_p_plus_fq(mp, (mp_value_node) mp_get_dep_list(p), v, (mp_value_node) mp_get_dep_list((mp_value_node) r), mp_proto_dependent_type, mp_type(r))); + mp_set_dep_list(p, mp_p_plus_fq(mp, (mp_value_node) mp_get_dep_list(p), v, (mp_value_node) mp_get_dep_list((mp_value_node) r), mp_proto_dependent_type, r->type)); if (mp->fix_needed) { mp_fix_dependencies(mp); } @@ -16300,7 +16297,7 @@ static void mp_bilin2 (MP mp, mp_node p, mp_node t, mp_number *v, mp_node u, mp_ if (mp_get_dep_list((mp_value_node) p) == (mp_node) mp->dep_final) { number_clone(vv, mp_get_dep_value(mp->dep_final)); mp_recycle_value(mp, p); - mp_type(p) = mp_known_type; + p->type = mp_known_type; mp_set_value_number(p, vv); } free_number(vv); @@ -16334,13 +16331,13 @@ static void mp_bilin3 (MP mp, mp_node p, mp_number *t, mp_number *v, mp_number * static void mp_big_trans (MP mp, mp_node p, int c) { mp_node q = mp_get_value_node(p); - if (mp_type(q) == mp_pair_node_type) { - if (mp_type(mp_x_part(q)) != mp_known_type || mp_type(mp_y_part(q)) != mp_known_type) { + if (q->type == mp_pair_node_type) { + if (mp_x_part(q)->type != mp_known_type || mp_y_part(q)->type != mp_known_type) { goto UNKNOWN; } - } else if (mp_type(mp_tx_part(q)) != mp_known_type || mp_type(mp_ty_part(q)) != mp_known_type || - mp_type(mp_xx_part(q)) != mp_known_type || mp_type(mp_xy_part(q)) != mp_known_type || - mp_type(mp_yx_part(q)) != mp_known_type || mp_type(mp_yy_part(q)) != mp_known_type) { + } else if (mp_tx_part(q)->type != mp_known_type || mp_ty_part(q)->type != mp_known_type || + mp_xx_part(q)->type != mp_known_type || mp_xy_part(q)->type != mp_known_type || + mp_yx_part(q)->type != mp_known_type || mp_yy_part(q)->type != mp_known_type) { goto UNKNOWN; } { @@ -16723,7 +16720,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_print_str(mp, ")}"); mp_end_diagnostic(mp, 0); } - switch (mp_type(p)) { + switch (p->type) { case mp_transform_type: case mp_color_type: case mp_cmykcolor_type: @@ -16765,12 +16762,12 @@ static void mp_do_binary (MP mp, mp_node p, int c) switch (c) { case mp_plus_operation: case mp_minus_operation: - if ((mp->cur_exp.type < mp_color_type) || (mp_type(p) < mp_color_type)) { + if ((mp->cur_exp.type < mp_color_type) || (p->type < mp_color_type)) { mp_bad_binary(mp, p, c); } else { - if ((mp->cur_exp.type > mp_pair_type) && (mp_type(p) > mp_pair_type)) { + if ((mp->cur_exp.type > mp_pair_type) && (p->type > mp_pair_type)) { mp_add_or_subtract(mp, p, NULL, c); - } else if (mp->cur_exp.type != mp_type(p)) { + } else if (mp->cur_exp.type != p->type) { mp_bad_binary(mp, p, c); } else { @@ -16813,9 +16810,9 @@ static void mp_do_binary (MP mp, mp_node p, int c) case mp_equal_operation: case mp_unequal_operation: check_arith(); - if ((mp->cur_exp.type > mp_pair_type) && (mp_type(p) > mp_pair_type)) { + if ((mp->cur_exp.type > mp_pair_type) && (p->type > mp_pair_type)) { mp_add_or_subtract(mp, p, NULL, mp_minus_operation); - } else if (mp->cur_exp.type != mp_type(p)) { + } else if (mp->cur_exp.type != p->type) { mp_bad_binary(mp, p, (int) c); goto DONE; } else { @@ -16852,13 +16849,13 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_node rr = mp_x_part(r); part_type = mp_x_part_operation; mp_add_or_subtract(mp, mp_x_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_y_part(r); part_type = mp_y_part_operation; mp_add_or_subtract(mp, mp_y_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } } @@ -16874,19 +16871,19 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_node rr = mp_red_part(r); part_type = mp_red_part_operation; mp_add_or_subtract(mp, mp_red_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_green_part(r); part_type = mp_green_part_operation; mp_add_or_subtract(mp, mp_green_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_blue_part(r); part_type = mp_blue_part_operation; mp_add_or_subtract(mp, mp_blue_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } } @@ -16902,25 +16899,25 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_node rr = mp_cyan_part(r); part_type = mp_cyan_part_operation; mp_add_or_subtract(mp, mp_cyan_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_magenta_part(r); part_type = mp_magenta_part_operation; mp_add_or_subtract(mp, mp_magenta_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_yellow_part(r); part_type = mp_yellow_part_operation; mp_add_or_subtract(mp, mp_yellow_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_black_part(r); part_type = mp_black_part_operation; mp_add_or_subtract(mp, mp_black_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } } @@ -16936,37 +16933,37 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_node rr = mp_tx_part(r); part_type = mp_x_part_operation; mp_add_or_subtract(mp, mp_tx_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_ty_part(r); part_type = mp_y_part_operation; mp_add_or_subtract(mp, mp_ty_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_xx_part(r); part_type = mp_xx_part_operation; mp_add_or_subtract(mp, mp_xx_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_xy_part(r); part_type = mp_xy_part_operation; mp_add_or_subtract(mp, mp_xy_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_yx_part(r); part_type = mp_yx_part_operation; mp_add_or_subtract(mp, mp_yx_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_yy_part(r); part_type = mp_yy_part_operation; mp_add_or_subtract(mp, mp_yy_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } } @@ -17034,19 +17031,19 @@ static void mp_do_binary (MP mp, mp_node p, int c) break; case mp_and_operation: case mp_or_operation: - if ((mp_type(p) != mp_boolean_type) || (mp->cur_exp.type != mp_boolean_type)) { + if ((p->type != mp_boolean_type) || (mp->cur_exp.type != mp_boolean_type)) { mp_bad_binary(mp, p, (int) c); } else if (number_to_boolean(p->data.n) == c + mp_false_operation - mp_and_operation) { mp_set_cur_exp_value_boolean(mp, number_to_boolean(p->data.n)); } break; case mp_times_operation: - if ((mp->cur_exp.type < mp_color_type) || (mp_type(p) < mp_color_type)) { + if ((mp->cur_exp.type < mp_color_type) || (p->type < mp_color_type)) { mp_bad_binary(mp, p, mp_times_operation); - } else if ((mp->cur_exp.type == mp_known_type) || (mp_type(p) == mp_known_type)) { + } else if ((mp->cur_exp.type == mp_known_type) || (p->type == mp_known_type)) { mp_number vv; new_fraction(vv); - if (mp_type(p) == mp_known_type) { + if (p->type == mp_known_type) { number_clone(vv, mp_get_value_number(p)); mp_free_value_node(mp, p); } else { @@ -17093,8 +17090,8 @@ static void mp_do_binary (MP mp, mp_node p, int c) free_number(vv); mp_finish_binary(mp, old_p, old_exp); return; - } else if ((mp_nice_color_or_pair(mp, p, mp_type(p)) && (mp->cur_exp.type > mp_pair_type)) - || (mp_nice_color_or_pair(mp, cur_exp_node, mp->cur_exp.type) && (mp_type(p) > mp_pair_type))) { + } else if ((mp_nice_color_or_pair(mp, p, p->type) && (mp->cur_exp.type > mp_pair_type)) + || (mp_nice_color_or_pair(mp, cur_exp_node, mp->cur_exp.type) && (p->type > mp_pair_type))) { mp_hard_times(mp, p); mp_finish_binary(mp, old_p, old_exp); return; @@ -17103,7 +17100,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) } break; case mp_over_operation: - if ((mp->cur_exp.type != mp_known_type) || (mp_type(p) < mp_color_type)) { + if ((mp->cur_exp.type != mp_known_type) || (p->type < mp_color_type)) { mp_bad_binary(mp, p, mp_over_operation); } else { mp_number v_n; @@ -17163,7 +17160,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) } break; case mp_power_operation: - if ((mp->cur_exp.type == mp_known_type) && (mp_type(p) == mp_known_type)) { + if ((mp->cur_exp.type == mp_known_type) && (p->type == mp_known_type)) { mp_number r; new_number(r); power_of(r, mp_get_value_number(p), cur_exp_value_number); @@ -17175,7 +17172,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) break; case mp_pythag_add_operation: case mp_pythag_sub_operation: - if ((mp->cur_exp.type == mp_known_type) && (mp_type(p) == mp_known_type)) { + if ((mp->cur_exp.type == mp_known_type) && (p->type == mp_known_type)) { mp_number r; new_number(r); if (c == mp_pythag_add_operation) { @@ -17196,7 +17193,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) case mp_x_scaled_operation: case mp_y_scaled_operation: case mp_z_scaled_operation: - switch (mp_type(p)) { + switch (p->type) { case mp_path_type: mp_set_up_known_trans(mp, (int) c); mp_unstash_cur_exp(mp, p); @@ -17234,7 +17231,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) case mp_just_append_operation: case mp_tolerant_concat_operation: case mp_tolerant_append_operation: - if ((mp->cur_exp.type == mp_string_type) && (mp_type(p) == mp_string_type)) { + if ((mp->cur_exp.type == mp_string_type) && (p->type == mp_string_type)) { mp_string str = mp_cat(mp, mp_get_value_str(p), cur_exp_str); delete_str_ref(cur_exp_str) ; mp_set_cur_exp_str(mp, str); @@ -17243,7 +17240,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) } break; case mp_substring_operation: - if (mp_nice_pair(mp, p, mp_type(p)) && (mp->cur_exp.type == mp_string_type)) { + if (mp_nice_pair(mp, p, p->type) && (mp->cur_exp.type == mp_string_type)) { mp_string str = mp_chop_string (mp, cur_exp_str, round_unscaled(mp_get_value_number(mp_x_part(mp_get_value_node(p)))), @@ -17259,7 +17256,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if (mp_nice_pair(mp, p, mp_type(p)) && (mp->cur_exp.type == mp_path_type)) { + if (mp_nice_pair(mp, p, p->type) && (mp->cur_exp.type == mp_path_type)) { mp_chop_path(mp, mp_get_value_node(p)); } else { mp_bad_binary(mp, p, mp_subpath_operation); @@ -17272,14 +17269,14 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && (mp_type(p) == mp_known_type)) { + if ((mp->cur_exp.type == mp_path_type) && (p->type == mp_known_type)) { mp_find_point(mp, &(mp_get_value_number(p)), (int) c); } else { mp_bad_binary(mp, p, c); } break; case mp_pen_offset_operation: - if ((mp->cur_exp.type == mp_pen_type || mp->cur_exp.type == mp_nep_type) && mp_nice_pair(mp, p, mp_type(p))) { + if ((mp->cur_exp.type == mp_pen_type || mp->cur_exp.type == mp_nep_type) && mp_nice_pair(mp, p, p->type)) { mp_set_up_offset(mp, mp_get_value_node(p)); } else { mp_bad_binary(mp, p, mp_pen_offset_operation); @@ -17289,21 +17286,21 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && mp_nice_pair(mp, p, mp_type(p))) { + if ((mp->cur_exp.type == mp_path_type) && mp_nice_pair(mp, p, p->type)) { mp_set_up_direction_time(mp, mp_get_value_node(p)); } else { mp_bad_binary(mp, p, mp_direction_time_operation); } break; case mp_envelope_operation: - if ((mp_type(p) != mp_pen_type && mp_type(p) != mp_nep_type) || (mp->cur_exp.type != mp_path_type)) { + if ((p->type != mp_pen_type && p->type != mp_nep_type) || (mp->cur_exp.type != mp_path_type)) { mp_bad_binary(mp, p, mp_envelope_operation); } else { mp_set_up_envelope(mp, p); } break; case mp_boundingpath_operation: - if ((mp_type(p) != mp_pen_type && mp_type(p) != mp_nep_type) || (mp->cur_exp.type != mp_path_type)) { + if ((p->type != mp_pen_type && p->type != mp_nep_type) || (mp->cur_exp.type != mp_path_type)) { mp_bad_binary(mp, p, mp_boundingpath_operation); } else { mp_set_up_boundingpath(mp, p); @@ -17313,7 +17310,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && (mp_type(p) == mp_known_type)) { + if ((mp->cur_exp.type == mp_path_type) && (p->type == mp_known_type)) { memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); mp_get_arc_time(mp, &new_expr.data.n, cur_exp_knot, &(mp_get_value_number(p)), 0); @@ -17326,11 +17323,11 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && (mp_type(p) == mp_known_type || mp_type(p) == mp_pair_type)) { + if ((mp->cur_exp.type == mp_path_type) && (p->type == mp_known_type || p->type == mp_pair_type)) { mp_knot k; memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); - if (mp_type(p) == mp_pair_type) { + if (p->type == mp_pair_type) { mp_knot f = cur_exp_knot; mp_node q = mp_get_value_node(p); mp_number x; @@ -17376,7 +17373,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && mp_type(p) == mp_known_type) { + if ((mp->cur_exp.type == mp_path_type) && p->type == mp_known_type) { mp_knot cur = cur_exp_knot; mp_number len, aln, seg, tot, tim, stp, acc, tmp; @@ -17471,7 +17468,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && mp_type(p) == mp_pair_type) { + if ((mp->cur_exp.type == mp_path_type) && p->type == mp_pair_type) { memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); mp_node q = mp_get_value_node(p); @@ -17483,7 +17480,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) break; case mp_intertimes_operation: case mp_intertimes_list_operation: - if (mp_type(p) == mp_pair_type) { + if (p->type == mp_pair_type) { mp_node q = mp_stash_cur_exp(mp); mp_unstash_cur_exp(mp, p); mp_pair_to_path(mp); @@ -17493,7 +17490,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && (mp_type(p) == mp_path_type)) { + if ((mp->cur_exp.type == mp_path_type) && (p->type == mp_path_type)) { if (c == mp_intertimes_operation) { mp_path_intersection(mp, mp_get_value_knot(p), cur_exp_knot, 0, NULL); @@ -17800,7 +17797,7 @@ void mp_do_equation (MP mp) trace_equation(mp, lhs); } if (mp->cur_exp.type == mp_unknown_path_type) { - if (mp_type(lhs) == mp_pair_type) { + if (lhs->type == mp_pair_type) { mp_node p; p = mp_stash_cur_exp(mp); mp_unstash_cur_exp(mp, lhs); @@ -17910,7 +17907,7 @@ static void trace_assignment (MP mp, mp_node lhs) { mp_begin_diagnostic(mp); mp_print_nl(mp, "{"); - if (mp_name_type(lhs) == mp_internal_operation) { + if (lhs->name_type == mp_internal_operation) { mp_print_str(mp, internal_name(mp_get_sym_info(lhs))); } else { mp_show_token_list(mp, lhs, NULL); @@ -17939,7 +17936,7 @@ void mp_do_assignment (MP mp) if (number_greater(internal_value(mp_tracing_commands_internal), two_t)) { trace_assignment (mp, lhs); } - if (mp_name_type(lhs) == mp_internal_operation) { + if (lhs->name_type == mp_internal_operation) { switch (mp->cur_exp.type) { case mp_known_type: case mp_string_type: @@ -17987,7 +17984,7 @@ void mp_do_assignment (MP mp) mp_node q = mp_stash_cur_exp(mp); mp->cur_exp.type = mp_und_type(mp, p); mp_recycle_value(mp, p); - mp_type(p) = mp->cur_exp.type; + p->type = mp->cur_exp.type; mp_set_value_number(p, zero_t); mp_make_exp_copy(mp, p); p = mp_stash_cur_exp(mp); @@ -18006,7 +18003,7 @@ static void announce_bad_equation (MP mp, mp_node lhs) char msg[256]; mp_snprintf(msg, 256, "Equation cannot be performed (%s=%s)", - (mp_type(lhs) <= mp_pair_type ? mp_type_string(mp_type(lhs)) : "numeric"), + (lhs->type <= mp_pair_type ? mp_type_string(lhs->type) : "numeric"), (mp->cur_exp.type <= mp_pair_type ? mp_type_string(mp->cur_exp.type) : "numeric")); mp_disp_err(mp, lhs); mp_disp_err(mp, NULL); @@ -18068,7 +18065,7 @@ void mp_make_eq (MP mp, mp_node lhs) memset(&new_expr, 0, sizeof(mp_value)); new_number(v); RESTART: - t = mp_type(lhs); + t = lhs->type; if (t <= mp_pair_type) { number_clone(v, mp_get_value_number(lhs)); } @@ -18211,7 +18208,7 @@ void mp_try_eq (MP mp, mp_node l, mp_node r) mp_value_node pp; mp_variable_type tt; int copied; - mp_variable_type t = mp_type(l); + mp_variable_type t = l->type; switch (t) { case mp_known_type: { @@ -18242,12 +18239,12 @@ void mp_try_eq (MP mp, mp_node l, mp_node r) if (mp_get_dep_info(q) == NULL) { break; } else { - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; } } - mp_link(mp_get_prev_dep(ll)) = mp_link(q); - mp_set_prev_dep((mp_value_node) mp_link(q), mp_get_prev_dep(ll)); - mp_type(ll) = mp_known_type; + mp_get_prev_dep(ll)->link = q->link; + mp_set_prev_dep((mp_value_node) q->link, mp_get_prev_dep(ll)); + ll->type = mp_known_type; } break; } @@ -18263,11 +18260,11 @@ void mp_try_eq (MP mp, mp_node l, mp_node r) pp = (mp_value_node) mp_get_dep_list((mp_value_node) cur_exp_node); } } - } else if (mp_type(r) == mp_known_type) { + } else if (r->type == mp_known_type) { number_add(mp_get_dep_value(q), mp_get_value_number(r)); goto DONE1; } else { - tt = mp_type(r); + tt = r->type; if (tt == mp_independent_type) { pp = mp_single_dependency(mp, r); } else { @@ -18293,7 +18290,7 @@ void mp_try_eq (MP mp, mp_node l, mp_node r) number_clone(x, mp_get_dep_value(q)); fraction_to_round_scaled(x); mp_set_dep_value(q, x); - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; } free_number(x); t = mp_proto_dependent_type; @@ -18308,7 +18305,7 @@ void mp_try_eq (MP mp, mp_node l, mp_node r) deal_with_redundant_or_inconsistent_equation(mp, p, r); } else { mp_linear_eq(mp, p, (int) t); - if (r == NULL && mp->cur_exp.type != mp_known_type && mp_type(cur_exp_node) == mp_known_type) { + if (r == NULL && mp->cur_exp.type != mp_known_type && cur_exp_node->type == mp_known_type) { mp_node pp = cur_exp_node; mp_set_cur_exp_value_number(mp, &(mp_get_value_number(pp))); mp->cur_exp.type = mp_known_type; @@ -18351,10 +18348,10 @@ mp_node mp_scan_declared_variable (MP mp) } } } - mp_link(t) = mp_new_symbolic_node(mp); - t = mp_link(t); + t->link = mp_new_symbolic_node(mp); + t = t->link; mp_set_sym_sym(t, cur_sym); - mp_name_type(t) = cur_sym_mod; + t->name_type = cur_sym_mod; } if (eq_property(x) != 0) { mp_check_overload(mp, x); @@ -18389,10 +18386,10 @@ void mp_do_type_declaration (MP mp) do { mp_node p = mp_scan_declared_variable(mp); mp_node q; - mp_flush_variable(mp, equiv_node(mp_get_sym_sym(p)), mp_link(p), 0); + mp_flush_variable(mp, equiv_node(mp_get_sym_sym(p)), p->link, 0); q = mp_find_variable(mp, p); if (q != NULL) { - mp_type(q) = t; + q->type = t; mp_set_value_number(q, zero_t); } else { mp_back_error( @@ -18993,26 +18990,26 @@ void mp_do_show_stats (MP mp) void mp_disp_var (MP mp, mp_node p) { - if (mp_type(p) == mp_structured_type) { + if (p->type == mp_structured_type) { mp_node q = mp_get_attribute_head(p); do { mp_disp_var(mp, q); - q = mp_link(q); + q = q->link; } while (q != mp->end_attr); q = mp_get_subscr_head(p); - while (mp_name_type(q) == mp_subscript_operation) { + while (q->name_type == mp_subscript_operation) { mp_disp_var(mp, q); - q = mp_link(q); + q = q->link; } - } else if (mp_type(p) >= mp_unsuffixed_macro_type) { + } else if (p->type >= mp_unsuffixed_macro_type) { mp_print_nl(mp, ""); mp_print_variable_name(mp, p); - if (mp_type(p) > mp_unsuffixed_macro_type) { + if (p->type > mp_unsuffixed_macro_type) { mp_print_str(mp, "@#"); } mp_print_str(mp, "=macro:"); mp_show_macro(mp, mp_get_value_node(p), NULL); - } else if (mp_type(p) != mp_undefined_type) { + } else if (p->type != mp_undefined_type) { mp_print_nl(mp, ""); mp_print_variable_name(mp, p); mp_print_chr(mp, '='); @@ -19038,22 +19035,23 @@ void mp_do_show_var (MP mp) void mp_do_show_dependencies (MP mp) { - mp_value_node p = (mp_value_node) mp_link(mp->dep_head); + mp_value_node p = (mp_value_node) mp->dep_head->link; while (p != mp->dep_head) { if (mp_interesting(mp, (mp_node) p)) { mp_print_nl(mp, ""); mp_print_variable_name(mp, (mp_node) p); - if (mp_type(p) == mp_dependent_type) { + if (p->type == mp_dependent_type) { mp_print_chr(mp, '='); } else { mp_print_str(mp, " = "); } - mp_print_dependency(mp, (mp_value_node) mp_get_dep_list(p), mp_type(p)); + mp_print_dependency(mp, (mp_value_node) mp_get_dep_list(p), p->type); } p = (mp_value_node) mp_get_dep_list(p); - while (mp_get_dep_info(p) != NULL) - p = (mp_value_node) mp_link(p); - p = (mp_value_node) mp_link(p); + while (mp_get_dep_info(p) != NULL) { + p = (mp_value_node) p->link; + } + p = (mp_value_node) p->link; } mp_get_x_next(mp); } @@ -19356,12 +19354,12 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) if (mp_has_pen(pp)) { break; } else { - pp = mp_link(pp); + pp = pp->link; } } } if (pp != NULL) { - switch (mp_type(pp)) { + switch (pp->type) { case mp_fill_node_type: case mp_stroked_node_type: if (mp_pen_ptr((mp_shape_node) pp) != NULL) { @@ -19386,7 +19384,7 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) ap = p; } while ((ap != NULL) && (! mp_has_script(ap))) { - ap = mp_link(ap); + ap = ap->link; } if (ap != NULL) { if (mp_pre_script(ap) != NULL) { @@ -19418,7 +19416,7 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) bp = p; } while ((bp != NULL) && (! mp_has_script(bp))) { - bp = mp_link(bp); + bp = bp->link; } if (bp != NULL) { if (mp_post_script(bp) != NULL) { @@ -19545,10 +19543,10 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) if (dp == MP_VOID) { dp = p; while (dp != NULL) { - if (mp_type(dp) == mp_stroked_node_type) { + if (dp->type == mp_stroked_node_type) { break; } else { - dp = mp_link(dp); + dp = dp->link; } } } @@ -19564,7 +19562,7 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) } } if (cp > MP_VOID) { - mp_node q = mp_link(cp); + mp_node q = cp->link; while (q != NULL) { if (mp_has_color(q)) { mp_shape_node q0 = (mp_shape_node) q; @@ -19575,14 +19573,14 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) number_clone(q0->black, cp0->black); mp_color_model(q) = mp_color_model(cp); } - q = mp_link(q); + q = q->link; } } if (pp > MP_VOID) { - mp_node q = mp_link(pp); + mp_node q = pp->link; while (q != NULL) { if (mp_has_pen(q)) { - switch (mp_type(q)) { + switch (q->type) { case mp_fill_node_type: case mp_stroked_node_type: if (mp_pen_ptr((mp_shape_node) q) != NULL) { @@ -19594,13 +19592,13 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) break; } } - q = mp_link(q); + q = q->link; } } if (dp > MP_VOID) { - mp_node q = mp_link(dp); + mp_node q = dp->link; while (q != NULL) { - if (mp_type(q) == mp_stroked_node_type) { + if (q->type == mp_stroked_node_type) { if (mp_dash_ptr(q) != NULL) { mp_delete_edge_ref(mp, mp_dash_ptr(q)); } @@ -19610,13 +19608,13 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) mp_add_edge_ref(mp, mp_dash_ptr(q)); } } - q = mp_link(q); + q = q->link; } } if (linecap >= 0 && linecap < mp_weird_linecap_code) { mp_node q = p; while (q != NULL) { - switch (mp_type(q)) { + switch (q->type) { case mp_fill_node_type: case mp_stroked_node_type: mp_set_linecap(q, linecap); @@ -19624,13 +19622,13 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) default: break; } - q = mp_link(q); + q = q->link; } } if (linejoin >= 0 && linejoin < mp_weird_linejoin_code) { mp_node q = p; while (q != NULL) { - switch (mp_type(q)) { + switch (q->type) { case mp_fill_node_type: case mp_stroked_node_type: mp_set_linejoin(q, linejoin); @@ -19638,13 +19636,13 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) default: break; } - q = mp_link(q); + q = q->link; } } if (miterlimit) { mp_node q = p; while (q != NULL) { - switch (mp_type(q)) { + switch (q->type) { case mp_fill_node_type: case mp_stroked_node_type: number_clone(mp_miterlimit(q), ml); @@ -19652,15 +19650,15 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) default: break; } - q = mp_link(q); + q = q->link; } free_number(ml); } if (! pp && sp > MP_VOID) { - mp_node q = mp_link(sp); + mp_node q = sp->link; while (q != NULL) { mp_stacking(q) = mp_stacking(sp); - q = mp_link(q); + q = q->link; } } } @@ -19681,7 +19679,7 @@ mp_edge_header_node mp_find_edges_var (MP mp, mp_node t) ); mp_memory_free(msg); mp_get_x_next(mp); - } else if (mp_type(p) != mp_picture_type) { + } else if (p->type != mp_picture_type) { char msg[256]; mp_string sname; int selector = mp->selector; @@ -19689,7 +19687,7 @@ mp_edge_header_node mp_find_edges_var (MP mp, mp_node t) mp_show_token_list(mp, t, NULL); sname = mp_make_string(mp); mp->selector = selector; - mp_snprintf(msg, 256, "Variable %s is the wrong type(%s)", mp_str(mp, sname), mp_type_string(mp_type(p))); + mp_snprintf(msg, 256, "Variable %s is the wrong type(%s)", mp_str(mp, sname), mp_type_string(p->type)); delete_str_ref(sname); mp_back_error( mp, @@ -19783,12 +19781,12 @@ void mp_do_bounds (MP mp) } pp = mp_new_bounds_node(mp, NULL, mm); mp_scan_with_list(mp, p, pp); - mp_link(p) = mp_link(mp_edge_list(lhe)); - mp_link(mp_edge_list(lhe)) = p; + p->link = mp_edge_list(lhe)->link; + mp_edge_list(lhe)->link = p; if (mp_obj_tail(lhe) == mp_edge_list(lhe)) { mp_obj_tail(lhe) = p; } - mp_link(mp_obj_tail(lhe)) = pp; + mp_obj_tail(lhe)->link = pp; mp_obj_tail(lhe) = pp; mp_init_bbox(mp, lhe); } @@ -19822,7 +19820,7 @@ void mp_do_add_to (MP mp) } else { e = mp_private_edges(mp, (mp_edge_header_node) cur_exp_node); mp->cur_exp.type = mp_vacuous_type; - p = mp_link(mp_edge_list(e)); + p = mp_edge_list(e)->link; } } else { e = NULL; @@ -19870,17 +19868,17 @@ void mp_do_add_to (MP mp) } } else if (add_type == mp_add_also_code) { if (e != NULL) { - if (mp_link(mp_edge_list(e)) != NULL) { - mp_link(mp_obj_tail(lhe)) = mp_link(mp_edge_list(e)); + if (mp_edge_list(e)->link != NULL) { + mp_obj_tail(lhe)->link = mp_edge_list(e)->link; mp_obj_tail(lhe) = mp_obj_tail(e); mp_obj_tail(e) = mp_edge_list(e); - mp_link(mp_edge_list(e)) = NULL; + mp_edge_list(e)->link = NULL; mp_flush_dash_list(mp, lhe); } mp_toss_edges(mp, e); } } else if (p != NULL) { - mp_link(mp_obj_tail(lhe)) = p; + mp_obj_tail(lhe)->link = p; mp_obj_tail(lhe) = p; if (add_type == mp_add_double_path_code) { if (mp_pen_ptr((mp_shape_node) p) == NULL) { @@ -20081,10 +20079,10 @@ struct mp_edge_object *mp_gr_export (MP mp, mp_edge_header_node h) hh->height = number_to_double(internal_value(mp_char_ht_internal)); hh->depth = number_to_double(internal_value(mp_char_dp_internal)); hh->italic = number_to_double(internal_value(mp_char_ic_internal)); - p = mp_link(mp_edge_list(h)); + p = mp_edge_list(h)->link; while (p != NULL) { - mp_graphic_object *hq = mp_new_graphic_object(mp, (int) ((mp_type(p) - mp_fill_node_type) + 1)); - switch (mp_type(p)) { + mp_graphic_object *hq = mp_new_graphic_object(mp, (int) ((p->type - mp_fill_node_type) + 1)); + switch (p->type) { case mp_fill_node_type: { mp_number d_width; @@ -20175,7 +20173,7 @@ struct mp_edge_object *mp_gr_export (MP mp, mp_edge_header_node h) gr_link(hp) = hq; } hp = hq; - p = mp_link(p); + p = p->link; } return hh; } @@ -20299,15 +20297,15 @@ void mp_scan_symbol_value (MP mp, int keep, char **s, int expand) unsigned char *r = NULL; mp_node p = mp_new_symbolic_node(mp); mp_set_sym_sym(p, cur_sym); - mp_name_type(p) = cur_sym_mod; - if (mp_type(p) == mp_symbol_node_type) { + p->name_type = cur_sym_mod; + if (p->type == mp_symbol_node_type) { mp_sym sr = mp_get_sym_sym(p); mp_string rr = text(sr); if (rr && rr->str) { r = rr->str; } - } else if (mp_name_type(p) == mp_token_operation) { - if (mp_type(p) == mp_string_type) { + } else if (p->name_type == mp_token_operation) { + if (p->type == mp_string_type) { r = mp_get_value_str(p)->str; } } @@ -20420,7 +20418,7 @@ void mp_scan_numeric_value (MP mp, int primary, double *d) } # define mp_set_double_value(mp,target,what) \ -if (mp_type(what) == mp_known_type) { \ +if (what->type == mp_known_type) { \ *target = number_to_double(mp_get_value_number(what)); \ } @@ -20579,13 +20577,13 @@ void mp_push_pair_value (MP mp, double x, double y) v = mp_get_value_node(p); new_number_from_double(mp, px, x); new_number_from_double(mp, py, y); - mp_type(mp_x_part(v)) = mp_known_type; - mp_type(mp_y_part(v)) = mp_known_type; + mp_x_part(v)->type = mp_known_type; + mp_y_part(v)->type = mp_known_type; mp_set_value_number(mp_x_part(v), px); mp_set_value_number(mp_y_part(v), py); free_number(px); free_number(py); - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp->cur_exp.type = mp_pair_type; mp_set_cur_exp_node(mp, p); mp_back_expr(mp); @@ -20601,16 +20599,16 @@ void mp_push_color_value (MP mp, double r, double g, double b) new_number_from_double(mp, pr, r); new_number_from_double(mp, pg, g); new_number_from_double(mp, pb, b); - mp_type(mp_red_part (v)) = mp_known_type; - mp_type(mp_green_part(v)) = mp_known_type; - mp_type(mp_blue_part (v)) = mp_known_type; + mp_red_part (v)->type = mp_known_type; + mp_green_part(v)->type = mp_known_type; + mp_blue_part (v)->type = mp_known_type; mp_set_value_number(mp_red_part (v), pr); mp_set_value_number(mp_green_part(v), pg); mp_set_value_number(mp_blue_part (v), pb); free_number(pr); free_number(pg); free_number(pb); - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp->cur_exp.type = mp_color_type; mp_set_cur_exp_node(mp, p); mp_back_expr(mp); @@ -20627,10 +20625,10 @@ void mp_push_cmykcolor_value (MP mp, double c, double m, double y, double k) new_number_from_double(mp, pm, m); new_number_from_double(mp, py, y); new_number_from_double(mp, pk, k); - mp_type(mp_cyan_part (v)) = mp_known_type; - mp_type(mp_magenta_part(v)) = mp_known_type; - mp_type(mp_yellow_part (v)) = mp_known_type; - mp_type(mp_black_part (v)) = mp_known_type; + mp_cyan_part (v)->type = mp_known_type; + mp_magenta_part(v)->type = mp_known_type; + mp_yellow_part (v)->type = mp_known_type; + mp_black_part (v)->type = mp_known_type; mp_set_value_number(mp_cyan_part (v), pc); mp_set_value_number(mp_magenta_part(v), pm); mp_set_value_number(mp_yellow_part (v), py); @@ -20639,7 +20637,7 @@ void mp_push_cmykcolor_value (MP mp, double c, double m, double y, double k) free_number(pm); free_number(py); free_number(pk); - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp->cur_exp.type = mp_cmykcolor_type; mp_set_cur_exp_node(mp, p); mp_back_expr(mp); @@ -20658,12 +20656,12 @@ void mp_push_transform_value (MP mp, double x, double y, double xx, double xy, d new_number_from_double(mp, pxy, xy); new_number_from_double(mp, pyx, yx); new_number_from_double(mp, pyy, yy); - mp_type(mp_x_part (v)) = mp_known_type; - mp_type(mp_y_part (v)) = mp_known_type; - mp_type(mp_xx_part(v)) = mp_known_type; - mp_type(mp_xy_part(v)) = mp_known_type; - mp_type(mp_yx_part(v)) = mp_known_type; - mp_type(mp_yy_part(v)) = mp_known_type; + mp_x_part (v)->type = mp_known_type; + mp_y_part (v)->type = mp_known_type; + mp_xx_part(v)->type = mp_known_type; + mp_xy_part(v)->type = mp_known_type; + mp_yx_part(v)->type = mp_known_type; + mp_yy_part(v)->type = mp_known_type; mp_set_value_number(mp_x_part (v), px); mp_set_value_number(mp_y_part (v), py); mp_set_value_number(mp_xx_part(v), pxx); @@ -20676,7 +20674,7 @@ void mp_push_transform_value (MP mp, double x, double y, double xx, double xy, d free_number(pxy); free_number(pyx); free_number(pyy); - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp->cur_exp.type = mp_transform_type; mp_set_cur_exp_node(mp, p); mp_back_expr(mp); @@ -20723,7 +20721,7 @@ void mp_scan_primary (MP mp) mp_node q = mp_new_value_node(mp); mp_node p1 = mp_stash_cur_exp(mp); mp_node r; - mp_name_type(q) = mp_capsule_operation; + q->name_type = mp_capsule_operation; mp_get_x_next(mp); mp_scan_expression(mp); if (mp->cur_exp.type < mp_known_type) { @@ -20806,7 +20804,7 @@ void mp_scan_primary (MP mp) } } mp_check_delimiter(mp, l_delim, r_delim); - mp->cur_exp.type = mp_type(q); + mp->cur_exp.type = q->type; mp_set_cur_exp_node(mp, q); } else { mp_check_delimiter(mp, l_delim, r_delim); @@ -20977,7 +20975,7 @@ void mp_scan_primary (MP mp) if (cur_cmd == mp_assignment_command) { mp_set_cur_exp_node(mp, mp_new_symbolic_node(mp)); mp_set_sym_info(cur_exp_node, qq); - mp_name_type(cur_exp_node) = mp_internal_operation; + cur_exp_node->name_type = mp_internal_operation; mp->cur_exp.type = mp_token_list_type; goto DONE; } @@ -21006,10 +21004,10 @@ void mp_scan_primary (MP mp) mp_node post_head = NULL; while (1) { t = mp_cur_tok(mp); - mp_link(tail) = t; + tail->link = t; if (tt != mp_undefined_type) { mp_sym qq; - p = mp_link(pre_head); + p = pre_head->link; qq = mp_get_sym_sym(p); tt = mp_undefined_type; @@ -21019,18 +21017,18 @@ void mp_scan_primary (MP mp) goto DONE2; } while (1) { - p = mp_link(p); + p = p->link; if (p == NULL) { - tt = mp_type(q); + tt = q->type; goto DONE2; } - if (mp_type(q) != mp_structured_type) { + if (q->type != mp_structured_type) { goto DONE2; } - q = mp_link(mp_get_attribute_head(q)); - if (mp_type(p) == mp_symbol_node_type) { + q = mp_get_attribute_head(q)->link; + if (p->type == mp_symbol_node_type) { do { - q = mp_link(q); + q = q->link; } while (! (mp_get_hashloc(q) >= mp_get_sym_sym(p))); if (mp_get_hashloc(q) > mp_get_sym_sym(p)) { goto DONE2; @@ -21040,18 +21038,18 @@ void mp_scan_primary (MP mp) } DONE2: if (tt >= mp_unsuffixed_macro_type) { - mp_link(tail) = NULL; + tail->link = NULL; if (tt > mp_unsuffixed_macro_type) { post_head = mp_new_symbolic_node(mp); tail = post_head; - mp_link(tail) = t; + tail->link = t; tt = mp_undefined_type; macro_ref = mp_get_value_node(q); mp_add_mac_ref(macro_ref); } else { p = mp_new_symbolic_node(mp); - mp_set_sym_sym(pre_head, mp_link(pre_head)); - mp_link(pre_head) = p; + mp_set_sym_sym(pre_head, pre_head->link); + pre_head->link = p; mp_set_sym_sym(p, t); mp_macro_call(mp, mp_get_value_node(q), pre_head, NULL); mp_get_x_next(mp); @@ -21088,19 +21086,19 @@ void mp_scan_primary (MP mp) if (post_head != NULL) { mp_back_input(mp); p = mp_new_symbolic_node(mp); - q = mp_link(post_head); - mp_set_sym_sym(pre_head, mp_link(pre_head)); - mp_link(pre_head) = post_head; + q = post_head->link; + mp_set_sym_sym(pre_head, pre_head->link); + pre_head->link = post_head; mp_set_sym_sym(post_head, q); - mp_link(post_head) = p; - mp_set_sym_sym(p, mp_link(q)); - mp_link(q) = NULL; + post_head->link = p; + mp_set_sym_sym(p, q->link); + q->link = NULL; mp_macro_call(mp, macro_ref, pre_head, NULL); mp_decr_mac_ref(macro_ref); mp_get_x_next(mp); goto RESTART; } - q = mp_link(pre_head); + q = pre_head->link; mp_free_symbolic_node(mp, pre_head); if (cur_cmd == my_var_flag) { mp->cur_exp.type = mp_token_list_type; @@ -21205,15 +21203,15 @@ static void mp_scan_suffix (MP mp) } else if ((cur_cmd == mp_tag_command) || (cur_cmd == mp_internal_command)) { p = mp_new_symbolic_node(mp); mp_set_sym_sym(p, cur_sym); - mp_name_type(p) = cur_sym_mod; + p->name_type = cur_sym_mod; } else { break; } - mp_link(t) = p; + t->link = p; t = p; mp_get_x_next(mp); } - mp_set_cur_exp_node(mp, mp_link(h)); + mp_set_cur_exp_node(mp, h->link); mp_free_symbolic_node(mp, h); mp->cur_exp.type = mp_token_list_type; } @@ -21308,7 +21306,7 @@ static void mp_scan_expression (MP mp) mac_name = cur_sym; mp_add_mac_ref(cc); } - if ((d < mp_ampersand_command) || ((d == mp_ampersand_command) && ((mp_type(p) == mp_pair_type) || (mp_type(p) == mp_path_type)))) { + if ((d < mp_ampersand_command) || ((d == mp_ampersand_command) && ((p->type == mp_pair_type) || (p->type == mp_path_type)))) { mp_unstash_cur_exp(mp, p); if (! mp_scan_path(mp)) { mp->expand_depth_count--; @@ -21704,8 +21702,8 @@ void mp_final_cleanup (MP mp) } mp_print_str(mp, " was incomplete)"); mp->if_line = mp_if_line_field(mp->cond_ptr); - mp->cur_if = mp_name_type(mp->cond_ptr); - mp->cond_ptr = mp_link(mp->cond_ptr); + mp->cur_if = mp->cond_ptr->name_type; + mp->cond_ptr = mp->cond_ptr->link; } if (mp->history != mp_spotless) { if (((mp->history == mp_warning_issued) || (mp->interaction < mp_error_stop_mode))) { @@ -22098,7 +22096,7 @@ void mp_final_cleanup (MP mp) mp_set_dep_list(mp->dep_head, NULL); mp->cur_mod_ = mp_new_symbolic_node(mp); mp->bad_vardef = mp_new_value_node(mp); - mp_name_type(mp->bad_vardef) = mp_root_operation; + mp->bad_vardef->name_type = mp_root_operation; mp_set_value_sym(mp->bad_vardef, mp->frozen_bad_vardef); mp->frozen_repeat_loop = @@ -22107,7 +22105,7 @@ void mp_final_cleanup (MP mp) new_number(mp->max_c[i]); } mp->temp_val = mp_new_value_node(mp); - mp_name_type(mp->temp_val) = mp_capsule_operation; + mp->temp_val->name_type = mp_capsule_operation; new_number(mp->txx); new_number(mp->txy); new_number(mp->tyx); diff --git a/source/luametatex/source/mp/mpc/mpmath.c b/source/luametatex/source/mp/mpc/mpmath.c index 42a596dac..0a848b23e 100644 --- a/source/luametatex/source/mp/mpc/mpmath.c +++ b/source/luametatex/source/mp/mpc/mpmath.c @@ -585,9 +585,9 @@ int mp_number_nonequalabs(mp_number *A, mp_number *B) static char *mp_string_scaled (MP mp, int s) { - (void) mp; static char scaled_string[32]; int i = 0; + (void) mp; if (s < 0) { scaled_string[i++] = '-'; s = -s; diff --git a/source/luametatex/source/mp/mpc/mpmathdecimal.c b/source/luametatex/source/mp/mpc/mpmathdecimal.c index 5ffa1e04f..268217f3e 100644 --- a/source/luametatex/source/mp/mpc/mpmathdecimal.c +++ b/source/luametatex/source/mp/mpc/mpmathdecimal.c @@ -766,18 +766,18 @@ void mp_number_scaled_to_angle(mp_number *A) int mp_number_to_scaled(mp_number *A) { - int32_t result; + int result; decNumber corrected; decNumberFromInt32(&corrected, 65536); decNumberMultiply(&corrected, &corrected, A->data.num, &mp_decimal_data.set); decNumberReduce(&corrected, &corrected, &mp_decimal_data.set); - result = (int) floor(decNumberToDouble(&corrected) + 0.5); + result = lround(decNumberToDouble(&corrected)); return result; } int mp_number_to_int(mp_number *A) { - int32_t result; + int result; mp_decimal_data.set.status = 0; result = decNumberToInt32(A->data.num, &mp_decimal_data.set); if (mp_decimal_data.set.status == DEC_Invalid_operation) { @@ -790,7 +790,7 @@ int mp_number_to_int(mp_number *A) int mp_number_to_boolean(mp_number *A) { - uint32_t result; + unsigned int result; mp_decimal_data.set.status = 0; result = decNumberToUInt32(A->data.num, &mp_decimal_data.set); if (mp_decimal_data.set.status == DEC_Invalid_operation) { @@ -1413,7 +1413,7 @@ typedef struct mp_decimal_random_info { long *ptr; } mp_decimal_random_info; -mp_decimal_random_info mp_decimal_random_data = { +static mp_decimal_random_info mp_decimal_random_data = { .dummy = -1, .started = -1, .ptr = &mp_decimal_random_data.dummy diff --git a/source/luametatex/source/mp/mpc/mpmathdouble.c b/source/luametatex/source/mp/mpc/mpmathdouble.c index 99be94727..8349a3b66 100644 --- a/source/luametatex/source/mp/mpc/mpmathdouble.c +++ b/source/luametatex/source/mp/mpc/mpmathdouble.c @@ -960,7 +960,7 @@ typedef struct mp_double_random_info { long *ptr; } mp_double_random_info; -mp_double_random_info mp_double_random_data = { +static mp_double_random_info mp_double_random_data = { .dummy = -1, .started = -1, .ptr = &mp_double_random_data.dummy diff --git a/source/luametatex/source/mp/mpc/mpstrings.c b/source/luametatex/source/mp/mpc/mpstrings.c index 593985a68..ceeccb127 100644 --- a/source/luametatex/source/mp/mpc/mpstrings.c +++ b/source/luametatex/source/mp/mpc/mpstrings.c @@ -277,7 +277,7 @@ mp_string mp_chop_string(MP mp, mp_string s, int a, int b) a = l; } } - mp_str_room(mp, (size_t) (b - a)); + mp_str_room(mp, (b - a)); if (reversed) { for (int k = b - 1; k >= a; k--) { mp_append_char(mp, *(s->str + k)); diff --git a/source/luametatex/source/mp/mpw/mp.w b/source/luametatex/source/mp/mpw/mp.w index a7a1a9b7d..fe47d3d82 100644 --- a/source/luametatex/source/mp/mpw/mp.w +++ b/source/luametatex/source/mp/mpw/mp.w @@ -2109,7 +2109,7 @@ static void mp_free_node (MP mp, mp_node p, size_t siz) There was a quite large |switch| here first, but the |mp_dash_node| case was the only one that did anything ... */ - if (mp_type(p) == mp_dash_node_type) { + if (p->type == mp_dash_node_type) { free_number(((mp_dash_node) p)->start_x); free_number(((mp_dash_node) p)->stop_x); free_number(((mp_dash_node) p)->dash_y); @@ -3866,8 +3866,8 @@ static void mp_flush_token_list (MP mp, mp_node p) { while (p != NULL) { mp_node q = p; /* the node being recycled */ - p = mp_link(p); - switch (mp_type(q)) { + p = p->link; + switch (q->type) { case mp_symbol_node_type: mp_free_symbolic_node(mp, q); continue; @@ -3933,9 +3933,9 @@ void mp_show_token_list (MP mp, mp_node p, mp_node q) (void) q; while (p != NULL) { int c = mp_letter_class; - if (mp_type(p) != mp_symbol_node_type) { - if (mp_name_type(p) == mp_token_operation) { - if (mp_type(p) == mp_known_type) { + if (p->type != mp_symbol_node_type) { + if (p->name_type == mp_token_operation) { + if (p->type == mp_known_type) { if (cclass == mp_digit_class) { mp_print_chr(mp, ' '); } @@ -3951,7 +3951,7 @@ void mp_show_token_list (MP mp, mp_node p, mp_node q) print_number(mp_get_value_number(p)); c = mp_digit_class; } - } else if (mp_type(p) == mp_string_type) { + } else if (p->type == mp_string_type) { mp_print_chr(mp, '"'); mp_print_mp_str(mp, mp_get_value_str(p)); mp_print_chr(mp, '"'); @@ -3959,17 +3959,17 @@ void mp_show_token_list (MP mp, mp_node p, mp_node q) } else { mp_print_str(mp, " BAD"); } - } else if ((mp_name_type(p) != mp_capsule_operation) || (mp_type(p) < mp_vacuous_type) || (mp_type(p) > mp_independent_type)) { + } else if ((p->name_type != mp_capsule_operation) || (p->type < mp_vacuous_type) || (p->type > mp_independent_type)) { mp_print_str(mp, " BAD"); } else { mp_print_capsule(mp, p); c = mp_right_parenthesis_class; } - } else if (mp_name_type(p) == mp_expr_operation || mp_name_type(p) == mp_suffix_operation || mp_name_type(p) == mp_text_operation) { + } else if (p->name_type == mp_expr_operation || p->name_type == mp_suffix_operation || p->name_type == mp_text_operation) { int r = mp_get_sym_info(p); - if (mp_name_type(p) == mp_expr_operation) { + if (p->name_type == mp_expr_operation) { mp_print_str(mp, "(EXPR"); - } else if (mp_name_type(p) == mp_suffix_operation) { + } else if (p->name_type == mp_suffix_operation) { mp_print_str(mp, "(SUFFIX"); } else { mp_print_str(mp, "(TEXT"); @@ -4011,7 +4011,7 @@ void mp_show_token_list (MP mp, mp_node p, mp_node q) } } cclass = c; - p = mp_link(p); + p = p->link; } return; } @@ -4020,9 +4020,9 @@ void mp_show_token_list_space (MP mp, mp_node p, mp_node q) { (void) q; while (p != NULL) { - if (mp_type(p) != mp_symbol_node_type) { - if (mp_name_type(p) == mp_token_operation) { - if (mp_type(p) == mp_known_type) { + if (p->type != mp_symbol_node_type) { + if (p->name_type == mp_token_operation) { + if (p->type == mp_known_type) { if (number_negative(mp_get_value_number(p))) { mp_print_str(mp, "[ "); print_number(mp_get_value_number(p)); @@ -4030,23 +4030,23 @@ void mp_show_token_list_space (MP mp, mp_node p, mp_node q) } else { print_number(mp_get_value_number(p)); } - } else if (mp_type(p) == mp_string_type) { + } else if (p->type == mp_string_type) { mp_print_chr(mp, '"'); mp_print_mp_str(mp, mp_get_value_str(p)); mp_print_chr(mp, '"'); } else { mp_print_str(mp, "BAD"); } - } else if ((mp_name_type(p) != mp_capsule_operation) || (mp_type(p) < mp_vacuous_type) || (mp_type(p) > mp_independent_type)) { + } else if ((p->name_type != mp_capsule_operation) || (p->type < mp_vacuous_type) || (p->type > mp_independent_type)) { mp_print_str(mp, "BAD"); } else { mp_print_capsule(mp, p); } - } else if (mp_name_type(p) == mp_expr_operation || mp_name_type(p) == mp_suffix_operation || mp_name_type(p) == mp_text_operation) { + } else if (p->name_type == mp_expr_operation || p->name_type == mp_suffix_operation || p->name_type == mp_text_operation) { int r = mp_get_sym_info(p); - if (mp_name_type(p) == mp_expr_operation) { + if (p->name_type == mp_expr_operation) { mp_print_str(mp, "(EXPR "); - } else if (mp_name_type(p) == mp_suffix_operation) { + } else if (p->name_type == mp_suffix_operation) { mp_print_str(mp, "(SUFFIX "); } else { mp_print_str(mp, "(TEXT "); @@ -4066,7 +4066,7 @@ void mp_show_token_list_space (MP mp, mp_node p, mp_node q) } } } - p = mp_link(p); + p = p->link; if (p) { mp_print_chr(mp, ' '); } @@ -4136,12 +4136,12 @@ count. @c static void mp_show_macro (MP mp, mp_node p, mp_node q) { - p = mp_link(p); /* bypass the reference count */ - while (mp_name_type(p) != mp_macro_operation) { - mp_node r = mp_link(p); - mp_link(p) = NULL; + p = p->link; /* bypass the reference count */ + while (p->name_type != mp_macro_operation) { + mp_node r = p->link; + p->link = NULL; mp_show_token_list(mp, p, NULL); - mp_link(p) = r; + p->link = r; p = r; } switch (mp_get_sym_info(p)) { @@ -4169,7 +4169,7 @@ static void mp_show_macro (MP mp, mp_node p, mp_node q) mp_print_str(mp, "<text> -> "); break; } - mp_show_token_list(mp, mp_link(p), q); + mp_show_token_list(mp, p->link, q); } @* Data structures for variables. @@ -4295,7 +4295,7 @@ static mp_node mp_new_value_node (MP mp) new_number(p->subscript); p->hasnumber = 2; } - mp_type(p) = mp_value_node_type; + p->type = mp_value_node_type; return (mp_node) p; } @@ -4396,7 +4396,7 @@ subscript attributes. static mp_value_node mp_get_attribute_node (MP mp) { mp_value_node p = (mp_value_node) mp_new_value_node(mp); - mp_type(p) = mp_attribute_node_type; + p->type = mp_attribute_node_type; return p; } @@ -4421,7 +4421,7 @@ mp_free_value_node(mp, mp->end_attr); static mp_value_node mp_get_subscr_node (MP mp) { mp_value_node p = (mp_value_node) mp_new_value_node(mp); - mp_type(p) = mp_subscript_node_type; + p->type = mp_subscript_node_type; return p; } @@ -4460,7 +4460,7 @@ static mp_node mp_get_pair_node (MP mp) } else { p = mp_allocate_node(mp, sizeof(mp_pair_node_data)); } - mp_type(p) = mp_pair_node_type; + p->type = mp_pair_node_type; return (mp_node) p; } @@ -4487,16 +4487,16 @@ such nodes are initially of type |mp_independent|. static void mp_init_pair_node (MP mp, mp_node p) { mp_node q; /* the new node */ - mp_type(p) = mp_pair_type; + p->type = mp_pair_type; q = mp_get_pair_node(mp); mp_y_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_y_part(q)); /* sets |type(q)| and |value(q)| */ - mp_name_type(mp_y_part(q)) = mp_y_part_operation; - mp_link(mp_y_part(q)) = p; + mp_y_part(q)->name_type = mp_y_part_operation; + mp_y_part(q)->link = p; mp_x_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_x_part(q)); /* sets |type(q)| and |value(q)| */ - mp_name_type(mp_x_part(q)) = mp_x_part_operation; - mp_link(mp_x_part(q)) = p; + mp_x_part(q)->name_type = mp_x_part_operation; + mp_x_part(q)->link = p; mp_set_value_node(p, q); } @@ -4534,7 +4534,7 @@ typedef struct mp_transform_node_data *mp_transform_node; static mp_node mp_get_transform_node (MP mp) { mp_transform_node p = (mp_transform_node) mp_allocate_node(mp, sizeof(mp_transform_node_data)); - mp_type(p) = mp_transform_node_type; + p->type = mp_transform_node_type; return (mp_node) p; } @@ -4542,32 +4542,32 @@ static mp_node mp_get_transform_node (MP mp) static void mp_init_transform_node (MP mp, mp_node p) { mp_node q; /* the new node */ - mp_type(p) = mp_transform_type; + p->type = mp_transform_type; q = mp_get_transform_node(mp); /* big node */ mp_yy_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_yy_part(q)); /* sets |type(q)| and |value(q)| */ - mp_name_type(mp_yy_part(q)) = mp_yy_part_operation; - mp_link(mp_yy_part(q)) = p; + mp_yy_part(q)->name_type = mp_yy_part_operation; + mp_yy_part(q)->link = p; mp_yx_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_yx_part(q)); /* sets |type(q)| and |value(q)| */ - mp_name_type(mp_yx_part(q)) = mp_yx_part_operation; - mp_link(mp_yx_part(q)) = p; + mp_yx_part(q)->name_type = mp_yx_part_operation; + mp_yx_part(q)->link = p; mp_xy_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_xy_part(q)); /* sets |type(q)| and |value(q)| */ - mp_name_type(mp_xy_part(q)) = mp_xy_part_operation; - mp_link(mp_xy_part(q)) = p; + mp_xy_part(q)->name_type = mp_xy_part_operation; + mp_xy_part(q)->link = p; mp_xx_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_xx_part(q)); /* sets |type(q)| and |value(q)| */ - mp_name_type(mp_xx_part(q)) = mp_xx_part_operation; - mp_link(mp_xx_part(q)) = p; + mp_xx_part(q)->name_type = mp_xx_part_operation; + mp_xx_part(q)->link = p; mp_ty_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_ty_part(q)); /* sets |type(q)| and |value(q)| */ - mp_name_type(mp_ty_part(q)) = mp_y_part_operation; - mp_link(mp_ty_part(q)) = p; + mp_ty_part(q)->name_type = mp_y_part_operation; + mp_ty_part(q)->link = p; mp_tx_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_tx_part(q)); /* sets |type(q)| and |value(q)| */ - mp_name_type(mp_tx_part(q)) = mp_x_part_operation; - mp_link(mp_tx_part(q)) = p; + mp_tx_part(q)->name_type = mp_x_part_operation; + mp_tx_part(q)->link = p; mp_set_value_node(p, q); } @@ -4615,49 +4615,48 @@ typedef struct mp_color_node_data *mp_color_node; static void mp_init_color_node (MP mp, mp_node p, int type) { mp_node q = (mp_node) mp_allocate_node(mp, sizeof(mp_color_node_data)); - q->link = NULL; - mp_type(p) = type; + p->type = type; switch (type) { case mp_color_type: - mp_type(q) = mp_color_node_type; + q->type = mp_color_node_type; /* */ mp_red_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_red_part(q)); - mp_name_type(mp_red_part(q)) = mp_red_part_operation; - mp_link(mp_red_part(q)) = p; + mp_red_part(q)->name_type = mp_red_part_operation; + mp_red_part(q)->link = p; /* */ mp_green_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_green_part(q)); - mp_name_type(mp_green_part(q)) = mp_green_part_operation; - mp_link(mp_green_part(q)) = p; + mp_green_part(q)->name_type = mp_green_part_operation; + mp_green_part(q)->link = p; /* */ mp_blue_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_blue_part(q)); - mp_name_type(mp_blue_part(q)) = mp_blue_part_operation; - mp_link(mp_blue_part(q)) = p; + mp_blue_part(q)->name_type = mp_blue_part_operation; + mp_blue_part(q)->link = p; break; case mp_cmykcolor_type: - mp_type(q) = mp_cmykcolor_node_type; + q->type = mp_cmykcolor_node_type; /* */ mp_cyan_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_cyan_part(q)); - mp_name_type(mp_cyan_part(q)) = mp_cyan_part_operation; - mp_link(mp_cyan_part(q)) = p; + mp_cyan_part(q)->name_type = mp_cyan_part_operation; + mp_cyan_part(q)->link = p; /* */ mp_magenta_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_magenta_part(q)); - mp_name_type(mp_magenta_part(q)) = mp_magenta_part_operation; - mp_link(mp_magenta_part(q)) = p; + mp_magenta_part(q)->name_type = mp_magenta_part_operation; + mp_magenta_part(q)->link = p; /* */ mp_yellow_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_yellow_part(q)); - mp_name_type(mp_yellow_part(q)) = mp_yellow_part_operation; - mp_link(mp_yellow_part(q)) = p; + mp_yellow_part(q)->name_type = mp_yellow_part_operation; + mp_yellow_part(q)->link = p; /* */ mp_black_part(q) = mp_new_value_node(mp); mp_new_indep(mp, mp_black_part(q)); - mp_name_type(mp_black_part(q)) = mp_black_part_operation; - mp_link(mp_black_part(q)) = p; + mp_black_part(q)->name_type = mp_black_part_operation; + mp_black_part(q)->link = p; break; } mp_set_value_node(p, q); @@ -4675,21 +4674,21 @@ static mp_node mp_id_transform (MP mp) { mp_node q; mp_node p = mp_new_value_node(mp); - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp_set_value_number(p, zero_t); /* todo: this was |null| */ mp_init_transform_node(mp, p); q = mp_get_value_node(p); - mp_type(mp_tx_part(q)) = mp_known_type; + mp_tx_part(q)->type = mp_known_type; mp_set_value_number(mp_tx_part(q), zero_t); - mp_type(mp_ty_part(q)) = mp_known_type; + mp_ty_part(q)->type = mp_known_type; mp_set_value_number(mp_ty_part(q), zero_t); - mp_type(mp_xy_part(q)) = mp_known_type; + mp_xy_part(q)->type = mp_known_type; mp_set_value_number(mp_xy_part(q), zero_t); - mp_type(mp_yx_part(q)) = mp_known_type; + mp_yx_part(q)->type = mp_known_type; mp_set_value_number(mp_yx_part(q), zero_t); - mp_type(mp_xx_part(q)) = mp_known_type; + mp_xx_part(q)->type = mp_known_type; mp_set_value_number(mp_xx_part(q), unity_t); - mp_type(mp_yy_part(q)) = mp_known_type; + mp_yy_part(q)->type = mp_known_type; mp_set_value_number(mp_yy_part(q), unity_t); return p; } @@ -4702,8 +4701,8 @@ establishes the root node on such grand occasions. static void mp_new_root (MP mp, mp_sym x) { mp_node p = mp_new_value_node(mp); - mp_type(p) = mp_undefined_type; - mp_name_type(p) = mp_root_operation; + p->type = mp_undefined_type; + p->name_type = mp_root_operation; mp_set_value_sym(p, x); set_equiv_node(x, p); } @@ -4720,8 +4719,8 @@ void mp_print_variable_name (MP mp, mp_node p) { mp_node q = NULL; /* a token list that will name the variable's suffix */ mp_node r = NULL; /* temporary for token list creation */ - while (mp_name_type(p) >= mp_x_part_operation) { - switch (mp_name_type(p)) { + while (p->name_type >= mp_x_part_operation) { + switch (p->name_type) { case mp_x_part_operation : mp_print_str(mp, "xpart "); break; case mp_y_part_operation : mp_print_str(mp, "ypart "); break; case mp_xx_part_operation : mp_print_str(mp, "xxpart "); break; @@ -4739,22 +4738,22 @@ void mp_print_variable_name (MP mp, mp_node p) case mp_capsule_operation : mp_print_fmt(mp, "%%CAPSULE%p", p); return; default : break; } - p = mp_link(p); + p = p->link; } - while (mp_name_type(p) > mp_saved_root_operation) { + while (p->name_type > mp_saved_root_operation) { /* Ascend one level, pushing a token onto list |q| and replacing |p| by its parent */ - if (mp_name_type(p) == mp_subscript_operation) { + if (p->name_type == mp_subscript_operation) { r = mp_new_num_tok(mp, &(mp_subscript(p))); do { - p = mp_link(p); - } while (mp_name_type(p) != mp_attribute_operation); - } else if (mp_name_type(p) == mp_structured_root_operation) { - p = mp_link(p); + p = p->link; + } while (p->name_type != mp_attribute_operation); + } else if (p->name_type == mp_structured_root_operation) { + p = p->link; goto FOUND; - } else if (mp_name_type(p) != mp_attribute_operation) { + } else if (p->name_type != mp_attribute_operation) { mp_confusion(mp, "variable"); } else { r = mp_new_symbolic_node(mp); @@ -4774,8 +4773,8 @@ void mp_print_variable_name (MP mp, mp_node p) */ r = mp_new_symbolic_node(mp); mp_set_sym_sym(r, mp_get_value_sym(p)); - mp_link(r) = q; - if (mp_name_type(p) == mp_saved_root_operation) { + r->link = q; + if (p->name_type == mp_saved_root_operation) { mp_print_str(mp, "(SAVED)"); } mp_show_token_list(mp, r, NULL); @@ -4791,25 +4790,25 @@ static int mp_interesting (MP mp, mp_node p) if (number_positive(internal_value(mp_tracing_capsules_internal))) { return 1; } else { - mp_name_type_type t = mp_name_type(p); + mp_name_type_type t = p->name_type; if (t >= mp_x_part_operation && t != mp_capsule_operation) { - mp_node tt = mp_get_value_node(mp_link(p)); + mp_node tt = mp_get_value_node(p->link); switch (t) { - case mp_x_part_operation: t = mp_name_type(mp_x_part (tt)); break; - case mp_y_part_operation: t = mp_name_type(mp_y_part (tt)); break; - case mp_xx_part_operation: t = mp_name_type(mp_xx_part (tt)); break; - case mp_xy_part_operation: t = mp_name_type(mp_xy_part (tt)); break; - case mp_yx_part_operation: t = mp_name_type(mp_yx_part (tt)); break; - case mp_yy_part_operation: t = mp_name_type(mp_yy_part (tt)); break; - case mp_red_part_operation: t = mp_name_type(mp_red_part (tt)); break; - case mp_green_part_operation: t = mp_name_type(mp_green_part (tt)); break; - case mp_blue_part_operation: t = mp_name_type(mp_blue_part (tt)); break; - case mp_cyan_part_operation: t = mp_name_type(mp_cyan_part (tt)); break; - case mp_magenta_part_operation: t = mp_name_type(mp_magenta_part(tt)); break; - case mp_yellow_part_operation: t = mp_name_type(mp_yellow_part (tt)); break; - case mp_black_part_operation: t = mp_name_type(mp_black_part (tt)); break; - case mp_grey_part_operation: t = mp_name_type(mp_grey_part (tt)); break; - default: break; + case mp_x_part_operation: t = mp_x_part (tt)->name_type; break; + case mp_y_part_operation: t = mp_y_part (tt)->name_type; break; + case mp_xx_part_operation: t = mp_xx_part (tt)->name_type; break; + case mp_xy_part_operation: t = mp_xy_part (tt)->name_type; break; + case mp_yx_part_operation: t = mp_yx_part (tt)->name_type; break; + case mp_yy_part_operation: t = mp_yy_part (tt)->name_type; break; + case mp_red_part_operation: t = mp_red_part (tt)->name_type; break; + case mp_green_part_operation: t = mp_green_part (tt)->name_type; break; + case mp_blue_part_operation: t = mp_blue_part (tt)->name_type; break; + case mp_cyan_part_operation: t = mp_cyan_part (tt)->name_type; break; + case mp_magenta_part_operation: t = mp_magenta_part(tt)->name_type; break; + case mp_yellow_part_operation: t = mp_yellow_part (tt)->name_type; break; + case mp_black_part_operation: t = mp_black_part (tt)->name_type; break; + case mp_grey_part_operation: t = mp_grey_part (tt)->name_type; break; + default: break; } } return (t != mp_capsule_operation); @@ -4828,7 +4827,7 @@ fields changed in any way. static mp_node mp_new_structure (MP mp, mp_node p) { mp_node r = NULL; - switch (mp_name_type(p)) { + switch (p->name_type) { case mp_root_operation: { mp_sym q = mp_get_value_sym(p); @@ -4842,14 +4841,14 @@ static mp_node mp_new_structure (MP mp, mp_node p) mp_node q_new; mp_node q = p; do { - q = mp_link(q); - } while (mp_name_type(q) != mp_attribute_operation); + q = q->link; + } while (q->name_type != mp_attribute_operation); q = mp_get_parent((mp_value_node) q); r = mp->temp_head; mp_set_link(r, mp_get_subscr_head(q)); do { q_new = r; - r = mp_link(r); + r = r->link; } while (r != p); r = (mp_node) mp_get_subscr_node(mp); if (q_new == mp->temp_head) { @@ -4872,7 +4871,7 @@ static mp_node mp_new_structure (MP mp, mp_node p) r = mp_get_attribute_head(q); do { q = r; - r = mp_link(r); + r = r->link; } while (r != p); rr = mp_get_attribute_node(mp); r = (mp_node) rr; @@ -4882,8 +4881,8 @@ static mp_node mp_new_structure (MP mp, mp_node p) if (mp_get_hashloc(p) == mp_collective_subscript) { q = mp->temp_head; mp_set_link(q, mp_get_subscr_head(mp_get_parent((mp_value_node) p))); - while (mp_link(q) != p) { - q = mp_link(q); + while (q->link != p) { + q = q->link; } if (q == mp->temp_head) { mp_set_subscr_head(mp_get_parent((mp_value_node) p), (mp_node) rr); @@ -4899,18 +4898,18 @@ static mp_node mp_new_structure (MP mp, mp_node p) } if (r) { mp_value_node q; - mp_set_link(r, mp_link(p)); + mp_set_link(r, p->link); mp_set_value_sym(r, mp_get_value_sym(p)); - mp_type(r) = mp_structured_type; - mp_name_type(r) = mp_name_type(p); + r->type = mp_structured_type; + r->name_type = p->name_type; mp_set_attribute_head(r, p); - mp_name_type(p) = mp_structured_root_operation; + p->name_type = mp_structured_root_operation; q = mp_get_attribute_node(mp); mp_set_link(p, q); mp_set_subscr_head(r, (mp_node) q); mp_set_parent(q, r); - mp_type(q) = mp_undefined_type; - mp_name_type(q) = mp_attribute_operation; + q->type = mp_undefined_type; + q->name_type = mp_attribute_operation; mp_set_link(q, mp->end_attr); mp_set_hashloc(q, mp_collective_subscript); } @@ -4940,7 +4939,7 @@ static mp_node mp_find_variable (MP mp, mp_node t) } else { mp_node p, q, r, s; /* nodes in the \quote {value} line */ mp_node pp, qq, rr, ss; /* nodes in the \quote {collective} line */ - t = mp_link(t); + t = t->link; if (equiv_node(p_sym) == NULL) { mp_new_root (mp, p_sym); } @@ -4953,8 +4952,8 @@ static mp_node mp_find_variable (MP mp, mp_node t) occurs; |pp|~stays in the collective line while |p|~goes through actual subscript values. */ - if (mp_type(pp) != mp_structured_type) { - if (mp_type(pp) > mp_structured_type) { + if (pp->type != mp_structured_type) { + if (pp->type > mp_structured_type) { return NULL; } else { ss = mp_new_structure(mp, pp); @@ -4965,12 +4964,12 @@ static mp_node mp_find_variable (MP mp, mp_node t) } } /* now |type(pp)=mp_structured| */ - if (mp_type(p) != mp_structured_type) { + if (p->type != mp_structured_type) { /* it cannot be |>mp_structured| */ p = mp_new_structure(mp, p); /* now |type(p)=mp_structured| */ } - if (mp_type(t) != mp_symbol_node_type) { + if (t->type != mp_symbol_node_type) { /* Descend one level for the subscript |value (t)| We want this part of the program to be reasonably fast, in case there are lots of @@ -4981,16 +4980,16 @@ static mp_node mp_find_variable (MP mp, mp_node t) */ mp_number nn, save_subscript; /* temporary storage */ new_number_clone(nn, mp_get_value_number(t)); - pp = mp_link(mp_get_attribute_head(pp)); + pp = mp_get_attribute_head(pp)->link; /* now |mp_get_hashloc(pp)=mp_collective_subscript| */ - q = mp_link(mp_get_attribute_head(p)); + q = mp_get_attribute_head(p)->link; new_number_clone(save_subscript, mp_subscript(q)); set_number_to_inf(mp_subscript(q)); s = mp->temp_head; mp_set_link(s, mp_get_subscr_head(p)); do { r = s; - s = mp_link(s); + s = s->link; } while (number_greater(nn, mp_subscript(s))); if (number_equal(nn, mp_subscript(s))) { p = s; @@ -5003,8 +5002,8 @@ static mp_node mp_find_variable (MP mp, mp_node t) } mp_set_link(p1, s); number_clone(mp_subscript(p1), nn); - mp_name_type(p1) = mp_subscript_operation; - mp_type(p1) = mp_undefined_type; + p1->name_type = mp_subscript_operation; + p1->type = mp_undefined_type; p = (mp_node) p1; } number_clone(mp_subscript(q), save_subscript); @@ -5016,15 +5015,15 @@ static mp_node mp_find_variable (MP mp, mp_node t) ss = mp_get_attribute_head(pp); do { rr = ss; - ss = mp_link(ss); + ss = ss->link; } while (nn1 > mp_get_hashloc(ss)); if (nn1 < mp_get_hashloc(ss)) { qq = (mp_node) mp_get_attribute_node(mp); mp_set_link(rr, qq); mp_set_link(qq, ss); mp_set_hashloc(qq, nn1); - mp_name_type(qq) = mp_attribute_operation; - mp_type(qq) = mp_undefined_type; + qq->name_type = mp_attribute_operation; + qq->type = mp_undefined_type; mp_set_parent((mp_value_node) qq, pp); ss = qq; } @@ -5036,7 +5035,7 @@ static mp_node mp_find_variable (MP mp, mp_node t) s = mp_get_attribute_head(p); do { r = s; - s = mp_link(s); + s = s->link; } while (nn1 > mp_get_hashloc(s)); if (nn1 == mp_get_hashloc(s)) { p = s; @@ -5045,31 +5044,31 @@ static mp_node mp_find_variable (MP mp, mp_node t) mp_set_link(r, q); mp_set_link(q, s); mp_set_hashloc(q, nn1); - mp_name_type(q) = mp_attribute_operation; - mp_type(q) = mp_undefined_type; + q->name_type = mp_attribute_operation; + q->type = mp_undefined_type; mp_set_parent((mp_value_node) q, p); p = q; } } } - t = mp_link(t); + t = t->link; } - if (mp_type(pp) >= mp_structured_type) { - if (mp_type(pp) == mp_structured_type) { + if (pp->type >= mp_structured_type) { + if (pp->type == mp_structured_type) { pp = mp_get_attribute_head(pp); } else { return NULL; } } - if (mp_type(p) == mp_structured_type) { + if (p->type == mp_structured_type) { p = mp_get_attribute_head(p); } - if (mp_type(p) == mp_undefined_type) { - if (mp_type(pp) == mp_undefined_type) { - mp_type(pp) = mp_numeric_type; + if (p->type == mp_undefined_type) { + if (pp->type == mp_undefined_type) { + pp->type = mp_numeric_type; mp_set_value_number(pp, zero_t); } - mp_type(p) = mp_type(pp); + p->type = pp->type; mp_set_value_number(p, zero_t); } return p; @@ -5100,35 +5099,35 @@ static void mp_flush_cur_exp (MP mp, mp_value v); static void mp_flush_variable (MP mp, mp_node p, mp_node t, int discard_suffixes) { while (t != NULL) { - if (mp_type(p) != mp_structured_type) { + if (p->type != mp_structured_type) { return; } else { /* attribute to match */ mp_sym n = mp_get_sym_sym(t); - t = mp_link(t); + t = t->link; if (n == mp_collective_subscript) { mp_node q = mp_get_subscr_head(p); mp_node r = NULL; - while (mp_name_type(q) == mp_subscript_operation) { + while (q->name_type == mp_subscript_operation) { mp_flush_variable(mp, q, t, discard_suffixes); if (t != NULL) { r = q; - } else if (mp_type(q) == mp_structured_type) { + } else if (q->type == mp_structured_type) { r = q; } else { if (r == NULL) { - mp_set_subscr_head(p, mp_link(q)); + mp_set_subscr_head(p, q->link); } else { - mp_set_link(r, mp_link(q)); + mp_set_link(r, q->link); } mp_free_value_node(mp, q); } - q = r == NULL ? mp_get_subscr_head(p) : mp_link(r); + q = r == NULL ? mp_get_subscr_head(p) : r->link; } } p = mp_get_attribute_head(p); do { - p = mp_link(p); + p = p->link; } while (mp_get_hashloc(p) < n); if (mp_get_hashloc(p) != n) { return; @@ -5138,7 +5137,7 @@ static void mp_flush_variable (MP mp, mp_node p, mp_node t, int discard_suffixes if (discard_suffixes) { mp_flush_below_variable(mp, p); } else { - if (mp_type(p) == mp_structured_type) { + if (p->type == mp_structured_type) { p = mp_get_attribute_head(p); } mp_recycle_value(mp, p); @@ -5154,28 +5153,28 @@ static void mp_flush_below_variable (MP mp, mp_node p); @ @c void mp_flush_below_variable (MP mp, mp_node p) { - if (mp_type(p) != mp_structured_type) { + if (p->type != mp_structured_type) { mp_recycle_value(mp, p); /* this sets |type(p)=undefined| */ } else { mp_node r; mp_node q = mp_get_subscr_head(p); - while (mp_name_type(q) == mp_subscript_operation) { + while (q->name_type == mp_subscript_operation) { mp_flush_below_variable(mp, q); r = q; - q = mp_link(q); + q = q->link; mp_free_value_node(mp, r); } r = mp_get_attribute_head(p); - q = mp_link(r); + q = r->link; mp_recycle_value(mp, r); mp_free_value_node(mp, r); do { mp_flush_below_variable(mp, q); r = q; - q = mp_link(q); + q = q->link; mp_free_value_node(mp, r); } while (q != mp->end_attr); - mp_type(p) = mp_undefined_type; + p->type = mp_undefined_type; } } @@ -5187,7 +5186,7 @@ undefined value should be given, based on the current type before recycling. static int mp_und_type (MP mp, mp_node p) { (void) mp; - switch (mp_type(p)) { + switch (p->type) { case mp_vacuous_type: return mp_undefined_type; case mp_boolean_type: @@ -5213,7 +5212,7 @@ static int mp_und_type (MP mp, mp_node p) case mp_cmykcolor_type: case mp_pair_type: case mp_numeric_type: - return mp_type(p); + return p->type; case mp_known_type: case mp_dependent_type: case mp_proto_dependent_type: @@ -5249,7 +5248,7 @@ static void mp_clear_symbol (MP mp, mp_sym p, int saving) case mp_tag_command: if (q != NULL) { if (saving) { - mp_name_type(q) = mp_saved_root_operation; + q->name_type = mp_saved_root_operation; } else { mp_flush_below_variable(mp, q); mp_free_value_node(mp, q); @@ -5358,7 +5357,7 @@ static void mp_unsave_variable (MP mp) if (eq_type(q) == mp_tag_command) { mp_node pp = q->v.data.node; if (pp != NULL) { - mp_name_type(pp) = mp_root_operation; + pp->name_type = mp_root_operation; } } } @@ -9251,9 +9250,9 @@ chooses one of them. static void mp_find_offset (MP mp, mp_number *x_orig, mp_number *y_orig, mp_knot h) { if (mp_pen_is_elliptical(h)) { - mp_fraction xx, yy; /* untransformed offset for an elliptical pen */ + mp_number xx, yy; /* untransformed offset for an elliptical pen */ mp_number wx, wy, hx, hy; /* the transformation matrix for an elliptical pen */ - mp_fraction d; /* a temporary register */ + mp_number d; /* a temporary register */ new_fraction(xx); new_fraction(yy); new_number(wx); @@ -9439,9 +9438,6 @@ static void mp_pen_bbox (MP mp, mp_knot h) This first set goes into the header @<MPlib internal header stuff@>= -@d mp_fraction mp_number -@d mp_angle mp_number - @d new_number(A) mp->math->md_allocate(mp, &(A), mp_scaled_type) @d new_fraction(A) mp->math->md_allocate(mp, &(A), mp_fraction_type) @d new_angle(A) mp->math->md_allocate(mp, &(A), mp_angle_type) @@ -9630,8 +9626,8 @@ typedef struct mp_shape_node_data *mp_shape_node; @d mp_line_join(A) ((mp_shape_node) (A))->linejoin @d mp_miterlimit(A) ((mp_shape_node) (A))->miterlimit -@d mp_set_linecap(A,B) ((mp_shape_node) (A))->linecap = (short) (B) -@d mp_set_linejoin(A,B) ((mp_shape_node) (A))->linejoin = (short) (B) +@d mp_set_linecap(A,B) ((mp_shape_node) (A))->linecap = (unsigned char) (B) +@d mp_set_linejoin(A,B) ((mp_shape_node) (A))->linejoin = (unsigned char) (B) @d mp_pre_script(A) ((mp_shape_node) (A))->pre_script @d mp_post_script(A) ((mp_shape_node) (A))->post_script @@ -9659,7 +9655,7 @@ be transformed without touching the picture that |dash_p| points to. static mp_node mp_new_shape_node (MP mp, mp_knot p, int type) { mp_shape_node t = mp_allocate_node(mp, sizeof(mp_shape_node_data)); - mp_type(t) = type; + t->type = type; mp_path_ptr(t) = p; mp_pen_ptr(t) = NULL; /* |NULL| means don't use a pen */ mp_dash_ptr(t) = NULL; @@ -9819,12 +9815,12 @@ For this reason, each clipping or |setbounds| operation is represented by a pair of nodes: first comes a node whose |path_ptr| gives the relevant path, then there is the list of objects to clip or bound followed by a closing node. -@d mp_has_color(A) (mp_type((A))<mp_start_clip_node_type) /* does a graphical object have color fields? */ -@d mp_has_script(A) (mp_type((A))<=mp_start_bounds_node_type) /* does a graphical object have color fields? */ -@d mp_has_pen(A) (mp_type((A))<=mp_stroked_node_type) /* does a graphical object have a |mp_pen_ptr| field? */ +@d mp_has_color(A) ((A)->type < mp_start_clip_node_type) /* does a graphical object have color fields? */ +@d mp_has_script(A) ((A)->type <= mp_start_bounds_node_type) /* does a graphical object have color fields? */ +@d mp_has_pen(A) ((A)->type <= mp_stroked_node_type) /* does a graphical object have a |mp_pen_ptr| field? */ -@d mp_is_start_or_stop(A) (mp_type((A))>=mp_start_clip_node_type) -@d mp_is_stop(A) (mp_type((A))>=mp_stop_clip_node_type) +@d mp_is_start_or_stop(A) ((A)->type >= mp_start_clip_node_type) +@d mp_is_stop(A) ((A)->type >= mp_stop_clip_node_type) @<MPlib internal header stuff@>= typedef struct mp_start_node_data { @@ -9863,9 +9859,8 @@ static mp_node mp_new_bounds_node (MP mp, mp_knot p, int c) case mp_start_bounds_node_type: { mp_start_node t = (mp_start_node) mp_allocate_node(mp, sizeof(mp_start_node_data)); - mp_type(t) = c; + t->type = c; t->path = p; - t->link = NULL; t->stacking = round_unscaled(internal_value(mp_stacking_internal)); mp_pre_script(t) = NULL; mp_post_script(t) = NULL; @@ -9877,8 +9872,7 @@ static mp_node mp_new_bounds_node (MP mp, mp_knot p, int c) case mp_stop_bounds_node_type: { mp_stop_node t = (mp_stop_node) mp_allocate_node(mp, sizeof(mp_stop_node_data)); - mp_type(t) = c; - t->link = NULL; + t->type = c; t->stacking = round_unscaled(internal_value(mp_stacking_internal)); return (mp_node) t; } @@ -9959,7 +9953,7 @@ static mp_dash_node mp_get_dash_node (MP mp) new_number(p->start_x); new_number(p->stop_x); new_number(p->dash_y); - mp_type(p) = mp_dash_node_type; + p->type = mp_dash_node_type; return p; } @@ -10039,7 +10033,7 @@ word and a pointer to the tail of the object list in the last word. static mp_edge_header_node mp_get_edge_header_node (MP mp) { mp_edge_header_node p = (mp_edge_header_node) mp_allocate_node(mp, sizeof(mp_edge_header_node_data)); - mp_type(p) = mp_edge_header_node_type; + p->type = mp_edge_header_node_type; new_number(p->start_x); new_number(p->stop_x); new_number(p->dash_y); @@ -10056,7 +10050,7 @@ static void mp_init_edges (MP mp, mp_edge_header_node h) /* initialize an edge header to NULL values */ mp_set_dash_list(h, mp->null_dash); mp_obj_tail(h) = mp_edge_list(h); - mp_link(mp_edge_list(h)) = NULL; + mp_edge_list(h)->link = NULL; mp_edge_ref_count(h) = 0; mp_init_bbox(mp, h); } @@ -10086,10 +10080,10 @@ void mp_toss_edges (MP mp, mp_edge_header_node h) mp_node q; /* pointers that scan the list being recycled */ mp_edge_header_node r; /* an edge structure that object |p| refers to */ mp_flush_dash_list(mp, h); - q = mp_link(mp_edge_list(h)); + q = mp_edge_list(h)->link; while (q != NULL) { mp_node p = q; - q = mp_link(q); + q = q->link; r = mp_toss_gr_object(mp, p); if (r != NULL) { mp_delete_edge_ref(mp, r); @@ -10111,7 +10105,7 @@ void mp_flush_dash_list (MP mp, mp_edge_header_node h) mp_dash_node q = mp_get_dash_list(h); while (q != mp->null_dash) { mp_dash_node p = q; - q = (mp_dash_node) mp_link(q); + q = (mp_dash_node) q->link; mp_free_node(mp, (mp_node) p, sizeof(mp_dash_node_data)); } mp_set_dash_list(h, mp->null_dash); @@ -10120,7 +10114,7 @@ void mp_flush_dash_list (MP mp, mp_edge_header_node h) mp_edge_header_node mp_toss_gr_object (MP mp, mp_node p) { /* returns an edge structure that needs to be dereferenced */ - switch (mp_type(p)) { + switch (p->type) { case mp_fill_node_type: case mp_stroked_node_type: return mp_free_shape_node(mp, (mp_shape_node) p); @@ -10154,7 +10148,7 @@ static mp_edge_header_node mp_private_edges (MP mp, mp_edge_header_node h) mp_edge_header_node hh; /* the edge header for the new copy */ mp_dash_node p, pp; /* pointers for copying the dash list */ mp_edge_ref_count(h) -= 1; - hh = (mp_edge_header_node) mp_copy_objects (mp, mp_link(mp_edge_list(h)), NULL); + hh = (mp_edge_header_node) mp_copy_objects (mp, mp_edge_list(h)->link, NULL); @<Copy the dash list from |h| to |hh|@> @<Copy the bounding box information from |h| to |hh| and make |mp_bblast(hh)| point into the new object list@> return hh; @@ -10168,13 +10162,13 @@ assumptions@> pp = (mp_dash_node) hh; p = mp_get_dash_list(h); while ((p != mp->null_dash)) { - mp_link(pp) = (mp_node) mp_get_dash_node(mp); - pp = (mp_dash_node) mp_link(pp); + pp->link = (mp_node) mp_get_dash_node(mp); + pp = (mp_dash_node) pp->link; number_clone(pp->start_x, p->start_x); number_clone(pp->stop_x, p->stop_x); - p = (mp_dash_node) mp_link(p); + p = (mp_dash_node) p->link; } -mp_link(pp) = (mp_node) mp->null_dash; +pp->link = (mp_node) mp->null_dash; number_clone(hh->dash_y, h->dash_y); @ |h| is an edge structure @@ -10222,12 +10216,12 @@ static mp_dash_object *mp_export_dashes (MP mp, mp_shape_node q, mp_number *w) set_number_from_subtraction(arg1, p->stop_x, p->start_x); take_scaled(ret, arg1, scf); dashes[(num_dashes - 1)] = number_to_double(ret); - set_number_from_subtraction(arg1, ((mp_dash_node) mp_link(p))->start_x, p->stop_x); + set_number_from_subtraction(arg1, ((mp_dash_node) p->link)->start_x, p->stop_x); take_scaled(ret, arg1, scf); dashes[(num_dashes)] = number_to_double(ret); dashes[(num_dashes + 1)] = -1.0; /* terminus */ num_dashes += 2; - p = (mp_dash_node) mp_link(p); + p = (mp_dash_node) p->link; } d->array = dashes; mp_dash_offset(mp, &dashoff, h); @@ -10255,8 +10249,8 @@ while ((p != (mp_dash_node) mp_bblast(h))) { mp_confusion(mp, "boundingbox last"); @:this can't happen bblast}{\quad bblast@> } else { - p = (mp_dash_node) mp_link(p); - pp = (mp_dash_node) mp_link(pp); + p = (mp_dash_node) p->link; + pp = (mp_dash_node) pp->link; } } mp_bblast(hh) = (mp_node) pp; @@ -10281,13 +10275,13 @@ mp_edge_header_node mp_copy_objects (MP mp, mp_node p, mp_node q) { @<Make |mp_link(pp)| point to a copy of object |p|, and update |p| and |pp|@> } mp_obj_tail(hh) = pp; - mp_link(pp) = NULL; + pp->link = NULL; return hh; } @ @<Make |mp_link(pp)| point to a copy of object |p|, and update |p| and |pp|@>= { - switch (mp_type(p)) { + switch (p->type) { case mp_fill_node_type: case mp_stroked_node_type: k = sizeof(mp_shape_node_data); @@ -10305,16 +10299,16 @@ mp_edge_header_node mp_copy_objects (MP mp, mp_node p, mp_node q) { default: break; } - mp_link(pp) = mp_allocate_node(mp, (size_t) k); /* |gr_object| */ - pp = mp_link(pp); + pp->link = mp_allocate_node(mp, (size_t) k); /* |gr_object| */ + pp = pp->link; memcpy(pp, p, (size_t) k); pp->link = NULL; @<Fix anything in graphical object |pp| that should differ from the corresponding field in |p|@> - p = mp_link(p); + p = p->link; } @ @<Fix anything in graphical object |pp| that should differ from the...@>= -switch (mp_type(p)) { +switch (p->type) { case mp_fill_node_type: case mp_stroked_node_type: { @@ -10383,7 +10377,7 @@ static mp_node mp_skip_1component (MP mp, mp_node p) ++lev; } } - p = mp_link(p); + p = p->link; } while (lev != 0); return p; } @@ -10400,10 +10394,10 @@ void mp_print_edges (MP mp, mp_node h, const char *s, int nuline) mp_number scf; /* a scale factor for the dash pattern */ new_number(scf); mp_print_diagnostic(mp, "Edge structure", s, nuline); - while (mp_link(p) != NULL) { - p = mp_link(p); + while (p->link != NULL) { + p = p->link; mp_print_ln(mp); - switch (mp_type(p)) { + switch (p->type) { @<Cases for printing graphical object node |p|@> default: mp_print_str(mp, "[unknown object type!]"); @@ -10579,10 +10573,10 @@ if ((ppd == mp->null_dash) || number_negative(hhd->dash_y)) { take_scaled(ret, arg1, scf); print_number( ret); mp_print_str(mp, " off "); - set_number_from_subtraction(arg1, ((mp_dash_node) mp_link(ppd))->start_x, ppd->stop_x); + set_number_from_subtraction(arg1, ((mp_dash_node) ppd->link)->start_x, ppd->stop_x); take_scaled(ret, arg1, scf); print_number(ret); - ppd = (mp_dash_node) mp_link(ppd); + ppd = (mp_dash_node) ppd->link; if (ppd != mp->null_dash) { mp_print_chr(mp, ' '); } @@ -10669,9 +10663,9 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) @<Other local variables in |make_dashes|@> new_number(y0); /* the initial $y$ coordinate */ p0 = NULL; - p = mp_link(mp_edge_list(h)); + p = mp_edge_list(h)->link; while (p != NULL) { - if (mp_type(p) != mp_stroked_node_type) { + if (p->type != mp_stroked_node_type) { @<Complain that the edge structure contains a node of the wrong type and |goto not_found|@> } pp = mp_path_ptr((mp_shape_node) p); @@ -10681,7 +10675,7 @@ static mp_edge_header_node mp_make_dashes (MP mp, mp_edge_header_node h) } @<Make |d| point to a new dash node created from stroke |p| and path |pp| or |goto not_found| if there is an error@> @<Insert |d| into the dash list and |goto not_found| if there is an error@> - p = mp_link(p); + p = p->link; } if (mp_get_dash_list(h) == mp->null_dash) { goto NOT_FOUND; /* No error message */ @@ -10825,20 +10819,20 @@ if (! number_equal(((mp_shape_node) p)->red, ((mp_shape_node) p0)->red) @ @<Insert |d| into the dash list and |goto not_found| if there is an error@>= number_clone(mp->null_dash->start_x, d->stop_x); dd = (mp_dash_node) h; /* this makes |mp_link(dd)=mp_get_dash_list(h)| */ -while (number_less(((mp_dash_node) mp_link(dd))->start_x, d->stop_x)) { - dd = (mp_dash_node) mp_link(dd); +while (number_less(((mp_dash_node) dd->link)->start_x, d->stop_x)) { + dd = (mp_dash_node) dd->link; } if ((dd != (mp_dash_node) h) && number_greater(dd->stop_x, d->start_x)) { mp_x_retrace_error(mp); goto NOT_FOUND; } -mp_link(d) = mp_link(dd); -mp_link(dd) = (mp_node) d; +d->link = dd->link; +dd->link = (mp_node) d; @ @<Set |dash_y(h)| and merge the first and last dashes if necessary@>= d = mp_get_dash_list(h); -while (mp_link(d) != (mp_node) mp->null_dash) { - d = (mp_dash_node) mp_link(d); +while (d->link != (mp_node) mp->null_dash) { + d = (mp_dash_node) d->link; } dd = mp_get_dash_list(h); set_number_from_subtraction(h->dash_y, d->stop_x, dd->start_x); @@ -10849,7 +10843,7 @@ set_number_from_subtraction(h->dash_y, d->stop_x, dd->start_x); if (number_greater(absval, h->dash_y) ) { number_clone(h->dash_y, absval); } else if (d != dd) { - mp_set_dash_list(h, mp_link(dd)); + mp_set_dash_list(h, dd->link); set_number_from_addition(d->stop_x, dd->stop_x, h->dash_y); mp_free_node(mp, (mp_node) dd, sizeof(mp_dash_node_data)); } @@ -10873,11 +10867,11 @@ nodes, we must be prepared to break up these dashes into smaller dashes. { mp_number hsf; /* the dash pattern from |hh| gets scaled by this */ new_number(hsf); -d = (mp_dash_node) h; /* now |mp_link(d)=mp_get_dash_list(h)| */ -while (mp_link(d) != (mp_node) mp->null_dash) { - ds = mp_dash_info(mp_link(d)); +d = (mp_dash_node) h; /* now |d->link=mp_get_dash_list(h)| */ +while (d->link != (mp_node) mp->null_dash) { + ds = mp_dash_info(d->link); if (ds == NULL) { - d = (mp_dash_node) mp_link(d); + d = (mp_dash_node) d->link; } else { hh = (mp_edge_header_node) mp_dash_ptr(ds); number_clone(hsf, ((mp_shape_node) ds)->dashscale); @@ -10886,7 +10880,7 @@ while (mp_link(d) != (mp_node) mp->null_dash) { @:this can't happen dash0}{\quad dash1@> return NULL; } else if (number_zero(((mp_dash_node) hh)->dash_y )) { - d = (mp_dash_node) mp_link(d); + d = (mp_dash_node) d->link; } else if (mp_get_dash_list (hh) == NULL) { mp_confusion(mp, "dash list"); @:this can't happen dash1}{\quad dash1@> @@ -10910,7 +10904,7 @@ mp_number dashoff; mp_number r1, r2; new_number(r1); new_number(r2); -dln = (mp_dash_node) mp_link(d); +dln = (mp_dash_node) d->link; dd = mp_get_dash_list(hh); new_number(xoff); new_number(dashoff); @@ -10928,14 +10922,14 @@ number_clone(mp->null_dash->stop_x, mp->null_dash->start_x); while (number_lessequal(dln->start_x, dln->stop_x)) { @<If |dd| has `fallen off the end', back up to the beginning and fix |xoff|@> @<Insert a dash between |d| and |dln| for the overlap with the offset version of |dd|@> - dd = (mp_dash_node) mp_link(dd); + dd = (mp_dash_node) dd->link; take_scaled(r1, hsf, dd->start_x); set_number_from_addition(dln->start_x , xoff, r1); } free_number(xoff); free_number(r1); free_number(r2); -mp_link(d) = mp_link(dln); +d->link = dln->link; mp_free_node(mp, (mp_node) dln, sizeof(mp_dash_node_data)); @ The name of this module is a bit of a lie because we just find the first |dd| @@ -10950,7 +10944,7 @@ between |dd| and its predecessor. take_scaled(r1, hsf, dd->stop_x); number_add(r1, xoff); while (number_less(r1, dln->start_x)) { - dd = (mp_dash_node) mp_link(dd); + dd = (mp_dash_node) dd->link; take_scaled(r1, hsf, dd->stop_x); number_add(r1, xoff); } @@ -10976,9 +10970,9 @@ if (dd == mp->null_dash) { take_scaled(r1, hsf, dd->start_x); number_add(r1, xoff); if (number_lessequal(r1, dln->stop_x)) { - mp_link(d) = (mp_node) mp_get_dash_node(mp); - d = (mp_dash_node) mp_link(d); - mp_link(d) = (mp_node) dln; + d->link = (mp_node) mp_get_dash_node(mp); + d = (mp_dash_node) d->link; + d->link = (mp_node) dln; take_scaled(r1, hsf, dd->start_x ); number_add(r1, xoff); if (number_greater(dln->start_x, r1)) { @@ -11028,7 +11022,7 @@ to be stroked with the pen~|pp|. static void mp_box_ends (MP mp, mp_knot p, mp_knot pp, mp_edge_header_node h) { if (mp_right_type(p) != mp_endpoint_knot) { - mp_fraction dx, dy; /* a unit vector in the direction out of the path at~|p| */ + mp_number dx, dy; /* a unit vector in the direction out of the path at~|p| */ mp_number d; /* a factor for adjusting the length of |(dx,dy)| */ mp_number z; /* a coordinate being tested against the bounding box */ mp_number xx, yy; /* the extreme pen vertex in the |(dx,dy)| direction */ @@ -11172,10 +11166,10 @@ void mp_set_bbox (MP mp, mp_edge_header_node h, int top_level) break; } - while (mp_link(mp_bblast(h)) != NULL) { - mp_node p = mp_link(mp_bblast(h)); /* a graphical object being considered */ + while (mp_bblast(h)->link != NULL) { + mp_node p = mp_bblast(h)->link; /* a graphical object being considered */ mp_bblast(h) = p; - switch (mp_type(p)) { + switch (p->type) { case mp_stop_clip_node_type: if (top_level) { mp_confusion(mp, "clip"); @@ -11219,14 +11213,14 @@ case mp_stop_bounds_node_type: { int lev = 1; while (lev != 0) { - if (mp_link(p) == NULL) { + if (p->link == NULL) { mp_confusion(mp, "bounds"); @:this can't happen bbox2}{\quad bbox2@> } else { - p = mp_link(p); - if (mp_type(p) == mp_start_bounds_node_type) { + p = p->link; + if (p->type == mp_start_bounds_node_type) { ++lev; - } else if (mp_type(p) == mp_stop_bounds_node_type) { + } else if (p->type == mp_stop_bounds_node_type) { --lev; } } @@ -12390,7 +12384,7 @@ static mp_knot mp_make_envelope (MP mp, mp_knot c, mp_knot h, int linejoin, int mp_knot w, w0; /* the pen knot for the current offset */ int k, k0; /* controls pen edge insertion */ mp_number qx, qy; /* unshifted coordinates of |q| */ - mp_fraction dxin, dyin, dxout, dyout; /* directions at |q| when square or mitered */ + mp_number dxin, dyin, dxout, dyout; /* directions at |q| when square or mitered */ int join_type = 0; /* codes |0..3| for mitered, round, beveled, or square */ @<Other local variables for |make_envelope|@> new_number(max_ht); @@ -13937,7 +13931,7 @@ static void mp_new_indep (MP mp, mp_node p) if (mp->serial_no >= max_integer) { mp_fatal_error(mp, "Variable instance identifiers exhausted"); } - mp_type(p) = mp_independent_type; + p->type = mp_independent_type; mp->serial_no = mp->serial_no + 1; mp_set_indep_scale(p, 0); mp_set_indep_value(p, mp->serial_no); @@ -14011,7 +14005,7 @@ inline static void do_set_dep_value (MP mp, mp_value_node p, mp_number *q); static mp_value_node mp_get_dep_node (MP mp) { mp_value_node p = (mp_value_node) mp_new_value_node(mp); - mp_type(p) = mp_dep_node_type; + p->type = mp_dep_node_type; return p; } @@ -14080,7 +14074,7 @@ void mp_print_dependency (MP mp, mp_value_node p, int t) if (! number_equal(v, unity_t)) { print_number(v); } - if (mp_type(q) != mp_independent_type) { + if (q->type != mp_independent_type) { mp_confusion(mp, "dependency"); } else { mp_print_variable_name(mp, q); @@ -14089,7 +14083,7 @@ void mp_print_dependency (MP mp, mp_value_node p, int t) mp_print_str(mp, "*4"); number_add_scaled(v, -2); } - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; } } } @@ -14100,7 +14094,7 @@ returned by the following simple function. @c static void mp_max_coef (MP mp, mp_number *x, mp_value_node p) { - mp_number(absv); + mp_number absv; new_number(absv); set_number_to_zero(*x); while (mp_get_dep_info(p) != NULL) { @@ -14108,7 +14102,7 @@ static void mp_max_coef (MP mp, mp_number *x, mp_value_node p) if (number_greater(absv, *x)) { number_clone(*x, absv); } - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; } free_number(absv); } @@ -14216,13 +14210,13 @@ static mp_value_node mp_p_plus_fq (MP mp, free_number(r1); mp_set_dep_value(p, v); s = p; - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; number_abs_clone(absv, v); if (number_less(absv, threshold)) { mp_free_dep_node(mp, s); } else { if (number_greaterequal(absv, coef_bound_k) && mp->watch_coefs) { - mp_type(qq) = independent_needing_fix; + qq->type = independent_needing_fix; /* If we set this , then we can drop |(mp_type(pp) == independent_needing_fix && mp->fix_needed)| later @@ -14236,20 +14230,20 @@ static mp_value_node mp_p_plus_fq (MP mp, } free_number(absv); pp = mp_get_dep_info(p); - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; qq = mp_get_dep_info(q); } } else { if (pp == NULL) { set_number_to_negative_inf(v); - } else if (mp_type(pp) == mp_independent_type || (mp_type(pp) == independent_needing_fix && mp->fix_needed)) { + } else if (pp->type == mp_independent_type || (pp->type == independent_needing_fix && mp->fix_needed)) { set_number_from_scaled(v, mp_get_indep_value(pp)); } else { number_clone(v, mp_get_value_number(pp)); } if (qq == NULL) { set_number_to_negative_inf(vv); - } else if (mp_type(qq) == mp_independent_type || (mp_type(qq) == independent_needing_fix && mp->fix_needed)) { + } else if (qq->type == mp_independent_type || (qq->type == independent_needing_fix && mp->fix_needed)) { set_number_from_scaled(vv, mp_get_indep_value(qq)); } else { number_clone(vv, mp_get_value_number(qq)); @@ -14279,19 +14273,19 @@ static mp_value_node mp_p_plus_fq (MP mp, mp_set_dep_info(s, qq); mp_set_dep_value(s, v); if (number_greaterequal(absv, coef_bound_k) && mp->watch_coefs) { - mp_type(qq) = independent_needing_fix; + qq->type = independent_needing_fix; mp->fix_needed = 1; } mp_set_link(r, s); r = s; } - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; qq = mp_get_dep_info(q); free_number(absv); } else { mp_set_link(r, p); r = p; - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; pp = mp_get_dep_info(p); } } @@ -14321,7 +14315,7 @@ static mp_value_node mp_p_plus_fq (MP mp, free_number(half_threshold); free_number(v); free_number(vv); - return (mp_value_node) mp_link(mp->temp_head); + return (mp_value_node) mp->temp_head->link; } @ It is convenient to have another subroutine for the special case of |p_plus_fq| @@ -14358,14 +14352,14 @@ static mp_value_node mp_p_plus_q (MP mp, mp_value_node p, mp_value_node q, mp_va set_number_from_addition(v, mp_get_dep_value(p), mp_get_dep_value(q)); mp_set_dep_value(p, v); s = p; - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; pp = mp_get_dep_info(p); number_abs_clone(test, v); if (number_less(test, threshold)) { mp_free_dep_node(mp, s); } else { if (number_greaterequal(test, coef_bound_k) && mp->watch_coefs) { - mp_type(qq) = independent_needing_fix; + qq->type = independent_needing_fix; /* If we set this , then we can drop |(mp_type(pp) == independent_needing_fix && mp->fix_needed)| later @@ -14378,21 +14372,21 @@ static mp_value_node mp_p_plus_q (MP mp, mp_value_node p, mp_value_node q, mp_va r = s; } free_number(test); - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; qq = mp_get_dep_info(q); } } else { if (pp == NULL) { set_number_to_zero(v); - } else if (mp_type(pp) == mp_independent_type || (mp_type(pp) == independent_needing_fix && mp->fix_needed)) { + } else if (pp->type == mp_independent_type || (pp->type == independent_needing_fix && mp->fix_needed)) { set_number_from_scaled(v, mp_get_indep_value(pp)); } else { number_clone(v, mp_get_value_number(pp)); } if (qq == NULL) { set_number_to_zero(vv); - } else if (mp_type(qq) == mp_independent_type || (mp_type(qq) == independent_needing_fix && mp->fix_needed)) { + } else if (qq->type == mp_independent_type || (qq->type == independent_needing_fix && mp->fix_needed)) { set_number_from_scaled(vv, mp_get_indep_value(qq)); } else { number_clone(vv, mp_get_value_number(qq)); @@ -14401,14 +14395,14 @@ static mp_value_node mp_p_plus_q (MP mp, mp_value_node p, mp_value_node q, mp_va s = mp_get_dep_node(mp); mp_set_dep_info(s, qq); mp_set_dep_value(s, mp_get_dep_value(q)); - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; qq = mp_get_dep_info(q); mp_set_link(r, s); r = s; } else { mp_set_link(r, p); r = p; - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; pp = mp_get_dep_info(p); } } @@ -14425,7 +14419,7 @@ static mp_value_node mp_p_plus_q (MP mp, mp_value_node p, mp_value_node q, mp_va free_number(v); free_number(vv); free_number(threshold); - return (mp_value_node) mp_link(mp->temp_head); + return (mp_value_node) mp->temp_head->link; } @ A somewhat simpler routine will multiply a dependency list by a given @@ -14460,18 +14454,18 @@ static mp_value_node mp_p_times_v (MP mp, mp_value_node p, mp_number *v, int t0, } number_abs_clone(test, w); if (number_lessequal(test, threshold)) { - s = (mp_value_node) mp_link(p); + s = (mp_value_node) p->link; mp_free_dep_node(mp, p); p = s; } else { if (number_greaterequal(test, coef_bound_k)) { mp->fix_needed = 1; - mp_type(mp_get_dep_info(p)) = independent_needing_fix; + mp_get_dep_info(p)->type = independent_needing_fix; } mp_set_link(r, p); r = p; mp_set_dep_value(p, w); - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; } free_number(test); } @@ -14489,7 +14483,7 @@ static mp_value_node mp_p_times_v (MP mp, mp_value_node p, mp_number *v, int t0, } free_number(w); free_number(threshold); - return (mp_value_node) mp_link(mp->temp_head); + return (mp_value_node) mp->temp_head->link; } @ Similarly, we sometimes need to divide a dependency list by a given |scaled| @@ -14540,18 +14534,18 @@ mp_value_node mp_p_over_v (MP mp, mp_value_node p, mp_number *v_orig, int t0, in new_number(test); number_abs_clone(test, w); if (number_lessequal(test, threshold)) { - s = (mp_value_node) mp_link(p); + s = (mp_value_node) p->link; mp_free_dep_node(mp, p); p = s; } else { if (number_greaterequal(test, coef_bound_k)) { mp->fix_needed = 1; - mp_type(mp_get_dep_info(p)) = independent_needing_fix; + mp_get_dep_info(p)->type = independent_needing_fix; } mp_set_link(r, p); r = p; mp_set_dep_value(p, w); - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; } free_number(test); } @@ -14567,7 +14561,7 @@ mp_value_node mp_p_over_v (MP mp, mp_value_node p, mp_number *v_orig, int t0, in free_number(v); free_number(w); free_number(threshold); - return (mp_value_node) mp_link(mp->temp_head); + return (mp_value_node) mp->temp_head->link; } @ Here's another utility routine for dependency lists. When an independent @@ -14589,7 +14583,7 @@ static mp_value_node mp_p_with_x_becoming_q (MP mp, mp_value_node p, mp_node x, int sx = mp_get_indep_value(x); /* serial number of |x| */ while (mp_get_dep_info(s) != NULL && mp_get_indep_value(mp_get_dep_info(s)) > sx) { r = s; - s = (mp_value_node) mp_link(s); + s = (mp_value_node) s->link; } if (mp_get_dep_info(s) == NULL || mp_get_dep_info(s) != x) { return p; @@ -14597,10 +14591,10 @@ static mp_value_node mp_p_with_x_becoming_q (MP mp, mp_value_node p, mp_node x, mp_value_node ret; mp_number v1; mp_set_link(mp->temp_head, p); - mp_set_link(r, mp_link(s)); + mp_set_link(r, s->link); new_number_clone(v1, mp_get_dep_value(s)); mp_free_dep_node(mp, s); - ret = mp_p_plus_fq(mp, (mp_value_node) mp_link(mp->temp_head), &v1, (mp_value_node) q, t, mp_dependent_type); + ret = mp_p_plus_fq(mp, (mp_value_node) mp->temp_head->link, &v1, (mp_value_node) q, t, mp_dependent_type); free_number(v1); return ret; } @@ -14638,12 +14632,12 @@ static void mp_make_known (MP mp, mp_value_node p, mp_value_node q); @ @c void mp_make_known (MP mp, mp_value_node p, mp_value_node q) { - mp_variable_type t = mp_type(p); /* the previous type */ + mp_variable_type t = p->type; /* the previous type */ mp_number absp; new_number(absp); - mp_set_prev_dep(mp_link(q), mp_get_prev_dep(p)); - mp_set_link(mp_get_prev_dep(p), mp_link(q)); - mp_type(p) = mp_known_type; + mp_set_prev_dep(q->link, mp_get_prev_dep(p)); + mp_set_link(mp_get_prev_dep(p), q->link); + p->type = mp_known_type; mp_set_value_number(p, mp_get_dep_value(q)); mp_free_dep_node(mp, q); number_abs_clone(absp, mp_get_value_number(p)); @@ -14681,7 +14675,7 @@ static void mp_fix_dependencies (MP mp); @ @c static void mp_fix_dependencies (MP mp) { - mp_value_node r = (mp_value_node) mp_link(mp->dep_head); + mp_value_node r = (mp_value_node) mp->dep_head->link; mp_value_node s = NULL; while (r != mp->dep_head) { /* @@ -14695,40 +14689,40 @@ static void mp_fix_dependencies (MP mp) if (t == r) { q = (mp_value_node) mp_get_dep_list(t); } else { - q = (mp_value_node) mp_link(r); + q = (mp_value_node) r->link; } x = mp_get_dep_info(q); if (x == NULL) { break; - } else if (mp_type(x) <= independent_being_fixed) { - if (mp_type(x) < independent_being_fixed) { + } else if (x->type <= independent_being_fixed) { + if (x->type < independent_being_fixed) { mp_value_node p = mp_get_dep_node(mp); mp_set_link(p, s); s = p; mp_set_dep_info(s, x); - mp_type(x) = independent_being_fixed; + x->type = independent_being_fixed; } mp_set_dep_value(q, mp_get_dep_value(q)); number_divide_int(mp_get_dep_value(q), 4); if (number_zero(mp_get_dep_value(q))) { - mp_set_link(r, mp_link(q)); + mp_set_link(r, q->link); mp_free_dep_node(mp, q); q = r; } } r = q; } - r = (mp_value_node) mp_link(q); + r = (mp_value_node) q->link; if (q == (mp_value_node) mp_get_dep_list(t)) { mp_make_known(mp, t, q); } } while (s != NULL) { - mp_value_node p = (mp_value_node) mp_link(s); + mp_value_node p = (mp_value_node) s->link; mp_node x = mp_get_dep_info(s); mp_free_dep_node(mp, s); s = p; - mp_type(x) = mp_independent_type; + x->type = mp_independent_type; mp_set_indep_scale(x, mp_get_indep_scale(x) + 2); } mp->fix_needed = 0; @@ -14743,10 +14737,10 @@ of list~|p|. static void mp_new_dep (MP mp, mp_node q, mp_variable_type newtype, mp_value_node p) { mp_node r; /* what used to be the first dependency */ - mp_type(q) = newtype; + q->type = newtype; mp_set_dep_list(q, p); mp_set_prev_dep(q, (mp_node) mp->dep_head); - r = mp_link(mp->dep_head); + r = mp->dep_head->link; mp_set_link(mp->dep_final, r); mp_set_prev_dep(r, (mp_node) mp->dep_final); mp_set_link(mp->dep_head, q); @@ -14809,8 +14803,8 @@ static mp_value_node mp_copy_dep_list (MP mp, mp_value_node p) break; } else { mp_set_link(mp->dep_final, mp_get_dep_node(mp)); - mp->dep_final = (mp_value_node) mp_link(mp->dep_final); - p = (mp_value_node) mp_link(p); + mp->dep_final = (mp_value_node) mp->dep_final->link; + p = (mp_value_node) p->link; } } return q; @@ -14858,20 +14852,20 @@ static void mp_linear_eq (MP mp, mp_value_node p, int t) display_new_dependency(mp, p, (mp_node) x, n); } prev_r = (mp_value_node) mp->dep_head; - r = (mp_value_node) mp_link(mp->dep_head); + r = (mp_value_node) mp->dep_head->link; while (r != mp->dep_head) { mp_value_node s = (mp_value_node) mp_get_dep_list(r); - mp_value_node q = mp_p_with_x_becoming_q(mp, s, x, (mp_node) p, mp_type(r)); + mp_value_node q = mp_p_with_x_becoming_q(mp, s, x, (mp_node) p, r->type); if (mp_get_dep_info(q) == NULL) { mp_make_known(mp, r, q); } else { mp_set_dep_list(r, q); do { - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; } while (mp_get_dep_info(q) != NULL); prev_r = q; } - r = (mp_value_node) mp_link(prev_r); + r = (mp_value_node) prev_r->link; } if (n > 0) { p = divide_p_by_2_n(mp, p, n); @@ -14889,7 +14883,7 @@ static mp_value_node find_node_with_largest_coefficient (MP mp, mp_value_node p, mp_number vabs; /* its absolute value of v*/ mp_number rabs; /* the absolute value of |mp_get_dep_value(r)| */ mp_value_node q = p; - mp_value_node r = (mp_value_node) mp_link(p); + mp_value_node r = (mp_value_node) p->link; new_number(vabs); new_number(rabs); number_clone(*v, mp_get_dep_value(q)); @@ -14900,7 +14894,7 @@ static mp_value_node find_node_with_largest_coefficient (MP mp, mp_value_node p, q = r; number_clone(*v, mp_get_dep_value(r)); } - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; } free_number(vabs); free_number(rabs); @@ -14922,7 +14916,7 @@ static mp_value_node divide_p_by_minusv_removing_q (MP mp, mp_set_link(s, p); do { if (r == q) { - mp_set_link(s, mp_link(r)); + mp_set_link(s, r->link); mp_free_dep_node(mp, r); } else { mp_number w; /* a tentative coefficient */ @@ -14932,7 +14926,7 @@ static mp_value_node divide_p_by_minusv_removing_q (MP mp, make_fraction(w, mp_get_dep_value(r), *v); number_abs_clone(absw, w); if (number_lessequal(absw, half_fraction_threshold_k)) { - mp_set_link(s, mp_link(r)); + mp_set_link(s, r->link); mp_free_dep_node(mp, r); } else { number_negate(w); @@ -14942,7 +14936,7 @@ static mp_value_node divide_p_by_minusv_removing_q (MP mp, free_number(w); free_number(absw); } - r = (mp_value_node) mp_link(s); + r = (mp_value_node) s->link; } while (mp_get_dep_info(r) != NULL); if (t == mp_proto_dependent_type) { mp_number ret; @@ -14960,7 +14954,7 @@ static mp_value_node divide_p_by_minusv_removing_q (MP mp, free_number(ret); } *final_node = r; - return (mp_value_node) mp_link(mp->temp_head); + return (mp_value_node) mp->temp_head->link; } @ @c @@ -15007,15 +15001,15 @@ static mp_value_node divide_p_by_2_n (MP mp, mp_value_node p, int n) } number_abs_clone(absw, w); if (number_lessequal(absw, half_fraction_threshold_k) && (mp_get_dep_info(r) != NULL)) { - mp_set_link(s, mp_link(r)); + mp_set_link(s, r->link); mp_free_dep_node(mp, r); } else { mp_set_dep_value(r, w); s = r; } - r = (mp_value_node) mp_link(s); + r = (mp_value_node) s->link; } while (mp_get_dep_info(s) != NULL); - pp = (mp_value_node) mp_link(mp->temp_head); + pp = (mp_value_node) mp->temp_head->link; free_number(absw); free_number(w); } @@ -15028,7 +15022,7 @@ static void change_to_known (MP mp, mp_value_node p, mp_node x, mp_value_node fi (void) n; if (mp_get_dep_info(p) == NULL) { mp_number absx; - mp_type(x) = mp_known_type; + x->type = mp_known_type; mp_set_value_number(x, mp_get_dep_value(p)); new_number_abs(absx, mp_get_value_number(x)); if (number_greaterequal(absx, warning_limit_t)) { @@ -15083,8 +15077,8 @@ enthusiasm for such generality, unless they have lots and lots of memory space. static mp_node mp_new_ring_entry (MP mp, mp_node p) { mp_node q = mp_new_value_node(mp); /* the new capsule node */ - mp_name_type(q) = mp_capsule_operation; - mp_type(q) = mp_type(p); + q->name_type = mp_capsule_operation; + q->type = p->type; if (mp_get_value_node(p) == NULL) { mp_set_value_node(q, p); } else { @@ -15124,16 +15118,16 @@ will soon be recycled. @c static void mp_nonlinear_eq (MP mp, mp_value v, mp_node p, int flush_p) { - mp_variable_type t = mp_type(p) - unknown_tag; /* the type of ring |p| */ + mp_variable_type t = p->type - unknown_tag; /* the type of ring |p| */ mp_node q = mp_get_value_node(p); if (flush_p) { - mp_type(p) = mp_vacuous_type; + p->type = mp_vacuous_type; } else { p = q; } do { mp_node r = mp_get_value_node(q); - mp_type(q) = t; + q->type = t; switch (t) { case mp_boolean_type: mp_set_value_number(q, v.data.n); @@ -15305,7 +15299,7 @@ static void mp_show_cmd_mod (MP mp, int c, int m) mp_print_cmd_mod(mp, mp_macro_def_command, c); mp_print_str(mp, "'d macro:"); mp_print_ln(mp); - mp_show_token_list(mp, mp_link(mp_link(cur_mod_node)),0); + mp_show_token_list(mp, cur_mod_node->link->link,0); break; default: mp_print_cmd_mod(mp, c, m); @@ -15697,7 +15691,7 @@ capsule~|p| in abbreviated form. mp_node pp = mp->param_stack[param_start]; mp_print_nl(mp, "<for("); if (pp != NULL) { - if (mp_link(pp) == MP_VOID) { + if (pp->link == MP_VOID) { mp_print_exp(mp, pp, 0); /* we're in a |for| loop */ } else { mp_show_token_list(mp, pp, NULL); @@ -15717,12 +15711,12 @@ together, we get the macro's full name. mp_show_token_list(mp, mp->param_stack[param_start + 1], NULL); } else { mp_node qq = pp; - while (mp_link(qq) != NULL) { - qq = mp_link(qq); + while (qq->link != NULL) { + qq = qq->link; } - mp_link(qq) = mp->param_stack[param_start + 1]; + qq->link = mp->param_stack[param_start + 1]; mp_show_token_list(mp, pp, NULL); - mp_link(qq) = NULL; + qq->link = NULL; } } @@ -15811,7 +15805,7 @@ static void mp_end_token_list (MP mp) --mp->param_ptr; p = mp->param_stack[mp->param_ptr]; if (p != NULL) { - if (mp_link(p) == MP_VOID) { + if (p->link == MP_VOID) { /* it's an |expr| parameter */ mp_recycle_value(mp, p); mp_free_value_node(mp, p); @@ -15842,25 +15836,25 @@ static mp_node mp_cur_tok (MP mp) number_clone(save_exp_num, cur_exp_value_number); mp_make_exp_copy(mp, cur_mod_node); p = mp_stash_cur_exp(mp); - mp_link(p) = NULL; + p->link = NULL; mp->cur_exp = save_exp; number_clone(mp->cur_exp.data.n, save_exp_num); free_number(save_exp_num); } else { p = mp_new_token_node(mp); - mp_name_type(p) = mp_token_operation; + p->name_type = mp_token_operation; if (cur_cmd == mp_numeric_command) { mp_set_value_number(p, cur_mod_number); - mp_type(p) = mp_known_type; + p->type = mp_known_type; } else { mp_set_value_str(p, cur_mod_str); - mp_type(p) = mp_string_type; + p->type = mp_string_type; } } } else { p = mp_new_symbolic_node(mp); mp_set_sym_sym(p, cur_sym); - mp_name_type(p) = cur_sym_mod; + p->name_type = cur_sym_mod; } return p; } @@ -16063,7 +16057,7 @@ if (cur_sym != NULL) { // if (cur_sym != NULL) { // mp_node p = mp_new_symbolic_node(mp); // mp_set_sym_sym(p, cur_sym); -// mp_name_type(p) = cur_sym_mod; +// p->name_type = cur_sym_mod; // /* prepare to read the symbolic token again */ // mp_begin_token_list(mp, p, mp_backed_up_text); // } @@ -16170,7 +16164,7 @@ void mp_runaway (MP mp) break; } mp_print_ln(mp); - mp_show_token_list(mp, mp_link(mp->hold_head), NULL); + mp_show_token_list(mp, mp->hold_head->link, NULL); } } @@ -16266,7 +16260,7 @@ void mp_get_next (MP mp) ); goto RESTART; } - mp_str_room(mp, (size_t) (loc - k)); + mp_str_room(mp, loc - k); do { mp_append_char(mp, mp->buffer[k]); ++k; @@ -16316,14 +16310,14 @@ void mp_get_next (MP mp) Input from token list; |goto restart| if end of list or if a parameter needs to be expanded, or |return| if a non-symbolic token is found. */ - if (nloc != NULL && mp_type(nloc) == mp_symbol_node_type) { + if (nloc != NULL && nloc->type == mp_symbol_node_type) { /* symbolic token */ - int cur_sym_mod_ = mp_name_type(nloc); + int cur_sym_mod_ = nloc->name_type; int cur_info = mp_get_sym_info(nloc); set_cur_sym(mp_get_sym_sym(nloc)); set_cur_sym_mod(cur_sym_mod_); /* move to next */ - nloc = mp_link(nloc); + nloc = nloc->link; if (cur_sym_mod_ == mp_expr_operation) { set_cur_cmd(mp_capsule_command); set_cur_mod_node(mp->param_stack[param_start + cur_info]); @@ -16336,8 +16330,8 @@ void mp_get_next (MP mp) } } else if (nloc != NULL) { /* Get a stored numeric or string or capsule token and |return| */ - if (mp_name_type(nloc) == mp_token_operation) { - if (mp_type(nloc) == mp_known_type) { + if (nloc->name_type == mp_token_operation) { + if (nloc->type == mp_known_type) { set_cur_mod_number(mp_get_value_number(nloc)); set_cur_cmd(mp_numeric_command); } else { @@ -16349,7 +16343,7 @@ void mp_get_next (MP mp) set_cur_mod_node(nloc); set_cur_cmd(mp_capsule_command); } - nloc = mp_link(nloc); + nloc = nloc->link; return; } else { /* we are done with this token list */ @@ -16648,7 +16642,7 @@ static mp_node mp_scan_toks (MP mp, mp_command_code terminator, mp_subst_list_it int cur_data_mod = 0; mp_node p = mp->hold_head; /* tail of the token list being built */ int balance = 1; /* left delimiters minus right delimiters */ - mp_link(mp->hold_head) = NULL; + mp->hold_head->link = NULL; while (1) { get_t_next(mp); cur_data = -1; @@ -16669,20 +16663,20 @@ static mp_node mp_scan_toks (MP mp, mp_command_code terminator, mp_subst_list_it if (cur_data != -1) { mp_node pp = mp_new_symbolic_node(mp); mp_set_sym_info(pp, cur_data); - mp_name_type(pp) = cur_data_mod; - mp_link(p) = pp; + pp->name_type = cur_data_mod; + p->link = pp; } else { - mp_link(p) = mp_cur_tok(mp); + p->link = mp_cur_tok(mp); } - p = mp_link(p); + p = p->link; } - mp_link(p) = tail_end; + p->link = tail_end; while (subst_list) { mp_subst_list_item *q = subst_list->link; mp_memory_free(subst_list); subst_list = q; } - return mp_link(mp->hold_head); + return mp->hold_head->link; } @ @<Substitute for |cur_sym|...@>= @@ -16838,10 +16832,10 @@ static void mp_make_op_def (MP mp, int code) q = mp_new_symbolic_node(mp); mp_set_ref_count(q, 0); r = mp_new_symbolic_node(mp); - mp_link(q) = r; + q->link = r; mp_set_sym_info(r, mp_general_macro); - mp_name_type(r) = mp_macro_operation; - mp_link(r) = mp_scan_toks(mp, mp_macro_def_command, qn, NULL, 0); + r->name_type = mp_macro_operation; + r->link = mp_scan_toks(mp, mp_macro_def_command, qn, NULL, 0); mp->scanner_status = mp_normal_state; set_eq_type(mp->warning_info, m); set_equiv_node(mp->warning_info, q); @@ -16898,7 +16892,7 @@ static void mp_scan_def (MP mp, int code) int sym_type; /* |expr_sym|, |suffix_sym|, or |text_sym| */ mp_sym l_delim, r_delim; /* matching delimiters */ int c = mp_general_macro; /* the kind of macro we're defining */ - mp_link(mp->hold_head) = NULL; + mp->hold_head->link = NULL; q = mp_new_symbolic_node(mp); mp_set_ref_count(q, 0); r = NULL; @@ -16917,7 +16911,7 @@ static void mp_scan_def (MP mp, int code) } else { /* |var_def| */ p = mp_scan_declared_variable(mp); - mp_flush_variable(mp, equiv_node(mp_get_sym_sym(p)), mp_link(p), 1); + mp_flush_variable(mp, equiv_node(mp_get_sym_sym(p)), p->link, 1); mp->warning_info_node = mp_find_variable(mp, p); mp_flush_node_list(mp, p); if (mp->warning_info_node == NULL) { @@ -16936,7 +16930,7 @@ static void mp_scan_def (MP mp, int code) n = 3; get_t_next(mp); } - mp_type(mp->warning_info_node) = mp_unsuffixed_macro_type - 2 + n; + mp->warning_info_node->type = mp_unsuffixed_macro_type - 2 + n; /* |mp_suffixed_macro=mp_unsuffixed_macro+1| */ mp_set_value_node(mp->warning_info_node, q); } @@ -16974,9 +16968,9 @@ static void mp_scan_def (MP mp, int code) OKAY: /* Absorb parameter tokens for type |sym_type| */ do { - mp_link(q) = mp_new_symbolic_node(mp); - q = mp_link(q); - mp_name_type(q) = sym_type; + q->link = mp_new_symbolic_node(mp); + q = q->link; + q->name_type = sym_type; mp_set_sym_info(q, k); mp_get_symbol(mp); rp = mp_memory_allocate(sizeof(mp_subst_list_item)); @@ -17046,22 +17040,22 @@ static void mp_scan_def (MP mp, int code) mp_check_equals(mp); p = mp_new_symbolic_node(mp); mp_set_sym_info(p, c); - mp_name_type(p) = mp_macro_operation; - mp_link(q) = p; + p->name_type = mp_macro_operation; + q->link = p; /* Attach the replacement text to the tail of node |p|. We don't put |mp->frozen_end_group| into the replacement text of a |vardef|, because the user may want to redefine |endgroup|. */ if (code == mp_def_code) { - mp_link(p) = mp_scan_toks(mp, mp_macro_def_command, r, NULL, (int) n); + p->link = mp_scan_toks(mp, mp_macro_def_command, r, NULL, (int) n); } else { mp_node qq = mp_new_symbolic_node(mp); mp_set_sym_sym(qq, mp->bg_loc); - mp_link(p) = qq; + p->link = qq; p = mp_new_symbolic_node(mp); mp_set_sym_sym(p, mp->eg_loc); - mp_link(qq) = mp_scan_toks(mp, mp_macro_def_command, r, p, (int) n); + qq->link = mp_scan_toks(mp, mp_macro_def_command, r, p, (int) n); } if (mp->warning_info_node == mp->bad_vardef) { mp_flush_token_list(mp, mp_get_value_node(mp->bad_vardef)); @@ -17076,7 +17070,7 @@ mp_sym eg_loc; /* hash addresses of |begingroup| and |endgroup| */ @ @<Initialize table entries@>= mp->bad_vardef = mp_new_value_node(mp); -mp_name_type(mp->bad_vardef) = mp_root_operation; +mp->bad_vardef->name_type = mp_root_operation; mp_set_value_sym(mp->bad_vardef, mp->frozen_bad_vardef); @ @<Free table entries@>= @@ -17722,11 +17716,11 @@ static void mp_macro_call (MP mp, mp_node def_ref, mp_node arg_list, mp_sym macr @c static void mp_macro_call (MP mp, mp_node def_ref, mp_node arg_list, mp_sym macro_name) { - int n; /* the number of arguments */ - mp_node tail = 0; /* tail of the argument list */ - mp_sym l_delim = NULL; /* a delimiter pair */ - mp_sym r_delim = NULL; /* a delimiter pair */ - mp_node r = mp_link(def_ref); /* current node in the macro's token list */ + int n; /* the number of arguments */ + mp_node tail = 0; /* tail of the argument list */ + mp_sym l_delim = NULL; /* a delimiter pair */ + mp_sym r_delim = NULL; /* a delimiter pair */ + mp_node r = def_ref->link; /* current node in the macro's token list */ mp_add_mac_ref(def_ref); if (arg_list == NULL) { n = 0; @@ -17755,7 +17749,7 @@ if (arg_list != NULL) { mp_node q = (mp_node) mp_get_sym_sym(p); mp_print_arg(mp, q, n, 0, 0); ++n; - p = mp_link(p); + p = p->link; } while (p != NULL); } mp_end_diagnostic(mp, 0); @@ -17772,14 +17766,14 @@ static void mp_print_macro_name (MP mp, mp_node a, mp_sym n) mp_node p = (mp_node) mp_get_sym_sym(a); if (p) { mp_node q = p; /* they traverse the first part of |a| */ - while (mp_link(q) != NULL) { - q = mp_link(q); + while (q->link != NULL) { + q = q->link; } - mp_link(q) = (mp_node) mp_get_sym_sym(mp_link(a)); + q->link = (mp_node) mp_get_sym_sym(a->link); mp_show_token_list(mp, p, NULL); - mp_link(q) = NULL; + q->link = NULL; } else { - mp_print_mp_str(mp,text(mp_get_sym_sym((mp_node) mp_get_sym_sym(mp_link(a))))); + mp_print_mp_str(mp,text(mp_get_sym_sym((mp_node) mp_get_sym_sym(a->link)))); } } } @@ -17790,7 +17784,7 @@ static void mp_print_arg (MP mp, mp_node q, int n, int b, int bb); @ @c static void mp_print_arg (MP mp, mp_node q, int n, int b, int bb) { - if (q && mp_link(q) == MP_VOID) { + if (q && q->link == MP_VOID) { mp_print_nl(mp, "(EXPR"); } else if ((bb < mp_text_operation) && (b != mp_text_macro)) { mp_print_nl(mp, "(SUFFIX"); @@ -17799,7 +17793,7 @@ static void mp_print_arg (MP mp, mp_node q, int n, int b, int bb) } mp_print_int(mp, n); mp_print_str(mp, ")<-"); - if (q && mp_link(q) == MP_VOID) { + if (q && q->link == MP_VOID) { mp_print_exp(mp, q, 1); } else { mp_show_token_list(mp, q, NULL); @@ -17809,16 +17803,16 @@ static void mp_print_arg (MP mp, mp_node q, int n, int b, int bb) @ @<Determine the number |n| of arguments already supplied...@>= n = 1; tail = arg_list; -while (mp_link(tail) != NULL) { +while (tail->link != NULL) { ++n; - tail = mp_link(tail); + tail = tail->link; } @ @<Scan the remaining arguments, if any; set |r|...@>= set_cur_cmd(mp_comma_command + 1); /* anything |<>comma| will do */ -while (mp_name_type(r) == mp_expr_operation || mp_name_type(r) == mp_suffix_operation || mp_name_type(r) == mp_text_operation) { +while (r->name_type == mp_expr_operation || r->name_type == mp_suffix_operation || r->name_type == mp_text_operation) { @<Scan the delimited argument represented by |mp_get_sym_info(r)|@> - r = mp_link(r); + r = r->link; } if (cur_cmd == mp_comma_command) { char msg[256]; @@ -17843,7 +17837,7 @@ if (cur_cmd == mp_comma_command) { if (mp_get_sym_info(r) != mp_general_macro) { @<Scan undelimited argument(s)@> } -r = mp_link(r); +r = r->link; @ At this point, the reader will find it advisable to review the explanation of token list format that was presented earlier, paying special attention to the @@ -17868,7 +17862,7 @@ if (cur_cmd != mp_comma_command) { mp_snprintf(msg, 256, "Missing argument to %s", mp_str(mp, sname)); @.Missing argument...@> delete_str_ref(sname); - if (mp_name_type(r) == mp_suffix_operation || mp_name_type(r) == mp_text_operation) { + if (r->name_type == mp_suffix_operation || r->name_type == mp_text_operation) { mp_set_cur_exp_value_number(mp, &zero_t); /* todo: this was |null| */ mp->cur_exp.type = mp_token_list_type; } else { @@ -17889,7 +17883,7 @@ if (cur_cmd != mp_comma_command) { } @<Scan the argument represented by |mp_get_sym_info(r)|@> if ((cur_cmd != mp_comma_command) && ((cur_cmd != mp_right_delimiter_command) || (equiv_sym(cur_sym) != l_delim))) { - switch (mp_name_type(mp_link(r))) { + switch (r->link->name_type) { case mp_expr_operation: case mp_suffix_operation: case mp_text_operation: @@ -17930,24 +17924,24 @@ pointed to by |cur_exp|, in which case we will have |cur_type=token_list|. } if (number_positive(internal_value(mp_tracing_macros_internal))) { mp_begin_diagnostic(mp); - mp_print_arg(mp, (mp_node) mp_get_sym_sym(p), n, mp_get_sym_info(r), mp_name_type(r)); + mp_print_arg(mp, (mp_node) mp_get_sym_sym(p), n, mp_get_sym_info(r), r->name_type); mp_end_diagnostic(mp, 0); } if (arg_list == NULL) { arg_list = p; } else { - mp_link(tail) = p; + tail->link = p; } tail = p; ++n; } @ @<Scan the argument represented by |mp_get_sym_info(r)|@>= -if (mp_name_type(r) == mp_text_operation) { +if (r->name_type == mp_text_operation) { mp_scan_text_arg(mp, l_delim, r_delim); } else { mp_get_x_next(mp); - if (mp_name_type(r) == mp_suffix_operation) { + if (r->name_type == mp_suffix_operation) { mp_scan_suffix(mp); } else { mp_scan_expression(mp); @@ -17968,7 +17962,7 @@ void mp_scan_text_arg (MP mp, mp_sym l_delim, mp_sym r_delim) mp->warning_info = l_delim; mp->scanner_status = mp_absorbing_state; mp_node p = mp->hold_head; /* list tail */ - mp_link(mp->hold_head) = NULL; + mp->hold_head->link = NULL; while (1) { get_t_next(mp); if (l_delim == NULL) { @@ -17976,10 +17970,10 @@ void mp_scan_text_arg (MP mp, mp_sym l_delim, mp_sym r_delim) } else { @<Adjust the balance for a delimited argument; |break| if done@> } - mp_link(p) = mp_cur_tok(mp); - p = mp_link(p); + p->link = mp_cur_tok(mp); + p = p->link; } - mp_set_cur_exp_node(mp, mp_link(mp->hold_head)); + mp_set_cur_exp_node(mp, mp->hold_head->link); mp->cur_exp.type = mp_token_list_type; mp->scanner_status = mp_normal_state; } @@ -18062,7 +18056,7 @@ if (number_positive(internal_value(mp_tracing_macros_internal))) { if (arg_list == NULL) { arg_list = p; } else { - mp_link(tail) = p; + tail->link = p; } tail = p; ++n; @@ -18123,7 +18117,7 @@ if (n > 0) { do { mp->param_stack[mp->param_ptr] = (mp_node) mp_get_sym_sym(p); ++mp->param_ptr; - p = mp_link(p); + p = p->link; } while (p != NULL); mp_flush_node_list(mp, arg_list); } @@ -18184,7 +18178,7 @@ typedef struct mp_if_node_data *mp_if_node; @c static mp_node mp_get_if_node (MP mp) { mp_if_node p = (mp_if_node) mp_allocate_node(mp, sizeof(mp_if_node_data)); - mp_type(p) = mp_if_node_type; + p->type = mp_if_node_type; return (mp_node) p; } @@ -18272,9 +18266,9 @@ static void mp_pop_condition_stack (MP mp); static void mp_push_condition_stack (MP mp) { mp_node p = mp_get_if_node(mp); - mp_link(p) = mp->cond_ptr; - mp_type(p) = (int) mp->if_limit; - mp_name_type(p) = mp->cur_if; + p->link = mp->cond_ptr; + p->type = (int) mp->if_limit; + p->name_type = mp->cur_if; mp_if_line_field(p) = mp->if_line; mp->cond_ptr = p; mp->if_limit = mp_if_code; @@ -18286,9 +18280,9 @@ static void mp_pop_condition_stack (MP mp) { mp_node p = mp->cond_ptr; mp->if_line = mp_if_line_field(p); - mp->cur_if = mp_name_type(p); - mp->if_limit = mp_type(p); - mp->cond_ptr = mp_link(p); + mp->cur_if = p->name_type; + mp->if_limit = p->type; + mp->cond_ptr = p->link; mp_free_node(mp, p, sizeof(mp_if_node_data)); } @ Here's a procedure that changes the |if_limit| code corresponding to @@ -18307,11 +18301,11 @@ static void mp_change_if_limit (MP mp, int l, mp_node p) mp_confusion(mp, "if"); @:this can't happen if}{\quad if@> return; - } else if (mp_link(q) == p) { - mp_type(q) = l; + } else if (q->link == p) { + q->type = l; return; } else { - q = mp_link(q); + q = q->link; } } } @@ -18663,7 +18657,7 @@ void mp_resume_iteration (MP mp) p = mp->loop_ptr->list; if (p != NULL && p == mp->loop_ptr->list_start) { q = p; - p = mp_link(p); + p = p->link; mp_free_symbolic_node(mp, q); mp->loop_ptr->list = p; } @@ -18671,7 +18665,7 @@ void mp_resume_iteration (MP mp) mp_stop_iteration(mp); return; } - mp->loop_ptr->list = mp_link(p); + mp->loop_ptr->list = p->link; q = (mp_node) mp_get_sym_sym(p); if (q) { number_clone(mp->loop_ptr->old_value, q->data.n); @@ -18697,7 +18691,7 @@ void mp_resume_iteration (MP mp) mp_begin_diagnostic(mp); mp_print_nl(mp, "{loop value="); @.loop value=n@> -if ((q != NULL) && (mp_link(q) == MP_VOID)) { +if ((q != NULL) && (q->link == MP_VOID)) { mp_print_exp(mp, q, 1); } else { mp_show_token_list(mp, q, NULL); @@ -18710,7 +18704,7 @@ q = mp->loop_ptr->list; if (q == NULL) { goto NOT_FOUND; } else if (! mp_is_start_or_stop(q)) { - q = mp_link(q); + q = q->link; } else if (! mp_is_stop(q)) { q = mp_skip_1component(mp, q); } else { @@ -18740,7 +18734,7 @@ void mp_stop_iteration (MP mp) while (q != NULL) { p = (mp_node) mp_get_sym_sym(q); if (p != NULL) { - if (mp_link(p) == MP_VOID) { + if (p->link == MP_VOID) { /* it's an |expr| parameter */ mp_recycle_value(mp, p); mp_free_value_node(mp, p); @@ -18750,7 +18744,7 @@ void mp_stop_iteration (MP mp) } } p = q; - q = mp_link(q); + q = q->link; mp_free_symbolic_node(mp, p); } } else if (p > MP_PROGRESSION_FLAG) { @@ -18793,13 +18787,13 @@ do { } mp_set_cur_exp_node(mp, mp_stash_cur_exp(mp)); } - mp_link(q) = mp_new_symbolic_node(mp); - q = mp_link(q); + q->link = mp_new_symbolic_node(mp); + q = q->link; mp_set_sym_sym(q, mp->cur_exp.data.node); if (m == mp_start_for_code) { - mp_name_type(q) = mp_expr_operation; + q->name_type = mp_expr_operation; } else if (m == mp_start_forsuffixes_code) { - mp_name_type(q) = mp_suffix_operation; + q->name_type = mp_suffix_operation; } mp->cur_exp.type = mp_vacuous_type; CONTINUE: @@ -18875,9 +18869,9 @@ if (mp->cur_exp.type == mp_path_type) { @<Make sure the current expression is a known picture@> s->type = mp->cur_exp.data.node; mp->cur_exp.type = mp_vacuous_type; - q = mp_link(mp_edge_list(mp->cur_exp.data.node)); + q = mp_edge_list(mp->cur_exp.data.node)->link; if (q != NULL && mp_is_start_or_stop (q) && mp_skip_1component(mp, q) == NULL) { - q = mp_link(q); + q = q->link; } s->list = q; } @@ -19508,8 +19502,8 @@ static mp_node mp_stash_cur_exp (MP mp) break; default: /* |case mp_path_type: case mp_pen_type: case mp_string_type:| */ p = mp_new_value_node(mp); - mp_name_type(p) = mp_capsule_operation; - mp_type(p) = mp->cur_exp.type; + p->name_type = mp_capsule_operation; + p->type = mp->cur_exp.type; mp_set_value_number(p, cur_exp_value_number); /* this also resets the rest to 0/NULL */ if (cur_exp_str) { mp_set_value_str(p, cur_exp_str); @@ -19521,7 +19515,7 @@ static mp_node mp_stash_cur_exp (MP mp) break; } mp->cur_exp.type = mp_vacuous_type; - mp_link(p) = MP_VOID; + p->link = MP_VOID; return p; } @@ -19547,7 +19541,7 @@ resuscitates them. @ @c void mp_unstash_cur_exp (MP mp, mp_node p) { - mp->cur_exp.type = mp_type(p); + mp->cur_exp.type = p->type; switch (mp->cur_exp.type) { case mp_unknown_boolean_type: case mp_unknown_string_type: @@ -19629,7 +19623,7 @@ void mp_print_exp (MP mp, mp_node p, int verbosity) p = mp_stash_cur_exp(mp); restore_cur_exp = 1; } - t = mp_type(p); + t = p->type; if (t < mp_dependent_type) { /* no dep list, could be a capsule */ if (t != mp_vacuous_type && t != mp_known_type && mp_get_value_node(p) != NULL) { @@ -19649,7 +19643,7 @@ void mp_print_exp (MP mp, mp_node p, int verbosity) void mp_print_big_node (MP mp, mp_node v, int verbosity) { - switch (mp_type(v)) { + switch (v->type) { case mp_known_type: print_number(mp_get_value_number(v)); break; @@ -19657,7 +19651,7 @@ void mp_print_big_node (MP mp, mp_node v, int verbosity) mp_print_variable_name(mp, v); break; default: - mp_print_dp(mp, mp_type(v), (mp_value_node) mp_get_dep_list((mp_value_node) v), verbosity); + mp_print_dp(mp, v->type, (mp_value_node) mp_get_dep_list((mp_value_node) v), verbosity); break; } } @@ -19816,7 +19810,7 @@ if (verbosity <= 1) { @ @c static void mp_print_dp (MP mp, int t, mp_value_node p, int verbosity) { - mp_value_node q = (mp_value_node) mp_link(p); /* the node following |p| */ + mp_value_node q = (mp_value_node) p->link; /* the node following |p| */ if ((mp_get_dep_info(q) == NULL) || (verbosity > 0)) { mp_print_dependency(mp, p, t); } else { @@ -19832,7 +19826,7 @@ the ring consists entirely of capsules. mp_print_type(mp, t); if (v != NULL) { mp_print_chr(mp, ' '); - while ((mp_name_type(v) == mp_capsule_operation) && (v != p)) { + while ((v->name_type == mp_capsule_operation) && (v != p)) { v = mp_get_value_node(v); } mp_print_variable_name(mp, v); @@ -19914,7 +19908,7 @@ static void mp_recycle_value (MP mp, mp_node p); static void mp_recycle_value (MP mp, mp_node p) { if (p != NULL && p != MP_VOID) { - mp_variable_type t = mp_type(p); + mp_variable_type t = p->type; switch (t) { case mp_vacuous_type: case mp_boolean_type: @@ -19996,10 +19990,10 @@ static void mp_recycle_value (MP mp, mp_node p) { mp_value_node qq = (mp_value_node) mp_get_dep_list((mp_value_node) p); while (mp_get_dep_info(qq) != NULL) { - qq = (mp_value_node) mp_link(qq); + qq = (mp_value_node) qq->link; } - mp_set_link(mp_get_prev_dep((mp_value_node) p), mp_link(qq)); - mp_set_prev_dep(mp_link(qq), mp_get_prev_dep((mp_value_node) p)); + mp_set_link(mp_get_prev_dep((mp_value_node) p), qq->link); + mp_set_prev_dep(qq->link, mp_get_prev_dep((mp_value_node) p)); mp_set_link(qq, NULL); mp_flush_node_list(mp, (mp_node) mp_get_dep_list((mp_value_node) p)); } @@ -20018,7 +20012,7 @@ static void mp_recycle_value (MP mp, mp_node p) default: break; } - mp_type(p) = mp_undefined_type; + p->type = mp_undefined_type; } } @@ -20056,7 +20050,7 @@ static void mp_recycle_independent_value (MP mp, mp_node p) mp_node pp; /* link manipulation register */ mp_number v ; /* a value */ mp_number test; /* a temporary value */ - mp_variable_type t = mp_type(p); + mp_variable_type t = p->type; new_number(test); new_number(v); if (t < mp_dependent_type) { @@ -20066,23 +20060,23 @@ static void mp_recycle_independent_value (MP mp, mp_node p) set_number_to_zero(mp->max_c[mp_proto_dependent_type]); mp->max_link[mp_dependent_type] = NULL; mp->max_link[mp_proto_dependent_type] = NULL; - q = (mp_value_node) mp_link(mp->dep_head); + q = (mp_value_node) mp->dep_head->link; while (q != mp->dep_head) { s = (mp_value_node) mp->temp_head; mp_set_link(s, mp_get_dep_list(q)); while (1) { - r = (mp_value_node) mp_link(s); + r = (mp_value_node) s->link; if (mp_get_dep_info(r) == NULL) { break; } else if (mp_get_dep_info(r) != p) { s = r; } else { - t = mp_type(q); - if (mp_link(s) == mp_get_dep_list(q)) { + t = q->type; + if (s->link == mp_get_dep_list(q)) { /* reset the |dep_list| */ - mp_set_dep_list(q, mp_link(r)); + mp_set_dep_list(q, r->link); } - mp_set_link(s, mp_link(r)); + mp_set_link(s, r->link); mp_set_dep_info(r, (mp_node) q); number_abs_clone(test, mp_get_dep_value(r)); if (number_greater(test, mp->max_c[t])) { @@ -20099,7 +20093,7 @@ static void mp_recycle_independent_value (MP mp, mp_node p) } } } - q = (mp_value_node) mp_link(r); + q = (mp_value_node) r->link; } if (number_positive(mp->max_c[mp_dependent_type]) || number_positive(mp->max_c[mp_proto_dependent_type])) { /* @@ -20140,9 +20134,9 @@ static void mp_recycle_independent_value (MP mp, mp_node p) r = (mp_value_node) mp_get_dep_list((mp_value_node) pp); mp_set_link(s, r); while (mp_get_dep_info(r) != NULL) { - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; } - q = (mp_value_node) mp_link(r); + q = (mp_value_node) r->link; mp_set_link(r, NULL); mp_set_prev_dep(q, mp_get_prev_dep((mp_value_node) pp)); mp_set_link(mp_get_prev_dep((mp_value_node) pp), (mp_node) q); @@ -20180,7 +20174,7 @@ static void mp_recycle_independent_value (MP mp, mp_node p) mp_make_known(mp, q, mp->dep_final); } q = r; - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; mp_free_dep_node(mp, q); } } @@ -20196,7 +20190,7 @@ static void mp_recycle_independent_value (MP mp, mp_node p) mp->cur_exp.type = mp_proto_dependent_type; } mp_set_dep_list(q, mp_p_over_v(mp, (mp_value_node) mp_get_dep_list(q), &unity_t, mp_dependent_type, mp_proto_dependent_type)); - mp_type(q) = mp_proto_dependent_type; + q->type = mp_proto_dependent_type; fraction_to_round_scaled(mp_get_dep_value(r)); } number_negated_clone(test, v); @@ -20206,7 +20200,7 @@ static void mp_recycle_independent_value (MP mp, mp_node p) mp_make_known(mp, q, mp->dep_final); } q = r; - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; mp_free_dep_node(mp, q); } } @@ -20360,7 +20354,7 @@ void mp_scan_primary (MP mp) mp_node q = mp_new_value_node(mp); mp_node p1 = mp_stash_cur_exp(mp); mp_node r; /* temporary node */ - mp_name_type(q) = mp_capsule_operation; + q->name_type = mp_capsule_operation; mp_get_x_next(mp); mp_scan_expression(mp); /* Make sure the second part of a pair or color has a numeric type */ @@ -20449,7 +20443,7 @@ void mp_scan_primary (MP mp) } } mp_check_delimiter(mp, l_delim, r_delim); - mp->cur_exp.type = mp_type(q); + mp->cur_exp.type = q->type; mp_set_cur_exp_node(mp, q); } else { mp_check_delimiter(mp, l_delim, r_delim); @@ -20655,7 +20649,7 @@ void mp_scan_primary (MP mp) if (cur_cmd == mp_assignment_command) { mp_set_cur_exp_node(mp, mp_new_symbolic_node(mp)); mp_set_sym_info(cur_exp_node, qq); - mp_name_type(cur_exp_node) = mp_internal_operation; + cur_exp_node->name_type = mp_internal_operation; mp->cur_exp.type = mp_token_list_type; goto DONE; } @@ -20779,7 +20773,7 @@ within a \quote {big node.} @c static void mp_stash_in (MP mp, mp_node p) { - mp_type(p) = mp->cur_exp.type; + p->type = mp->cur_exp.type; if (mp->cur_exp.type == mp_known_type) { mp_set_value_number(p, cur_exp_value_number); } else if (mp->cur_exp.type == mp_independent_type) { @@ -20791,7 +20785,7 @@ static void mp_stash_in (MP mp, mp_node p) */ mp_value_node q = mp_single_dependency(mp, cur_exp_node); if (q == mp->dep_final) { - mp_type(p) = mp_known_type; + p->type = mp_known_type; mp_set_value_number(p, zero_t); mp_free_dep_node(mp, q); } else { @@ -20838,7 +20832,7 @@ the precise value of |tt| isn't critical. mp_node post_head = NULL; while (1) { t = mp_cur_tok(mp); - mp_link(tail) = t; + tail->link = t; if (tt != mp_undefined_type) { /* Find the approximate type |tt| and corresponding~|q|. Every time we call @@ -20847,7 +20841,7 @@ the precise value of |tt| isn't critical. variable structure; we need to start searching from the root each time. */ mp_sym qq; - p = mp_link(pre_head); + p = pre_head->link; qq = mp_get_sym_sym(p); tt = mp_undefined_type; // if (eq_type(qq) % mp_outer_tag_command == mp_tag_command) { @@ -20857,19 +20851,19 @@ the precise value of |tt| isn't critical. goto DONE2; } while (1) { - p = mp_link(p); + p = p->link; if (p == NULL) { - tt = mp_type(q); + tt = q->type; goto DONE2; } - if (mp_type(q) != mp_structured_type) { + if (q->type != mp_structured_type) { goto DONE2; } - q = mp_link(mp_get_attribute_head(q)); /* the |mp_collective_subscript| attribute */ - if (mp_type(p) == mp_symbol_node_type) { + q = mp_get_attribute_head(q)->link; /* the |mp_collective_subscript| attribute */ + if (p->type == mp_symbol_node_type) { /* it's not a subscript */ do { - q = mp_link(q); + q = q->link; } while (! (mp_get_hashloc(q) >= mp_get_sym_sym(p))); if (mp_get_hashloc(q) > mp_get_sym_sym(p)) { goto DONE2; @@ -20880,12 +20874,12 @@ the precise value of |tt| isn't critical. DONE2: if (tt >= mp_unsuffixed_macro_type) { /* Either begin an unsuffixed macro call or prepare for a suffixed one */ - mp_link(tail) = NULL; + tail->link = NULL; if (tt > mp_unsuffixed_macro_type) { /* |tt=mp_suffixed_macro| */ post_head = mp_new_symbolic_node(mp); tail = post_head; - mp_link(tail) = t; + tail->link = t; tt = mp_undefined_type; macro_ref = mp_get_value_node(q); mp_add_mac_ref(macro_ref); @@ -20897,8 +20891,8 @@ the precise value of |tt| isn't critical. appropriate list of lists. */ p = mp_new_symbolic_node(mp); - mp_set_sym_sym(pre_head, mp_link(pre_head)); - mp_link(pre_head) = p; + mp_set_sym_sym(pre_head, pre_head->link); + pre_head->link = p; mp_set_sym_sym(p, t); mp_macro_call(mp, mp_get_value_node(q), pre_head, NULL); mp_get_x_next(mp); @@ -20958,19 +20952,19 @@ the precise value of |tt| isn't critical. */ mp_back_input(mp); p = mp_new_symbolic_node(mp); - q = mp_link(post_head); - mp_set_sym_sym(pre_head, mp_link(pre_head)); - mp_link(pre_head) = post_head; + q = post_head->link; + mp_set_sym_sym(pre_head, pre_head->link); + pre_head->link = post_head; mp_set_sym_sym(post_head, q); - mp_link(post_head) = p; - mp_set_sym_sym(p, mp_link(q)); - mp_link(q) = NULL; + post_head->link = p; + mp_set_sym_sym(p, q->link); + q->link = NULL; mp_macro_call(mp, macro_ref, pre_head, NULL); mp_decr_mac_ref(macro_ref); mp_get_x_next(mp); goto RESTART; } - q = mp_link(pre_head); + q = pre_head->link; mp_free_symbolic_node(mp, pre_head); if (cur_cmd == my_var_flag) { mp->cur_exp.type = mp_token_list_type; @@ -21006,7 +21000,7 @@ the precise value of |tt| isn't critical. static void mp_back_expr (MP mp) { mp_node p = mp_stash_cur_exp(mp); /* capsule token */ - mp_link(p) = NULL; + p->link = NULL; mp_begin_token_list(mp, p, mp_backed_up_text); } @@ -21071,7 +21065,7 @@ multiplicity of possible cases. static void mp_make_exp_copy (MP mp, mp_node p) { RESTART: - mp->cur_exp.type = mp_type(p); + mp->cur_exp.type = p->type; switch (mp->cur_exp.type) { case mp_vacuous_type: case mp_boolean_type: @@ -21117,7 +21111,7 @@ static void mp_make_exp_copy (MP mp, mp_node p) mp_node t; mp_value_node q; if (mp_get_value_node(p) == NULL) { - switch (mp_type(p)) { + switch (p->type) { case mp_pair_type: mp_init_pair_node(mp, p); break; @@ -21135,7 +21129,7 @@ static void mp_make_exp_copy (MP mp, mp_node p) } } t = mp_new_value_node(mp); - mp_name_type(t) = mp_capsule_operation; + t->name_type = mp_capsule_operation; q = (mp_value_node) mp_get_value_node(p); switch (mp->cur_exp.type) { case mp_pair_type: @@ -21208,7 +21202,7 @@ list~|p|. static void mp_encapsulate (MP mp, mp_value_node p) { mp_node q = mp_new_value_node(mp); - mp_name_type(q) = mp_capsule_operation; + q->name_type = mp_capsule_operation; mp_new_dep(mp, q, mp->cur_exp.type, p); mp_set_cur_exp_node(mp, q); } @@ -21219,20 +21213,20 @@ a big node that will be part of a capsule. @<Declare subroutines needed by |make_exp_copy|@>= static void mp_install (MP mp, mp_node r, mp_node q) { - if (mp_type(q) == mp_known_type) { - mp_type(r) = mp_known_type; + if (q->type == mp_known_type) { + r->type = mp_known_type; mp_set_value_number(r, mp_get_value_number(q)); - } else if (mp_type(q) == mp_independent_type) { + } else if (q->type == mp_independent_type) { mp_value_node p = mp_single_dependency(mp, q); if (p == mp->dep_final) { - mp_type(r) = mp_known_type; + r->type = mp_known_type; mp_set_value_number(r, zero_t); mp_free_dep_node(mp, p); } else { mp_new_dep(mp, r, mp_dependent_type, p); } } else { - mp_new_dep(mp, r, mp_type(q), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list((mp_value_node) q))); + mp_new_dep(mp, r, q->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list((mp_value_node) q))); } } @@ -21272,15 +21266,15 @@ static void mp_scan_suffix (MP mp) } else if ((cur_cmd == mp_tag_command) || (cur_cmd == mp_internal_command)) { p = mp_new_symbolic_node(mp); mp_set_sym_sym(p, cur_sym); - mp_name_type(p) = cur_sym_mod; + p->name_type = cur_sym_mod; } else { break; } - mp_link(t) = p; + t->link = p; t = p; mp_get_x_next(mp); } - mp_set_cur_exp_node(mp, mp_link(h)); + mp_set_cur_exp_node(mp, h->link); mp_free_symbolic_node(mp, h); mp->cur_exp.type = mp_token_list_type; } @@ -21340,7 +21334,7 @@ static void mp_binary_mac (MP mp, mp_node p, mp_node c, mp_sym n) { mp_node q = mp_new_symbolic_node(mp); mp_node r = mp_new_symbolic_node(mp); - mp_link(q) = r; + q->link = r; mp_set_sym_sym(q, p); mp_set_sym_sym(r, mp_stash_cur_exp(mp)); mp_macro_call(mp, c, q, n); @@ -21417,7 +21411,7 @@ static void mp_scan_expression (MP mp) mac_name = cur_sym; mp_add_mac_ref(cc); } - if ((d < mp_ampersand_command) || ((d == mp_ampersand_command) && ((mp_type(p) == mp_pair_type) || (mp_type(p) == mp_path_type)))) { + if ((d < mp_ampersand_command) || ((d == mp_ampersand_command) && ((p->type == mp_pair_type) || (p->type == mp_path_type)))) { /* Scan a path construction operation; but |return| if |p| has the wrong type */ mp_unstash_cur_exp(mp, p); if (! mp_scan_path(mp)) { @@ -21837,7 +21831,7 @@ void mp_known_pair (MP mp) Make sure that both |x| and |y| parts of |p| are known; copy them into |cur_x| and |cur_y| */ - if (mp_type(mp_x_part(p)) == mp_known_type) { + if (mp_x_part(p)->type == mp_known_type) { number_clone(mp->cur_x, mp_get_value_number(mp_x_part(p))); } else { mp_disp_err(mp, mp_x_part(p)); @@ -21851,7 +21845,7 @@ void mp_known_pair (MP mp) mp_recycle_value(mp, mp_x_part(p)); set_number_to_zero(mp->cur_x); } - if (mp_type(mp_y_part(p)) == mp_known_type) { + if (mp_y_part(p)->type == mp_known_type) { number_clone(mp->cur_y, mp_get_value_number(mp_y_part(p))); } else { mp_disp_err(mp, mp_y_part(p)); @@ -22417,18 +22411,18 @@ color part primitives (this is needed for backward compatibility) . @c static int mp_pict_color_type (MP mp, int c) { - /* cur_pic_item = mp_link(mp_edge_list(cur_exp_node)) */ + /* cur_pic_item = mp_edge_list(cur_exp_node)->link */ return ( - (mp_link(mp_edge_list(cur_exp_node)) != NULL) + (mp_edge_list(cur_exp_node)->link != NULL) && ( - (! mp_has_color(mp_link(mp_edge_list(cur_exp_node)))) + (! mp_has_color(mp_edge_list(cur_exp_node)->link)) || (( - (mp_color_model(mp_link(mp_edge_list(cur_exp_node))) == c) + (mp_color_model(mp_edge_list(cur_exp_node)->link) == c) || ( - (mp_color_model(mp_link(mp_edge_list(cur_exp_node))) == mp_uninitialized_model) + (mp_color_model(mp_edge_list(cur_exp_node)->link) == mp_uninitialized_model) && (number_to_scaled(internal_value(mp_default_color_model_internal))/number_to_scaled(unity_t)) == c ) @@ -22946,12 +22940,12 @@ static void mp_do_unary (MP mp, int c) new_number(expr.data.n); if (mp->cur_exp.type != mp_picture_type) { set_number_from_boolean(expr.data.n, mp_false_operation); - } else if (mp_link(mp_edge_list(cur_exp_node)) == NULL) { + } else if (mp_edge_list(cur_exp_node)->link == NULL) { set_number_from_boolean(expr.data.n, mp_false_operation); } else { /* they are parallel: */ int type = c - mp_filled_operation + mp_fill_node_type; - set_number_from_boolean(expr.data.n, mp_type(mp_link(mp_edge_list(cur_exp_node))) == type ? mp_true_operation: mp_false_operation); + set_number_from_boolean(expr.data.n, mp_edge_list(cur_exp_node)->link->type == type ? mp_true_operation: mp_false_operation); } mp_flush_cur_exp(mp, expr); mp->cur_exp.type = mp_boolean_type; @@ -23186,7 +23180,7 @@ static int mp_nice_pair (MP mp, mp_node p, int t) (void) mp; if (t == mp_pair_type) { p = mp_get_value_node(p); - if (mp_type(mp_x_part(p)) == mp_known_type && mp_type(mp_y_part(p)) == mp_known_type) + if (mp_x_part(p)->type == mp_known_type && mp_y_part(p)->type == mp_known_type) return 1; } return 0; @@ -23203,23 +23197,25 @@ static int mp_nice_color_or_pair (MP mp, mp_node p, int t) switch (t) { case mp_pair_type: q = mp_get_value_node(p); - if (mp_type(mp_x_part(q)) == mp_known_type - && mp_type(mp_y_part(q)) == mp_known_type) + if (mp_x_part(q)->type == mp_known_type + && mp_y_part(q)->type == mp_known_type) { return 1; - break; + } else { + break; + } case mp_color_type: q = mp_get_value_node(p); - if (mp_type(mp_red_part (q)) == mp_known_type - && mp_type(mp_green_part(q)) == mp_known_type - && mp_type(mp_blue_part (q)) == mp_known_type) + if (mp_red_part (q)->type == mp_known_type + && mp_green_part(q)->type == mp_known_type + && mp_blue_part (q)->type == mp_known_type) return 1; break; case mp_cmykcolor_type: q = mp_get_value_node(p); - if (mp_type(mp_cyan_part (q)) == mp_known_type - && mp_type(mp_magenta_part(q)) == mp_known_type - && mp_type(mp_yellow_part (q)) == mp_known_type - && mp_type(mp_black_part (q)) == mp_known_type) + if (mp_cyan_part (q)->type == mp_known_type + && mp_magenta_part(q)->type == mp_known_type + && mp_yellow_part (q)->type == mp_known_type + && mp_black_part (q)->type == mp_known_type) return 1; break; } @@ -23283,7 +23279,7 @@ static void mp_negate_dep_list (MP mp, mp_value_node p) number_negate(mp_get_dep_value(p)); if (mp_get_dep_info(p) == NULL) return; - p = (mp_value_node) mp_link(p); + p = (mp_value_node) p->link; } } @@ -23300,7 +23296,7 @@ recycling it afterwards (cf.~the |stash_in| routine). static void mp_negate_value(MP mp, mp_node r) { - if (mp_type(r) == mp_known_type) { + if (r->type == mp_known_type) { mp_set_value_number(r, mp_get_value_number(r)); /* to clear the rest */ number_negate(mp_get_value_number(r)); } else { @@ -23386,7 +23382,7 @@ static void mp_bad_color_part (MP mp, int c) mp_string sname; memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); - p = mp_link(mp_edge_list(cur_exp_node)); + p = mp_edge_list(cur_exp_node)->link; mp_disp_err(mp, NULL); selector = mp->selector; mp->selector = mp_new_string_selector; @@ -23425,8 +23421,8 @@ static void mp_take_part (MP mp, int c) { mp_node p = mp_get_value_node(cur_exp_node); /* the big node */ mp_set_value_node(mp->temp_val, p); - mp_type(mp->temp_val) = mp->cur_exp.type; - mp_link(p) = mp->temp_val; + mp->temp_val->type = mp->cur_exp.type; + p->link= mp->temp_val; mp_free_value_node(mp, cur_exp_node); switch (c) { case mp_x_part_operation: @@ -23485,7 +23481,7 @@ static void mp_take_part (MP mp, int c) @ @<Initialize table entries@>= mp->temp_val = mp_new_value_node(mp); -mp_name_type(mp->temp_val) = mp_capsule_operation; +mp->temp_val->name_type = mp_capsule_operation; @ @<Free table entries@>= mp_free_value_node(mp, mp->temp_val); @@ -23500,7 +23496,7 @@ static void mp_take_pict_part (MP mp, int c) mp_value new_expr; memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); - p = mp_link(mp_edge_list(cur_exp_node)); + p = mp_edge_list(cur_exp_node)->link; if (p != NULL) { switch (c) { case mp_x_part_operation: @@ -23614,7 +23610,7 @@ static void mp_take_pict_part (MP mp, int c) mp_confusion(mp, "picture"); } else { new_expr.data.node = NULL; - switch (mp_type(p)) { + switch (p->type) { case mp_fill_node_type: case mp_stroked_node_type: new_expr.data.p = mp_copy_path(mp, mp_path_ptr((mp_shape_node) p)); @@ -23635,7 +23631,7 @@ static void mp_take_pict_part (MP mp, int c) if (! mp_has_pen(p)) { goto NOT_FOUND; } else { - switch (mp_type(p)) { + switch (p->type) { case mp_fill_node_type: case mp_stroked_node_type: if (mp_pen_ptr((mp_shape_node) p) == NULL) { @@ -23652,7 +23648,7 @@ static void mp_take_pict_part (MP mp, int c) } break; case mp_dash_part_operation: - if (mp_type(p) != mp_stroked_node_type) { + if (p->type != mp_stroked_node_type) { goto NOT_FOUND; } else if (mp_dash_ptr(p) == NULL) { goto NOT_FOUND; @@ -23754,15 +23750,15 @@ static void mp_path_length (MP mp, mp_number *n) static void mp_picture_length (MP mp, mp_number *n) { /* counts interior components in picture |cur_exp| */ - mp_node p = mp_link(mp_edge_list(cur_exp_node)); + mp_node p = mp_edge_list(cur_exp_node)->link; int l = 0; if (p != NULL) { if (mp_is_start_or_stop(p) && mp_skip_1component(mp, p) == NULL) { - p = mp_link(p); + p = p->link; } while (p != NULL) { if (! mp_is_start_or_stop(p)) { - p = mp_link(p); + p = p->link; } else if (! mp_is_stop(p)) { p = mp_skip_1component(mp, p); } else { @@ -23915,13 +23911,13 @@ static void mp_bezier_slope (MP mp, static void mp_turn_cycles (MP mp, mp_number *turns, mp_knot c) { int selector; /* saved |selector| setting */ - mp_angle res, ang; /* the angles of intermediate results */ + mp_number res, ang; /* the angles of intermediate results */ mp_knot p; /* for running around the path */ mp_number xp, yp; /* coordinates of next point */ mp_number x, y; /* helper coordinates */ mp_number arg1, arg2; - mp_angle in_angle, out_angle; /* helper angles */ - mp_angle seven_twenty_deg_t; + mp_number in_angle, out_angle; /* helper angles */ + mp_number seven_twenty_deg_t; set_number_to_zero(*turns); new_number(arg1); new_number(arg2); @@ -24050,12 +24046,12 @@ static int mp_test_known (MP mp, int c) case mp_transform_type: { mp_node p = mp_get_value_node(cur_exp_node); - if ( (mp_type(mp_tx_part(p)) == mp_known_type) && - (mp_type(mp_ty_part(p)) == mp_known_type) && - (mp_type(mp_xx_part(p)) == mp_known_type) && - (mp_type(mp_xy_part(p)) == mp_known_type) && - (mp_type(mp_yx_part(p)) == mp_known_type) && - (mp_type(mp_yy_part(p)) == mp_known_type) ) { + if ( (mp_tx_part(p)->type == mp_known_type) && + (mp_ty_part(p)->type == mp_known_type) && + (mp_xx_part(p)->type == mp_known_type) && + (mp_xy_part(p)->type== mp_known_type) && + (mp_yx_part(p)->type == mp_known_type) && + (mp_yy_part(p)->type == mp_known_type) ) { b = mp_true_operation; } } @@ -24063,9 +24059,9 @@ static int mp_test_known (MP mp, int c) case mp_color_type: { mp_node p = mp_get_value_node(cur_exp_node); - if ( (mp_type(mp_red_part(p)) == mp_known_type) && - (mp_type(mp_green_part(p)) == mp_known_type) && - (mp_type(mp_blue_part(p)) == mp_known_type) ) { + if ( (mp_red_part (p)->type == mp_known_type) && + (mp_green_part(p)->type == mp_known_type) && + (mp_blue_part (p)->type == mp_known_type) ) { b = mp_true_operation; } } @@ -24073,10 +24069,10 @@ static int mp_test_known (MP mp, int c) case mp_cmykcolor_type: { mp_node p = mp_get_value_node(cur_exp_node); - if ( (mp_type(mp_cyan_part(p)) == mp_known_type) && - (mp_type(mp_magenta_part(p)) == mp_known_type) && - (mp_type(mp_yellow_part(p)) == mp_known_type) && - (mp_type(mp_black_part(p)) == mp_known_type) ) { + if ( (mp_cyan_part (p)->type == mp_known_type) && + (mp_magenta_part(p)->type == mp_known_type) && + (mp_yellow_part (p)->type == mp_known_type) && + (mp_black_part (p)->type == mp_known_type) ) { b = mp_true_operation; } } @@ -24084,8 +24080,8 @@ static int mp_test_known (MP mp, int c) case mp_pair_type: { mp_node p = mp_get_value_node(cur_exp_node); - if ( (mp_type(mp_x_part(p)) == mp_known_type) && - (mp_type(mp_y_part(p)) == mp_known_type) ) { + if ( (mp_x_part(p)->type == mp_known_type) && + (mp_y_part(p)->type == mp_known_type) ) { b = mp_true_operation; } } @@ -24117,16 +24113,16 @@ static void mp_pair_value (MP mp, mp_number *x, mp_number *y) memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); p = mp_new_value_node(mp); - new_expr.type = mp_type(p); + new_expr.type = p->type; new_expr.data.node = p; mp_flush_cur_exp(mp, new_expr); mp->cur_exp.type = mp_pair_type; - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp_init_pair_node(mp, p); p = mp_get_value_node(p); - mp_type(mp_x_part(p)) = mp_known_type; + mp_x_part(p)->type = mp_known_type; mp_set_value_number(mp_x_part(p), x1); - mp_type(mp_y_part(p)) = mp_known_type; + mp_y_part(p)->type = mp_known_type; mp_set_value_number(mp_y_part(p), y1); free_number(x1); free_number(y1); @@ -24349,7 +24345,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) define a simple function called |tarnished| that returns |NULL| if and only if its argument is not tarnished. */ - switch (mp_type(p)) { + switch (p->type) { case mp_transform_type: case mp_color_type: case mp_cmykcolor_type: @@ -24393,19 +24389,19 @@ static void mp_do_binary (MP mp, mp_node p, int c) case mp_plus_operation: case mp_minus_operation: /* Add or subtract the current expression from |p| */ - if ((mp->cur_exp.type < mp_color_type) || (mp_type(p) < mp_color_type)) { + if ((mp->cur_exp.type < mp_color_type) || (p->type < mp_color_type)) { mp_bad_binary(mp, p, c); } else { - if ((mp->cur_exp.type > mp_pair_type) && (mp_type(p) > mp_pair_type)) { + if ((mp->cur_exp.type > mp_pair_type) && (p->type > mp_pair_type)) { mp_add_or_subtract(mp, p, NULL, c); - } else if (mp->cur_exp.type != mp_type(p)) { + } else if (mp->cur_exp.type != p->type) { /* We catch a mismatch, so we can handle intermediates (assuming a flexible withcolor); if we would go double only live would be easier ... I might eventually make a more generic color type. */ /* - if (mp->cur_exp.type == mp_color_type && mp_type(p) == mp_cmykcolor_type) { + if (mp->cur_exp.type == mp_color_type && p->type == mp_cmykcolor_type) { mp_node q = mp_get_value_node(p); mp_node r = mp_get_value_node(cur_exp_node); number_negate((mp_cyan_part(q))->data.n); @@ -24417,7 +24413,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_add_or_subtract(mp, mp_cyan_part(q), mp_red_part(r), c); mp_add_or_subtract(mp, mp_magenta_part(q), mp_green_part(r), c); mp_add_or_subtract(mp, mp_yellow_part(q), mp_blue_part(r), c); - } else if (mp->cur_exp.type == mp_cmykcolor_type && mp_type(p) == mp_color_type) { + } else if (mp->cur_exp.type == mp_cmykcolor_type && p->type == mp_color_type) { mp_node q = mp_get_value_node(p); mp_node r = mp_get_value_node(cur_exp_node); number_negate((mp_red_part(q))->data.n); @@ -24474,10 +24470,10 @@ static void mp_do_binary (MP mp, mp_node p, int c) case mp_unequal_operation: check_arith(); /* at this point |arith_error| should be |false|? */ - if ((mp->cur_exp.type > mp_pair_type) && (mp_type(p) > mp_pair_type)) { + if ((mp->cur_exp.type > mp_pair_type) && (p->type > mp_pair_type)) { /* |cur_exp:=(p)-cur_exp| */ mp_add_or_subtract(mp, p, NULL, mp_minus_operation); - } else if (mp->cur_exp.type != mp_type(p)) { + } else if (mp->cur_exp.type != p->type) { mp_bad_binary(mp, p, (int) c); goto DONE; } else { @@ -24524,13 +24520,13 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_node rr = mp_x_part(r); part_type = mp_x_part_operation; mp_add_or_subtract(mp, mp_x_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_y_part(r); part_type = mp_y_part_operation; mp_add_or_subtract(mp, mp_y_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } } @@ -24546,19 +24542,19 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_node rr = mp_red_part(r); part_type = mp_red_part_operation; mp_add_or_subtract(mp, mp_red_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_green_part(r); part_type = mp_green_part_operation; mp_add_or_subtract(mp, mp_green_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_blue_part(r); part_type = mp_blue_part_operation; mp_add_or_subtract(mp, mp_blue_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } } @@ -24574,25 +24570,25 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_node rr = mp_cyan_part(r); part_type = mp_cyan_part_operation; mp_add_or_subtract(mp, mp_cyan_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_magenta_part(r); part_type = mp_magenta_part_operation; mp_add_or_subtract(mp, mp_magenta_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_yellow_part(r); part_type = mp_yellow_part_operation; mp_add_or_subtract(mp, mp_yellow_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_black_part(r); part_type = mp_black_part_operation; mp_add_or_subtract(mp, mp_black_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } } @@ -24608,37 +24604,37 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_node rr = mp_tx_part(r); part_type = mp_x_part_operation; mp_add_or_subtract(mp, mp_tx_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_ty_part(r); part_type = mp_y_part_operation; mp_add_or_subtract(mp, mp_ty_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_xx_part(r); part_type = mp_xx_part_operation; mp_add_or_subtract(mp, mp_xx_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_xy_part(r); part_type = mp_xy_part_operation; mp_add_or_subtract(mp, mp_xy_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_yx_part(r); part_type = mp_yx_part_operation; mp_add_or_subtract(mp, mp_yx_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } rr = mp_yy_part(r); part_type = mp_yy_part_operation; mp_add_or_subtract(mp, mp_yy_part(q), rr, mp_minus_operation); - if (mp_type(rr) != mp_known_type || ! number_zero(mp_get_value_number(rr))) { + if (rr->type != mp_known_type || ! number_zero(mp_get_value_number(rr))) { break; } } @@ -24710,20 +24706,20 @@ static void mp_do_binary (MP mp, mp_node p, int c) case mp_and_operation: case mp_or_operation: /* Here we use the sneaky fact that |and_op-false_code=or_op-true_code| */ - if ((mp_type(p) != mp_boolean_type) || (mp->cur_exp.type != mp_boolean_type)) { + if ((p->type != mp_boolean_type) || (mp->cur_exp.type != mp_boolean_type)) { mp_bad_binary(mp, p, (int) c); } else if (number_to_boolean(p->data.n) == c + mp_false_operation - mp_and_operation) { mp_set_cur_exp_value_boolean(mp, number_to_boolean(p->data.n)); } break; case mp_times_operation: - if ((mp->cur_exp.type < mp_color_type) || (mp_type(p) < mp_color_type)) { + if ((mp->cur_exp.type < mp_color_type) || (p->type < mp_color_type)) { mp_bad_binary(mp, p, mp_times_operation); - } else if ((mp->cur_exp.type == mp_known_type) || (mp_type(p) == mp_known_type)) { + } else if ((mp->cur_exp.type == mp_known_type) || (p->type == mp_known_type)) { /* Multiply when at least one operand is known */ mp_number vv; new_fraction(vv); - if (mp_type(p) == mp_known_type) { + if (p->type == mp_known_type) { number_clone(vv, mp_get_value_number(p)); mp_free_value_node(mp, p); } else { @@ -24770,8 +24766,8 @@ static void mp_do_binary (MP mp, mp_node p, int c) free_number(vv); mp_finish_binary(mp, old_p, old_exp); return; - } else if ((mp_nice_color_or_pair(mp, p, mp_type(p)) && (mp->cur_exp.type > mp_pair_type)) - || (mp_nice_color_or_pair(mp, cur_exp_node, mp->cur_exp.type) && (mp_type(p) > mp_pair_type))) { + } else if ((mp_nice_color_or_pair(mp, p, p->type) && (mp->cur_exp.type > mp_pair_type)) + || (mp_nice_color_or_pair(mp, cur_exp_node, mp->cur_exp.type) && (p->type > mp_pair_type))) { mp_hard_times(mp, p); mp_finish_binary(mp, old_p, old_exp); return; @@ -24780,7 +24776,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) } break; case mp_over_operation: - if ((mp->cur_exp.type != mp_known_type) || (mp_type(p) < mp_color_type)) { + if ((mp->cur_exp.type != mp_known_type) || (p->type < mp_color_type)) { mp_bad_binary(mp, p, mp_over_operation); } else { mp_number v_n; @@ -24841,7 +24837,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) } break; case mp_power_operation: - if ((mp->cur_exp.type == mp_known_type) && (mp_type(p) == mp_known_type)) { + if ((mp->cur_exp.type == mp_known_type) && (p->type == mp_known_type)) { mp_number r; new_number(r); power_of(r, mp_get_value_number(p), cur_exp_value_number); @@ -24853,7 +24849,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) break; case mp_pythag_add_operation: case mp_pythag_sub_operation: - if ((mp->cur_exp.type == mp_known_type) && (mp_type(p) == mp_known_type)) { + if ((mp->cur_exp.type == mp_known_type) && (p->type == mp_known_type)) { mp_number r; new_number(r); if (c == mp_pythag_add_operation) { @@ -24878,7 +24874,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) The next few sections of the program deal with affine transformations of coordinate data. */ - switch (mp_type(p)) { + switch (p->type) { case mp_path_type: mp_set_up_known_trans(mp, (int) c); mp_unstash_cur_exp(mp, p); @@ -24917,7 +24913,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) case mp_just_append_operation: case mp_tolerant_concat_operation: case mp_tolerant_append_operation: - if ((mp->cur_exp.type == mp_string_type) && (mp_type(p) == mp_string_type)) { + if ((mp->cur_exp.type == mp_string_type) && (p->type == mp_string_type)) { mp_string str = mp_cat(mp, mp_get_value_str(p), cur_exp_str); delete_str_ref(cur_exp_str) ; mp_set_cur_exp_str(mp, str); @@ -24926,7 +24922,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) } break; case mp_substring_operation: - if (mp_nice_pair(mp, p, mp_type(p)) && (mp->cur_exp.type == mp_string_type)) { + if (mp_nice_pair(mp, p, p->type) && (mp->cur_exp.type == mp_string_type)) { mp_string str = mp_chop_string (mp, cur_exp_str, round_unscaled(mp_get_value_number(mp_x_part(mp_get_value_node(p)))), @@ -24942,7 +24938,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if (mp_nice_pair(mp, p, mp_type(p)) && (mp->cur_exp.type == mp_path_type)) { + if (mp_nice_pair(mp, p, p->type) && (mp->cur_exp.type == mp_path_type)) { mp_chop_path(mp, mp_get_value_node(p)); } else { mp_bad_binary(mp, p, mp_subpath_operation); @@ -24955,14 +24951,14 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && (mp_type(p) == mp_known_type)) { + if ((mp->cur_exp.type == mp_path_type) && (p->type == mp_known_type)) { mp_find_point(mp, &(mp_get_value_number(p)), (int) c); } else { mp_bad_binary(mp, p, c); } break; case mp_pen_offset_operation: - if ((mp->cur_exp.type == mp_pen_type || mp->cur_exp.type == mp_nep_type) && mp_nice_pair(mp, p, mp_type(p))) { + if ((mp->cur_exp.type == mp_pen_type || mp->cur_exp.type == mp_nep_type) && mp_nice_pair(mp, p, p->type)) { mp_set_up_offset(mp, mp_get_value_node(p)); } else { mp_bad_binary(mp, p, mp_pen_offset_operation); @@ -24972,21 +24968,21 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && mp_nice_pair(mp, p, mp_type(p))) { + if ((mp->cur_exp.type == mp_path_type) && mp_nice_pair(mp, p, p->type)) { mp_set_up_direction_time(mp, mp_get_value_node(p)); } else { mp_bad_binary(mp, p, mp_direction_time_operation); } break; case mp_envelope_operation: - if ((mp_type(p) != mp_pen_type && mp_type(p) != mp_nep_type) || (mp->cur_exp.type != mp_path_type)) { + if ((p->type != mp_pen_type && p->type != mp_nep_type) || (mp->cur_exp.type != mp_path_type)) { mp_bad_binary(mp, p, mp_envelope_operation); } else { mp_set_up_envelope(mp, p); } break; case mp_boundingpath_operation: - if ((mp_type(p) != mp_pen_type && mp_type(p) != mp_nep_type) || (mp->cur_exp.type != mp_path_type)) { + if ((p->type != mp_pen_type && p->type != mp_nep_type) || (mp->cur_exp.type != mp_path_type)) { mp_bad_binary(mp, p, mp_boundingpath_operation); } else { mp_set_up_boundingpath(mp, p); @@ -24996,7 +24992,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && (mp_type(p) == mp_known_type)) { + if ((mp->cur_exp.type == mp_path_type) && (p->type == mp_known_type)) { memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); mp_get_arc_time(mp, &new_expr.data.n, cur_exp_knot, &(mp_get_value_number(p)), 0); @@ -25010,11 +25006,11 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && (mp_type(p) == mp_known_type || mp_type(p) == mp_pair_type)) { + if ((mp->cur_exp.type == mp_path_type) && (p->type == mp_known_type || p->type == mp_pair_type)) { mp_knot k; memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); - if (mp_type(p) == mp_pair_type) { + if (p->type == mp_pair_type) { mp_knot f = cur_exp_knot; mp_node q = mp_get_value_node(p); mp_number x; @@ -25083,7 +25079,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && mp_type(p) == mp_known_type) { + if ((mp->cur_exp.type == mp_path_type) && p->type == mp_known_type) { // we can consider using ints as we have discrete points mp_knot cur = cur_exp_knot; mp_number len, aln, seg, tot, tim, stp, acc, tmp; @@ -25184,7 +25180,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && mp_type(p) == mp_pair_type) { + if ((mp->cur_exp.type == mp_path_type) && p->type == mp_pair_type) { memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); mp_node q = mp_get_value_node(p); @@ -25196,7 +25192,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) break; case mp_intertimes_operation: case mp_intertimes_list_operation: - if (mp_type(p) == mp_pair_type) { + if (p->type == mp_pair_type) { mp_node q = mp_stash_cur_exp(mp); mp_unstash_cur_exp(mp, p); mp_pair_to_path(mp); @@ -25206,7 +25202,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) if (mp->cur_exp.type == mp_pair_type) { mp_pair_to_path(mp); } - if ((mp->cur_exp.type == mp_path_type) && (mp_type(p) == mp_path_type)) { + if ((mp->cur_exp.type == mp_path_type) && (p->type == mp_path_type)) { if (c == mp_intertimes_operation) { // mp_number arg1, arg2; // mp_path_intersection(mp, mp_get_value_knot(p), cur_exp_knot, 0, NULL); @@ -25245,7 +25241,7 @@ static void mp_bad_binary (MP mp, mp_node p, int c) if (c >= mp_min_of_operation) { mp_print_op(mp, c); } - mp_print_known_or_unknown_type(mp, mp_type(p), p); + mp_print_known_or_unknown_type(mp, p->type, p); if (c >= mp_min_of_operation) { mp_print_str(mp, "of"); } else { @@ -25289,33 +25285,33 @@ static mp_node mp_tarnished (MP mp, mp_node p) { mp_node q = mp_get_value_node(p); (void) mp; - switch (mp_type(p)) { + switch (p->type) { case mp_pair_type: return ( - (mp_type(mp_x_part(q)) == mp_independent_type) || - (mp_type(mp_y_part(q)) == mp_independent_type) + (mp_x_part(q)->type == mp_independent_type) || + (mp_y_part(q)->type == mp_independent_type) ) ? MP_VOID : NULL; case mp_color_type: return ( - (mp_type(mp_red_part(q)) == mp_independent_type) || - (mp_type(mp_green_part(q)) == mp_independent_type) || - (mp_type(mp_blue_part(q)) == mp_independent_type) + (mp_red_part (q)->type == mp_independent_type) || + (mp_green_part(q)->type == mp_independent_type) || + (mp_blue_part (q)->type == mp_independent_type) ) ? MP_VOID : NULL; case mp_cmykcolor_type: return ( - (mp_type(mp_cyan_part(q)) == mp_independent_type) || - (mp_type(mp_magenta_part(q)) == mp_independent_type) || - (mp_type(mp_yellow_part(q)) == mp_independent_type) || - (mp_type(mp_black_part(q)) == mp_independent_type) + (mp_cyan_part (q)->type == mp_independent_type) || + (mp_magenta_part(q)->type == mp_independent_type) || + (mp_yellow_part (q)->type == mp_independent_type) || + (mp_black_part (q)->type == mp_independent_type) ) ? MP_VOID : NULL; case mp_transform_type: return ( - (mp_type(mp_tx_part(q)) == mp_independent_type) || - (mp_type(mp_ty_part(q)) == mp_independent_type) || - (mp_type(mp_xx_part(q)) == mp_independent_type) || - (mp_type(mp_xy_part(q)) == mp_independent_type) || - (mp_type(mp_yx_part(q)) == mp_independent_type) || - (mp_type(mp_yy_part(q)) == mp_independent_type) + (mp_tx_part(q)->type == mp_independent_type) || + (mp_ty_part(q)->type == mp_independent_type) || + (mp_xx_part(q)->type == mp_independent_type) || + (mp_xy_part(q)->type == mp_independent_type) || + (mp_yx_part(q)->type == mp_independent_type) || + (mp_yy_part(q)->type == mp_independent_type) ) ? MP_VOID : NULL; default: return NULL; @@ -25349,7 +25345,7 @@ static void mp_add_or_subtract (MP mp, mp_node p, mp_node q, int c) v = (mp_value_node) mp_get_dep_list((mp_value_node) cur_exp_node); } } else { - t = mp_type(q); + t = q->type; if (t < mp_dependent_type) { number_clone(vv, mp_get_value_number(q)); } else { @@ -25361,7 +25357,7 @@ static void mp_add_or_subtract (MP mp, mp_node p, mp_node q, int c) if (c == mp_minus_operation) { number_negate(vv); } - if (mp_type(p) == mp_known_type) { + if (p->type == mp_known_type) { slow_add(vv, mp_get_value_number(p), vv); if (q == NULL) { mp_set_cur_exp_value_number(mp, &vv); @@ -25374,22 +25370,22 @@ static void mp_add_or_subtract (MP mp, mp_node p, mp_node q, int c) /* Add a known value to the constant term of |mp_get_dep_list(p)| */ r = (mp_value_node) mp_get_dep_list((mp_value_node) p); while (mp_get_dep_info(r) != NULL) { - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; } slow_add(vv, mp_get_dep_value(r), vv); mp_set_dep_value(r, vv); if (qq == NULL) { qq = mp_get_dep_node(mp); mp_set_cur_exp_node(mp, (mp_node) qq); - mp->cur_exp.type = mp_type(p); - mp_name_type(qq) = mp_capsule_operation; + mp->cur_exp.type = p->type; + qq->name_type = mp_capsule_operation; /* clang: never read: |q = (mp_node) qq;| */ } mp_set_dep_list(qq, mp_get_dep_list((mp_value_node) p)); - mp_type(qq) = mp_type(p); + qq->type = p->type; mp_set_prev_dep(qq, mp_get_prev_dep((mp_value_node) p)); - mp_link(mp_get_prev_dep((mp_value_node) p)) = (mp_node) qq; - mp_type(p) = mp_known_type; /* this will keep the recycler from collecting non-garbage */ + mp_get_prev_dep((mp_value_node) p)->link = (mp_node) qq; + p->type = mp_known_type; /* this will keep the recycler from collecting non-garbage */ } } else { if (c == mp_minus_operation) { @@ -25401,15 +25397,15 @@ static void mp_add_or_subtract (MP mp, mp_node p, mp_node q, int c) of |fraction| coefficients. But we have to handle both kinds, and mixtures too. */ - if (mp_type(p) == mp_known_type) { + if (p->type == mp_known_type) { /* Add the known |value(p)| to the constant term of |v| */ while (mp_get_dep_info(v) != NULL) { - v = (mp_value_node) mp_link(v); + v = (mp_value_node) v->link; } slow_add(vv, mp_get_value_number(p), mp_get_dep_value(v)); mp_set_dep_value(v, vv); } else { - s = mp_type(p); + s = p->type; r = (mp_value_node) mp_get_dep_list((mp_value_node) p); if (t == mp_dependent_type) { if (s == mp_dependent_type) { @@ -25459,7 +25455,7 @@ static void mp_dep_finish (MP mp, mp_value_node v, mp_value_node q, int t) { mp_value_node p = (q == NULL) ? (mp_value_node) cur_exp_node : q; /* the destination */ mp_set_dep_list(p, v); - mp_type(p) = t; + p->type = t; if (mp_get_dep_info(v) == NULL) { mp_number vv; /* the value, if it is |known| */ new_number_clone(vv, mp_get_value_number(v)); @@ -25470,7 +25466,7 @@ static void mp_dep_finish (MP mp, mp_value_node v, mp_value_node q, int t) mp_flush_cur_exp(mp, new_expr); } else { mp_recycle_value(mp, (mp_node) p); - mp_type(q) = mp_known_type; + q->type = mp_known_type; mp_set_value_number(q, vv); } free_number(vv); @@ -25489,7 +25485,7 @@ static void mp_dep_mult (MP mp, mp_value_node p, mp_number *v, int v_is_scaled) int s, t; /* its type, before and after */ if (p == NULL) { q = (mp_value_node) cur_exp_node; - } else if (mp_type(p) != mp_known_type) { + } else if (p->type != mp_known_type) { q = p; } else { mp_number r1, arg1; @@ -25506,7 +25502,7 @@ static void mp_dep_mult (MP mp, mp_value_node p, mp_number *v, int v_is_scaled) free_number(arg1); return; } - t = mp_type(q); + t = q->type; q = (mp_value_node) mp_get_dep_list(q); s = t; if (t == mp_dependent_type && v_is_scaled) { @@ -25623,7 +25619,7 @@ static void mp_hard_times (MP mp, mp_node p) mp_value_node pp; /* for typecasting p */ mp_number v; /* the known value for |r| */ new_number(v); - if (mp_type(p) <= mp_pair_type) { + if (p->type <= mp_pair_type) { q = (mp_value_node) mp_stash_cur_exp(mp); mp_unstash_cur_exp(mp, p); p = (mp_node) q; @@ -25635,11 +25631,11 @@ static void mp_hard_times (MP mp, mp_node p) { mp_node r = mp_x_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_y_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); } break; @@ -25647,15 +25643,15 @@ static void mp_hard_times (MP mp, mp_node p) { mp_node r = mp_red_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_green_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_blue_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); } break; @@ -25663,19 +25659,19 @@ static void mp_hard_times (MP mp, mp_node p) { mp_node r = mp_cyan_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_yellow_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_magenta_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); r = mp_black_part(mp_get_value_node(cur_exp_node)); number_clone(v, mp_get_value_number(r)); - mp_new_dep(mp, r, mp_type(pp), mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); + mp_new_dep(mp, r, pp->type, mp_copy_dep_list(mp, (mp_value_node) mp_get_dep_list(pp))); mp_dep_mult(mp, (mp_value_node) r, &v, 1); } break; @@ -25692,7 +25688,7 @@ static void mp_dep_div (MP mp, mp_value_node p, mp_number *v) int s, t; /* its type, before and after */ if (p == NULL) { q = (mp_value_node) cur_exp_node; - } else if (mp_type(p) != mp_known_type) { + } else if (p->type != mp_known_type) { q = p; } else { mp_number ret; @@ -25702,7 +25698,7 @@ static void mp_dep_div (MP mp, mp_value_node p, mp_number *v) free_number(ret); return; } - t = mp_type(q); + t = q->type; q = (mp_value_node) mp_get_dep_list(q); s = t; if (t == mp_dependent_type) { @@ -25760,12 +25756,12 @@ static void mp_set_up_trans (MP mp, int c) otherwise |return| */ q = mp_get_value_node(cur_exp_node); - if ( (mp_type(mp_tx_part(q)) == mp_known_type) && - (mp_type(mp_ty_part(q)) == mp_known_type) && - (mp_type(mp_xx_part(q)) == mp_known_type) && - (mp_type(mp_xy_part(q)) == mp_known_type) && - (mp_type(mp_yx_part(q)) == mp_known_type) && - (mp_type(mp_yy_part(q)) == mp_known_type) ) { + if ( (mp_tx_part(q)->type == mp_known_type) && + (mp_ty_part(q)->type == mp_known_type) && + (mp_xx_part(q)->type == mp_known_type) && + (mp_xy_part(q)->type == mp_known_type) && + (mp_yx_part(q)->type == mp_known_type) && + (mp_yy_part(q)->type == mp_known_type) ) { number_clone(mp->txx, mp_get_value_number(mp_xx_part(q))); number_clone(mp->txy, mp_get_value_number(mp_xy_part(q))); number_clone(mp->tyx, mp_get_value_number(mp_yx_part(q))); @@ -25804,25 +25800,25 @@ free_number(mp->ty); @ @<For each of the eight cases...@>= switch (c) { case mp_rotated_operation: - if (mp_type(p) == mp_known_type) { + if (p->type == mp_known_type) { @<Install sines and cosines, then |goto done|@> } break; case mp_slanted_operation: - if (mp_type(p) > mp_pair_type) { + if (p->type > mp_pair_type) { mp_install(mp, mp_xy_part(q), p); goto DONE; } break; case mp_scaled_operation: - if (mp_type(p) > mp_pair_type) { + if (p->type > mp_pair_type) { mp_install(mp, mp_xx_part(q), p); mp_install(mp, mp_yy_part(q), p); goto DONE; } break; case mp_shifted_operation: - if (mp_type(p) == mp_pair_type) { + if (p->type == mp_pair_type) { r = mp_get_value_node(p); mp_install(mp, mp_tx_part(q), mp_x_part(r)); mp_install(mp, mp_ty_part(q), mp_y_part(r)); @@ -25830,19 +25826,19 @@ switch (c) { } break; case mp_x_scaled_operation: - if (mp_type(p) > mp_pair_type) { + if (p->type > mp_pair_type) { mp_install(mp, mp_xx_part(q), p); goto DONE; } break; case mp_y_scaled_operation: - if (mp_type(p) > mp_pair_type) { + if (p->type > mp_pair_type) { mp_install(mp, mp_yy_part(q), p); goto DONE; } break; case mp_z_scaled_operation: - if (mp_type(p) == mp_pair_type) { + if (p->type == mp_pair_type) { @<Install a complex multiplier, then |goto done|@> } break; @@ -25879,7 +25875,7 @@ goto DONE; mp_install(mp, mp_xx_part(q), mp_x_part(r)); mp_install(mp, mp_yy_part(q), mp_x_part(r)); mp_install(mp, mp_yx_part(q), mp_y_part(r)); - if (mp_type(mp_y_part(r)) == mp_known_type) { + if (mp_y_part(r)->type == mp_known_type) { mp_set_value_number(mp_y_part(r), mp_get_value_number(mp_y_part(r))); number_negate(mp_get_value_number(mp_y_part(r))); } else { @@ -25996,7 +25992,7 @@ static void mp_do_path_pen_trans (MP mp, mp_shape_node p, mp_number *sqdet, int set_number_to_zero(mp->tx); set_number_to_zero(mp->ty); mp_do_pen_trans(mp, mp_pen_ptr(p)); - if (number_nonzero(*sqdet) && ((mp_type(p) == mp_stroked_node_type) && (mp_dash_ptr(p) != NULL))) { + if (number_nonzero(*sqdet) && ((p->type == mp_stroked_node_type) && (mp_dash_ptr(p) != NULL))) { mp_number ret; new_number(ret); take_scaled(ret, ((mp_shape_node) p)->dashscale, *sqdet); @@ -26037,10 +26033,10 @@ static mp_edge_header_node mp_edges_trans (MP mp, mp_edge_header_node h) @<Try to transform the dash list of |h|@> } @<Make the bounding box of |h| unknown if it can't be updated properly without scanning the whole structure@> - q = mp_link(mp_edge_list(h)); + q = mp_edge_list(h)->link; while (q != NULL) { @<Transform graphical object |q|@> - q = mp_link(q); + q = q->link; } free_number(sqdet); return h; @@ -26088,9 +26084,9 @@ if (number_nonzero(mp->txy) || number_nonzero(mp->tyx) || number_nonzero(mp->ty) mp_set_dash_list(h, mp->null_dash); while (r != mp->null_dash) { s = r; - r = (mp_dash_node) mp_link(r); + r = (mp_dash_node) r->link; number_swap(s->start_x, s->stop_x ); - mp_link(s) = (mp_node) mp_get_dash_list(h); + s->link = (mp_node) mp_get_dash_list(h); mp_set_dash_list(h, s); } } @@ -26105,7 +26101,7 @@ r = mp_get_dash_list(h); set_number_from_addition(r->start_x, arg1, mp->tx); take_scaled(arg1, r->stop_x, mp->txx); set_number_from_addition(r->stop_x, arg1, mp->tx); - r = (mp_dash_node) mp_link(r); + r = (mp_dash_node) r->link; } free_number(arg1); } @@ -26159,7 +26155,7 @@ free_number(tot); structure~|h|. @<Transform graphical object |q|@>= -switch (mp_type(q)) { +switch (q->type) { case mp_fill_node_type: case mp_stroked_node_type: mp_do_path_trans(mp, mp_path_ptr((mp_shape_node) q)); @@ -26186,13 +26182,13 @@ some of their components are unknown. static void mp_big_trans (MP mp, mp_node p, int c) { mp_node q = mp_get_value_node(p); - if (mp_type(q) == mp_pair_node_type) { - if (mp_type(mp_x_part(q)) != mp_known_type || mp_type(mp_y_part(q)) != mp_known_type) { + if (q->type == mp_pair_node_type) { + if (mp_x_part(q)->type != mp_known_type || mp_y_part(q)->type != mp_known_type) { goto UNKNOWN; } - } else if (mp_type(mp_tx_part(q)) != mp_known_type || mp_type(mp_ty_part(q)) != mp_known_type || - mp_type(mp_xx_part(q)) != mp_known_type || mp_type(mp_xy_part(q)) != mp_known_type || - mp_type(mp_yx_part(q)) != mp_known_type || mp_type(mp_yy_part(q)) != mp_known_type) { + } else if (mp_tx_part(q)->type != mp_known_type || mp_ty_part(q)->type != mp_known_type || + mp_xx_part(q)->type != mp_known_type || mp_xy_part(q)->type != mp_known_type || + mp_yx_part(q)->type != mp_known_type || mp_yy_part(q)->type != mp_known_type) { goto UNKNOWN; } { @@ -26233,7 +26229,7 @@ static void mp_bilin1 (MP mp, mp_node p, mp_number *t, mp_node q, mp_number *u, mp_dep_mult(mp, (mp_value_node) p, t, 1); } if (number_nonzero(*u)) { - if (mp_type(q) == mp_known_type) { + if (q->type == mp_known_type) { mp_number tmp; new_number(tmp); take_scaled(tmp, mp_get_value_number(q), *u); @@ -26241,32 +26237,32 @@ static void mp_bilin1 (MP mp, mp_node p, mp_number *t, mp_node q, mp_number *u, free_number(tmp); } else { /* Ensure that |type(p)=mp_proto_dependent| */ - if (mp_type(p) != mp_proto_dependent_type) { - if (mp_type(p) == mp_known_type) { - mp_new_dep(mp, p, mp_type(p), mp_const_dependency(mp, &(mp_get_value_number(p)))); + if (p->type != mp_proto_dependent_type) { + if (p->type == mp_known_type) { + mp_new_dep(mp, p, p->type, mp_const_dependency(mp, &(mp_get_value_number(p)))); } else { mp_set_dep_list((mp_value_node) p, mp_p_times_v(mp, (mp_value_node) mp_get_dep_list((mp_value_node) p), &unity_t, mp_dependent_type, mp_proto_dependent_type, 1)); } - mp_type(p) = mp_proto_dependent_type; + p->type = mp_proto_dependent_type; } mp_set_dep_list((mp_value_node) p, mp_p_plus_fq(mp, (mp_value_node) mp_get_dep_list((mp_value_node) p), u, (mp_value_node) mp_get_dep_list((mp_value_node) q), - mp_proto_dependent_type, mp_type(q))); + mp_proto_dependent_type, q->type)); } } - if (mp_type(p) == mp_known_type) { + if (p->type == mp_known_type) { mp_set_value_number(p, mp_get_value_number(p)); number_add(mp_get_value_number(p), delta); } else { mp_number tmp; mp_value_node r = (mp_value_node) mp_get_dep_list((mp_value_node) p); while (mp_get_dep_info(r) != NULL) { - r = (mp_value_node) mp_link(r); + r = (mp_value_node) r->link; } new_number_clone(tmp, mp_get_value_number(r)); number_add(delta, tmp); @@ -26275,7 +26271,7 @@ static void mp_bilin1 (MP mp, mp_node p, mp_number *t, mp_node q, mp_number *u, mp_set_value_number(r, delta); } else { mp_recycle_value(mp, p); - mp_type(p) = mp_known_type; + p->type = mp_known_type; mp_set_value_number(p, delta); } free_number(tmp); @@ -26325,7 +26321,7 @@ to~|p|. @<Declare subroutines needed by |big_trans|@>= static void mp_add_mult_dep (MP mp, mp_value_node p, mp_number *v, mp_node r) { - if (mp_type(r) == mp_known_type) { + if (r->type == mp_known_type) { mp_number ret; new_number(ret); take_scaled(ret, mp_get_value_number(r), *v); @@ -26333,7 +26329,7 @@ static void mp_add_mult_dep (MP mp, mp_value_node p, mp_number *v, mp_node r) number_add(mp_get_dep_value(mp->dep_final), ret); free_number(ret); } else { - mp_set_dep_list(p, mp_p_plus_fq(mp, (mp_value_node) mp_get_dep_list(p), v, (mp_value_node) mp_get_dep_list((mp_value_node) r), mp_proto_dependent_type, mp_type(r))); + mp_set_dep_list(p, mp_p_plus_fq(mp, (mp_value_node) mp_get_dep_list(p), v, (mp_value_node) mp_get_dep_list((mp_value_node) r), mp_proto_dependent_type, r->type)); if (mp->fix_needed) { mp_fix_dependencies(mp); } @@ -26367,7 +26363,7 @@ static void mp_bilin2 (MP mp, mp_node p, mp_node t, mp_number *v, mp_node u, mp_ if (mp_get_dep_list((mp_value_node) p) == (mp_node) mp->dep_final) { number_clone(vv, mp_get_dep_value(mp->dep_final)); mp_recycle_value(mp, p); - mp_type(p) = mp_known_type; + p->type = mp_known_type; mp_set_value_number(p, vv); } free_number(vv); @@ -26993,7 +26989,7 @@ void mp_do_equation (MP mp) trace_equation(mp, lhs); } if (mp->cur_exp.type == mp_unknown_path_type) { - if (mp_type(lhs) == mp_pair_type) { + if (lhs->type == mp_pair_type) { mp_node p; /* temporary register */ p = mp_stash_cur_exp(mp); mp_unstash_cur_exp(mp, lhs); @@ -27110,7 +27106,7 @@ static void trace_assignment (MP mp, mp_node lhs) { mp_begin_diagnostic(mp); mp_print_nl(mp, "{"); - if (mp_name_type(lhs) == mp_internal_operation) { + if (lhs->name_type == mp_internal_operation) { mp_print_str(mp, internal_name(mp_get_sym_info(lhs))); } else { mp_show_token_list(mp, lhs, NULL); @@ -27139,7 +27135,7 @@ void mp_do_assignment (MP mp) if (number_greater(internal_value(mp_tracing_commands_internal), two_t)) { trace_assignment (mp, lhs); } - if (mp_name_type(lhs) == mp_internal_operation) { + if (lhs->name_type == mp_internal_operation) { /* Assign the current expression to an internal variable */ switch (mp->cur_exp.type) { case mp_known_type: @@ -27192,7 +27188,7 @@ void mp_do_assignment (MP mp) mp_node q = mp_stash_cur_exp(mp); /* temporary capsule for the right-hand value */ mp->cur_exp.type = mp_und_type(mp, p); mp_recycle_value(mp, p); - mp_type(p) = mp->cur_exp.type; + p->type = mp->cur_exp.type; mp_set_value_number(p, zero_t); mp_make_exp_copy(mp, p); p = mp_stash_cur_exp(mp); @@ -27218,7 +27214,7 @@ static void announce_bad_equation (MP mp, mp_node lhs) char msg[256]; mp_snprintf(msg, 256, "Equation cannot be performed (%s=%s)", - (mp_type(lhs) <= mp_pair_type ? mp_type_string(mp_type(lhs)) : "numeric"), + (lhs->type <= mp_pair_type ? mp_type_string(lhs->type) : "numeric"), (mp->cur_exp.type <= mp_pair_type ? mp_type_string(mp->cur_exp.type) : "numeric")); mp_disp_err(mp, lhs); mp_disp_err(mp, NULL); @@ -27280,7 +27276,7 @@ void mp_make_eq (MP mp, mp_node lhs) memset(&new_expr, 0, sizeof(mp_value)); new_number(v); RESTART: - t = mp_type(lhs); + t = lhs->type; if (t <= mp_pair_type) { number_clone(v, mp_get_value_number(lhs)); } @@ -27446,7 +27442,7 @@ void mp_try_eq (MP mp, mp_node l, mp_node r) Remove the left operand from its container, negate it, and put it into dependency list~|p| with constant term~|q| */ - mp_variable_type t = mp_type(l); /* the type of list |p| */ + mp_variable_type t = l->type; /* the type of list |p| */ switch (t) { case mp_known_type: { @@ -27477,12 +27473,12 @@ void mp_try_eq (MP mp, mp_node l, mp_node r) if (mp_get_dep_info(q) == NULL) { break; } else { - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; } } - mp_link(mp_get_prev_dep(ll)) = mp_link(q); - mp_set_prev_dep((mp_value_node) mp_link(q), mp_get_prev_dep(ll)); - mp_type(ll) = mp_known_type; + mp_get_prev_dep(ll)->link = q->link; + mp_set_prev_dep((mp_value_node) q->link, mp_get_prev_dep(ll)); + ll->type = mp_known_type; } break; } @@ -27499,11 +27495,11 @@ void mp_try_eq (MP mp, mp_node l, mp_node r) pp = (mp_value_node) mp_get_dep_list((mp_value_node) cur_exp_node); } } - } else if (mp_type(r) == mp_known_type) { + } else if (r->type == mp_known_type) { number_add(mp_get_dep_value(q), mp_get_value_number(r)); goto DONE1; } else { - tt = mp_type(r); + tt = r->type; if (tt == mp_independent_type) { pp = mp_single_dependency(mp, r); } else { @@ -27530,7 +27526,7 @@ void mp_try_eq (MP mp, mp_node l, mp_node r) number_clone(x, mp_get_dep_value(q)); fraction_to_round_scaled(x); mp_set_dep_value(q, x); - q = (mp_value_node) mp_link(q); + q = (mp_value_node) q->link; } free_number(x); t = mp_proto_dependent_type; @@ -27545,7 +27541,7 @@ void mp_try_eq (MP mp, mp_node l, mp_node r) deal_with_redundant_or_inconsistent_equation(mp, p, r); } else { mp_linear_eq(mp, p, (int) t); - if (r == NULL && mp->cur_exp.type != mp_known_type && mp_type(cur_exp_node) == mp_known_type) { + if (r == NULL && mp->cur_exp.type != mp_known_type && cur_exp_node->type == mp_known_type) { mp_node pp = cur_exp_node; mp_set_cur_exp_value_number(mp, &(mp_get_value_number(pp))); mp->cur_exp.type = mp_known_type; @@ -27604,10 +27600,10 @@ mp_node mp_scan_declared_variable (MP mp) } } } - mp_link(t) = mp_new_symbolic_node(mp); - t = mp_link(t); + t->link = mp_new_symbolic_node(mp); + t = t->link; mp_set_sym_sym(t, cur_sym); - mp_name_type(t) = cur_sym_mod; + t->name_type = cur_sym_mod; } if (eq_property(x) != 0) { mp_check_overload(mp, x); @@ -27685,10 +27681,10 @@ void mp_do_type_declaration (MP mp) do { mp_node p = mp_scan_declared_variable(mp); /* token list for a declared variable */ mp_node q; /* value node for the variable */ - mp_flush_variable(mp, equiv_node(mp_get_sym_sym(p)), mp_link(p), 0); + mp_flush_variable(mp, equiv_node(mp_get_sym_sym(p)), p->link, 0); q = mp_find_variable(mp, p); if (q != NULL) { - mp_type(q) = t; + q->type = t; mp_set_value_number(q, zero_t); /* todo: this was |null| */ } else { mp_back_error( @@ -28670,28 +28666,28 @@ static void mp_disp_var (MP mp, mp_node p); @ @c void mp_disp_var (MP mp, mp_node p) { - if (mp_type(p) == mp_structured_type) { + if (p->type == mp_structured_type) { /* Descend the structure */ mp_node q = mp_get_attribute_head(p); do { mp_disp_var(mp, q); - q = mp_link(q); + q = q->link; } while (q != mp->end_attr); q = mp_get_subscr_head(p); - while (mp_name_type(q) == mp_subscript_operation) { + while (q->name_type == mp_subscript_operation) { mp_disp_var(mp, q); - q = mp_link(q); + q = q->link; } - } else if (mp_type(p) >= mp_unsuffixed_macro_type) { + } else if (p->type >= mp_unsuffixed_macro_type) { /* Display a variable macro */ mp_print_nl(mp, ""); mp_print_variable_name(mp, p); - if (mp_type(p) > mp_unsuffixed_macro_type) { + if (p->type > mp_unsuffixed_macro_type) { mp_print_str(mp, "@@#"); /* |suffixed_macro| */ } mp_print_str(mp, "=macro:"); mp_show_macro(mp, mp_get_value_node(p), NULL); - } else if (mp_type(p) != mp_undefined_type) { + } else if (p->type != mp_undefined_type) { mp_print_nl(mp, ""); mp_print_variable_name(mp, p); mp_print_chr(mp, '='); @@ -28726,22 +28722,23 @@ static void mp_do_show_dependencies (MP mp); void mp_do_show_dependencies (MP mp) { /* link that runs through all dependencies */ - mp_value_node p = (mp_value_node) mp_link(mp->dep_head); + mp_value_node p = (mp_value_node) mp->dep_head->link; while (p != mp->dep_head) { if (mp_interesting(mp, (mp_node) p)) { mp_print_nl(mp, ""); mp_print_variable_name(mp, (mp_node) p); - if (mp_type(p) == mp_dependent_type) { + if (p->type == mp_dependent_type) { mp_print_chr(mp, '='); } else { mp_print_str(mp, " = "); /* extra spaces imply proto-dependency */ } - mp_print_dependency(mp, (mp_value_node) mp_get_dep_list(p), mp_type(p)); + mp_print_dependency(mp, (mp_value_node) mp_get_dep_list(p), p->type); } p = (mp_value_node) mp_get_dep_list(p); - while (mp_get_dep_info(p) != NULL) - p = (mp_value_node) mp_link(p); - p = (mp_value_node) mp_link(p); + while (mp_get_dep_info(p) != NULL) { + p = (mp_value_node) p->link; + } + p = (mp_value_node) p->link; } mp_get_x_next(mp); } @@ -28899,7 +28896,7 @@ will ever contain a color outside the legal range for \ps\ graphics. if (mp_has_color(cp)) { break; } else { - cp = mp_link(cp); + cp = cp->link; } } } while (0) @@ -29203,12 +29200,12 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) if (mp_has_pen(pp)) { break; } else { - pp = mp_link(pp); + pp = pp->link; } } } if (pp != NULL) { - switch (mp_type(pp)) { + switch (pp->type) { case mp_fill_node_type: case mp_stroked_node_type: if (mp_pen_ptr((mp_shape_node) pp) != NULL) { @@ -29233,7 +29230,7 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) ap = p; } while ((ap != NULL) && (! mp_has_script(ap))) { - ap = mp_link(ap); + ap = ap->link; } if (ap != NULL) { if (mp_pre_script(ap) != NULL) { @@ -29265,7 +29262,7 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) bp = p; } while ((bp != NULL) && (! mp_has_script(bp))) { - bp = mp_link(bp); + bp = bp->link; } if (bp != NULL) { if (mp_post_script(bp) != NULL) { @@ -29395,10 +29392,10 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) /* Make |dp| a stroked node in list~|p| */ dp = p; while (dp != NULL) { - if (mp_type(dp) == mp_stroked_node_type) { + if (dp->type == mp_stroked_node_type) { break; } else { - dp = mp_link(dp); + dp = dp->link; } } } @@ -29420,7 +29417,7 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) */ if (cp > MP_VOID) { /* Copy |cp|'s color into the colored objects linked to~|cp| */ - mp_node q = mp_link(cp); + mp_node q = cp->link; while (q != NULL) { if (mp_has_color(q)) { mp_shape_node q0 = (mp_shape_node) q; @@ -29431,15 +29428,15 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) number_clone(q0->black, cp0->black); mp_color_model(q) = mp_color_model(cp); } - q = mp_link(q); + q = q->link; } } if (pp > MP_VOID) { /* Copy |mp_pen_ptr(pp)| into stroked and filled nodes linked to |pp| */ - mp_node q = mp_link(pp); + mp_node q = pp->link; while (q != NULL) { if (mp_has_pen(q)) { - switch (mp_type(q)) { + switch (q->type) { case mp_fill_node_type: case mp_stroked_node_type: if (mp_pen_ptr((mp_shape_node) q) != NULL) { @@ -29451,14 +29448,14 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) break; } } - q = mp_link(q); + q = q->link; } } if (dp > MP_VOID) { /* Make stroked nodes linked to |dp| refer to |mp_dash_ptr(dp)| */ - mp_node q = mp_link(dp); + mp_node q = dp->link; while (q != NULL) { - if (mp_type(q) == mp_stroked_node_type) { + if (q->type == mp_stroked_node_type) { if (mp_dash_ptr(q) != NULL) { mp_delete_edge_ref(mp, mp_dash_ptr(q)); } @@ -29468,13 +29465,13 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) mp_add_edge_ref(mp, mp_dash_ptr(q)); } } - q = mp_link(q); + q = q->link; } } if (linecap >= 0 && linecap < mp_weird_linecap_code) { mp_node q = p; while (q != NULL) { - switch (mp_type(q)) { + switch (q->type) { case mp_fill_node_type: case mp_stroked_node_type: mp_set_linecap(q, linecap); @@ -29482,13 +29479,13 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) default: break; } - q = mp_link(q); + q = q->link; } } if (linejoin >= 0 && linejoin < mp_weird_linejoin_code) { mp_node q = p; while (q != NULL) { - switch (mp_type(q)) { + switch (q->type) { case mp_fill_node_type: case mp_stroked_node_type: mp_set_linejoin(q, linejoin); @@ -29496,13 +29493,13 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) default: break; } - q = mp_link(q); + q = q->link; } } if (miterlimit) { mp_node q = p; while (q != NULL) { - switch (mp_type(q)) { + switch (q->type) { case mp_fill_node_type: case mp_stroked_node_type: number_clone(mp_miterlimit(q), ml); @@ -29510,15 +29507,15 @@ void mp_scan_with_list (MP mp, mp_node p, mp_node pstop) default: break; } - q = mp_link(q); + q = q->link; } free_number(ml); } if (! pp && sp > MP_VOID) { - mp_node q = mp_link(sp); + mp_node q = sp->link; while (q != NULL) { mp_stacking(q) = mp_stacking(sp); - q = mp_link(q); + q = q->link; } } } @@ -29548,7 +29545,7 @@ mp_edge_header_node mp_find_edges_var (MP mp, mp_node t) ); mp_memory_free(msg); mp_get_x_next(mp); - } else if (mp_type(p) != mp_picture_type) { + } else if (p->type != mp_picture_type) { char msg[256]; mp_string sname; int selector = mp->selector; @@ -29556,7 +29553,7 @@ mp_edge_header_node mp_find_edges_var (MP mp, mp_node t) mp_show_token_list(mp, t, NULL); sname = mp_make_string(mp); mp->selector = selector; - mp_snprintf(msg, 256, "Variable %s is the wrong type(%s)", mp_str(mp, sname), mp_type_string(mp_type(p))); + mp_snprintf(msg, 256, "Variable %s is the wrong type(%s)", mp_str(mp, sname), mp_type_string(p->type)); @.Variable x is the wrong type@> delete_str_ref(sname); mp_back_error( @@ -29693,12 +29690,12 @@ void mp_do_bounds (MP mp) } pp = mp_new_bounds_node(mp, NULL, mm); mp_scan_with_list(mp, p, pp); - mp_link(p) = mp_link(mp_edge_list(lhe)); - mp_link(mp_edge_list(lhe)) = p; + p->link = mp_edge_list(lhe)->link; + mp_edge_list(lhe)->link = p; if (mp_obj_tail(lhe) == mp_edge_list(lhe)) { mp_obj_tail(lhe) = p; } - mp_link(mp_obj_tail(lhe)) = pp; + mp_obj_tail(lhe)->link = pp; mp_obj_tail(lhe) = pp; mp_init_bbox(mp, lhe); } @@ -29745,7 +29742,7 @@ void mp_do_add_to (MP mp) } else { e = mp_private_edges(mp, (mp_edge_header_node) cur_exp_node); mp->cur_exp.type = mp_vacuous_type; - p = mp_link(mp_edge_list(e)); + p = mp_edge_list(e)->link; } } else { /* @@ -29802,17 +29799,17 @@ void mp_do_add_to (MP mp) } else if (add_type == mp_add_also_code) { if (e != NULL) { /* Merge |e| into |lhe| and delete |e| */ - if (mp_link(mp_edge_list(e)) != NULL) { - mp_link(mp_obj_tail(lhe)) = mp_link(mp_edge_list(e)); + if (mp_edge_list(e)->link != NULL) { + mp_obj_tail(lhe)->link = mp_edge_list(e)->link; mp_obj_tail(lhe) = mp_obj_tail(e); mp_obj_tail(e) = mp_edge_list(e); - mp_link(mp_edge_list(e)) = NULL; + mp_edge_list(e)->link = NULL; mp_flush_dash_list(mp, lhe); } mp_toss_edges(mp, e); } } else if (p != NULL) { - mp_link(mp_obj_tail(lhe)) = p; + mp_obj_tail(lhe)->link = p; mp_obj_tail(lhe) = p; if (add_type == mp_add_double_path_code) { if (mp_pen_ptr((mp_shape_node) p) == NULL) { @@ -30225,13 +30222,13 @@ typedef struct mp_edge_object { @d mp_gr_export_color(q,p) if (mp_color_model(p) == mp_uninitialized_model) { - gr_color_model(q) = number_to_scaled(internal_value(mp_default_color_model_internal))/65536; + gr_color_model(q) = (unsigned char) (number_to_scaled(internal_value(mp_default_color_model_internal))/65536); gr_cyan_val(q) = 0; gr_magenta_val(q) = 0; gr_yellow_val(q) = 0; gr_black_val(q) = gr_color_model(q) == mp_cmyk_model ? (number_to_scaled(unity_t)/65536.0) : 0; } else { - gr_color_model(q) = mp_color_model(p); + gr_color_model(q) = (unsigned char) mp_color_model(p); gr_cyan_val(q) = number_to_double(p->cyan); gr_magenta_val(q) = number_to_double(p->magenta); gr_yellow_val(q) = number_to_double(p->yellow); @@ -30271,10 +30268,10 @@ struct mp_edge_object *mp_gr_export (MP mp, mp_edge_header_node h) hh->height = number_to_double(internal_value(mp_char_ht_internal)); hh->depth = number_to_double(internal_value(mp_char_dp_internal)); hh->italic = number_to_double(internal_value(mp_char_ic_internal)); - p = mp_link(mp_edge_list(h)); + p = mp_edge_list(h)->link; while (p != NULL) { - mp_graphic_object *hq = mp_new_graphic_object(mp, (int) ((mp_type(p) - mp_fill_node_type) + 1)); - switch (mp_type(p)) { + mp_graphic_object *hq = mp_new_graphic_object(mp, (int) ((p->type - mp_fill_node_type) + 1)); + switch (p->type) { /* todo: share code between fill and stroked */ case mp_fill_node_type: { @@ -30366,7 +30363,7 @@ struct mp_edge_object *mp_gr_export (MP mp, mp_edge_header_node h) gr_link(hp) = hq; } hp = hq; - p = mp_link(p); + p = p->link; } return hh; } @@ -30563,8 +30560,8 @@ only serialize symbolic names, strings and single tokens. // p = mp_cur_tok(mp); // if (p) { // /* simplified mp_show_token_list */ -// if (mp_type(p) == mp_symbol_node_type) { -// // if (mp_name_type(p) != mp_expr_operation && mp_name_type(p) != mp_suffix_operation && mp_name_type(p) != mp_text_operation) { +// if (p->type == mp_symbol_node_type) { +// // if (p->name_type != mp_expr_operation && p->name_type != mp_suffix_operation && p->name_type != mp_text_operation) { // mp_sym sr = mp_get_sym_sym(p); // // if (sr != mp_collective_subscript) { // mp_string rr = text(sr); @@ -30573,8 +30570,8 @@ only serialize symbolic names, strings and single tokens. // } // // } // // } -// } else if (mp_name_type(p) == mp_token_operation) { -// if (mp_type(p) == mp_string_type) { +// } else if (p->name_type == mp_token_operation) { +// if (p->type == mp_string_type) { // r = mp_get_value_str(p)->str; // } // } @@ -30604,15 +30601,15 @@ void mp_scan_symbol_value (MP mp, int keep, char **s, int expand) unsigned char *r = NULL; mp_node p = mp_new_symbolic_node(mp); mp_set_sym_sym(p, cur_sym); - mp_name_type(p) = cur_sym_mod; - if (mp_type(p) == mp_symbol_node_type) { + p->name_type = cur_sym_mod; + if (p->type == mp_symbol_node_type) { mp_sym sr = mp_get_sym_sym(p); mp_string rr = text(sr); if (rr && rr->str) { r = rr->str; } - } else if (mp_name_type(p) == mp_token_operation) { - if (mp_type(p) == mp_string_type) { + } else if (p->name_type == mp_token_operation) { + if (p->type == mp_string_type) { r = mp_get_value_str(p)->str; } } @@ -30725,7 +30722,7 @@ void mp_scan_numeric_value (MP mp, int primary, double *d) } # define mp_set_double_value(mp,target,what) \ -if (mp_type(what) == mp_known_type) { \ +if (what->type == mp_known_type) { \ *target = number_to_double(mp_get_value_number(what)); \ } @@ -30887,8 +30884,8 @@ void mp_push_pair_value (MP mp, double x, double y) v = mp_get_value_node(p); new_number_from_double(mp, px, x); new_number_from_double(mp, py, y); - mp_type(mp_x_part(v)) = mp_known_type; - mp_type(mp_y_part(v)) = mp_known_type; + mp_x_part(v)->type = mp_known_type; + mp_y_part(v)->type = mp_known_type; mp_set_value_number(mp_x_part(v), px); mp_set_value_number(mp_y_part(v), py); free_number(px); @@ -30896,13 +30893,13 @@ void mp_push_pair_value (MP mp, double x, double y) /* memset(&new_expr, 0, sizeof(mp_value)); new_number(new_expr.data.n); - new_expr.type = mp_type(p); + new_expr.type = p->type; new_expr.data.node = p; mp_flush_cur_exp(mp, new_expr); mp->cur_exp.type = mp_pair_type; - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; */ - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp->cur_exp.type = mp_pair_type; mp_set_cur_exp_node(mp, p); mp_back_expr(mp); @@ -30918,16 +30915,16 @@ void mp_push_color_value (MP mp, double r, double g, double b) new_number_from_double(mp, pr, r); new_number_from_double(mp, pg, g); new_number_from_double(mp, pb, b); - mp_type(mp_red_part (v)) = mp_known_type; - mp_type(mp_green_part(v)) = mp_known_type; - mp_type(mp_blue_part (v)) = mp_known_type; + mp_red_part (v)->type = mp_known_type; + mp_green_part(v)->type = mp_known_type; + mp_blue_part (v)->type = mp_known_type; mp_set_value_number(mp_red_part (v), pr); mp_set_value_number(mp_green_part(v), pg); mp_set_value_number(mp_blue_part (v), pb); free_number(pr); free_number(pg); free_number(pb); - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp->cur_exp.type = mp_color_type; mp_set_cur_exp_node(mp, p); mp_back_expr(mp); @@ -30944,10 +30941,10 @@ void mp_push_cmykcolor_value (MP mp, double c, double m, double y, double k) new_number_from_double(mp, pm, m); new_number_from_double(mp, py, y); new_number_from_double(mp, pk, k); - mp_type(mp_cyan_part (v)) = mp_known_type; - mp_type(mp_magenta_part(v)) = mp_known_type; - mp_type(mp_yellow_part (v)) = mp_known_type; - mp_type(mp_black_part (v)) = mp_known_type; + mp_cyan_part (v)->type = mp_known_type; + mp_magenta_part(v)->type = mp_known_type; + mp_yellow_part (v)->type = mp_known_type; + mp_black_part (v)->type = mp_known_type; mp_set_value_number(mp_cyan_part (v), pc); mp_set_value_number(mp_magenta_part(v), pm); mp_set_value_number(mp_yellow_part (v), py); @@ -30956,7 +30953,7 @@ void mp_push_cmykcolor_value (MP mp, double c, double m, double y, double k) free_number(pm); free_number(py); free_number(pk); - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp->cur_exp.type = mp_cmykcolor_type; mp_set_cur_exp_node(mp, p); mp_back_expr(mp); @@ -30975,12 +30972,12 @@ void mp_push_transform_value (MP mp, double x, double y, double xx, double xy, d new_number_from_double(mp, pxy, xy); new_number_from_double(mp, pyx, yx); new_number_from_double(mp, pyy, yy); - mp_type(mp_x_part (v)) = mp_known_type; - mp_type(mp_y_part (v)) = mp_known_type; - mp_type(mp_xx_part(v)) = mp_known_type; - mp_type(mp_xy_part(v)) = mp_known_type; - mp_type(mp_yx_part(v)) = mp_known_type; - mp_type(mp_yy_part(v)) = mp_known_type; + mp_x_part (v)->type = mp_known_type; + mp_y_part (v)->type = mp_known_type; + mp_xx_part(v)->type = mp_known_type; + mp_xy_part(v)->type = mp_known_type; + mp_yx_part(v)->type = mp_known_type; + mp_yy_part(v)->type = mp_known_type; mp_set_value_number(mp_x_part (v), px); mp_set_value_number(mp_y_part (v), py); mp_set_value_number(mp_xx_part(v), pxx); @@ -30993,7 +30990,7 @@ void mp_push_transform_value (MP mp, double x, double y, double xx, double xy, d free_number(pxy); free_number(pyx); free_number(pyy); - mp_name_type(p) = mp_capsule_operation; + p->name_type = mp_capsule_operation; mp->cur_exp.type = mp_transform_type; mp_set_cur_exp_node(mp, p); mp_back_expr(mp); @@ -31114,8 +31111,8 @@ void mp_final_cleanup (MP mp) } mp_print_str(mp, " was incomplete)"); mp->if_line = mp_if_line_field(mp->cond_ptr); - mp->cur_if = mp_name_type(mp->cond_ptr); - mp->cond_ptr = mp_link(mp->cond_ptr); + mp->cur_if = mp->cond_ptr->name_type; + mp->cond_ptr = mp->cond_ptr->link; } if (mp->history != mp_spotless) { if (((mp->history == mp_warning_issued) || (mp->interaction < mp_error_stop_mode))) { diff --git a/source/luametatex/source/mp/mpw/mpmath.w b/source/luametatex/source/mp/mpw/mpmath.w index b9001a61b..5e9592fc7 100644 --- a/source/luametatex/source/mp/mpw/mpmath.w +++ b/source/luametatex/source/mp/mpw/mpmath.w @@ -665,9 +665,9 @@ possibly become zero. We round to five digits @ @c static char *mp_string_scaled (MP mp, int s) { - (void) mp; static char scaled_string[32]; int i = 0; + (void) mp; if (s < 0) { scaled_string[i++] = '-'; s = -s; diff --git a/source/luametatex/source/mp/mpw/mpmathdecimal.w b/source/luametatex/source/mp/mpw/mpmathdecimal.w index 7854a4ff5..124c77ecb 100644 --- a/source/luametatex/source/mp/mpw/mpmathdecimal.w +++ b/source/luametatex/source/mp/mpw/mpmathdecimal.w @@ -866,19 +866,19 @@ Bad! @c int mp_number_to_scaled(mp_number *A) { - int32_t result; + int result; decNumber corrected; decNumberFromInt32(&corrected, 65536); decNumberMultiply(&corrected, &corrected, A->data.num, &mp_decimal_data.set); decNumberReduce(&corrected, &corrected, &mp_decimal_data.set); - result = (int) floor(decNumberToDouble(&corrected) + 0.5); + result = lround(decNumberToDouble(&corrected)); return result; } @ @c int mp_number_to_int(mp_number *A) { - int32_t result; + int result; mp_decimal_data.set.status = 0; result = decNumberToInt32(A->data.num, &mp_decimal_data.set); if (mp_decimal_data.set.status == DEC_Invalid_operation) { @@ -892,7 +892,7 @@ int mp_number_to_int(mp_number *A) int mp_number_to_boolean(mp_number *A) { - uint32_t result; + unsigned int result; mp_decimal_data.set.status = 0; result = decNumberToUInt32(A->data.num, &mp_decimal_data.set); if (mp_decimal_data.set.status == DEC_Invalid_operation) { @@ -1737,7 +1737,7 @@ typedef struct mp_decimal_random_info { long *ptr; } mp_decimal_random_info; -mp_decimal_random_info mp_decimal_random_data = { +static mp_decimal_random_info mp_decimal_random_data = { .dummy = -1, .started = -1, .ptr = &mp_decimal_random_data.dummy diff --git a/source/luametatex/source/mp/mpw/mpmathdouble.w b/source/luametatex/source/mp/mpw/mpmathdouble.w index 83741794b..ab9caf460 100644 --- a/source/luametatex/source/mp/mpw/mpmathdouble.w +++ b/source/luametatex/source/mp/mpw/mpmathdouble.w @@ -1270,7 +1270,7 @@ typedef struct mp_double_random_info { long *ptr; } mp_double_random_info; -mp_double_random_info mp_double_random_data = { +static mp_double_random_info mp_double_random_data = { .dummy = -1, .started = -1, .ptr = &mp_double_random_data.dummy diff --git a/source/luametatex/source/mp/mpw/mpstrings.w b/source/luametatex/source/mp/mpw/mpstrings.w index 07236bd9c..b8e421b00 100644 --- a/source/luametatex/source/mp/mpw/mpstrings.w +++ b/source/luametatex/source/mp/mpw/mpstrings.w @@ -438,7 +438,7 @@ mp_string mp_chop_string(MP mp, mp_string s, int a, int b) a = l; } } - mp_str_room(mp, (size_t) (b - a)); + mp_str_room(mp, (b - a)); if (reversed) { for (int k = b - 1; k >= a; k--) { mp_append_char(mp, *(s->str + k)); diff --git a/source/luametatex/source/tex/texbuildpage.c b/source/luametatex/source/tex/texbuildpage.c index 0e2883305..0cf8b70e9 100644 --- a/source/luametatex/source/tex/texbuildpage.c +++ b/source/luametatex/source/tex/texbuildpage.c @@ -1011,8 +1011,8 @@ static void tex_aux_fire_up(halfword c) wait = 1; } } + split_best_insert(r) = null; { - split_best_insert(r) = null; /*tex We need this juggling in order to also set the old school box when we're in traditional mode. diff --git a/source/luametatex/source/tex/texcommands.c b/source/luametatex/source/tex/texcommands.c index f0949b9ab..5a4cc48b3 100644 --- a/source/luametatex/source/tex/texcommands.c +++ b/source/luametatex/source/tex/texcommands.c @@ -138,6 +138,7 @@ void tex_initialize_commands(void) tex_primitive(tex_command, "exhyphenchar", internal_int_cmd, ex_hyphen_char_code, internal_int_base); tex_primitive(tex_command, "exhyphenpenalty", internal_int_cmd, ex_hyphen_penalty_code, internal_int_base); tex_primitive(tex_command, "fam", internal_int_cmd, family_code, internal_int_base); + tex_primitive(luatex_command, "variablefam", internal_int_cmd, variable_family_code, internal_int_base); tex_primitive(tex_command, "finalhyphendemerits", internal_int_cmd, final_hyphen_demerits_code, internal_int_base); tex_primitive(tex_command, "floatingpenalty", internal_int_cmd, floating_penalty_code, internal_int_base); tex_primitive(tex_command, "globaldefs", internal_int_cmd, global_defs_code, internal_int_base); @@ -743,6 +744,7 @@ void tex_initialize_commands(void) tex_primitive(tex_command, "hyphenchar", set_font_property_cmd, font_hyphen_code, 0); tex_primitive(tex_command, "skewchar", set_font_property_cmd, font_skew_code, 0); tex_primitive(luatex_command, "efcode", set_font_property_cmd, font_ef_code, 0); + tex_primitive(luatex_command, "cfcode", set_font_property_cmd, font_cf_code, 0); tex_primitive(luatex_command, "lpcode", set_font_property_cmd, font_lp_code, 0); tex_primitive(luatex_command, "rpcode", set_font_property_cmd, font_rp_code, 0); tex_primitive(tex_command, "fontdimen", set_font_property_cmd, font_dimen_code, 0); diff --git a/source/luametatex/source/tex/texcommands.h b/source/luametatex/source/tex/texcommands.h index 792e23662..6d85f1ed7 100644 --- a/source/luametatex/source/tex/texcommands.h +++ b/source/luametatex/source/tex/texcommands.h @@ -462,12 +462,16 @@ typedef enum convert_codes { # define first_convert_code number_code # define last_convert_code luatex_banner_code +/*tex + At some point we might make |token_input_code| behave like |tex_token_input_code| and get rid + of |\everyeof| which is a quite useless feature that does more harm than good. +*/ + typedef enum input_codes { normal_input_code, end_of_input_code, token_input_code, tex_token_input_code, - /* for now private */ tokenized_code, retokenized_code, quit_loop_code, @@ -577,6 +581,7 @@ typedef enum font_property_codes { font_lp_code, font_rp_code, font_ef_code, + font_cf_code, font_dimen_code, scaled_font_dimen_code, } font_property_codes; @@ -1067,7 +1072,7 @@ typedef enum math_styles { # define first_math_style display_style # define last_math_style all_cramped_styles -# define is_valid_math_style(n) (n >= display_style && n <= cramped_script_script_style) +# define is_valid_math_style(n) (n >= display_style && n <= cramped_script_script_style) # define are_valid_math_styles(n) (n >= all_display_styles && n <= all_cramped_styles) inline static halfword tex_math_style_to_size(halfword s) diff --git a/source/luametatex/source/tex/texconditional.c b/source/luametatex/source/tex/texconditional.c index b25bdfbbe..be68a8d6d 100644 --- a/source/luametatex/source/tex/texconditional.c +++ b/source/luametatex/source/tex/texconditional.c @@ -349,16 +349,19 @@ static void tex_aux_show_if_state(halfword code, halfword case_value) { tex_begin_diagnostic(); switch (code) { - case if_chk_int_code : tex_print_format("{chknum %i}", case_value); break; - case if_val_int_code : tex_print_format("{numval %i}", case_value); break; - case if_cmp_int_code : tex_print_format("{cmpnum %i}", case_value); break; - case if_chk_dim_code : tex_print_format("{chkdim %i}", case_value); break; - case if_val_dim_code : tex_print_format("{dimval %i}", case_value); break; - case if_cmp_dim_code : tex_print_format("{cmpdim %i}", case_value); break; - case if_case_code : tex_print_format("{case %i}", case_value); break; - case if_math_style_code: tex_print_format("{mathstyle %i}", case_value); break; - case if_arguments_code : tex_print_format("{arguments %i}", case_value); break; - default : tex_print_format("{todo %i}", case_value); break; + case if_chk_int_code : tex_print_format("{chknum %i}", case_value); break; + case if_val_int_code : tex_print_format("{numval %i}", case_value); break; + case if_cmp_int_code : tex_print_format("{cmpnum %i}", case_value); break; + case if_chk_dim_code : tex_print_format("{chkdim %i}", case_value); break; + case if_val_dim_code : tex_print_format("{dimval %i}", case_value); break; + case if_cmp_dim_code : tex_print_format("{cmpdim %i}", case_value); break; + case if_case_code : tex_print_format("{case %i}", case_value); break; + case if_math_parameter_code: tex_print_format("{mathparameter %i}", case_value); break; + case if_math_style_code : tex_print_format("{mathstyle %i}", case_value); break; + case if_arguments_code : tex_print_format("{arguments %i}", case_value); break; + case if_parameters_code : tex_print_format("{parameter %i}", case_value); break; + case if_parameter_code : tex_print_format("{parameters %i}", case_value); break; + default : tex_print_format("{todo %i}", case_value); break; } tex_end_diagnostic(); } @@ -776,38 +779,44 @@ void tex_conditional_if(halfword code, int unless) goto RESULT; case if_flags_code: { - singleword flag, fl; + halfword cs; + singleword flag; tex_get_r_token(); - flag = eq_flag(cur_cs); + cs = cur_cs; + flag = eq_flag(cs); /* todo: each prefix */ tex_get_token(); if (cur_cmd == prefix_cmd) { switch (cur_chr) { - case permanent_code : result = is_permanent (flag); break; - case immutable_code : result = is_immutable (flag); break; - case mutable_code : result = is_mutable (flag); break; - case noaligned_code : result = is_noaligned (flag); break; - case instance_code : result = is_instance (flag); break; - case untraced_code : result = is_untraced (flag); break; - case global_code : result = is_global (flag); break; - case tolerant_code : result = is_tolerant (flag); break; - case protected_code : result = is_protected (flag); break; - case overloaded_code : result = is_overloaded (flag); break; - case aliased_code : result = is_aliased (flag); break; - case immediate_code : result = is_immediate (flag); break; - case semiprotected_code : result = is_semiprotected(flag); break; + /*tex We check flags: */ + case frozen_code : result = is_frozen (flag); break; + case permanent_code : result = is_permanent(flag); break; + case immutable_code : result = is_immutable(flag); break; + /* case primitive_code : result = is_primitive(flag); break; */ + case mutable_code : result = is_mutable (flag); break; + case noaligned_code : result = is_noaligned(flag); break; + case instance_code : result = is_instance (flag); break; + case untraced_code : result = is_untraced (flag); break; + /*tex We check cmd: */ + case global_code : result = eq_level(cs) == level_one;; break; + case tolerant_code : result = is_tolerant_cmd(eq_type(cs)); break; + case protected_code : result = is_protected_cmd(eq_type(cs)); break; + case semiprotected_code : result = is_semi_protected_cmd(eq_type(cs)); break; } } else { + int fl; tex_back_input(cur_tok); - fl = (singleword) tex_scan_int(1, NULL); /* maybe some checking or masking is needed here */ + fl = tex_scan_int(1, NULL); result = (flag & fl) == fl; if (! result) { if (is_protected(fl)) { - result = is_protected_cmd(eq_type(cur_cs)); + result = is_protected_cmd(eq_type(cs)); + } else if (is_semiprotected(fl)) { + result = is_semi_protected_cmd(eq_type(cs)); } else if (is_tolerant(fl)) { - result = is_tolerant_cmd(eq_type(cur_cs)); + result = is_tolerant_cmd(eq_type(cs)); } else if (is_global(fl)) { - result = eq_level(cur_cs) == level_one; + result = eq_level(cs) == level_one; } } } diff --git a/source/luametatex/source/tex/texdumpdata.h b/source/luametatex/source/tex/texdumpdata.h index bea80869d..e6f51d323 100644 --- a/source/luametatex/source/tex/texdumpdata.h +++ b/source/luametatex/source/tex/texdumpdata.h @@ -55,7 +55,7 @@ */ -# define luametatex_format_fingerprint 674 +# define luametatex_format_fingerprint 675 /* These end up in the string pool. */ @@ -71,8 +71,11 @@ extern int tex_load_fmt_file (void); extern int tex_fatal_undump_error (const char *s); extern void tex_initialize_dump_state (void); -# define dump_items(f,p,item_size,nitems) fwrite((void *) p, (size_t) item_size, (size_t) nitems, f) -# define undump_items(f,p,item_size,nitems) { if (fread ((void *) p, (size_t) item_size, (size_t) nitems, f)) { } } +//define dump_items(f,p,item_size,nitems) fwrite((void *) p, (size_t) item_size, (size_t) nitems, f) +//define undump_items(f,p,item_size,nitems) { if (fread ((void *) p, (size_t) item_size, (size_t) nitems, f)) { } } + +# define dump_items(f,p,item_size,nitems) fwrite((void *) p, (size_t) item_size, (size_t) nitems, f) +# define undump_items(f,p,item_size,nitems) fread ((void *) p, (size_t) item_size, (size_t) nitems, f) # define dump_things(f,base,len) dump_items(f, (char *) &(base), sizeof (base), (int) (len)) # define undump_things(f,base,len) undump_items(f, (char *) &(base), sizeof (base), (int) (len)) diff --git a/source/luametatex/source/tex/texequivalents.c b/source/luametatex/source/tex/texequivalents.c index aa434d8fd..4de7617c9 100644 --- a/source/luametatex/source/tex/texequivalents.c +++ b/source/luametatex/source/tex/texequivalents.c @@ -711,8 +711,8 @@ void tex_show_save_groups(void) FOUND1: { /*tex Show the box packaging info. */ - tex_print_str_esc(package); halfword packing, amount; + tex_print_str_esc(package); if (tex_aux_saved_box_spec(&packing, &amount)) { tex_print_str(packing == packing_exactly ? " to " : " spread "); tex_print_dimension(amount, pt_unit); @@ -1970,3 +1970,18 @@ int tex_located_save_value(int id) } return 0; } + +extern int tex_cs_state(halfword p) +{ + if (p == null_cs) { + return cs_null_error; + } else if (p < hash_base) { + return cs_below_base_error; + } else if (p == undefined_control_sequence) { + return cs_undefined_error; + } else if (eqtb_out_of_range(p)) { + return cs_out_of_range_error; + } else { + return cs_no_error; + } +} diff --git a/source/luametatex/source/tex/texequivalents.h b/source/luametatex/source/tex/texequivalents.h index 24a1729f9..2feab6858 100644 --- a/source/luametatex/source/tex/texequivalents.h +++ b/source/luametatex/source/tex/texequivalents.h @@ -571,6 +571,7 @@ typedef enum int_codes { alignment_wrap_source_code, /* page_boundary_penalty_code, */ line_break_criterium_code, + variable_family_code, /* those below these are not interfaced via primitives */ internal_par_state_code, internal_dir_state_code, @@ -1347,6 +1348,7 @@ extern void tex_forced_word_define (int g, halfword p, singleword flag, halfword # define split_top_skip_par glue_parameter(split_top_skip_code) # define cur_fam_par count_parameter(family_code) +# define variable_family_par count_parameter(variable_family_code) # define pre_display_direction_par count_parameter(pre_display_direction_code) # define pre_display_penalty_par count_parameter(pre_display_penalty_code) # define post_display_penalty_par count_parameter(post_display_penalty_code) @@ -1705,6 +1707,7 @@ extern halfword tex_explicit_disc_penalty (halfword mode); # define update_tex_glyph_state(a,v) tex_word_define(a, internal_int_location(glyph_state_code), v) # define update_tex_glyph_script(a,v) tex_word_define(a, internal_int_location(glyph_script_code), v) # define update_tex_family(a,v) tex_word_define(a, internal_int_location(family_code), v) +# define update_tex_variable_family(a,v) tex_word_define(a, internal_int_location(variable_family_code), v) # define update_tex_language(a,v) tex_word_define(a, internal_int_location(language_code), v) # define update_tex_font(a,v) tex_word_define(a, internal_int_location(font_code), v) @@ -1766,4 +1769,14 @@ extern halfword tex_explicit_disc_penalty (halfword mode); # define insert_maxheight(A) dimen_register(A) # define insert_distance(A) skip_register(A) +typedef enum cs_errors { + cs_no_error, + cs_null_error, + cs_below_base_error, + cs_undefined_error, + cs_out_of_range_error, +} cs_errors; + +extern int tex_cs_state(halfword p) ; + # endif diff --git a/source/luametatex/source/tex/texerrors.c b/source/luametatex/source/tex/texerrors.c index bcc581f21..1d1e83dc9 100644 --- a/source/luametatex/source/tex/texerrors.c +++ b/source/luametatex/source/tex/texerrors.c @@ -610,7 +610,7 @@ extern void tex_handle_error(error_types type, const char *format, ...) va_list args; va_start(args, format); /* hm, weird, no number */ tex_aux_start_error(); - tex_print_format_args(format, args); + str = tex_print_format_args(format, args); tex_aux_update_help_text(str); tex_aux_do_handle_error_type(type); va_end(args); diff --git a/source/luametatex/source/tex/texexpand.c b/source/luametatex/source/tex/texexpand.c index a0416d118..e74a9c08d 100644 --- a/source/luametatex/source/tex/texexpand.c +++ b/source/luametatex/source/tex/texexpand.c @@ -528,13 +528,22 @@ void tex_expand_current_token(void) default: /* Maybe ... or maybe an option */ // if (lmt_expand_state.cs_name_level == 0) { - /*tex Complain about an undefined macro */ - tex_handle_error( - normal_error_type, - "Undefined control sequence %m", cur_cs, - "The control sequence at the end of the top line of your error message was never\n" - "\\def'ed. You can just continue as I'll forget about whatever was undefined." - ); + if (tex_cs_state(cur_cs) == cs_undefined_error) { + /*tex Complain about an undefined macro */ + tex_handle_error( + normal_error_type, + "Undefined control sequence %m", cur_cs, + "The control sequence at the end of the top line of your error message was never\n" + "\\def'ed. You can just continue as I'll forget about whatever was undefined." + ); + } else { + /*tex We ended up in a situation that is unlikely to happen in traditional \TEX. */ + tex_handle_error( + normal_error_type, + "Control sequence expected instead of %C", cur_cmd, cur_chr, + "You injected something that confused the parser, maybe by using some Lua call." + ); + } // } break; } @@ -1027,7 +1036,7 @@ static void tex_aux_macro_call(halfword cs, halfword cmd, halfword chr) s = null; goto BAD; } - break; + // break; case thrash_match_token: match = 0; thrash = 1; diff --git a/source/luametatex/source/tex/texfont.c b/source/luametatex/source/tex/texfont.c index 605d6ff75..4aad8f495 100644 --- a/source/luametatex/source/tex/texfont.c +++ b/source/luametatex/source/tex/texfont.c @@ -134,33 +134,18 @@ void tex_undump_font_data(dumpstream f) { lmt_font_state.font_data.ptr = 0; } -void tex_set_charinfo_vertical_parts(charinfo *ci, extinfo *ext) +void tex_set_charinfo_extensible_recipe(charinfo *ci, extinfo *ext) { if (ci->math) { - if (ci->math->vertical_parts) { - extinfo *lst = ci->math->vertical_parts; + extinfo *lst = ci->math->extensible_recipe; + if (lst) { while (lst) { extinfo *c = lst->next; lmt_memory_free(lst); lst = c; } } - ci->math->vertical_parts = ext; - } -} - -void tex_set_charinfo_horizontal_parts(charinfo *ci, extinfo *ext) -{ - if (ci->math) { - if (ci->math->horizontal_parts) { - extinfo *lst = ci->math->horizontal_parts; - while (lst) { - extinfo *c = lst->next; - lmt_memory_free(lst); - lst = c; - } - } - ci->math->horizontal_parts = ext; + ci->math->extensible_recipe = ext; } } @@ -245,8 +230,8 @@ void tex_char_malloc_mathinfo(charinfo *ci) int size = sizeof(mathinfo); mathinfo *mi = lmt_memory_calloc(1, (size_t) size); if (mi) { - mi->horizontal_parts = NULL; - mi->vertical_parts = NULL; + mi->extensible_recipe = NULL; + /* */ mi->top_left_math_kern_array = NULL; mi->top_right_math_kern_array = NULL; mi->bottom_right_math_kern_array = NULL; @@ -256,6 +241,7 @@ void tex_char_malloc_mathinfo(charinfo *ci) mi->top_right_kern = 0; mi->bottom_left_kern = 0; mi->bottom_right_kern = 0; + /* */ mi->left_margin = 0; mi->right_margin = 0; mi->top_margin = 0; @@ -265,8 +251,7 @@ void tex_char_malloc_mathinfo(charinfo *ci) mi->bottom_overshoot = INT_MIN; if (ci->math) { /*tex This seldom or probably never happens. */ - tex_set_charinfo_vertical_parts(ci, NULL); - tex_set_charinfo_horizontal_parts(ci, NULL); + tex_set_charinfo_extensible_recipe(ci, NULL); set_charinfo_top_left_math_kern_array(ci, NULL); set_charinfo_top_right_math_kern_array(ci, NULL); set_charinfo_bottom_right_math_kern_array(ci, NULL); @@ -281,12 +266,19 @@ void tex_char_malloc_mathinfo(charinfo *ci) } } -# define find_charinfo_id(f,c) (sa_get_item_4(lmt_font_state.fonts[f]->characters,c).int_value) +inline int aux_find_charinfo_id(halfword f, int c) +{ + sa_tree_item item; + sa_get_item_4(lmt_font_state.fonts[f]->characters, c, &item); + return (int) item.int_value; +} charinfo *tex_get_charinfo(halfword f, int c) { if (proper_char_index(f, c)) { - int glyph = sa_get_item_4(lmt_font_state.fonts[f]->characters, c).int_value; + sa_tree_item item; + sa_get_item_4(lmt_font_state.fonts[f]->characters, c, &item); + int glyph = (int) item.int_value; if (! glyph) { sa_tree_item sa_value = { 0 }; int tglyph = ++lmt_font_state.fonts[f]->chardata_count; @@ -334,7 +326,7 @@ static charinfo *tex_aux_char_info(halfword f, int c) if (f > lmt_font_state.font_data.ptr) { return NULL; } else if (proper_char_index(f, c)) { - return &(lmt_font_state.fonts[f]->chardata[(int) find_charinfo_id(f, c)]); + return &(lmt_font_state.fonts[f]->chardata[(int) aux_find_charinfo_id(f, c)]); } else if (c == left_boundary_char) { if (font_left_boundary(f)) { return font_left_boundary(f); @@ -363,7 +355,7 @@ int tex_char_exists(halfword f, int c) if (f > lmt_font_state.font_data.ptr) { return 0; } else if (proper_char_index(f, c)) { - return (int) find_charinfo_id(f, c); + return (int) aux_find_charinfo_id(f, c); } else if (c == left_boundary_char) { if (font_has_left_boundary(f)) { return 1; @@ -384,7 +376,7 @@ static int check_math_char(halfword f, int c, int size) if (callback_id > 0) { halfword s = c; lmt_run_callback(lua_state.lua_instance, callback_id, "ddd->d", f, c, size, &s); - if (s && proper_char_index(f, s) && find_charinfo_id(f, s)) { + if (s && proper_char_index(f, s) && aux_find_charinfo_id(f, s)) { return s; } } @@ -405,7 +397,7 @@ int tex_math_char_exists(halfword f, int c, int size) int tex_get_math_char(halfword f, int c, int size, scaled *scale, int direction) { - int id = find_charinfo_id(f, c); + int id = aux_find_charinfo_id(f, c); texfont *tf = lmt_font_state.fonts[f]; if (id) { /* */ @@ -413,7 +405,7 @@ int tex_get_math_char(halfword f, int c, int size, scaled *scale, int direction) charinfo *ci = &tf->chardata[id]; int m = ci->math->mirror; if (m && proper_char_index(f, m)) { - int mid = find_charinfo_id(f, m); + int mid = aux_find_charinfo_id(f, m); if (mid) { id = mid; c = m; @@ -427,7 +419,7 @@ int tex_get_math_char(halfword f, int c, int size, scaled *scale, int direction) if (ci->math) { int s = ci->math->smaller; if (s && proper_char_index(f, s)) { - id = find_charinfo_id(f, s); + id = aux_find_charinfo_id(f, s); if (id) { /* todo: trace */ c = s; @@ -452,58 +444,33 @@ int tex_get_math_char(halfword f, int c, int size, scaled *scale, int direction) return c; } -extinfo *tex_new_charinfo_part(int glyph, int startconnect, int endconnect, int advance, int extender) -{ - int size = sizeof(extinfo); - extinfo *ext = lmt_memory_malloc((size_t) size); - if (ext) { - ext->next = NULL; - ext->glyph = glyph; - ext->start_overlap = startconnect; - ext->end_overlap = endconnect; - ext->advance = advance; - ext->extender = extender; - } else { - tex_overflow_error("font", size); - } - return ext; -} - -void tex_add_charinfo_vertical_part(charinfo *ci, extinfo *ext) -{ - if (ci->math) { - if (ci->math->vertical_parts) { - extinfo *lst = ci->math->vertical_parts; - while (lst->next) - lst = lst->next; - lst->next = ext; - } else { - ci->math->vertical_parts = ext; - } - } -} - -void tex_add_charinfo_horizontal_part(charinfo *ci, extinfo *ext) +void tex_append_charinfo_extensible_recipe(charinfo *ci, int glyph, int startconnect, int endconnect, int advance, int extender) { if (ci->math) { - if (ci->math->horizontal_parts) { - extinfo *lst = ci->math->horizontal_parts; - while (lst->next) { - lst = lst->next; + int size = sizeof(extinfo); + extinfo *ext = lmt_memory_malloc((size_t) size); + if (ext) { + extinfo *lst = ci->math->extensible_recipe; + ext->next = NULL; + ext->glyph = glyph; + ext->start_overlap = startconnect; + ext->end_overlap = endconnect; + ext->advance = advance; + ext->extender = extender; + if (lst) { + while (lst->next) { + lst = lst->next; + } + lst->next = ext; + } else { + ci->math->extensible_recipe = ext; } - lst->next = ext; } else { - ci->math->horizontal_parts = ext; + tex_overflow_error("font", size); } } } -/*tex - - Note that many more small things like this are implemented as macros in the header file. - -*/ - int tex_get_charinfo_math_kerns(charinfo *ci, int id) { /*tex All callers check for |result > 0|. */ @@ -598,43 +565,43 @@ void tex_add_charinfo_math_kern(charinfo *ci, int id, scaled ht, scaled krn) A small complication arises if |rep| is the only non-zero: it needs to be doubled as a non-repeatable to avoid mayhem. -*/ - -void tex_set_charinfo_extensible(charinfo *ci, int top, int bottom, int middle, int extender) -{ - if (ci->math) { - extinfo *ext; - /*tex Clear old data: */ - tex_set_charinfo_vertical_parts(ci, NULL); - if (bottom == 0 && top == 0 && middle == 0 && extender != 0) { - ext = tex_new_charinfo_part(extender, 0, 0, 0, math_extension_normal); - tex_add_charinfo_vertical_part(ci, ext); - ext = tex_new_charinfo_part(extender, 0, 0, 0, math_extension_repeat); - tex_add_charinfo_vertical_part(ci, ext); - } else { - if (bottom) { - ext = tex_new_charinfo_part(bottom, 0, 0, 0, math_extension_normal); - tex_add_charinfo_vertical_part(ci, ext); - } - if (extender) { - ext = tex_new_charinfo_part(extender, 0, 0, 0, math_extension_repeat); - tex_add_charinfo_vertical_part(ci, ext); - } - if (middle) { - ext = tex_new_charinfo_part(middle, 0, 0, 0, math_extension_normal); - tex_add_charinfo_vertical_part(ci, ext); + \starttyping + void tex_set_charinfo_extensible(charinfo *ci, int top, int bottom, int middle, int extender) + { + if (ci->math) { + extinfo *ext; + tex_set_charinfo_extensible_recipe(ci, NULL); + if (bottom == 0 && top == 0 && middle == 0 && extender != 0) { + ext = tex_new_charinfo_extensible_step(extender, 0, 0, 0, math_extension_normal); + tex_add_charinfo_extensible_step(ci, ext); + ext = tex_new_charinfo_extensible_step(extender, 0, 0, 0, math_extension_repeat); + tex_add_charinfo_extensible_step(ci, ext); + } else { + if (bottom) { + ext = tex_new_charinfo_extensible_step(bottom, 0, 0, 0, math_extension_normal); + tex_add_charinfo_extensible_step(ci, ext); + } if (extender) { - ext = tex_new_charinfo_part(extender, 0, 0, 0, math_extension_repeat); - tex_add_charinfo_vertical_part(ci, ext); + ext = tex_new_charinfo_extensible_step(extender, 0, 0, 0, math_extension_repeat); + tex_add_charinfo_extensible_step(ci, ext); + } + if (middle) { + ext = tex_new_charinfo_extensible_step(middle, 0, 0, 0, math_extension_normal); + tex_add_charinfo_extensible_step(ci, ext); + if (extender) { + ext = tex_new_charinfo_extensible_step(extender, 0, 0, 0, math_extension_repeat); + tex_add_charinfo_extensible_step(ci, ext); + } + } + if (top) { + ext = tex_new_charinfo_extensible_step(top, 0, 0, 0, math_extension_normal); + tex_add_charinfo_extensible_step(ci, ext); } - } - if (top) { - ext = tex_new_charinfo_part(top, 0, 0, 0, math_extension_normal); - tex_add_charinfo_vertical_part(ci, ext); } } } -} + \stoptyping +*/ /*tex why not just preallocate for all math otf parameters */ @@ -667,13 +634,12 @@ void tex_delete_font(int f) set_font_left_boundary(f, NULL); set_font_right_boundary(f, NULL); for (int i = font_first_character(f); i <= font_last_character(f); i++) { - if (quick_char_exists(f, i)) { + if (tex_char_exists(f, i)) { charinfo *co = tex_aux_char_info(f, i); set_charinfo_kerns(co, NULL); set_charinfo_ligatures(co, NULL); if (co->math) { - tex_set_charinfo_vertical_parts(co, NULL); - tex_set_charinfo_horizontal_parts(co, NULL); + tex_set_charinfo_extensible_recipe(co, NULL); set_charinfo_top_left_math_kern_array(co, NULL); set_charinfo_top_right_math_kern_array(co, NULL); set_charinfo_bottom_right_math_kern_array(co, NULL); @@ -1119,11 +1085,6 @@ static halfword tex_aux_handle_ligature_nesting(halfword root, halfword cur) have (any kind of) discretionaries. It is still on my agenda to look into nested discretionaries i.e. discs nodes in disc fields but it might never result in useable code. - Remark: there is now a patch for \LUATEX\ that fixes some long pending issue with select discs but - still it's kind of fuzzy. It also complicates the par builder in a way that I don't really want - (at least in \CONTEXT). It was anyway a good reason for removing traces of these special disc nodes - in \LUAMETATEX. - */ static halfword tex_aux_handle_ligature_word(halfword cur) @@ -1327,7 +1288,6 @@ static halfword tex_aux_handle_ligature_word(halfword cur) return cur; } - /*tex The return value is the new tail, head should be a dummy: */ halfword tex_handle_ligaturing(halfword head, halfword tail) @@ -1725,6 +1685,11 @@ scaled tex_char_ef_from_font(halfword f, halfword c) return tex_aux_char_info(f, c)->expansion; } +scaled tex_char_cf_from_font(halfword f, halfword c) +{ + return tex_aux_char_info(f, c)->compression; +} + scaled tex_char_lp_from_font(halfword f, halfword c) { return tex_aux_char_info(f, c)->leftprotrusion; @@ -1737,32 +1702,35 @@ scaled tex_char_rp_from_font(halfword f, halfword c) halfword tex_char_has_tag_from_font(halfword f, halfword c, halfword tag) { - return (charinfo_tag(tex_aux_char_info(f, c)->tagrem) & tag) == tag; + return (tex_aux_char_info(f, c)->tag & tag) == tag; } void tex_char_reset_tag_from_font(halfword f, halfword c, halfword tag) { charinfo *ci = tex_aux_char_info(f, c); - // tag = charinfo_tag(ci->tagrem) & ~(tag | charinfo_tag(ci->tagrem)); - tag = charinfo_tag(ci->tagrem) & ~(tag); - ci->tagrem = charinfo_tagrem(tag,charinfo_rem(ci->tagrem)); - + ci->tag = ci->tag & ~(tag); } halfword tex_char_tag_from_font(halfword f, halfword c) { - return charinfo_tag(tex_aux_char_info(f, c)->tagrem); + return tex_aux_char_info(f, c)->tag; +} + +int tex_char_checked_tag(halfword tag) +{ + return tag & (horizontal_tag | vertical_tag | extend_last_tag | italic_tag | n_ary_tag | radical_tag | punctuation_tag); } -halfword tex_char_remainder_from_font(halfword f, halfword c) +halfword tex_char_next_from_font(halfword f, halfword c) { - return charinfo_rem(tex_aux_char_info(f, c)->tagrem); + charinfo *ci = tex_aux_char_info(f, c); + return ci->math ? ci->math->next : -1; } -halfword tex_char_vertical_italic_from_font(halfword f, halfword c) +halfword tex_char_extensible_italic_from_font(halfword f, halfword c) { charinfo *ci = tex_aux_char_info(f, c); - return ci->math ? ci->math->vertical_italic : INT_MIN; + return ci->math ? ci->math->extensible_italic : INT_MIN; } halfword tex_char_unchecked_top_anchor_from_font(halfword f, halfword c) @@ -1819,16 +1787,10 @@ scaled tex_char_bottom_right_kern_from_font(halfword f, halfword c) return ci->math ? ci->math->bottom_right_kern : 0; } -extinfo *tex_char_vertical_parts_from_font(halfword f, halfword c) -{ - charinfo *ci = tex_aux_char_info(f, c); - return ci->math ? ci->math->vertical_parts : NULL; -} - -extinfo *tex_char_horizontal_parts_from_font(halfword f, halfword c) +extinfo *tex_char_extensible_recipe_from_font(halfword f, halfword c) { charinfo *ci = tex_aux_char_info(f, c); - return ci->math ? ci->math->horizontal_parts : NULL; + return ci->math ? ci->math->extensible_recipe : NULL; } scaled tex_char_left_margin_from_font(halfword f, halfword c) @@ -1867,6 +1829,18 @@ scaled tex_char_bottom_overshoot_from_font(halfword f, halfword c) return ci->math ? ci->math->bottom_overshoot : 0; } +scaled tex_char_inner_x_offset_from_font(halfword f, halfword c) +{ + charinfo *ci = tex_aux_char_info(f, c); + return ci->math ? ci->math->inner_x_offset : 0; +} + +scaled tex_char_inner_y_offset_from_font(halfword f, halfword c) +{ + charinfo *ci = tex_aux_char_info(f, c); + return ci->math ? ci->math->inner_y_offset : 0; +} + /* Nodes */ scaled tex_char_width_from_glyph(halfword g) @@ -1992,6 +1966,13 @@ void tex_set_efcode_in_font(halfword f, halfword c, halfword i) { } } +void tex_set_cfcode_in_font(halfword f, halfword c, halfword i) { + charinfo *ci = tex_aux_char_info(f, c); + if (ci) { + ci->compression = i; + } +} + void tex_set_font_name(halfword f, const char *s) { if (font_name(f)) { diff --git a/source/luametatex/source/tex/texfont.h b/source/luametatex/source/tex/texfont.h index e5365a0be..d3722f9ad 100644 --- a/source/luametatex/source/tex/texfont.h +++ b/source/luametatex/source/tex/texfont.h @@ -72,42 +72,68 @@ typedef struct extinfo { int padding; } extinfo; -// typedef enum math_font_options { -// math_font_ignore_italic_option = 0x01, -// } math_font_options; -// -// # define math_font_option(options,option) ((options & option) == option) +/*tex + We have dedicated fields for hparts and vparts and their italics. Only avery few fonts actually + set the italic on the extensible which is why the engine can use the regular italic, which in + that case is then the last in the variant list because that is where we put the recipe. Keep in + mind that in an \OPENTYPE\ fonts we have a base glyph that has a variant list and part recipe + while in the engine (in good \TEX\ tradition) we chain the variants (with the next field)) so by + the time we arrive at the last one we look at the (h,v) italic there. No fonts (so far) have a + horizontal extensible with a set italic correction. + + Actually, because the specification is rather explicit about glyphs only having horizontal or + vertical extensibles we now have collapsed the two categories into one. +*/ typedef struct mathinfo { - scaled vertical_italic; - scaled top_anchor; /* provided by the font, aka topaccent */ - scaled bottom_anchor; /* provided by context */ - int smaller; - scaled scale; - int flat_accent; /* flac feature code point */ - int top_left_math_kerns; /* size of array */ - int top_right_math_kerns; /* size of array */ - int bottom_right_math_kerns; /* size of array */ - int bottom_left_math_kerns; /* size of array */ - extinfo *horizontal_parts; - extinfo *vertical_parts; - scaled *top_left_math_kern_array; + /*tex + Optional code points for next smaller in size, right2left and flat accent glyphs. + */ + halfword smaller; + halfword mirror; + halfword flat_accent; + halfword next; + /*tex + The top anchor is provides by the font and is also known as topaccent while the bottom + anchor is one set by (in our case) \CONTEXT. + */ + scaled top_anchor; + scaled bottom_anchor; + /*tex + A set of pointers to variable size arrays which is why we also have the number of slots + stored. + */ + int top_left_math_kerns; + int top_right_math_kerns; + int bottom_right_math_kerns; + int bottom_left_math_kerns; + scaled *top_left_math_kern_array; scaled *top_right_math_kern_array; scaled *bottom_right_math_kern_array; scaled *bottom_left_math_kern_array; - /* these are for specific (script) anchoring */ - scaled top_left_kern; - scaled bottom_left_kern; - scaled top_right_kern; - scaled bottom_right_kern; - scaled left_margin; - scaled right_margin; - scaled top_margin; - scaled bottom_margin; - scaled top_overshoot; - scaled bottom_overshoot; - int mirror; - int padding; + /*tex + Here come the extensible recipes. Because we haven't seen both in one glyph we can share + the pointer and put a h/v flag in the tag field. For the moment we keep them both because + we might want to play with a two dimensional extensible some day. + */ + extinfo *extensible_recipe; + scaled extensible_italic; + /*tex These are for specific (script) anchoring. */ + scaled top_left_kern; + scaled bottom_left_kern; + scaled top_right_kern; + scaled bottom_right_kern; + /*tex These four are used in accents. */ + scaled left_margin; + scaled right_margin; + scaled top_margin; + scaled bottom_margin; + /*tex As are the following. */ + scaled top_overshoot; + scaled bottom_overshoot; + /*tex These are for degrees in radicals. */ + scaled inner_x_offset; + scaled inner_y_offset; } mathinfo; typedef struct charinfo { @@ -123,36 +149,59 @@ typedef struct charinfo { /*tex The next three variables relate to expansion and protrusion, properties introduced in the \PDFTEX\ engine. Handling of protrusion and expansion is the only features that we inherit - from this important extension to traditional \TEX. + from this important extension to traditional \TEX. + + We can make the next four into a a pointer which saves on large fonts and only a subset + of characters has protrusion or expansion, if used at all. That way we delegate some memory + consumption to usage (of course allocated blobs also have overhead). */ - scaled expansion; + scaled expansion; + scaled compression; scaled leftprotrusion; scaled rightprotrusion; - /* halfword padding; */ /* when we pack |tag| and |remainder| we can safe 4 bytes */ /*tex - These two are used in a \TFM\ file for signaling ligatures. They are also used for math - extensions in traditional \TEX\ fonts, so we just keep them. + The tag and remainder are used in a \TFM\ file for signaling ligatures. They are also used + for math extensions in traditional \TEX\ fonts. We used to pack the tag and remainder + in an integer: 2 bits is enough for the tag (but we get some more) and the remainder (aka + next) fits in 21 bits. So we had |tagrem| for quite a while. + + But we now use a 32 bit tag field and use proper next field that has been moved to the math + blob so that we can have a compression field here without padding. */ - /* halfword tag; */ /* 2 bits is enough (flags) */ - /* halfword remainder; */ /* 21 bits is enough (unicode) */ - halfword tagrem; /* just an integer, less (arm) alignment hassle that way */ + halfword tag; /*tex Traditional \TEX\ fonts use these two lists for ligature building and inter-character kerning and these are now optional (via pointers). By also using an indirect structure for math data we save quite a bit of memory when we have no math font. + + We could combine math and ligatures and save two slots but then we cannot have a hybrid base + font so ... not now. */ - ligatureinfo *ligatures; kerninfo *kerns; - mathinfo *math; + mathinfo *math; + ligatureinfo *ligatures; } charinfo; +/* + An option is to make this a pointer to a structure but then we also waste a slot. When we + never support it in math then we can actually go smaller: + + charinfo: 8 * 4 : width height depth italic tag *[text or math] *kerns padding + textinfo: 4 * 4 : expansion leftprotrusion rightprotrusion *ligatures + mathinfo: 2 * 4 : next padding ... n * 4 + + But ... given the amount of fields that \CONTEXT\ adds to the basic character data anyway + there is no real reason to spend much time in saving some bytes here. + +*/ + /*tex We can just abuse the token setters and getters here. */ -# define charinfo_tag token_cmd -# define charinfo_rem token_chr -# define charinfo_tagrem token_val +//define charinfo_tag token_cmd +//define charinfo_rem token_chr +//define charinfo_tagrem token_val /*tex @@ -280,10 +329,8 @@ typedef enum text_control_codes { # define has_font_text_control(f,c) ((font_textcontrol(f) & c) == c) /*tex - These are special codes that are used in the traditional ligature builder. In \OPENTYPE\ - fonts we don't see these. - + fonts we don't see these. Maybe this will be dropped at some point. */ typedef enum boundarychar_codes { @@ -292,8 +339,6 @@ typedef enum boundarychar_codes { non_boundary_char = -3, } boundarychar_codes; -/*tex These are pointers, so: |NULL| */ - # define font_left_boundary(a) lmt_font_state.fonts[a]->left_boundary # define font_right_boundary(a) lmt_font_state.fonts[a]->right_boundary @@ -304,12 +349,16 @@ typedef enum boundarychar_codes { # define set_font_right_boundary(a,b) { if (font_right_boundary(a)) { lmt_memory_free(font_right_boundary(a)); } font_right_boundary(a) = b; } /*tex + The math engine can benefit from these properties. For instance we use them for optimizing + the positioning of the degree in a (left) radical. These properties are not stored in the + tag (for a short while we had a variable). +*/ +/*tex In traditional \TEX\ there are just over a handful of font specific parameters for text fonts and some more in math fonts. Actually, these parameters were stored in a way that permitted adding more at runtime, something that made no real sense, but can be abused for creeating more dimensions than the 256 that traditional \TEX\ provides. - */ # define font_parameter_count(a) lmt_font_state.fonts[a]->parameter_count @@ -324,10 +373,8 @@ typedef enum boundarychar_codes { # define set_font_math_parameter_base(a,b) lmt_font_state.fonts[a]->math_parameter_base = b; /*tex - These font parameters could be adapted at runtime but one should really wonder if that is such a good idea nowadays. - */ //define set_font_parameter(f,n,b) { if (font_parameter_count(f) < n) { tex_set_font_parameters(f, n); } font_parameter(f, n) = b; } @@ -346,10 +393,8 @@ extern halfword tex_checked_font_adjust ( ); /*tex - Font parameters are sometimes referred to as |slant(f)|, |space(f)|, etc. These numbers are also the font dimen numbers. - */ typedef enum font_parameter_codes { @@ -372,6 +417,7 @@ extern scaled tex_get_font_extra_space (halfword f); extern scaled tex_get_font_parameter (halfword f, halfword code); extern void tex_set_font_parameter (halfword f, halfword code, scaled v); +extern scaled tex_get_scaled_slant (halfword f); extern scaled tex_get_scaled_space (halfword f); extern scaled tex_get_scaled_space_stretch (halfword f); extern scaled tex_get_scaled_space_shrink (halfword f); @@ -388,9 +434,7 @@ extern halfword tex_get_parameter_glue (quarterword p, quarterword s); extern halfword tex_get_font_identifier (halfword fs); /*tex - The \OPENTYPE\ math fonts have four edges and reference points for kerns. Here we go: - */ typedef enum font_math_kern_codes { @@ -406,17 +450,34 @@ extern void tex_char_process (halfword f, int c); extern int tex_math_char_exists (halfword f, int c, int size); extern int tex_get_math_char (halfword f, int c, int size, scaled *scale, int direction); -/*tex - - Here is a quick way to test if a glyph exists, when you are already certain the font |f| exists, - and that the |c| is a regular glyph id, not one of the two special boundary objects. Contrary - to traditional \TEX\ we store character information in a hash table instead of an array. Keep - in mind that we talk \UNICODE: plenty of characters in the code space, but less so in a font, - so we can best be sparse. +/*tex + These used to be small integers, bit 22 upto 31, but now we have a 32 bit set. We actually don't + really need the granularity but by having these flags we can actually add a bit of control, like + having kerns but still blocking them. The numbers here are no longer reflective of what a tfm + file provides. We assume tfm files to be converted anyway. + Not all are needed but at least we now can keep some state. We can actually use them to something + if we really want to (like when we runt tests). However, that is a rather drastic measure for + shared fonts. Tracing is another application and at some point it will be used for this. */ -# define quick_char_exists(f,c) (sa_get_item_4(lmt_font_state.fonts[f]->characters,c).int_value) +typedef enum char_tag_codes { + no_tag = 0x0000, /*tex vanilla character */ + ligatures_tag = 0x0001, /*tex character has a ligature program, not used */ + kerns_tag = 0x0002, /*tex character has a kerning program, not used */ + list_tag = 0x0004, /*tex character has a successor in a charlist */ + callback_tag = 0x0010, + extensible_tag = 0x0020, /*tex character is extensible, we can unset it in order to block */ + horizontal_tag = 0x0040, /*tex horizontal extensible */ + vertical_tag = 0x0080, /*tex vertical extensible */ + extend_last_tag = 0x0100, /*tex auto scale last variant */ + inner_left_tag = 0x0200, /*tex anchoring */ + inner_right_tag = 0x0400, /*tex anchoring */ + italic_tag = 0x0800, + n_ary_tag = 0x1000, + radical_tag = 0x2000, + punctuation_tag = 0x4000, +} char_tag_codes; /*tex These low level setters are not publis and used in helpers. They might become functions @@ -428,14 +489,15 @@ extern int tex_get_math_char (halfword f, int c, int size, scaled *scal # define set_charinfo_depth(ci,val) ci->depth = val; # define set_charinfo_italic(ci,val) ci->italic = val; # define set_charinfo_expansion(ci,val) ci->expansion = val; +# define set_charinfo_compression(ci,val) ci->compression = val; # define set_charinfo_leftprotrusion(ci,val) ci->leftprotrusion = val; # define set_charinfo_rightprotrusion(ci,val) ci->rightprotrusion = val; -# define set_charinfo_tag(ci,tag) ci->tagrem = charinfo_tagrem(charinfo_tag(ci->tagrem) | tag,charinfo_rem(ci->tagrem)); -# define set_charinfo_remainder(ci,rem) ci->tagrem = charinfo_tagrem(charinfo_tag(ci->tagrem),rem); +# define set_charinfo_tag(ci,val) ci->tag |= val; +# define set_charinfo_next(ci,val) if (ci->math) { ci->math->next = val; } -# define has_charinfo_tag(ci,p) (charinfo_tag(ci->tagrem) & (p) == (p)) -# define get_charinfo_tag(ci) charinfo_tag(ci->tagrem) +# define has_charinfo_tag(ci,p) (ci->tag) & (p) == (p)) +# define get_charinfo_tag(ci) ci->tag # define set_charinfo_ligatures(ci,val) { lmt_memory_free(ci->ligatures); ci->ligatures = val; } # define set_charinfo_kerns(ci,val) { lmt_memory_free(ci->kerns); ci->kerns = val; } @@ -458,11 +520,14 @@ extern int tex_get_math_char (halfword f, int c, int size, scaled *scal # define set_charinfo_smaller(ci,val) if (ci->math) { ci->math->smaller = val; } # define set_charinfo_mirror(ci,val) if (ci->math) { ci->math->mirror = val; } -# define set_charinfo_vertical_italic(ci,val) if (ci->math) { ci->math->vertical_italic = val; } +# define set_charinfo_extensible_italic(ci,val) if (ci->math) { ci->math->extensible_italic = val; } # define set_charinfo_top_anchor(ci,val) if (ci->math) { ci->math->top_anchor = val; } # define set_charinfo_bottom_anchor(ci,val) if (ci->math) { ci->math->bottom_anchor = val; } # define set_charinfo_flat_accent(ci,val) if (ci->math) { ci->math->flat_accent = val; } +# define set_charinfo_inner_x_offset(ci,val) if (ci->math) { ci->math->inner_x_offset = val; } +# define set_charinfo_inner_y_offset(ci,val) if (ci->math) { ci->math->inner_y_offset = val; } + # define set_charinfo_top_left_kern(ci,val) if (ci->math) { ci->math->top_left_kern = val; } # define set_charinfo_top_right_kern(ci,val) if (ci->math) { ci->math->top_right_kern = val; } # define set_charinfo_bottom_left_kern(ci,val) if (ci->math) { ci->math->bottom_left_kern = val; } @@ -476,15 +541,12 @@ extern int tex_get_math_char (halfword f, int c, int size, scaled *scal void tex_set_lpcode_in_font (halfword f, halfword c, halfword i); void tex_set_rpcode_in_font (halfword f, halfword c, halfword i); void tex_set_efcode_in_font (halfword f, halfword c, halfword i); +void tex_set_cfcode_in_font (halfword f, halfword c, halfword i); -extern void tex_set_charinfo_extensible (charinfo *ci, int top, int bottom, int middle, int extender); extern void tex_add_charinfo_math_kern (charinfo *ci, int type, scaled ht, scaled krn); extern int tex_get_charinfo_math_kerns (charinfo *ci, int id); -extern void tex_set_charinfo_horizontal_parts (charinfo *ci, extinfo *ext); -extern void tex_set_charinfo_vertical_parts (charinfo *ci, extinfo *ext); -extern void tex_add_charinfo_vertical_part (charinfo *ci, extinfo *ext); -extern void tex_add_charinfo_horizontal_part (charinfo *ci, extinfo *ext); -extern extinfo *tex_new_charinfo_part (int glyph, int startconnect, int endconnect, int advance, int repeater); +extern void tex_set_charinfo_extensible_recipe (charinfo *ci, extinfo *ext); +extern void tex_append_charinfo_extensible_recipe (charinfo *ci, int glyph, int startconnect, int endconnect, int advance, int repeater); /*tex Checkers: */ @@ -496,63 +558,54 @@ int tex_has_kern (halfword f, halfword c) # define MATH_KERN_NOT_FOUND 0x7FFFFFFF +extern scaled tex_font_x_scaled (scaled v); +extern scaled tex_font_y_scaled (scaled v); + extern scaled tex_char_width_from_font (halfword f, halfword c); /* math + maincontrol */ extern scaled tex_char_height_from_font (halfword f, halfword c); /* math + maincontrol */ extern scaled tex_char_depth_from_font (halfword f, halfword c); /* math + maincontrol */ extern scaled tex_char_total_from_font (halfword f, halfword c); /* math */ +extern scaledwhd tex_char_whd_from_font (halfword f, halfword c); /* math + maincontrol */ extern scaled tex_char_italic_from_font (halfword f, halfword c); /* math + maincontrol */ -// halfword tex_char_options_from_font (halfword f, halfword c); extern scaled tex_char_ef_from_font (halfword f, halfword c); /* packaging + maincontrol */ +extern scaled tex_char_cf_from_font (halfword f, halfword c); /* packaging + maincontrol */ extern scaled tex_char_lp_from_font (halfword f, halfword c); /* packaging + maincontrol */ extern scaled tex_char_rp_from_font (halfword f, halfword c); /* packaging + maincontrol */ extern halfword tex_char_tag_from_font (halfword f, halfword c); /* math */ -extern halfword tex_char_remainder_from_font (halfword f, halfword c); /* math */ +extern halfword tex_char_next_from_font (halfword f, halfword c); /* math */ extern halfword tex_char_has_tag_from_font (halfword f, halfword c, halfword tag); extern void tex_char_reset_tag_from_font (halfword f, halfword c, halfword tag); -// int tex_char_has_option_from_font (halfword g, halfword c, int option); - +extern int tex_char_checked_tag (halfword tag); +extern scaled tex_char_inner_x_offset_from_font (halfword f, halfword c); +extern scaled tex_char_inner_y_offset_from_font (halfword f, halfword c); extern scaled tex_char_top_left_kern_from_font (halfword f, halfword c); /* math */ extern scaled tex_char_top_right_kern_from_font (halfword f, halfword c); /* math */ extern scaled tex_char_bottom_left_kern_from_font (halfword f, halfword c); /* math */ extern scaled tex_char_bottom_right_kern_from_font (halfword f, halfword c); /* math */ - -extern scaledwhd tex_char_whd_from_font (halfword f, halfword c); /* math + maincontrol */ - -extern scaled tex_font_x_scaled (scaled v); -extern scaled tex_font_y_scaled (scaled v); - -extern scaled tex_char_width_from_glyph (halfword g); /* x/y scaled */ -extern scaled tex_char_height_from_glyph (halfword g); /* x/y scaled */ -extern scaled tex_char_depth_from_glyph (halfword g); /* x/y scaled */ -extern scaled tex_char_total_from_glyph (halfword g); /* x/y scaled */ -extern scaled tex_char_italic_from_glyph (halfword g); /* x/y scaled */ -// int tex_char_options_from_glyph (halfword g); -extern scaled tex_char_width_italic_from_glyph (halfword g); /* x/y scaled */ -// int tex_char_has_option_from_glyph (halfword g, int option); - -extern scaledwhd tex_char_whd_from_glyph (halfword g); /* x/y scaled */ - -extern halfword tex_char_unchecked_top_anchor_from_font (halfword f, halfword c); -extern halfword tex_char_unchecked_bottom_anchor_from_font (halfword f, halfword c); - -extern halfword tex_char_vertical_italic_from_font (halfword f, halfword c); +extern halfword tex_char_extensible_italic_from_font (halfword f, halfword c); extern halfword tex_char_flat_accent_from_font (halfword f, halfword c); extern halfword tex_char_top_anchor_from_font (halfword f, halfword c); extern halfword tex_char_bottom_anchor_from_font (halfword f, halfword c); - extern scaled tex_char_left_margin_from_font (halfword f, halfword c); extern scaled tex_char_right_margin_from_font (halfword f, halfword c); extern scaled tex_char_top_margin_from_font (halfword f, halfword c); extern scaled tex_char_bottom_margin_from_font (halfword f, halfword c); - extern scaled tex_char_top_overshoot_from_font (halfword f, halfword c); extern scaled tex_char_bottom_overshoot_from_font (halfword f, halfword c); +extern scaled tex_char_inner_x_offset_from_font (halfword f, halfword c); +extern scaled tex_char_inner_y_offset_from_font (halfword f, halfword c); +extern extinfo *tex_char_extensible_recipe_from_font (halfword f, halfword c); -extern extinfo *tex_char_vertical_parts_from_font (halfword f, halfword c); -extern extinfo *tex_char_horizontal_parts_from_font (halfword f, halfword c); - -/* scaled tex_math_kern_at (halfword f, int c, int side, int v); */ -/* scaled tex_find_math_kern (halfword l_f, int l_c, halfword r_f, int r_c, int cmd, scaled shift); */ +extern halfword tex_char_unchecked_top_anchor_from_font (halfword f, halfword c); +extern halfword tex_char_unchecked_bottom_anchor_from_font (halfword f, halfword c); + +extern scaled tex_char_width_from_glyph (halfword g); /* x/y scaled */ +extern scaled tex_char_height_from_glyph (halfword g); /* x/y scaled */ +extern scaled tex_char_depth_from_glyph (halfword g); /* x/y scaled */ +extern scaled tex_char_total_from_glyph (halfword g); /* x/y scaled */ +extern scaled tex_char_italic_from_glyph (halfword g); /* x/y scaled */ +extern scaled tex_char_width_italic_from_glyph (halfword g); /* x/y scaled */ +extern scaledwhd tex_char_whd_from_glyph (halfword g); /* x/y scaled */ extern int tex_valid_kern (halfword left, halfword right); /* returns kern */ extern int tex_valid_ligature (halfword left, halfword right, int *slot); /* returns type */ @@ -560,7 +613,7 @@ extern int tex_valid_ligature (halfword left, halfword extern scaled tex_calculated_char_width (halfword f, halfword c, halfword ex); extern scaled tex_calculated_glyph_width (halfword g, halfword ex); /* scale */ -/* +/*tex Kerns: the |otherchar| value signals \quote {stop}. These are not really public and only to be used in the helpers. But we keep them as reference. */ @@ -574,7 +627,7 @@ extern scaled tex_calculated_glyph_width (halfword g, halfword ex # define kern_end(b) ((b).adjacent == end_kern) # define kern_disabled(b) ((b).adjacent > end_kern) -/* +/*tex Ligatures: the |otherchar| value signals \quote {stop}. These are not really public and only to be used in the helpers. But we keep them as reference. */ @@ -590,14 +643,14 @@ extern scaled tex_calculated_glyph_width (halfword g, halfword ex # define ligature_end(a) ((a).adjacent == end_of_ligature_code) # define ligature_disabled(a) ((a).adjacent > end_of_ligature_code) -/* Remainders and related flags: */ +/*tex Extension specific: */ typedef enum math_extension_modes { math_extension_normal, math_extension_repeat, } math_extension_modes; -/* Expansion */ +/*tex Expansion and protrusion: */ typedef enum adjust_spacing_modes { adjust_spacing_off, @@ -622,17 +675,6 @@ typedef enum math_extension_locations { } math_extension_locations; */ -/* Tags: */ - -typedef enum tag_codes { - no_tag = 0x00, /*tex vanilla character */ - ligature_tag = 0x01, /*tex character has a ligature/kerning program */ - list_tag = 0x02, /*tex character has a successor in a charlist */ - extension_tag = 0x04, /*tex character is extensible */ - callback_tag = 0x08, - extend_last_tag = 0x10, -} tag_codes; - extern halfword tex_checked_font (halfword f); extern int tex_is_valid_font (halfword f); extern int tex_raw_get_kern (halfword f, int lc, int rc); @@ -641,7 +683,7 @@ extern ligatureinfo tex_get_ligature (halfword f, int lc, int rc); extern int tex_new_font (void); extern int tex_new_font_id (void); extern void tex_font_malloc_charinfo (halfword f, int num); -extern void tex_char_malloc_mathinfo (charinfo * ci); +extern void tex_char_malloc_mathinfo (charinfo *ci); extern void tex_dump_font_data (dumpstream f); extern void tex_undump_font_data (dumpstream f); extern void tex_create_null_font (void); diff --git a/source/luametatex/source/tex/texinputstack.c b/source/luametatex/source/tex/texinputstack.c index 9823fe137..e73451226 100644 --- a/source/luametatex/source/tex/texinputstack.c +++ b/source/luametatex/source/tex/texinputstack.c @@ -392,14 +392,16 @@ static void tex_aux_print_current_input_state(void) } else { switch (lmt_input_state.cur_input.name) { case io_initial_input_code: - tex_print_str("initial"); + tex_print_str("initial input"); break; case io_lua_input_code: - tex_print_str("lua output"); + tex_print_str("lua input"); break; case io_token_input_code: + tex_print_str("token input"); + break; case io_token_eof_input_code: - tex_print_str("scantokens"); + tex_print_str("token eof input"); break; case io_tex_macro_code: case io_file_input_code: @@ -841,11 +843,12 @@ void tex_cleanup_input_state(void) break; case macro_text: { + int ptr, start; /*tex Using a simple version for no arguments has no gain. */ tex_delete_token_reference(lmt_input_state.cur_input.start); /*tex Parameters must be flushed: */ - int ptr = lmt_input_state.parameter_stack_data.ptr; - int start = lmt_input_state.cur_input.parameter_start; + ptr = lmt_input_state.parameter_stack_data.ptr; + start = lmt_input_state.cur_input.parameter_start; while (ptr > start) { --ptr; if (lmt_input_state.parameter_stack[ptr]) { @@ -1063,9 +1066,15 @@ void tex_initialize_inputstack(void) lmt_input_state.align_state = 1000000; } +/*tex + Currently |iotype| can be |io_token_input_code| or |io_token_eof_input_code| but the idea + was to get rid of the eof variant. However, it seems that there are still use cases (not + in \CONTEXT). +*/ + void tex_tex_string_start(int iotype, int cattable) { - (void) iotype; + /* (void) iotype; */ { halfword head = tex_scan_general_text(NULL); int saved_selector = lmt_print_state.selector; @@ -1082,7 +1091,7 @@ void tex_tex_string_start(int iotype, int cattable) lmt_input_state.input_line = 0; lmt_input_state.cur_input.limit = lmt_input_state.cur_input.start; lmt_input_state.cur_input.loc = lmt_input_state.cur_input.limit + 1; - lmt_input_state.cur_input.name = io_token_input_code; + lmt_input_state.cur_input.name = iotype; /* io_token_input_code; */ lmt_cstring_start(); } } diff --git a/source/luametatex/source/tex/texinserts.c b/source/luametatex/source/tex/texinserts.c index 27b979e0f..dbd164926 100644 --- a/source/luametatex/source/tex/texinserts.c +++ b/source/luametatex/source/tex/texinserts.c @@ -424,10 +424,11 @@ void tex_dump_insert_data(dumpstream f) { } void tex_undump_insert_data(dumpstream f) { + insert_record *tmp; undump_int(f, lmt_insert_state.mode); undump_int(f, lmt_insert_state.insert_data.ptr); undump_int(f, lmt_insert_state.insert_data.top); - insert_record *tmp = aux_allocate_clear_array(sizeof(insert_record), lmt_insert_state.insert_data.top, 1); + tmp = aux_allocate_clear_array(sizeof(insert_record), lmt_insert_state.insert_data.top, 1); if (tmp) { lmt_insert_state.inserts = tmp; lmt_insert_state.insert_data.allocated = lmt_insert_state.insert_data.top * sizeof(insert_record); diff --git a/source/luametatex/source/tex/texlanguage.c b/source/luametatex/source/tex/texlanguage.c index 22627ee58..0fcd3b243 100644 --- a/source/luametatex/source/tex/texlanguage.c +++ b/source/luametatex/source/tex/texlanguage.c @@ -525,6 +525,7 @@ void tex_load_hyphenation(struct tex_language *lang, const unsigned char *buff) } } } + lua_pop(L, 1); } } @@ -627,44 +628,6 @@ static char *tex_aux_hyphenation_exception(int exceptions, char *w) return ret; } -/*tex Kept as reference: */ - -/* -char *get_exception_strings(struct tex_language *lang) -{ - char *ret = NULL; - if (lang && lang->exceptions) { - lua_State *L = lua_state.lua_instance; - if (lua_rawgeti(L, LUA_REGISTRYINDEX, lang->exceptions) == LUA_TTABLE) { - size_t size = 0; - size_t current = 0; - lua_pushnil(L); - while (lua_next(L, -2)) { - size_t l = 0; - const char *value = lua_tolstring(L, -1, &l); - if (current + l + 2 > size) { - size_t new = (size + size/5) + current + l + 1024; - char *tmp = lmt_memory_realloc(ret, new); - if (tmp) { - ret = tmp; - size = new; - } else { - overflow_error("exceptions", (int) size); - } - } - if (ret) { - ret[current] = ' '; - strcpy(&ret[current + 1], value); - current += l + 1; - } - lua_pop(L, 1); - } - } - } - return ret; -} -*/ - /*tex The sequence from |wordstart| to |r| can contain only normal characters it could be faster to @@ -997,8 +960,6 @@ static void tex_aux_do_exception(halfword wordstart, halfword r, char *replaceme */ -// # define is_hyphen_char(chr) (get_hc_code(chr) || chr == ex_hyphen_char_par) - inline static halfword tex_aux_is_hyphen_char(halfword chr) { if (tex_get_hc_code(chr)) { @@ -1013,7 +974,6 @@ inline static halfword tex_aux_is_hyphen_char(halfword chr) static halfword tex_aux_find_next_wordstart(halfword r, halfword first_language) { int start_ok = 1; - int mathlevel = 1; halfword lastglyph = r; while (r) { switch (node_type(r)) { @@ -1038,15 +998,18 @@ static halfword tex_aux_find_next_wordstart(halfword r, halfword first_language) start_ok = 1; break; case math_node: - while (mathlevel > 0) { - r = node_next(r); - if (! r) { - return r; - } else if (node_type(r) == math_node) { - if (node_subtype(r) == begin_inline_math) { - mathlevel++; - } else { - mathlevel--; + if (node_subtype(r) == begin_inline_math) { + int mathlevel = 1; + while (mathlevel > 0) { + r = node_next(r); + if (! r) { + return r; + } else if (node_type(r) == math_node) { + if (node_subtype(r) == begin_inline_math) { + mathlevel++; + } else { + mathlevel--; + } } } } diff --git a/source/luametatex/source/tex/texmaincontrol.c b/source/luametatex/source/tex/texmaincontrol.c index 5e0bb2f92..f3d91ffe0 100644 --- a/source/luametatex/source/tex/texmaincontrol.c +++ b/source/luametatex/source/tex/texmaincontrol.c @@ -1594,8 +1594,7 @@ int tex_main_control(void) return cur_chr == dump_code; } } - /*tex not reached */ - return 0; + return 0; /* unreachable */ } /*tex @@ -2242,9 +2241,9 @@ static void tex_aux_run_discretionary(void) case explicit_discretionary_code: /*tex |\-| */ if (hyphenation_permitted(hyphenation_mode_par, explicit_hyphenation_mode)) { + int c = tex_get_pre_hyphen_char(cur_lang_par); halfword d = tex_new_disc_node(explicit_discretionary_code); tex_tail_append(d); - int c = tex_get_pre_hyphen_char(cur_lang_par); if (c > 0) { tex_set_disc_field(d, pre_break_code, tex_new_char_node(glyph_unset_subtype, cur_font_par, c, 1)); } @@ -2259,10 +2258,10 @@ static void tex_aux_run_discretionary(void) case mathematics_discretionary_code: /*tex |-| */ if (hyphenation_permitted(hyphenation_mode_par, automatic_hyphenation_mode)) { + halfword c = tex_get_pre_exhyphen_char(cur_lang_par); halfword d = tex_new_disc_node(automatic_discretionary_code); tex_tail_append(d); /*tex As done in hyphenator: */ - halfword c = tex_get_pre_exhyphen_char(cur_lang_par); if (c <= 0) { c = ex_hyphen_char_par; } @@ -4353,6 +4352,14 @@ static void tex_aux_set_font_property(void) tex_set_efcode_in_font(fnt, chr, val); break; } + case font_cf_code: + { + halfword fnt = tex_scan_font_identifier(NULL); + halfword chr = tex_scan_char_number(0); + halfword val = tex_scan_int(1, NULL); + tex_set_cfcode_in_font(fnt, chr, val); + break; + } case font_dimen_code: { tex_set_font_dimen(); @@ -5958,7 +5965,7 @@ static void tex_aux_run_show_whatever(void) int online = 0; int max = 0; while (1) { - switch (tex_scan_character("ocdnaOCDNA", 0, 0, 0)) { + switch (tex_scan_character("ocdnaOCDNA", 0, 1, 0)) { case 'a': case 'A': if (tex_scan_mandate_keyword("all", 1)) { max = 1; diff --git a/source/luametatex/source/tex/texmarks.c b/source/luametatex/source/tex/texmarks.c index 060c5f579..01e002fbd 100644 --- a/source/luametatex/source/tex/texmarks.c +++ b/source/luametatex/source/tex/texmarks.c @@ -67,12 +67,12 @@ void tex_reset_mark(halfword m) size = m; } if (size <= lmt_mark_state.mark_data.maximum) { - mark_record *tmp = aux_reallocate_array(lmt_mark_state.data, sizeof(mark_record), (size_t) size, 1); + mark_record *tmp = aux_reallocate_array(lmt_mark_state.data, sizeof(mark_record), size, 1); if (tmp) { lmt_mark_state.data = tmp; memset(&lmt_mark_state.data[lmt_mark_state.mark_data.top], 0, sizeof(mark_record) * (size - lmt_mark_state.mark_data.top)); lmt_mark_state.mark_data.top = size; - lmt_mark_state.mark_data.allocated = sizeof(mark_record) * ((size_t) size); + lmt_mark_state.mark_data.allocated = sizeof(mark_record) * size; } else { tex_overflow_error("marks", size); } diff --git a/source/luametatex/source/tex/texmath.c b/source/luametatex/source/tex/texmath.c index 3f452b1ff..f650704cd 100644 --- a/source/luametatex/source/tex/texmath.c +++ b/source/luametatex/source/tex/texmath.c @@ -243,7 +243,6 @@ halfword tex_size_of_style(halfword style) case script_script_style: case cramped_script_script_style: return script_script_size; - break; default: return text_size; } @@ -372,7 +371,9 @@ static void tex_aux_print_fam(const char *what, halfword size, halfword fam) int tex_fam_fnt(int fam, int size) { - return (int) sa_get_item_4(lmt_math_state.fam_head, fam + (256 * size)).int_value; + sa_tree_item item; + sa_get_item_4(lmt_math_state.fam_head, fam + (256 * size), &item); + return (int) item.int_value; } void tex_def_fam_fnt(int fam, int size, int fnt, int level) @@ -413,7 +414,7 @@ void tex_def_math_parameter(int style, int param, scaled value, int level, int i int different = 1; if (level <= 1) { if (math_parameter_value_type(param) == math_muglue_parameter) { - item1 = sa_get_item_8(lmt_math_state.par_head, (param + (math_parameter_max_range * style)), &item2); + sa_get_item_8(lmt_math_state.par_head, (param + (math_parameter_max_range * style)), &item1, &item2); if (item2.int_value == indirect_math_regular && item1.int_value > thick_mu_skip_code) { if (lmt_node_memory_state.nodesizes[item1.int_value]) { tex_free_node(item1.int_value, glue_spec_size); @@ -422,7 +423,7 @@ void tex_def_math_parameter(int style, int param, scaled value, int level, int i } } else { /*tex Less tracing at the cost of a lookup. */ - item1 = sa_get_item_8(lmt_math_state.par_head, (param + (math_parameter_max_range * style)), &item2); + sa_get_item_8(lmt_math_state.par_head, (param + (math_parameter_max_range * style)), &item1, &item2); different = item1.int_value != value || item2.int_value != indirect; } // if (different) { // maybe @@ -440,8 +441,8 @@ void tex_def_math_parameter(int style, int param, scaled value, int level, int i scaled tex_get_math_parameter(int style, int param, halfword *type) { halfword indirect, value; - sa_tree_item v2; - sa_tree_item v1 = sa_get_item_8(lmt_math_state.par_head, (param + (math_parameter_max_range * style)), &v2); + sa_tree_item v1, v2; + sa_get_item_8(lmt_math_state.par_head, (param + (math_parameter_max_range * style)), &v1, &v2); indirect = v2.int_value == lmt_math_state.par_head->dflt.int_value ? indirect_math_unset : v2.uint_value; value = v1.int_value; switch (indirect) { @@ -662,8 +663,8 @@ scaled tex_get_math_parameter(int style, int param, halfword *type) int tex_has_math_parameter(int style, int param) { - sa_tree_item v2; - sa_get_item_8(lmt_math_state.par_head, (param + (math_parameter_max_range * style)), &v2); + sa_tree_item v1, v2; + sa_get_item_8(lmt_math_state.par_head, (param + (math_parameter_max_range * style)), &v1, &v2); return v2.int_value == lmt_math_state.par_head->dflt.int_value ? indirect_math_unset : v2.uint_value; } @@ -675,9 +676,9 @@ static void tex_aux_unsave_math_parameter_data(int gl) if (item.level > 0) { int param = item.code % math_parameter_max_range; int style = item.code / math_parameter_max_range; - sa_tree_item item1, item2; if (math_parameter_value_type(param) == math_muglue_parameter) { - item1 = sa_get_item_8(lmt_math_state.par_head, item.code, &item2); + sa_tree_item item1, item2; + sa_get_item_8(lmt_math_state.par_head, item.code, &item1, &item2); if (item2.int_value == indirect_math_regular && item1.int_value > thick_mu_skip_code) { /* if (tex_valid_node(item1.int_value)) { */ if (lmt_node_memory_state.nodesizes[item1.int_value]) { @@ -788,13 +789,17 @@ halfword tex_new_sub_box(halfword curbox) return noad; } -quarterword tex_aux_set_math_char(halfword target, mathcodeval *mval, mathdictval *dval) +static quarterword tex_aux_set_math_char(halfword target, mathcodeval *mval, mathdictval *dval) { halfword hmcode = tex_get_hm_code(mval->character_value); kernel_math_character(target) = mval->character_value; if (mval->class_value == math_use_current_family_code) { kernel_math_family(target) = cur_fam_par_in_range ? cur_fam_par : mval->family_value; node_subtype(target) = ordinary_noad_subtype; + } else if (mval->family_value == variable_family_par) { + /*tex For CMS chairman MS, so that he can answer a ltx question someplace. */ + kernel_math_family(target) = cur_fam_par_in_range ? cur_fam_par : mval->family_value; + node_subtype(target) = mval->class_value; } else { kernel_math_family(target) = mval->family_value; node_subtype(target) = mval->class_value; @@ -1121,13 +1126,19 @@ static void tex_aux_display_fence_noad(halfword n, int threshold, int max) if (noad_depth(n)) { tex_print_format(", depth %D", noad_depth(n), pt_unit); } - if (get_noad_main_class(n) >= 0) { + if (fence_top_overshoot(n)) { + tex_print_format(", top %D", fence_top_overshoot(n), pt_unit); + } + if (fence_bottom_overshoot(n)) { + tex_print_format(", top %D", fence_bottom_overshoot(n), pt_unit); + } + if (get_noad_main_class(n) != unset_noad_class) { tex_print_format(", class %i", get_noad_main_class(n)); } - if (get_noad_left_class(n) >= 0) { + if (get_noad_left_class(n) != unset_noad_class) { tex_print_format(", leftclass %i", get_noad_left_class(n)); } - if (get_noad_right_class(n) >= 0) { + if (get_noad_right_class(n) != unset_noad_class) { tex_print_format(", rightclass %i", get_noad_right_class(n)); } if (noad_source(n) != 0) { @@ -1976,11 +1987,34 @@ int tex_scan_math_cmd_val(mathcodeval *mval, mathdictval *dval) return 0; } break; - case letter_cmd: - case other_char_cmd: - mval->character_value = cur_chr; + case delimiter_number_cmd: + switch (cur_chr) { + case math_delimiter_code: + *mval = tex_scan_delimiter_as_mathchar(tex_mathcode); + break; + case math_udelimiter_code: + *mval = tex_scan_delimiter_as_mathchar(umath_mathcode); + break; + default: + /* no message yet */ + return 0; + } break; + /*tex + This is/was an experiment but could work out ambigiuous in some cases so when I bring it + back it will be under more strict control. So, for instance a register would make us + enter the default branch but a direct number the other case. In the meantiem we no longer + use the direct char approach (for delimiters mostly) so we can comment it. + */ + // case letter_cmd: + // case other_char_cmd: + // mval->character_value = cur_chr; + // break; default: + /*tex + We could do a fast |tex_scan_something_internal| here but this branch is not that + critical. + */ { halfword n = 0; tex_back_input(cur_tok); @@ -2718,7 +2752,7 @@ void tex_run_math_accent(void) case math_uaccent_code: /*tex |\Umathaccent| */ while (1) { - switch (tex_scan_character("ansfASFN", 0, 0, 0)) { + switch (tex_scan_character("ansfASFN", 0, 1, 0)) { case 'a': case 'A': if (tex_scan_mandate_keyword("attr", 1)) { attrlist = tex_scan_attribute(attrlist); @@ -3707,8 +3741,10 @@ void tex_finish_math_group(void) void tex_run_math_fence(void) { - halfword ht = 0; - halfword dp = 0; + scaled ht = 0; + scaled dp = 0; + scaled top = 0; + scaled bottom = 0; halfword options = 0; halfword mainclass = unset_noad_class; halfword leftclass = unset_noad_class; @@ -3738,19 +3774,9 @@ void tex_run_math_fence(void) } while (1) { /* todo: break down */ - switch (tex_scan_character("hdanlevpcrsuHDANLEVPCRSU", 0, 1, 0)) { + switch (tex_scan_character("hdanlevpcrsutbHDANLEVPCRSUTB", 0, 1, 0)) { case 0: goto CHECK_PAIRING; - case 'h': case 'H': - if (tex_scan_mandate_keyword("height", 1)) { - ht = tex_scan_dimen(0, 0, 0, 0, NULL); - } - break; - case 'd': case 'D': - if (tex_scan_mandate_keyword("depth", 1)) { - dp = tex_scan_dimen(0, 0, 0, 0, NULL); - } - break; case 'a': case 'A': switch (tex_scan_character("uxtUXT", 0, 0, 0)) { case 'u': case 'U': @@ -3773,6 +3799,21 @@ void tex_run_math_fence(void) goto CHECK_PAIRING; } break; + case 'b': case 'B': + if (tex_scan_mandate_keyword("bottom", 1)) { + bottom = tex_scan_dimen(0, 0, 0, 0, NULL); + } + break; + case 'd': case 'D': + if (tex_scan_mandate_keyword("depth", 1)) { + dp = tex_scan_dimen(0, 0, 0, 0, NULL); + } + break; + case 'h': case 'H': + if (tex_scan_mandate_keyword("height", 1)) { + ht = tex_scan_dimen(0, 0, 0, 0, NULL); + } + break; case 'n': case 'N': switch (tex_scan_character("oO", 0, 0, 0)) { case 'o': case 'O': @@ -3863,6 +3904,11 @@ void tex_run_math_fence(void) source = tex_scan_int(0, NULL); } break; + case 't': case 'T': + if (tex_scan_mandate_keyword("top", 1)) { + top = tex_scan_dimen(0, 0, 0, 0, NULL); + } + break; default: goto CHECK_PAIRING; } @@ -3930,6 +3976,9 @@ void tex_run_math_fence(void) } noad_italic(fence) = 0; noad_source(fence) = source; + /* */ + fence_top_overshoot(fence) = top; + fence_bottom_overshoot(fence) = bottom; /*tex By setting this here, we can get rid of the hard coded values in |mlist_to_hlist| which sort of interfere (or at least confuse) things there. When set, the |leftclass| and @@ -4643,6 +4692,27 @@ static void tex_aux_define_dis_math_parameters(int size, int param, scaled value } } +/*tex + In principle we could save some storage in the format file with: + + \starttyping + static void tex_aux_define_all_math_parameters(int size, int param, scaled value, int level) + { + tex_def_math_parameter(all_math_styles, param, value, level, indirect_math_regular); + } + \stoptyping + + and then do this (we also need to move |all_math_styles| up in the enum to keep ranges compact): + + \starttyping + if (! sa_get_item_8(lmt_math_state.par_head, (param + (math_parameter_max_range * style)), &item1, &item2)) { + sa_get_item_8(lmt_math_state.par_head, (param + (math_parameter_max_range * all_math_styles)), &item1, &item2); + } + \stoptyping + + but in practice we actually get a bit larger file. +*/ + static void tex_aux_define_all_math_parameters(int size, int param, scaled value, int level) { switch (size) { @@ -4756,7 +4826,7 @@ inline static scaled tex_aux_get_font_math_quantity(scaled scale, halfword v) /*tex The next function is called when we define a family, but first we define a few helpers - for identifying traditional math fonts. Watch the hard codes family check! + for identifying traditional math fonts. Watch the hard codes family check (gone now)! */ void tex_fixup_math_parameters(int fam, int size, int f, int level) diff --git a/source/luametatex/source/tex/texmath.h b/source/luametatex/source/tex/texmath.h index cc7aa7e7f..b97b1e8f2 100644 --- a/source/luametatex/source/tex/texmath.h +++ b/source/luametatex/source/tex/texmath.h @@ -663,20 +663,22 @@ typedef enum math_control_codes { math_control_accent_skew_apply = 0x000040, math_control_apply_ordinary_kern_pair = 0x000080, math_control_apply_vertical_italic_kern = 0x000100, - math_control_apply_ordinary_italic_kern = 0x000200, - math_control_apply_char_italic_kern = 0x000400, /* traditional */ - math_control_rebox_char_italic_kern = 0x000800, /* traditional */ - math_control_apply_boxed_italic_kern = 0x001000, - math_control_staircase_kern = 0x002000, - math_control_apply_text_italic_kern = 0x004000, - math_control_check_text_italic_kern = 0x008000, - math_control_check_space_italic_kern = 0x010000, - math_control_apply_script_italic_kern = 0x020000, - math_control_analyze_script_nucleus_char = 0x040000, - math_control_analyze_script_nucleus_list = 0x080000, - math_control_analyze_script_nucleus_box = 0x100000, - math_control_accent_top_skew_with_offset = 0x200000, - math_control_ignore_kern_dimensions = 0x400000, /* for bad fonts (like xits fence depths) */ + math_control_apply_ordinary_italic_kern = 0x0000200, + math_control_apply_char_italic_kern = 0x0000400, /* traditional */ + math_control_rebox_char_italic_kern = 0x0000800, /* traditional */ + math_control_apply_boxed_italic_kern = 0x0001000, + math_control_staircase_kern = 0x0002000, + math_control_apply_text_italic_kern = 0x0004000, + math_control_check_text_italic_kern = 0x0008000, + math_control_check_space_italic_kern = 0x0010000, + math_control_apply_script_italic_kern = 0x0020000, + math_control_analyze_script_nucleus_char = 0x0040000, + math_control_analyze_script_nucleus_list = 0x0080000, + math_control_analyze_script_nucleus_box = 0x0100000, + math_control_accent_top_skew_with_offset = 0x0200000, + math_control_ignore_kern_dimensions = 0x0400000, /* for bad fonts (like xits fence depths) */ + math_control_ignore_flat_accents = 0x0800000, + math_control_extend_accents = 0x1000000, } math_control_codes; /*tex This is what we use for \OPENTYPE\ in \CONTEXT: */ diff --git a/source/luametatex/source/tex/texmathcodes.c b/source/luametatex/source/tex/texmathcodes.c index 545013264..f19cde91c 100644 --- a/source/luametatex/source/tex/texmathcodes.c +++ b/source/luametatex/source/tex/texmathcodes.c @@ -164,8 +164,9 @@ void tex_set_math_code(int n, mathcodeval v, int level) mathcodeval tex_get_math_code(int n) { - sa_tree_item item = sa_get_item_4(lmt_mathcode_state.mathcode_head, n); + sa_tree_item item; mathcodeval m = { 0, 0, 0 }; + sa_get_item_4(lmt_mathcode_state.mathcode_head, n, &item); if (item.uint_value == MATHCODEDEFAULT) { m.character_value = n; } else if (item.uint_value == MATHCODEACTIVE) { @@ -267,9 +268,9 @@ delcodeval tex_no_del_code(void) delcodeval tex_get_del_code(int n) { - sa_tree_item v2; - sa_tree_item v1 = sa_get_item_8(lmt_mathcode_state.delcode_head, n, &v2); + sa_tree_item v1, v2; delcodeval d = { { 0, -1, 0 }, { 0, 0, 0} }; + sa_get_item_8(lmt_mathcode_state.delcode_head, n, &v1, &v2); if (v1.uint_value != DELCODEDEFAULT) { d.small.class_value = (short) v1.math_code_value.class_value; d.small.family_value = (short) v1.math_code_value.family_value; diff --git a/source/luametatex/source/tex/texmlist.c b/source/luametatex/source/tex/texmlist.c index ddc3f0a6e..0ea1f82e8 100644 --- a/source/luametatex/source/tex/texmlist.c +++ b/source/luametatex/source/tex/texmlist.c @@ -178,7 +178,8 @@ static void tex_aux_prepend_hkern_to_box_list(halfword q, scaled delta, halfword \startitem |FlattenedAccentBaseHeight|: This is based on the |flac| |GSUB| feature. It would not be hard to support that, but proper math accent placements cf.\ |MATH| needs support - for |MathTopAccentAttachment| table to be implemented first. + for |MathTopAccentAttachment| table to be implemented first. We actually do support + it in \LUAMETATEX. \stopitem \stopitemize @@ -188,10 +189,10 @@ static void tex_aux_prepend_hkern_to_box_list(halfword q, scaled delta, halfword Occasionally I visit this file and make some variables more verbose. - In the meantime some experimental and in the meantime obsolete code has been removed but it can - be found in the development repository if really needed. It makes no sense to keep code around - that has been replaced or improved otherwise. Some code we keep commented for a while before it - is flushed out. + In the meantime some experimental and obsolete code has been removed but it can be found in + the development repository if really needed. It makes no sense to keep code around that has + been replaced or improved otherwise. Some code we keep commented for a while before it is + flushed out. */ @@ -297,7 +298,7 @@ inline static void tex_aux_make_style(halfword current, halfword *current_style, } tex_aux_set_current_math_size(style); if (current_mu) { - *current_mu = scaledround(tex_get_math_quad_style(style) / 18.0); + *current_mu = scaledround((double) tex_get_math_quad_style(style) / 18.0); } } break; @@ -311,7 +312,7 @@ void tex_set_math_text_font(halfword style, int usetextfont) halfword scale = tex_get_math_font_scale(font, size); switch (usetextfont) { case math_atom_text_font_option: - scale = scaledround((double) scale * lmt_font_state.fonts[font]->size / lmt_font_state.fonts[cur_font_par]->size); + scale = scaledround((double) scale * (double) lmt_font_state.fonts[font]->size / (double) lmt_font_state.fonts[cur_font_par]->size); break; case math_atom_math_font_option: update_tex_font(0, font); @@ -858,11 +859,13 @@ static halfword tex_aux_char_box(halfword fnt, int chr, halfword att, scaled *ic } else if (ic) { *ic = 0; } - if (target && whd.wd < target && tex_char_has_tag_from_font(fnt, chr, extend_last_tag)) { + if (target && whd.wd > 0 && whd.wd < target && tex_aux_math_engine_control(fnt, math_control_extend_accents) && tex_char_has_tag_from_font(fnt, chr, extend_last_tag)) { scaled margin = tex_get_math_x_parameter_default(style, math_parameter_accent_extend_margin, 0); scaled amount = target - 2 * margin; - glyph_x_scale(glyph) = lround((double) glyph_x_scale(glyph) * amount/whd.wd); - glyph_x_offset(glyph) = (whd.wd - amount)/2; + if (amount > 0) { + glyph_x_scale(glyph) = lround((double) glyph_x_scale(glyph) * amount/whd.wd); + glyph_x_offset(glyph) = (whd.wd - amount)/2; + } } return box; } @@ -1016,7 +1019,6 @@ halfword tex_make_extensible(halfword fnt, halfword chr, scaled target, scaled m scaled max_natural = 0; /*tex amount of possible shrink in the stack */ scaled max_shrink = 0; - extinfo *extensible = NULL; scaled overlap; /*tex a temporary counter number of extensible pieces */ int pieces = 0; @@ -1026,15 +1028,10 @@ halfword tex_make_extensible(halfword fnt, halfword chr, scaled target, scaled m int with_extenders = -1; int n_of_extenders = 0; int n_of_normal = 0; + extinfo *extensible = tex_char_extensible_recipe_from_font(fnt, chr); if (minoverlap < 0) { minoverlap = 0; } - /* chr = math_char_exists(fnt, chr, math_state.size); */ - if (horizontal) { - extensible = tex_char_horizontal_parts_from_font(fnt, chr); - } else { - extensible = tex_char_vertical_parts_from_font(fnt, chr); - } tex_attach_attribute_list_attribute(box, att); for (extinfo *e = extensible; e; e = e->next) { if (! tex_char_exists(fnt, e->glyph)) { @@ -1135,13 +1132,13 @@ halfword tex_make_extensible(halfword fnt, halfword chr, scaled target, scaled m if (overlap < initial) { initial = overlap; } - if (advance == 0) { - /*tex for tfm fonts (so no need for scaling) */ - advance = tex_aux_math_x_size_scaled(fnt, tex_char_width_from_font(fnt, e->glyph), size); /* todo: combine */ + // if (advance == 0) { + // /*tex for tfm fonts (so no need for scaling) */ + // advance = tex_aux_math_x_size_scaled(fnt, tex_char_width_from_font(fnt, e->glyph), size); /* todo: combine */ if (advance <= 0) { tex_formatted_error("fonts", "bad horizontal extensible character %i in font %i", chr, fnt); } - } + // } max_natural += advance - initial; overlap = tex_aux_math_x_size_scaled(fnt, e->end_overlap, size); } else { @@ -1155,13 +1152,13 @@ halfword tex_make_extensible(halfword fnt, halfword chr, scaled target, scaled m if (overlap < initial) { initial = overlap; } - if (advance == 0) { - /*tex for tfm fonts (so no need for scaling) */ - advance = tex_aux_math_x_size_scaled(fnt, tex_char_width_from_font(fnt, e->glyph), size); /* todo: combine */ + // if (advance == 0) { + // /*tex for tfm fonts (so no need for scaling) */ + // advance = tex_aux_math_x_size_scaled(fnt, tex_char_width_from_font(fnt, e->glyph), size); /* todo: combine */ if (advance <= 0) { tex_formatted_error("fonts", "bad horizontal extensible character %i in font %i", chr, fnt); } - } + // } max_natural += advance - initial; overlap = tex_aux_math_x_size_scaled(fnt, e->end_overlap, size); pieces--; @@ -1179,12 +1176,12 @@ halfword tex_make_extensible(halfword fnt, halfword chr, scaled target, scaled m if (overlap < initial) { initial = overlap; } - if (advance == 0) { - advance = tex_aux_math_y_size_scaled(fnt, tex_char_total_from_font(fnt, e->glyph), size); /* todo: combine */ + // if (advance == 0) { + // advance = tex_aux_math_y_size_scaled(fnt, tex_char_total_from_font(fnt, e->glyph), size); /* todo: combine */ if (advance <= 0) { tex_formatted_error("fonts", "bad vertical extensible character %i in font %i", chr, fnt); } - } + // } max_natural += advance - initial; overlap = tex_aux_math_y_size_scaled(fnt, e->end_overlap, size); } else { @@ -1198,12 +1195,12 @@ halfword tex_make_extensible(halfword fnt, halfword chr, scaled target, scaled m if (overlap < initial) { initial = overlap; } - if (advance == 0) { - advance = tex_aux_math_y_size_scaled(fnt, tex_char_total_from_font(fnt, e->glyph), size); /* todo: combine */ + // if (advance == 0) { + // advance = tex_aux_math_y_size_scaled(fnt, tex_char_total_from_font(fnt, e->glyph), size); /* todo: combine */ if (advance <= 0) { tex_formatted_error("fonts", "bad vertical extensible character %i in font %i", chr, fnt); } - } + // } max_natural += advance - initial; overlap = tex_aux_math_y_size_scaled(fnt, e->end_overlap, size); pieces--; @@ -1263,15 +1260,37 @@ halfword tex_make_extensible(halfword fnt, halfword chr, scaled target, scaled m } /*tex Set glue so as to stretch the connections if needed. */ if (target > max_natural && max_shrink > 0) { - scaled delta = target - max_natural; - /*tex Don't stretch more than |s_max|. */ - if (delta > max_shrink) { - delta = max_shrink; - } - box_glue_order(box) = normal_glue_order; - box_glue_sign(box) = stretching_glue_sign; - box_glue_set(box) = (glueratio) (delta / (glueratio) max_shrink); - max_natural += delta; + // if (1) { + // halfword b; + // if (horizontal) { + // b = tex_hpack(box_list(box), target, packing_exactly, (singleword) math_direction_par, holding_none_option); + // } else { + // b = tex_vpack(box_list(box), target, packing_exactly, max_dimen, (singleword) math_direction_par, holding_none_option); + // } + // box_glue_order(box) = box_glue_order(b); + // box_glue_sign(box) = box_glue_sign(b); + // box_glue_set(box) = box_glue_set(b); + // box_list(b) = null; + // tex_flush_node(b); + // max_natural = target; + // } else { + scaled delta = target - max_natural; + /*tex Don't stretch more than |s_max|. */ + if (delta > max_shrink) { + if (tracing_math_par >= 1) { + tex_begin_diagnostic(); + tex_print_format("[math: extensible clipped, target %D, natural %D, shrink %D, clip %D]", + target, pt_unit, max_natural, pt_unit, max_shrink, pt_unit, delta - max_shrink, pt_unit + ); + tex_end_diagnostic(); + } + delta = max_shrink; + } + box_glue_order(box) = normal_glue_order; + box_glue_sign(box) = stretching_glue_sign; + box_glue_set(box) = (glueratio) (delta / (glueratio) max_shrink); + max_natural += delta; + // } } if (horizontal) { box_width(box) = max_natural; @@ -1402,7 +1421,7 @@ static halfword tex_aux_make_delimiter(halfword target, halfword delimiter, int goto FOUND; } } - if (tex_char_has_tag_from_font(curfnt, curchr, extension_tag)) { + if (tex_char_has_tag_from_font(curfnt, curchr, extensible_tag)) { fnt = curfnt; chr = curchr; do_parts = 1; @@ -1413,7 +1432,7 @@ static halfword tex_aux_make_delimiter(halfword target, halfword delimiter, int } else if (tex_char_has_tag_from_font(curfnt, curchr, list_tag)) { prvfnt = curfnt; prvchr = curchr; - curchr = tex_char_remainder_from_font(curfnt, curchr); + curchr = tex_char_next_from_font(curfnt, curchr); goto CONTINUE; } } @@ -1444,17 +1463,14 @@ static halfword tex_aux_make_delimiter(halfword target, halfword delimiter, int When the following code is executed, |do_parts| will be true if a built-up symbol is supposed to be returned. */ - extinfo *ext = NULL; - if (do_parts) { - /* tex_char_process(fnt, chr); */ /* in case we realloc */ - ext = flat ? tex_char_horizontal_parts_from_font(fnt, chr) : tex_char_vertical_parts_from_font(fnt, chr); - } + extinfo *ext = do_parts ? tex_char_extensible_recipe_from_font(fnt, chr) : NULL; if (ext) { scaled minoverlap = flat ? tex_get_math_x_parameter_default(style, math_parameter_connector_overlap_min, 0) : tex_get_math_y_parameter_default(style, math_parameter_connector_overlap_min, 0);; result = tex_aux_get_delimiter_box(fnt, chr, targetsize, minoverlap, flat, att); if (delta) { + /*tex Not yet done: horizontal italics. */ if (tex_aux_math_engine_control(fnt, math_control_apply_vertical_italic_kern)) { - *delta = tex_aux_math_x_size_scaled(fnt, tex_char_vertical_italic_from_font(fnt, nxtchr), size); + *delta = tex_aux_math_x_size_scaled(fnt, tex_char_extensible_italic_from_font(fnt, nxtchr), size); } else { *delta = tex_aux_math_x_size_scaled(fnt, tex_char_italic_from_font(fnt, nxtchr), size); } @@ -2303,6 +2319,8 @@ static void tex_aux_make_root_radical(halfword target, int style, int size, kern halfword companion = leftdelimiter ? rightdelimiter : null; halfword radical = null; delimiterextremes extremes = { .tfont = null_font, .tchar = 0, .bfont = null_font, .bchar = 0, .height = 0, .depth = 0 }; + scaled innerx = INT_MIN; + scaled innery = INT_MIN; noad_new_hlist(target) = null; /*tex We can take the rule width from the fam/style of the delimiter or use the most recent math @@ -2321,6 +2339,15 @@ static void tex_aux_make_root_radical(halfword target, int style, int size, kern theta = tex_get_math_y_parameter_checked(style, math_parameter_fraction_rule); /* a bit weird this one */ } delimiter = tex_aux_make_delimiter(target, delimiter, size, box_total(nucleus) + clearance + theta, 0, style, 1, NULL, NULL, 0, has_noad_option_nooverflow(target), &extremes, 0); + if (radical_degree(target)) { + if (tex_char_has_tag_from_font(extremes.bfont, extremes.bchar, inner_left_tag)) { + innerx = tex_char_inner_x_offset_from_font(extremes.bfont, extremes.bchar); + innery = tex_char_inner_y_offset_from_font(extremes.bfont, extremes.bchar); + } else if (tex_char_has_tag_from_font(extremes.tfont, extremes.tchar, inner_left_tag)) { + innerx = tex_char_inner_x_offset_from_font(extremes.tfont, extremes.tchar); + innery = tex_char_inner_y_offset_from_font(extremes.tfont, extremes.tchar); + } + } if (companion) { /*tex For now we assume symmetry and same height and depth! */ companion = tex_aux_make_delimiter(target, companion, size, box_total(nucleus) + clearance + theta, 0, style, 1, NULL, NULL, 0, has_noad_option_nooverflow(target), &extremes, 0); @@ -2385,6 +2412,10 @@ static void tex_aux_make_root_radical(halfword target, int style, int size, kern scaled before = tex_get_math_x_parameter_checked(style, math_parameter_radical_degree_before); scaled after = tex_get_math_x_parameter_checked(style, math_parameter_radical_degree_after); scaled raise = tex_get_math_parameter_checked(style, math_parameter_radical_degree_raise); + if (innerx != INT_MIN) { + tex_aux_append_hkern_to_box_list(degree, innerx, horizontal_math_kern_subtype, "bad degree"); + width += innerx; + } if (-after > width) { before += -after - width; } @@ -2396,7 +2427,11 @@ static void tex_aux_make_root_radical(halfword target, int style, int size, kern } else { nucleus = radical; } - box_shift_amount(degree) = - (tex_xn_over_d(total, raise, 100) - box_depth(radical) - box_shift_amount(radical)); + if (innery != INT_MIN) { + box_shift_amount(degree) = - innery + box_depth(radical) + box_shift_amount(radical); + } else { + box_shift_amount(degree) = - (tex_xn_over_d(total, raise, 100) - box_depth(radical) - box_shift_amount(radical)); + } tex_couple_nodes(degree, nucleus); if (before) { halfword kern = tex_new_kern_node(before, horizontal_math_kern_subtype); @@ -2876,8 +2911,8 @@ static void tex_aux_do_make_math_accent(halfword target, halfword accentfnt, hal target = tex_xn_over_d(target, fraction, 1000); } while (1) { - if (tex_char_has_tag_from_font(accentfnt, accentchr, extension_tag)) { - extended = tex_char_horizontal_parts_from_font(accentfnt, accentchr); + if (tex_char_has_tag_from_font(accentfnt, accentchr, extensible_tag)) { + extended = tex_char_extensible_recipe_from_font(accentfnt, accentchr); } if (extended) { /*tex @@ -2891,19 +2926,19 @@ static void tex_aux_do_make_math_accent(halfword target, halfword accentfnt, hal } else if (! tex_char_has_tag_from_font(accentfnt, accentchr, list_tag)) { break; } else { - halfword remainder = tex_char_remainder_from_font(accentfnt, accentchr); - if (! tex_char_exists(accentfnt, remainder)) { + halfword next = tex_char_next_from_font(accentfnt, accentchr); + if (! tex_char_exists(accentfnt, next)) { break; } else if (flags & overlay_accent_code) { - if (tex_aux_math_y_size_scaled(accentfnt, tex_char_height_from_font(accentfnt, remainder), size) > target) { + if (tex_aux_math_y_size_scaled(accentfnt, tex_char_height_from_font(accentfnt, next), size) > target) { break; } } else { - if (tex_aux_math_x_size_scaled(accentfnt, tex_char_width_from_font(accentfnt, remainder), size) > target) { + if (tex_aux_math_x_size_scaled(accentfnt, tex_char_width_from_font(accentfnt, next), size) > target) { break; } } - accentchr = remainder; + accentchr = next; } } /*tex @@ -2914,24 +2949,23 @@ static void tex_aux_do_make_math_accent(halfword target, halfword accentfnt, hal /*tex Italic gets added to width for traditional fonts (no italic anyway): */ accent = tex_aux_char_box(accentfnt, accentchr, attrlist, NULL, glyph_math_accent_subtype, basewidth, style); // usedwidth } - if (accenttotal) { - *accenttotal = box_total(accent); - } if (flags & top_accent_code) { scaled b = tex_get_math_y_parameter(style, math_parameter_accent_base_height); - scaled f = tex_get_math_y_parameter(style, math_parameter_flattened_accent_base_height); scaled u = tex_get_math_y_parameter(style, stretch ? math_parameter_flattened_accent_top_shift_up : math_parameter_accent_top_shift_up); - if (f != undefined_math_parameter && baseheight > f) { - halfword flatchr = tex_char_flat_accent_from_font(accentfnt, accentchr); - if (flatchr != INT_MIN && flatchr != accentchr) { - tex_flush_node(accent); - accent = tex_aux_char_box(accentfnt, flatchr, attrlist, NULL, glyph_math_accent_subtype, usedwidth, style); - if (tracing_math_par >= 2) { - tex_begin_diagnostic(); - tex_print_format("[math: flattening accent, old %x, new %x]", accentchr, flatchr); - tex_end_diagnostic(); + if (! tex_aux_math_engine_control(accentfnt, math_control_ignore_flat_accents)) { + scaled f = tex_get_math_y_parameter(style, math_parameter_flattened_accent_base_height); + if (f != undefined_math_parameter && baseheight > f) { + halfword flatchr = tex_char_flat_accent_from_font(accentfnt, accentchr); + if (flatchr != INT_MIN && flatchr != accentchr) { + tex_flush_node(accent); + accent = tex_aux_char_box(accentfnt, flatchr, attrlist, NULL, glyph_math_accent_subtype, usedwidth, style); + if (tracing_math_par >= 2) { + tex_begin_diagnostic(); + tex_print_format("[math: flattening accent, old %x, new %x]", accentchr, flatchr); + tex_end_diagnostic(); + } + accentchr = flatchr; } - accentchr = flatchr; } } if (b != undefined_math_parameter) { @@ -2956,6 +2990,9 @@ static void tex_aux_do_make_math_accent(halfword target, halfword accentfnt, hal /*tex Center the accent vertically around base: */ delta = tex_half_scaled(box_total(accent) + box_total(base)); } + if (accenttotal) { + *accenttotal = box_total(accent); + } if (node_type(nucleus) != math_char_node) { /*tex We have a molecule, not a simple atom. */ } else if (noad_has_following_scripts(target)) { @@ -3151,11 +3188,11 @@ static void tex_aux_wrap_fraction_result(halfword target, int style, int size, h halfword left = null; halfword right = null; halfword delta = tex_get_math_y_parameter(style, math_parameter_fraction_del_size); + delimiterextremes extremes = { .tfont = null_font, .tchar = 0, .bfont = null_font, .bchar = 0, .height = 0, .depth = 0 }; if (delta == undefined_math_parameter) { delta = tex_aux_get_delimiter_height(box_height(fraction), box_depth(fraction), 1, size, style); } /*tex Watch out: there can be empty delimiter boxes but with width. */ - delimiterextremes extremes = { .tfont = null_font, .tchar = 0, .bfont = null_font, .bchar = 0, .height = 0, .depth = 0 }; left = tex_aux_make_delimiter(target, left_delimiter, size, delta, 0, style, 1, NULL, NULL, 0, has_noad_option_nooverflow(target), NULL, 0); right = tex_aux_make_delimiter(target, right_delimiter, size, delta, 0, style, 1, NULL, NULL, 0, has_noad_option_nooverflow(target), &extremes, 0); if (kerns && extremes.tfont) { @@ -3895,9 +3932,9 @@ static scaled tex_aux_op_wrapup(halfword target, int style, int size, int italic } */ while (tex_char_has_tag_from_font(fnt, chr, list_tag) && tex_char_total_from_font(fnt, chr) < opsize) { - halfword rem = tex_char_remainder_from_font(fnt, chr); - if (chr != rem && tex_char_exists(fnt, rem)) { - chr = rem; + halfword next = tex_char_next_from_font(fnt, chr); + if (chr != next && tex_char_exists(fnt, next)) { + chr = next; kernel_math_character(noad_nucleus(target)) = chr; } else { break; @@ -4054,11 +4091,11 @@ static halfword tex_aux_check_ord(halfword current, halfword size, halfword next } case math_char_node: { + halfword curchr = null; + halfword curfnt = null; if (! next) { next = node_next(current); } - halfword curchr = null; - halfword curfnt = null; tex_aux_fetch(nucleus, "ordinal", &curfnt, &curchr); if (curfnt && curchr) { halfword kern = 0; @@ -4439,7 +4476,6 @@ static scaled tex_aux_math_kern_at(halfword fnt, int chr, int side, int value) return tex_char_top_left_kern_from_font(fnt, chr); case bottom_left_kern: return tex_char_bottom_left_kern_from_font(fnt, chr); - break; case top_right_kern: return tex_char_top_right_kern_from_font(fnt, chr); case bottom_right_kern: @@ -5336,6 +5372,22 @@ static void tex_aux_make_scripts(halfword target, halfword kernel, scaled italic */ +// static inline int tex_aux_is_extensible(halfword result) +// { +// if (result) { +// switch (node_type(result)) { +// case hlist_node: +// case vlist_node: +// switch (node_subtype(result)) { +// case math_h_delimiter_list: +// case math_v_delimiter_list: +// return 1; +// } +// } +// } +// return 0; +// } + static halfword tex_aux_make_left_right(halfword target, int style, scaled max_d, scaled max_h, int size, delimiterextremes *extremes) { halfword tmp; @@ -5347,6 +5399,8 @@ static halfword tex_aux_make_left_right(halfword target, int style, scaled max_d scaled height = tex_aux_math_given_y_scaled(noad_height(target)); scaled depth = tex_aux_math_given_y_scaled(noad_depth(target)); int leftoperator = node_type(target) == fence_noad && node_subtype(target) == left_operator_side; + max_h += fence_top_overshoot(target); + max_d += fence_bottom_overshoot(target); if (extremes) { extremes->tfont = null_font; extremes->bfont = null_font; @@ -5365,6 +5419,15 @@ static halfword tex_aux_make_left_right(halfword target, int style, scaled max_d /*tex Beware, a stacked delimiter has a shift but no corrected height/depth (yet). */ +/* or do we need has_noad_option_check(target) */ +if (! stack && has_noad_option_exact(target)) { + if (extremes && extremes->height < height) { + height = extremes->height; + } + if (extremes && extremes->depth < depth) { + depth = extremes->depth; + } +} if (stack) { box_shift_amount(tmp) = depth; } @@ -5373,10 +5436,15 @@ static halfword tex_aux_make_left_right(halfword target, int style, scaled max_d depth = box_depth(tmp) + box_shift_amount(tmp); } if (has_noad_option_axis(target)) { - halfword axis = tex_aux_math_axis(size); - height += axis; - depth -= axis; - box_shift_amount(tmp) -= axis; + // if (has_noad_option_noaxis(target) && tex_aux_is_extensible(tmp)) { + if (has_noad_option_noaxis(target) && stack) { + /*tex A sort of special case: see sized integrals in ctx examples. */ + } else { + halfword axis = tex_aux_math_axis(size); + height += axis; + depth -= axis; + box_shift_amount(tmp) -= axis; + } } lst = tex_new_node(hlist_node, 0); tex_attach_attribute_list_copy(lst, target); @@ -5392,7 +5460,7 @@ static halfword tex_aux_make_left_right(halfword target, int style, scaled max_d if (leftoperator && has_noad_option_auto(target)) { /*tex Todo: option for skipping this. */ if (style < text_style) { - scaled s = scaledround(tex_get_math_parameter(style, math_parameter_operator_size, NULL)); + scaled s = scaledround((double) tex_get_math_parameter(style, math_parameter_operator_size, NULL)); if (s > max_h + max_d) { max_h = scaledround(s / 2.0); max_d = max_h; @@ -5703,6 +5771,7 @@ static halfword tex_aux_check_nucleus_complexity(halfword target, scaled *italic halfword fnt = null; if (tex_aux_fetch(nucleus, "(text) char", &fnt, &chr)) { /*tex We make a math glyph from an ordinary one. */ + halfword glyph; quarterword subtype = 0; switch (node_subtype(nucleus)) { case ordinary_noad_subtype: subtype = glyph_math_ordinary_subtype; break; @@ -5736,7 +5805,7 @@ static halfword tex_aux_check_nucleus_complexity(halfword target, scaled *italic break; } - halfword glyph = tex_aux_new_math_glyph(fnt, chr, subtype); + glyph = tex_aux_new_math_glyph(fnt, chr, subtype); tex_attach_attribute_list_copy(glyph, nucleus); if (node_type(nucleus) == math_char_node) { glyph_properties(glyph) = kernel_math_properties(nucleus); @@ -6050,7 +6119,7 @@ static halfword tex_aux_unroll_noad(halfword tail, halfword l, quarterword s) while (l) { halfword n = node_next(l); node_next(l) = null; - if (node_type(l) == hlist_node && (s < 0 || node_subtype(l) == s) && ! box_source_anchor(l)) { + if (node_type(l) == hlist_node && (node_subtype(l) == s) && ! box_source_anchor(l)) { if (box_list(l)) { tex_couple_nodes(tail, box_list(l)); tail = tex_tail_of_node_list(tail); diff --git a/source/luametatex/source/tex/texnodes.c b/source/luametatex/source/tex/texnodes.c index c627a07cb..0134eb419 100644 --- a/source/luametatex/source/tex/texnodes.c +++ b/source/luametatex/source/tex/texnodes.c @@ -2451,7 +2451,7 @@ const char *tex_aux_subtype_str(halfword n) */ -void tex_print_specnode(halfword v, int unit) +static void tex_print_specnode(halfword v, int unit) /* for now local */ { if (tracing_nodes_par > 2) { tex_print_format("<%i>", v); @@ -2766,7 +2766,7 @@ void tex_show_node_list(halfword p, int threshold, int max) if (tex_par_state_is_set(p, par_pre_tolerance_code) ) { v = par_pre_tolerance(p) ; if (v) { tex_print_str(", pretolerance "); tex_print_int (v); } } if (tex_par_state_is_set(p, par_tolerance_code) ) { v = par_tolerance(p) ; if (v) { tex_print_str(", tolerance "); tex_print_int (v); } } if (tex_par_state_is_set(p, par_looseness_code) ) { v = par_looseness(p) ; if (v) { tex_print_str(", looseness "); tex_print_int (v); } } - if (tex_par_state_is_set(p, par_adjust_spacing_code) ) { v = par_adjust_spacing(p) ; if (v) { tex_print_str(", adjustaspacing "); tex_print_int (v); } } + if (tex_par_state_is_set(p, par_adjust_spacing_code) ) { v = par_adjust_spacing(p) ; if (v) { tex_print_str(", adjustspacing "); tex_print_int (v); } } if (tex_par_state_is_set(p, par_adj_demerits_code) ) { v = par_adj_demerits(p) ; if (v) { tex_print_str(", adjdemerits "); tex_print_int (v); } } if (tex_par_state_is_set(p, par_protrude_chars_code) ) { v = par_protrude_chars(p) ; if (v) { tex_print_str(", protrudechars "); tex_print_int (v); } } if (tex_par_state_is_set(p, par_line_penalty_code) ) { v = par_line_penalty(p) ; if (v) { tex_print_str(", linepenalty "); tex_print_int (v); } } @@ -3356,7 +3356,7 @@ scaled tex_glyph_depth(halfword p) /* not used */ scaledwhd tex_glyph_dimensions(halfword p) { - scaledwhd whd = { 0, 0, 0 }; + scaledwhd whd = { 0, 0, 0, 0 }; scaled x = glyph_x_offset(p); scaled y = glyph_y_offset(p); whd.ht = tex_char_height_from_glyph(p) + glyph_raise(p); @@ -3380,7 +3380,7 @@ scaledwhd tex_glyph_dimensions(halfword p) scaledwhd tex_glyph_dimensions_ex(halfword p) { - scaledwhd whd = { 0, 0, 0 }; + scaledwhd whd = { 0, 0, 0, 0 }; scaled x = glyph_x_offset(p); scaled y = glyph_y_offset(p); whd.ht = tex_char_height_from_glyph(p) + glyph_raise(p); @@ -3451,7 +3451,7 @@ halfword tex_kern_dimension_ex(halfword p) scaledwhd tex_pack_dimensions(halfword p) { - scaledwhd whd = { 0, 0, 0 }; + scaledwhd whd = { 0, 0, 0, 0 }; whd.ht = box_height(p); whd.dp = box_depth(p); whd.wd = box_width(p); @@ -4331,13 +4331,13 @@ void tex_check_disc_field(halfword n) void tex_set_discpart(halfword d, halfword h, halfword t, halfword code) { + halfword c = h; switch (node_subtype(d)) { case automatic_discretionary_code: case mathematics_discretionary_code: code = glyph_discpart_always; break; } - halfword c = h; while (c) { if (node_type(c) == glyph_node) { set_glyph_discpart(c, code); diff --git a/source/luametatex/source/tex/texnodes.h b/source/luametatex/source/tex/texnodes.h index a20117ff8..9e24ada27 100644 --- a/source/luametatex/source/tex/texnodes.h +++ b/source/luametatex/source/tex/texnodes.h @@ -1555,36 +1555,36 @@ typedef enum simple_choice_subtypes { \starttabulate[|l|l|l|l|l|l|] \FL - \BC \BC noad \BC accent \BC fraction \BC radical \NC fence \NC \NR - \ML \NC - \NC vlink 2 \NC new_hlist \NC \NC \NC \NC \NC \NR - \ML \NC - \NC vinfo 2 \NC nucleus \NC \NC \NC \NC \NC \NR - \NC vlink 3 \NC supscr \NC \NC numerator \NC \NC \NC \NR - \NC vinfo 3 \NC subscr \NC \NC denominator \NC \NC \NC \NR - \NC vlink 4 \NC supprescr \NC \NC \NC \NC \NC \NR - \NC vinfo 4 \NC subprescr \NC \NC \NC \NC \NC \NR - \ML \NC - \NC vlink 5 \NC italic \NC \NC \NC \NC \NC \NR - \NC vinfo 5 \NC width \NC \NC \NC \NC \NC \NR - \NC vlink 6 \NC height \NC \NC \NC \NC \NC \NR - \NC vinfo 6 \NC depth \NC \NC \NC \NC \NC \NR - \ML \NC - \NC vlink 7 \NC options \NC \NC \NC \NC \NC \NR - \NC vinfo 7 \NC style \NC \NC \NC \NC \NC \NR - \NC vlink 8 \NC family \NC \NC \NC \NC \NC \NR - \NC vinfo 8 \NC class \NC \NC \NC \NC \NC \NR - \NC vlink 9 \NC source \NC \NC \NC \NC \NC \NR - \NC vinfo 9 \NC prime \NC \NC \NC \NC \NC \NR - \NC vlink 10 \NC leftslack \NC \NC \NC \NC \NC \NR - \NC vinfo 10 \NC rightslack \NC \NC \NC \NC \NC \NR - \ML \NC - \NC vlink 11 \NC extra_1 \NC top_character \NC rule_thickness \NC degree \NC list \NC \NR - \NC vinfo 11 \NC extra_2 \NC bot_character \NC left_delimiter \NC left_delimiter \NC source \NC \NR - \NC vlink 12 \NC extra_3 \NC overlay_character \NC right_delimiter \NC right_delimiter \NC top \NC \NR - \NC vinfo 12 \NC extra_4 \NC fraction \NC middle_delimiter \NC \NC bottom \NC \NR - \NC vlink 13 \NC extra_5 \NC topovershoot \NC \NC height \NC \NC \NR - \NC vinfo 13 \NC extra_6 \NC botovershoot \NC \NC depth \NC \NC \NR + \BC \BC noad \BC accent \BC fraction \BC radical \NC fence \NC \NR + \ML \NC + \NC vlink 2 \NC new_hlist \NC \NC \NC \NC \NC \NR + \ML \NC + \NC vinfo 2 \NC nucleus \NC \NC \NC \NC \NC \NR + \NC vlink 3 \NC supscr \NC \NC numerator \NC \NC \NC \NR + \NC vinfo 3 \NC subscr \NC \NC denominator \NC \NC \NC \NR + \NC vlink 4 \NC supprescr \NC \NC \NC \NC \NC \NR + \NC vinfo 4 \NC subprescr \NC \NC \NC \NC \NC \NR + \ML \NC + \NC vlink 5 \NC italic \NC \NC \NC \NC \NC \NR + \NC vinfo 5 \NC width \NC \NC \NC \NC \NC \NR + \NC vlink 6 \NC height \NC \NC \NC \NC \NC \NR + \NC vinfo 6 \NC depth \NC \NC \NC \NC \NC \NR + \ML \NC + \NC vlink 7 \NC options \NC \NC \NC \NC \NC \NR + \NC vinfo 7 \NC style \NC \NC \NC \NC \NC \NR + \NC vlink 8 \NC family \NC \NC \NC \NC \NC \NR + \NC vinfo 8 \NC class \NC \NC \NC \NC \NC \NR + \NC vlink 9 \NC source \NC \NC \NC \NC \NC \NR + \NC vinfo 9 \NC prime \NC \NC \NC \NC \NC \NR + \NC vlink 10 \NC leftslack \NC \NC \NC \NC \NC \NR + \NC vinfo 10 \NC rightslack \NC \NC \NC \NC \NC \NR + \ML \NC + \NC vlink 11 \NC extra_1 \NC top_character \NC rule_thickness \NC degree \NC list \NC \NR + \NC vinfo 11 \NC extra_2 \NC bot_character \NC left_delimiter \NC left_delimiter \NC source \NC \NR + \NC vlink 12 \NC extra_3 \NC overlay_character \NC right_delimiter \NC right_delimiter \NC top \NC \NR + \NC vinfo 12 \NC extra_4 \NC fraction \NC middle_delimiter \NC \NC bottom \NC \NR + \NC vlink 13 \NC extra_5 \NC topovershoot \NC \NC height \NC topovershoot \NC \NR + \NC vinfo 13 \NC extra_6 \NC botovershoot \NC \NC depth \NC botovershoot \NC \NR \LL \stoptabulate @@ -1767,10 +1767,10 @@ inline int has_noad_no_script_option(halfword n, halfword option) return 0; } -# define has_noad_option_nosubscript(a) has_noad_no_script_option(a, noad_option_no_sub_script) -# define has_noad_option_nosupscript(a) has_noad_no_script_option(a, noad_option_no_super_script) -# define has_noad_option_nosubprescript(a) has_noad_no_script_option(a, noad_option_no_sub_pre_script) -# define has_noad_option_nosupprescript(a) has_noad_no_script_option(a, noad_option_no_super_pre_script) +# define has_noad_option_nosubscript(a) has_noad_no_script_option(a, noad_option_no_sub_script) +# define has_noad_option_nosupscript(a) has_noad_no_script_option(a, noad_option_no_super_script) +# define has_noad_option_nosubprescript(a) has_noad_no_script_option(a, noad_option_no_sub_pre_script) +# define has_noad_option_nosupprescript(a) has_noad_no_script_option(a, noad_option_no_super_pre_script) # define has_noad_option_shiftedsubscript(a) (has_option(noad_options(a), noad_option_shifted_sub_script)) # define has_noad_option_shiftedsupscript(a) (has_option(noad_options(a), noad_option_shifted_super_script)) @@ -1906,8 +1906,8 @@ typedef enum math_accent_subtypes { # define fence_delimiter_list noad_extra_1 // not really a list # define fence_delimiter_top noad_extra_3 # define fence_delimiter_bottom noad_extra_4 -//define fence_delimiter_first noad_extra_5 -//define fence_delimiter_last noad_extra_6 +# define fence_top_overshoot noad_extra_5 +# define fence_bottom_overshoot noad_extra_6 typedef enum fence_subtypes { unset_fence_side, @@ -2004,14 +2004,14 @@ typedef enum math_kernel_options { math_kernel_has_italic_shape = 0x0080, } math_kernel_options; -# define math_kernel_node_size 5 -# define kernel_math_family(a) vinfo(a,2) -# define kernel_math_character(a) vlink(a,2) -# define kernel_math_options(a) vinfo(a,3) -# define kernel_math_list(a) vlink(a,3) -# define kernel_math_properties(a) vinfo0(a,4) /* for characters */ -# define kernel_math_group(a) vinfo1(a,4) /* for characters */ -# define kernel_math_index(a) vlink(a,4) /* for characters */ +# define math_kernel_node_size 5 +# define kernel_math_family(a) vinfo(a,2) +# define kernel_math_character(a) vlink(a,2) +# define kernel_math_options(a) vinfo(a,3) +# define kernel_math_list(a) vlink(a,3) +# define kernel_math_properties(a) vinfo0(a,4) /* for characters */ +# define kernel_math_group(a) vinfo1(a,4) /* for characters */ +# define kernel_math_index(a) vlink(a,4) /* for characters */ # define math_kernel_node_has_option(a,b) ((kernel_math_options(a) & b) == b) # define math_kernel_node_set_option(a,b) kernel_math_options(a) = (kernel_math_options(a) | b) @@ -2021,6 +2021,26 @@ typedef enum math_kernel_options { in traditional \TEX\ fonts where a base character can come from one font, and the extensible from another, but in \OPENTYPE\ math font that doesn't happen. */ + +/* It could be: */ + +// # define math_delimiter_node_size 4 +// # define delimiter_small_family(a) vinfo00(a,2) +// # define delimiter_large_family(a) vinfo01(a,2) +// # define delimiter_reserved_1 vinfo02(a,2) +// # define delimiter_reserved_2 vinfo03(a,2) +// # define delimiter_reserved_3 vlink(a,2) +// # define delimiter_small_character(a) vinfo(a,3) +// # define delimiter_large_character(a) vlink(a,3) + +/* And some day (we then even assume traditionally to be mapped onto wide): */ + +// # define math_delimiter_node_size 3 +// # define delimiter_family(a) vinfo00(a,2) +// # define delimiter_reserved_1 vinfo01(a,2) +// # define delimiter_reserved_2 vinfo02(a,2) +// # define delimiter_reserved_3 vinfo03(a,2) +// # define delimiter_character(a) vlink(a,2) # define math_delimiter_node_size 4 # define delimiter_small_family(a) vinfo(a,2) /*tex |family| for small delimiter */ @@ -2538,15 +2558,20 @@ inline static void tex_attach_attribute_list_attribute(halfword target, halfword is used in the \LUA\ interface is stored alongside. */ -extern void tex_print_short_node_contents (halfword n); -extern void tex_show_node_list (halfword n, int threshold, int max); -extern halfword tex_actual_box_width (halfword r, scaled base_width); -extern void tex_print_name (halfword p, const char *what); -extern void tex_print_node_list (halfword n, const char *what, int threshold, int max); -/* void tex_print_node_and_details (halfword p); */ -/* void tex_print_subtype_and_attributes_info (halfword p, halfword s, node_info *data); */ -extern void tex_print_extended_subtype (halfword p, quarterword s); -extern void tex_aux_show_dictionary (halfword p, halfword properties, halfword group, halfword index, halfword font, halfword character); +extern void tex_print_short_node_contents (halfword n); +extern const char *tex_aux_subtype_str (halfword n); +extern void tex_show_node_list (halfword n, int threshold, int max); +extern halfword tex_actual_box_width (halfword r, scaled base_width); +extern void tex_print_name (halfword p, const char *what); +extern void tex_print_node_list (halfword n, const char *what, int threshold, int max); +/* void tex_print_node_and_details (halfword p); */ +/* void tex_print_subtype_and_attributes_info (halfword p, halfword s, node_info *data); */ +extern void tex_print_extended_subtype (halfword p, quarterword s); +extern void tex_aux_show_dictionary (halfword p, halfword properties, halfword group, halfword index, halfword font, halfword character); + +/*tex + Basic node management: +*/ extern halfword tex_new_node (quarterword i, quarterword j); extern void tex_flush_node_list (halfword n); @@ -2596,23 +2621,8 @@ typedef enum glue_signs { # define normal_glue_multiplier 0.0 -inline halfword tex_checked_glue_sign(halfword sign) -{ - if ((sign < min_glue_sign) || (sign > max_glue_sign)) { - return normal_glue_sign; - } else { - return sign; - } -} - -inline halfword tex_checked_glue_order(halfword order) -{ - if ((order < min_glue_order) || (order > max_glue_order)) { - return normal_glue_order; - } else { - return order; - } -} +inline halfword tex_checked_glue_sign (halfword sign) { return ((sign < min_glue_sign ) || (sign > max_glue_sign )) ? normal_glue_sign : sign ; } +inline halfword tex_checked_glue_order (halfword order) { return ((order < min_glue_order) || (order > max_glue_order)) ? normal_glue_order : order; } /*tex These are reserved nodes that sit at the start of main memory. We could actually just allocate @@ -2626,7 +2636,6 @@ inline halfword tex_checked_glue_order(halfword order) Changing this to real nodes makes sense but is also tricky due to initializations ... some day (we need to store stuff in teh states then and these are not saved!). - */ # define fi_glue (zero_glue + glue_spec_size) /*tex These are constants */ @@ -2683,6 +2692,8 @@ extern scaledwhd tex_glyph_dimensions_ex (halfword p); /* x/y scaled, expansion extern halfword tex_kern_dimension (halfword p); extern halfword tex_kern_dimension_ex (halfword p); /* expansion included */ +extern scaled tex_effective_glue (halfword parent, halfword glue); + extern scaledwhd tex_pack_dimensions (halfword p); extern halfword tex_list_node_mem_usage (void); @@ -2723,13 +2734,9 @@ typedef enum special_node_list_types { /* not in sycn with the above .. maybe ad // best_page_break_type } special_node_list_types; -extern int tex_is_special_node_list (halfword n, int *istail); -extern halfword tex_get_special_node_list (special_node_list_types list, halfword *tail); -extern void tex_set_special_node_list (special_node_list_types list, halfword head); - -extern scaled tex_effective_glue (halfword parent, halfword glue); - -extern const char *tex_aux_subtype_str (halfword n ); +extern int tex_is_special_node_list (halfword n, int *istail); +extern halfword tex_get_special_node_list (special_node_list_types list, halfword *tail); +extern void tex_set_special_node_list (special_node_list_types list, halfword head); # endif diff --git a/source/luametatex/source/tex/texpackaging.c b/source/luametatex/source/tex/texpackaging.c index b2286cd71..796c3c1b7 100644 --- a/source/luametatex/source/tex/texpackaging.c +++ b/source/luametatex/source/tex/texpackaging.c @@ -422,11 +422,11 @@ scaled tex_char_stretch(halfword p) /* todo: move this to texfont.c and make it halfword m = font_max_stretch(f); if (m > 0) { halfword c = glyph_character(p); - halfword ef = tex_char_ef_from_font(f, c); - if (ef > 0) { + scaled e = tex_char_ef_from_font(f, c); + if (e > 0) { scaled dw = tex_calculated_glyph_width(p, m) - tex_char_width_from_glyph(p); if (dw > 0) { - return tex_round_xn_over_d(dw, ef, 1000); + return tex_round_xn_over_d(dw, e, 1000); } } } @@ -441,11 +441,11 @@ scaled tex_char_shrink(halfword p) /* todo: move this to texfont.c and make it m halfword m = font_max_shrink(f); if (m > 0) { halfword c = glyph_character(p); - halfword ef = tex_char_ef_from_font(f, c); - if (ef > 0) { + scaled e = tex_char_cf_from_font(f, c); + if (e > 0) { scaled dw = tex_char_width_from_glyph(p) - tex_calculated_glyph_width(p, -m); if (dw > 0) { - return tex_round_xn_over_d(dw, ef, 1000); + return tex_round_xn_over_d(dw, e, 1000); } } } @@ -482,7 +482,7 @@ scaled tex_kern_shrink(halfword p) if (l && node_type(l) == glyph_node && ! tex_has_glyph_option(l, glyph_option_no_expansion)) { halfword m = font_max_shrink(glyph_font(l)); if (m > 0) { - halfword e = tex_char_ef_from_font(glyph_font(l), glyph_character(l)); + scaled e = tex_char_cf_from_font(glyph_font(l), glyph_character(l)); if (e > 0) { scaled dw = tex_round_xn_over_d(w, 1000 - m, 1000) - w; if (dw > 0) { @@ -503,20 +503,23 @@ static void tex_aux_set_kern_expansion(halfword p, halfword ex_ratio) if (l && node_type(l) == glyph_node && ! tex_has_glyph_option(l, glyph_option_no_expansion)) { halfword f = glyph_font(l); halfword c = glyph_character(l); - halfword ef = tex_char_ef_from_font(f, c); - if (ef == 0) { - return; - } else if (ex_ratio > 0) { - halfword m = font_max_stretch(f); - if (m > 0) { - halfword ex_stretch = tex_ext_xn_over_d(ex_ratio * ef, m, 1000000); - kern_expansion(p) = tex_fix_expand_value(f, ex_stretch) * 1000; + if (ex_ratio > 0) { + scaled e = tex_char_ef_from_font(f, c); + if (e > 0) { + halfword m = font_max_stretch(f); + if (m > 0) { + e = tex_ext_xn_over_d(ex_ratio * e, m, 1000000); + kern_expansion(p) = tex_fix_expand_value(f, e) * 1000; + } } } else if (ex_ratio < 0) { - halfword m = font_max_shrink(f); - if (m > 0) { - halfword ex_shrink = tex_ext_xn_over_d(ex_ratio * ef, m, 1000000); - kern_expansion(p) = tex_fix_expand_value(f, ex_shrink) * 1000; + scaled e = tex_char_cf_from_font(f, c); + if (e > 0) { + halfword m = font_max_shrink(f); + if (m > 0) { + e = tex_ext_xn_over_d(ex_ratio * e, m, 1000000); + kern_expansion(p) = tex_fix_expand_value(f, e) * 1000; + } } } } @@ -528,22 +531,27 @@ static void tex_aux_set_glyph_expansion(halfword p, int ex_ratio) switch (node_type(p)) { case glyph_node: if (! tex_has_glyph_option(p, glyph_option_no_expansion)) { - halfword f = glyph_font(p); - halfword c = glyph_character(p); - halfword ef = tex_char_ef_from_font(f, c); - if (ef == 0) { - return; - } else if (ex_ratio > 0) { - halfword m = font_max_stretch(f); - if (m > 0) { - halfword ex_stretch = tex_ext_xn_over_d(ex_ratio * ef, m, 1000000); - glyph_expansion(p) = tex_fix_expand_value(f, ex_stretch) * 1000; + if (ex_ratio > 0) { + halfword f = glyph_font(p); + halfword c = glyph_character(p); + scaled e = tex_char_ef_from_font(f, c); + if (e > 0) { + halfword m = font_max_stretch(f); + if (m > 0) { + e = tex_ext_xn_over_d(ex_ratio * e, m, 1000000); + glyph_expansion(p) = tex_fix_expand_value(f, e) * 1000; + } } } else if (ex_ratio < 0) { - halfword m = font_max_shrink(f); - if (m > 0) { - halfword ex_shrink = tex_ext_xn_over_d(ex_ratio * ef, m, 1000000); - glyph_expansion(p) = tex_fix_expand_value(f, ex_shrink) * 1000; + halfword f = glyph_font(p); + halfword c = glyph_character(p); + scaled e = tex_char_cf_from_font(f, c); + if (e > 0) { + halfword m = font_max_shrink(f); + if (m > 0) { + e = tex_ext_xn_over_d(ex_ratio * e, m, 1000000); + glyph_expansion(p) = tex_fix_expand_value(f, e) * 1000; + } } } } @@ -1039,7 +1047,7 @@ halfword tex_hpack(halfword p, scaled w, int m, singleword pack_direction, int r /*tex natural width */ scaled x = 0; /*tex the current direction */ - singleword hpack_dir = pack_direction == direction_unknown ? text_direction_par : pack_direction; + singleword hpack_dir = pack_direction == direction_unknown ?(singleword) text_direction_par : pack_direction; int disc_level = 0; halfword pack_interrupt[8]; scaled font_stretch = 0; @@ -1126,11 +1134,11 @@ halfword tex_hpack(halfword p, scaled w, int m, singleword pack_direction, int r break; } case packing_substitute: - { - lmt_packaging_state.previous_char_ptr = p; + lmt_packaging_state.previous_char_ptr = p; + if (lmt_packaging_state.font_expansion_ratio != 0) { tex_aux_set_glyph_expansion(p, lmt_packaging_state.font_expansion_ratio); - break; } + break; } } whd = tex_glyph_dimensions_ex(p); @@ -1256,10 +1264,10 @@ halfword tex_hpack(halfword p, scaled w, int m, singleword pack_direction, int r break; } case packing_substitute: - { + if (lmt_packaging_state.font_expansion_ratio != 0) { tex_aux_set_kern_expansion(p, lmt_packaging_state.font_expansion_ratio); - break; } + break; } } x += tex_kern_dimension_ex(p); @@ -1274,7 +1282,9 @@ halfword tex_hpack(halfword p, scaled w, int m, singleword pack_direction, int r */ break; case packing_substitute: - tex_aux_set_glyph_expansion(p, lmt_packaging_state.font_expansion_ratio); + if (lmt_packaging_state.font_expansion_ratio != 0) { + tex_aux_set_glyph_expansion(p, lmt_packaging_state.font_expansion_ratio); + } break; } } @@ -1575,7 +1585,7 @@ halfword tex_hpack(halfword p, scaled w, int m, singleword pack_direction, int r halfword tex_filtered_hpack(halfword p, halfword qt, scaled w, int m, int grp, halfword d, int just_pack, halfword attr, int state, int retain) { halfword head; - singleword direction = checked_direction_value(d); + singleword direction = (singleword) checked_direction_value(d); (void) state; /*tex Why do we pass it? Probably a left-over from an experiment. */ if (just_pack) { head = node_next(p); @@ -1603,7 +1613,7 @@ halfword tex_filtered_hpack(halfword p, halfword qt, scaled w, int m, int grp, h scaledwhd tex_natural_hsizes(halfword p, halfword pp, glueratio g_mult, int g_sign, int g_order) { - scaledwhd siz = { 0, 0, 0 }; + scaledwhd siz = { 0, 0, 0, 0 }; scaled gp = 0; scaled gm = 0; while (p && p != pp) { @@ -1757,7 +1767,7 @@ scaledwhd tex_natural_hsizes(halfword p, halfword pp, glueratio g_mult, int g_si scaledwhd tex_natural_vsizes(halfword p, halfword pp, glueratio g_mult, int g_sign, int g_order) { - scaledwhd siz = { 0, 0, 0 }; + scaledwhd siz = { 0, 0, 0, 0 }; scaled gp = 0; scaled gm = 0; while (p && p != pp) { @@ -1974,7 +1984,7 @@ halfword tex_natural_hsize(halfword p, halfword *correction) halfword tex_natural_vsize(halfword p) { - scaledwhd siz = { 0, 0, 0 }; + scaledwhd siz = { 0, 0, 0, 0 }; while (p) { switch (node_type(p)) { case hlist_node: @@ -2293,7 +2303,7 @@ halfword tex_filtered_vpack(halfword p, scaled h, int m, scaled maxdepth, int gr if (! just_pack) { q = lmt_vpack_filter_callback(q, h, m, maxdepth, grp, direction, attr); } - q = tex_vpack(q, h, m, maxdepth, checked_direction_value(direction), retain); + q = tex_vpack(q, h, m, maxdepth, (singleword) checked_direction_value(direction), retain); if (q && normalize_par_mode_permitted(normalize_par_mode_par, flatten_v_leaders_mode) && ! is_box_package_state(state, package_u_leader_delayed)) { tex_flatten_leaders(q, NULL); } @@ -3111,7 +3121,7 @@ halfword tex_vert_break(halfword p, scaled h, scaled d) prev_p = p; p = node_next(prev_p); } - return best_place; + return best_place; /* unreachable */ } /*tex diff --git a/source/luametatex/source/tex/texprimitive.c b/source/luametatex/source/tex/texprimitive.c index 42344af15..d5f2b0927 100644 --- a/source/luametatex/source/tex/texprimitive.c +++ b/source/luametatex/source/tex/texprimitive.c @@ -182,7 +182,7 @@ static int tex_aux_room_in_hash(void) */ -inline static halfword tex_aux_compute_hash(const char *j, int l) +inline static halfword tex_aux_compute_hash(const char *j, unsigned l) { halfword h = (unsigned const char) j[0]; for (unsigned k = 1; k < l; k++) { @@ -504,7 +504,7 @@ static halfword tex_aux_insert_id(halfword p, const unsigned char *j, unsigned i halfword tex_id_locate(int j, int l, int create) { /*tex The index in |hash| array: */ - halfword h = tex_aux_compute_hash((char *) (lmt_fileio_state.io_buffer + j), l); + halfword h = tex_aux_compute_hash((char *) (lmt_fileio_state.io_buffer + j), (unsigned) l); /*tex We start searching here. Note that |0 <= h < hash_prime|: */ halfword p = h + hash_base; /*tex The next one in a list: */ @@ -536,7 +536,7 @@ halfword tex_id_locate(int j, int l, int create) halfword tex_string_locate(const char *s, size_t l, int create) { /*tex The hash code: */ - halfword h = tex_aux_compute_hash(s, (int) l); + halfword h = tex_aux_compute_hash(s, (unsigned) l); /*tex The index in |hash| array. We start searching here. Note that |0 <= h < hash_prime|: */ halfword p = h + hash_base; while (1) { @@ -702,7 +702,7 @@ void tex_print_cmd_flags(halfword cs, halfword cmd, int flags, int escaped) if (is_instance (flags)) { (escaped ? tex_print_str_esc : tex_print_str)("instance " ); } if (is_untraced (flags)) { (escaped ? tex_print_str_esc : tex_print_str)("untraced " ); } } - if (is_tolerant_cmd (cmd)) { + if (is_tolerant_cmd(cmd)) { (escaped ? tex_print_str_esc : tex_print_str)("tolerant " ); } if (is_protected_cmd(cmd)) { diff --git a/source/luametatex/source/tex/texprinting.c b/source/luametatex/source/tex/texprinting.c index deabb4b72..860ff6731 100644 --- a/source/luametatex/source/tex/texprinting.c +++ b/source/luametatex/source/tex/texprinting.c @@ -590,10 +590,6 @@ void tex_print_hex(int sn) unsigned int n = (unsigned int) sn; int k = 0; unsigned char digits[24]; - if (n < 0) { - tex_print_char('-'); - n = -n; - } do { unsigned char d = (unsigned char) (n % 16); if (d < 10) { @@ -695,30 +691,38 @@ void tex_print_current_string(void) void tex_print_cs_checked(halfword p) { - if (p == null_cs) { - tex_print_str_esc("csname"); - tex_print_str_esc("endcsname"); - tex_print_char(' '); - } else if (p < hash_base) { - tex_print_str(error_string_impossible(11)); - } else if (p == undefined_control_sequence) { - tex_print_str_esc("undefined"); - tex_print_char(' '); - } else if (eqtb_out_of_range(p)) { - tex_print_str(error_string_impossible(12)); - } else { - strnumber t = cs_text(p); - if (t < 0 || t >= lmt_string_pool_state.string_pool_data.ptr) { - tex_print_str(error_string_nonexistent(13)); - } else if (tex_is_active_cs(t)) { - tex_print_tex_str(active_cs_value(t)); - } else { - tex_print_tex_str_esc(t); - if (! tex_single_letter(t) || (tex_get_cat_code(cat_code_table_par, aux_str2uni(str_string(t))) == letter_cmd)) { - tex_print_char(' '); + switch (tex_cs_state(p)) { + case cs_no_error: + { + strnumber t = cs_text(p); + if (t < 0 || t >= lmt_string_pool_state.string_pool_data.ptr) { + tex_print_str(error_string_nonexistent(13)); + } else if (tex_is_active_cs(t)) { + tex_print_tex_str(active_cs_value(t)); + } else { + tex_print_tex_str_esc(t); + if (! tex_single_letter(t) || (tex_get_cat_code(cat_code_table_par, aux_str2uni(str_string(t))) == letter_cmd)) { + tex_print_char(' '); + } + } } - } - } + break; + case cs_null_error: + tex_print_str_esc("csname"); + tex_print_str_esc("endcsname"); + tex_print_char(' '); + break; + case cs_below_base_error: + tex_print_str(error_string_impossible(11)); + break; + case cs_undefined_error: + tex_print_str_esc("undefined"); + tex_print_char(' '); + break; + case cs_out_of_range_error: + tex_print_str(error_string_impossible(12)); + break; + } } /*tex diff --git a/source/luametatex/source/tex/texscanning.c b/source/luametatex/source/tex/texscanning.c index fec04356b..5480910dc 100644 --- a/source/luametatex/source/tex/texscanning.c +++ b/source/luametatex/source/tex/texscanning.c @@ -668,7 +668,7 @@ static int tex_aux_set_cur_val_by_some_cmd(int code) case math_char_class_code: case math_char_fam_code: case math_char_slot_code: - /* we actually need two commands or we need to look ahead */ + /* we actually need two commands or we need to look ahead */ { mathcodeval mval = { 0, 0, 0 }; mathdictval dval = { 0, 0, 0 }; @@ -1594,6 +1594,14 @@ static halfword tex_aux_scan_something_internal(halfword cmd, halfword chr, int cur_val_level = int_val_level; break; } + case font_cf_code: + { + halfword fnt = tex_scan_font_identifier(NULL); + halfword chr = tex_scan_char_number(0); + cur_val = tex_char_cf_from_font(fnt, chr); + cur_val_level = int_val_level; + break; + } case font_dimen_code: { cur_val = tex_get_font_dimen(); @@ -1975,8 +1983,8 @@ halfword tex_scan_int(int optional_equal, int *radix) *radix = 8; } while (1) { - tex_get_x_token(); unsigned d = 0; + tex_get_x_token(); if ((cur_tok >= zero_token) && (cur_tok <= seven_token)) { d = cur_tok - zero_token; } else { @@ -1997,7 +2005,7 @@ halfword tex_scan_int(int optional_equal, int *radix) } } } - break; + // break; } case hex_token: { @@ -2005,8 +2013,8 @@ halfword tex_scan_int(int optional_equal, int *radix) *radix = 16; } while (1) { - tex_get_x_token(); unsigned d = 0; + tex_get_x_token(); if ((cur_tok >= zero_token) && (cur_tok <= nine_token)) { d = cur_tok - zero_token; } else if ((cur_tok >= A_token_l) && (cur_tok <= F_token_l)) { @@ -2031,7 +2039,7 @@ halfword tex_scan_int(int optional_equal, int *radix) } } } - break; + // break; } default: { @@ -2061,7 +2069,7 @@ halfword tex_scan_int(int optional_equal, int *radix) } tex_get_x_token(); } - break; + // break; } } DONE: @@ -2099,8 +2107,8 @@ int tex_scan_cardinal(unsigned *value, int dontbark) case octal_token: { while (1) { - tex_get_x_token(); unsigned d = 0; + tex_get_x_token(); if ((cur_tok >= zero_token) && (cur_tok <= seven_token)) { d = cur_tok - zero_token; } else { @@ -2112,13 +2120,13 @@ int tex_scan_cardinal(unsigned *value, int dontbark) result = max_cardinal; } } - break; + // break; } case hex_token: { while (1) { - tex_get_x_token(); unsigned d = 0; + tex_get_x_token(); if ((cur_tok >= zero_token) && (cur_tok <= nine_token)) { d = cur_tok - zero_token; } else if ((cur_tok >= A_token_l) && (cur_tok <= F_token_l)) { @@ -2134,7 +2142,7 @@ int tex_scan_cardinal(unsigned *value, int dontbark) result = max_cardinal; } } - break; + // break; } default: { @@ -2152,7 +2160,7 @@ int tex_scan_cardinal(unsigned *value, int dontbark) } tex_get_x_token(); } - break; + // break; } } DONE: @@ -2304,6 +2312,7 @@ typedef enum scanned_unit { static int tex_aux_scan_unit(halfword *num, halfword *denom, halfword *value, halfword *order) { + AGAIN: /* only for true */ do { tex_get_x_token(); } while (cur_cmd == spacer_cmd); @@ -2327,7 +2336,6 @@ static int tex_aux_scan_unit(halfword *num, halfword *denom, halfword *value, ha goto BACK_TWO; } cur_cs = save_cur_cs; - AGAIN: switch (chrone) { case 'p': case 'P': switch (chrtwo) { @@ -2405,7 +2413,7 @@ static int tex_aux_scan_unit(halfword *num, halfword *denom, halfword *value, ha switch (chrtwo) { case 'r': case 'R': if (tex_scan_mandate_keyword("true", 2)) { - /*tex This is now a bogus prefix! */ + /*tex This is now a bogus prefix that might get dropped! */ goto AGAIN; } } @@ -4178,7 +4186,7 @@ static void tex_aux_scan_expr(halfword level) node_subtype(t) = 0; /* */ node_next(t) = top; - expression_type(t) = (quarterword) level; + expression_type(t) = (singleword) level; expression_state(t) = (singleword) state; expression_result(t) = (singleword) result; expression_expression(t) = expression; @@ -4576,7 +4584,7 @@ static const char *bit_expression_names[] = { variant that only uses doubles: |dimenexpression| and |numberexpression|. */ -# define factor 1000 +# define factor 1 // 256, 1000 : wrong results so needs a fix typedef struct stack_info { halfword head; @@ -4879,8 +4887,8 @@ static halfword tex_scan_bit_int(int *radix) *radix = 8; } while (1) { - tex_get_x_token(); unsigned d = 0; + tex_get_x_token(); if ((cur_tok >= zero_token) && (cur_tok <= seven_token)) { d = cur_tok - zero_token; } else { @@ -4896,7 +4904,7 @@ static halfword tex_scan_bit_int(int *radix) } } } - break; + // break; } case hex_token: { @@ -4904,8 +4912,8 @@ static halfword tex_scan_bit_int(int *radix) *radix = 16; } while (1) { - tex_get_x_token(); unsigned d = 0; + tex_get_x_token(); if ((cur_tok >= zero_token) && (cur_tok <= nine_token)) { d = cur_tok - zero_token; } else if ((cur_tok >= A_token_l) && (cur_tok <= F_token_l)) { @@ -4925,7 +4933,7 @@ static halfword tex_scan_bit_int(int *radix) } } } - break; + // break; } default: { @@ -4950,7 +4958,7 @@ static halfword tex_scan_bit_int(int *radix) } tex_get_x_token(); } - break; + // break; } } DONE: @@ -5066,6 +5074,8 @@ static void tex_aux_trace_expression(stack_info stack, halfword level, halfword tex_end_diagnostic(); } +/* This one is not yet okay ... work in progress. */ + static void tex_aux_scan_expression(int level) { stack_info operators = tex_aux_new_stack(); @@ -5521,7 +5531,7 @@ static void tex_aux_scan_expression(int level) break; case bit_expression_multiply: { - double d = va * vb; + double d = (double) va * (double) vb; if (sa == bit_expression_float) { d = d / (65536 * factor); } else if (sb == bit_expression_float) { @@ -5687,7 +5697,7 @@ int tex_scan_tex_value(halfword level, halfword *value) quarterword tex_scan_direction(int optional_equal) { int i = tex_scan_int(optional_equal, NULL); - return checked_direction_value(i); + return (quarterword) checked_direction_value(i); } halfword tex_scan_geometry(int optional_equal) diff --git a/source/luametatex/source/tex/textoken.c b/source/luametatex/source/tex/textoken.c index 93bf3913a..7dd9c888b 100644 --- a/source/luametatex/source/tex/textoken.c +++ b/source/luametatex/source/tex/textoken.c @@ -161,13 +161,12 @@ void tex_compact_tokens(void) { int nc = 0; // memoryword *target = allocate_array(sizeof(memoryword), (size_t) token_memory_state.tokens_data.allocated, 0); - memoryword *target = aux_allocate_clear_array(sizeof(memoryword), (size_t) lmt_token_memory_state.tokens_data.allocated, 0); - halfword *mapper = aux_allocate_array(sizeof(halfword), (size_t) lmt_token_memory_state.tokens_data.allocated, 0); + memoryword *target = aux_allocate_clear_array(sizeof(memoryword), lmt_token_memory_state.tokens_data.allocated, 0); + halfword *mapper = aux_allocate_array(sizeof(halfword), lmt_token_memory_state.tokens_data.allocated, 0); int nofluacmds = 0; if (target && mapper) { - // memset((void *) target, 0, ((size_t) token_memory_state.tokens_data.allocated) * sizeof(memoryword)); - memset((void *) mapper, -1, ((size_t) lmt_token_memory_state.tokens_data.allocated) * sizeof(halfword)); memoryword *tokens = lmt_token_memory_state.tokens; + memset((void *) mapper, -1, ((size_t) lmt_token_memory_state.tokens_data.allocated) * sizeof(halfword)); /* also reset available */ for (int cs = 0; cs < (eqtb_size + lmt_hash_state.hash_data.ptr + 1); cs++) { switch (eq_type(cs)) { @@ -579,8 +578,6 @@ static const char *tex_aux_special_cmd_string(halfword cmd, halfword chr, const } } -halfword nn = 0; - halfword tex_show_token_list(halfword p, halfword q, int l, int asis) { if (p) { @@ -794,7 +791,6 @@ halfword tex_scan_character(const char *s, int left_brace, int skip_space, int s } else { goto DONE; } - break; case relax_cmd: if (skip_relax) { break; @@ -3082,6 +3078,13 @@ char *tex_tokenlist_to_tstring(int pp, int inhibit_par, int *siz, int skippreamb /*tex We need to go beyond the reference. */ int p = token_link(pp); if (p) { + int e = escape_char_par; /*tex The serialization of the escape, normally a backlash. */ + int n = '0'; /*tex The character after |#|, so |#0| upto |#9| */ + int min = 0; + int max = lmt_token_memory_state.tokens_data.top; + int skip = 0; + int tail = p; + int count = 0; if (lmt_token_state.bufmax > default_buffer_size) { /* Let's start fresh and small. */ aux_deallocate_array(lmt_token_state.buffer); @@ -3093,13 +3096,6 @@ char *tex_tokenlist_to_tstring(int pp, int inhibit_par, int *siz, int skippreamb lmt_token_state.bufmax = default_buffer_size; } lmt_token_state.bufloc = 0; - int e = escape_char_par; /*tex The serialization of the escape, normally a backlash. */ - int n = '0'; /*tex The character after |#|, so |#0| upto |#9| */ - int min = 0; - int max = lmt_token_memory_state.tokens_data.top; - int skip = 0; - int tail = p; - int count = 0; if (skippreamble) { skip = get_token_parameters(pp); } diff --git a/source/luametatex/source/utilities/auxarithmetic.h b/source/luametatex/source/utilities/auxarithmetic.h index 8daf6f29a..ac01c10ca 100644 --- a/source/luametatex/source/utilities/auxarithmetic.h +++ b/source/luametatex/source/utilities/auxarithmetic.h @@ -53,7 +53,7 @@ in some places we clip to the official maxima but not always. //define zround(r) ((r>2147483647.0) ? 2147483647 : ((r<-2147483647.0) ? -2147483647 : ((r >= 0.0) ? (int)(r + 0.5) : ((int)(r-0.5))))) //define zround(r) ((r>2147483647.0) ? 2147483647 : ((r<-2147483647.0) ? -2147483647 : (int) lround(r))) -# define scaledround(x) ((scaled) lround((double) x)) +# define scaledround(x) ((scaled) lround((double) (x))) # define longlonground llround # define clippedround(r) ((r>2147483647.0) ? 2147483647 : ((r<-2147483647.0) ? -2147483647 : (int) lround(r))) # define glueround(x) clippedround((double) (x)) diff --git a/source/luametatex/source/utilities/auxsparsearray.c b/source/luametatex/source/utilities/auxsparsearray.c index c3f2c7687..3ea8f1c46 100644 --- a/source/luametatex/source/utilities/auxsparsearray.c +++ b/source/luametatex/source/utilities/auxsparsearray.c @@ -128,21 +128,23 @@ int sa_get_item_2(const sa_tree head, int n) return (int) head->dflt.ushort_value[n%2]; } -sa_tree_item sa_get_item_4(const sa_tree head, int n) +int sa_get_item_4(const sa_tree head, int n, sa_tree_item *v) { if (head->tree) { int h = LMT_SA_H_PART(n); if (head->tree[h]) { int m = LMT_SA_M_PART(n); if (head->tree[h][m]) { - return head->tree[h][m][LMT_SA_L_PART(n)]; + *v = head->tree[h][m][LMT_SA_L_PART(n)]; + return 1; } } } - return head->dflt; + *v = head->dflt; + return 0; } -sa_tree_item sa_get_item_8(const sa_tree head, int n, sa_tree_item *v2) +int sa_get_item_8(const sa_tree head, int n, sa_tree_item *v1, sa_tree_item *v2) { if (head->tree != NULL) { int h = LMT_SA_H_PART(n); @@ -150,13 +152,15 @@ sa_tree_item sa_get_item_8(const sa_tree head, int n, sa_tree_item *v2) int m = LMT_SA_M_PART(n); if (head->tree[h][m]) { int l = 2*LMT_SA_L_PART(n); + *v1 = head->tree[h][m][l]; *v2 = head->tree[h][m][l+1]; - return head->tree[h][m][l]; + return 1; } } } + *v1 = head->dflt; *v2 = head->dflt; - return head->dflt; + return 0; } void sa_set_item_1(sa_tree head, int n, int v, int gl) diff --git a/source/luametatex/source/utilities/auxsparsearray.h b/source/luametatex/source/utilities/auxsparsearray.h index a1a902c54..91e310074 100644 --- a/source/luametatex/source/utilities/auxsparsearray.h +++ b/source/luametatex/source/utilities/auxsparsearray.h @@ -105,24 +105,24 @@ typedef struct sa_tree_head { typedef sa_tree_head *sa_tree; -extern int sa_get_item_1 (const sa_tree head, int n); -extern int sa_get_item_2 (const sa_tree head, int n); -extern sa_tree_item sa_get_item_4 (const sa_tree head, int n); -extern sa_tree_item sa_get_item_8 (const sa_tree head, int n, sa_tree_item * v2); -extern void sa_set_item_1 (sa_tree head, int n, int v, int gl); -extern void sa_set_item_2 (sa_tree head, int n, int v, int gl); -extern void sa_set_item_4 (sa_tree head, int n, sa_tree_item v, int gl); -extern void sa_set_item_8 (sa_tree head, int n, sa_tree_item v1, sa_tree_item v2, int gl); -extern sa_tree sa_new_tree (int size, int bytes, sa_tree_item dflt); -extern sa_tree sa_copy_tree (sa_tree head); -extern void sa_destroy_tree (sa_tree head); -extern void sa_dump_tree (dumpstream f, sa_tree a); -extern sa_tree sa_undump_tree (dumpstream f); -extern void sa_restore_stack (sa_tree a, int gl); -extern void sa_clear_stack (sa_tree a); - -extern void sa_set_item_n (const sa_tree head, int n, int v, int gl); -extern int sa_get_item_n (const sa_tree head, int n); +extern int sa_get_item_1 (const sa_tree head, int n); /* these return the value or dflt */ +extern int sa_get_item_2 (const sa_tree head, int n); /* these return the value or dflt */ +extern int sa_get_item_4 (const sa_tree head, int n, sa_tree_item *v); /* these return success */ +extern int sa_get_item_8 (const sa_tree head, int n, sa_tree_item *v1, sa_tree_item *v2); /* these return success */ +extern void sa_set_item_1 (sa_tree head, int n, int v, int gl); +extern void sa_set_item_2 (sa_tree head, int n, int v, int gl); +extern void sa_set_item_4 (sa_tree head, int n, sa_tree_item v, int gl); +extern void sa_set_item_8 (sa_tree head, int n, sa_tree_item v1, sa_tree_item v2, int gl); +extern sa_tree sa_new_tree (int size, int bytes, sa_tree_item dflt); +extern sa_tree sa_copy_tree (sa_tree head); +extern void sa_destroy_tree (sa_tree head); +extern void sa_dump_tree (dumpstream f, sa_tree a); +extern sa_tree sa_undump_tree (dumpstream f); +extern void sa_restore_stack (sa_tree a, int gl); +extern void sa_clear_stack (sa_tree a); + +extern void sa_set_item_n (const sa_tree head, int n, int v, int gl); +extern int sa_get_item_n (const sa_tree head, int n); inline static halfword sa_return_item_1(sa_tree head, halfword n) { diff --git a/source/luametatex/source/utilities/auxunistring.c b/source/luametatex/source/utilities/auxunistring.c index 30dc518e6..10ae6393d 100644 --- a/source/luametatex/source/utilities/auxunistring.c +++ b/source/luametatex/source/utilities/auxunistring.c @@ -58,8 +58,9 @@ unsigned char *aux_uni2str(unsigned unic) buf[2] = (unsigned char) (0x80 | (unic & 0x3f)); buf[3] = '\0'; } else if (unic < 0x110000) { + int u; unic -= 0x10000; - int u = (int) (((unic & 0xf0000) >> 16) + 1); + u = (int) (((unic & 0xf0000) >> 16) + 1); buf[0] = (unsigned char) (0xf0 | (u >> 2)); buf[1] = (unsigned char) (0x80 | ((u & 3) << 4) | ((unic & 0x0f000) >> 12)); buf[2] = (unsigned char) (0x80 | ((unic & 0x00fc0) >> 6)); @@ -92,8 +93,9 @@ char *aux_uni2string(char *utf8_text, unsigned unic) *utf8_text++ = (char) (0x80 | ((unic >> 6) & 0x3f)); *utf8_text++ = (char) (0x80 | (unic & 0x3f)); } else if (unic < 0x110000) { + unsigned u; unic -= 0x10000; - unsigned u = ((unic & 0xf0000) >> 16) + 1; + u = ((unic & 0xf0000) >> 16) + 1; *utf8_text++ = (char) (0xf0 | (u >> 2)); *utf8_text++ = (char) (0x80 | ((u & 3) << 4) | ((unic & 0x0f000) >> 12)); *utf8_text++ = (char) (0x80 | ((unic & 0x00fc0) >> 6)); |