diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-07-24 22:43:11 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-07-24 22:43:11 +0000 |
commit | 7b14b75626befe976530136bcf3158a16bd95df0 (patch) | |
tree | 9aefff9670d456ac7402074ffddb1a7f2d7b036d /Build/source/texk/web2c | |
parent | b7f40e4f685e941ac062cac36728a4cad0faab6c (diff) |
luatexdir: Sync with the upstream
git-svn-id: svn://tug.org/texlive/trunk@41755 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c')
72 files changed, 1958 insertions, 1605 deletions
diff --git a/Build/source/texk/web2c/luatexdir/dvi/dvigen.w b/Build/source/texk/web2c/luatexdir/dvi/dvigen.w index 0a3ca08ea14..d703db1a2a8 100644 --- a/Build/source/texk/web2c/luatexdir/dvi/dvigen.w +++ b/Build/source/texk/web2c/luatexdir/dvi/dvigen.w @@ -39,21 +39,6 @@ #define mode cur_list.mode_field /* current mode */ -#define mag int_par(mag_code) -#define tracing_output int_par(tracing_output_code) -#define tracing_stats int_par(tracing_stats_code) -#define tracing_online int_par(tracing_online_code) -#define page_width dimen_par(page_width_code) -#define page_height dimen_par(page_height_code) -#define page_left_offset dimen_par(page_left_offset_code) -#define page_right_offset dimen_par(page_right_offset_code) -#define page_top_offset dimen_par(page_top_offset_code) -#define page_bottom_offset dimen_par(page_bottom_offset_code) -#define h_offset dimen_par(h_offset_code) -#define v_offset dimen_par(v_offset_code) - -#define count(A) eqtb[count_base+(A)].cint - @ The most important output produced by a run of \TeX\ is the ``device independent'' (\.{DVI}) file that specifies where characters and rules are to appear on printed pages. The form of these files was designed by @@ -1136,7 +1121,7 @@ void ensure_dvi_header_written(PDF pdf) dvi_four(25400000); dvi_four(473628672); /* conversion ratio for sp */ prepare_mag(); - dvi_four(mag); /* magnification factor is frozen */ + dvi_four(mag_par); /* magnification factor is frozen */ if (output_comment) { l = (unsigned) strlen(output_comment); dvi_out(l); @@ -1146,14 +1131,14 @@ void ensure_dvi_header_written(PDF pdf) old_setting = selector; selector = new_string; tprint(" LuaTeX output "); - print_int(int_par(year_code)); + print_int(year_par); print_char('.'); - print_two(int_par(month_code)); + print_two(month_par); print_char('.'); - print_two(int_par(day_code)); + print_two(day_par); print_char(':'); - print_two(int_par(time_code) / 60); - print_two(int_par(time_code) % 60); + print_two(time_par / 60); + print_two(time_par % 60); selector = old_setting; dvi_out(cur_length); for (s = 0; s < cur_length; s++) @@ -1236,7 +1221,7 @@ void finish_dvi_file(PDF pdf, int version, int revision) dvi_four(25400000); dvi_four(473628672); /* conversion ratio for sp */ prepare_mag(); - dvi_four(mag); /* magnification factor */ + dvi_four(mag_par); /* magnification factor */ dvi_four(max_v); dvi_four(max_h); dvi_out(max_push / 256); diff --git a/Build/source/texk/web2c/luatexdir/font/dofont.w b/Build/source/texk/web2c/luatexdir/font/dofont.w index db4c2a5ebf0..b91bec10689 100644 --- a/Build/source/texk/web2c/luatexdir/font/dofont.w +++ b/Build/source/texk/web2c/luatexdir/font/dofont.w @@ -81,8 +81,8 @@ static int do_define_font(int f, const char *cnom, scaled s, int natural_dir) } else if (callback_id == 0) { res = read_tfm_info(f, cnom, s); if (res) { - set_hyphen_char(f, int_par(default_hyphen_char_code)); - set_skew_char(f, int_par(default_skew_char_code)); + set_hyphen_char(f, default_hyphen_char_par); + set_skew_char(f, default_skew_char_par); } } if (font_name(f) && strlen(font_name(f)) > 255) { @@ -120,7 +120,7 @@ int read_font_info(pointer u, char *cnom, scaled s, int natural_dir) "e.g., type `I\\font<same font id>=<substitute font name>'.", NULL }; - if (int_par(suppress_fontnotfound_error_code) == 0) { + if (suppress_fontnotfound_error_par == 0) { msg = font_error_message(u, cnom, s); tex_error(msg, help); free(msg); diff --git a/Build/source/texk/web2c/luatexdir/font/luafont.w b/Build/source/texk/web2c/luatexdir/font/luafont.w index daf20e65b7e..f3a8e52792c 100644 --- a/Build/source/texk/web2c/luatexdir/font/luafont.w +++ b/Build/source/texk/web2c/luatexdir/font/luafont.w @@ -1389,9 +1389,9 @@ int font_from_lua(lua_State * L, int f) i = FONT_SLANT_MAX; set_font_slant(f, i); - i = lua_numeric_field_by_index(L,lua_key_index(hyphenchar), int_par(default_hyphen_char_code)); + i = lua_numeric_field_by_index(L,lua_key_index(hyphenchar), default_hyphen_char_par); set_hyphen_char(f, i); - i = lua_numeric_field_by_index(L,lua_key_index(skewchar), int_par(default_skew_char_code)); + i = lua_numeric_field_by_index(L,lua_key_index(skewchar), default_skew_char_par); set_skew_char(f, i); i = n_boolean_field(L, lua_key_index(used), 0); set_font_used(f, (char) i); @@ -2126,21 +2126,20 @@ halfword handle_kerning(halfword head, halfword tail) @c static halfword run_lua_ligkern_callback(halfword head, halfword tail, int callback_id) { - lua_State *L = Luas; int i; - int top = lua_gettop(L); - if (!get_callback(L, callback_id)) { - lua_pop(L, 2); + int top = lua_gettop(Luas); + if (!get_callback(Luas, callback_id)) { + lua_pop(Luas, 2); return tail; } - nodelist_to_lua(L, head); - nodelist_to_lua(L, tail); - if ((i=lua_pcall(L, 2, 0, 0)) != 0) { - luatex_error(L, (i == LUA_ERRRUN ? 0 : 1)); + nodelist_to_lua(Luas, head); + nodelist_to_lua(Luas, tail); + if ((i=lua_pcall(Luas, 2, 0, 0)) != 0) { + luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1)); return tail; } fix_node_list(head); - lua_settop(L, top); + lua_settop(Luas, top); return tail; } diff --git a/Build/source/texk/web2c/luatexdir/font/mapfile.w b/Build/source/texk/web2c/luatexdir/font/mapfile.w index 939468af4d8..f4f31e5a833 100644 --- a/Build/source/texk/web2c/luatexdir/font/mapfile.w +++ b/Build/source/texk/web2c/luatexdir/font/mapfile.w @@ -58,7 +58,7 @@ mapitem *mitem = NULL; while (*r != ' ' && *r != '<' && *r != '"' && *r != '\0') \ *q++ = *r++; \ *q = '\0'; \ - skip (r, ' '); \ + skip_char(r, ' '); \ } while (0) #define set_field(F) do { \ @@ -367,7 +367,7 @@ static void fm_scan_line(void) } } while (1) { /* loop through "specials", encoding, font file */ - skip(r, ' '); + skip_char(r, ' '); switch (*r) { case '\0': goto done; @@ -375,7 +375,7 @@ static void fm_scan_line(void) r++; u = v = 0; do { - skip(r, ' '); + skip_char(r, ' '); if (sscanf(r, "%f %n", &d, &j) > 0) { s = r + j; /* jump behind number, eat also blanks, if any */ if (*(s - 1) == 'E' || *(s - 1) == 'e') diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.w b/Build/source/texk/web2c/luatexdir/font/texfont.w index 06926a2f5a1..e68deac84ad 100644 --- a/Build/source/texk/web2c/luatexdir/font/texfont.w +++ b/Build/source/texk/web2c/luatexdir/font/texfont.w @@ -354,22 +354,21 @@ int char_exists(internal_font_number f, int c) static int lua_char_exists_callback(internal_font_number f, int c) { int callback_id; - lua_State *L = Luas; int ret = 0; callback_id = callback_defined(char_exists_callback); if (callback_id != 0) { - if (!get_callback(L, callback_id)) { - lua_pop(L, 2); + if (!get_callback(Luas, callback_id)) { + lua_pop(Luas, 2); return 0; } - lua_pushinteger(L, f); - lua_pushinteger(L, c); - if (lua_pcall(L, 2, 1, 0) != 0) { /* two args, 1 result */ - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_pop(L, 2); + lua_pushinteger(Luas, f); + lua_pushinteger(Luas, c); + if (lua_pcall(Luas, 2, 1, 0) != 0) { /* two args, 1 result */ + fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1)); + lua_pop(Luas, 2); error(); } else { - ret = lua_toboolean(L, -1); + ret = lua_toboolean(Luas, -1); } } return ret; @@ -1798,8 +1797,6 @@ void undump_font(int f) /* moved from pdffont.w */ @ @c -#define font_id_text(A) cs_text(font_id_base+(A)) /* a frozen font identifier's name */ - int pk_dpi; /* PK pixel density value from \.{texmf.cnf} */ @ @c diff --git a/Build/source/texk/web2c/luatexdir/font/vfpacket.w b/Build/source/texk/web2c/luatexdir/font/vfpacket.w index 32b5e634672..5b76eb81f40 100644 --- a/Build/source/texk/web2c/luatexdir/font/vfpacket.w +++ b/Build/source/texk/web2c/luatexdir/font/vfpacket.w @@ -202,13 +202,13 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c, int ex_glyph) break; case packet_char_code: packet_number(k); - if (!char_exists(vp->lf, (int) k)) + /* we also check if c == k and font(c) == font)k) */ + if (!char_exists(vp->lf, (int) k)) { char_warning(vp->lf, (int) k); - else { - if (has_packet(vp->lf, (int) k)) - do_vf_packet(pdf, vp->lf, (int) k, ex_glyph); - else - backend_out[glyph_node] (pdf, vp->lf, (int) k, ex_glyph); + } else if (! ((c == k && vp->lf == vf_f)) && (has_packet(vp->lf, (int) k))) { + do_vf_packet(pdf, vp->lf, (int) k, ex_glyph); + } else { + backend_out[glyph_node] (pdf, vp->lf, (int) k, ex_glyph); } w = char_width(vp->lf, (int) k); mat_p->pos.h += round_xn_over_d(w, 1000 + ex_glyph, 1000); diff --git a/Build/source/texk/web2c/luatexdir/font/writet1.w b/Build/source/texk/web2c/luatexdir/font/writet1.w index 958adfbb0db..fc1a89cd547 100644 --- a/Build/source/texk/web2c/luatexdir/font/writet1.w +++ b/Build/source/texk/web2c/luatexdir/font/writet1.w @@ -309,13 +309,13 @@ char **load_enc_file(char *enc_name) } names_count = 0; r++; /* skip '[' */ - skip(r, ' '); + skip_char(r, ' '); for (;;) { while (*r == '/') { for (p = buf, r++; *r != ' ' && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++); *p = 0; - skip(r, ' '); + skip_char(r, ' '); if (names_count >= 256) normal_error("type 1","encoding vector contains more than 256 names"); if (strcmp(buf, notdef) != 0) @@ -444,7 +444,7 @@ static char *eol(char *s) static float t1_scan_num(char *p, char **r) { float f; - skip(p, ' '); + skip_char(p, ' '); if (sscanf(p, "%g", &f) != 1) { remove_eol(p, t1_line_array); formatted_error("type 1","a number expected: '%s'", t1_line_array); @@ -682,7 +682,7 @@ static void t1_scan_keys(PDF pdf) if (key - font_key == FONT_KEYS_NUM) return; p = t1_line_array + strlen(key->t1name) + 1; - skip(p, ' '); + skip_char(p, ' '); if ((k = (int) (key - font_key)) == FONTNAME_CODE) { if (*p != '/') { remove_eol(p, t1_line_array); @@ -787,14 +787,14 @@ static char **t1_builtin_enc(void) t1_encoding = ENC_BUILTIN; if (t1_prefix("/Encoding [") || t1_prefix("/Encoding[")) { /* the first case */ r = strchr(t1_line_array, '[') + 1; - skip(r, ' '); + skip_char(r, ' '); for (;;) { while (*r == '/') { for (p = t1_buf_array, r++; *r != 32 && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++); *p = 0; - skip(r, ' '); + skip_char(r, ' '); if (counter > 255) normal_error("type 1","encoding vector contains more than 256 names"); if (strcmp(t1_buf_array, notdef) != 0) @@ -827,7 +827,7 @@ static char **t1_builtin_enc(void) if (strcmp(t1_buf_array + 1, notdef) != 0) glyph_names[i] = xstrdup(t1_buf_array + 1); p = strstr(p, " put") + strlen(" put"); - skip(p, ' '); + skip_char(p, ' '); } /* check for \.{dup dup <to> exch <from> get put} @@ -836,7 +836,7 @@ static char **t1_builtin_enc(void) && valid_code(a) && valid_code(b)) { copy_glyph_names(glyph_names, a, b); p = strstr(p, " get put") + strlen(" get put"); - skip(p, ' '); + skip_char(p, ' '); } /* check for \.{dup dup <from> <size> getinterval <to> exch putinterval} @@ -848,7 +848,7 @@ static char **t1_builtin_enc(void) for (i = 0; i < c; i++) copy_glyph_names(glyph_names, a + i, b + i); p = strstr(p, " putinterval") + strlen(" putinterval"); - skip(p, ' '); + skip_char(p, ' '); } /* check for \.{def} or \.{readonly def} @@ -862,7 +862,7 @@ static char **t1_builtin_enc(void) else { while (*p != ' ' && *p != 10) p++; - skip(p, ' '); + skip_char(p, ' '); } } } diff --git a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w index d86504f82bc..0f3e75d002c 100644 --- a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w +++ b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w @@ -596,6 +596,10 @@ void read_pdf_info(image_dict * idict) pdf_doc = refPdfDocument(img_filepath(idict), FE_FAIL); else if (img_type(idict) == IMG_TYPE_PDFMEMSTREAM) { pdf_doc = findPdfDocument(img_filepath(idict)) ; + if (pdf_doc == NULL ) + normal_error("pdf inclusion", "memstream not initialized"); + if (pdf_doc->doc == NULL) + normal_error("pdf inclusion", "memstream document is empty"); pdf_doc->occurences++; } else { normal_error("pdf inclusion","unknown document"); diff --git a/Build/source/texk/web2c/luatexdir/image/writeimg.w b/Build/source/texk/web2c/luatexdir/image/writeimg.w index f8e035f549d..0944509c044 100644 --- a/Build/source/texk/web2c/luatexdir/image/writeimg.w +++ b/Build/source/texk/web2c/luatexdir/image/writeimg.w @@ -281,15 +281,22 @@ void read_img(image_dict * idict) callback_id = callback_defined(find_image_file_callback); if (img_filepath(idict) == NULL) { if (callback_id > 0) { + /* we always callback, also for a mem stream */ if (run_callback(callback_id, "S->S", img_filename(idict),&filepath)) { if (filepath && (strlen(filepath) > 0)) { img_filepath(idict) = strdup(filepath); } } - } else { + } + if (img_filepath(idict) == NULL && (strstr(img_filename(idict),"data:application/pdf,") != NULL)) { + /* we need to check here for a pdf memstream */ + img_filepath(idict) = strdup(img_filename(idict)); + } else if (callback_id == 0) { + /* otherwise we use kpse but only when we don't callback */ img_filepath(idict) = kpse_find_file(img_filename(idict), kpse_tex_format, true); } if (img_filepath(idict) == NULL) { + /* in any case we need a name */ formatted_error("pdf backend","cannot find image file '%s'", img_filename(idict)); } } @@ -420,8 +427,6 @@ void scan_pdfximage(PDF pdf) /* static_pdf */ } @ @c -#define tail cur_list.tail_field - void scan_pdfrefximage(PDF pdf) { int transform = 0; /* one could scan transform as well */ @@ -434,20 +439,20 @@ void scan_pdfrefximage(PDF pdf) idict = idict_array[obj_data_ptr(pdf, cur_val)]; if (img_state(idict) == DICT_NEW) { normal_warning("image","don't rely on the image data to be okay"); - width(tail) = 0; - height(tail) = 0; - depth(tail) = 0; + width(tail_par) = 0; + height(tail_par) = 0; + depth(tail_par) = 0; } else { if (alt_rule.wd != null_flag || alt_rule.ht != null_flag || alt_rule.dp != null_flag) { dim = scale_img(idict, alt_rule, transform); } else { dim = scale_img(idict, img_dimen(idict), img_transform(idict)); } - width(tail) = dim.wd; - height(tail) = dim.ht; - depth(tail) = dim.dp; - rule_transform(tail) = transform; - rule_index(tail) = img_index(idict); + width(tail_par) = dim.wd; + height(tail_par) = dim.ht; + depth(tail_par) = dim.dp; + rule_transform(tail_par) = transform; + rule_index(tail_par) = img_index(idict); } } diff --git a/Build/source/texk/web2c/luatexdir/lang/hyphen.w b/Build/source/texk/web2c/luatexdir/lang/hyphen.w index c661b6c8213..8e13896090d 100644 --- a/Build/source/texk/web2c/luatexdir/lang/hyphen.w +++ b/Build/source/texk/web2c/luatexdir/lang/hyphen.w @@ -805,10 +805,14 @@ void hnj_hyphen_hyphenate(HyphenDict * dict, here = get_vlink(here)) { int ch; - if (here == begin_point || here == end_point) + if (here == begin_point || here == end_point) { ch = '.'; - else - ch = get_lc_code(get_character(here)); + } else { + ch = get_hj_code(char_lang(here),get_character(here)); + if (ch <= 32) { + ch = get_character(here); + } + } while (state != -1) { #if 0 printf("%*s%s%c",char_num-strlen(get_state_str(state)),"",get_state_str(state),(char)ch); diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.h b/Build/source/texk/web2c/luatexdir/lang/texlang.h index 0920dc9f740..5e7a046195f 100644 --- a/Build/source/texk/web2c/luatexdir/lang/texlang.h +++ b/Build/source/texk/web2c/luatexdir/lang/texlang.h @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ - #ifndef TEXLANG_H # define TEXLANG_H @@ -46,8 +45,7 @@ struct tex_language { extern struct tex_language *new_language(int n); extern struct tex_language *get_language(int n); extern void load_patterns(struct tex_language *lang, const unsigned char *buf); -extern void load_hyphenation(struct tex_language *lang, - const unsigned char *buf); +extern void load_hyphenation(struct tex_language *lang, const unsigned char *buf); extern int hyphenate_string(struct tex_language *lang, char *w, char **ret); extern void new_hyphenation(halfword h, halfword t); diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.w b/Build/source/texk/web2c/luatexdir/lang/texlang.w index 68cb0581cd2..f89ca5d4a33 100644 --- a/Build/source/texk/web2c/luatexdir/lang/texlang.w +++ b/Build/source/texk/web2c/luatexdir/lang/texlang.w @@ -30,8 +30,6 @@ #define MAX_TEX_LANGUAGES 16384 -#define ex_hyphen_char int_par(ex_hyphen_char_code) - static struct tex_language *tex_languages[MAX_TEX_LANGUAGES] = { NULL }; static int next_lang_id = 0; @@ -61,7 +59,7 @@ struct tex_language *new_language(int n) lang->pre_exhyphen_char = 0; lang->post_exhyphen_char = 0; lang->hyphenation_min = -1; - if (int_par(saving_hyph_codes_code)) { + if (saving_hyph_codes_par) { hj_codes_from_lc_codes(l); /* for now, we might just use specific value for whatever task */ } return lang; @@ -187,7 +185,7 @@ void load_tex_patterns(int curlang, halfword head) @ @c #define STORE_CHAR(l,x) do { \ unsigned xx = get_hj_code(l,x); \ - if (!xx) { \ + if (!xx || xx <= 32) { \ xx = x; \ } \ uindex = uni2string(uindex, xx); \ @@ -212,7 +210,7 @@ const char *clean_hyphenation(int id, const char *buff, char **cleaned) s++; if ((s-buff)>MAX_WORD_LEN) { /* todo: this is too strict, should count unicode, not bytes */ - *cleaned = NULL; + *cleaned = NULL; tex_error("exception too long", NULL); return s; } @@ -224,7 +222,7 @@ const char *clean_hyphenation(int id, const char *buff, char **cleaned) /* build the new word string */ i = 0; while (uword[i]>0) { - u = uword[i++]; + u = uword[i++]; if (u == '-') { /* skip */ } else if (u == '=') { STORE_CHAR(id,'-'); @@ -276,14 +274,13 @@ void load_hyphenation(struct tex_language *lang, const unsigned char *buff) const char *value; char *cleaned; int id ; - lua_State *L = Luas; if (lang == NULL) return; if (lang->exceptions == 0) { - lua_newtable(L); - lang->exceptions = luaL_ref(L, LUA_REGISTRYINDEX); + lua_newtable(Luas); + lang->exceptions = luaL_ref(Luas, LUA_REGISTRYINDEX); } - lua_rawgeti(L, LUA_REGISTRYINDEX, lang->exceptions); + lua_rawgeti(Luas, LUA_REGISTRYINDEX, lang->exceptions); s = (const char *) buff; id = lang->id; while (*s) { @@ -294,9 +291,9 @@ void load_hyphenation(struct tex_language *lang, const unsigned char *buff) s = clean_hyphenation(id, s, &cleaned); if (cleaned != NULL) { if ((s - value) > 0) { - lua_pushstring(L, cleaned); - lua_pushlstring(L, value, (size_t) (s - value)); - lua_rawset(L, -3); + lua_pushstring(Luas, cleaned); + lua_pushlstring(Luas, value, (size_t) (s - value)); + lua_rawset(Luas, -3); } free(cleaned); } else { @@ -381,7 +378,7 @@ halfword insert_syllable_discretionary(halfword t, lang_variables * lan) { halfword g, n; n = new_node(disc_node, syllable_disc); - disc_penalty(n) = int_par(hyphen_penalty_code); + disc_penalty(n) = hyphen_penalty_par; couple_nodes(n, vlink(t)); couple_nodes(t, n); delete_attribute_ref(node_attr(n)); @@ -427,7 +424,7 @@ halfword insert_word_discretionary(halfword t, lang_variables * lan) pre = insert_character(null, lan->pre_exhyphen_char); if (lan->post_exhyphen_char > 0) pos = insert_character(null, lan->post_exhyphen_char); - return insert_discretionary(t, pre, pos, null,int_par(ex_hyphen_penalty_code)); + return insert_discretionary(t, pre, pos, null,ex_hyphen_penalty_par); } @ @c @@ -446,7 +443,7 @@ halfword insert_complex_discretionary(halfword t, lang_variables * lan, halfword replace) { (void) lan; - return insert_discretionary(t, pre, pos, replace,int_par(hyphen_penalty_code)); + return insert_discretionary(t, pre, pos, replace,hyphen_penalty_par); } halfword insert_character(halfword t, int c) @@ -477,18 +474,17 @@ void set_disc_field(halfword f, halfword t) static char *hyphenation_exception(int exceptions, char *w) { char *ret = NULL; - lua_State *L = Luas; - lua_checkstack(L, 2); - lua_rawgeti(L, LUA_REGISTRYINDEX, exceptions); - if (lua_istable(L, -1)) { /* ?? */ - lua_pushstring(L, w); /* word table */ - lua_rawget(L, -2); - if (lua_type(L, -1) == LUA_TSTRING) { - ret = xstrdup(lua_tostring(L, -1)); + lua_checkstack(Luas, 2); + lua_rawgeti(Luas, LUA_REGISTRYINDEX, exceptions); + if (lua_istable(Luas, -1)) { /* ?? */ + lua_pushstring(Luas, w); /* word table */ + lua_rawget(Luas, -2); + if (lua_type(Luas, -1) == LUA_TSTRING) { + ret = xstrdup(lua_tostring(Luas, -1)); } - lua_pop(L, 2); + lua_pop(Luas, 2); } else { - lua_pop(L, 1); + lua_pop(Luas, 1); } return ret; } @@ -500,16 +496,15 @@ char *exception_strings(struct tex_language *lang) size_t size = 0, current = 0; size_t l = 0; char *ret = NULL; - lua_State *L = Luas; if (lang->exceptions == 0) return NULL; - lua_checkstack(L, 2); - lua_rawgeti(L, LUA_REGISTRYINDEX, lang->exceptions); - if (lua_istable(L, -1)) { + lua_checkstack(Luas, 2); + lua_rawgeti(Luas, LUA_REGISTRYINDEX, lang->exceptions); + if (lua_istable(Luas, -1)) { /* iterate and join */ - lua_pushnil(L); /* first key */ - while (lua_next(L, -2) != 0) { - value = lua_tolstring(L, -1, &l); + lua_pushnil(Luas); /* first key */ + while (lua_next(Luas, -2) != 0) { + value = lua_tolstring(Luas, -1, &l); if (current + 2 + l > size) { ret = xrealloc(ret, (unsigned) ((size + size / 5) + current + l + 1024)); size = (size + size / 5) + current + l + 1024; @@ -517,7 +512,7 @@ char *exception_strings(struct tex_language *lang) *(ret + current) = ' '; strcpy(ret + current + 1, value); current += l + 1; - lua_pop(L, 1); + lua_pop(Luas, 1); } } return ret; @@ -629,7 +624,7 @@ static void do_exception(halfword wordstart, halfword r, char *replacement) try_couple_nodes(t, vlink(q)); vlink(q) = null; } - t = insert_discretionary(t, gg, hh, replace,int_par(hyphen_penalty_code)); + t = insert_discretionary(t, gg, hh, replace, hyphen_penalty_par); t = vlink(t); /* skip the new disc */ } else { t = vlink(t); @@ -699,7 +694,30 @@ hyphenated, but most european users seem to agree that prohibiting hyphenation there was not the best idea ever. @c -static halfword find_next_wordstart(halfword r, halfword first_language) +/* + More strict: \hyphenationbounds + + 0 = not strict + 1 = strict start + 2 = strict end + 3 = strict start and strict end + + \parindent0pt \hsize=1.1cm + 12-34-56 \par + 12-34-\hbox{56} \par + 12-34-\vrule width 1em height 1.5ex \par + 12-\hbox{34}-56 \par + 12-\vrule width 1em height 1.5ex-56 \par + \hjcode`\1=`\1 \hjcode`\2=`\2 \hjcode`\3=`\3 \hjcode`\4=`\4 \vskip.5cm + 12-34-56 \par + 12-34-\hbox{56} \par + 12-34-\vrule width 1em height 1.5ex \par + 12-\hbox{34}-56 \par + 12-\vrule width 1em height 1.5ex-56 \par + +*/ + +static halfword find_next_wordstart(halfword r, halfword first_language, halfword strict_bound) { register int l; register int start_ok = 1; @@ -713,7 +731,14 @@ static halfword find_next_wordstart(halfword r, halfword first_language) start_ok = 1; } break; + case hlist_node: /* new > 0.95 */ + case vlist_node: /* new > 0.95 */ + case rule_node: /* new > 0.95 */ + case dir_node: case whatsit_node: + if (strict_bound == 1 || strict_bound == 3) { + start_ok = 0; + } break; case glue_node: start_ok = 1; @@ -735,7 +760,7 @@ static halfword find_next_wordstart(halfword r, halfword first_language) case glyph_node: if (is_simple_character(r)) { chr = character(r) ; - if (chr == ex_hyphen_char) { + if (chr == ex_hyphen_char_par) { /* We only accept an explicit hyphen when there is a preceding glyph and we skip a sequence of explicit hyphens as that normally indicates a @@ -745,7 +770,7 @@ static halfword find_next_wordstart(halfword r, halfword first_language) hyphenation, ligaturing and kerning steps. A test is cmr with ------. */ t = vlink(r) ; - if ((start_ok > 0) && (t!=null) && (type(t) == glyph_node) && (character(t) != ex_hyphen_char)) { + if ((start_ok == 0) && (t!=null) && (type(t) == glyph_node) && (character(t) != ex_hyphen_char_par)) { t = compound_word_break(r, char_lang(r)); subtype(t) = automatic_disc; start_ok = 1 ; @@ -753,7 +778,7 @@ static halfword find_next_wordstart(halfword r, halfword first_language) start_ok = 0; } } else if (start_ok && (char_lang(r)>=first_language) && ((l = get_hj_code(char_lang(r),chr)) > 0)) { - if (char_uchyph(r) || l == chr) { + if (char_uchyph(r) || l == chr || l <= 32) { return r; } else { start_ok = 0; @@ -771,27 +796,35 @@ static halfword find_next_wordstart(halfword r, halfword first_language) } @ @c -static int valid_wordend(halfword s) +static int valid_wordend(halfword s, halfword strict_bound) { register halfword r = s; register int clang = char_lang(s); if (r == null) return 1; - while ((r != null) && ( (type(r) == glyph_node && is_simple_character(r) && clang == char_lang(r)) - || (type(r) == kern_node && (subtype(r) == normal)) - )) { + while ( (r != null) && + ( (type(r) == glyph_node && is_simple_character(r) && clang == char_lang(r)) + || (type(r) == kern_node && (subtype(r) == normal)) + ) + ) { r = vlink(r); } if (r == null || (type(r) == glyph_node && is_simple_character(r) && clang != char_lang(r)) || type(r) == glue_node - || type(r) == boundary_node - || type(r) == whatsit_node - || type(r) == ins_node - || type(r) == adjust_node || type(r) == penalty_node - || (type(r) == kern_node && (subtype(r) == explicit_kern || + || (type(r) == kern_node && (subtype(r) == explicit_kern || /* so why not italic correction ? */ subtype(r) == italic_kern || - subtype(r) == accent_kern ))) + subtype(r) == accent_kern )) + || ((type(r) == hlist_node || /* new > 0.95 */ + type(r) == vlist_node || /* new > 0.95 */ + type(r) == rule_node || /* new > 0.95 */ + type(r) == dir_node || /* new > 0.97 */ + type(r) == whatsit_node || + type(r) == ins_node || /* yes or no strict test */ + type(r) == adjust_node /* yes or no strict test */ + ) && ! (strict_bound == 2 || strict_bound == 3)) + || type(r) == boundary_node + ) return 1; return 0; } @@ -807,7 +840,8 @@ void hnj_hyphenation(halfword head, halfword tail) char *hy = utf8word; char *replacement = NULL; boolean explicit_hyphen = false; - halfword first_language = int_par(first_valid_language_code); + halfword first_language = first_valid_language_par; + halfword strict_bound = hyphenation_bounds_par; halfword s, r = head, wordstart = null, save_tail1 = null, left = null, right = null; /* this first movement assures two things: @@ -822,7 +856,7 @@ void hnj_hyphenation(halfword head, halfword tail) r = vlink(r); } /* this will make |r| a glyph node with subtype character */ - r = find_next_wordstart(r,first_language); + r = find_next_wordstart(r,first_language,strict_bound); if (r == null) return; @@ -853,21 +887,35 @@ void hnj_hyphenation(halfword head, halfword tail) && ( ( (clang >= first_language) && (lchar = get_hj_code(clang,character(r))) > 0 ) - || ( character(r) == ex_hyphen_char - && (lchar = ex_hyphen_char) + || ( character(r) == ex_hyphen_char_par + && (lchar = ex_hyphen_char_par) ) ) ) { - if (character(r) == ex_hyphen_char) - explicit_hyphen = true; + if (character(r) == ex_hyphen_char_par) { + explicit_hyphen = true; + } wordlen++; + if (lchar <= 32) { + if (lchar == 32) { + lchar = 0 ; + } + if (wordlen <= lhmin) { + lhmin = lhmin - lchar + 1 ; + } + if (wordlen >= rhmin) { + rhmin = rhmin - lchar + 1 ; + } + hmin = hmin - lchar + 1 ; + lchar = character(r) ; + } hy = uni2string(hy, (unsigned) lchar); /* this should not be needed any more */ /*if (vlink(r)!=null) alink(vlink(r))=r; */ end_word = r; r = vlink(r); } - if ( valid_wordend(r) + if ( valid_wordend(r,strict_bound) && clang >= first_language && wordlen >= lhmin + rhmin && (hmin <= 0 || wordlen >= hmin) @@ -884,19 +932,21 @@ void hnj_hyphenation(halfword head, halfword tail) do_exception(wordstart, r, replacement); free(replacement); } else if (explicit_hyphen == true) { - /* insert an explicit discretionary after each of the last in a - set of explicit hyphens */ + /* + insert an explicit discretionary after each of the last in a + set of explicit hyphens + */ halfword rr = r; halfword t = null; #ifdef VERBOSE formatted_warning("hyphenation","explicit hyphen(s) found in %s (c=%d)", utf8word, clang); #endif while (rr != wordstart) { - if (is_simple_character(rr)) { - if (character(rr) == ex_hyphen_char) { + if (is_simple_character(rr)) { + if (character(rr) == ex_hyphen_char_par) { t = compound_word_break(rr, clang); subtype(t) = automatic_disc; - while (character(alink(rr)) == ex_hyphen_char) + while (character(alink(rr)) == ex_hyphen_char_par) rr = alink(rr); if (rr == wordstart) break; @@ -924,12 +974,12 @@ void hnj_hyphenation(halfword head, halfword tail) (void) hnj_hyphen_hyphenate(lang->patterns, wordstart, end_word, wordlen, left, right, &langdata); } } - explicit_hyphen = false; + explicit_hyphen = false; wordlen = 0; hy = utf8word; if (r == null) break; - r = find_next_wordstart(r,first_language); + r = find_next_wordstart(r,first_language,strict_bound); } flush_node(vlink(tail)); vlink(tail) = save_tail1; @@ -944,20 +994,19 @@ void new_hyphenation(halfword head, halfword tail) fix_node_list(head); callback_id = callback_defined(hyphenate_callback); if (callback_id > 0) { - lua_State *L = Luas; - if (!get_callback(L, callback_id)) { - lua_pop(L, 2); + if (!get_callback(Luas, callback_id)) { + lua_pop(Luas, 2); return; } - nodelist_to_lua(L, head); - nodelist_to_lua(L, tail); - if (lua_pcall(L, 2, 0, 0) != 0) { - formatted_warning("hyphenation","bad specification: %s",lua_tostring(L, -1)); - lua_pop(L, 2); - lua_error(L); + nodelist_to_lua(Luas, head); + nodelist_to_lua(Luas, tail); + if (lua_pcall(Luas, 2, 0, 0) != 0) { + formatted_warning("hyphenation","bad specification: %s",lua_tostring(Luas, -1)); + lua_pop(Luas, 2); + lua_error(Luas); return; } - lua_pop(L, 1); + lua_pop(Luas, 1); } else if (callback_id == 0) { hnj_hyphenation(head, tail); } @@ -1072,7 +1121,7 @@ void undump_language_data(void) void new_hyph_exceptions(void) { /* enters new exceptions */ (void) scan_toks(false, true); - load_tex_hyphenation(int_par(language_code), def_ref); + load_tex_hyphenation(language_par, def_ref); flush_list(def_ref); } @@ -1083,7 +1132,7 @@ procedure named |new_patterns|. void new_patterns(void) { /* initializes the hyphenation pattern data */ (void) scan_toks(false, true); - load_tex_patterns(int_par(language_code), def_ref); + load_tex_patterns(language_par, def_ref); flush_list(def_ref); } @@ -1096,14 +1145,14 @@ void new_pre_hyphen_char(void) { scan_optional_equals(); scan_int(); - set_pre_hyphen_char(int_par(language_code), cur_val); + set_pre_hyphen_char(language_par, cur_val); } void new_post_hyphen_char(void) { scan_optional_equals(); scan_int(); - set_post_hyphen_char(int_par(language_code), cur_val); + set_post_hyphen_char(language_par, cur_val); } @ `\.{\\preexhyphenchar}', sets the |pre_break| character, and @@ -1115,21 +1164,21 @@ void new_pre_exhyphen_char(void) { scan_optional_equals(); scan_int(); - set_pre_exhyphen_char(int_par(language_code), cur_val); + set_pre_exhyphen_char(language_par, cur_val); } void new_post_exhyphen_char(void) { scan_optional_equals(); scan_int(); - set_post_exhyphen_char(int_par(language_code), cur_val); + set_post_exhyphen_char(language_par, cur_val); } void new_hyphenation_min(void) { scan_optional_equals(); scan_int(); - set_hyphenation_min(int_par(language_code), cur_val); + set_hyphenation_min(language_par, cur_val); } void new_hj_code(void) @@ -1139,5 +1188,5 @@ void new_hj_code(void) i = cur_val; scan_optional_equals(); scan_int(); - set_hj_code(int_par(language_code), i, cur_val, -1); + set_hj_code(language_par, i, cur_val, -1); } diff --git a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c index 778fbf18876..5ceb7998d1d 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c @@ -196,20 +196,19 @@ int run_saved_callback(int r, const char *name, const char *values, ...) { va_list args; int ret = 0; - lua_State *L = Luas; - int stacktop = lua_gettop(L); + int stacktop = lua_gettop(Luas); va_start(args, values); - luaL_checkstack(L, 2, "out of stack space"); - lua_rawgeti(L, LUA_REGISTRYINDEX, r); - lua_pushstring(L, name); - lua_rawget(L, -2); - if (lua_isfunction(L, -1)) { + luaL_checkstack(Luas, 2, "out of stack space"); + lua_rawgeti(Luas, LUA_REGISTRYINDEX, r); + lua_pushstring(Luas, name); + lua_rawget(Luas, -2); + if (lua_isfunction(Luas, -1)) { saved_callback_count++; callback_count++; ret = do_run_callback(2, values, args); } va_end(args); - lua_settop(L, stacktop); + lua_settop(Luas, stacktop); return ret; } @@ -230,17 +229,16 @@ int run_and_save_callback(int i, const char *values, ...) { va_list args; int ret = 0; - lua_State *L = Luas; - int stacktop = lua_gettop(L); + int stacktop = lua_gettop(Luas); va_start(args, values); - if (get_callback(L, i)) { + if (get_callback(Luas, i)) { ret = do_run_callback(1, values, args); } va_end(args); if (ret > 0) { - ret = luaL_ref(L, LUA_REGISTRYINDEX); + ret = luaL_ref(Luas, LUA_REGISTRYINDEX); } - lua_settop(L, stacktop); + lua_settop(Luas, stacktop); return ret; } @@ -248,14 +246,13 @@ int run_callback(int i, const char *values, ...) { va_list args; int ret = 0; - lua_State *L = Luas; - int stacktop = lua_gettop(L); + int stacktop = lua_gettop(Luas); va_start(args, values); - if (get_callback(L, i)) { + if (get_callback(Luas, i)) { ret = do_run_callback(0, values, args); } va_end(args); - lua_settop(L, stacktop); + lua_settop(Luas, stacktop); return ret; } @@ -270,46 +267,45 @@ int do_run_callback(int special, const char *values, va_list vl) int *bufloc; char *ss = NULL; int retval = 0; - lua_State *L = Luas; if (special == 2) { /* copy the enclosing table */ - luaL_checkstack(L, 1, "out of stack space"); - lua_pushvalue(L, -2); + luaL_checkstack(Luas, 1, "out of stack space"); + lua_pushvalue(Luas, -2); } ss = strchr(values, '>'); - luaL_checkstack(L, (int) (ss - values + 1), "out of stack space"); + luaL_checkstack(Luas, (int) (ss - values + 1), "out of stack space"); ss = NULL; for (narg = 0; *values; narg++) { switch (*values++) { case CALLBACK_CHARNUM: /* an ascii char! */ cs = (char) va_arg(vl, int); - lua_pushlstring(L, &cs, 1); + lua_pushlstring(Luas, &cs, 1); break; case CALLBACK_STRING: /* C string */ s = va_arg(vl, char *); - lua_pushstring(L, s); + lua_pushstring(Luas, s); break; case CALLBACK_LSTRING: /* 'lstring' */ lstr = va_arg(vl, lstring *); - lua_pushlstring(L, (const char *)lstr->s, lstr->l); + lua_pushlstring(Luas, (const char *)lstr->s, lstr->l); break; case CALLBACK_INTEGER: /* int */ - lua_pushinteger(L, va_arg(vl, int)); + lua_pushinteger(Luas, va_arg(vl, int)); break; case CALLBACK_STRNUMBER: /* TeX string */ s = makeclstring(va_arg(vl, int), &len); - lua_pushlstring(L, s, len); + lua_pushlstring(Luas, s, len); break; case CALLBACK_BOOLEAN: /* boolean */ - lua_pushboolean(L, va_arg(vl, int)); + lua_pushboolean(Luas, va_arg(vl, int)); break; case CALLBACK_LINE: /* a buffer section, with implied start */ - lua_pushlstring(L, (char *) (buffer + first), (size_t) va_arg(vl, int)); + lua_pushlstring(Luas, (char *) (buffer + first), (size_t) va_arg(vl, int)); break; case CALLBACK_NODE: - lua_nodelib_push_fast(L,va_arg(vl, int)); + lua_nodelib_push_fast(Luas, va_arg(vl, int)); break; case CALLBACK_DIR: - lua_push_dir_par(L,va_arg(vl, int)); + lua_push_dir_par(Luas, va_arg(vl, int)); break; case '-': narg--; @@ -331,7 +327,7 @@ int do_run_callback(int special, const char *values, va_list vl) { int i; lua_active++; - i = lua_pcall(L, narg, nres, 0); + i = lua_pcall(Luas, narg, nres, 0); lua_active--; /* lua_remove(L, base); *//* remove traceback function */ if (i != 0) { @@ -339,11 +335,11 @@ int do_run_callback(int special, const char *values, va_list vl) * TeX initialization is complete */ if (!log_opened_global) { - fprintf(stderr, "error in callback: %s\n", lua_tostring(L, -1)); + fprintf(stderr, "error in callback: %s\n", lua_tostring(Luas, -1)); error(); } else { - lua_gc(L, LUA_GCCOLLECT, 0); - luatex_error(L, (i == LUA_ERRRUN ? 0 : 1)); + lua_gc(Luas, LUA_GCCOLLECT, 0); + luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1)); } return 0; } @@ -355,25 +351,25 @@ int do_run_callback(int special, const char *values, va_list vl) while (*values) { int b, t; halfword p; - t = lua_type(L, nres); + t = lua_type(Luas, nres); switch (*values++) { case CALLBACK_BOOLEAN: if (t == LUA_TNIL) { b = 0; } else if (t != LUA_TBOOLEAN) { - fprintf(stderr, "callback should return a boolean, not: %s\n", lua_typename(L, t)); + fprintf(stderr, "callback should return a boolean, not: %s\n", lua_typename(Luas, t)); goto EXIT; } else { - b = lua_toboolean(L, nres); + b = lua_toboolean(Luas, nres); } *va_arg(vl, boolean *) = (boolean) b; break; case CALLBACK_INTEGER: if (t != LUA_TNUMBER) { - fprintf(stderr, "callback should return a number, not: %s\n", lua_typename(L, t)); + fprintf(stderr, "callback should return a number, not: %s\n", lua_typename(Luas, t)); goto EXIT; } - b = lua_tointeger(L, nres); + b = lua_tointeger(Luas, nres); *va_arg(vl, int *) = b; break; case CALLBACK_LINE: /* TeX line ... happens frequently when we have a plug-in */ @@ -381,7 +377,7 @@ int do_run_callback(int special, const char *values, va_list vl) bufloc = 0; goto EXIT; } else if (t == LUA_TSTRING) { - s = lua_tolstring(L, nres, &len); + s = lua_tolstring(Luas, nres, &len); if (s == NULL) { /* |len| can be zero */ bufloc = 0; } else if (len == 0) { @@ -397,16 +393,16 @@ int do_run_callback(int special, const char *values, va_list vl) (*bufloc)--; } } else { - fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t)); + fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t)); goto EXIT; } break; case CALLBACK_STRNUMBER: /* TeX string */ if (t != LUA_TSTRING) { - fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t)); + fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t)); goto EXIT; } - s = lua_tolstring(L, nres, &len); + s = lua_tolstring(Luas, nres, &len); if (s == NULL) /* |len| can be zero */ *va_arg(vl, int *) = 0; else { @@ -415,10 +411,10 @@ int do_run_callback(int special, const char *values, va_list vl) break; case CALLBACK_STRING: /* C string aka buffer */ if (t != LUA_TSTRING) { - fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t)); + fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t)); goto EXIT; } - s = lua_tolstring(L, nres, &len); + s = lua_tolstring(Luas, nres, &len); if (s == NULL) /* |len| can be zero */ *va_arg(vl, int *) = 0; else { @@ -431,18 +427,18 @@ int do_run_callback(int special, const char *values, va_list vl) if (t == LUA_TNIL) { *va_arg(vl, int *) = 0; } else if (t == LUA_TBOOLEAN) { - b = lua_toboolean(L, nres); + b = lua_toboolean(Luas, nres); if (b == 0) { *va_arg(vl, int *) = 0; } else { - fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(L, t)); + fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(Luas, t)); goto EXIT; } } else if (t != LUA_TSTRING) { - fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(L, t)); + fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(Luas, t)); goto EXIT; } else { - s = lua_tolstring(L, nres, &len); + s = lua_tolstring(Luas, nres, &len); if (s == NULL) /* |len| can be zero */ *va_arg(vl, int *) = 0; else { @@ -454,10 +450,10 @@ int do_run_callback(int special, const char *values, va_list vl) break; case CALLBACK_LSTRING: /* lstring */ if (t != LUA_TSTRING) { - fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t)); + fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t)); goto EXIT; } - s = lua_tolstring(L, nres, &len); + s = lua_tolstring(Luas, nres, &len); if (s == NULL) /* |len| can be zero */ *va_arg(vl, int *) = 0; else { @@ -472,7 +468,7 @@ int do_run_callback(int special, const char *values, va_list vl) if (t == LUA_TNIL) { p = null; } else { - p = *check_isnode(L,nres); + p = *check_isnode(Luas,nres); } *va_arg(vl, int *) = p; break; diff --git a/Build/source/texk/web2c/luatexdir/lua/limglib.c b/Build/source/texk/web2c/luatexdir/lua/limglib.c index 44f1d72bff0..eb9e4145a37 100644 --- a/Build/source/texk/web2c/luatexdir/lua/limglib.c +++ b/Build/source/texk/web2c/luatexdir/lua/limglib.c @@ -298,17 +298,16 @@ void vf_out_image(PDF pdf, unsigned i) { image *a, **aa; image_dict *ad; - lua_State *L = Luas; - lua_rawgeti(L, LUA_REGISTRYINDEX, (int) i); - aa = (image **) luaL_checkudata(L, -1, TYPE_IMG); + lua_rawgeti(Luas, LUA_REGISTRYINDEX, (int) i); + aa = (image **) luaL_checkudata(Luas, -1, TYPE_IMG); a = *aa; ad = img_dict(a); if (ad == NULL) { - luaL_error(L, "invalid image dictionary"); + luaL_error(Luas, "invalid image dictionary"); } setup_image(pdf, a, WR_VF_IMG); place_img(pdf, ad, img_dimen(a), img_transform(a)); - lua_pop(L, 1); + lua_pop(Luas, 1); } /* metamethods for image */ diff --git a/Build/source/texk/web2c/luatexdir/lua/llanglib.c b/Build/source/texk/web2c/luatexdir/lua/llanglib.c index 3356e734189..27f3c84d25e 100644 --- a/Build/source/texk/web2c/luatexdir/lua/llanglib.c +++ b/Build/source/texk/web2c/luatexdir/lua/llanglib.c @@ -227,7 +227,7 @@ static int do_lang_clean(lua_State * L) { char *cleaned; if (lua_type(L, 1) == LUA_TSTRING) { - (void) clean_hyphenation(int_par(cur_lang_code), lua_tostring(L, 1), &cleaned); + (void) clean_hyphenation(cur_lang_par, lua_tostring(L, 1), &cleaned); } else { struct tex_language **lang_ptr; lang_ptr = check_islang(L, 1); diff --git a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c index 561fef65e66..373f2d98382 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c @@ -63,7 +63,7 @@ typedef struct saved_tex_scanner { static lua_token *check_istoken(lua_State * L, int ud); -#define TOKEN_METATABLE "luatex_token" +#define TOKEN_METATABLE "luatex.token" #define DEBUG 0 #define DEBUG_OUT stdout @@ -534,7 +534,7 @@ static int run_build(lua_State * L) if (lua_type(L, 1) == LUA_TNUMBER) { int cs = 0; int chr = (int) lua_tointeger(L, 1); - int cmd = (int) luaL_optinteger(L, 2, get_cat_code(int_par(cat_code_table_code),chr)); + int cmd = (int) luaL_optinteger(L, 2, get_cat_code(cat_code_table_par,chr)); if (cmd == 0 || cmd == 9 || cmd == 14 || cmd == 15) { formatted_warning("token lib","not a good token, catcode %i can not be returned, so 12 will be used",(int) cmd); cmd = 12; @@ -821,7 +821,7 @@ static int set_macro(lua_State * L) if (n > 3) s = lua_tostring(L, 4); } else { - ct = int_par(cat_code_table_code) ; + ct = cat_code_table_par; name = lua_tolstring(L, 1, &lname); if (n > 1) str = lua_tolstring(L, 2, &lstr); diff --git a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c index 7ff2eb7c3bd..c4706e43331 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -170,7 +170,6 @@ while (vlink(t)!=current && t != null) { \ t = vlink(t); \ } -#define box(A) eqtb[box_base+(A)].hh.rh #define direct_check_index_range(j,s) \ if (j<0 || j > 65535) { \ luaL_error(L, "incorrect index value %d for tex.%s()", (int)j, s); \ @@ -2180,8 +2179,7 @@ static int lua_nodelib_direct_has_attribute(lua_State * L) static int lua_nodelib_get_attribute(lua_State * L) { - halfword p; - p = *check_isnode(L, 1); + halfword p = *check_isnode(L, 1); if (nodetype_has_attributes(type(p))) { p = node_attr(p); if (p != null) { @@ -2209,6 +2207,43 @@ static int lua_nodelib_get_attribute(lua_State * L) return 1; } +static int lua_nodelib_find_attribute(lua_State * L) /* returns attr value and node */ +{ + halfword c = *check_isnode(L, 1); + halfword p ; + int i = lua_tointeger(L, 2); + while (c != null) { + if (nodetype_has_attributes(type(c))) { + p = node_attr(c); + if (p != null) { + p = vlink(p); + while (p != null) { + if (attribute_id(p) == i) { + int ret = attribute_value(p); + if (ret == UNUSED_ATTRIBUTE) { + break; + } else { + lua_pushinteger(L,ret); + lua_nodelib_push_fast(L, p); + return 2; + } + } else if (attribute_id(p) > i) { + break; + } + p = vlink(p); + } + } + } + c = vlink(c); + } + /* + lua_pushnil(L); + lua_pushnil(L); + return 2; + */ + return 0; +} + /* node.direct.get_attribute */ static int lua_nodelib_direct_get_attribute(lua_State * L) @@ -2241,6 +2276,43 @@ static int lua_nodelib_direct_get_attribute(lua_State * L) return 1; } +static int lua_nodelib_direct_find_attribute(lua_State * L) /* returns attr value and node */ +{ + halfword c = lua_tointeger(L, 1); + halfword p ; + int i = lua_tointeger(L, 2); + while (c != null) { + if (nodetype_has_attributes(type(c))) { + p = node_attr(c); + if (p != null) { + p = vlink(p); + while (p != null) { + if (attribute_id(p) == i) { + int ret = attribute_value(p); + if (ret == UNUSED_ATTRIBUTE) { + break; + } else { + lua_pushinteger(L,ret); + lua_pushinteger(L,p); + return 2; + } + } else if (attribute_id(p) > i) { + break; + } + p = vlink(p); + } + } + } + c = vlink(c); + } + /* + lua_pushnil(L); + lua_pushnil(L); + return 2; + */ + return 0; +} + /* node.set_attribute */ static int lua_nodelib_set_attribute(lua_State * L) @@ -2392,7 +2464,7 @@ static int lua_nodelib_is_zero_glue(lua_State * L) { halfword n = *check_isnode(L, 1); if ((n != null) && (type(n) == glue_node || type(n) == glue_spec_node)) { - lua_toboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0)); + lua_pushboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0)); return 1; } else { return luaL_error(L, "glue (spec) expected"); @@ -2403,7 +2475,7 @@ static int lua_nodelib_direct_is_zero_glue(lua_State * L) { halfword n = lua_tointeger(L, 1); if ((n != null) && (type(n) == glue_node || type(n) == glue_spec_node)) { - lua_toboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0)); + lua_pushboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0)); return 1; } else { return luaL_error(L, "glue (spec) expected"); @@ -3291,7 +3363,7 @@ static int lua_nodelib_fast_getfield(lua_State * L) lua_pushinteger(L, height(n)); } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) { /* already mapped */ fast_metatable_or_nil_alink(ins_ptr(n)); - /* glue parameters */ + /* glue parameters */ } else if (lua_key_eq(s, width)) { lua_pushinteger(L, width(n)); } else if (lua_key_eq(s, stretch)) { @@ -3310,7 +3382,7 @@ static int lua_nodelib_fast_getfield(lua_State * L) lua_pushinteger(L, subtype(n)); } else if (lua_key_eq(s, surround)) { lua_pushinteger(L, surround(n)); - /* glue parameters */ + /* glue parameters */ } else if (lua_key_eq(s, width)) { lua_pushinteger(L, width(n)); } else if (lua_key_eq(s, stretch)) { @@ -4000,7 +4072,7 @@ static int lua_nodelib_direct_getfield(lua_State * L) lua_pushinteger(L, height(n)); } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) { nodelib_pushdirect_or_nil_alink(ins_ptr(n)); - /* glue */ + /* glue */ } else if (lua_key_eq(s, width)) { lua_pushinteger(L, width(n)); } else if (lua_key_eq(s, stretch)) { @@ -6495,12 +6567,12 @@ static int lua_nodelib_direct_setbox(lua_State * L) } } - save_global_defs = int_par(global_defs_code); + save_global_defs = global_defs_par; if (isglobal) { - int_par(global_defs_code) = 1; + global_defs_par = 1; } err = set_tex_box_register(k, j); - int_par(global_defs_code) = save_global_defs; + global_defs_par = save_global_defs; if (err) { luaL_error(L, "incorrect value"); } @@ -6787,6 +6859,7 @@ static const struct luaL_Reg direct_nodelib_f[] = { {"has_glyph", lua_nodelib_direct_has_glyph}, {"has_attribute", lua_nodelib_direct_has_attribute}, {"get_attribute", lua_nodelib_direct_get_attribute}, + {"find_attribute", lua_nodelib_direct_find_attribute}, {"has_field", lua_nodelib_direct_has_field}, {"is_char", lua_nodelib_direct_is_char}, {"is_glyph", lua_nodelib_direct_is_glyph}, @@ -6881,6 +6954,7 @@ static const struct luaL_Reg nodelib_f[] = { {"has_glyph", lua_nodelib_has_glyph}, {"has_attribute", lua_nodelib_has_attribute}, {"get_attribute", lua_nodelib_get_attribute}, + {"find_attribute", lua_nodelib_find_attribute}, {"has_field", lua_nodelib_has_field}, {"is_char", lua_nodelib_is_char}, {"is_glyph", lua_nodelib_is_glyph}, diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c index 2161d791108..de82be7479e 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c @@ -950,6 +950,20 @@ static int getpdforigin(lua_State * L) return 2 ; } +static int setpdfimageresolution(lua_State * L) +{ + if (lua_type(L, 1) == LUA_TNUMBER) { + set_tex_extension_count_register(c_pdf_image_resolution,lua_tointeger(L, 1)); + } + return 0; +} + +static int getpdfimageresolution(lua_State * L) +{ + lua_pushinteger(L,get_tex_extension_count_register(c_pdf_image_resolution)); + return 1 ; +} + static int setpdfthreadmargin(lua_State * L) { if (lua_type(L, 1) == LUA_TNUMBER) { set_tex_extension_dimen_register(d_pdf_thread_margin,lua_tointeger(L, 1)); @@ -1065,6 +1079,24 @@ static int newpdfcolorstack(lua_State * L) return 1 ; } + +static int l_set_font_attributes(lua_State * L) +{ + int f = luaL_checkinteger(L, -2); + int i ; + /*char *s;*/ + const char *st; + if ((lua_type(L,-1) == LUA_TSTRING) && (st = lua_tostring(L, -1)) != NULL) { + /* is this dup needed? */ + /*s = xstrdup(st);*/ + i = maketexstring(st); /* brrr */ + set_pdf_font_attr(f, i); + /*free(s);*/ + } + return 0; +} + + static const struct luaL_Reg pdflib[] = { { "gethpos", l_gethpos }, { "getvpos", l_getvpos }, @@ -1081,6 +1113,7 @@ static const struct luaL_Reg pdflib[] = { { "objtype", l_objtype }, { "getmatrix", l_getmatrix }, { "hasmatrix", l_hasmatrix }, + { "setfontattributes", l_set_font_attributes }, { "setcatalog", l_set_catalog }, { "setinfo", l_set_info }, { "setnames", l_set_names }, @@ -1126,6 +1159,8 @@ static const struct luaL_Reg pdflib[] = { { "newcolorstack", newpdfcolorstack }, { "setorigin", setpdforigin }, { "getorigin", getpdforigin }, + { "setimageresolution", setpdfimageresolution }, + { "getimageresolution", getpdfimageresolution }, { "setthreadmargin", setpdfthreadmargin }, { "setdestmargin", setpdfdestmargin }, { "setlinkmargin", setpdflinkmargin }, diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc b/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc index cc311daebee..9ad50c99aeb 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc +++ b/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc @@ -105,17 +105,17 @@ static void clear_operand_stack (scannerdata *self, int from); static Token *_parseToken (scannerdata *self, int c); static void push_token (lua_State *L, scannerdata *self); -void *xmalloc (size_t size) +static void *priv_xmalloc (size_t size) { void *new_mem = (void *)malloc(size); if (new_mem == NULL) { - fprintf(stderr, "fatal: memory exhausted (xmalloc of %lu bytes).\n", (unsigned long)size); + fprintf(stderr, "fatal: memory exhausted (priv_xmalloc of %lu bytes).\n", (unsigned long)size); exit(1); } return new_mem; } -void *xrealloc (void *old_ptr, size_t size) +static void *priv_xrealloc (void *old_ptr, size_t size) { void *new_mem = (void *)realloc(old_ptr, size); if (new_mem == NULL) { @@ -125,12 +125,12 @@ void *xrealloc (void *old_ptr, size_t size) return new_mem; } -#define xreallocarray(ptr,type,size) ((type*)xrealloc(ptr,(size+1)*sizeof(type))) +#define xreallocarray(ptr,type,size) ((type*)priv_xrealloc(ptr,(size+1)*sizeof(type))) #define INITBUFSIZE 64 #define define_buffer(a) \ - char *a = (char *)xmalloc (INITBUFSIZE); \ + char *a = (char *)priv_xmalloc (INITBUFSIZE); \ int a##_size = INITBUFSIZE; \ int a##index = 0; \ memset (a,0,INITBUFSIZE) @@ -194,7 +194,7 @@ static void push_operand (scannerdata *self, Token *token) static Token * new_operand (pdf_token_type c) { - Token *token = (Token *)xmalloc(sizeof(Token)); + Token *token = (Token *)priv_xmalloc(sizeof(Token)); memset (token, 0, sizeof(Token)); token->type = c; return token; @@ -586,7 +586,7 @@ static int scanner_scan(lua_State * L) luaL_checktype(L, 3, LUA_TTABLE); self = scanner_push(L); memset(self,0,sizeof(scannerdata)); - self->_operandstack = (Token **)xmalloc (MAXOPERANDS * sizeof (Token)); + self->_operandstack = (Token **)priv_xmalloc (MAXOPERANDS * sizeof (Token)); memset (self->_operandstack,0,(MAXOPERANDS * sizeof (Token))); // 4 = self if (lua_type(L,1)== LUA_TTABLE) { @@ -598,7 +598,7 @@ static int scanner_scan(lua_State * L) uin = (udstruct *) luaL_checkudata(L, -1, M_Object); if (((Object *) uin->d)->isStream()) { ObjectList *rover = self->_streams; - ObjectList *item = (ObjectList *)xmalloc (sizeof(ObjectList)); + ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList)); item->stream = ((Object *) uin->d); item->next = NULL; if (!rover) { @@ -637,7 +637,7 @@ static int scanner_scan(lua_State * L) arrayref->get(i, val); if (val->isStream()) { ObjectList *rover = self->_streams; - ObjectList *item = (ObjectList *)xmalloc (sizeof(ObjectList)); + ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList)); item->stream = val; item->next = NULL; if (!rover) { diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c index aa0e8c7e4b2..0966176b1e2 100644 --- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c @@ -24,14 +24,6 @@ setter no prev link is created so we can presume that it's not used later on. */ #include "ptexlib.h" #include "lua/luatex-api.h" -#define attribute(A) eqtb[attribute_base+(A)].hh.rh -#define dimen(A) eqtb[scaled_base+(A)].hh.rh -#undef skip -#define skip(A) eqtb[skip_base+(A)].hh.rh -#define mu_skip(A) eqtb[mu_skip_base+(A)].hh.rh -#define count(A) eqtb[count_base+(A)].hh.rh -#define box(A) equiv(box_base+(A)) - /* tex random generators */ extern int unif_rand(int ); extern int norm_rand(void ); @@ -541,7 +533,7 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret) v = (x_height(get_cur_font())); } else if (strncmp(s, "px", 2) == 0) { s += 2; - v = dimen_par(px_dimen_code); + v = px_dimen_par; } else { goto NOT_FOUND; } @@ -560,11 +552,11 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret) if (strncmp(s, "true", 4) == 0) { /* Adjust (f)for the magnification ratio */ s += 4; - if (output_mode_used == OMODE_DVI) { + if (output_mode_used <= OMODE_DVI) { prepare_mag(); - if (int_par(mag_code) != 1000) { - cur_val = xn_over_d(cur_val, 1000, int_par(mag_code)); - f = (1000 * f + 0200000 * tex_remainder) / int_par(mag_code); + if (mag_par != 1000) { + cur_val = xn_over_d(cur_val, 1000, mag_par); + f = (1000 * f + 0200000 * tex_remainder) / mag_par; cur_val = cur_val + (f / 0200000); f = f % 0200000; } @@ -749,9 +741,9 @@ static int get_item_index(lua_State * L, int i, int base) size_t len; \ const char *str; \ int key, err, cs; \ - int save_global_defs = int_par(global_defs_code); \ + int save_global_defs = global_defs_par; \ if (is_global) { \ - int_par(global_defs_code) = 1; \ + global_defs_par = 1; \ } \ switch (lua_type(L, where)) { \ case LUA_TSTRING: \ @@ -779,7 +771,7 @@ static int get_item_index(lua_State * L, int i, int base) } \ break; \ case LUA_TNUMBER: \ - key = luaL_checkinteger(L, where); \ + key = luaL_checkinteger(L, where); \ if (key>=0 && key <= 65535) { \ err = set_register(key, value); \ if (err) { \ @@ -792,7 +784,7 @@ static int get_item_index(lua_State * L, int i, int base) default: \ luaL_error(L, "argument of 'set%s' must be a string or a number", what); \ } \ - int_par(global_defs_code) = save_global_defs; \ + global_defs_par = save_global_defs; \ } static int gettex(lua_State * L); @@ -1088,7 +1080,7 @@ static int settoks(lua_State * L) char *s; const char *ss; int is_global = 0; - int save_global_defs = int_par(global_defs_code); + int save_global_defs = global_defs_par; int n = lua_gettop(L); if (n == 3 && (lua_type(L,1) == LUA_TSTRING)) { const char *s = lua_tostring(L, 1); @@ -1096,7 +1088,7 @@ static int settoks(lua_State * L) is_global = 1; } if (is_global) - int_par(global_defs_code) = 1; + global_defs_par = 1; i = lua_gettop(L); if (lua_type(L,i) != LUA_TSTRING) { luaL_error(L, "unsupported value type"); @@ -1109,7 +1101,7 @@ static int settoks(lua_State * L) check_index_range(k, "settoks"); err = set_tex_toks_register(k, str); xfree(str.s); - int_par(global_defs_code) = save_global_defs; + global_defs_par = save_global_defs; if (err) { luaL_error(L, "incorrect value"); } @@ -1123,7 +1115,7 @@ static int scantoks(lua_State * L) char *s; const char *ss; int is_global = 0; - int save_global_defs = int_par(global_defs_code); + int save_global_defs = global_defs_par; int n = lua_gettop(L); if (n == 4 && (lua_type(L,1) == LUA_TSTRING)) { const char *s = lua_tostring(L, 1); @@ -1132,7 +1124,7 @@ static int scantoks(lua_State * L) } /* action : vsettokscct(L, is_global); */ if (is_global) - int_par(global_defs_code) = 1; + global_defs_par = 1; i = lua_gettop(L); if (lua_type(L,i) != LUA_TSTRING) { luaL_error(L, "unsupported value type"); @@ -1146,7 +1138,7 @@ static int scantoks(lua_State * L) check_index_range(k, "settoks"); err = scan_tex_toks_register(k, c, str); xfree(str.s); - int_par(global_defs_code) = save_global_defs; + global_defs_par = save_global_defs; if (err) { luaL_error(L, "incorrect value"); } @@ -1243,9 +1235,9 @@ static int isbox(lua_State * L) static int vsetbox(lua_State * L, int is_global) { int j, k, err; - int save_global_defs = int_par(global_defs_code); + int save_global_defs = global_defs_par; if (is_global) - int_par(global_defs_code) = 1; + global_defs_par = 1; k = get_box_id(L, -2, true); check_index_range(k, "setbox"); if (lua_isboolean(L, -1)) { @@ -1263,7 +1255,7 @@ static int vsetbox(lua_State * L, int is_global) } err = set_tex_box_register(k, j); - int_par(global_defs_code) = save_global_defs; + global_defs_par = save_global_defs; if (err) { luaL_error(L, "incorrect value"); } @@ -1361,7 +1353,7 @@ static int setcatcode(lua_State * L) int ch; halfword val; int level = cur_level; - int cattable = int_par(cat_code_table_code); + int cattable = cat_code_table_par; int n = lua_gettop(L); int f = 1; if (n>1 && lua_type(L,1) == LUA_TTABLE) @@ -1386,7 +1378,7 @@ static int setcatcode(lua_State * L) static int getcatcode(lua_State * L) { - int cattable = int_par(cat_code_table_code); + int cattable = cat_code_table_par; int ch = luaL_checkinteger(L, -1); if (lua_gettop(L)>=2 && lua_type(L,-2)==LUA_TNUMBER) { cattable = luaL_checkinteger(L, -2); @@ -1860,7 +1852,7 @@ static int getromannumeral(lua_State * L) static int get_parshape(lua_State * L) { - halfword par_shape_ptr = equiv(par_shape_loc); + halfword par_shape_ptr = par_shape_par_ptr; if (par_shape_ptr != 0) { int m = 1; int n = vinfo(par_shape_ptr + 1); @@ -2591,27 +2583,27 @@ static int tex_run_linebreak(lua_State * L) } lua_pop(L, 1); - get_int_par (pretolerance, int_par(pretolerance_code)); - get_int_par (tracingparagraphs, int_par(tracing_paragraphs_code)); - get_int_par (tolerance, int_par(tolerance_code)); - get_int_par (looseness, int_par(looseness_code)); - get_int_par (adjustspacing, int_par(adjust_spacing_code)); - get_int_par (adjdemerits, int_par(adj_demerits_code)); - get_int_par (protrudechars, int_par(protrude_chars_code)); - get_int_par (linepenalty, int_par(line_penalty_code)); - get_int_par (lastlinefit, int_par(last_line_fit_code)); - get_int_par (doublehyphendemerits, int_par(double_hyphen_demerits_code)); - get_int_par (finalhyphendemerits, int_par(final_hyphen_demerits_code)); - get_int_par (hangafter, int_par(hang_after_code)); - get_intx_par (interlinepenalty,int_par(inter_line_penalty_code), interlinepenalties, equiv(inter_line_penalties_loc)); - get_intx_par (clubpenalty, int_par(club_penalty_code), clubpenalties, equiv(club_penalties_loc)); - get_intx_par (widowpenalty, int_par(widow_penalty_code), widowpenalties, equiv(widow_penalties_loc)); - get_int_par (brokenpenalty, int_par(broken_penalty_code)); - get_dimen_par(emergencystretch, dimen_par(emergency_stretch_code)); - get_dimen_par(hangindent, dimen_par(hang_indent_code)); - get_dimen_par(hsize, dimen_par(hsize_code)); - get_glue_par (leftskip, glue_par(left_skip_code)); - get_glue_par (rightskip, glue_par(right_skip_code)); + get_int_par (pretolerance, pretolerance_par); + get_int_par (tracingparagraphs, tracing_paragraphs_par); + get_int_par (tolerance, tolerance_par); + get_int_par (looseness, looseness_par); + get_int_par (adjustspacing, adjust_spacing_par); + get_int_par (adjdemerits, adj_demerits_par); + get_int_par (protrudechars, protrude_chars_par); + get_int_par (linepenalty, line_penalty_par); + get_int_par (lastlinefit, last_line_fit_par); + get_int_par (doublehyphendemerits, double_hyphen_demerits_par); + get_int_par (finalhyphendemerits, final_hyphen_demerits_par); + get_int_par (hangafter, hang_after_par); + get_intx_par (interlinepenalty,inter_line_penalty_par, interlinepenalties, equiv(inter_line_penalties_loc)); + get_intx_par (clubpenalty, club_penalty_par, clubpenalties, equiv(club_penalties_loc)); + get_intx_par (widowpenalty, widow_penalty_par, widowpenalties, equiv(widow_penalties_loc)); + get_int_par (brokenpenalty, broken_penalty_par); + get_dimen_par(emergencystretch, emergency_stretch_par); + get_dimen_par(hangindent, hang_indent_par); + get_dimen_par(hsize, hsize_par); + get_glue_par (leftskip, left_skip_par); + get_glue_par (rightskip, right_skip_par); ext_do_line_break(paragraph_dir, pretolerance, tracingparagraphs, @@ -2827,6 +2819,7 @@ static int tex_save_box_resource(lua_State * L) int index = null; int attributes = null; int resources = null; + int type = 0; boolean immediate = false; /* box attributes resources */ halfword boxnumber = lua_tointeger(L,1); @@ -2841,6 +2834,9 @@ static int tex_save_box_resource(lua_State * L) if (lua_type(L,4) == LUA_TBOOLEAN) { immediate = lua_toboolean(L, 4); } + if (lua_type(L,5) == LUA_TNUMBER) { + type = lua_tointeger(L, 5); + } /* more or less same as scanner variant */ boxdata = box(boxnumber); if (boxdata == null) @@ -2856,6 +2852,7 @@ static int tex_save_box_resource(lua_State * L) set_obj_xform_width(static_pdf, index, width(boxdata)); set_obj_xform_height(static_pdf, index, height(boxdata)); set_obj_xform_depth(static_pdf, index, depth(boxdata)); + set_obj_xform_type(static_pdf, index, type); box(boxnumber) = null; last_saved_box_index = index; lua_pushinteger(L, index); diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.w b/Build/source/texk/web2c/luatexdir/lua/luainit.w index 4456834206d..6681b4b560c 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luainit.w +++ b/Build/source/texk/web2c/luatexdir/lua/luainit.w @@ -88,6 +88,7 @@ const_string LUATEX_IHELP[] = { " --[no-]shell-escape disable/enable system commands", " --shell-restricted restrict system commands to a list of commands given in texmf.cnf", " --synctex=NUMBER enable synctex", + " --utc init time to UTC", " --version display version and exit", "", "Alternate behaviour models can be obtained by special switches", @@ -183,6 +184,7 @@ char *jithash_hashname = NULL; int safer_option = 0; int nosocket_option = 0; +int utc_option = 0; @ Reading the options. @@ -212,6 +214,7 @@ static struct option long_options[] = { {"jithash", 1, 0, 0}, #endif {"safer", 0, &safer_option, 1}, + {"utc", 0, &utc_option, 1}, {"nosocket", 0, &nosocket_option, 1}, {"help", 0, 0, 0}, {"ini", 0, &ini_version, 1}, @@ -573,6 +576,7 @@ static void init_kpse(void) kpse_set_program_name(argv[0], user_progname); init_shell_escape(); /* set up 'restrictedshell' */ + init_start_time(); program_name_set = 1 ; if (recorderoption) { recorder_enabled = 1; @@ -856,6 +860,8 @@ void lua_initialize(int ac, char **av) char *banner; int kpse_init; size_t len; + int starttime; + int utc; static char LC_CTYPE_C[] = "LC_CTYPE=C"; static char LC_COLLATE_C[] = "LC_COLLATE=C"; static char LC_NUMERIC_C[] = "LC_NUMERIC=C"; @@ -1032,6 +1038,25 @@ void lua_initialize(int ac, char **av) } } + starttime = -1 ; + get_lua_number("texconfig", "start_time", &starttime); + if (starttime < 0) { + /* + We provide this one for compatibility reasons and therefore also in + uppercase. + */ + get_lua_number("texconfig", "SOURCE_DATE_EPOCH", &starttime); + } + if (starttime >= 0) { + set_start_time(starttime); + } + + utc = -1 ; + get_lua_boolean("texconfig", "use_utc_time", &utc); + if (utc >= 0 && utc <= 1) { + utc_option = utc; + } + fix_dumpname(); } else { if (luainit) { diff --git a/Build/source/texk/web2c/luatexdir/lua/luanode.w b/Build/source/texk/web2c/luatexdir/lua/luanode.w index 3325245fcaa..39b68a68614 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luanode.w +++ b/Build/source/texk/web2c/luatexdir/lua/luanode.w @@ -28,109 +28,57 @@ nodes are removed or inserted, temp nodes don't interfere */ @ @c void lua_node_filter_s(int filterid, int extrainfo) { - lua_State *L = Luas; int callback_id = callback_defined(filterid); - int s_top = lua_gettop(L); + int s_top = lua_gettop(Luas); if (callback_id <= 0) { - lua_settop(L, s_top); + lua_settop(Luas, s_top); return; } - if (!get_callback(L, callback_id)) { - lua_settop(L, s_top); + if (!get_callback(Luas, callback_id)) { + lua_settop(Luas, s_top); return; } - lua_push_string_by_index(L,extrainfo); /* arg 1 */ - if (lua_pcall(L, 1, 0, 0) != 0) { - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_settop(L, s_top); + lua_push_string_by_index(Luas,extrainfo); /* arg 1 */ + if (lua_pcall(Luas, 1, 0, 0) != 0) { + fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1)); + lua_settop(Luas, s_top); error(); return; } - lua_settop(L, s_top); + lua_settop(Luas, s_top); return; } @ @c -/* -void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node) -{ - halfword ret; - int a; - lua_State *L = Luas; - int s_top = lua_gettop(L); - int callback_id = callback_defined(filterid); - if (head_node == null || vlink(head_node) == null || callback_id <= 0) { - lua_settop(L, s_top); - return; - } - if (!get_callback(L, callback_id)) { - lua_settop(L, s_top); - return; - } - alink(vlink(head_node)) = null ; - nodelist_to_lua(L, vlink(head_node)); - lua_push_group_code(L,extrainfo); - if (lua_pcall(L, 2, 1, 0) != 0) { - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_settop(L, s_top); - error(); - return; - } - if (lua_isboolean(L, -1)) { - if (lua_toboolean(L, -1) != 1) { - flush_node_list(vlink(head_node)); - vlink(head_node) = null; - } - } else { - a = nodelist_from_lua(L); - try_couple_nodes(head_node,a); - } - lua_pop(L, 2); - if (fix_node_lists) - fix_node_list(head_node); - ret = vlink(head_node); - if (ret != null) { - while (vlink(ret) != null) - ret = vlink(ret); - *tail_node = ret; - } else { - *tail_node = head_node; - } - lua_settop(L, s_top); - return; -} -*/ - void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node) { halfword start_node, start_done, last_node; - lua_State *L = Luas; - int s_top = lua_gettop(L); + int s_top = lua_gettop(Luas); int callback_id = callback_defined(filterid); if (head_node == null || callback_id <= 0) { - lua_settop(L, s_top); + lua_settop(Luas, s_top); return; } /* we start after head */ start_node = vlink(head_node); - if (start_node == null || !get_callback(L, callback_id)) { - lua_settop(L, s_top); + if (start_node == null || !get_callback(Luas, callback_id)) { + lua_settop(Luas, s_top); return; } /* we make sure we have no prev */ alink(start_node) = null ; /* the action */ - nodelist_to_lua(L, start_node); - lua_push_group_code(L,extrainfo); - if (lua_pcall(L, 2, 1, 0) != 0) { - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_settop(L, s_top); + nodelist_to_lua(Luas, start_node); + lua_push_group_code(Luas,extrainfo); + if (lua_pcall(Luas, 2, 1, 0) != 0) { + fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1)); + lua_settop(Luas, s_top); error(); return; } /* the result */ - if (lua_isboolean(L, -1)) { - if (lua_toboolean(L, -1) != 1) { + if (lua_isboolean(Luas, -1)) { + if (lua_toboolean(Luas, -1) != 1) { /* discard */ flush_node_list(start_node); vlink(head_node) = null; @@ -139,11 +87,11 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * } } else { /* append to old head */ - start_done = nodelist_from_lua(L); + start_done = nodelist_from_lua(Luas); try_couple_nodes(head_node,start_done); } /* redundant as we set top anyway */ - lua_pop(L, 2); + lua_pop(Luas, 2); /* find tail in order to update tail */ start_node = vlink(head_node); if (start_node != null) { @@ -168,7 +116,7 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * *tail_node = head_node; } /* clean up */ - lua_settop(L, s_top); + lua_settop(Luas, s_top); return; } @@ -178,33 +126,32 @@ int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_hea int a; register halfword *p; int ret = 0; /* failure */ - lua_State *L = Luas; - int s_top = lua_gettop(L); + int s_top = lua_gettop(Luas); int callback_id = callback_defined(linebreak_filter_callback); if (head_node == null || vlink(head_node) == null || callback_id <= 0) { - lua_settop(L, s_top); + lua_settop(Luas, s_top); return ret; } - if (!get_callback(L, callback_id)) { - lua_settop(L, s_top); + if (!get_callback(Luas, callback_id)) { + lua_settop(Luas, s_top); return ret; } alink(vlink(head_node)) = null ; /* hh-ls */ - nodelist_to_lua(L, vlink(head_node)); /* arg 1 */ - lua_pushboolean(L, is_broken); /* arg 2 */ - if (lua_pcall(L, 2, 1, 0) != 0) { /* no arg, 1 result */ - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_settop(L, s_top); + nodelist_to_lua(Luas, vlink(head_node)); /* arg 1 */ + lua_pushboolean(Luas, is_broken); /* arg 2 */ + if (lua_pcall(Luas, 2, 1, 0) != 0) { /* no arg, 1 result */ + fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1)); + lua_settop(Luas, s_top); error(); return ret; } - p = lua_touserdata(L, -1); + p = lua_touserdata(Luas, -1); if (p != NULL) { - a = nodelist_from_lua(L); + a = nodelist_from_lua(Luas); try_couple_nodes(*new_head,a); ret = 1; } - lua_settop(L, s_top); + lua_settop(Luas, s_top); return ret; } @@ -212,39 +159,38 @@ int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_hea int lua_appendtovlist_callback(halfword box, int location, halfword prev_depth, boolean is_mirrored, halfword * result, int * next_depth, boolean * prev_set) { register halfword *p; - lua_State *L = Luas; - int s_top = lua_gettop(L); + int s_top = lua_gettop(Luas); int callback_id = callback_defined(append_to_vlist_filter_callback); if (box == null || callback_id <= 0) { - lua_settop(L, s_top); + lua_settop(Luas, s_top); return 0; } - if (!get_callback(L, callback_id)) { - lua_settop(L, s_top); + if (!get_callback(Luas, callback_id)) { + lua_settop(Luas, s_top); return 0; } - nodelist_to_lua(L, box); - lua_push_string_by_index(L,location); - lua_pushinteger(L, (int) prev_depth); - lua_pushboolean(L, is_mirrored); - if (lua_pcall(L, 4, 2, 0) != 0) { - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_settop(L, s_top); + nodelist_to_lua(Luas, box); + lua_push_string_by_index(Luas,location); + lua_pushinteger(Luas, (int) prev_depth); + lua_pushboolean(Luas, is_mirrored); + if (lua_pcall(Luas, 4, 2, 0) != 0) { + fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1)); + lua_settop(Luas, s_top); error(); return 0; } - if (lua_type(L,-1) == LUA_TNUMBER) { - *next_depth = lua_tointeger(L,-1); + if (lua_type(Luas,-1) == LUA_TNUMBER) { + *next_depth = lua_tointeger(Luas,-1); *prev_set = true; - if (lua_type(L, -2) != LUA_TNIL) { - p = check_isnode(L, -2); + if (lua_type(Luas, -2) != LUA_TNIL) { + p = check_isnode(Luas, -2); *result = *p; } - } else if (lua_type(L, -1) != LUA_TNIL) { - p = check_isnode(L, -1); + } else if (lua_type(Luas, -1) != LUA_TNIL) { + p = check_isnode(Luas, -1); *result = *p; } - lua_settop(L, s_top); + lua_settop(Luas, s_top); return 1; } @@ -252,50 +198,49 @@ int lua_appendtovlist_callback(halfword box, int location, halfword prev_depth, halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo, int pack_direction, halfword attr) { halfword ret; - lua_State *L = Luas; - int s_top = lua_gettop(L); + int s_top = lua_gettop(Luas); int callback_id = callback_defined(hpack_filter_callback); if (head_node == null || callback_id <= 0) { - lua_settop(L, s_top); + lua_settop(Luas, s_top); return head_node; } - if (!get_callback(L, callback_id)) { - lua_settop(L, s_top); + if (!get_callback(Luas, callback_id)) { + lua_settop(Luas, s_top); return head_node; } alink(head_node) = null ; /* hh-ls */ - nodelist_to_lua(L, head_node); - lua_push_group_code(L,extrainfo); - lua_pushinteger(L, size); - lua_push_pack_type(L,pack_type); + nodelist_to_lua(Luas, head_node); + lua_push_group_code(Luas,extrainfo); + lua_pushinteger(Luas, size); + lua_push_pack_type(Luas, pack_type); if (pack_direction >= 0) { - lua_push_dir_par(L, pack_direction); + lua_push_dir_par(Luas, pack_direction); } else { - lua_pushnil(L); + lua_pushnil(Luas); } if (attr != null) { - nodelist_to_lua(L, attr); + nodelist_to_lua(Luas, attr); } else { - lua_pushnil(L); + lua_pushnil(Luas); } - if (lua_pcall(L, 6, 1, 0) != 0) { - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_settop(L, s_top); + if (lua_pcall(Luas, 6, 1, 0) != 0) { + fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1)); + lua_settop(Luas, s_top); error(); return head_node; } ret = head_node; - if (lua_isboolean(L, -1)) { - if (lua_toboolean(L, -1) != 1) { + if (lua_isboolean(Luas, -1)) { + if (lua_toboolean(Luas, -1) != 1) { flush_node_list(head_node); ret = null; } } else { - ret = nodelist_from_lua(L); + ret = nodelist_from_lua(Luas); } - lua_settop(L, s_top); + lua_settop(Luas, s_top); #if 0 - lua_gc(L,LUA_GCSTEP, LUA_GC_STEP_SIZE); + lua_gc(Luas,LUA_GCSTEP, LUA_GC_STEP_SIZE); #endif if (fix_node_lists) fix_node_list(ret); @@ -308,10 +253,9 @@ halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled { halfword ret; int callback_id; - lua_State *L = Luas; - int s_top = lua_gettop(L); + int s_top = lua_gettop(Luas); if (head_node == null) { - lua_settop(L, s_top); + lua_settop(Luas, s_top); return head_node; } if (extrainfo == 8) { /* output */ @@ -320,47 +264,47 @@ halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled callback_id = callback_defined(vpack_filter_callback); } if (callback_id <= 0) { - lua_settop(L, s_top); + lua_settop(Luas, s_top); return head_node; } - if (!get_callback(L, callback_id)) { - lua_settop(L, s_top); + if (!get_callback(Luas, callback_id)) { + lua_settop(Luas, s_top); return head_node; } alink(head_node) = null ; /* hh-ls */ - nodelist_to_lua(L, head_node); - lua_push_group_code(L,extrainfo); - lua_pushinteger(L, size); - lua_push_pack_type(L,pack_type); - lua_pushinteger(L, maxd); + nodelist_to_lua(Luas, head_node); + lua_push_group_code(Luas, extrainfo); + lua_pushinteger(Luas, size); + lua_push_pack_type(Luas, pack_type); + lua_pushinteger(Luas, maxd); if (pack_direction >= 0) { - lua_push_dir_par(L, pack_direction); + lua_push_dir_par(Luas, pack_direction); } else { - lua_pushnil(L); + lua_pushnil(Luas); } if (attr != null) { - nodelist_to_lua(L, attr); + nodelist_to_lua(Luas, attr); } else { - lua_pushnil(L); + lua_pushnil(Luas); } - if (lua_pcall(L, 7, 1, 0) != 0) { - fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); - lua_settop(L, s_top); + if (lua_pcall(Luas, 7, 1, 0) != 0) { + fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1)); + lua_settop(Luas, s_top); error(); return head_node; } ret = head_node; - if (lua_isboolean(L, -1)) { - if (lua_toboolean(L, -1) != 1) { + if (lua_isboolean(Luas, -1)) { + if (lua_toboolean(Luas, -1) != 1) { flush_node_list(head_node); ret = null; } } else { - ret = nodelist_from_lua(L); + ret = nodelist_from_lua(Luas); } - lua_settop(L, s_top); + lua_settop(Luas, s_top); #if 0 - lua_gc(L,LUA_GCSTEP, LUA_GC_STEP_SIZE); + lua_gc(Luas,LUA_GCSTEP, LUA_GC_STEP_SIZE); #endif if (fix_node_lists) fix_node_list(ret); diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h index dddfa9f2209..cf3740101da 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h +++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h @@ -198,6 +198,7 @@ extern void preset_environment(lua_State * L, const parm_struct * p, const char extern char *startup_filename; extern int safer_option; extern int nosocket_option; +extern int utc_option; extern char *last_source_name; extern int last_lineno; @@ -824,7 +825,8 @@ make_lua_key(xsize);\ make_lua_key(xyz_zoom);\ make_lua_key(yoffset); \ make_lua_key(yres); \ -make_lua_key(ysize) +make_lua_key(ysize); \ +make_lua_key(__index) #define set_init_keys \ init_lua_key(cmdname);init_lua_key(expandable);init_lua_key(protected);\ @@ -1178,10 +1180,12 @@ init_lua_key(xyz_zoom);\ init_lua_key(yoffset);\ init_lua_key(yres);\ init_lua_key(ysize);\ +init_lua_key(__index);\ init_lua_key_alias(empty_string,"");\ init_lua_key_alias(lua_bytecodes_indirect,"lua.bytecodes.indirect");\ init_lua_key_alias(lua_functions,"lua.functions");\ init_lua_key_alias(luatex_node, "luatex.node");\ +init_lua_key_alias(luatex_token, "luatex.token");\ init_lua_key_alias(mLTL,"-LTL");\ init_lua_key_alias(mRTT,"-RTT");\ init_lua_key_alias(mTLT,"-TLT");\ @@ -1599,3 +1603,4 @@ use_lua_key(xyz_zoom); use_lua_key(yoffset); use_lua_key(yres); use_lua_key(ysize); +use_lua_key(__index); diff --git a/Build/source/texk/web2c/luatexdir/lua/luatoken.w b/Build/source/texk/web2c/luatexdir/lua/luatoken.w index 893519b5925..a567c7f7a2b 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luatoken.w +++ b/Build/source/texk/web2c/luatexdir/lua/luatoken.w @@ -113,6 +113,7 @@ command_item command_names[] = { {"assign_mu_glue", assign_mu_glue_cmd, NULL}, {"assign_font_dimen", assign_font_dimen_cmd, NULL}, {"assign_font_int", assign_font_int_cmd, NULL}, + {"assign_hang_indent", assign_hang_indent_cmd, NULL}, {"set_aux", set_aux_cmd, NULL}, {"set_prev_graf", set_prev_graf_cmd, NULL}, {"set_page_dimen", set_page_dimen_cmd, NULL}, @@ -362,34 +363,33 @@ int tokenlist_from_lua(lua_State * L) static void do_get_token_lua(int callback_id) { - lua_State *L = Luas; while (1) { - if (!get_callback(L, callback_id)) { + if (!get_callback(Luas, callback_id)) { get_next(); - lua_pop(L, 2); + lua_pop(Luas, 2); break; } - if (lua_pcall(L, 0, 1, 0) != 0) { - tex_error(lua_tostring(L, -1), NULL); - lua_pop(L, 2); + if (lua_pcall(Luas, 0, 1, 0) != 0) { + tex_error(lua_tostring(Luas, -1), NULL); + lua_pop(Luas, 2); break; } - if (lua_istable(L, -1)) { - lua_rawgeti(L, -1, 1); - if (lua_istable(L, -1)) { + if (lua_istable(Luas, -1)) { + lua_rawgeti(Luas, -1, 1); + if (lua_istable(Luas, -1)) { int p, q, r; size_t i, j; - lua_pop(L, 1); + lua_pop(Luas, 1); r = get_avail(); p = r; - j = lua_rawlen(L, -1); + j = lua_rawlen(Luas, -1); if (j > 0) { for (i = 1; i <= j; i++) { - lua_rawgeti(L, -1, (int) i); - if (get_cur_cmd(L) || get_cur_cs(L)) { + lua_rawgeti(Luas, -1, (int) i); + if (get_cur_cmd(Luas) || get_cur_cs(Luas)) { store_new_token(cur_tok); } - lua_pop(L, 1); + lua_pop(Luas, 1); } } if (p != r) { @@ -399,23 +399,22 @@ static void do_get_token_lua(int callback_id) cur_input.nofilter_field = true; get_next(); } else { - tex_error("error: illegal or empty token list returned", - NULL); + tex_error("error: illegal or empty token list returned", NULL); } - lua_pop(L, 2); + lua_pop(Luas, 2); break; } else { - lua_pop(L, 1); - if (get_cur_cmd(L) || get_cur_cs(L)) { - lua_pop(L, 2); + lua_pop(Luas, 1); + if (get_cur_cmd(Luas) || get_cur_cs(Luas)) { + lua_pop(Luas, 2); break; } else { - lua_pop(L, 2); + lua_pop(Luas, 2); continue; } } } else { - lua_pop(L, 2); + lua_pop(Luas, 2); } } return; diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c index e400cd1932a..f4b2945d970 100644 --- a/Build/source/texk/web2c/luatexdir/luatex.c +++ b/Build/source/texk/web2c/luatexdir/luatex.c @@ -28,10 +28,10 @@ #define TeX -int luatex_version = 95; /* \.{\\luatexversion} */ +int luatex_version = 97; /* \.{\\luatexversion} */ int luatex_revision = '0'; /* \.{\\luatexrevision} */ -int luatex_date_info = 2016042515; /* the compile date is now hardwired */ -const char *luatex_version_string = "0.95.0"; +int luatex_date_info = 2016060720; /* the compile date is now hardwired */ +const char *luatex_version_string = "0.97.0"; const char *engine_name = my_name; /* the name of this engine */ #include <kpathsea/c-ctype.h> @@ -148,6 +148,88 @@ void mk_shellcmdlist(char *v) /* Called from maininit. Not static because also called from luatexdir/lua/luainit.c. */ +/* + In order to avoid all kind of time code in the backend code we use a function. + The start time can be overloaded in several ways: + + (1) By setting the environmment variable SOURCE_DATE_EPOCH. This will influence + the tex parameters, random seed, pdf timestamp and pdf id that is derived + from the time. This variable is consulted when the kpse library is enabled + which is analogue to other properties. + + (2) By setting the texconfig.start_time variable (as with other variables + we use the internal name there). This has the same effect as (1) and is + provided for when kpse is not used to set these variables or when an overloaded + is wanted. This is analogue to other properties. + + When an utc time is needed one can provide the flag --utc. This property is + independent of this time hackery. This flag has a corresponding texconfig + option use_utc_time. + + To some extend a cleaner solution would be to have a flag that disables all + variable data in one go (like filenames and so) but we just follow the method + implemented in pdftex where primitives are used tod disable it. + +*/ + +static int start_time = -1; + +int get_start_time(void) { + if (start_time < 0) { + start_time = time((time_t *) NULL); + } + return start_time; +} + +/* + This one is called as part of the kpse initialization which only happens + when this library is enabled. +*/ +#if defined(_MSC_VER) +#define strtoull _strtoui64 +#endif + +void init_start_time(void) { + if (start_time < 0) { + unsigned long long epoch; + char *endptr; + /* + We don't really care how kpse sets up this variable but we prefer to + just use its abstract interface. + */ + /* char *source_date_epoch = getenv("SOURCE_DATE_EPOCH"); */ + char *source_date_epoch = kpse_var_value("SOURCE_DATE_EPOCH"); + if (source_date_epoch && source_date_epoch != '\0' ) { + errno = 0; + epoch = strtoull(source_date_epoch, &endptr, 10); + if (epoch < 0 || *endptr != '\0' || errno != 0) { + epoch = 0; + } +#if defined(_MSC_VER) + /* We avoid to crash if users test a large value which is not + * supported by Visual Studio 2010: + * a later time than 3001/01/01 20:59:59. + */ + if (epoch > 32535291599ULL) + epoch = 32535291599ULL; +#endif + start_time = epoch; + } + } +} + +/* + This one is used to fetch a value from texconfig which can also be used to + set properties. This might come in handy when one has other ways to get date + info in the pdf file. +*/ + +void set_start_time(int s) { + if (s >= 0) { + start_time = s ; + } +} + void init_shell_escape(void) { if (shellenabledp < 0) { /* --no-shell-escape on cmd line */ @@ -469,7 +551,10 @@ main (int ac, string *av) # endif av[0] = kpse_program_basename (av[0]); _setmaxstdio(2048); +/* + * We choose to crash for fatal errors SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); + */ setmode(fileno(stdin), _O_BINARY); # endif @@ -858,8 +943,13 @@ static RETSIGTYPE catch_interrupt(int arg) void get_date_and_time(int *minutes, int *day, int *month, int *year) { - time_t myclock = time((time_t *) 0); - struct tm *tmptr = localtime(&myclock); + time_t myclock = get_start_time(); + struct tm *tmptr ; + if (utc_option) { + tmptr = gmtime(&myclock); + } else { + tmptr = localtime(&myclock); + } *minutes = tmptr->tm_hour * 60 + tmptr->tm_min; *day = tmptr->tm_mday; @@ -933,8 +1023,13 @@ int getrandomseed(void) ftime(&tb); return (tb.millitm + 1000 * tb.time); #else - time_t myclock = time((time_t *) NULL); - struct tm *tmptr = localtime(&myclock); + time_t myclock = get_start_time((time_t *) NULL); + struct tm *tmptr ; + if (utc_option) { + tmptr = gmtime(&myclock); + } else { + tmptr = localtime(&myclock); + } return (tmptr->tm_sec + 60 * (tmptr->tm_min + 60 * tmptr->tm_hour)); #endif } diff --git a/Build/source/texk/web2c/luatexdir/luatex.h b/Build/source/texk/web2c/luatexdir/luatex.h index 8b1254dcbff..1c88ec6673b 100644 --- a/Build/source/texk/web2c/luatexdir/luatex.h +++ b/Build/source/texk/web2c/luatexdir/luatex.h @@ -71,6 +71,11 @@ /* Executing shell commands. */ extern void mk_shellcmdlist(char *); extern void init_shell_escape(void); +extern void init_start_time(void); +extern int get_start_time(void); +extern void set_start_time(int); +extern boolean get_start_time(void); + extern int shell_cmd_is_allowed(const char *cmd, char **safecmd, char **cmdname); diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w index 6bbfec226e7..43ee3692bd1 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w @@ -22,8 +22,6 @@ #include "ptexlib.h" @ @c -#define tail cur_list.tail_field - void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur) { scaled_whd alt_rule; @@ -52,15 +50,15 @@ void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur) scaled_whd alt_rule; new_whatsit(w); alt_rule = scan_alt_rule(); /* scans |<rule spec>| to |alt_rule| */ - set_width(tail, alt_rule.wd); - set_height(tail, alt_rule.ht); - set_depth(tail, alt_rule.dp); + set_width(tail_par, alt_rule.wd); + set_height(tail_par, alt_rule.ht); + set_depth(tail_par, alt_rule.dp); if ((w == pdf_thread_node) || (w == pdf_start_thread_node)) { if (scan_keyword("attr")) { scan_toks(false, true); - set_pdf_thread_attr(tail, def_ref); + set_pdf_thread_attr(tail_par, def_ref); } else { - set_pdf_thread_attr(tail, null); + set_pdf_thread_attr(tail_par, null); } } } @@ -87,10 +85,10 @@ void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur) k = pdf_create_obj(pdf, obj_type_annot, 0); } new_annot_whatsit(pdf_annot_node); - obj_annot_ptr(pdf, k) = tail; - set_pdf_annot_objnum(tail, k); + obj_annot_ptr(pdf, k) = tail_par; + set_pdf_annot_objnum(tail_par, k); scan_toks(false, true); - set_pdf_annot_data(tail, def_ref); + set_pdf_annot_data(tail_par, def_ref); } pdf_last_annot = k; } diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w index bcc7145c6ce..ac117d6ba05 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w @@ -47,9 +47,6 @@ They have the following properties: */ #define COLOR_DEFAULT "0 g 0 G" -#define SET_ORIGIN 0 -#define DIRECT_PAGE 1 -#define DIRECT_ALWAYS 2 typedef struct { char **page_stack; @@ -89,7 +86,7 @@ static void colstacks_first_init(void) colstacks[0].page_current = xstrdup(COLOR_DEFAULT); colstacks[0].form_current = xstrdup(COLOR_DEFAULT); colstacks[0].form_init = xstrdup(COLOR_DEFAULT); - colstacks[0].literal_mode = DIRECT_ALWAYS; + colstacks[0].literal_mode = direct_always; colstacks[0].page_start = true; } diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h index 0a8e099b177..551f686e6fe 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h @@ -188,7 +188,7 @@ extern scaled round_xn_over_d(scaled x, int n, unsigned int d); extern char *convertStringToPDFString(const char *in, int len); -extern void init_start_time(PDF); +extern void initialize_start_time(PDF); extern char *getcreationdate(PDF); extern void check_o_mode(PDF pdf, const char *s, int o_mode, boolean errorflag); diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w index 7786d83a125..e27928a9e18 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w @@ -26,8 +26,6 @@ #include "lua/luatex-api.h" #include "md5.h" -#define is_hex_char isxdigit - #define check_nprintf(size_get, size_want) \ if ((unsigned)(size_get) >= (unsigned)(size_want)) \ formatted_error("pdf backend","snprintf() failed in file %s at line %d", __FILE__, __LINE__); @@ -50,6 +48,7 @@ halfword pdf_names_toks; /* additional keys of Names halfword pdf_trailer_toks; /* additional keys of Trailer dictionary */ shipping_mode_e global_shipping_mode = NOT_SHIPPING; /* set to |shipping_mode| when |ship_out| starts */ + @ Create a new buffer |strbuf_s| of size |size| and maximum allowed size |limit|. Initialize it and set |p| to begin of data. @@ -245,7 +244,7 @@ int pdf_get_mem(PDF pdf, int s) output_mode get_o_mode(void) { output_mode o_mode; - if (int_par(output_mode_code) > 0) { + if (output_mode_par > 0) { o_mode = OMODE_PDF; } else o_mode = OMODE_DVI; @@ -285,7 +284,7 @@ void fix_pdf_minorversion(PDF pdf) /* Check that variables for \.{PDF} output are unchanged */ if (pdf->minor_version != pdf_minor_version) normal_error("pdf backend", "minorversion cannot be changed after data is written to the PDF file"); - if (pdf->draftmode != int_par(draft_mode_code)) + if (pdf->draftmode != draft_mode_par) normal_error("pdf backend", "draftmode cannot be changed after data is written to the PDF file"); } if (pdf->draftmode != 0) { @@ -633,7 +632,7 @@ void pdf_print_str(PDF pdf, const char *s) return; } s++; - while (is_hex_char((unsigned char)*s)) + while (isxdigit((unsigned char)*s)) s++; if (s != orig + l) { pdf_out(pdf, '('); @@ -960,7 +959,7 @@ void pdf_rectangle(PDF pdf, halfword r) static void init_pdf_outputparameters(PDF pdf) { int pk_mode; - pdf->draftmode = fix_int(int_par(draft_mode_code), 0, 1); + pdf->draftmode = fix_int(draft_mode_par, 0, 1); pdf->compress_level = fix_int(pdf_compress_level, 0, 9); pdf->decimal_digits = fix_int(pdf_decimal_digits, 3, 5); pdf->gamma = fix_int(pdf_gamma, 0, 1000000); @@ -987,15 +986,17 @@ static void init_pdf_outputparameters(PDF pdf) pk_mode = pdf_pk_mode; /* lookup once */ if (pk_mode != null) { char *s = tokenlist_to_cstring(pk_mode, true, NULL); + /* This will become LUATEX in 1.0. */ kpse_init_prog("PDFTEX", (unsigned) pdf->pk_resolution, s, nil); xfree(s); } else { + /* This will become LUATEX in 1.0. */ kpse_init_prog("PDFTEX", (unsigned) pdf->pk_resolution, nil, nil); } if (!kpse_var_value("MKTEXPK")) kpse_set_program_enabled(kpse_pk_format, 1, kpse_src_cmdline); } - set_job_id(pdf, int_par(year_code), int_par(month_code), int_par(day_code), int_par(time_code)); + set_job_id(pdf, year_par, month_par, day_par, time_par); if ((pdf_unique_resname > 0) && (pdf->resname_prefix == NULL)) pdf->resname_prefix = get_resname_prefix(pdf); } @@ -1026,6 +1027,7 @@ static void ensure_pdf_header_written(PDF pdf) init_pdf_outputparameters(pdf); /* Write \.{PDF} header */ pdf_printf(pdf, "%%PDF-1.%d\n", pdf->minor_version); + /* The next blob will be removed 1.0. */ pdf_out(pdf, '%'); pdf_out(pdf, 'P' + 128); pdf_out(pdf, 'T' + 128); @@ -1455,7 +1457,7 @@ static void print_ID(PDF pdf) /* start md5 */ md5_init(&state); /* get the time */ - t = time(NULL); + t = pdf->start_time; size = strftime(time_str, sizeof(time_str), "%Y%m%dT%H%M%SZ", gmtime(&t)); md5_append(&state, (const md5_byte_t *) time_str, (int) size); /* get the file name */ @@ -1542,7 +1544,11 @@ static void makepdftime(PDF pdf) time_t t = pdf->start_time; char *time_str = pdf->start_time_str; /* get the time */ - lt = *localtime(&t); + if (utc_option) { + lt = *gmtime(&t); + } else { + lt = *localtime(&t); + } size = strftime(time_str, TIME_STR_SIZE, "D:%Y%m%d%H%M%S", <); /* expected format: "YYYYmmddHHMMSS" */ if (size == 0) { @@ -1582,10 +1588,10 @@ static void makepdftime(PDF pdf) } @ @c -void init_start_time(PDF pdf) +void initialize_start_time(PDF pdf) { if (pdf->start_time == 0) { - pdf->start_time = time((time_t *) NULL); + pdf->start_time = get_start_time(); pdf->start_time_str = xtalloc(TIME_STR_SIZE, char); makepdftime(pdf); } @@ -1594,7 +1600,7 @@ void init_start_time(PDF pdf) @ @c char *getcreationdate(PDF pdf) { - init_start_time(pdf); + initialize_start_time(pdf); return pdf->start_time_str; } @@ -1642,9 +1648,9 @@ void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict) normal_error("pdf backend","weird output state"); } if (strict) - formatted_error("pdf backend", "%s not allowed in %s mode (outputmode = %d)",s, m, (int) int_par(output_mode_code)); + formatted_error("pdf backend", "%s not allowed in %s mode (outputmode = %d)",s, m, (int) output_mode_par); else - formatted_warning("pdf backend", "%s not allowed in %s mode (outputmode = %d)",s, m, (int) int_par(output_mode_code)); + formatted_warning("pdf backend", "%s not allowed in %s mode (outputmode = %d)",s, m, (int) output_mode_par); } else if (strict) ensure_output_state(pdf, ST_HEADER_WRITTEN); } @@ -1688,11 +1694,10 @@ char *get_resname_prefix(PDF pdf) } @ @c -#define mag int_par(mag_code) - void pdf_begin_page(PDF pdf) { int xform_attributes; + int xform_type = 0; scaled form_margin = pdf_xform_margin; /* was one_bp until SVN4066 */ ensure_output_state(pdf, ST_HEADER_WRITTEN); init_pdf_pagecalculations(pdf); @@ -1711,12 +1716,16 @@ void pdf_begin_page(PDF pdf) pdf->last_thread = null; pdf_begin_dict(pdf); } else { + xform_type = obj_xform_type(pdf, pdf_cur_form) ; pdf_begin_obj(pdf, pdf_cur_form, OBJSTM_NEVER); pdf->last_stream = pdf_cur_form; /* Write out Form stream header */ pdf_begin_dict(pdf); - pdf_dict_add_name(pdf, "Type", "XObject"); - pdf_dict_add_name(pdf, "Subtype", "Form"); + if (xform_type == 0) { + pdf_dict_add_name(pdf, "Type", "XObject"); + pdf_dict_add_name(pdf, "Subtype", "Form"); + pdf_dict_add_int(pdf, "FormType", 1); + } xform_attributes = pdf_xform_attr; /* lookup once */ if (xform_attributes != null) pdf_print_toks(pdf, xform_attributes); @@ -1730,23 +1739,26 @@ void pdf_begin_page(PDF pdf) luaL_unref(Luas, LUA_REGISTRYINDEX, obj_xform_attr_str(pdf, pdf_cur_form)); set_obj_xform_attr_str(pdf, pdf_cur_form, null); } - pdf_add_name(pdf, "BBox"); - pdf_begin_array(pdf); - pdf_add_bp(pdf, -form_margin); - pdf_add_bp(pdf, -form_margin); - pdf_add_bp(pdf, pdf->page_size.h + form_margin); - pdf_add_bp(pdf, pdf->page_size.v + form_margin); - pdf_end_array(pdf); - pdf_dict_add_int(pdf, "FormType", 1); - pdf_add_name(pdf, "Matrix"); - pdf_begin_array(pdf); - pdf_add_int(pdf, 1); - pdf_add_int(pdf, 0); - pdf_add_int(pdf, 0); - pdf_add_int(pdf, 1); - pdf_add_int(pdf, 0); - pdf_add_int(pdf, 0); - pdf_end_array(pdf); + if (xform_type == 0 || xform_type == 1 || xform_type == 3) { + pdf_add_name(pdf, "BBox"); + pdf_begin_array(pdf); + pdf_add_bp(pdf, -form_margin); + pdf_add_bp(pdf, -form_margin); + pdf_add_bp(pdf, pdf->page_size.h + form_margin); + pdf_add_bp(pdf, pdf->page_size.v + form_margin); + pdf_end_array(pdf); + } + if (xform_type == 0 || xform_type == 2 || xform_type == 3) { + pdf_add_name(pdf, "Matrix"); + pdf_begin_array(pdf); + pdf_add_int(pdf, 1); + pdf_add_int(pdf, 0); + pdf_add_int(pdf, 0); + pdf_add_int(pdf, 1); + pdf_add_int(pdf, 0); + pdf_add_int(pdf, 0); + pdf_end_array(pdf); + } pdf_dict_add_ref(pdf, "Resources", pdf->page_resources->last_resources); } /* Start stream of page/form contents */ @@ -2176,11 +2188,11 @@ static int pdf_print_info(PDF pdf, int luatexversion, pdf_dict_add_string(pdf, "Creator", "TeX"); } if ((pdf_suppress_optional_info & 32) == 0 && !creationdate_given) { - init_start_time(pdf); + initialize_start_time(pdf); pdf_dict_add_string(pdf, "CreationDate", pdf->start_time_str); } if ((pdf_suppress_optional_info & 64) == 0 && !moddate_given) { - init_start_time(pdf); + initialize_start_time(pdf); pdf_dict_add_string(pdf, "ModDate", pdf->start_time_str); } if ((pdf_suppress_optional_info & 256) == 0 && !trapped_given) { diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w index 93096d025e5..a1059828938 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w @@ -22,13 +22,10 @@ #include "ptexlib.h" #include "pdf/pdfpage.h" -#define pdf2double(a) ((double) (a).m / ten_pow[(a).e]) - @ eternal constants @c -#define one_bp ((double) 65536 * (double) 72.27 / 72) /* number of sp per 1bp */ -#define e_tj 3 /* must be 3; movements in []TJ are in fontsize/$10^3$ units */ +#define e_tj 3 /* must be 3; movements in []TJ are in fontsize/$10^3$ units */ @ @c static int64_t pdf_char_width(pdfstructure * p, internal_font_number f, int i) @@ -58,7 +55,7 @@ static void setup_fontparameters(PDF pdf, internal_font_number f, int ex_glyph) u = font_units_per_em(f) / 1000.0; pdf->f_cur = f; p->f_pdf = pdf_set_font(pdf, f); - p->fs.m = i64round(font_size(f) / u / one_bp * ten_pow[p->fs.e]); + p->fs.m = i64round(font_size(f) / u / by_one_bp * ten_pow[p->fs.e]); slant = font_slant(f) / 1000.0; extend = font_extend(f) / 1000.0; expand = 1.0 + (ex_glyph/1) / 1000.0; diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w index b6f3e6ff1a1..8c5abad5302 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w @@ -310,7 +310,7 @@ void hlist_out(PDF pdf, halfword this_box, int rule_callback_id) int i; /* index to scan |pdf_link_stack| */ int save_loc = 0; /* DVI! \.{DVI} byte location upon entry */ scaledpos save_dvi = { 0, 0 }; /* DVI! what |dvi| should pop to */ - int synctex = int_par(synctex_code) ; + int synctex = synctex_par ; g_order = glue_order(this_box); g_sign = glue_sign(this_box); @@ -764,7 +764,7 @@ void vlist_out(PDF pdf, halfword this_box, int rule_callback_id) scaled_whd rule; int save_loc = 0; /* DVI byte location upon entry */ scaledpos save_dvi = { 0, 0 }; /* DVI! what |dvi| should pop to */ - int synctex = int_par(synctex_code) ; + int synctex = synctex_par ; g_order = (glue_ord) glue_order(this_box); g_sign = glue_sign(this_box); diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w index 7dd51061595..e5ca09de624 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w @@ -29,13 +29,21 @@ void pdf_write_obj(PDF pdf, int k) lstring data; const_lstring st; size_t li; /* index into |data.s| */ - int saved_compress_level = pdf->compress_level; + int saved_compress_level ; int os_threshold = OBJSTM_ALWAYS; /* gives compressed objects for \.{\\pdfvariable objcompresslevel} >= |OBJSTM_ALWAYS| */ int l = 0; /* possibly a lua registry reference */ int ll = 0; data.s = NULL; - if (obj_obj_pdfcompresslevel(pdf, k) > -1) /* -1 = "unset" */ + /* we can have an immediate object before we are initialized */ + ensure_output_state(pdf, ST_HEADER_WRITTEN); + saved_compress_level = pdf->compress_level; + /* end of ugly hack */ + if (obj_obj_pdfcompresslevel(pdf, k) > -1) { /* -1 = "unset" */ pdf->compress_level = obj_obj_pdfcompresslevel(pdf, k); + if (pdf->compress_level == 0) { + pdf->objcompresslevel = 0; + } + } if (obj_obj_objstm_threshold(pdf, k) != OBJSTM_UNSET) os_threshold = obj_obj_objstm_threshold(pdf, k); if (obj_obj_is_stream(pdf, k)) { @@ -183,21 +191,19 @@ void scan_obj(PDF pdf) } @ @c -#define tail cur_list.tail_field - void scan_refobj(PDF pdf) { scan_int(); check_obj_type(pdf, obj_type_obj, cur_val); new_whatsit(pdf_refobj_node); - pdf_obj_objnum(tail) = cur_val; + pdf_obj_objnum(tail_par) = cur_val; } void scan_refobj_lua(PDF pdf, int k) { check_obj_type(pdf, obj_type_obj, k); new_whatsit(pdf_refobj_node); - pdf_obj_objnum(tail) = k; + pdf_obj_objnum(tail_par) = k; } @ @c diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w index 90f63534d32..f0782d2093c 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w @@ -26,11 +26,6 @@ #include <assert.h> #include <math.h> -@ eternal constant: number of sp per 1bp - -@c -#define one_bp ((double) 65536 * (double) 72.27 / 72) - @ @c void init_pdf_pagecalculations(PDF pdf) { @@ -66,7 +61,7 @@ void init_pdf_pagecalculations(PDF pdf) p->ishex = 0; p->need_tf = false; p->need_tm = false; - p->k1 = ten_pow[p->pdf.h.e] / one_bp; + p->k1 = ten_pow[p->pdf.h.e] / by_one_bp; } @ @c diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w index 253f8dc4202..8665f685e1f 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w @@ -22,20 +22,6 @@ #include "ptexlib.h" @ @c -#define count(A) eqtb[count_base+(A)].cint - -#define mag int_par(mag_code) -#define h_offset dimen_par(h_offset_code) -#define page_bottom_offset dimen_par(page_bottom_offset_code) -#define page_height dimen_par(page_height_code) -#define page_left_offset dimen_par(page_left_offset_code) -#define page_right_offset dimen_par(page_right_offset_code) -#define page_top_offset dimen_par(page_top_offset_code) -#define page_width dimen_par(page_width_code) -#define tracing_output int_par(tracing_output_code) -#define tracing_stats int_par(tracing_stats_code) -#define v_offset dimen_par(v_offset_code) - scaledpos shipbox_refpos; @ |ship_out| is used to shipout a box to PDF or DVI mode. If |shipping_mode| is @@ -61,16 +47,16 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode) Start sheet {\sl Sync\TeX} information record; we assume that |pdf_output| is properly set up. */ - if (int_par(synctex_code)) { + if (synctex_par) { if (output_mode_used == OMODE_DVI) { - synctexsheet(mag); + synctexsheet(mag_par); } else { synctexsheet(1000); } } pre_callback_id = callback_defined(start_page_number_callback); post_callback_id = callback_defined(stop_page_number_callback); - if ((tracing_output > 0) && (pre_callback_id == 0)) { + if ((tracing_output_par > 0) && (pre_callback_id == 0)) { tprint_nl(""); print_ln(); tprint("Completed box being shipped out"); @@ -95,7 +81,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode) } } } - if ((tracing_output > 0) && shipping_mode == SHIPPING_PAGE) { + if ((tracing_output_par > 0) && shipping_mode == SHIPPING_PAGE) { print_char(']'); update_terminal(); begin_diagnostic(); @@ -103,7 +89,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode) end_diagnostic(true); } /* Ship box |p| out */ - if (shipping_mode == SHIPPING_PAGE && box_dir(p) != page_direction) + if (shipping_mode == SHIPPING_PAGE && box_dir(p) != page_direction_par) normal_warning("backend","pagedir differs from bodydir, the output may be placed wrongly on the page"); /* Update the values of |max_h| and |max_v|; but if the page is too large, @@ -111,14 +97,14 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode) error messages are being ignored. Such pages are not output to the \.{dvi} file, since they may confuse the printing software. */ - if ((height(p) > max_dimen) || (depth(p) > max_dimen) || (height(p) + depth(p) + v_offset > max_dimen) || (width(p) + h_offset > max_dimen)) { + if ((height(p) > max_dimen) || (depth(p) > max_dimen) || (height(p) + depth(p) + v_offset_par > max_dimen) || (width(p) + h_offset_par > max_dimen)) { const char *hlp[] = { "The page just created is more than 18 feet tall or", "more than 18 feet wide, so I suspect something went wrong.", NULL }; tex_error("Huge page cannot be shipped out", hlp); - if (tracing_output <= 0) { + if (tracing_output_par <= 0) { begin_diagnostic(); tprint_nl("The following box has been deleted:"); show_box(p); @@ -126,47 +112,47 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode) } goto DONE; } - if (height(p) + depth(p) + v_offset > max_v) - max_v = height(p) + depth(p) + v_offset; - if (width(p) + h_offset > max_h) - max_h = width(p) + h_offset; + if (height(p) + depth(p) + v_offset_par > max_v) + max_v = height(p) + depth(p) + v_offset_par; + if (width(p) + h_offset_par > max_h) + max_h = width(p) + h_offset_par; /* Calculate page dimensions and margins */ if (global_shipping_mode == SHIPPING_PAGE) { - if (page_width > 0) - pdf->page_size.h = page_width; + if (page_width_par > 0) + pdf->page_size.h = page_width_par; else { - switch (page_direction) { + switch (page_direction_par) { case dir_TLT: - pdf->page_size.h = width(p) + 2 * page_left_offset; + pdf->page_size.h = width(p) + 2 * page_left_offset_par; break; case dir_TRT: - pdf->page_size.h = width(p) + 2 * page_right_offset; + pdf->page_size.h = width(p) + 2 * page_right_offset_par; break; case dir_LTL: - pdf->page_size.h = height(p) + depth(p) + 2 * page_left_offset; + pdf->page_size.h = height(p) + depth(p) + 2 * page_left_offset_par; break; case dir_RTT: - pdf->page_size.h = height(p) + depth(p) + 2 * page_right_offset; + pdf->page_size.h = height(p) + depth(p) + 2 * page_right_offset_par; break; default: - pdf->page_size.h = width(p) + 2 * page_left_offset; + pdf->page_size.h = width(p) + 2 * page_left_offset_par; normal_warning("pdf backend","bad page direction, assuming TLT, case 1"); } } - if (page_height > 0) - pdf->page_size.v = page_height; + if (page_height_par > 0) + pdf->page_size.v = page_height_par; else { - switch (page_direction) { + switch (page_direction_par) { case dir_TLT: case dir_TRT: - pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset; + pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset_par; break; case dir_LTL: case dir_RTT: - pdf->page_size.v = width(p) + 2 * page_top_offset; + pdf->page_size.v = width(p) + 2 * page_top_offset_par; break; default: - pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset; + pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset_par; normal_warning("pdf backend","bad page direction, assuming TLT, case 2"); } } @@ -193,27 +179,27 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode) Then shift |refpoint.pos| of the DVI origin depending on the |page_direction| within the upright (TLT) page coordinate system */ - switch (page_direction) { + switch (page_direction_par) { case dir_TLT: case dir_LTL: - refpoint.pos.h += h_offset; - refpoint.pos.v -= v_offset; + refpoint.pos.h += h_offset_par; + refpoint.pos.v -= v_offset_par; break; case dir_TRT: case dir_RTT: - refpoint.pos.h += pdf->page_size.h - page_right_offset - one_true_inch; - refpoint.pos.v -= v_offset; + refpoint.pos.h += pdf->page_size.h - page_right_offset_par - one_true_inch; + refpoint.pos.v -= v_offset_par; break; default: - refpoint.pos.h += h_offset; - refpoint.pos.v -= v_offset; + refpoint.pos.h += h_offset_par; + refpoint.pos.v -= v_offset_par; normal_warning("pdf backend","bad page direction, assuming TLT, case 3"); } /* Then switch to page box coordinate system; do |height(p)| movement, to get the location of the box origin. */ - pdf->posstruct->dir = page_direction; + pdf->posstruct->dir = page_direction_par; cur.h = 0; cur.v = height(p); synch_pos_with_cur(pdf->posstruct, &refpoint, cur); @@ -297,13 +283,13 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode) normal_error("pdf backend", "unknown output mode"); } DONE: - if ((tracing_output <= 0) && (post_callback_id == 0) && shipping_mode == SHIPPING_PAGE) { + if ((tracing_output_par <= 0) && (post_callback_id == 0) && shipping_mode == SHIPPING_PAGE) { print_char(']'); update_terminal(); } dead_cycles = 0; /* Flush the box from memory, showing statistics if requested */ - if ((tracing_stats > 1) && (pre_callback_id == 0)) { + if ((tracing_stats_par > 1) && (pre_callback_id == 0)) { tprint_nl("Memory usage before: "); print_int(var_used); print_char('&'); @@ -311,7 +297,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode) print_char(';'); } flush_node_list(p); - if ((tracing_stats > 1) && (post_callback_id == 0)) { + if ((tracing_stats_par > 1) && (post_callback_id == 0)) { tprint(" after: "); print_int(var_used); print_char('&'); @@ -321,7 +307,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode) if (shipping_mode == SHIPPING_PAGE && (post_callback_id > 0)) (void) run_callback(post_callback_id, "->"); /* Finish sheet {\sl Sync\TeX} information record */ - if (int_par(synctex_code)) + if (synctex_par) synctexteehs(); global_shipping_mode = NOT_SHIPPING; } diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h index 47dee7c6949..d36f6e611a9 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h +++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h @@ -99,6 +99,10 @@ depending on the object type; however it may be used as a counter as well. # define inf_pk_dpi 72 /* min PK pixel density value from \.{texmf.cnf} */ # define sup_pk_dpi 8000 /* max PK pixel density value from \.{texmf.cnf} */ +# define pdf2double(a) ((double) (a).m / ten_pow[(a).e]) + +# define by_one_bp ((double) 65536 * (double) 72.27 / 72) /* number of sp per 1bp */ + extern int find_obj(PDF pdf, int t, int i, boolean byname); extern void check_obj_exists(PDF pdf, int objnum); extern void check_obj_type(PDF pdf, int t, int objnum); diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w index b11e48c5fc0..6b3dd4b9432 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w @@ -21,10 +21,6 @@ #include "ptexlib.h" -@ @c -#define page_width dimen_par(page_width_code) -#define page_height dimen_par(page_height_code) - @ Threads are handled in similar way as link annotations @c void append_bead(PDF pdf, halfword p) @@ -168,8 +164,8 @@ void pdf_fix_thread(PDF pdf, int t) pdf_begin_array(pdf); pdf_add_int(pdf, 0); pdf_add_int(pdf, 0); - pdf_add_bp(pdf, page_width); - pdf_add_bp(pdf, page_height); + pdf_add_bp(pdf, page_width_par); + pdf_add_bp(pdf, page_height_par); pdf_end_array(pdf); pdf_end_dict(pdf); pdf_end_obj(pdf); diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h index f7f6e54d68f..64525d837ea 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h @@ -22,7 +22,7 @@ #ifndef PDFXFORM_H # define PDFXFORM_H -# define pdfmem_xform_size 8 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */ +# define pdfmem_xform_size 9 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */ # define obj_xform_width(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 0] # define obj_xform_height(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 1] @@ -32,6 +32,7 @@ # define obj_xform_resources(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 5] /* additional xform Resources */ # define obj_xform_attr_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 6] # define obj_xform_resources_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 7] +# define obj_xform_type(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 8] # define set_pdf_xform_objnum(A,B) pdf_xform_objnum(A)=B # define set_obj_xform_width(pdf,A,B) obj_xform_width(pdf,A)=B @@ -42,6 +43,7 @@ # define set_obj_xform_resources(pdf,A,B) obj_xform_resources(pdf,A)=B # define set_obj_xform_attr_str(pdf,A,B) obj_xform_attr_str(pdf,A)=B # define set_obj_xform_resources_str(pdf,A,B) obj_xform_resources_str(pdf,A)=B +# define set_obj_xform_type(pdf,A,B) obj_xform_type(pdf,A)=B extern int pdf_cur_form; /* the form being output */ diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w index 962acb0f031..4c83b024939 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w @@ -22,8 +22,6 @@ #include "pdf/pdfpage.h" @ @c -#define box(A) eqtb[box_base+(A)].hh.rh - int pdf_cur_form; /* the form being output */ void pdf_place_form(PDF pdf, halfword p) @@ -72,6 +70,12 @@ void scan_pdfxform(PDF pdf) pdf->xform_count++; k = pdf_create_obj(pdf, obj_type_xform, pdf->xform_count); set_obj_data_ptr(pdf, k, pdf_get_mem(pdf, pdfmem_xform_size)); + if (scan_keyword("type")) { + scan_int(); + set_obj_xform_type(pdf, k, cur_val); + } else { + set_obj_xform_type(pdf, k, 0); + } if (scan_keyword("attr")) { scan_toks(false, true); set_obj_xform_attr(pdf, k, def_ref); @@ -99,8 +103,6 @@ void scan_pdfxform(PDF pdf) } @ @c -#define tail cur_list.tail_field - void scan_pdfrefxform(PDF pdf) { scaled_whd alt_rule, dim, nat; @@ -116,8 +118,8 @@ void scan_pdfrefxform(PDF pdf) } else { dim = nat; } - width(tail) = dim.wd; - height(tail) = dim.ht; - depth(tail) = dim.dp; - rule_index(tail) = cur_val; + width(tail_par) = dim.wd; + height(tail_par) = dim.ht; + depth(tail_par) = dim.dp; + rule_index(tail_par) = cur_val; } diff --git a/Build/source/texk/web2c/luatexdir/ptexlib.h b/Build/source/texk/web2c/luatexdir/ptexlib.h index a70bcfb2d92..e71efae65f8 100644 --- a/Build/source/texk/web2c/luatexdir/ptexlib.h +++ b/Build/source/texk/web2c/luatexdir/ptexlib.h @@ -111,7 +111,7 @@ extern char **suffixlist; /* in luainit.w */ *p = 0; \ } while (0) -# define skip(p, c) if (*p == c) p++ +# define skip_char(p, c) if (*p == c) p++ # define alloc_array(T, n, s) do { \ if (T##_array == NULL) { \ diff --git a/Build/source/texk/web2c/luatexdir/tex/align.w b/Build/source/texk/web2c/luatexdir/tex/align.w index cd8086af301..dd0ed10338e 100644 --- a/Build/source/texk/web2c/luatexdir/tex/align.w +++ b/Build/source/texk/web2c/luatexdir/tex/align.w @@ -31,17 +31,6 @@ void init_col(void); #define noDEBUG -#define end_template_token (cs_token_flag+frozen_end_template) - -#define prev_depth cur_list.prev_depth_field -#define space_factor cur_list.space_factor_field -#define incompleat_noad cur_list.incompleat_noad_field - -#define every_cr equiv(every_cr_loc) -#define display_indent dimen_par(display_indent_code) -#define max_depth dimen_par(max_depth_code) -#define overfull_rule dimen_par(overfull_rule_code) - @ It's sort of a miracle whenever \.{\\halign} and \.{\\valign} work, because they cut across so many of the control structures of \TeX. @@ -177,10 +166,12 @@ is necessary to store information about what to do when a template ends. This information is called the |extra_info| field. @c -#define u_part(A) vlink((A)+depth_offset) /* pointer to \<u_j> token list */ -#define v_part(A) vinfo((A)+depth_offset) /* pointer to \<v_j> token list */ -#define span_ptr(A) vinfo((A)+1) /* column spanning list */ -#define extra_info(A) vinfo((A)+list_offset) /* info to remember during template */ +/* could be in texnodes.h, but documented here*/ + +#define u_part(A) vlink((A)+depth_offset) /* pointer to \<u_j> token list */ +#define v_part(A) vinfo((A)+depth_offset) /* pointer to \<v_j> token list */ +#define span_ptr(A) vinfo((A)+1) /* column spanning list */ +#define extra_info(A) vinfo((A)+list_offset) /* info to remember during template */ @ Alignments can occur within alignments, so a small stack is used to access the alignrecord information. At each level we have a |preamble| pointer, @@ -201,6 +192,8 @@ when they have to be pushed down, they are stored in 6-word nodes, and |align_ptr| points to the topmost such node. @c +/* could be in texnodes.h but documented here*/ + #define preamble vlink(align_head) /* the current preamble list */ pointer cur_align = null; /* current position in preamble list */ @@ -301,7 +294,7 @@ static void get_preamble_token(void) && (cur_chr == glue_base + tab_skip_code)) { scan_optional_equals(); scan_glue(glue_val_level); - if (int_par(global_defs_code) > 0) + if (global_defs_par > 0) geq_define(glue_base + tab_skip_code, glue_ref_cmd, cur_val); else eq_define(glue_base + tab_skip_code, glue_ref_cmd, cur_val); @@ -332,7 +325,7 @@ void init_align(void) if ((cur_list.mode_field == mmode) && ((cur_list.tail_field != cur_list.head_field) - || (incompleat_noad != null))) { + || (incompleat_noad_par != null))) { const char *hlp[] = { "Displays can use special alignments (like \\eqalignno)", "only if nothing but the alignment itself is between $$'s.", @@ -349,7 +342,7 @@ void init_align(void) correct baseline calculations. */ if (cur_list.mode_field == mmode) { cur_list.mode_field = -vmode; - prev_depth = nest[nest_ptr - 2].prev_depth_field; + prev_depth_par = nest[nest_ptr - 2].prev_depth_field; } else if (cur_list.mode_field > 0) { cur_list.mode_field = -(cur_list.mode_field); } @@ -445,8 +438,8 @@ void init_align(void) scanner_status = normal; new_save_level(align_group); - if (every_cr != null) - begin_token_list(every_cr, every_cr_text); + if (every_cr_par != null) + begin_token_list(every_cr_par, every_cr_text); align_peek(); /* look for \.{\\noalign} or \.{\\omit} */ } @@ -494,9 +487,9 @@ static void init_span(pointer p) { push_nest(); if (cur_list.mode_field == -hmode) { - space_factor = 1000; + space_factor_par = 1000; } else { - prev_depth = ignore_depth; + prev_depth_par = ignore_depth; normal_paragraph(); } cur_span = p; @@ -515,9 +508,9 @@ void init_row(void) push_nest(); cur_list.mode_field = (-hmode - vmode) - cur_list.mode_field; if (cur_list.mode_field == -hmode) - space_factor = 0; + space_factor_par = 0; else - prev_depth = 0; + prev_depth_par = 0; tail_append(new_glue(preamble)); subtype(cur_list.tail_field) = tab_skip_code + 1; cur_align = vlink(preamble); @@ -781,16 +774,16 @@ void fin_row(void) append_list(cur_head, cur_tail); } else { p = filtered_vpackage(vlink(cur_list.head_field), - 0, additional, max_depth, fin_row_group, -1, 0, 0); + 0, additional, max_depth_par, fin_row_group, -1, 0, 0); pop_nest(); vlink(cur_list.tail_field) = p; cur_list.tail_field = p; - space_factor = 1000; + space_factor_par = 1000; } type(p) = unset_node; glue_stretch(p) = 0; - if (every_cr != null) - begin_token_list(every_cr, every_cr_text); + if (every_cr_par != null) + begin_token_list(every_cr_par, every_cr_text); align_peek(); /* note that |glue_shrink(p)=0| since |glue_shrink==shift_amount| */ } @@ -817,7 +810,7 @@ void fin_align(void) confusion("align0"); unsave(); /* that |align_group| was for the whole alignment */ if (nest[nest_ptr - 1].mode_field == mmode) - o = display_indent; + o = display_indent_par; else o = 0; /* Go through the preamble list, determining the column widths and @@ -856,7 +849,7 @@ value is changed to zero and so is the next tabskip. /* Nullify |width(q)| and the tabskip glue following this column */ width(q) = 0; r = vlink(q); - reset_glue_to_zero(r); /* is a lready copy */ + reset_glue_to_zero(r); /* is a lready copy */ } if (span_ptr(q) != end_span) { /* Merge the widths in the span nodes of |q| with those of |p|, @@ -917,10 +910,10 @@ value is changed to zero and so is the next tabskip. decr(save_ptr); pack_begin_line = -cur_list.ml_field; if (cur_list.mode_field == -vmode) { - rule_save = overfull_rule; - overfull_rule = 0; /* prevent rule from being packaged */ + rule_save = overfull_rule_par; + overfull_rule_par = 0; /* prevent rule from being packaged */ p = hpack(preamble, saved_value(0), saved_level(0), -1); - overfull_rule = rule_save; + overfull_rule_par = rule_save; } else { q = vlink(preamble); do { @@ -929,7 +922,7 @@ value is changed to zero and so is the next tabskip. q = vlink(vlink(q)); } while (q != null); p = filtered_vpackage(preamble, - saved_value(0), saved_level(0), max_depth, preamble_group, -1, 0, 0); + saved_value(0), saved_level(0), max_depth_par, preamble_group, -1, 0, 0); q = vlink(preamble); do { width(q) = height(q); @@ -1120,14 +1113,14 @@ value is changed to zero and so is the next tabskip. we will need to insert glue before and after the display; that part of the program will be deferred until we're more familiar with such operations.) */ - pd = cur_list.prev_depth_field; + pd = prev_depth_par; p = vlink(cur_list.head_field); q = cur_list.tail_field; pop_nest(); if (cur_list.mode_field == mmode) { finish_display_alignment(p, q, pd); } else { - cur_list.prev_depth_field = pd; /* aux:=aux_save; */ + prev_depth_par = pd; /* aux:=aux_save; */ vlink(cur_list.tail_field) = p; if (p != null) cur_list.tail_field = q; diff --git a/Build/source/texk/web2c/luatexdir/tex/buildpage.w b/Build/source/texk/web2c/luatexdir/tex/buildpage.w index 104566f790b..c45d9cb7d7e 100644 --- a/Build/source/texk/web2c/luatexdir/tex/buildpage.w +++ b/Build/source/texk/web2c/luatexdir/tex/buildpage.w @@ -22,29 +22,9 @@ #include "ptexlib.h" @ @c -#define box(A) eqtb[box_base+(A)].hh.rh -#define count(A) eqtb[count_base+(A)].hh.rh -#undef skip -#define skip(A) eqtb[skip_base+(A)].hh.rh -#define dimen(A) eqtb[scaled_base+(A)].hh.rh - -#define vbadness int_par(vbadness_code) -#define max_dead_cycles int_par(max_dead_cycles_code) -#define output_box int_par(output_box_code) -#define holding_inserts int_par(holding_inserts_code) - -#define vsize dimen_par(vsize_code) -#define vfuzz dimen_par(vfuzz_code) -#define max_depth dimen_par(max_depth_code) - -#define output_routine equiv(output_routine_loc) -#define split_top_skip glue_par(split_top_skip_code) - -#define prev_depth cur_list.prev_depth_field -#define mode_line cur_list.ml_field -#define mode cur_list.mode_field -#define tail cur_list.tail_field -#define head cur_list.head_field +#define mode mode_par +#define head head_par +#define tail tail_par @ When \TeX\ appends new material to its main vlist in vertical mode, it uses a method something like |vsplit| to decide where a page ends, except that @@ -221,12 +201,12 @@ from |empty| to |inserts_only| or |box_there|. void freeze_page_specs(int s) { page_contents = s; - page_goal = vsize; - page_max_depth = max_depth; + page_goal = vsize_par; + page_max_depth = max_depth_par; page_depth = 0; do_all_six(set_page_so_far_zero); least_page_cost = awful_bad; - if (int_par(tracing_pages_code) > 0) { + if (tracing_pages_par > 0) { begin_diagnostic(); tprint_nl("%% goal height="); print_scaled(page_goal); @@ -360,7 +340,7 @@ void build_page(void) else page_contents = box_there; q = new_skip_param(top_skip_code); - if ((type(p) == hlist_node) && is_mirrored(body_direction)) { + if ((type(p) == hlist_node) && is_mirrored(body_direction_par)) { if (width(q) > depth(p)) width(q) = width(q) - depth(p); else @@ -378,7 +358,7 @@ void build_page(void) } else { /* Prepare to move a box or rule node to the current page, then |goto contribute| */ - if ((type(p) == hlist_node) && is_mirrored(body_direction)) { + if ((type(p) == hlist_node) && is_mirrored(body_direction_par)) { page_total = page_total + page_depth + depth(p); page_depth = height(p); } else { @@ -510,7 +490,7 @@ void build_page(void) w = dimen(n) - height(r); q = vert_break(ins_ptr(p), w, depth(p)); height(r) = height(r) + best_height_plus_depth; - if (int_par(tracing_pages_code) > 0) { + if (tracing_pages_par > 0) { /* Display the insertion split cost */ begin_diagnostic(); tprint_nl("% split"); @@ -582,7 +562,7 @@ void build_page(void) } if (insert_penalties >= 10000) c = awful_bad; - if (int_par(tracing_pages_code) > 0) { + if (tracing_pages_par > 0) { /* Display the page break cost */ begin_diagnostic(); tprint_nl("%"); @@ -670,7 +650,7 @@ void build_page(void) /* Recycle node |p| */ try_couple_nodes(contrib_head,vlink(p)); vlink(p) = null; - if (int_par(saving_vdiscards_code) > 0) { + if (saving_vdiscards_par > 0) { if (page_disc == null) { page_disc = p; } else { @@ -746,18 +726,18 @@ void fire_up(halfword c) if (c == best_page_break) best_page_break = null; /* |c| not yet linked in */ /* Ensure that box |output_box| is empty before output */ - if (box(output_box) != null) { + if (box(output_box_par) != null) { print_err("\\box"); - print_int(output_box); + print_int(output_box_par); tprint(" is not void"); help2("You shouldn't use \\box\\outputbox except in \\output routines.", "Proceed, and I'll discard its present contents."); - box_error(output_box); + box_error(output_box_par); } insert_penalties = 0; /* this will count the number of insertions held over */ - save_split_top_skip = split_top_skip; - if (holding_inserts <= 0) { + save_split_top_skip = split_top_skip_par; + if (holding_inserts_par <= 0) { /* Prepare all the boxes involved in insertions to act as queues */ /* If many insertions are supposed to go into the same box, we want to know the position of the last node in that box, so that we don't need to waste time @@ -787,7 +767,7 @@ void fire_up(halfword c) p = vlink(prev_p); while (p != best_page_break) { if (type(p) == ins_node) { - if (holding_inserts <= 0) { + if (holding_inserts_par <= 0) { /* Either insert the material specified by node |p| into the appropriate box, or hold it for the next page; also delete node |p| from the current page */ @@ -814,7 +794,7 @@ void fire_up(halfword c) while (vlink(s) != broken_ptr(r)) s = vlink(s); vlink(s) = null; - split_top_skip = split_top_ptr(p); + split_top_skip_par = split_top_ptr(p); ins_ptr(p) = prune_page_top(broken_ptr(r), false); if (ins_ptr(p) != null) { @@ -831,7 +811,7 @@ void fire_up(halfword c) t = list_ptr(box(n)); list_ptr(box(n)) = null; flush_node(box(n)); - box(n) = vpack(t, 0, additional, body_direction); + box(n) = vpack(t, 0, additional, body_direction_par); } else { while (vlink(s) != null) @@ -869,7 +849,7 @@ void fire_up(halfword c) prev_p = p; p = vlink(prev_p); } - split_top_skip = save_split_top_skip; + split_top_skip_par = save_split_top_skip; /* Break the current page at node |p|, put it in box~|output_box|, and put the remaining nodes on the contribution list */ /* When the following code is executed, the current page runs from node @@ -891,14 +871,14 @@ void fire_up(halfword c) couple_nodes(contrib_head, p); vlink(prev_p) = null; } - save_vbadness = vbadness; - vbadness = inf_bad; - save_vfuzz = vfuzz; - vfuzz = max_dimen; /* inhibit error messages */ - box(output_box) = filtered_vpackage(vlink(page_head), - best_size, exactly, page_max_depth, output_group, body_direction, 0, 0); - vbadness = save_vbadness; - vfuzz = save_vfuzz; + save_vbadness = vbadness_par; + vbadness_par = inf_bad; + save_vfuzz = vfuzz_par; + vfuzz_par = max_dimen; /* inhibit error messages */ + box(output_box_par) = filtered_vpackage(vlink(page_head), + best_size, exactly, page_max_depth, output_group, body_direction_par, 0, 0); + vbadness_par = save_vbadness; + vfuzz_par = save_vfuzz; if (last_glue != max_halfword) flush_node(last_glue); /* Start a new current page */ @@ -911,7 +891,7 @@ void fire_up(halfword c) /* Delete the page-insertion nodes */ r = vlink(page_ins_head); while (r != page_ins_head) { - /* todo: couple */ + /* todo: couple */ q = vlink(r); flush_node(r); r = q; @@ -924,8 +904,8 @@ void fire_up(halfword c) add_token_ref(top_mark(i)); } } - if (output_routine != null) { - if (dead_cycles >= max_dead_cycles) { + if (output_routine_par != null) { + if (dead_cycles >= max_dead_cycles_par) { /* Explain that too many dead cycles have occurred in a row */ print_err("Output loop---"); print_int(dead_cycles); @@ -941,9 +921,9 @@ void fire_up(halfword c) incr(dead_cycles); push_nest(); mode = -vmode; - prev_depth = ignore_depth; - mode_line = -line; - begin_token_list(output_routine, output_text); + prev_depth_par = ignore_depth; + mode_line_par = -line; + begin_token_list(output_routine_par, output_text); new_save_level(output_group); normal_paragraph(); scan_left_brace(); @@ -967,8 +947,8 @@ void fire_up(halfword c) } flush_node_list(page_disc); page_disc = null; - ship_out(static_pdf, box(output_box), SHIPPING_PAGE); - box(output_box) = null; + ship_out(static_pdf, box(output_box_par), SHIPPING_PAGE); + box(output_box_par) = null; } @ When the user's output routine finishes, it has constructed a vlist @@ -996,13 +976,13 @@ void resume_after_output(void) output_active = false; insert_penalties = 0; /* Ensure that box |output_box| is empty after output */ - if (box(output_box) != null) { + if (box(output_box_par) != null) { print_err("Output routine didn't use all of \\box"); - print_int(output_box); + print_int(output_box_par); help3("Your \\output commands should empty \\box\\outputbox,", "e.g., by saying `\\shipout\\box\\outputbox'.", "Proceed; I'll discard its present contents."); - box_error(output_box); + box_error(output_box_par); } if (tail != head) { /* current list goes after heldover insertions */ diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.h b/Build/source/texk/web2c/luatexdir/tex/commands.h index edaeb72fe28..fc61ffd46c8 100644 --- a/Build/source/texk/web2c/luatexdir/tex/commands.h +++ b/Build/source/texk/web2c/luatexdir/tex/commands.h @@ -161,6 +161,7 @@ typedef enum { assign_mu_glue_cmd, /* user-defined muglue ( \.{\\thinmuskip}, etc.~) */ assign_font_dimen_cmd, /* user-defined font dimension ( \.{\\fontdimen} ) */ assign_font_int_cmd, /* user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} ) */ + assign_hang_indent_cmd, set_aux_cmd, /* specify state info ( \.{\\spacefactor}, \.{\\prevdepth} ) */ set_prev_graf_cmd, /* specify state info ( \.{\\prevgraf} ) */ set_page_dimen_cmd, /* specify state info ( \.{\\pagegoal}, etc.~) */ @@ -326,11 +327,14 @@ typedef enum { expand_font_code, } normal_codes; -# define lp_code_base 2 -# define rp_code_base 3 -# define ef_code_base 4 -# define tag_code 5 -# define no_lig_code 6 +typedef enum { + lp_code_base = 2, + rp_code_base = 3, + ef_code_base = 4, + tag_code = 5, + no_lig_code = 6, + gp_code_base = 7 +} font_codes ; # define immediate_code 4 /* command modifier for \.{\\immediate} */ diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.w b/Build/source/texk/web2c/luatexdir/tex/commands.w index ece74a5406b..88211643533 100644 --- a/Build/source/texk/web2c/luatexdir/tex/commands.w +++ b/Build/source/texk/web2c/luatexdir/tex/commands.w @@ -689,6 +689,7 @@ void initialize_commands(void) primitive_luatex("pardir", assign_dir_cmd, int_base + par_direction_code, dir_base); primitive_luatex("textdir", assign_dir_cmd, int_base + text_direction_code, dir_base); primitive_luatex("mathdir", assign_dir_cmd, int_base + math_direction_code, dir_base); + primitive_luatex("linedir", assign_dir_cmd, int_base + line_direction_code, dir_base); primitive_luatex("pageleftoffset", assign_dimen_cmd, dimen_base + page_left_offset_code, dimen_base); primitive_luatex("pagetopoffset", assign_dimen_cmd, dimen_base + page_top_offset_code, dimen_base); primitive_luatex("pagerightoffset", assign_dimen_cmd, dimen_base + page_right_offset_code, dimen_base); @@ -767,6 +768,9 @@ void initialize_etex_commands(void) primitive_etex("parshapeindent", last_item_cmd, par_shape_indent_code, 0); primitive_etex("parshapedimen", last_item_cmd, par_shape_dimen_code, 0); + primitive_luatex("shapemode", assign_int_cmd, int_base + shape_mode_code, int_base); + primitive_luatex("hyphenationbounds", assign_int_cmd, int_base + hyphenation_bounds_code, int_base); + primitive_etex("showgroups", xray_cmd, show_groups, 0); /* diff --git a/Build/source/texk/web2c/luatexdir/tex/conditional.w b/Build/source/texk/web2c/luatexdir/tex/conditional.w index fa4e73b49cb..268786add75 100644 --- a/Build/source/texk/web2c/luatexdir/tex/conditional.w +++ b/Build/source/texk/web2c/luatexdir/tex/conditional.w @@ -21,9 +21,6 @@ #include "ptexlib.h" -@ @c -#define box(A) eqtb[box_base+(A)].hh.rh - @* We consider now the way \TeX\ handles various kinds of \.{\\if} commands. @ Conditions can be inside conditions, and this nesting has a stack @@ -79,7 +76,7 @@ void pass_text(void) } } scanner_status = save_scanner_status; - if (int_par(tracing_ifs_code) > 0) + if (tracing_ifs_par > 0) show_cur_cmd_chr(); } @@ -163,7 +160,7 @@ static boolean test_for_cs(void) } if (cur_cmd != end_cs_name_cmd) { last_tested_cs = null_cs; - if (int_par(suppress_ifcsname_error_code)) { + if (suppress_ifcsname_error_par) { do { get_x_token(); } while (cur_cmd != end_cs_name_cmd); @@ -241,7 +238,7 @@ void conditional(void) halfword save_cond_ptr; /*|cond_ptr| corresponding to this conditional */ int this_if; /*type of this conditional */ boolean is_unless; /*was this if preceded by `\.{\\unless}' ? */ - if ((int_par(tracing_ifs_code) > 0) && (int_par(tracing_commands_code) <= 1)) + if ((tracing_ifs_par > 0) && (tracing_commands_par <= 1)) show_cur_cmd_chr(); push_condition_stack(); save_cond_ptr = cond_ptr; @@ -441,7 +438,7 @@ void conditional(void) scan_int(); /* |n| is the number of cases to pass */ n = cur_val; - if (int_par(tracing_commands_code) > 1) { + if (tracing_commands_par > 1) { begin_diagnostic(); tprint("{case "); print_int(n); @@ -508,7 +505,7 @@ void conditional(void) } if (is_unless) b = !b; - if (int_par(tracing_commands_code) > 1) { + if (tracing_commands_par > 1) { /* Display the value of |b| */ begin_diagnostic(); if (b) diff --git a/Build/source/texk/web2c/luatexdir/tex/dumpdata.w b/Build/source/texk/web2c/luatexdir/tex/dumpdata.w index 993ad8a16c0..ae769584381 100644 --- a/Build/source/texk/web2c/luatexdir/tex/dumpdata.w +++ b/Build/source/texk/web2c/luatexdir/tex/dumpdata.w @@ -19,15 +19,11 @@ @ @c - #include "ptexlib.h" -#define font_id_text(A) cs_text(font_id_base+(A)) -#define prev_depth cur_list.prev_depth_field - /* we start with 907: the sum of the values of the bytes of "don knuth" */ -#define FORMAT_ID (907+15) +#define FORMAT_ID (907+17) #if ((FORMAT_ID>=0) && (FORMAT_ID<=256)) #error Wrong value for FORMAT_ID. #endif @@ -91,11 +87,11 @@ void store_fmt_file(void) tprint(" (format="); print(job_name); print_char(' '); - print_int(int_par(year_code)); + print_int(year_par); print_char('.'); - print_int(int_par(month_code)); + print_int(month_par); print_char('.'); - print_int(int_par(day_code)); + print_int(day_par); print_char(')'); str_room(2); format_ident = make_string(); @@ -308,7 +304,7 @@ void store_fmt_file(void) dump_int(69069); /* We have already printed a lot of statistics, so we set |tracing_stats:=0| to prevent them from appearing again. */ - int_par(tracing_stats_code) = 0; + tracing_stats_par = 0; /* Dump the lua bytecodes */ dump_luac_registers(); @@ -520,7 +516,7 @@ boolean load_fmt_file(const char *fmtname) /* Undump the lua bytecodes */ undump_luac_registers(); - prev_depth = ignore_depth; + prev_depth_par = ignore_depth; return true; /* it worked! */ BAD_FMT: wake_up_terminal(); diff --git a/Build/source/texk/web2c/luatexdir/tex/equivalents.h b/Build/source/texk/web2c/luatexdir/tex/equivalents.h index 1289ab70cba..7f83dd3d6cc 100644 --- a/Build/source/texk/web2c/luatexdir/tex/equivalents.h +++ b/Build/source/texk/web2c/luatexdir/tex/equivalents.h @@ -279,23 +279,26 @@ the |number_regs| \.{\\dimen} registers. # define math_display_skip_mode_code 88 # define math_scripts_mode_code 89 # define synctex_code 90 /* is synctex file generation enabled ? */ -# define first_valid_language_code 91 +# define shape_mode_code 91 +# define first_valid_language_code 92 +# define hyphenation_bounds_code 93 -# define math_option_code 92 +# define math_option_code 94 -# define mathoption_int_base (int_base+93) -# define mathoption_int_last (int_base+99) +# define mathoption_int_base (int_base+95) /* one reserve */ +# define mathoption_int_last (int_base+100) -# define backend_int_base (int_base+100) -# define backend_int_last (int_base+124) +# define backend_int_base (int_base+101) +# define backend_int_last (int_base+125) -# define tex_int_pars (125) /* total number of integer parameters */ +# define tex_int_pars (126) /* total number of integer parameters */ # define page_direction_code (tex_int_pars) # define body_direction_code (tex_int_pars+1) # define par_direction_code (tex_int_pars+2) # define text_direction_code (tex_int_pars+3) # define math_direction_code (tex_int_pars+4) +# define line_direction_code (tex_int_pars+5) /* gets remapped so is no real register */ # define int_pars (tex_int_pars+5) /* total number of integer parameters */ @@ -533,16 +536,248 @@ extern void show_eqtb(halfword n); extern halfword last_cs_name; -/* more will move here */ +/* + The *_par macros expand to the variables that are (in most cases) also accessible + at the users end. Most are registers but some are in the (stack) lists. + + More *_par will move here : there is no real need for thse macros but because there + were already a bunch and because they were defined all over the place we moved them + here. + +*/ -#define space_skip glue_par(space_skip_code) -#define xspace_skip glue_par(xspace_skip_code) -#define math_skip glue_par(math_skip_code) +#define space_skip_par glue_par(space_skip_code) +#define xspace_skip_par glue_par(xspace_skip_code) +#define math_skip_par glue_par(math_skip_code) + +#define pre_display_size_par dimen_par(pre_display_size_code) +#define display_width_par dimen_par(display_width_code) +#define display_indent_par dimen_par(display_indent_code) +#define math_surround_par dimen_par(math_surround_code) + +#define display_skip_mode_par int_par(math_display_skip_mode_code) +#define math_eqno_gap_step_par int_par(math_eqno_gap_step_code) + +#define body_direction_par int_par(body_direction_code) +#define page_direction_par int_par(page_direction_code) +#define par_direction_par int_par(par_direction_code) +#define text_direction_par int_par(text_direction_code) +#define math_direction_par int_par(math_direction_code) + +#define shape_mode_par int_par(shape_mode_code) +#define hyphenation_bounds_par int_par(hyphenation_bounds_code) +#define first_valid_language_par int_par(first_valid_language_code) + +#define hsize_par dimen_par(hsize_code) +#define vsize_par dimen_par(vsize_code) +#define hfuzz_par dimen_par(hfuzz_code) +#define vfuzz_par dimen_par(vfuzz_code) +#define hbadness_par int_par(hbadness_code) +#define vbadness_par int_par(vbadness_code) + +#define baseline_skip_par glue_par(baseline_skip_code) +#define par_indent_par dimen_par(par_indent_code) +#define hang_indent_par dimen_par(hang_indent_code) +#define hang_after_par int_par(hang_after_code) +#define left_skip_par glue_par(left_skip_code) +#define right_skip_par glue_par(right_skip_code) + +#define emergency_stretch_par dimen_par(emergency_stretch_code) +#define pretolerance_par int_par(pretolerance_code) +#define tolerance_par int_par(tolerance_code) +#define looseness_par int_par(looseness_code) +#define adjust_spacing_par int_par(adjust_spacing_code) +#define adj_demerits_par int_par(adj_demerits_code) +#define protrude_chars_par int_par(protrude_chars_code) +#define line_penalty_par int_par(line_penalty_code) +#define last_line_fit_par int_par(last_line_fit_code) +#define double_hyphen_demerits_par int_par(double_hyphen_demerits_code) +#define final_hyphen_demerits_par int_par(final_hyphen_demerits_code) +#define inter_line_penalty_par int_par(inter_line_penalty_code) +#define club_penalty_par int_par(club_penalty_code) +#define broken_penalty_par int_par(broken_penalty_code) +#define display_widow_penalty_par int_par(display_widow_penalty_code) +#define widow_penalty_par int_par(widow_penalty_code) +#define line_skip_limit_par dimen_par(line_skip_limit_code) + +#define delimiter_shortfall_par dimen_par(delimiter_shortfall_code) +#define null_delimiter_space_par dimen_par(null_delimiter_space_code) +#define script_space_par dimen_par(script_space_code) +#define max_depth_par dimen_par(max_depth_code) +#define box_max_depth_par dimen_par(box_max_depth_code) +#define split_max_depth_par dimen_par(split_max_depth_code) +#define overfull_rule_par dimen_par(overfull_rule_code) +#define box_max_depth_par dimen_par(box_max_depth_code) +#define top_skip_par glue_par(top_skip_code) +#define split_top_skip_par glue_par(split_top_skip_code) + +#define cur_fam_par int_par(cur_fam_code) +#define pre_display_direction_par int_par(pre_display_direction_code) +#define pre_display_penalty_par int_par(pre_display_penalty_code) +#define post_display_penalty_par int_par(post_display_penalty_code) + +#define cur_fam_par_in_range ((cur_fam_par>=0)&&(cur_fam_par<256)) + +#define local_inter_line_penalty_par int_par(local_inter_line_penalty_code) +#define local_broken_penalty_par int_par(local_broken_penalty_code) +#define local_left_box_par equiv(local_left_box_base) +#define local_right_box_par equiv(local_right_box_base) + +#define end_line_char_par int_par(end_line_char_code) +#define new_line_char_par int_par(new_line_char_code) +#define escape_char_par int_par(escape_char_code) + +#define end_line_char_inactive ((end_line_char_par < 0) || (end_line_char_par > 127)) + +#define delimiter_factor_par int_par(delimiter_factor_code) +#define bin_op_penalty_par int_par(bin_op_penalty_code) +#define rel_penalty_par int_par(rel_penalty_code) +#define null_delimiter_space_par dimen_par(null_delimiter_space_code) +#define disable_lig_par int_par(disable_lig_code) +#define disable_kern_par int_par(disable_kern_code) +#define disable_space_par int_par(disable_space_code) +#define scripts_mode_par int_par(math_scripts_mode_code) + +#define thin_mu_skip_par glue_par(thin_mu_skip_code) +#define med_mu_skip_par glue_par(med_mu_skip_code) +#define thick_mu_skip_par glue_par(thick_mu_skip_code) + +#define every_math_par equiv(every_math_loc) +#define every_display_par equiv(every_display_loc) +#define every_cr_par equiv(every_cr_loc) +#define every_hbox_par equiv(every_hbox_loc) +#define every_vbox_par equiv(every_vbox_loc) +#define every_eof_par equiv(every_eof_loc) +#define every_par_par equiv(every_par_loc) +#define err_help_par equiv(err_help_loc) + +#define no_local_whatsits_par int_par(no_local_whatsits_code) +#define no_local_dirs_par int_par(no_local_dirs_code) + +#define prev_depth_par cur_list.prev_depth_field +#define prev_graf_par cur_list.pg_field +#define tail_par cur_list.tail_field +#define head_par cur_list.head_field +#define mode_par cur_list.mode_field +#define dirs_par cur_list.dirs_field +#define space_factor_par cur_list.space_factor_field +#define incompleat_noad_par cur_list.incompleat_noad_field +#define mode_line_par cur_list.ml_field +#define aux_par cur_list.eTeX_aux_field +#define delim_par aux_par + +#define par_shape_par_ptr equiv(par_shape_loc) +#define inter_line_penalties_par_ptr equiv(inter_line_penalties_loc) +#define club_penalties_par_ptr equiv(club_penalties_loc) +#define widow_penalties_par_ptr equiv(widow_penalties_loc) +#define display_widow_penalties_par_ptr equiv(display_widow_penalties_loc) + +#define page_width_par dimen_par(page_width_code) +#define page_height_par dimen_par(page_height_code) +#define h_offset_par dimen_par(h_offset_code) +#define v_offset_par dimen_par(v_offset_code) +#define page_left_offset_par dimen_par(page_left_offset_code) +#define page_top_offset_par dimen_par(page_top_offset_code) +#define page_right_offset_par dimen_par(page_right_offset_code) +#define page_bottom_offset_par dimen_par(page_bottom_offset_code) +#define px_dimen_par dimen_par(px_dimen_code) + +#define max_dead_cycles_par int_par(max_dead_cycles_code) +#define output_box_par int_par(output_box_code) +#define holding_inserts_par int_par(holding_inserts_code) +#define output_routine_par equiv(output_routine_loc) +#define floating_penalty_par int_par(floating_penalty_code) + +#define mag_par int_par(mag_code) + +#define global_defs_par int_par(global_defs_code) +#define cat_code_table_par int_par(cat_code_table_code) +#define saving_vdiscards_par int_par(saving_vdiscards_code) + +#define tracing_output_par int_par(tracing_output_code) +#define tracing_stats_par int_par(tracing_stats_code) +#define tracing_online_par int_par(tracing_online_code) +#define tracing_paragraphs_par int_par(tracing_paragraphs_code) +#define tracing_nesting_par int_par(tracing_nesting_code) +#define tracing_lost_chars_par int_par(tracing_lost_chars_code) +#define tracing_scan_tokens_par int_par(tracing_scan_tokens_code) +#define tracing_ifs_par int_par(tracing_ifs_code) +#define tracing_commands_par int_par(tracing_commands_code) +#define tracing_macros_par int_par(tracing_macros_code) +#define tracing_assigns_par int_par(tracing_assigns_code) +#define tracing_fonts_par int_par(tracing_fonts_code) +#define tracing_pages_par int_par(tracing_pages_code) +#define tracing_restores_par int_par(tracing_restores_code) +#define tracing_groups_par int_par(tracing_groups_code) + +#define show_box_depth_par int_par(show_box_depth_code) +#define show_box_breadth_par int_par(show_box_breadth_code) + +#define pausing_par int_par(pausing_code) + +#define suppress_outer_error_par int_par(suppress_outer_error_code) +#define suppress_long_error_par int_par(suppress_long_error_code) +#define suppress_mathpar_error_par int_par(suppress_mathpar_error_code) +#define suppress_fontnotfound_error_par int_par(suppress_fontnotfound_error_code) +#define suppress_ifcsname_error_par int_par(suppress_ifcsname_error_code) +#define error_context_lines_par int_par(error_context_lines_code) + +#define math_old_par mathoption_int_par(c_mathoption_old_code) +#define math_no_italic_compensation_par mathoption_int_par(c_mathoption_no_italic_compensation_code) +#define math_no_char_italic_par mathoption_int_par(c_mathoption_no_char_italic_code) +#define math_use_old_fraction_scaling_par mathoption_int_par(c_mathoption_use_old_fraction_scaling_code) +#define math_umathcode_meaning_par mathoption_int_par(c_mathoption_umathcode_meaning_code) + +#define time_par int_par(time_code) +#define day_par int_par(day_code) +#define month_par int_par(month_code) +#define year_par int_par(year_code) + +#define output_mode_par int_par(output_mode_code) +#define draft_mode_par int_par(draft_mode_code) +#define synctex_par int_par(synctex_code) + +#define language_par int_par(language_code) +#define uc_hyph_par int_par(uc_hyph_code) +#define left_hyphen_min_par int_par(left_hyphen_min_code) +#define right_hyphen_min_par int_par(right_hyphen_min_code) +#define ex_hyphen_char_par int_par(ex_hyphen_char_code) +#define hyphen_penalty_par int_par(hyphen_penalty_code) +#define ex_hyphen_penalty_par int_par(ex_hyphen_penalty_code) +#define default_hyphen_char_par int_par(default_hyphen_char_code) +#define default_skew_char_par int_par(default_skew_char_code) +#define saving_hyph_codes_par int_par(saving_hyph_codes_code) + +#define cur_lang_par int_par(cur_lang_code) +#define cur_font_par equiv(cur_font_loc) + +/* */ + +#define math_use_current_family_code 7 + +/* + #define box(A) equiv(box_base+(A)) + #define box(A) eqtb[box_base+(A)].hh.rh +*/ -#define body_direction int_par(body_direction_code) -#define page_direction int_par(page_direction_code) -#define par_direction int_par(par_direction_code) -#define text_direction int_par(text_direction_code) -#define math_direction int_par(math_direction_code) +#define attribute(A) equiv(attribute_base+(A)) +#define box(A) equiv(box_base+(A)) +#define count(A) equiv(count_base+(A)) +#define dimen(A) equiv(scaled_base+(A)) +#define mu_skip(A) equiv(mu_skip_base+(A)) +#define skip(A) equiv(skip_base+(A)) +#define toks(A) equiv(toks_base+(A)) + +#define get_tex_attribute_register(j) attribute(j) +#define get_tex_box_register(j) box(j) +#define get_tex_count_register(j) count(j) +#define get_tex_dimen_register(j) dimen(j) +#define get_tex_mu_skip_register(j) mu_skip(j) +#define get_tex_skip_register(j) skip(j) + +#define font_id_text(A) cs_text(font_id_base+(A)) + +#define end_template_token (cs_token_flag+frozen_end_template) +#define end_write_token (cs_token_flag+end_write) #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/equivalents.w b/Build/source/texk/web2c/luatexdir/tex/equivalents.w index cc709c1bd7e..271fc67ffbd 100644 --- a/Build/source/texk/web2c/luatexdir/tex/equivalents.w +++ b/Build/source/texk/web2c/luatexdir/tex/equivalents.w @@ -37,8 +37,6 @@ static void diagnostic_trace(halfword p, const char *s) } @ @c -#define par_shape_ptr equiv(par_shape_loc) - void show_eqtb_meaning(halfword n); /* forward */ @ Now that we have studied the data structures for \TeX's semantic routines, @@ -216,7 +214,7 @@ void new_save_level(group_code c) /* quit if |(cur_level+1)| is too big to be stored in |eqtb| */ cur_boundary = save_ptr; cur_group = c; - if (int_par(tracing_groups_code) > 0) + if (tracing_groups_par > 0) group_trace(false); incr(cur_level); incr(save_ptr); @@ -627,7 +625,7 @@ the call, since |eq_save| makes the necessary test. @c void eq_define(halfword p, quarterword t, halfword e) { - boolean trace = int_par(tracing_assigns_code) > 0; + boolean trace = tracing_assigns_par > 0; if ((eq_type(p) == t) && (equiv(p) == e)) { if (trace) diagnostic_trace(p, "reassigning"); @@ -654,7 +652,7 @@ void eq_define(halfword p, quarterword t, halfword e) @c void eq_word_define(halfword p, int w) { - boolean trace = int_par(tracing_assigns_code) > 0; + boolean trace = tracing_assigns_par > 0; if (eqtb[p].cint == w) { if (trace) diagnostic_trace(p, "reassigning"); @@ -680,7 +678,7 @@ to save old values, and the new value is associated with |level_one|. @c void geq_define(halfword p, quarterword t, halfword e) { /* global |eq_define| */ - boolean trace = int_par(tracing_assigns_code) > 0; + boolean trace = tracing_assigns_par > 0; if (trace) diagnostic_trace(p, "globally changing"); eq_destroy(eqtb[p]); @@ -693,7 +691,7 @@ void geq_define(halfword p, quarterword t, halfword e) void geq_word_define(halfword p, int w) { /* global |eq_word_define| */ - boolean trace = int_par(tracing_assigns_code) > 0; + boolean trace = tracing_assigns_par > 0; if (trace) diagnostic_trace(p, "globally changing"); eqtb[p].cint = w; @@ -727,11 +725,11 @@ void unsave(void) quarterword l = level_one; /* saved level, if in fullword regions of |eqtb| */ boolean a = false; /* have we already processed an \.{\\aftergroup} ? */ unsave_math_codes(cur_level); - unsave_cat_codes(int_par(cat_code_table_code), cur_level); + unsave_cat_codes(cat_code_table_par, cur_level); unsave_text_codes(cur_level); unsave_math_data(cur_level); if (cur_level > level_one) { - boolean trace = int_par(tracing_restores_code) > 0; + boolean trace = tracing_restores_par > 0; decr(cur_level); /* Clear off top level from |save_stack| */ while (true) { @@ -778,7 +776,7 @@ void unsave(void) } } } - if (int_par(tracing_groups_code) > 0) + if (tracing_groups_par > 0) group_trace(true); if (grp_stack[in_open] == cur_boundary) group_warning(); /* groups possibly not properly nested with files */ @@ -798,19 +796,17 @@ entire run. The global variable |mag_set| is set to the current magnification whenever it becomes necessary to ``freeze'' it at a particular value. @c -int mag_set; /* if nonzero, this magnification should be used henceforth */ +int mag_set = 0; /* if nonzero, this magnification should be used henceforth */ @ The |prepare_mag| subroutine is called whenever \TeX\ wants to use |mag| for magnification. @c -#define mag int_par(mag_code) - void prepare_mag(void) { - if ((mag_set > 0) && (mag != mag_set)) { + if ((mag_set > 0) && (mag_par != mag_set)) { print_err("Incompatible magnification ("); - print_int(mag); + print_int(mag_par); tprint(");"); tprint_nl(" the previous value will be retained"); help2("I can handle only one magnification ratio per job. So I've", @@ -818,19 +814,19 @@ void prepare_mag(void) int_error(mag_set); geq_word_define(int_base + mag_code, mag_set); /* |mag:=mag_set| */ } - if ((mag <= 0) || (mag > 32768)) { + if ((mag_par <= 0) || (mag_par > 32768)) { print_err("Illegal magnification has been changed to 1000"); help1("The magnification ratio must be between 1 and 32768."); - int_error(mag); + int_error(mag_par); geq_word_define(int_base + mag_code, 1000); } - if ((mag_set == 0) && (mag != mag_set)) { - if (mag != 1000) - one_true_inch = xn_over_d(one_hundred_inch, 10, mag); + if ((mag_set == 0) && (mag_par != mag_set)) { + if (mag_par != 1000) + one_true_inch = xn_over_d(one_hundred_inch, 10, mag_par); else one_true_inch = one_inch; } - mag_set = mag; + mag_set = mag_par; } @ Let's pause a moment now and try to look at the Big Picture. @@ -888,8 +884,6 @@ halfword cur_tok; /* packed representative of |cur_cmd| and |cur_c @ Here is a procedure that displays the current command. @c -#define mode cur_list.mode_field - void show_cur_cmd_chr(void) { int n; /* level of \.{\\if...\\fi} nesting */ @@ -897,13 +891,13 @@ void show_cur_cmd_chr(void) halfword p; begin_diagnostic(); tprint_nl("{"); - if (mode != shown_mode) { - print_mode(mode); + if (mode_par != shown_mode) { + print_mode(mode_par); tprint(": "); - shown_mode = mode; + shown_mode = mode_par; } print_cmd_chr((quarterword) cur_cmd, cur_chr); - if (int_par(tracing_ifs_code) > 0) { + if (tracing_ifs_par > 0) { if (cur_cmd >= if_test_cmd) { if (cur_cmd <= fi_or_else_cmd) { tprint(": "); @@ -1013,7 +1007,7 @@ void show_eqtb(halfword n) if (penalty(equiv(n)) > 1) tprint_esc("ETC."); } else { - print_int(vinfo(par_shape_ptr + 1)); + print_int(vinfo(par_shape_par_ptr + 1)); } } else if (n < toks_base) { print_cmd_chr(assign_toks_cmd, n); diff --git a/Build/source/texk/web2c/luatexdir/tex/errors.w b/Build/source/texk/web2c/luatexdir/tex/errors.w index d981f9fee4f..4cad07c6f28 100644 --- a/Build/source/texk/web2c/luatexdir/tex/errors.w +++ b/Build/source/texk/web2c/luatexdir/tex/errors.w @@ -25,9 +25,6 @@ luafflib.c @ @c #include "ptexlib.h" -@ @c -#define new_line_char int_par(new_line_char_code) - @ When something anomalous is detected, \TeX\ typically does something like this: $$\vbox{\halign{#\hfil\cr |print_err("Something anomalous has been detected");|\cr @@ -72,9 +69,9 @@ void set_last_error_context(void) int saved_new_line_char; int saved_new_string_line; selector = new_string; - saved_new_line_char = new_line_char; + saved_new_line_char = new_line_char_par; saved_new_string_line = new_string_line; - new_line_char = 10; + new_line_char_par = 10; new_string_line = 10; show_context(); xfree(last_error_context); @@ -82,7 +79,7 @@ void set_last_error_context(void) last_error_context = makecstring(str); flush_str(str); selector = sel; - new_line_char = saved_new_line_char; + new_line_char_par = saved_new_line_char; new_string_line = saved_new_string_line; return; } @@ -511,6 +508,11 @@ void overflow(const char *s, unsigned int n) print_char('='); print_int((int) n); print_char(']'); + if (varmem == NULL) { + print_err("Sorry, I ran out of memory."); + print_ln(); + exit(EXIT_FAILURE); + } help2("If you really absolutely need more capacity,", "you can ask a wizard to enlarge me."); succumb(); @@ -629,10 +631,10 @@ void char_warning(internal_font_number f, int c) { int old_setting; /* saved value of |tracing_online| */ int k; /* index to current digit; we assume that $0\L n<16^{22}$ */ - if (int_par(tracing_lost_chars_code) > 0) { - old_setting = int_par(tracing_online_code); - if (int_par(tracing_lost_chars_code) > 1) - int_par(tracing_online_code) = 1; + if (tracing_lost_chars_par > 0) { + old_setting = tracing_online_par; + if (tracing_lost_chars_par > 1) + tracing_online_par = 1; begin_diagnostic(); tprint_nl("Missing character: There is no "); print(c); @@ -654,7 +656,7 @@ void char_warning(internal_font_number f, int c) print_font_name(f); print_char('!'); end_diagnostic(false); - int_par(tracing_online_code) = old_setting; + tracing_online_par = old_setting; } } @@ -737,8 +739,8 @@ void normal_warning(const char *t, const char *p) int report_id ; if (strcmp(t,"lua") == 0) { int saved_new_line_char; - saved_new_line_char = new_line_char; - new_line_char = 10; + saved_new_line_char = new_line_char_par; + new_line_char_par = 10; report_id = callback_defined(show_lua_error_hook_callback); if (report_id == 0) { tprint(p); @@ -748,7 +750,7 @@ void normal_warning(const char *t, const char *p) (void) run_callback(report_id, "->"); } error(); - new_line_char = saved_new_line_char; + new_line_char_par = saved_new_line_char; } else { report_id = callback_defined(show_warning_message_callback); if (report_id > 0) { diff --git a/Build/source/texk/web2c/luatexdir/tex/expand.w b/Build/source/texk/web2c/luatexdir/tex/expand.w index 46c8622b491..731345eb66e 100644 --- a/Build/source/texk/web2c/luatexdir/tex/expand.w +++ b/Build/source/texk/web2c/luatexdir/tex/expand.w @@ -80,7 +80,7 @@ void expand(void) RESWITCH: if (cur_cmd < call_cmd) { /* Expand a nonmacro */ - if (int_par(tracing_commands_code) > 1) + if (tracing_commands_par > 1) show_cur_cmd_chr(); switch (cur_cmd) { case top_bot_mark_cmd: @@ -247,8 +247,8 @@ void expand(void) code, which is actually part of |expand|. It comes into play when \.{\\or}, \.{\\else}, or \.{\\fi} is scanned. */ - if (int_par(tracing_ifs_code) > 0) - if (int_par(tracing_commands_code) <= 1) + if (tracing_ifs_par > 0) + if (tracing_commands_par <= 1) show_cur_cmd_chr(); if (cur_chr > if_limit) { if (if_limit == if_code) { @@ -554,7 +554,7 @@ void macro_call(void) warning_index = cur_cs; ref_count = cur_chr; r = token_link(ref_count); - if (int_par(tracing_macros_code) > 0) { + if (tracing_macros_par > 0) { /* Show the text of the macro being expanded */ begin_diagnostic(); print_ln(); @@ -686,7 +686,7 @@ void macro_call(void) if (cur_tok == par_token) if (long_state != long_call_cmd) - if (!int_par(suppress_long_error_code)) { + if (!suppress_long_error_par) { goto RUNAWAY; } if (cur_tok < right_brace_limit) { @@ -698,7 +698,7 @@ void macro_call(void) get_token(); if (cur_tok == par_token) { if (long_state != long_call_cmd) { - if (!int_par(suppress_long_error_code)) { + if (!suppress_long_error_par) { goto RUNAWAY; } @@ -768,7 +768,7 @@ void macro_call(void) pstack[n] = token_link(temp_token_head); } incr(n); - if (int_par(tracing_macros_code) > 0) { + if (tracing_macros_par > 0) { begin_diagnostic(); print_nl(match_chr); print_int(n); diff --git a/Build/source/texk/web2c/luatexdir/tex/extensions.w b/Build/source/texk/web2c/luatexdir/tex/extensions.w index f787e936092..feff6e38277 100644 --- a/Build/source/texk/web2c/luatexdir/tex/extensions.w +++ b/Build/source/texk/web2c/luatexdir/tex/extensions.w @@ -24,18 +24,10 @@ #include "ptexlib.h" @ @c -#define mode cur_list.mode_field -#define tail cur_list.tail_field -#define head cur_list.head_field -#define prev_graf cur_list.pg_field -#define dir_save cur_list.dirs_field - -#define tracing_nesting int_par(tracing_nesting_code) -#define tracing_online int_par(tracing_online_code) -#define box(A) eqtb[box_base+(A)].hh.rh -#define global_defs int_par(global_defs_code) -#define cat_code_table int_par(cat_code_table_code) -#define toks(A) equiv(toks_base+(A)) +#define mode mode_par +#define tail tail_par +#define head head_par +#define dir_save dirs_par @ The program above includes a bunch of ``hooks'' that allow further capabilities to be added without upsetting \TeX's basic structure. @@ -477,8 +469,6 @@ above.) If it were not removed, and if there were numerous writes on a single page, the stack would overflow. @c -#define end_write_token cs_token_flag+end_write - void expand_macros_in_tokenlist(halfword p) { int old_mode; @@ -741,7 +731,7 @@ void group_warning(void) /* Set variable |w| to indicate if this case should be reported */ /* This code scans the input stack in order to determine the type of the current input file. */ - if (tracing_nesting > 0) { + if (tracing_nesting_par > 0) { while ((input_stack[base_ptr].state_field == token_list) || (input_stack[base_ptr].index_field > i)) decr(base_ptr); @@ -757,7 +747,7 @@ void group_warning(void) print_group(true); tprint(" of a different file"); print_ln(); - if (tracing_nesting > 1) + if (tracing_nesting_par > 1) show_context(); if (history == spotless) history = warning_issued; @@ -778,7 +768,7 @@ void if_warning(void) input_stack[base_ptr] = cur_input; /* store current state */ while (if_stack[i] == cond_ptr) { /* Set variable |w| to... */ - if (tracing_nesting > 0) { + if (tracing_nesting_par > 0) { while ((input_stack[base_ptr].state_field == token_list) || (input_stack[base_ptr].index_field > i)) decr(base_ptr); @@ -795,7 +785,7 @@ void if_warning(void) print_if_line(if_line); tprint(" of a different file"); print_ln(); - if (tracing_nesting > 1) + if (tracing_nesting_par > 1) show_context(); if (history == spotless) history = warning_issued; @@ -847,7 +837,7 @@ void file_warning(void) cur_if = c; if_line = i; /* restore old values */ print_ln(); - if (tracing_nesting > 1) + if (tracing_nesting_par > 1) show_context(); if (history == spotless) history = warning_issued; @@ -862,9 +852,6 @@ internal stuff has to be accessed from C directly, where lots of the defines are not available. @c -#define dimen(A) eqtb[scaled_base+(A)].hh.rh -#define count(A) eqtb[count_base+(A)].hh.rh - #define get_tex_dimen_register(j) dimen(j) #define get_tex_skip_register(j) skip(j) #define get_tex_mu_skip_register(j) mu_skip(j) @@ -902,7 +889,7 @@ int get_tex_extension_toks_register(int i) int set_tex_dimen_register(int j, scaled v) { int a; /* return non-nil for error */ - if (global_defs > 0) + if (global_defs_par > 0) a = 4; else a = 0; @@ -913,7 +900,7 @@ int set_tex_dimen_register(int j, scaled v) int set_tex_skip_register(int j, halfword v) { int a; /* return non-nil for error */ - if (global_defs > 0) + if (global_defs_par > 0) a = 4; else a = 0; @@ -926,7 +913,7 @@ int set_tex_skip_register(int j, halfword v) int set_tex_mu_skip_register(int j, halfword v) { int a; /* return non-nil for error */ - if (global_defs > 0) + if (global_defs_par > 0) a = 4; else a = 0; @@ -939,7 +926,7 @@ int set_tex_mu_skip_register(int j, halfword v) int set_tex_count_register(int j, scaled v) { int a; /* return non-nil for error */ - if (global_defs > 0) + if (global_defs_par > 0) a = 4; else a = 0; @@ -950,7 +937,7 @@ int set_tex_count_register(int j, scaled v) int set_tex_box_register(int j, scaled v) { int a; /* return non-nil for error */ - if (global_defs > 0) + if (global_defs_par > 0) a = 4; else a = 0; @@ -961,7 +948,7 @@ int set_tex_box_register(int j, scaled v) int set_tex_attribute_register(int j, scaled v) { int a; /* return non-nil for error */ - if (global_defs > 0) + if (global_defs_par > 0) a = 4; else a = 0; @@ -988,7 +975,7 @@ int set_tex_toks_register(int j, lstring s) (void) str_toks(s); set_token_ref_count(ref, 0); set_token_link(ref, token_link(temp_token_head)); - if (global_defs > 0) + if (global_defs_par > 0) a = 4; else a = 0; @@ -1003,7 +990,7 @@ int scan_tex_toks_register(int j, int c, lstring s) (void) str_scan_toks(c,s); set_token_ref_count(ref, 0); set_token_link(ref, token_link(temp_token_head)); - if (global_defs > 0) + if (global_defs_par > 0) a = 4; else a = 0; diff --git a/Build/source/texk/web2c/luatexdir/tex/inputstack.w b/Build/source/texk/web2c/luatexdir/tex/inputstack.w index be4cf9378e4..68b22e1a334 100644 --- a/Build/source/texk/web2c/luatexdir/tex/inputstack.w +++ b/Build/source/texk/web2c/luatexdir/tex/inputstack.w @@ -22,15 +22,11 @@ #include "ptexlib.h" @ @c -#define end_line_char int_par(end_line_char_code) -#define error_context_lines int_par(error_context_lines_code) - in_state_record *input_stack = NULL; int input_ptr = 0; /* first unused location of |input_stack| */ int max_in_stack = 0; /* largest value of |input_ptr| when pushing */ in_state_record cur_input; /* the ``top'' input state */ - int in_open = 0; /* the number of lines in the buffer, less one */ int open_parens = 0; /* the number of open text files */ alpha_file *input_file = NULL; @@ -39,7 +35,6 @@ int *line_stack = NULL; str_number *source_filename_stack = NULL; char **full_source_filename_stack = NULL; - int scanner_status = 0; /* can a subfile end now? */ pointer warning_index = null; /* identifier relevant to non-|normal| scanner status */ pointer def_ref = null; /* reference count of token list being defined */ @@ -235,7 +230,7 @@ void set_trick_count(void) #define PSEUDO_PRINT_THE_LINE() do { \ begin_pseudoprint(); \ - if (buffer[ilimit]==end_line_char) \ + if (buffer[ilimit]==end_line_char_par) \ j=ilimit; \ else \ j=ilimit+1; /* determine the effective end of the line */ \ @@ -300,7 +295,7 @@ void show_context(void) if ((iname > 21) || (base_ptr == 0)) bottom_line = true; } - if ((base_ptr == input_ptr) || bottom_line || (nn < error_context_lines)) { + if ((base_ptr == input_ptr) || bottom_line || (nn < error_context_lines_par)) { /* Display the current context */ if ((base_ptr == input_ptr) || (istate != token_list) || (token_type != backed_up) || (iloc != null)) { /* we omit backed-up token lists that have already been read */ @@ -381,10 +376,10 @@ void show_context(void) tprint("..."); incr(nn); } - } else if (nn == error_context_lines) { + } else if (nn == error_context_lines_par) { tprint_nl("..."); incr(nn); - /* omitted if |error_context_lines<0| */ + /* omitted if |error_context_lines_par<0| */ } if (bottom_line) break; @@ -435,7 +430,7 @@ void begin_token_list(halfword p, quarterword t) param_start = param_ptr; } else { iloc = token_link(p); - if (int_par(tracing_macros_code) > 1) { + if (tracing_macros_par > 1) { begin_diagnostic(); tprint_nl(""); if (t == mark_text) @@ -726,7 +721,7 @@ void pseudo_from_string(void) halfword p; /* for list construction */ s = make_string(); /* Convert string |s| into a new pseudo file */ - p = string_to_pseudo(s, int_par(new_line_char_code)); + p = string_to_pseudo(s, new_line_char_par); vlink(p) = pseudo_files; pseudo_files = p; flush_str(s); @@ -735,7 +730,7 @@ void pseudo_from_string(void) line = 0; ilimit = istart; iloc = ilimit + 1; /* force line read */ - if (int_par(tracing_scan_tokens_code) > 0) { + if (tracing_scan_tokens_par > 0) { if (term_offset > max_print_line - 3) print_ln(); else if ((term_offset > 0) || (file_offset > 0)) diff --git a/Build/source/texk/web2c/luatexdir/tex/linebreak.w b/Build/source/texk/web2c/luatexdir/tex/linebreak.w index 6e74e0b27be..fb67eb2fcec 100644 --- a/Build/source/texk/web2c/luatexdir/tex/linebreak.w +++ b/Build/source/texk/web2c/luatexdir/tex/linebreak.w @@ -146,7 +146,7 @@ void line_break(boolean d, int line_break_context) succumb(); } } else { - if (int_par(tracing_paragraphs_code) > 0) { + if (tracing_paragraphs_par > 0) { begin_diagnostic(); print_int(line); end_diagnostic(true); @@ -160,31 +160,31 @@ void line_break(boolean d, int line_break_context) confusion("weird par dir"); /* assert(0); */ /* |paragraph_dir = 0|; */ } ext_do_line_break(paragraph_dir, - int_par(pretolerance_code), - int_par(tracing_paragraphs_code), - int_par(tolerance_code), - dimen_par(emergency_stretch_code), - int_par(looseness_code), - int_par(adjust_spacing_code), - equiv(par_shape_loc), - int_par(adj_demerits_code), - int_par(protrude_chars_code), - int_par(line_penalty_code), - int_par(last_line_fit_code), - int_par(double_hyphen_demerits_code), - int_par(final_hyphen_demerits_code), - dimen_par(hang_indent_code), - dimen_par(hsize_code), - int_par(hang_after_code), - glue_par(left_skip_code), - glue_par(right_skip_code), - equiv(inter_line_penalties_loc), - int_par(inter_line_penalty_code), - int_par(club_penalty_code), - equiv(club_penalties_loc), - (d ? equiv(display_widow_penalties_loc) : equiv(widow_penalties_loc)), - (d ? int_par(display_widow_penalty_code) : int_par(widow_penalty_code)), - int_par(broken_penalty_code), + pretolerance_par, + tracing_paragraphs_par, + tolerance_par, + emergency_stretch_par, + looseness_par, + adjust_spacing_par, + par_shape_par_ptr, + adj_demerits_par, + protrude_chars_par, + line_penalty_par, + last_line_fit_par, + double_hyphen_demerits_par, + final_hyphen_demerits_par, + hang_indent_par, + hsize_par, + hang_after_par, + left_skip_par, + right_skip_par, + inter_line_penalties_par_ptr, + inter_line_penalty_par, + club_penalty_par, + club_penalties_par_ptr, + (d ? display_widow_penalties_par_ptr : widow_penalties_par_ptr), + (d ? display_widow_penalty_code : widow_penalty_code), + broken_penalty_par, final_par_glue); } lua_node_filter(post_linebreak_filter_callback, @@ -898,7 +898,7 @@ static void compute_break_width(int break_type, int line_break_dir, int adjust_s switch (type(s)) { case math_node: /* begin mathskip code */ - if (glue_is_zero(math_skip)) { + if (glue_is_zero(math_skip_par)) { break_width[1] -= surround(s); break; } else { @@ -1630,14 +1630,15 @@ void ext_do_line_break(int paragraph_dir, second_width = hsize; second_indent = 0; } else { + halfword used_hang_indent = swap_hang_indent(hang_indent); /* Set line length parameters in preparation for hanging indentation */ /* We compute the values of |easy_line| and the other local variables relating to line length when the |line_break| procedure is initializing itself. */ last_special_line = abs(hang_after); if (hang_after < 0) { - first_width = hsize - abs(hang_indent); - if (hang_indent >= 0) - first_indent = hang_indent; + first_width = hsize - abs(used_hang_indent); + if (used_hang_indent >= 0) + first_indent = used_hang_indent; else first_indent = 0; second_width = hsize; @@ -1645,19 +1646,18 @@ void ext_do_line_break(int paragraph_dir, } else { first_width = hsize; first_indent = 0; - second_width = hsize - abs(hang_indent); - if (hang_indent >= 0) - second_indent = hang_indent; + second_width = hsize - abs(used_hang_indent); + if (used_hang_indent >= 0) + second_indent = used_hang_indent; else second_indent = 0; } } } else { last_special_line = vinfo(par_shape_ptr + 1) - 1; - second_indent = - varmem[(par_shape_ptr + 2 * (last_special_line + 1))].cint; - second_width = - varmem[(par_shape_ptr + 2 * (last_special_line + 1) + 1)].cint; + second_indent = varmem[(par_shape_ptr + 2 * (last_special_line + 1))].cint; + second_width = varmem[(par_shape_ptr + 2 * (last_special_line + 1) + 1)].cint; + second_indent = swap_parshape_indent(second_indent,second_width); } if (looseness == 0) easy_line = last_special_line; @@ -1840,7 +1840,7 @@ void ext_do_line_break(int paragraph_dir, case math_node: auto_breaking = (subtype(cur_p) == after); /* begin mathskip code */ - if (glue_is_zero(math_skip)) { + if (glue_is_zero(math_skip_par)) { kern_break(); break; } else { @@ -2132,7 +2132,7 @@ void ext_do_line_break(int paragraph_dir, protrude_chars, par_shape_ptr, adjust_spacing, - inter_line_penalties_ptr, + inter_line_penalties_par_ptr, inter_line_penalty, club_penalty, club_penalties_ptr, diff --git a/Build/source/texk/web2c/luatexdir/tex/mainbody.h b/Build/source/texk/web2c/luatexdir/tex/mainbody.h index fdef20ab882..158893631d7 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mainbody.h +++ b/Build/source/texk/web2c/luatexdir/tex/mainbody.h @@ -214,8 +214,7 @@ is conditionally compiled in the C code. @^system dependencies@> */ - -# define fix_date_and_time() dateandtime(int_par(time_code),int_par(day_code),int_par(month_code),int_par(year_code)) +# define fix_date_and_time() dateandtime(time_par,day_par,month_par,year_par) extern int get_luatexversion(void); extern str_number get_luatexrevision(void); diff --git a/Build/source/texk/web2c/luatexdir/tex/mainbody.w b/Build/source/texk/web2c/luatexdir/tex/mainbody.w index ad0bb783a1f..0fb8bc4b484 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mainbody.w +++ b/Build/source/texk/web2c/luatexdir/tex/mainbody.w @@ -432,9 +432,9 @@ void main_body(void) incr(iloc); } if (output_mode_option != 0) - int_par(output_mode_code) = output_mode_value; + output_mode_par = output_mode_value; if (draft_mode_option != 0) { - int_par(draft_mode_code) = draft_mode_value; + draft_mode_par = draft_mode_value; } /* can this be moved? */ pdf_init_map_file((char *) pdftex_map); @@ -442,15 +442,14 @@ void main_body(void) if (end_line_char_inactive) decr(ilimit); else - buffer[ilimit] = (packed_ASCII_code) int_par(end_line_char_code); + buffer[ilimit] = (packed_ASCII_code) end_line_char_par; fix_date_and_time(); random_seed = (microseconds * 1000) + (epochseconds % 1000000); init_randoms(random_seed); initialize_math(); fixup_selector(log_opened_global); check_texconfig_init(); - if ((iloc < ilimit) && (get_cat_code(int_par(cat_code_table_code), - buffer[iloc]) != escape_cmd)) + if ((iloc < ilimit) && (get_cat_code(cat_code_table_code, buffer[iloc]) != escape_cmd)) start_input(); /* \.{\\input} assumed */ /* DIR: Initialize |text_dir_ptr| */ text_dir_ptr = new_dir(0); @@ -487,7 +486,7 @@ void close_files_and_terminate(void) int callback_id; callback_id = callback_defined(stop_run_callback); finalize_write_files(); - if (int_par(tracing_stats_code) > 0) { + if (tracing_stats_par > 0) { if (callback_id == 0) { /* Output statistics about this job */ /* The present section goes directly to the log file instead of using diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.h b/Build/source/texk/web2c/luatexdir/tex/maincontrol.h index c42dcc93aa4..13e3c6ff3b0 100644 --- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.h +++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.h @@ -71,9 +71,9 @@ since the following routines test for the \.{\\global} prefix as follows. # define define_cat_code(A,B) do { \ if (is_global(a)) \ - set_cat_code(int_par(cat_code_table_code),(A),(B),level_one); \ + set_cat_code(cat_code_table_par,(A),(B),level_one); \ else \ - set_cat_code(int_par(cat_code_table_code),(A),(B),cur_level); \ + set_cat_code(cat_code_table_par,(A),(B),cur_level); \ } while (0) # define define_fam_fnt(A,B,C) do { \ @@ -174,6 +174,17 @@ extern void fixup_directions(void); tprint(" entered on line "); print_int((A)); \ } +/* + extern halfword swap_hang_indent(halfword indentation, halfword shape_mode); + extern halfword swap_parshape_indent(halfword indentation, halfword width, halfword shape_mode); +*/ + +#define swap_hang_indent(indentation) \ + ( ((shape_mode_par == 1 || shape_mode_par == 3 || shape_mode_par == -1 || shape_mode_par == -3)) ? negate(indentation) : indentation ) + +#define swap_parshape_indent(indentation,width) \ + ( ((shape_mode_par == 2 || shape_mode_par == 3 || shape_mode_par == -2 || shape_mode_par == -3)) ? (hsize_par - width - indentation) : indentation ) + extern void get_r_token(void); extern void assign_internal_value(int a, halfword p, int cur_val); extern void do_register_command(int a); diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w index 690952b2bf2..cbfd333bbb7 100644 --- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w +++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w @@ -22,72 +22,11 @@ #include "ptexlib.h" #include "lua/luatex-api.h" -/* these will move to equivalents.h */ - @ @c -#define lp_code_base 2 -#define rp_code_base 3 -#define ef_code_base 4 -#define tag_code 5 -#define no_lig_code 6 -#define gp_code_base 7 - -#define prev_depth cur_list.prev_depth_field -#define space_factor cur_list.space_factor_field -#define par_shape_ptr equiv(par_shape_loc) - -#define cur_lang int_par(cur_lang_code) -#define global_defs int_par(global_defs_code) -#define output_box int_par(output_box_code) -#define end_line_char int_par(end_line_char_code) -#define new_line_char int_par(new_line_char_code) -#define tracing_online int_par(tracing_online_code) -#define no_local_whatsits int_par(no_local_whatsits_code) -#define no_local_dirs int_par(no_local_dirs_code) -#define err_help equiv(err_help_loc) -#define every_par equiv(every_par_loc) - -#define page_left_offset dimen_par(page_left_offset_code) -#define page_top_offset dimen_par(page_top_offset_code) -#define page_right_offset dimen_par(page_right_offset_code) -#define page_bottom_offset dimen_par(page_bottom_offset_code) -#define px_dimen dimen_par(px_dimen_code) - -#define math_eqno_gap_step int_par(math_eqno_gap_step_code) - -#define escape_char int_par(escape_char_code) -#define max_dead_cycles int_par(max_dead_cycles_code) -#define tolerance int_par(tolerance_code) -#define mag int_par(mag_code) -#define cat_code_table int_par(cat_code_table_code) - -#define par_indent dimen_par(par_indent_code) -#define looseness int_par(looseness_code) -#define space_skip glue_par(space_skip_code) -#define xspace_skip glue_par(xspace_skip_code) -#define math_skip glue_par(math_skip_code) -#define every_vbox equiv(every_vbox_loc) - -#define split_top_skip glue_par(split_top_skip_code) -#define split_max_depth dimen_par(split_max_depth_code) - -#define hang_indent dimen_par(hang_indent_code) -#define hang_after int_par(hang_after_code) -#define inter_line_penalties_ptr equiv(inter_line_penalties_loc) - -#define box(A) eqtb[box_base+(A)].hh.rh -#define cur_font equiv(cur_font_loc) -#define hsize dimen_par(hsize_code) -#define ex_hyphen_char int_par(ex_hyphen_char_code) -#define floating_penalty int_par(floating_penalty_code) - -#define mode cur_list.mode_field -#define tail cur_list.tail_field -#define head cur_list.head_field -#define prev_graf cur_list.pg_field -#define dir_save cur_list.dirs_field - -#define var_code 7 /* math code meaning ``use the current family'' */ +#define mode mode_par +#define tail tail_par +#define head head_par +#define dir_save dirs_par @ We come now to the |main_control| routine, which contains the master switch that causes all the various pieces of \TeX\ to do their things, @@ -140,14 +79,14 @@ void adjust_space_factor(void) { halfword s = get_sf_code(cur_chr); if (s == 1000) { - space_factor = 1000; + space_factor_par = 1000; } else if (s < 1000) { if (s > 0) - space_factor = s; - } else if (space_factor < 1000) { - space_factor = 1000; + space_factor_par = s; + } else if (space_factor_par < 1000) { + space_factor_par = 1000; } else { - space_factor = s; + space_factor_par = s; } } @@ -179,12 +118,12 @@ static void run_char_num (void) { scan_char_num(); cur_chr = cur_val; adjust_space_factor(); - tail_append(new_char(cur_font, cur_chr)); + tail_append(new_char(cur_font_par, cur_chr)); } static void run_char (void) { adjust_space_factor(); - tail_append(new_char(cur_font, cur_chr)); + tail_append(new_char(cur_font_par, cur_chr)); } @ @@ -201,23 +140,23 @@ is zero or~not. @c static void run_app_space (void) { halfword p; /* was a global temp_ptr */ - int method = int_par(disable_space_code) ; + int method = disable_space_par ; if (method == 1) { /* don't inject anything, not even zero skip */ } else if (method == 2) { p = new_glue(zero_glue); couple_nodes(tail,p); tail = p; - } else if ((abs(mode) + cur_cmd == hmode + spacer_cmd) && (!(space_factor == 1000))) { + } else if ((abs(mode) + cur_cmd == hmode + spacer_cmd) && (!(space_factor_par == 1000))) { app_space(); } else { /* Append a normal inter-word space to the current list */ - if (glue_is_zero(space_skip)) { + if (glue_is_zero(space_skip_par)) { /* Find the glue specification for text spaces in the current font */ p = new_glue(zero_glue); - width(p) = space(cur_font); - stretch(p) = space_stretch(cur_font); - shrink(p) = space_shrink(cur_font); + width(p) = space(cur_font_par); + stretch(p) = space_stretch(cur_font_par); + shrink(p) = space_shrink(cur_font_par); } else { p = new_param_glue(space_skip_code); @@ -351,9 +290,9 @@ mode, by setting |prev_depth:=ignore_depth|. static void run_rule (void) { tail_append(scan_rule_spec()); if (abs(mode) == vmode) - prev_depth = ignore_depth; + prev_depth_par = ignore_depth; else if (abs(mode) == hmode) - space_factor = 1000; + space_factor_par = 1000; } @ @@ -567,9 +506,9 @@ static void run_vcenter (void) { normal_paragraph(); push_nest(); mode = -vmode; - prev_depth = ignore_depth; - if (every_vbox != null) - begin_token_list(every_vbox, every_vbox_text); + prev_depth_par = ignore_depth; + if (every_vbox_par != null) + begin_token_list(every_vbox_par, every_vbox_text); } @ @c @@ -629,12 +568,12 @@ static void run_normal (void) { help1("All \\catcode table ids must be between 0 and 0x7FFF"); error(); } else { - if (cur_val == cat_code_table) { + if (cur_val == cat_code_table_par) { print_err("Invalid \\catcode table"); help1("You cannot overwrite the current \\catcode table"); error(); } else { - copy_cat_codes(cat_code_table, cur_val); + copy_cat_codes(cat_code_table_par, cur_val); } } break; @@ -645,7 +584,7 @@ static void run_normal (void) { help1("All \\catcode table ids must be between 0 and 0x7FFF"); error(); } else { - if (cur_val == cat_code_table) { + if (cur_val == cat_code_table_par) { print_err("Invalid \\catcode table"); help1("You cannot overwrite the current \\catcode table"); error(); @@ -965,7 +904,7 @@ void main_control(void) check_interrupt(); continue; } - if (int_par(tracing_commands_code) > 0) + if (tracing_commands_par > 0) show_cur_cmd_chr(); (jump_table[(abs(mode) + cur_cmd)])(); /* run the command */ @@ -981,24 +920,24 @@ void main_control(void) void app_space(void) { /* handle spaces when |space_factor<>1000| */ halfword q; /* glue node */ - if ((space_factor >= 2000) && (! glue_is_zero(xspace_skip))) { + if ((space_factor_par >= 2000) && (! glue_is_zero(xspace_skip_par))) { q = new_param_glue(xspace_skip_code); /* so from now we have a subtype with spaces: */ subtype(q) = xspace_skip_code + 1; } else { - if (!glue_is_zero(space_skip)) { - q = new_glue(space_skip); + if (!glue_is_zero(space_skip_par)) { + q = new_glue(space_skip_par); } else { q = new_glue(zero_glue); - width(q) = space(cur_font); - stretch(q) = space_stretch(cur_font); - shrink(q) = space_shrink(cur_font); + width(q) = space(cur_font_par); + stretch(q) = space_stretch(cur_font_par); + shrink(q) = space_shrink(cur_font_par); } /* Modify the glue specification in |q| according to the space factor */ - if (space_factor >= 2000) - width(q) = width(q) + extra_space(cur_font); - stretch(q) = xn_over_d(stretch(q), space_factor, 1000); - shrink(q) = xn_over_d(shrink(q), 1000, space_factor); + if (space_factor_par >= 2000) + width(q) = width(q) + extra_space(cur_font_par); + stretch(q) = xn_over_d(stretch(q), space_factor_par, 1000); + shrink(q) = xn_over_d(shrink(q), 1000, space_factor_par); /* so from now we have a subtype with spaces: */ subtype(q) = space_skip_code + 1; @@ -1023,7 +962,7 @@ void insert_dollar_sign(void) @c void insert_dollar_sign_par_end(void) { - if (!int_par(suppress_mathpar_error_code)) { + if (!suppress_mathpar_error_par) { insert_dollar_sign() ; } } @@ -1094,7 +1033,7 @@ boolean its_all_over(void) } back_input(); /* we will try to end again after ejecting residual material */ tail_append(new_null_box()); - width(tail) = hsize; + width(tail) = hsize_par; tail_append(new_glue(fill_glue)); tail_append(new_penalty(-010000000000)); normal_page_filter(end); @@ -1265,9 +1204,9 @@ void handle_right_brace(void) break; case insert_group: end_graf(insert_group); - q = new_glue(split_top_skip); - d = split_max_depth; - f = floating_penalty; + q = new_glue(split_top_skip_par); + d = split_max_depth_par; + f = floating_penalty_par; unsave(); save_ptr--; /* now |saved_value(0)| is the insertion number, or the |vadjust| subtype */ @@ -1368,16 +1307,18 @@ default values after every paragraph and when internal vertical mode is entered. @c void normal_paragraph(void) { - if (looseness != 0) + if (looseness_par != 0) eq_word_define(int_base + looseness_code, 0); - if (hang_indent != 0) + if (hang_indent_par != 0) eq_word_define(dimen_base + hang_indent_code, 0); - if (hang_after != 1) + if (hang_after_par != 1) eq_word_define(int_base + hang_after_code, 1); - if (par_shape_ptr != null) + if (par_shape_par_ptr != null) eq_define(par_shape_loc, shape_ref_cmd, null); - if (inter_line_penalties_ptr != null) + if (inter_line_penalties_par_ptr != null) eq_define(inter_line_penalties_loc, shape_ref_cmd, null); + if (shape_mode_par > 0) + eq_word_define(dimen_base + shape_mode_code, 0); } @ The global variable |cur_box| will point to a newly-made box. If the box @@ -1421,7 +1362,7 @@ void box_end(int box_context) } } else { if (abs(mode) == hmode) - space_factor = 1000; + space_factor_par = 1000; else cur_box = new_sub_box(cur_box); couple_nodes(tail, cur_box); @@ -1491,19 +1432,19 @@ void new_graf(boolean indented) { halfword p, q, dir_graf_tmp; halfword dir_rover; - prev_graf = 0; + prev_graf_par = 0; if ((mode == vmode) || (head != tail)) { tail_append(new_param_glue(par_skip_code)); } push_nest(); mode = hmode; - space_factor = 1000; + space_factor_par = 1000; /* LOCAL: Add local paragraph node */ tail_append(make_local_par_node(new_graf_par_code)); if (indented) { p = new_null_box(); - box_dir(p) = par_direction; - width(p) = par_indent; + box_dir(p) = par_direction_par; + width(p) = par_indent_par; subtype(p) = indent_list; q = tail; tail_append(p); @@ -1512,7 +1453,7 @@ void new_graf(boolean indented) } dir_rover = text_dir_ptr; while (dir_rover != null) { - if ((vlink(dir_rover) != null) || (dir_dir(dir_rover) != par_direction)) { + if ((vlink(dir_rover) != null) || (dir_dir(dir_rover) != par_direction_par)) { dir_graf_tmp = new_dir(dir_dir(dir_rover)); try_couple_nodes(dir_graf_tmp,vlink(q)); couple_nodes(q,dir_graf_tmp); @@ -1523,8 +1464,8 @@ void new_graf(boolean indented) while (vlink(q) != null) q = vlink(q); tail = q; - if (every_par != null) - begin_token_list(every_par, every_par_text); + if (every_par_par != null) + begin_token_list(every_par_par, every_par_text); if (nest_ptr == 1) { checked_page_filter(new_graf); build_page(); /* put |par_skip| glue on current page */ @@ -1537,9 +1478,9 @@ void indent_in_hmode(void) halfword p; if (cur_chr > 0) { /* \.{\\indent} */ p = new_null_box(); - width(p) = par_indent; + width(p) = par_indent_par; if (abs(mode) == hmode) - space_factor = 1000; + space_factor_par = 1000; else p = new_sub_box(p); tail_append(p); @@ -1596,9 +1537,9 @@ void begin_insert_or_adjust(void) { if (cur_cmd != vadjust_cmd) { scan_register_num(); - if (cur_val == output_box) { + if (cur_val == output_box_par) { print_err("You can't \\insert"); - print_int(output_box); + print_int(output_box_par); help1("I'm changing to \\insert0; box \\outputbox is special."); error(); cur_val = 0; @@ -1615,7 +1556,7 @@ void begin_insert_or_adjust(void) normal_paragraph(); push_nest(); mode = -vmode; - prev_depth = ignore_depth; + prev_depth_par = ignore_depth; } @ I (TH)'ve renamed the |make_mark| procedure to this, because if the @@ -1800,7 +1741,7 @@ void append_local_box(int kind) scan_left_brace(); push_nest(); mode = -hmode; - space_factor = 1000; + space_factor_par = 1000; } @ Discretionary nodes are easy in the common case `\.{\\-}', but in the @@ -1817,19 +1758,19 @@ void append_discretionary(void) subtype(tail) = (quarterword) cur_chr; if (cur_chr == explicit_disc) { /* \- */ - c = get_pre_hyphen_char(cur_lang); + c = get_pre_hyphen_char(cur_lang_par); if (c != 0) { vlink(pre_break(tail)) = new_char(equiv(cur_font_loc), c); alink(vlink(pre_break(tail))) = pre_break(tail); tlink(pre_break(tail)) = vlink(pre_break(tail)); } - c = get_post_hyphen_char(cur_lang); + c = get_post_hyphen_char(cur_lang_par); if (c != 0) { vlink(post_break(tail)) = new_char(equiv(cur_font_loc), c); alink(vlink(post_break(tail))) = post_break(tail); tlink(post_break(tail)) = vlink(post_break(tail)); } - disc_penalty(tail) = int_par(ex_hyphen_penalty_code); + disc_penalty(tail) = ex_hyphen_penalty_par; } else { /* \discretionary */ if (scan_keyword("penalty")) { @@ -1842,8 +1783,8 @@ void append_discretionary(void) scan_left_brace(); push_nest(); mode = -hmode; - space_factor = 1000; - /* already preset: disc_penalty(tail) = int_par(hyphen_penalty_code); */ + space_factor_par = 1000; + /* already preset: disc_penalty(tail) = hyphen_penalty_par; */ } } @@ -1871,7 +1812,7 @@ void build_local_box(void) /* LOCAL: Add local paragraph node */ tail_append(make_local_par_node(local_box_par_code)); } - eq_word_define(int_base + no_local_whatsits_code, no_local_whatsits + 1); + eq_word_define(int_base + no_local_whatsits_code, no_local_whatsits_par + 1); } @ The three discretionary lists are constructed somewhat as if they were @@ -1954,7 +1895,7 @@ void build_discretionary(void) scan_left_brace(); push_nest(); mode = -hmode; - space_factor = 1000; + space_factor_par = 1000; } @ The positioning of accents is straightforward but tedious. Given an accent @@ -2023,7 +1964,7 @@ void make_accent(void) } couple_nodes(tail, p); tail = p; - space_factor = 1000; + space_factor_par = 1000; } } @@ -2177,6 +2118,25 @@ following program is careful to check each case properly. } while (0) @ @c +/* +halfword swap_hang_indent(halfword indentation, halfword shape_mode) { + if (shape_mode == 1 || shape_mode == 3 || shape_mode == -1 || shape_mode == -3) { + return negate(indentation); + } else { + return indentation; + } +} + +halfword swap_parshape_indent(halfword indentation, halfword width, halfword shape_mode) { + if (shape_mode == 2 || shape_mode == 3 || shape_mode == -2 || shape_mode == -3) { + return hsize_par - width - indentation; + } else { + return indentation; + } +} + +*/ + void prefixed_command(void) { int a; /* accumulated prefix codes so far */ @@ -2184,7 +2144,7 @@ void prefixed_command(void) halfword j; /* index into a \.{\\parshape} specification */ halfword p, q; /* for temporary short-term use */ int n; /* ditto */ - boolean e; /* should a definition be expanded? or was \.{\\let} not done? */ + boolean e, check_glue; /* should a definition be expanded? or was \.{\\let} not done? */ mathcodeval mval; /* for handling of \.{\\mathchardef}s */ a = 0; while (cur_cmd == prefix_cmd) { @@ -2206,7 +2166,7 @@ void prefixed_command(void) back_error(); return; } - if (int_par(tracing_commands_code) > 2) + if (tracing_commands_par > 2) show_cur_cmd_chr(); } /* Discard the prefixes \.{\\long} and \.{\\outer} if they are irrelevant */ @@ -2224,8 +2184,8 @@ void prefixed_command(void) error(); } /* Adjust for the setting of \.{\\globaldefs} */ - if (global_defs != 0) { - if (global_defs < 0) { + if (global_defs_par != 0) { + if (global_defs_par < 0) { if (is_global(a)) a = a - 4; } else { @@ -2244,7 +2204,7 @@ void prefixed_command(void) |cur_chr| is odd if the definition is supposed to be global, and |cur_chr>=2| if the definition is supposed to be expanded. */ - if (odd(cur_chr) && !is_global(a) && (global_defs >= 0)) + if (odd(cur_chr) && !is_global(a) && (global_defs_par >= 0)) a = a + 4; e = (cur_chr >= 2); get_r_token(); @@ -2325,7 +2285,7 @@ void prefixed_command(void) break; case math_char_def_code: mval = scan_mathchar(tex_mathcode); - if (mathoption_int_par(c_mathoption_umathcode_meaning_code) == 1) { + if (math_umathcode_meaning_par == 1) { cur_val = (mval.class_value + (8 * mval.family_value)) * (65536 * 32) + mval.character_value; define(p, xmath_given_cmd, cur_val); } else { @@ -2464,42 +2424,78 @@ void prefixed_command(void) /* DIR: Assign direction codes */ scan_direction(); switch (cur_chr) { - case int_base + page_direction_code: - eq_word_define(int_base + page_direction_code, cur_val); - break; - case int_base + body_direction_code: - eq_word_define(int_base + body_direction_code, cur_val); - break; - case int_base + par_direction_code: - eq_word_define(int_base + par_direction_code, cur_val); - break; - case int_base + math_direction_code: - eq_word_define(int_base + math_direction_code, cur_val); - break; - case int_base + text_direction_code: -#if 0 - /* various tests hint that this is unnecessary and - * sometimes even produces weird results, eg - * (\hbox{\textdir TRT ABC\textdir TLT DEF}) - * becomes - * (DEFCBA) - * in the output - */ - if ((no_local_dirs > 0) && (abs(mode) == hmode)) { - /* DIR: Add local dir node */ - tail_append(new_dir(text_direction)); - } -#endif - update_text_dir_ptr(cur_val); - if (abs(mode) == hmode) { - /* DIR: Add local dir node */ - tail_append(new_dir(cur_val)); - dir_level(tail) = cur_level; + case int_base + page_direction_code: + eq_word_define(int_base + page_direction_code, cur_val); + break; + case int_base + body_direction_code: + eq_word_define(int_base + body_direction_code, cur_val); + break; + case int_base + par_direction_code: + eq_word_define(int_base + par_direction_code, cur_val); + break; + case int_base + math_direction_code: + eq_word_define(int_base + math_direction_code, cur_val); + break; + case int_base + text_direction_code: + case int_base + line_direction_code: + /* + pre version 0.97 this was a commented section because various tests hint that this + is unnecessary and sometimes even produces weird results, like: + + (\hbox{\textdir TRT ABC\textdir TLT DEF})) + + becomes + + (DEFCBA) + + in the output when we use + + tail_append(new_dir(text_direction_par) + + but when we append the reverse of the current it goes better + + */ + check_glue = (cur_chr == (int_base + line_direction_code)); + if (check_glue) { + cur_chr = int_base + text_direction_code ; + } + if (abs(mode) == hmode) { + if (no_local_dirs_par > 0) { + /* tail is non zero but we test anyway */ + if (check_glue && (tail != null && type(tail) == glue_node)) { + halfword prev = alink(tail); + halfword dirn = new_dir(text_direction_par - dir_swap); + couple_nodes(prev,dirn); + couple_nodes(dirn,tail); + } else { + tail_append(new_dir(text_direction_par - dir_swap)); + } + } else { + /* what is the use of nolocaldirs .. maybe we should get rid of it */ + } + update_text_dir_ptr(cur_val); + tail_append(new_dir(cur_val)); + dir_level(tail) = cur_level; + } else { + update_text_dir_ptr(cur_val); + } + /* original: + + // if ((no_local_dirs_par > 0) && (abs(mode) == hmode)) { + // // tail_append(new_dir(text_direction_par) // kind of wrong + // tail_append(new_dir(text_direction_par - dir_swap)); // better + // } + + update_text_dir_ptr(cur_val); + if (abs(mode) == hmode) { + tail_append(new_dir(cur_val)); + dir_level(tail) = cur_level; + } + */ + eq_word_define(int_base + text_direction_code, cur_val); + eq_word_define(int_base + no_local_dirs_code, no_local_dirs_par + 1); + break; } - eq_word_define(int_base + text_direction_code, cur_val); - eq_word_define(int_base + no_local_dirs_code, no_local_dirs + 1); - break; - } break; case assign_dimen_cmd: p = cur_chr; @@ -2614,11 +2610,11 @@ void prefixed_command(void) scan_dimen(false, false, false); } else { scan_glue(mu_val_level); - if (cur_val == glue_par(thin_mu_skip_code)) + if (cur_val == thin_mu_skip_par) cur_val = thin_mu_skip_code; - else if (cur_val == glue_par(med_mu_skip_code)) + else if (cur_val == med_mu_skip_par) cur_val = med_mu_skip_code; - else if (cur_val == glue_par(thick_mu_skip_code)) + else if (cur_val == thick_mu_skip_par) cur_val = thick_mu_skip_code; } define_math_param(p, cur_val1, cur_val); @@ -2812,9 +2808,9 @@ void prefixed_command(void) @ @c void fixup_directions(void) { - int temp_no_whatsits = no_local_whatsits; - int temp_no_dirs = no_local_dirs; - int temporary_dir = text_direction; + int temp_no_whatsits = no_local_whatsits_par; + int temp_no_dirs = no_local_dirs_par; + int temporary_dir = text_direction_par; if (dir_level(text_dir_ptr) == cur_level) { /* DIR: Remove from |text_dir_ptr| */ halfword text_dir_tmp = vlink(text_dir_ptr); @@ -2825,7 +2821,7 @@ void fixup_directions(void) if (abs(mode) == hmode) { if (temp_no_dirs != 0) { /* DIR: Add local dir node */ - tail_append(new_dir(text_direction)); + tail_append(new_dir(text_direction_par)); dir_dir(tail) = temporary_dir - dir_swap; } if (temp_no_whatsits != 0) { @@ -2870,7 +2866,7 @@ void assign_internal_value(int a, halfword p, int val) switch ((p - int_base)) { case cat_code_table_code: if (valid_catcode_table(val)) { - if (val != int_par(cat_code_table_code)) + if (val != cat_code_table_par) word_define(p, val); } else { print_err("Invalid \\catcode table"); @@ -2941,9 +2937,7 @@ void assign_internal_value(int a, halfword p, int val) (p == (int_base + local_broken_penalty_code)))) { /* LOCAL: Add local paragraph node */ tail_append(make_local_par_node(penalty_par_code)); - - eq_word_define(int_base + no_local_whatsits_code, - no_local_whatsits + 1); + eq_word_define(int_base + no_local_whatsits_code, no_local_whatsits_par + 1); } } else if ((p >= dimen_base) && (p <= eqtb_size)) { if (p == (dimen_base + page_left_offset_code)) { @@ -3117,7 +3111,7 @@ void alter_aux(void) scan_optional_equals(); if (c == vmode) { scan_normal_dimen(); - prev_depth = cur_val; + prev_depth_par = cur_val; } else { scan_int(); if ((cur_val <= 0) || (cur_val > 32767)) { @@ -3125,7 +3119,7 @@ void alter_aux(void) help1("I allow only values in the range 1..32767 here."); int_error(cur_val); } else { - space_factor = cur_val; + space_factor_par = cur_val; } } } @@ -3301,7 +3295,7 @@ void issue_message(void) give a verbose explanation only once. */ print_err(""); print(s); - if (err_help != null) { + if (err_help_par != null) { use_err_help = true; } else if (long_help_seen) { help1("(That was another \\errmessage.)"); @@ -3326,7 +3320,7 @@ the |err_help| parameter. @c void give_err_help(void) { - token_show(err_help); + token_show(err_help_par); } @ The \.{\\uppercase} and \.{\\lowercase} commands are implemented by @@ -3469,7 +3463,7 @@ void show_whatever(void) end_diagnostic(true); print_err("OK"); if (selector == term_and_log) { - if (tracing_online <= 0) { + if (tracing_online_par <= 0) { selector = term_only; tprint(" (see the transcript file)"); selector = term_and_log; @@ -3479,7 +3473,7 @@ void show_whatever(void) if (interaction < error_stop_mode) { help0(); decr(error_count); - } else if (tracing_online > 0) { + } else if (tracing_online_par > 0) { help3("This isn't an error message; I'm just \\showing something.", "Type `I\\show...' to show more (e.g., \\show\\cs,", "\\showthe\\count10, \\showbox255, \\showlists)."); @@ -3533,7 +3527,7 @@ void initialize(void) initialize_directions(); initialize_write_files(); seconds_and_micros(epochseconds, microseconds); - init_start_time(static_pdf); + initialize_start_time(static_pdf); edit_name_start = 0; stop_at_space = true; @@ -3560,7 +3554,7 @@ void initialize(void) for (k = glue_base + 1; k <= local_base - 1; k++) { eqtb[k] = eqtb[glue_base]; } - par_shape_ptr = null; + par_shape_par_ptr = null; set_eq_type(par_shape_loc, shape_ref_cmd); set_eq_level(par_shape_loc, level_one); for (k = etex_pen_base; k <= (etex_pens - 1); k++) @@ -3572,7 +3566,7 @@ void initialize(void) set_eq_level(box_base, level_one); for (k = box_base + 1; k <= (box_base + biggest_reg); k++) eqtb[k] = eqtb[box_base]; - cur_font = null_font; + cur_font_par = null_font; set_eq_type(cur_font_loc, data_cmd); set_eq_level(cur_font_loc, level_one); set_equiv(cat_code_base, 0); @@ -3583,15 +3577,15 @@ void initialize(void) eqtb[uc_code_base] = eqtb[cat_code_base]; eqtb[sf_code_base] = eqtb[cat_code_base]; eqtb[math_code_base] = eqtb[cat_code_base]; - cat_code_table = 0; + cat_code_table_par = 0; initialize_math_codes(); initialize_text_codes(); initex_cat_codes(0); for (k = '0'; k <= '9'; k++) - set_math_code(k, var_code, 0, k, level_one); + set_math_code(k, math_use_current_family_code, 0, k, level_one); for (k = 'A'; k <= 'Z'; k++) { - set_math_code(k, var_code, 1, k, level_one); - set_math_code((k + 32), var_code, 1, (k + 32), level_one); + set_math_code(k, math_use_current_family_code, 1, k, level_one); + set_math_code((k + 32), math_use_current_family_code, 1, (k + 32), level_one); set_lc_code(k, k + 32, level_one); set_lc_code(k + 32, k + 32, level_one); set_uc_code(k, k, level_one); @@ -3602,21 +3596,21 @@ void initialize(void) eqtb[k].cint = 0; for (k = attribute_base; k <= del_code_base - 1; k++) eqtb[k].cint = UNUSED_ATTRIBUTE; - mag = 1000; - tolerance = 10000; - hang_after = 1; - max_dead_cycles = 25; - escape_char = '\\'; - end_line_char = carriage_return; + mag_par = 1000; + tolerance_par = 10000; + hang_after_par = 1; + max_dead_cycles_par = 25; + escape_char_par = '\\'; + end_line_char_par = carriage_return; set_del_code('.', 0, 0, 0, 0, level_one); /* this null delimiter is used in error recovery */ - ex_hyphen_char = '-'; - output_box = 255; + ex_hyphen_char_par = '-'; + output_box_par = 255; for (k = dimen_base; k <= eqtb_size; k++) eqtb[k].cint = 0; - page_left_offset = one_inch; - page_top_offset = one_inch; - page_right_offset = one_inch; - page_bottom_offset = one_inch; + page_left_offset_par = one_inch; + page_top_offset_par = one_inch; + page_right_offset_par = one_inch; + page_bottom_offset_par = one_inch; ini_init_primitives(); hash_used = frozen_control_sequence; /* nothing is used */ hash_high = 0; @@ -3629,8 +3623,8 @@ void initialize(void) cs_text(frozen_primitive) = maketexstring("primitive"); create_null_font(); font_bytes = 0; - px_dimen = one_bp; - math_eqno_gap_step = 1000 ; + px_dimen_par = one_bp; + math_eqno_gap_step_par = 1000 ; cs_text(frozen_protection) = maketexstring("inaccessible"); format_ident = maketexstring(" (INITEX)"); cs_text(end_write) = maketexstring("endwrite"); diff --git a/Build/source/texk/web2c/luatexdir/tex/mathcodes.w b/Build/source/texk/web2c/luatexdir/tex/mathcodes.w index 64efce9d898..8c0760ae51e 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mathcodes.w +++ b/Build/source/texk/web2c/luatexdir/tex/mathcodes.w @@ -124,7 +124,7 @@ static void unsavemathcode(quarterword gl) st = mathcode_head->stack[mathcode_head->stack_ptr]; if (st.level > 0) { rawset_sa_item(mathcode_head, st.code, st.value); - if (int_par(tracing_restores_code) > 1) { + if (tracing_restores_par > 1) { begin_diagnostic(); print_char('{'); tprint("restoring"); @@ -150,7 +150,7 @@ void set_math_code(int n, int mathclass, int mathfamily, int mathcharacter, quar v.math_code_value.character_value = mathcharacter; } set_sa_item(mathcode_head, n, v, level); - if (int_par(tracing_assigns_code) > 1) { + if (tracing_assigns_par > 1) { begin_diagnostic(); print_char('{'); tprint("assigning"); @@ -242,7 +242,7 @@ static void unsavedelcode(quarterword gl) st = delcode_head->stack[delcode_head->stack_ptr]; if (st.level > 0) { rawset_sa_item(delcode_head, st.code, st.value); - if (int_par(tracing_restores_code) > 1) { + if (tracing_restores_par > 1) { begin_diagnostic(); print_char('{'); tprint("restoring"); @@ -267,7 +267,7 @@ void set_del_code(int n, int smathfamily, int smathcharacter, int lmathfamily, i v.del_code_value.large_family_value = lmathfamily; v.del_code_value.large_character_value = lmathcharacter; set_sa_item(delcode_head, n, v, gl); /* always global */ - if (int_par(tracing_assigns_code) > 1) { + if (tracing_assigns_par > 1) { begin_diagnostic(); print_char('{'); tprint("assigning"); diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.w b/Build/source/texk/web2c/luatexdir/tex/mlist.w index bceb4e88ad1..331be47de7d 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mlist.w +++ b/Build/source/texk/web2c/luatexdir/tex/mlist.w @@ -51,12 +51,7 @@ to italics. Axis are another area of concern, as it looks like opentype math fon already apply that shift. @ @c -#define math_old mathoption_int_par(c_mathoption_old_code) -#define math_no_italic_compensation mathoption_int_par(c_mathoption_no_italic_compensation_code) -#define math_no_char_italic mathoption_int_par(c_mathoption_no_char_italic_code) -#define math_use_old_fraction_scaling mathoption_int_par(c_mathoption_use_old_fraction_scaling_code) - -#define is_new_mathfont(A) ((font_math_params(A) >0) && (math_old == 0)) +#define is_new_mathfont(A) ((font_math_params(A) >0) && (math_old_par == 0)) #define is_old_mathfont(A,B) ((font_math_params(A)==0) && (font_params(A)>=(B))) @ @@ -68,17 +63,6 @@ already apply that shift. #include "lua/luatex-api.h" @ @c -#define delimiter_factor int_par(delimiter_factor_code) -#define delimiter_shortfall dimen_par(delimiter_shortfall_code) -#define bin_op_penalty int_par(bin_op_penalty_code) -#define rel_penalty int_par(rel_penalty_code) -#define null_delimiter_space dimen_par(null_delimiter_space_code) -#define script_space dimen_par(script_space_code) -#define disable_lig int_par(disable_lig_code) -#define disable_kern int_par(disable_kern_code) -#define disable_space int_par(disable_space_code) -#define scripts_mode int_par(math_scripts_mode_code) - #define nDEBUG #define reset_attributes(p,newatt) do { \ @@ -322,8 +306,8 @@ static scaled get_delimiter_height(scaled max_d, scaled max_h, boolean axis) { /* |delta1| is max distance from axis */ delta1 = delta2; } - delta = (delta1 / 500) * delimiter_factor; - delta2 = delta1 + delta1 - delimiter_shortfall; + delta = (delta1 / 500) * delimiter_factor_par; + delta2 = delta1 + delta1 - delimiter_shortfall_par; if (delta < delta2) { return delta2; } else { @@ -884,27 +868,27 @@ backward compatibility with \.{\\scriptspace}. @c static void finalize_math_parameters(void) { - int saved_trace = int_par(tracing_assigns_code); - int_par(tracing_assigns_code) = 0; + int saved_trace = tracing_assigns_par; + tracing_assigns_par = 0; if (get_math_param(math_param_space_after_script, display_style) == undefined_math_parameter) { def_math_param(math_param_space_after_script, display_style, - script_space, level_one); + script_space_par, level_one); def_math_param(math_param_space_after_script, text_style, - script_space, level_one); + script_space_par, level_one); def_math_param(math_param_space_after_script, script_style, - script_space, level_one); + script_space_par, level_one); def_math_param(math_param_space_after_script, script_script_style, - script_space, level_one); + script_space_par, level_one); def_math_param(math_param_space_after_script, cramped_display_style, - script_space, level_one); + script_space_par, level_one); def_math_param(math_param_space_after_script, cramped_text_style, - script_space, level_one); + script_space_par, level_one); def_math_param(math_param_space_after_script, cramped_script_style, - script_space, level_one); + script_space_par, level_one); def_math_param(math_param_space_after_script, cramped_script_script_style, - script_space, level_one); + script_space_par, level_one); } - int_par(tracing_assigns_code) = saved_trace; + tracing_assigns_par = saved_trace; } @ In order to convert mlists to hlists, i.e., noads to nodes, we need several @@ -968,7 +952,7 @@ static pointer do_fraction_rule(scaled t, pointer att) { pointer p; /* the new node */ p = new_rule(normal_rule); - rule_dir(p) = math_direction; + rule_dir(p) = math_direction_par; height(p) = t; depth(p) = 0; reset_attributes(p, att); @@ -991,7 +975,7 @@ static pointer overbar(pointer b, scaled k, scaled t, scaled ht, pointer att) p = new_kern(ht); reset_attributes(p, att); couple_nodes(p,q); - q = vpackage(p, 0, additional, max_dimen, math_direction); + q = vpackage(p, 0, additional, max_dimen, math_direction_par); reset_attributes(q, att); return q; } @@ -1134,7 +1118,7 @@ static pointer get_delim_box(pointer q, extinfo * ext, internal_font_number f, s NULL }; tex_error("Variant part doesn't exist.", hlp); - width(b) = null_delimiter_space; + width(b) = null_delimiter_space_par; return b; } if (cur->extender > 0) @@ -1447,7 +1431,7 @@ static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat, width(b) = 0; } else { /* use this width if no delimiter was found */ - width(b) = null_delimiter_space; + width(b) = null_delimiter_space_par; } if (delta != NULL) { *delta = 0; @@ -1595,7 +1579,6 @@ void run_mlist_to_hlist(halfword p, boolean penalties, int mstyle) { int callback_id; int a, sfix; - lua_State *L = Luas; if (p == null) { vlink(temp_head) = null; return; @@ -1603,26 +1586,26 @@ void run_mlist_to_hlist(halfword p, boolean penalties, int mstyle) finalize_math_parameters(); callback_id = callback_defined(mlist_to_hlist_callback); if (callback_id > 0) { - sfix = lua_gettop(L); - if (!get_callback(L, callback_id)) { - lua_settop(L, sfix); + sfix = lua_gettop(Luas); + if (!get_callback(Luas, callback_id)) { + lua_settop(Luas, sfix); return; } alink(p) = null ; - nodelist_to_lua(L, p); - lua_push_math_style_name(L,mstyle); - lua_pushboolean(L, penalties); - if (lua_pcall(L, 3, 1, 0) != 0) { /* 3 args, 1 result */ + nodelist_to_lua(Luas, p); + lua_push_math_style_name(Luas, mstyle); + lua_pushboolean(Luas, penalties); + if (lua_pcall(Luas, 3, 1, 0) != 0) { /* 3 args, 1 result */ char errmsg[256]; /* temp hack ... we will have a formatted error */ - snprintf(errmsg, 255, "error: %s\n", lua_tostring(L, -1)); + snprintf(errmsg, 255, "error: %s\n", lua_tostring(Luas, -1)); errmsg[255]='\0'; - lua_settop(L, sfix); + lua_settop(Luas, sfix); normal_error("mlist to hlist",errmsg); /* to be done */ return; } - a = nodelist_from_lua(L); + a = nodelist_from_lua(Luas); /* alink(vlink(a)) = null; */ - lua_settop(L, sfix); + lua_settop(Luas, sfix); vlink(temp_head) = a; } else if (callback_id == 0) { mlist_to_hlist(p, penalties, mstyle); @@ -1803,7 +1786,7 @@ static void make_under(pointer q, int cur_style) couple_nodes(x,p); r = do_fraction_rule(underbar_rule(cur_style), node_attr(q)); couple_nodes(p,r); - y = vpackage(x, 0, additional, max_dimen, math_direction); + y = vpackage(x, 0, additional, max_dimen, math_direction_par); reset_attributes(y, node_attr(q)); delta = height(y) + depth(y) + underbar_kern(cur_style); height(y) = height(x); @@ -2304,7 +2287,7 @@ static void do_make_math_accent(pointer q, internal_font_number f, int c, int fl /* just take the center */ sa = half(width(y)); } - if (math_direction == dir_TRT) { + if (math_direction_par == dir_TRT) { shift_amount(y) = s + sa - width(y); } else { shift_amount(y) = s - sa; @@ -2312,7 +2295,7 @@ static void do_make_math_accent(pointer q, internal_font_number f, int c, int fl } else { if (width(y)== 0) { shift_amount(y) = s + w; - } else if (math_direction == dir_TRT) { + } else if (math_direction_par == dir_TRT) { shift_amount(y) = s + width(y); /* ok? */ } else { shift_amount(y) = s + half(w - width(y)); @@ -2328,7 +2311,7 @@ static void do_make_math_accent(pointer q, internal_font_number f, int c, int fl couple_nodes(x,y); y = x; } - r = vpackage(y, 0, additional, max_dimen, math_direction); + r = vpackage(y, 0, additional, max_dimen, math_direction_par); reset_attributes(r, node_attr(q)); width(r) = width(x); y = r; @@ -2564,7 +2547,7 @@ static void make_fraction(pointer q, int cur_style) point to it */ if (is_new_mathfont(cur_f)) { - if (math_use_old_fraction_scaling) { + if (math_use_old_fraction_scaling_par) { delta = fraction_del_size_old(cur_style); } else { delta = fraction_del_size_new(cur_style); @@ -2711,7 +2694,7 @@ static scaled make_op(pointer q, int cur_style) type(v) = vlist_node; if (is_new_mathfont(cur_f)) { n = null; - if (! math_no_italic_compensation) { + if (! math_no_italic_compensation_par) { n = nucleus(q); if (n != null) { if ((type(n) == sub_mlist_node) || (type(n) == sub_box_node)) { @@ -2885,7 +2868,7 @@ static void make_ord(pointer q) ligatures only when this convention makes sense */ - if (disable_lig == 0 && has_lig(cur_f, a)) { + if (disable_lig_par == 0 && has_lig(cur_f, a)) { lig = get_ligature(cur_f, a, cur_c); if (is_valid_ligature(lig)) { check_interrupt(); /* allow a way out of infinite ligature loop */ @@ -2941,7 +2924,7 @@ static void make_ord(pointer q) goto RESTART; } } - if (disable_kern == 0 && has_kern(cur_f, a)) { + if (disable_kern_par == 0 && has_kern(cur_f, a)) { /* todo: should this use mathkerns? */ k = get_kern(cur_f, a, cur_c); if (k != 0) { @@ -3239,7 +3222,7 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled */ x = clean_box(subscr(q), sub_style(cur_style), cur_style); width(x) = width(x) + space_after_script(cur_style); - switch (scripts_mode) { + switch (scripts_mode_par) { case 1: shift_down = sub_shift_down(cur_style) ; break; @@ -3289,7 +3272,7 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled */ x = clean_box(supscr(q), sup_style(cur_style), cur_style); width(x) = width(x) + space_after_script(cur_style); - switch (scripts_mode) { + switch (scripts_mode_par) { case 1: shift_up = sup_shift_up(cur_style); break; @@ -3344,7 +3327,7 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled */ y = clean_box(subscr(q), sub_style(cur_style), cur_style); width(y) = width(y) + space_after_script(cur_style); - switch (scripts_mode) { + switch (scripts_mode_par) { case 1: shift_down = sub_shift_down(cur_style) ; break; @@ -3413,7 +3396,7 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled couple_nodes(x,p); couple_nodes(p,y); /* we end up with funny dimensions */ - x = vpackage(x, 0, additional, max_dimen, math_direction); + x = vpackage(x, 0, additional, max_dimen, math_direction_par); reset_attributes(x, node_attr(q)); shift_amount(x) = shift_down; } @@ -3758,7 +3741,7 @@ static pointer check_nucleus_complexity(halfword q, scaled * delta, int cur_styl p = new_glyph(cur_f, cur_c); reset_attributes(p, node_attr(nucleus(q))); if (is_new_mathfont(cur_f)) { - if (! math_no_char_italic) { + if (! math_no_char_italic_par) { /* keep italic, but bad with two successive letters */ } else if (get_char_cat_code(cur_c) == 11) { /* no italic correction in mid-word of text font */ @@ -4087,10 +4070,10 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style) t_subtype = subtype(q); switch (t_subtype) { case bin_noad_type: - pen = bin_op_penalty; + pen = bin_op_penalty_par; break; case rel_noad_type: - pen = rel_penalty; + pen = rel_penalty_par; break; case vcenter_noad_type: case over_noad_type: diff --git a/Build/source/texk/web2c/luatexdir/tex/nesting.w b/Build/source/texk/web2c/luatexdir/tex/nesting.w index 045bf78febe..d9e7cf744ee 100644 --- a/Build/source/texk/web2c/luatexdir/tex/nesting.w +++ b/Build/source/texk/web2c/luatexdir/tex/nesting.w @@ -19,14 +19,11 @@ @ @c - #include "ptexlib.h" @ these are for |show_activities| @c #define page_goal page_so_far[0] -#define count(A) eqtb[count_base+(A)].cint - @ \TeX\ is typically in the midst of building many lists at once. For example, when a math formula is being processed, \TeX\ is in math mode and @@ -251,9 +248,7 @@ void initialize_nesting(void) init_math_fields(); } - - -@ Here is a common way to make the current list grow: +@ Here is a common way to make the current list grow: @c void tail_append(halfword p) @@ -262,7 +257,6 @@ void tail_append(halfword p) cur_list.tail_field = vlink(cur_list.tail_field); } - @ @c halfword pop_tail(void) { @@ -311,7 +305,6 @@ void push_nest(void) init_math_fields(); } - @ Conversely, when \TeX\ is finished on the current level, the former state is restored by calling |pop_nest|. This routine will never be called at the lowest semantic level, nor will it be called unless |head| @@ -324,7 +317,7 @@ void pop_nest(void) decr(nest_ptr); } -@ Here is a procedure that displays what \TeX\ is working on, at all levels. +@ Here is a procedure that displays what \TeX\ is working on, at all levels. @c void show_activities(void) @@ -343,7 +336,7 @@ void show_activities(void) print_int(abs(nest[p].ml_field)); /* we dont do this any more */ #if 0 - + if (m == hmode) if (nest[p].pg_field != 040600000) { tprint(" (language"); diff --git a/Build/source/texk/web2c/luatexdir/tex/packaging.w b/Build/source/texk/web2c/luatexdir/tex/packaging.w index 4a5ab77c690..ba0a5d764ac 100644 --- a/Build/source/texk/web2c/luatexdir/tex/packaging.w +++ b/Build/source/texk/web2c/luatexdir/tex/packaging.w @@ -21,17 +21,6 @@ #include "ptexlib.h" -@ @c -#define scan_normal_dimen() scan_dimen(false,false,false) - -#define prev_depth cur_list.prev_depth_field -#define space_factor cur_list.space_factor_field -#define box(A) eqtb[box_base+(A)].hh.rh - -#define every_hbox equiv(every_hbox_loc) -#define every_vbox equiv(every_vbox_loc) -#define box_max_depth dimen_par(box_max_depth_code) - @ We're essentially done with the parts of \TeX\ that are concerned with the input (|get_next|) and the output (|ship_out|). So it's time to get heavily into the remaining part, which does the real work of typesetting. @@ -286,7 +275,7 @@ void scan_full_spec(group_code c, int spec_direction, int just_pack) if (! done) { scan_left_brace(); } - /* no gain: if (body_direction != spec_direction) etc */ + /* no gain: if (body_direction_par != spec_direction) etc */ eq_word_define(int_base + body_direction_code, spec_direction); eq_word_define(int_base + par_direction_code, spec_direction); eq_word_define(int_base + text_direction_code, spec_direction); @@ -439,7 +428,7 @@ scaled kern_stretch(halfword p) return 0; } /* we use the old logic, kind of, but average the ef as we might depend on proper overlap */ - m = (font_max_shrink(font(l)) + font_max_shrink(font(r)))/2; + m = (font_max_stretch(font(l)) + font_max_stretch(font(r)))/2; if (m == 0) { /* nothing to kern */ return 0; @@ -478,7 +467,7 @@ scaled kern_shrink(halfword p) // and a reason to kern if ((font(l) != font(r)) || (font_max_shrink(font(l)) == 0)) return 0; - m = font_max_stretch(font(l)); + m = font_max_shrink(font(l)); d = get_kern(font(l), character(l), character(r)); // real kern, so what is width(p) then; the messed up one d = round_xn_over_d(d, 1000 - m, 1000); return round_xn_over_d(width(p) - d, get_ef_code(font(l), character(l)), 1000); @@ -632,7 +621,7 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction) halfword pack_interrupt[8]; scaled font_stretch = 0; scaled font_shrink = 0; - int adjust_spacing = int_par(adjust_spacing_code); + int adjust_spacing = adjust_spacing_par; /* int font_expand_ratio = 0; @@ -640,7 +629,7 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction) last_badness = 0; r = new_node(hlist_node, min_quarterword); /* the box node that will be returned */ if (pack_direction == -1) { - hpack_dir = text_direction; + hpack_dir = text_direction_par; } else { hpack_dir = pack_direction; } @@ -943,7 +932,7 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction) is sufficiently bad. */ last_badness = badness(x, total_stretch[normal]); - if (last_badness > int_par(hbadness_code)) { + if (last_badness > hbadness_par) { int callback_id = callback_defined(hpack_quality_callback); if (callback_id > 0) { halfword rule = null; @@ -1010,15 +999,15 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction) Report an overfull hbox and |goto common_ending|, if this box is sufficiently bad. */ - if ((overshoot > dimen_par(hfuzz_code)) || (int_par(hbadness_code) < 100)) { + if ((overshoot > hfuzz_par) || (hbadness_par < 100)) { int callback_id = callback_defined(hpack_quality_callback); halfword rule = null; if (callback_id > 0) { run_callback(callback_id, "SdNdd->N","overfull",overshoot,r,abs(pack_begin_line),line,&rule); - } else if (dimen_par(overfull_rule_code) > 0) { + } else if (overfull_rule_par > 0) { rule = new_rule(normal_rule); rule_dir(rule) = box_dir(r); - width(rule) = dimen_par(overfull_rule_code); + width(rule) = overfull_rule_par; } if (rule != null) { while (vlink(q) != null) { @@ -1041,7 +1030,7 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction) sufficiently bad. */ last_badness = badness(-x, total_shrink[normal]); - if (last_badness > int_par(hbadness_code)) { + if (last_badness > hbadness_par) { int callback_id = callback_defined(hpack_quality_callback); if (callback_id > 0) { halfword rule = null; @@ -1119,7 +1108,7 @@ halfword filtered_hpack(halfword p, halfword qt, scaled w, int m, int grp, int p q = vlink(p); /* q = new_node(hlist_node, min_quarterword); - box_dir(q) = (pac == -1) ? text_direction : pac; + box_dir(q) = (pac == -1) ? text_direction_par : pac; width(q) = w; return q; */ @@ -1147,7 +1136,7 @@ scaled_whd natural_sizes(halfword p, halfword pp, glue_ratio g_mult, scaled gp = 0; scaled gm = 0; if (pack_direction == -1) { - hpack_dir = text_direction; + hpack_dir = text_direction_par; } else { hpack_dir = pack_direction; } @@ -1292,7 +1281,7 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction) last_badness = 0; r = new_node(vlist_node, 0); if (pack_direction == -1) { - box_dir(r) = body_direction; + box_dir(r) = body_direction_par; } else { box_dir(r) = pack_direction; } @@ -1434,7 +1423,7 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction) is sufficiently bad. */ last_badness = badness(x, total_stretch[normal]); - if (last_badness > int_par(vbadness_code)) { + if (last_badness > vbadness_par) { int callback_id = callback_defined(vpack_quality_callback); if (callback_id > 0) { if (last_badness > 100) { @@ -1492,7 +1481,7 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction) Report an overfull vbox and |goto common_ending|, if this box is sufficiently bad. */ - if ((overshoot > dimen_par(vfuzz_code)) || (int_par(vbadness_code) < 100)) { + if ((overshoot > vfuzz_par) || (vbadness_par < 100)) { int callback_id = callback_defined(vpack_quality_callback); if (callback_id > 0) { run_callback(callback_id, "SdNdd->","overfull",overshoot,r,abs(pack_begin_line),line); @@ -1512,7 +1501,7 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction) sufficiently bad. */ last_badness = badness(-x, total_shrink[normal]); - if (last_badness > int_par(vbadness_code)) { + if (last_badness > vbadness_par) { int callback_id = callback_defined(vpack_quality_callback); if (callback_id > 0) { run_callback(callback_id, "SdNdd->","tight",last_badness,r,abs(pack_begin_line),line); @@ -1579,7 +1568,7 @@ void package(int c) { halfword saved0, saved2, saved3, saved4; int grp = cur_group; - scaled d = box_max_depth; /* max depth */ + scaled d = box_max_depth_par; /* max depth */ unsave(); save_ptr -= 5; saved0 = saved_value(0); @@ -1633,23 +1622,23 @@ void append_to_vlist(halfword b, int location) halfword result = null; halfword next_depth = ignore_depth; boolean prev_set = false ; - if (lua_appendtovlist_callback(b,location,prev_depth,mirrored,&result,&next_depth,&prev_set)) { + if (lua_appendtovlist_callback(b,location,prev_depth_par,mirrored,&result,&next_depth,&prev_set)) { while (result != null) { couple_nodes(cur_list.tail_field, result); cur_list.tail_field = result; result = vlink(result); } if (prev_set) { - prev_depth = next_depth; + prev_depth_par = next_depth; } } else { - if (prev_depth > ignore_depth) { + if (prev_depth_par > ignore_depth) { if (mirrored) { - d = width(glue_par(baseline_skip_code)) - prev_depth - depth(b); + d = width(baseline_skip_par) - prev_depth_par - depth(b); } else { - d = width(glue_par(baseline_skip_code)) - prev_depth - height(b); + d = width(baseline_skip_par) - prev_depth_par - height(b); } - if (d < dimen_par(line_skip_limit_code)) { + if (d < line_skip_limit_par) { p = new_param_glue(line_skip_code); } else { p = new_skip_param(baseline_skip_code); @@ -1661,9 +1650,9 @@ void append_to_vlist(halfword b, int location) couple_nodes(cur_list.tail_field, b); cur_list.tail_field = b; if (mirrored) { - prev_depth = height(b); + prev_depth_par = height(b); } else { - prev_depth = depth(b); + prev_depth_par = depth(b); } } } @@ -1959,7 +1948,7 @@ halfword vsplit(halfword n, scaled h, int m) error(); return null; } - q = vert_break(list_ptr(v), h, dimen_par(split_max_depth_code)); + q = vert_break(list_ptr(v), h, split_max_depth_par); /* Look at all the marks in nodes before the break, and set the final link to |null| at the break. It's possible that the box begins with @@ -1990,7 +1979,7 @@ halfword vsplit(halfword n, scaled h, int m) p = vlink(p); } } - q = prune_page_top(q, int_par(saving_vdiscards_code) > 0); + q = prune_page_top(q, saving_vdiscards_par > 0); p = list_ptr(v); list_ptr(v) = null; flush_node(v); @@ -1998,12 +1987,12 @@ halfword vsplit(halfword n, scaled h, int m) /* the |eq_level| of the box stays the same */ box(n) = null; } else { - box(n) = filtered_vpackage(q, 0, additional, dimen_par(max_depth_code), split_keep_group, vdir, 0, 0); + box(n) = filtered_vpackage(q, 0, additional, max_depth_par, split_keep_group, vdir, 0, 0); } if (m == exactly) { - return filtered_vpackage(p, h, exactly, dimen_par(split_max_depth_code), split_off_group, vdir, 0, 0); + return filtered_vpackage(p, h, exactly, split_max_depth_par, split_off_group, vdir, 0, 0); } else { - return filtered_vpackage(p, 0, additional, dimen_par(max_depth_code), split_off_group, vdir, 0, 0); + return filtered_vpackage(p, 0, additional, max_depth_par, split_off_group, vdir, 0, 0); } } @@ -2020,6 +2009,7 @@ void begin_box(int box_context) int n; /* a box number */ int spec_direction = -1; int just_pack = 0; + int split_mode = exactly ; switch (cur_chr) { case box_code: scan_register_num(); @@ -2077,15 +2067,17 @@ void begin_box(int box_context) */ scan_register_num(); n = cur_val; - if (!scan_keyword("to")) { + if (scan_keyword("upto")) { + split_mode = additional ; + } else if (!scan_keyword("to")) { print_err("Missing `to' inserted"); help2("I'm working on `\\vsplit<box number> to <dimen>';", "will look for the <dimen> next."); error(); } scan_normal_dimen(); - cur_box = vsplit(n, cur_val, additional); - break; + cur_box = vsplit(n, cur_val, split_mode); + break; default: /* Initiate the construction of an hbox or vbox, then |return|. Here is @@ -2111,13 +2103,13 @@ void begin_box(int box_context) set_saved_record(0, saved_boxcontext, 0, box_context); switch (abs(cur_list.mode_field)) { case vmode: - spec_direction = body_direction; + spec_direction = body_direction_par; break; case hmode: - spec_direction = text_direction; + spec_direction = text_direction_par; break; case mmode: - spec_direction = math_direction; + spec_direction = math_direction_par; break; } if (k == hmode) { @@ -2137,13 +2129,13 @@ void begin_box(int box_context) push_nest(); cur_list.mode_field = -k; if (k == vmode) { - prev_depth = ignore_depth; - if (every_vbox != null) - begin_token_list(every_vbox, every_vbox_text); + prev_depth_par = ignore_depth; + if (every_vbox_par != null) + begin_token_list(every_vbox_par, every_vbox_text); } else { - space_factor = 1000; - if (every_hbox != null) - begin_token_list(every_hbox, every_hbox_text); + space_factor_par = 1000; + if (every_hbox_par != null) + begin_token_list(every_hbox_par, every_hbox_text); } return; break; diff --git a/Build/source/texk/web2c/luatexdir/tex/primitive.w b/Build/source/texk/web2c/luatexdir/tex/primitive.w index a173e133d44..8c6592c9edf 100644 --- a/Build/source/texk/web2c/luatexdir/tex/primitive.w +++ b/Build/source/texk/web2c/luatexdir/tex/primitive.w @@ -555,7 +555,7 @@ void print_cmd_chr(quarterword cmd, halfword chr_code) print_hex(chr_code); break; case math_given_cmd: - if (mathoption_int_par(c_mathoption_umathcode_meaning_code) == 1) { + if (math_umathcode_meaning_par == 1) { tprint_esc("Umathchar"); show_mathcode_value(mathchar_from_integer(chr_code, tex_mathcode)); } else { diff --git a/Build/source/texk/web2c/luatexdir/tex/printing.w b/Build/source/texk/web2c/luatexdir/tex/printing.w index 478d55f88ba..006392810b9 100644 --- a/Build/source/texk/web2c/luatexdir/tex/printing.w +++ b/Build/source/texk/web2c/luatexdir/tex/printing.w @@ -22,8 +22,6 @@ #include "lua/luatex-api.h" /* for luatex_banner */ @ @c -#define font_id_text(A) cs_text(font_id_base+(A)) - #define wlog(A) fputc(A,log_file) #define wterm(A) fputc(A,term_out) @@ -182,7 +180,7 @@ void print_char(int s) formatted_warning("print","weird character %i",s); return; } - if (s == int_par(new_line_char_code)) { + if (s == new_line_char_par) { if (selector < pseudo) { print_ln(); return; @@ -270,7 +268,7 @@ void print(int s) print_char(s); return; } - if (s == int_par(new_line_char_code)) { + if (s == new_line_char_par) { if (selector < pseudo) { print_ln(); return; @@ -364,7 +362,7 @@ void tprint(const char *sss) { char *buffer = NULL; int i = 0; /* buffer index */ - int newlinechar = int_par(new_line_char_code); + int newlinechar = new_line_char_par; int dolog = 0; int doterm = 0; switch (selector) { @@ -509,22 +507,22 @@ void log_banner(const char *v) "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; - unsigned month = (unsigned) int_par(month_code); + unsigned month = (unsigned) month_par; if (month > 12) month = 0; fprintf(log_file, "This is " MyName ", Version %s%s ", v, WEB2CVERSION); print(format_ident); print_char(' '); print_char(' '); - print_int(int_par(day_code)); + print_int(day_par); print_char(' '); fprintf(log_file, "%s", months[month]); print_char(' '); - print_int(int_par(year_code)); + print_int(year_par); print_char(' '); - print_two(int_par(time_code) / 60); + print_two(time_par / 60); print_char(':'); - print_two(int_par(time_code) % 60); + print_two(time_par % 60); if (shellenabledp) { wlog_cr(); wlog(' '); @@ -550,7 +548,7 @@ the user's escape character (which is usually a backslash). @c void print_esc(str_number s) { - int c = int_par(escape_char_code); /* Set variable |c| to the current escape character */ + int c = escape_char_par; /* Set variable |c| to the current escape character */ if (c >= 0 && c < STRING_OFFSET) print(c); print(s); @@ -561,7 +559,7 @@ void print_esc(str_number s) @c void tprint_esc(const char *s) { - int c = int_par(escape_char_code); /* Set variable |c| to the current escape character */ + int c = escape_char_par; /* Set variable |c| to the current escape character */ if (c >= 0 && c < STRING_OFFSET) print(c); tprint(s); @@ -724,8 +722,7 @@ void print_cs(int p) } else { print_esc(t); if (single_letter(t)) { - if (get_cat_code(int_par(cat_code_table_code), - pool_to_unichar(str_string(t))) == letter_cmd) + if (get_cat_code(cat_code_table_par, pool_to_unichar(str_string(t))) == letter_cmd) print_char(' '); } else { print_char(' '); @@ -851,7 +848,7 @@ void print_font_identifier(internal_font_number f) tprint_esc("FONT"); print_int(f); } - if (int_par(tracing_fonts_code) > 0) { + if (tracing_fonts_par > 0) { tprint(" ("); print_font_name(f); if (font_size(f) != font_dsize(f)) { @@ -955,8 +952,8 @@ int breadth_max; /* maximum number of items shown at the same list level */ @c void show_box(halfword p) { - depth_threshold = int_par(show_box_depth_code); - breadth_max = int_par(show_box_breadth_code); + depth_threshold = show_box_depth_par; + breadth_max = show_box_breadth_par; if (breadth_max <= 0) breadth_max = 5; /* the show starts at |p| */ @@ -1072,7 +1069,7 @@ Here are two routines that adjust the destination of print commands: void begin_diagnostic(void) { global_old_setting = selector; - if ((int_par(tracing_online_code) <= 0) && (selector == term_and_log)) { + if ((tracing_online_par <= 0) && (selector == term_and_log)) { decr(selector); if (history == spotless) history = warning_issued; diff --git a/Build/source/texk/web2c/luatexdir/tex/scanning.h b/Build/source/texk/web2c/luatexdir/tex/scanning.h index 729fcda20ef..f5f620c6746 100644 --- a/Build/source/texk/web2c/luatexdir/tex/scanning.h +++ b/Build/source/texk/web2c/luatexdir/tex/scanning.h @@ -45,6 +45,8 @@ extern void scan_something_internal(int level, boolean negative); extern void scan_limited_int(int max, const char *name); +extern void negate_cur_val(boolean delete_glue); + # define scan_register_num() scan_limited_int(65535,"register code") # define scan_mark_num() scan_limited_int(65535,"marks code") # define scan_char_num() scan_limited_int(biggest_char,"character code") diff --git a/Build/source/texk/web2c/luatexdir/tex/scanning.w b/Build/source/texk/web2c/luatexdir/tex/scanning.w index 907d25f5bac..658f149adaf 100644 --- a/Build/source/texk/web2c/luatexdir/tex/scanning.w +++ b/Build/source/texk/web2c/luatexdir/tex/scanning.w @@ -22,19 +22,6 @@ #include "ptexlib.h" @ @c -#define prev_depth cur_list.prev_depth_field -#define space_factor cur_list.space_factor_field -#define par_shape_ptr equiv(par_shape_loc) -#define font_id_text(A) cs_text(font_id_base+(A)) - -#define attribute(A) eqtb[attribute_base+(A)].hh.rh -#define dimen(A) eqtb[scaled_base+(A)].hh.rh -#undef skip -#define skip(A) eqtb[skip_base+(A)].hh.rh -#define mu_skip(A) eqtb[mu_skip_base+(A)].hh.rh -#define count(A) eqtb[count_base+(A)].hh.rh -#define box(A) equiv(box_base+(A)) - static void scan_expr(void); @ Let's turn now to some procedures that \TeX\ calls upon frequently to digest @@ -165,7 +152,7 @@ static void downgrade_cur_val(boolean delete_glue) decr(cur_val_level); } -static void negate_cur_val(boolean delete_glue) +void negate_cur_val(boolean delete_glue) { halfword m; if (cur_val_level >= glue_val_level) { @@ -208,6 +195,9 @@ static boolean short_scan_something_internal(int cmd, int chr, int level, scanned_result(eqtb[m].cint, int_val_level); break; case assign_dir_cmd: + if (m == (int_base + line_direction_code)) { + m = int_base + text_direction_code; + } scanned_result(eqtb[m].cint, dir_val_level); break; case assign_dimen_cmd: @@ -215,11 +205,9 @@ static boolean short_scan_something_internal(int cmd, int chr, int level, break; case assign_glue_cmd: scanned_result(equiv(m), glue_val_level); -// cur_val = new_spec(cur_val); break; case assign_mu_glue_cmd: scanned_result(equiv(m), mu_val_level); -// cur_val = new_spec(cur_val); break; case math_style_cmd: scanned_result(m, int_val_level); @@ -239,9 +227,9 @@ static boolean short_scan_something_internal(int cmd, int chr, int level, else scanned_result(0, int_val_level); } else if (m == vmode) { - scanned_result(prev_depth, dimen_val_level); + scanned_result(prev_depth_par, dimen_val_level); } else { - scanned_result(space_factor, int_val_level); + scanned_result(space_factor_par, int_val_level); } break; case set_prev_graf_cmd: @@ -279,10 +267,10 @@ static boolean short_scan_something_internal(int cmd, int chr, int level, break; case set_tex_shape_cmd: /* Fetch the |par_shape| size */ - if (par_shape_ptr == null) + if (par_shape_par_ptr == null) cur_val = 0; else - cur_val = vinfo(par_shape_ptr + 1); + cur_val = vinfo(par_shape_par_ptr + 1); cur_val_level = int_val_level; break; case set_etex_shape_cmd: @@ -381,17 +369,17 @@ static boolean short_scan_something_internal(int cmd, int chr, int level, case par_shape_dimen_code: q = cur_chr - par_shape_length_code; scan_int(); - if ((par_shape_ptr == null) || (cur_val <= 0)) { + if ((par_shape_par_ptr == null) || (cur_val <= 0)) { cur_val = 0; } else { if (q == 2) { q = cur_val % 2; cur_val = (cur_val + q) / 2; } - if (cur_val > vinfo(par_shape_ptr + 1)) - cur_val = vinfo(par_shape_ptr + 1); + if (cur_val > vinfo(par_shape_par_ptr + 1)) + cur_val = vinfo(par_shape_par_ptr + 1); cur_val = - varmem[par_shape_ptr + 2 * cur_val - q + 1].cint; + varmem[par_shape_par_ptr + 2 * cur_val - q + 1].cint; } cur_val_level = dimen_val_level; break; @@ -531,7 +519,7 @@ static boolean short_scan_something_internal(int cmd, int chr, int level, break; case lastskip_code: if (last_glue != max_halfword) - cur_val = last_glue; /* maybe new_glue */ + cur_val = last_glue; /* maybe new_glue */ break; case last_node_type_code: cur_val = last_node_type; @@ -614,7 +602,7 @@ void scan_something_internal(int level, boolean negative) cur_val1 = get_sf_code(cur_val); scanned_result(cur_val1, int_val_level); } else if (m == cat_code_base) { - cur_val1 = get_cat_code(int_par(cat_code_table_code), cur_val); + cur_val1 = get_cat_code(cat_code_table_par, cur_val); scanned_result(cur_val1, int_val_level); } else { confusion("def_char"); @@ -690,11 +678,11 @@ void scan_something_internal(int level, boolean negative) } else { cur_val1 = get_math_param(cur_val1, cur_chr); if (cur_val1 == thin_mu_skip_code) - cur_val1 = glue_par(thin_mu_skip_code); + cur_val1 = thin_mu_skip_par; else if (cur_val1 == med_mu_skip_code) - cur_val1 = glue_par(med_mu_skip_code); + cur_val1 = med_mu_skip_par; else if (cur_val1 == thick_mu_skip_code) - cur_val1 = glue_par(thick_mu_skip_code); + cur_val1 = thick_mu_skip_par; scanned_result(cur_val1, mu_val_level); } break; @@ -803,28 +791,28 @@ void scan_something_internal(int level, boolean negative) goto DEFAULT; break; case 2: - cur_val = get_pre_hyphen_char(int_par(language_code)); + cur_val = get_pre_hyphen_char(language_par); cur_val_level = int_val_level; break; case 3: - cur_val = get_post_hyphen_char(int_par(language_code)); + cur_val = get_post_hyphen_char(language_par); cur_val_level = int_val_level; break; case 4: - cur_val = get_pre_exhyphen_char(int_par(language_code)); + cur_val = get_pre_exhyphen_char(language_par); cur_val_level = int_val_level; break; case 5: - cur_val = get_post_exhyphen_char(int_par(language_code)); + cur_val = get_post_exhyphen_char(language_par); cur_val_level = int_val_level; break; case 6: - cur_val = get_hyphenation_min(int_par(language_code)); + cur_val = get_hyphenation_min(language_par); cur_val_level = int_val_level; break; case 7: scan_int(); - cur_val = get_hj_code(int_par(language_code),cur_val); + cur_val = get_hj_code(language_par,cur_val); cur_val_level = int_val_level; break; } @@ -1192,15 +1180,16 @@ static void scan_dimen_out_of_range_error(void) { void scan_dimen(boolean mu, boolean inf, boolean shortcut) { - boolean negative; /* should the answer be negated? */ - int f = 0; /* numerator of a fraction whose denominator is $2^{16}$ */ - int num, denom; /* conversion ratio for the scanned units */ - halfword q; /* top of decimal digit stack */ - scaled v; /* an internal dimension */ - int save_cur_val; /* temporary storage of |cur_val| */ + boolean negative = false; /* should the answer be negated? */ + boolean is_true = false; + int f = 0; /* numerator of a fraction whose denominator is $2^{16}$ */ + int num = 0; /* conversion ratio for the scanned units */ + int denom = 0; + halfword q; /* top of decimal digit stack */ + scaled v; /* an internal dimension */ + int save_cur_val; /* temporary storage of |cur_val| */ arith_error = false; cur_order = normal; - negative = false; if (!shortcut) { /* Get the next non-blank non-sign... */ do { @@ -1370,7 +1359,7 @@ void scan_dimen(boolean mu, boolean inf, boolean shortcut) } else if (scan_keyword("ex")) { v = x_height(get_cur_font()); } else if (scan_keyword("px")) { - v = dimen_par(px_dimen_code); + v = px_dimen_par; } else { goto PICKUP_UNIT; } @@ -1388,7 +1377,7 @@ void scan_dimen(boolean mu, boolean inf, boolean shortcut) */ PICKUP_UNIT: if (scan_keyword("pt")) { - goto ATTACH_FRACTION; /* the easy case */ + goto SCALE_VALUE; /* the easy case */ } else if (scan_keyword("mm")) { set_conversion(7227, 2540); goto SCALE_VALUE; @@ -1418,28 +1407,37 @@ void scan_dimen(boolean mu, boolean inf, boolean shortcut) } else if (scan_keyword("nc")) { set_conversion(1370, 107); goto SCALE_VALUE; - } else if (scan_keyword("true")) { - /* Adjust (f)for the magnification ratio */ - if (output_mode_used == OMODE_DVI) { + } else if (!is_true && scan_keyword("true")) { + is_true = true; + goto PICKUP_UNIT; + } + /* Complain about unknown unit and |goto done2| */ + scan_dimen_unknown_unit_error(); + goto BAD_NEWS; + SCALE_VALUE: + /* Adjust (f) for the magnification ratio */ + if (is_true) { + /* maybe at some point we will drop mag completely, even in dvi mode */ + if (output_mode_used <= OMODE_DVI) { prepare_mag(); - if (int_par(mag_code) != 1000) { - cur_val = xn_over_d(cur_val, 1000, int_par(mag_code)); - f = (1000 * f + 0200000 * tex_remainder) / int_par(mag_code); + if (mag_par != 1000) { + cur_val = xn_over_d(cur_val, 1000, mag_par); + f = (1000 * f + 0200000 * tex_remainder) / mag_par; cur_val = cur_val + (f / 0200000); f = f % 0200000; } + } else { + /* in pdf mode we're always true */ + one_true_inch = one_inch; /* saveguard */ } - goto PICKUP_UNIT; - } else { - /* Complain about unknown unit and |goto done2| */ - scan_dimen_unknown_unit_error(); - goto BAD_NEWS; } - SCALE_VALUE: - cur_val = xn_over_d(cur_val, num, denom); - f = (num * f + 0200000 * tex_remainder) / denom; - cur_val = cur_val + (f / 0200000); - f = f % 0200000; + /* */ + if (num) { + cur_val = xn_over_d(cur_val, num, denom); + f = (num * f + 0200000 * tex_remainder) / denom; + cur_val = cur_val + (f / 0200000); + f = f % 0200000; + } BAD_NEWS: ATTACH_FRACTION: if (cur_val >= 040000) { @@ -1837,11 +1835,11 @@ halfword scan_rule_spec(void) } if (cur_cmd == vrule_cmd) { width(q) = default_rule; - rule_dir(q) = body_direction; + rule_dir(q) = body_direction_par; } else { height(q) = default_rule; depth(q) = 0; - rule_dir(q) = text_direction; + rule_dir(q) = text_direction_par; } RESWITCH: if (scan_keyword("width")) { @@ -2157,15 +2155,14 @@ parenthesis. @c typedef enum { - expr_none = 0, /* \.( seen, or \.( $\langle\it expr\rangle$ \.) seen */ - expr_add = 1, /* \.( $\langle\it expr\rangle$ \.+ seen */ - expr_sub = 2, /* \.( $\langle\it expr\rangle$ \.- seen */ - expr_mult = 3, /* $\langle\it term\rangle$ \.* seen */ - expr_div = 4, /* $\langle\it term\rangle$ \./ seen */ - expr_scale = 5, /* $\langle\it term\rangle$ \.* $\langle\it factor\rangle$ \./ seen */ + expr_none = 0, /* \.( seen, or \.( $\langle\it expr\rangle$ \.) seen */ + expr_add = 1, /* \.( $\langle\it expr\rangle$ \.+ seen */ + expr_sub = 2, /* \.( $\langle\it expr\rangle$ \.- seen */ + expr_mult = 3, /* $\langle\it term\rangle$ \.* seen */ + expr_div = 4, /* $\langle\it term\rangle$ \./ seen */ + expr_scale = 5, /* $\langle\it term\rangle$ \.* $\langle\it factor\rangle$ \./ seen */ } expression_states; - @ We want to make sure that each term and (intermediate) result is in the proper range. Integer values must not exceed |infinity| ($2^{31}-1$) in absolute value, dimensions must not exceed |max_dimen| @@ -2202,12 +2199,6 @@ term so far and |s| is the state of its evaluation; finally |n| is the numerator for a combined multiplication and division, if any. @c -#define expr_type(A) type((A)+1) -#define expr_state(A) subtype((A)+1) -#define expr_e_field(A) vlink((A)+1) /* saved expression so far */ -#define expr_t_field(A) vlink((A)+2) /* saved term so far */ -#define expr_n_field(A) vinfo((A)+2) /* saved numerator */ - #define expr_add_sub(A,B,C) add_or_sub((A),(B),(C),(r==expr_sub)) #define expr_a(A,B) expr_add_sub((A),(B),max_dimen) @@ -2493,7 +2484,7 @@ static void scan_expr(void) */ t = f; if ((l >= glue_val_level) && (o != expr_none)) { - /* do we really need to copy here ? */ + /* do we really need to copy here ? */ t = new_spec(f); flush_node(f); normalize_glue(t); diff --git a/Build/source/texk/web2c/luatexdir/tex/texfileio.w b/Build/source/texk/web2c/luatexdir/tex/texfileio.w index e04bf991afb..8b21cd02e71 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texfileio.w +++ b/Build/source/texk/web2c/luatexdir/tex/texfileio.w @@ -25,10 +25,6 @@ #include <string.h> #include <kpathsea/absolute.h> -@ @c -#define end_line_char int_par(end_line_char_code) - - @ The bane of portability is the fact that different operating systems treat input and output quite differently, perhaps because computer scientists have not given sufficient attention to this problem. People have felt somehow @@ -116,7 +112,7 @@ char *luatex_find_read_file(const char *s, int n, int callback_index) char *ftemp = NULL; int callback_id = callback_defined(callback_index); if (callback_id > 0) { - (void) run_callback(callback_id, "dS->S", n, s, &ftemp); + (void) run_callback(callback_id, "dS->R", n, s, &ftemp); } else { /* use kpathsea here */ ftemp = find_in_output_directory(s); @@ -844,7 +840,7 @@ void open_log_file(void) input_stack[input_ptr] = cur_input; /* make sure bottom level is in memory */ tprint_nl("**"); l = input_stack[0].limit_field; /* last position of first line */ - if (buffer[l] == end_line_char) + if (buffer[l] == end_line_char_par) decr(l); /* TODO: multichar endlinechar */ for (k = 1; k <= l; k++) print_char(buffer[k]); @@ -978,7 +974,7 @@ void start_input(void) if (end_line_char_inactive) decr(ilimit); else - buffer[ilimit] = (packed_ASCII_code) end_line_char; + buffer[ilimit] = (packed_ASCII_code) end_line_char_par; first = ilimit + 1; iloc = istart; } @@ -1137,7 +1133,7 @@ boolean zopen_w_input(FILE ** f, const char *fname, int format, char *fnam; callbackid = callback_defined(find_format_file_callback); if (callbackid > 0) { - res = run_callback(callbackid, "S->S", fname, &fnam); + res = run_callback(callbackid, "S->R", fname, &fnam); if (res && fnam && strlen(fnam) > 0) { *f = fopen(fnam, fopen_mode); if (*f == NULL) { diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.h b/Build/source/texk/web2c/luatexdir/tex/texmath.h index f36644e997d..93e85b46221 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texmath.h +++ b/Build/source/texk/web2c/luatexdir/tex/texmath.h @@ -109,8 +109,6 @@ void print_math_style(void); # define script_size 1 # define script_script_size 2 -# define math_direction int_par(math_direction_code) - # define dir_math_save cur_list.math_field # define m_style cur_list.math_style_field # define init_math_fields() do { \ diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.w b/Build/source/texk/web2c/luatexdir/tex/texmath.w index 32bc134a488..4d588079ce7 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texmath.w +++ b/Build/source/texk/web2c/luatexdir/tex/texmath.w @@ -18,21 +18,13 @@ % with LuaTeX; if not, see <http://www.gnu.org/licenses/>. @ @c - -// define DEBUG #include "ptexlib.h" @ @c -#define mode cur_list.mode_field -#define head cur_list.head_field -#define tail cur_list.tail_field -#define prev_graf cur_list.pg_field -#define eTeX_aux cur_list.eTeX_aux_field -#define delim_ptr eTeX_aux -#define space_factor cur_list.space_factor_field -#define incompleat_noad cur_list.incompleat_noad_field - -#define cur_fam int_par(cur_fam_code) +#define mode mode_par +#define tail tail_par +#define head head_par +#define dir_save dirs_par /* @@ -47,12 +39,6 @@ */ -#define display_skip_mode int_par(math_display_skip_mode_code) - -#define math_skip glue_par(math_skip_code) - -#define var_code 7 - @ TODO: not sure if this is the right order @c #define back_error(A,B) do { \ @@ -67,19 +53,6 @@ int scan_math(pointer, int); int scan_math_style(pointer, int); pointer fin_mlist(pointer); -#define pre_display_size dimen_par(pre_display_size_code) -#define hsize dimen_par(hsize_code) -#define display_width dimen_par(display_width_code) -#define display_indent dimen_par(display_indent_code) -#define math_surround dimen_par(math_surround_code) -#define hang_indent dimen_par(hang_indent_code) -#define hang_after int_par(hang_after_code) -#define every_math equiv(every_math_loc) -#define every_display equiv(every_display_loc) -#define par_shape_ptr equiv(par_shape_loc) - -#define math_eqno_gap_step int_par(math_eqno_gap_step_code) - @ When \TeX\ reads a formula that is enclosed between \.\$'s, it constructs an {\sl mlist}, which is essentially a tree structure representing that formula. An mlist is a linear sequence of items, but we can regard it as @@ -175,10 +148,10 @@ subroutine empties the current list, assuming that |abs(mode)=mmode|. void flush_math(void) { flush_node_list(vlink(head)); - flush_node_list(incompleat_noad); + flush_node_list(incompleat_noad_par); vlink(head) = null; tail = head; - incompleat_noad = null; + incompleat_noad_par = null; } @ Before we can do anything in math mode, we need fonts. @@ -203,7 +176,7 @@ void def_fam_fnt(int fam_id, int size_id, int f, int lvl) sa_value.int_value = f; set_sa_item(math_fam_head, n, sa_value, lvl); fixup_math_parameters(fam_id, size_id, f, lvl); - if (int_par(tracing_assigns_code) > 1) { + if (tracing_assigns_par > 1) { begin_diagnostic(); tprint("{assigning"); print_char(' '); @@ -229,7 +202,7 @@ static void unsave_math_fam_data(int gl) if (st.level > 0) { rawset_sa_item(math_fam_head, st.code, st.value); /* now do a trace message, if requested */ - if (int_par(tracing_restores_code) > 1) { + if (tracing_restores_par > 1) { int size_id = st.code / 256; int fam_id = st.code % 256; begin_diagnostic(); @@ -262,7 +235,7 @@ void def_math_param(int param_id, int style_id, scaled value, int lvl) sa_tree_item sa_value = { 0 }; sa_value.int_value = (int) value; set_sa_item(math_param_head, n, sa_value, lvl); - if (int_par(tracing_assigns_code) > 1) { + if (tracing_assigns_par > 1) { begin_diagnostic(); tprint("{assigning"); print_char(' '); @@ -294,7 +267,7 @@ static void unsave_math_param_data(int gl) if (st.level > 0) { rawset_sa_item(math_param_head, st.code, st.value); /* now do a trace message, if requested */ - if (int_par(tracing_restores_code) > 1) { + if (tracing_restores_par > 1) { int param_id = st.code % 256; int style_id = st.code / 256; begin_diagnostic(); @@ -889,22 +862,22 @@ is about to be processed. The parameter is a code like |math_group|. static void new_save_level_math(group_code c) { set_saved_record(0, saved_textdir, 0, text_dir_ptr); - text_dir_ptr = new_dir(math_direction); + text_dir_ptr = new_dir(math_direction_par); incr(save_ptr); new_save_level(c); - eq_word_define(int_base + body_direction_code, math_direction); - eq_word_define(int_base + par_direction_code, math_direction); - eq_word_define(int_base + text_direction_code, math_direction); + eq_word_define(int_base + body_direction_code, math_direction_par); + eq_word_define(int_base + par_direction_code, math_direction_par); + eq_word_define(int_base + text_direction_code, math_direction_par); } @ @c static void push_math(group_code c, int mstyle) { - if (math_direction != text_direction) + if (math_direction_par != text_direction_par) dir_math_save = true; push_nest(); mode = -mmode; - incompleat_noad = null; + incompleat_noad_par = null; m_style = mstyle; new_save_level_math(c); } @@ -914,8 +887,8 @@ static void enter_ordinary_math(void) { push_math(math_shift_group, text_style); eq_word_define(int_base + cur_fam_code, -1); - if (every_math != null) - begin_token_list(every_math, every_math_text); + if (every_math_par != null) + begin_token_list(every_math_par, every_math_text); } @ @c @@ -1007,7 +980,7 @@ static boolean math_and_text_reversed_p(void) while (i < save_ptr) { if (save_type(i) == restore_old_value && save_value(i) == int_base + par_direction_code) { - if (textdir_opposite(math_direction, save_value(i - 1))) + if (textdir_opposite(math_direction_par, save_value(i - 1))) return true; } i++; @@ -1046,27 +1019,27 @@ void enter_display_math(void) /* now we are in vertical mode, working on the list that will contain the display */ /* A displayed equation is considered to be three lines long, so we calculate the length and offset of line number |prev_graf+2|. */ - if (par_shape_ptr == null) { - if ((hang_indent != 0) && - (((hang_after >= 0) && (prev_graf + 2 > hang_after)) || - (prev_graf + 1 < -hang_after))) { - l = hsize - abs(hang_indent); - if (hang_indent > 0) - s = hang_indent; + if (par_shape_par_ptr == null) { + if ((hang_indent_par != 0) && (((hang_after_par >= 0) && (prev_graf_par + 2 > hang_after_par)) || (prev_graf_par + 1 < -hang_after_par))) { + halfword used_hang_indent = swap_hang_indent(hang_indent_par); + l = hsize_par - abs(used_hang_indent); + if (used_hang_indent > 0) + s = used_hang_indent; else s = 0; } else { - l = hsize; + l = hsize_par; s = 0; } } else { - n = vinfo(par_shape_ptr + 1); - if (prev_graf + 2 >= n) - p = par_shape_ptr + 2 * n + 1; + n = vinfo(par_shape_par_ptr + 1); + if (prev_graf_par + 2 >= n) + p = par_shape_par_ptr + 2 * n + 1; else - p = par_shape_ptr + 2 * (prev_graf + 2) + 1; + p = par_shape_par_ptr + 2 * (prev_graf_par + 2) + 1; s = varmem[(p - 1)].cint; l = varmem[p].cint; + s = swap_parshape_indent(s,l); } push_math(math_shift_group, display_style); @@ -1076,8 +1049,8 @@ void enter_display_math(void) eq_word_define(dimen_base + display_width_code, l); eq_word_define(dimen_base + display_indent_code, s); eq_word_define(int_base + pre_display_direction_code, (math_and_text_reversed_p() ? -1 : 0)); - if (every_display != null) - begin_token_list(every_display, every_display_text); + if (every_display_par != null) + begin_token_list(every_display_par, every_display_text); if (nest_ptr == 1) { checked_page_filter(before_display); build_page(); @@ -1090,8 +1063,6 @@ void enter_display_math(void) (the class is passed on for conversion to \.{\\mathchar}). @c -#define fam_in_range ((cur_fam>=0)&&(cur_fam<256)) - static delcodeval do_scan_extdef_del_code(int extcode, boolean doclass) { const char *hlp[] = { @@ -1368,8 +1339,8 @@ int scan_math(pointer p, int mstyle) } type(p) = math_char_node; math_character(p) = mval.character_value; - if ((mval.class_value == var_code) && fam_in_range) - math_fam(p) = cur_fam; + if ((mval.class_value == math_use_current_family_code) && cur_fam_par_in_range) + math_fam(p) = cur_fam_par; else math_fam(p) = mval.family_value; return 0; @@ -1398,9 +1369,9 @@ void set_math_char(mathcodeval mval) nucleus(p) = q; math_character(nucleus(p)) = mval.character_value; math_fam(nucleus(p)) = mval.family_value; - if (mval.class_value == var_code) { - if (fam_in_range) - math_fam(nucleus(p)) = cur_fam; + if (mval.class_value == math_use_current_family_code) { + if (cur_fam_par_in_range) + math_fam(nucleus(p)) = cur_fam_par; subtype(p) = ord_noad_type; } else { switch (mval.class_value) { @@ -1668,8 +1639,8 @@ void math_ac(void) q = new_node(math_char_node, 0); top_accent_chr(tail) = q; math_character(top_accent_chr(tail)) = t.character_value; - if ((t.class_value == var_code) && fam_in_range) - math_fam(top_accent_chr(tail)) = cur_fam; + if ((t.class_value == math_use_current_family_code) && cur_fam_par_in_range) + math_fam(top_accent_chr(tail)) = cur_fam_par; else math_fam(top_accent_chr(tail)) = t.family_value; } @@ -1677,8 +1648,8 @@ void math_ac(void) q = new_node(math_char_node, 0); bot_accent_chr(tail) = q; math_character(bot_accent_chr(tail)) = b.character_value; - if ((b.class_value == var_code) && fam_in_range) - math_fam(bot_accent_chr(tail)) = cur_fam; + if ((b.class_value == math_use_current_family_code) && cur_fam_par_in_range) + math_fam(bot_accent_chr(tail)) = cur_fam_par; else math_fam(bot_accent_chr(tail)) = b.family_value; } @@ -1686,8 +1657,8 @@ void math_ac(void) q = new_node(math_char_node, 0); overlay_accent_chr(tail) = q; math_character(overlay_accent_chr(tail)) = o.character_value; - if ((o.class_value == var_code) && fam_in_range) - math_fam(overlay_accent_chr(tail)) = cur_fam; + if ((o.class_value == math_use_current_family_code) && cur_fam_par_in_range) + math_fam(overlay_accent_chr(tail)) = cur_fam_par; else math_fam(overlay_accent_chr(tail)) = o.family_value; } @@ -1807,7 +1778,7 @@ void math_fraction(void) pointer q; halfword options = 0; c = cur_chr; - if (incompleat_noad != null) { + if (incompleat_noad_par != null) { const char *hlp[] = { "I'm ignoring this fraction specification, since I don't", "know whether a construction like `x \\over y \\over z'", @@ -1822,25 +1793,25 @@ void math_fraction(void) scan_normal_dimen(); tex_error("Ambiguous; you need another { and }", hlp); } else { - incompleat_noad = new_node(fraction_noad, 0); - numerator(incompleat_noad) = new_node(sub_mlist_node, 0); - math_list(numerator(incompleat_noad)) = vlink(head); + incompleat_noad_par = new_node(fraction_noad, 0); + numerator(incompleat_noad_par) = new_node(sub_mlist_node, 0); + math_list(numerator(incompleat_noad_par)) = vlink(head); vlink(head) = null; tail = head; m_style = cramped_style(m_style); if ((c % delimited_code) == skewed_code) { q = new_node(delim_node, 0); - middle_delimiter(incompleat_noad) = q; - scan_delimiter(middle_delimiter(incompleat_noad), no_mathcode); + middle_delimiter(incompleat_noad_par) = q; + scan_delimiter(middle_delimiter(incompleat_noad_par), no_mathcode); } if (c >= delimited_code) { q = new_node(delim_node, 0); - left_delimiter(incompleat_noad) = q; + left_delimiter(incompleat_noad_par) = q; q = new_node(delim_node, 0); - right_delimiter(incompleat_noad) = q; - scan_delimiter(left_delimiter(incompleat_noad), no_mathcode); - scan_delimiter(right_delimiter(incompleat_noad), no_mathcode); + right_delimiter(incompleat_noad_par) = q; + scan_delimiter(left_delimiter(incompleat_noad_par), no_mathcode); + scan_delimiter(right_delimiter(incompleat_noad_par), no_mathcode); } switch (c % delimited_code) { case above_code: @@ -1851,15 +1822,15 @@ void math_fraction(void) break; } } - fractionoptions(incompleat_noad) = options; + fractionoptions(incompleat_noad_par) = options; scan_normal_dimen(); - thickness(incompleat_noad) = cur_val; + thickness(incompleat_noad_par) = cur_val; break; case over_code: - thickness(incompleat_noad) = default_code; + thickness(incompleat_noad_par) = default_code; break; case atop_code: - thickness(incompleat_noad) = 0; + thickness(incompleat_noad_par) = 0; break; case skewed_code: while (1) { @@ -1871,8 +1842,8 @@ void math_fraction(void) break; } } - fractionoptions(incompleat_noad) = options; - thickness(incompleat_noad) = 0; + fractionoptions(incompleat_noad_par) = options; + thickness(incompleat_noad_par) = 0; break; } } @@ -1888,24 +1859,24 @@ current mlist; this |fence_noad| has not yet been appended. pointer fin_mlist(pointer p) { pointer q; /* the mlist to return */ - if (incompleat_noad != null) { - if (denominator(incompleat_noad) != null) { - type(denominator(incompleat_noad)) = sub_mlist_node; + if (incompleat_noad_par != null) { + if (denominator(incompleat_noad_par) != null) { + type(denominator(incompleat_noad_par)) = sub_mlist_node; } else { q = new_node(sub_mlist_node, 0); - denominator(incompleat_noad) = q; + denominator(incompleat_noad_par) = q; } - math_list(denominator(incompleat_noad)) = vlink(head); + math_list(denominator(incompleat_noad_par)) = vlink(head); if (p == null) { - q = incompleat_noad; + q = incompleat_noad_par; } else { - q = math_list(numerator(incompleat_noad)); + q = math_list(numerator(incompleat_noad_par)); if ((type(q) != fence_noad) || (subtype(q) != left_noad_side) - || (delim_ptr == null)) + || (delim_par == null)) confusion("right"); /* this can't happen */ - math_list(numerator(incompleat_noad)) = vlink(delim_ptr); - vlink(delim_ptr) = incompleat_noad; - vlink(incompleat_noad) = p; + math_list(numerator(incompleat_noad_par)) = vlink(delim_par); + vlink(delim_par) = incompleat_noad_par; + vlink(incompleat_noad_par) = p; } } else { vlink(tail) = p; @@ -2077,7 +2048,7 @@ void math_left_right(void) push_math(math_left_group, m_style); vlink(head) = q; tail = p; - delim_ptr = p; + delim_par = p; } else { tail_append(new_noad()); subtype(tail) = inner_noad_type; @@ -2133,10 +2104,10 @@ static void resume_after_display(void) if (cur_group != math_shift_group) confusion("display"); unsave_math(); - prev_graf = prev_graf + 3; + prev_graf_par = prev_graf_par + 3; push_nest(); mode = hmode; - space_factor = 1000; + space_factor_par = 1000; /* this needs to be intercepted in the display math start ! */ tail_append(make_local_par_node(penalty_par_code)); get_x_token(); @@ -2158,6 +2129,39 @@ At this time we are in vertical mode (or internal vertical mode). |l| is true if there was an \.{\\leqno}/ (so |a| is a horizontal box). @c +#define inject_display_skip_before(g) \ + switch (display_skip_mode_par) { \ + case 0 : /* normal tex */ \ + tail_append(new_param_glue(g)); \ + break;\ + case 1 : /* always */ \ + tail_append(new_param_glue(g)); \ + break; \ + case 2 : /* non-zero */ \ + if (g != 0 && ! glue_is_zero(glue_par(g))) \ + tail_append(new_param_glue(g)); \ + break; \ + case 3: /* ignore */ \ + break; \ + } + +#define inject_display_skip_after(g) \ + switch (display_skip_mode_par) { \ + case 0 : /* normal tex */ \ + if (g != 0 && glue_is_positive(glue_par(g))) \ + tail_append(new_param_glue(g)); \ + break; \ + case 1 : /* always */ \ + tail_append(new_param_glue(g)); \ + break; \ + case 2 : /* non-zero */ \ + if (g != 0 && ! glue_is_zero(glue_par(g))) \ + tail_append(new_param_glue(g)); \ + break; \ + case 3: /* ignore */ \ + break; \ + } + static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) { pointer eq_box; /* box containing the equation */ @@ -2173,7 +2177,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) pointer pre_t; /* tail of pre-adjustment list */ boolean swap_dir; /* true if the math and surrounding text dirs are opposed */ scaled eqno_width; - swap_dir = (int_par(pre_display_direction_code) < 0 ? true : false ); + swap_dir = (pre_display_direction_par < 0 ? true : false ); if (eqno_box != null && swap_dir) l = !l; adjust_tail = adjust_head; @@ -2187,8 +2191,8 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) pre_t = pre_adjust_tail; pre_adjust_tail = null; eq_w = width(eq_box); - line_w = display_width; - line_s = display_indent; + line_w = display_width_par; + line_s = display_indent_par; if (eqno_box == null) { eqno_w = 0; eqno_width = 0; @@ -2196,7 +2200,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) } else { eqno_w = width(eqno_box); eqno_width = eqno_w; - eqno_w2 = eqno_w + round_xn_over_d(math_eqno_gap_step, get_math_quad_style(text_style), 1000); + eqno_w2 = eqno_w + round_xn_over_d(math_eqno_gap_step_par, get_math_quad_style(text_style), 1000); subtype(eqno_box) = equation_number_list; /* new */ /* build_attribute_list(eqno_box); */ /* probably already set */ } @@ -2242,8 +2246,8 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) d = 0; } - tail_append(new_penalty(int_par(pre_display_penalty_code))); - if ((d + line_s <= pre_display_size) || l) { /* not enough clearance */ + tail_append(new_penalty(pre_display_penalty_par)); + if ((d + line_s <= pre_display_size_par) || l) { /* not enough clearance */ g1 = above_display_skip_code; g2 = below_display_skip_code; } else { @@ -2261,35 +2265,22 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) /* it follows that |type(a)=hlist_node| */ if (eqno_box && l && (eqno_w == 0)) { - /* if (math_direction==dir_TLT) { */ + /* if (math_direction_par==dir_TLT) { */ shift_amount(eqno_box) = 0; /* } else { */ /* } */ append_to_vlist(eqno_box,lua_key_index(equation_number)); tail_append(new_penalty(inf_penalty)); } else { - switch (display_skip_mode) { - case 0 : /* normal tex */ - tail_append(new_param_glue(g1)); - break; - case 1 : /* always */ - tail_append(new_param_glue(g1)); - break; - case 2 : /* non-zero */ - if (g1 != 0) - tail_append(new_param_glue(g1)); - break; - case 3: /* ignore */ - break; - } + inject_display_skip_before(g1); } if (eqno_w != 0) { r = new_kern(line_w - eq_w - eqno_w - d); if (l) { if (swap_dir) { - if (math_direction==dir_TLT) { - /* TRT + TLT + \eqno, (swap_dir=true, math_direction=TLT, l=true) */ + if (math_direction_par==dir_TLT) { + /* TRT + TLT + \eqno, (swap_dir=true, math_direction_par=TLT, l=true) */ #ifdef DEBUG fprintf(stderr, "\nDEBUG: CASE 1\n"); #endif @@ -2298,7 +2289,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) try_couple_nodes(r,eq_box); try_couple_nodes(eq_box,s); } else { - /* TLT + TRT + \eqno, (swap_dir=true, math_direction=TRT, l=true) */ + /* TLT + TRT + \eqno, (swap_dir=true, math_direction_par=TRT, l=true) */ #ifdef DEBUG fprintf(stderr, "\nDEBUG: CASE 2\n"); #endif @@ -2306,14 +2297,14 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) try_couple_nodes(r,eq_box); } } else { - if (math_direction==dir_TLT) { - /* TLT + TLT + \leqno, (swap_dir=false, math_direction=TLT, l=true) */ /* OK */ + if (math_direction_par==dir_TLT) { + /* TLT + TLT + \leqno, (swap_dir=false, math_direction_par=TLT, l=true) */ /* OK */ #ifdef DEBUG fprintf(stderr, "\nDEBUG: CASE 3\n"); #endif s = new_kern(width(r) + eqno_w); } else { - /* TRT + TRT + \leqno, (swap_dir=false, math_direction=TRT, l=true) */ + /* TRT + TRT + \leqno, (swap_dir=false, math_direction_par=TRT, l=true) */ #ifdef DEBUG fprintf(stderr, "\nDEBUG: CASE 4\n"); #endif @@ -2326,13 +2317,13 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) eq_box = eqno_box; } else { if (swap_dir) { - if (math_direction==dir_TLT) { - /* TRT + TLT + \leqno, (swap_dir=true, math_direction=TLT, l=false) */ + if (math_direction_par==dir_TLT) { + /* TRT + TLT + \leqno, (swap_dir=true, math_direction_par=TLT, l=false) */ #ifdef DEBUG fprintf(stderr, "\nDEBUG: CASE 5\n"); #endif } else { - /* TLT + TRT + \leqno, (swap_dir=true, math_direction=TRT, l=false) */ + /* TLT + TRT + \leqno, (swap_dir=true, math_direction_par=TRT, l=false) */ #ifdef DEBUG fprintf(stderr, "\nDEBUG: CASE 6\n"); #endif @@ -2340,14 +2331,14 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) try_couple_nodes(eq_box,r); try_couple_nodes(r,eqno_box); } else { - if (math_direction==dir_TLT) { - /* TLT + TLT + \eqno, (swap_dir=false, math_direction=TLT, l=false) */ /* OK */ + if (math_direction_par==dir_TLT) { + /* TLT + TLT + \eqno, (swap_dir=false, math_direction_par=TLT, l=false) */ /* OK */ #ifdef DEBUG fprintf(stderr, "\nDEBUG: CASE 7\n"); #endif s = new_kern(d); } else { - /* TRT + TRT + \eqno, (swap_dir=false, math_direction=TRT, l=false) */ + /* TRT + TRT + \eqno, (swap_dir=false, math_direction_par=TRT, l=false) */ #ifdef DEBUG fprintf(stderr, "\nDEBUG: CASE 8\n"); #endif @@ -2371,7 +2362,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) if ((eqno_box != null) && (eqno_w == 0) && !l) { tail_append(new_penalty(inf_penalty)); - /* if (math_direction==dir_TLT) { */ + /* if (math_direction_par==dir_TLT) { */ shift_amount(eqno_box) = line_s + line_w - eqno_width ; /* } else { */ /* } */ @@ -2390,24 +2381,8 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) alink(pre_adjust_tail) = alink(tail); tail = pre_t; } - tail_append(new_penalty(int_par(post_display_penalty_code))); - - switch (display_skip_mode) { - case 0 : /* normal tex */ - if (g2 > 0) - tail_append(new_param_glue(g2)); - break; - case 1 : /* always */ - tail_append(new_param_glue(g2)); - break; - case 2 : /* non-zero */ - if (g2 != 0) - tail_append(new_param_glue(g2)); - break; - case 3: /* ignore */ - break; - } - + tail_append(new_penalty(post_display_penalty_par)); + inject_display_skip_after(g2); resume_after_display(); } @@ -2452,15 +2427,15 @@ void after_math(void) if (cur_cmd == math_shift_cs_cmd) { check_inline_math_end(); } - tail_append(new_math(math_surround, before)); + tail_append(new_math(math_surround_par, before)); /* begin mathskip code */ - if (! glue_is_zero(math_skip)) { - copy_glue_values(tail,math_skip); + if (! glue_is_zero(math_skip_par)) { + copy_glue_values(tail,math_skip_par); surround(tail) = 0; } /* end mathskip code */ if (dir_math_save) { - tail_append(new_dir(math_direction)); + tail_append(new_dir(math_direction_par)); } run_mlist_to_hlist(p, (mode > 0), text_style); vlink(tail) = vlink(temp_head); @@ -2468,17 +2443,17 @@ void after_math(void) tail = vlink(tail); } if (dir_math_save) { - tail_append(new_dir(math_direction - dir_swap)); + tail_append(new_dir(math_direction_par - dir_swap)); } dir_math_save = false; - tail_append(new_math(math_surround, after)); + tail_append(new_math(math_surround_par, after)); /* begin mathskip code */ - if (! glue_is_zero(math_skip)) { - copy_glue_values(tail,math_skip); + if (! glue_is_zero(math_skip_par)) { + copy_glue_values(tail,math_skip_par); surround(tail) = 0; } /* end mathskip code */ - space_factor = 1000; + space_factor_par = 1000; unsave_math(); } else { if (a == null) { @@ -2508,13 +2483,13 @@ void finish_display_alignment(pointer p, pointer q, halfword saved_prevdepth) check_display_math_end(); } pop_nest(); - tail_append(new_penalty(int_par(pre_display_penalty_code))); - tail_append(new_param_glue(above_display_skip_code)); + tail_append(new_penalty(pre_display_penalty_par)); + inject_display_skip_before(above_display_skip_code); vlink(tail) = p; if (p != null) tail = q; - tail_append(new_penalty(int_par(post_display_penalty_code))); - tail_append(new_param_glue(below_display_skip_code)); + tail_append(new_penalty(post_display_penalty_par)); + inject_display_skip_after(below_display_skip_code); cur_list.prev_depth_field = saved_prevdepth; resume_after_display(); } diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.h b/Build/source/texk/web2c/luatexdir/tex/texnodes.h index 93670b7f5b3..6650d17f410 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.h +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.h @@ -148,30 +148,33 @@ typedef enum { # define synctex_line_glue(a) vlink((a)+6) #define glue_is_zero(p) \ - ((p == null) || (width(p) == 0 && stretch(p) == 0 && shrink(p) == 0)) + ((p == null) || (width(p) == 0 && stretch(p) == 0 && shrink(p) == 0)) + +#define glue_is_positive(p) \ + ((p == null) || (width(p) > 0)) #define reset_glue_to_zero(p) \ - if (p != null) { \ - width(p) = 0; \ - stretch(p) = 0; \ - shrink(p) = 0; \ - stretch_order(p) = 0; \ - shrink_order(p) = 0; \ - } + if (p != null) { \ + width(p) = 0; \ + stretch(p) = 0; \ + shrink(p) = 0; \ + stretch_order(p) = 0; \ + shrink_order(p) = 0; \ + } #define copy_glue_values(p,q) \ - if (q == null) { \ - width(p) = 0; \ - stretch(p) = 0; \ - shrink(p) = 0; \ - stretch_order(p) = 0; \ - shrink_order(p) = 0; \ - } else { \ - width(p) = width(q); \ - stretch(p) = stretch(q); \ - shrink(p) = shrink(q); \ - stretch_order(p) = stretch_order(q); \ - shrink_order(p) = shrink_order(q); \ + if (q == null) { \ + width(p) = 0; \ + stretch(p) = 0; \ + shrink(p) = 0; \ + stretch_order(p) = 0; \ + shrink_order(p) = 0; \ + } else { \ + width(p) = width(q); \ + stretch(p) = stretch(q); \ + shrink(p) = shrink(q); \ + stretch_order(p) = stretch_order(q); \ + shrink_order(p) = shrink_order(q); \ } @@ -417,11 +420,17 @@ typedef enum { # define last_known_node temp_node /* used by \lastnodetype */ # define movement_node_size 3 -# define expr_node_size 3 # define if_node_size 2 # define align_stack_node_size 6 # define nesting_node_size 2 +# define expr_node_size 3 +# define expr_type(A) type((A)+1) +# define expr_state(A) subtype((A)+1) /* enum defined in scanning.w */ +# define expr_e_field(A) vlink((A)+1) /* saved expression so far */ +# define expr_t_field(A) vlink((A)+2) /* saved term so far */ +# define expr_n_field(A) vinfo((A)+2) /* saved numerator */ + # define span_node_size 3 # define span_span(a) vlink((a)+1) # define span_link(a) vinfo((a)+1) @@ -944,7 +953,10 @@ typedef enum { # define var_mem_stat_max (end_point+glyph_node_size-1) # define stretching 1 -# define shrinking 2 +# define shrinking 2 + +# define last_normal_node shape_node +# define last_whatsit_node pdf_restore_node # define is_running(A) ((A)==null_flag) /* tests for a running dimension */ @@ -978,11 +990,6 @@ extern int lua_properties_enabled ; extern int lua_properties_level ; extern int lua_properties_use_metatable ; -#define local_inter_line_penalty int_par(local_inter_line_penalty_code) -#define local_broken_penalty int_par(local_broken_penalty_code) -#define local_left_box equiv(local_left_box_base) -#define local_right_box equiv(local_right_box_base) - extern halfword make_local_par_node(int mode); #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.w b/Build/source/texk/web2c/luatexdir/tex/texnodes.w index df7de17db5f..6bfa14f2356 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.w +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.w @@ -33,16 +33,8 @@ makes no sense, not even to make it configureable. There is a little more memory used but that is neglectable compared to other memory usage. @c -#define attribute(A) eqtb[attribute_base+(A)].cint - -#define uc_hyph int_par(uc_hyph_code) -#define cur_lang int_par(cur_lang_code) -#define left_hyphen_min int_par(left_hyphen_min_code) -#define right_hyphen_min int_par(right_hyphen_min_code) - -#define MAX_CHAIN_SIZE 13 /* why not a bit larger */ - -#define CHECK_NODE_USAGE 1 /* this triggers checking */ +#define MAX_CHAIN_SIZE 13 /* why not a bit larger */ +#define CHECK_NODE_USAGE 1 /* this triggers checking */ memory_word *volatile varmem = NULL; @@ -61,8 +53,8 @@ int fix_node_lists = 1; /* used in font and lang */ halfword slow_get_node(int s); /* defined below */ -#define fake_node 100 -#define fake_node_size 2 +#define fake_node 100 +#define fake_node_size 2 #define fake_node_name "fake" #define variable_node_size 2 @@ -144,18 +136,6 @@ const char *node_fields_noad[] = { "attr", "nucleus", "sub", "sup", NULL }; -#define node_fields_ord node_fields_noad -#define node_fields_op node_fields_noad -#define node_fields_bin node_fields_noad -#define node_fields_rel node_fields_noad -#define node_fields_open node_fields_noad -#define node_fields_close node_fields_noad -#define node_fields_punct node_fields_noad -#define node_fields_inner node_fields_noad -#define node_fields_under node_fields_noad -#define node_fields_over node_fields_noad -#define node_fields_vcenter node_fields_noad - const char *node_fields_style[] = { "attr", "style", NULL }; @@ -342,7 +322,7 @@ node_info node_data[] = { /* the last entry in a row is the etex number */ { unset_node, box_node_size, node_fields_unset, "unset", 14 }, { style_node, style_node_size, node_fields_style, "style", 15 }, { choice_node, style_node_size, node_fields_choice, "choice", 15 }, - { simple_noad, noad_size, node_fields_ord, "noad", 15 }, + { simple_noad, noad_size, node_fields_noad, "noad", 15 }, { radical_noad, radical_noad_size, node_fields_radical, "radical", 15 }, { fraction_noad, fraction_noad_size, node_fields_fraction, "fraction", 15 }, { accent_noad, accent_noad_size, node_fields_accent, "accent", 15 }, @@ -377,8 +357,6 @@ node_info node_data[] = { /* the last entry in a row is the etex number */ { -1, -1, NULL, NULL, -1 }, }; -#define last_normal_node shape_node - const char *node_subtypes_pdf_destination[] = { "xyz", "fit", "fith", "fitv", "fitb", "fitbh", "fitbv", "fitr", NULL }; @@ -552,6 +530,8 @@ important, don't keep resolving the registry index. /* isn't there a faster way to metatable? */ +/* + #define lua_properties_copy(target,source) do { \ if (lua_properties_enabled) { \ if (lua_properties_level == 0) { \ @@ -590,6 +570,55 @@ important, don't keep resolving the registry index. } \ } while(0) +*/ + +/* + A simple testrun on many pages of dumb text shows 1% gain (of course it depends + on how properties are used but some other tests confirm it). +*/ + +#define lua_properties_copy(target,source) do { \ + if (lua_properties_enabled) { \ + if (lua_properties_level == 0) { \ + lua_get_metatablelua_l(Luas,node_properties); \ + lua_rawgeti(Luas,-1,source); \ + if (lua_type(Luas,-1)==LUA_TTABLE) { \ + if (lua_properties_use_metatable) { \ + lua_newtable(Luas); \ + lua_insert(Luas,-2); \ + lua_push_string_by_name(Luas,__index); \ + lua_insert(Luas,-2); \ + lua_rawset(Luas, -3); \ + lua_newtable(Luas); \ + lua_insert(Luas,-2); \ + lua_setmetatable(Luas,-2); \ + } \ + lua_rawseti(Luas,-2,target); \ + } else { \ + lua_pop(Luas,1); \ + } \ + lua_pop(Luas,1); \ + } else { \ + lua_rawgeti(Luas,-1,source); \ + if (lua_type(Luas,-1)==LUA_TTABLE) { \ + if (lua_properties_use_metatable) { \ + lua_newtable(Luas); \ + lua_insert(Luas,-2); \ + lua_push_string_by_name(Luas,__index); \ + lua_insert(Luas,-2); \ + lua_rawset(Luas, -3); \ + lua_newtable(Luas); \ + lua_insert(Luas,-2); \ + lua_setmetatable(Luas,-2); \ + } \ + lua_rawseti(Luas,-2,target); \ + } else { \ + lua_pop(Luas,1); \ + } \ + } \ + } \ +} while(0) + /* Here end the property handlers. */ @ @c @@ -862,7 +891,7 @@ halfword new_node(int i, int j) default: break; } - if (int_par(synctex_code)) { + if (synctex_par) { /* handle synctex extension */ switch (i) { case math_node: @@ -1063,7 +1092,7 @@ halfword copy_node(const halfword p) (void) memcpy((void *) (varmem + r), (void *) (varmem + p), (sizeof(memory_word) * (unsigned) i)); - if (int_par(synctex_code)) { + if (synctex_par) { /* handle synctex extension */ switch (type(p)) { case math_node: @@ -1224,6 +1253,9 @@ static void flush_node_wrapup_core(halfword p) break; case 'd': break; + case 'l': + free_user_lua(user_node_value(p)); + break; case 'n': flush_node_list(user_node_value(p)); break; @@ -2815,7 +2847,7 @@ void show_node_list(int p) while (p != null) { print_ln(); print_current_string(); /* display the nesting history */ - if (int_par(tracing_online_code) < -2) + if (tracing_online_par < -2) print_int(p); incr(n); if (n > breadth_max) { /* time to stop */ @@ -3296,7 +3328,7 @@ The |subtype| field is set to |min_quarterword|, since that's the desired halfword new_null_box(void) { /* creates a new box node */ halfword p = new_node(hlist_node, min_quarterword); - box_dir(p) = text_direction; + box_dir(p) = text_direction_par; return p; } @@ -3413,7 +3445,7 @@ halfword new_char(int f, int c) set_to_character(p); font(p) = f; character(p) = c; - lang_data(p) = make_lang_data(uc_hyph, cur_lang, left_hyphen_min, right_hyphen_min); + lang_data(p) = make_lang_data(uc_hyph_par, cur_lang_par, left_hyphen_min_par, right_hyphen_min_par); return p; } @@ -3471,7 +3503,7 @@ not chosen. halfword new_disc(void) { /* creates an empty |disc_node| */ halfword p = new_node(disc_node, 0); - disc_penalty(p) = int_par(hyphen_penalty_code); + disc_penalty(p) = hyphen_penalty_par; return p; } @@ -3694,19 +3726,19 @@ halfword make_local_par_node(int mode) int callback_id; halfword q; halfword p = new_node(local_par_node,0); - local_pen_inter(p) = local_inter_line_penalty; - local_pen_broken(p) = local_broken_penalty; - if (local_left_box != null) { - q = copy_node_list(local_left_box); + local_pen_inter(p) = local_inter_line_penalty_par; + local_pen_broken(p) = local_broken_penalty_par; + if (local_left_box_par != null) { + q = copy_node_list(local_left_box_par); local_box_left(p) = q; - local_box_left_width(p) = width(local_left_box); + local_box_left_width(p) = width(local_left_box_par); } - if (local_right_box != null) { - q = copy_node_list(local_right_box); + if (local_right_box_par != null) { + q = copy_node_list(local_right_box_par); local_box_right(p) = q; - local_box_right_width(p) = width(local_right_box); + local_box_right_width(p) = width(local_right_box_par); } - local_par_dir(p) = par_direction; + local_par_dir(p) = par_direction_par; /* callback with node passed */ callback_id = callback_defined(insert_local_par_callback); if (callback_id > 0) { diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.h b/Build/source/texk/web2c/luatexdir/tex/textoken.h index d2174beb370..9a9ef501cf6 100644 --- a/Build/source/texk/web2c/luatexdir/tex/textoken.h +++ b/Build/source/texk/web2c/luatexdir/tex/textoken.h @@ -137,8 +137,6 @@ extern int get_char_cat_code(int); */ # define no_expand_flag special_char -# define end_line_char int_par(end_line_char_code) -# define end_line_char_inactive ((end_line_char < 0) || (end_line_char > 127)) extern halfword par_loc; extern halfword par_token; diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.w b/Build/source/texk/web2c/luatexdir/tex/textoken.w index 8d147f4e2a8..8f44f686641 100644 --- a/Build/source/texk/web2c/luatexdir/tex/textoken.w +++ b/Build/source/texk/web2c/luatexdir/tex/textoken.w @@ -22,17 +22,6 @@ #include "ptexlib.h" @ @c -#define pausing int_par(pausing_code) -#define cat_code_table int_par(cat_code_table_code) -#define tracing_nesting int_par(tracing_nesting_code) -#define suppress_outer_error int_par(suppress_outer_error_code) -#define suppress_mathpar_error int_par(suppress_mathpar_error_code) - - -#define every_eof equiv(every_eof_loc) -#define box(A) equiv(box_base+(A)) -#define toks(A) equiv(toks_base+(A)) - #define detokenized_line() (line_catcode_table==NO_CAT_TABLE) /* @@ -42,13 +31,13 @@ else if (line_catcode_table!=DEFAULT_CAT_TABLE) \ a=get_cat_code(line_catcode_table,b); \ else \ - a=get_cat_code(cat_code_table,b); \ + a=get_cat_code(cat_code_table_par,b); \ } while (0) */ #define do_get_cat_code(a,b) do { \ if (line_catcode_table==DEFAULT_CAT_TABLE) \ - a=get_cat_code(cat_code_table,b); \ + a=get_cat_code(cat_code_table_par,b); \ else if (line_catcode_table>-0xFF) \ a=get_cat_code(line_catcode_table,b); \ else \ @@ -766,7 +755,7 @@ void firm_up_the_line(void) { int k; /* an index into |buffer| */ ilimit = last; - if (pausing > 0) { + if (pausing_par > 0) { if (interaction > nonstop_mode) { wake_up_terminal(); print_ln(); @@ -795,7 +784,7 @@ void check_outer_validity(void) { halfword p; /* points to inserted token list */ halfword q; /* auxiliary pointer */ - if (suppress_outer_error) + if (suppress_outer_error_par) return; if (scanner_status != normal) { deletions_allowed = false; @@ -980,7 +969,7 @@ static boolean get_next_file(void) case skip_blanks + escape_cmd: /* Scan a control sequence ...; */ istate = (unsigned char) scan_control_sequence(); - if (! suppress_outer_error && cur_cmd >= outer_call_cmd) + if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd) check_outer_validity(); break; case mid_line + active_char_cmd: @@ -991,7 +980,7 @@ static boolean get_next_file(void) cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); istate = mid_line; - if (! suppress_outer_error && cur_cmd >= outer_call_cmd) + if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd) check_outer_validity(); break; case mid_line + sup_mark_cmd: @@ -1041,7 +1030,7 @@ static boolean get_next_file(void) cur_cs = par_loc; cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); - if (! suppress_outer_error && cur_cmd >= outer_call_cmd) + if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd) check_outer_validity(); break; case skip_blanks + left_brace_cmd: @@ -1141,7 +1130,7 @@ static boolean get_next_file(void) switch (c-new_line) { case escape_cmd: istate = (unsigned char) scan_control_sequence(); - if (! suppress_outer_error && cur_cmd >= outer_call_cmd) + if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd) check_outer_validity(); return true; case left_brace_cmd: @@ -1164,7 +1153,7 @@ static boolean get_next_file(void) cur_cs = par_loc; cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); - if (! suppress_outer_error && cur_cmd >= outer_call_cmd) + if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd) check_outer_validity(); return true; case mac_param_cmd: @@ -1196,7 +1185,7 @@ static boolean get_next_file(void) cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); istate = mid_line; - if (! suppress_outer_error && cur_cmd >= outer_call_cmd) + if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd) check_outer_validity(); return true; case comment_cmd: @@ -1214,7 +1203,7 @@ static boolean get_next_file(void) case escape_cmd: /* Scan a control sequence ...; */ istate = (unsigned char) scan_control_sequence(); - if (! suppress_outer_error && cur_cmd >= outer_call_cmd) + if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd) check_outer_validity(); return true; case left_brace_cmd: @@ -1262,7 +1251,7 @@ static boolean get_next_file(void) cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); istate = mid_line; - if (! suppress_outer_error && cur_cmd >= outer_call_cmd) + if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd) check_outer_validity(); return true; case comment_cmd: @@ -1281,7 +1270,7 @@ static boolean get_next_file(void) switch (c-mid_line) { case escape_cmd: istate = (unsigned char) scan_control_sequence(); - if (! suppress_outer_error && cur_cmd >= outer_call_cmd) + if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd) check_outer_validity(); return true; case left_brace_cmd: @@ -1334,7 +1323,7 @@ static boolean get_next_file(void) cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); istate = mid_line; - if (! suppress_outer_error && cur_cmd >= outer_call_cmd) + if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd) check_outer_validity(); return true; case comment_cmd: @@ -1694,11 +1683,11 @@ one more branch. line_catcode_table = DEFAULT_CAT_TABLE; if ((iname == 19) && (pseudo_lines(pseudo_files) == null)) inhibit_eol = true; - } else if ((every_eof != null) && !eof_seen[iindex]) { + } else if ((every_eof_par != null) && !eof_seen[iindex]) { ilimit = first - 1; eof_seen[iindex] = true; /* fake one empty line */ if (iname != 19) - begin_token_list(every_eof, every_eof_text); + begin_token_list(every_eof_par, every_eof_text); return next_line_restart; } else { force_eof = true; @@ -1721,10 +1710,10 @@ one more branch. if (lua_input_ln(cur_file, 0, true)) { /* not end of file */ firm_up_the_line(); /* this sets |ilimit| */ line_catcode_table = DEFAULT_CAT_TABLE; - } else if ((every_eof != null) && (!eof_seen[iindex])) { + } else if ((every_eof_par != null) && (!eof_seen[iindex])) { ilimit = first - 1; eof_seen[iindex] = true; /* fake one empty line */ - begin_token_list(every_eof, every_eof_text); + begin_token_list(every_eof_par, every_eof_text); return next_line_restart; } else { force_eof = true; @@ -1733,7 +1722,7 @@ one more branch. } } if (force_eof) { - if (tracing_nesting > 0) + if (tracing_nesting_par > 0) if ((grp_stack[in_open] != cur_boundary) || (if_stack[in_open] != cond_ptr)) if (!((iname == 19) || (iname == 21))) { /* give warning for some unfinished groups and/or conditionals */ @@ -1749,7 +1738,7 @@ one more branch. end_file_reading(); } else { end_file_reading(); - if (! suppress_outer_error) + if (! suppress_outer_error_par) check_outer_validity(); } return next_line_restart; @@ -1757,7 +1746,7 @@ one more branch. if (inhibit_eol || end_line_char_inactive) ilimit--; else - buffer[ilimit] = (packed_ASCII_code) end_line_char; + buffer[ilimit] = (packed_ASCII_code) end_line_char_par; first = ilimit + 1; iloc = istart; /* ready to read */ } else { @@ -1788,7 +1777,7 @@ one more branch. if (end_line_char_inactive) ilimit--; else - buffer[ilimit] = (packed_ASCII_code) end_line_char; + buffer[ilimit] = (packed_ASCII_code) end_line_char_par; first = ilimit + 1; iloc = istart; } else { @@ -1829,7 +1818,7 @@ static boolean get_next_tokenlist(void) cur_chr = no_expand_flag; return true; } - } else if (! suppress_outer_error) { + } else if (! suppress_outer_error_par) { check_outer_validity(); } } @@ -2364,7 +2353,7 @@ static int do_feedback_dvi(halfword c) /* codes not really needed but cleaner when testing */ -#define pdftex_version 40 /* these values will not change any more */ +#define pdftex_version 140 /* these values will not change any more */ #define pdftex_revision "0" /* these values will not change any more */ static int do_feedback_pdf(halfword c) @@ -3154,7 +3143,7 @@ void read_toks(int n, halfword r, halfword j) if (end_line_char_inactive) decr(ilimit); else - buffer[ilimit] = (packed_ASCII_code) int_par(end_line_char_code); + buffer[ilimit] = (packed_ASCII_code) end_line_char_par; first = ilimit + 1; iloc = istart; istate = new_line; @@ -3285,7 +3274,7 @@ char *tokenlist_to_cstring(int pp, int inhibit_par, int *siz) ret = xmalloc(alloci); p = token_link(p); /* skip refcount */ if (p != null) { - e = int_par(escape_char_code); + e = escape_char_par; } while (p != null) { if (p < (int) fix_mem_min || p > (int) fix_mem_end) { |