diff options
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/luatoken.w | 2 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/pdf/pdftables.h | 68 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/commands.h | 33 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/commands.w | 8 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/expand.w | 6 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/extensions.h | 84 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/extensions.w | 369 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/textoken.h | 12 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/textoken.w | 687 |
9 files changed, 605 insertions, 664 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatoken.w b/Build/source/texk/web2c/luatexdir/lua/luatoken.w index f0ff08eec54..d8ac7eebca8 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luatoken.w +++ b/Build/source/texk/web2c/luatexdir/lua/luatoken.w @@ -155,6 +155,8 @@ command_item command_names[] = { {"fi_or_else", fi_or_else_cmd, NULL}, {"cs_name", cs_name_cmd, NULL}, {"convert", convert_cmd, NULL}, + {"variable", variable_cmd, NULL}, + {"feedback", feedback_cmd, NULL}, {"the", the_cmd, NULL}, {"top_bot_mark", top_bot_mark_cmd, NULL}, {"call", call_cmd, NULL}, diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h index 8dd3286e426..8b14f5e06ea 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h +++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h @@ -121,39 +121,39 @@ extern void undump_pdftex_data(PDF pdf); /* pdf backend definitions */ -# define pdf_compress_level get_tex_extension_count_register("pdf_compresslevel", 9) -# define pdf_decimal_digits get_tex_extension_count_register("pdf_decimaldigits", 3) -# define pdf_image_resolution get_tex_extension_count_register("pdf_imageresolution", 72) -# define pdf_pk_resolution get_tex_extension_count_register("pdf_pkresolution", 72) -# define pdf_unique_resname get_tex_extension_count_register("pdf_uniqueresname", 0) -# define pdf_minor_version get_tex_extension_count_register("pdf_minorversion", 4) -# define pdf_pagebox get_tex_extension_count_register("pdf_pagebox", 0) -# define pdf_inclusion_errorlevel get_tex_extension_count_register("pdf_inclusionerrorlevel", 0) -# define pdf_gamma get_tex_extension_count_register("pdf_gamma", 1000) -# define pdf_image_apply_gamma get_tex_extension_count_register("pdf_imageapplygamma", 0) -# define pdf_image_gamma get_tex_extension_count_register("pdf_imagegamma", 2200) -# define pdf_image_hicolor get_tex_extension_count_register("pdf_imagehicolor", 1) -# define pdf_image_addfilename get_tex_extension_count_register("pdf_imageaddfilename", 1) -# define pdf_objcompresslevel get_tex_extension_count_register("pdf_objcompresslevel", 0) -# define pdf_inclusion_copy_font get_tex_extension_count_register("pdf_inclusioncopyfonts", 0) -# define pdf_gen_tounicode get_tex_extension_count_register("pdf_gentounicode", 0) -# define pdf_replace_font get_tex_extension_count_register("pdf_replacefont", 0) - -# define pdf_h_origin get_tex_extension_dimen_register("pdf_horigin", one_inch) -# define pdf_v_origin get_tex_extension_dimen_register("pdf_vorigin", one_inch) -# define pdf_thread_margin get_tex_extension_dimen_register("pdf_threadmargin", 0) -# define pdf_dest_margin get_tex_extension_dimen_register("pdf_destmargin", 0) -# define pdf_link_margin get_tex_extension_dimen_register("pdf_linkmargin", 0) - -# define pdf_page_attr get_tex_extension_toks_register("pdf_pageattr") -# define pdf_page_resources get_tex_extension_toks_register("pdf_pageresources") -# define pdf_pages_attr get_tex_extension_toks_register("pdf_pagesattr") -# define pdf_xform_attr get_tex_extension_toks_register("pdf_xformattr") -# define pdf_xform_resources get_tex_extension_toks_register("pdf_xformresources") -# define pdf_pk_mode get_tex_extension_toks_register("pdf_pkmode") - -# define set_pdf_minor_version(i) set_tex_extension_count_register("pdf_minorversion",i) -# define set_pdf_compress_level(i) set_tex_extension_count_register("pdf_compresslevel",i) -# define set_pdf_objcompresslevel(i) set_tex_extension_count_register("pdf_objcompresslevel",i) +# define pdf_compress_level get_tex_extension_count_register( 1, 9) +# define pdf_decimal_digits get_tex_extension_count_register( 2, 3) +# define pdf_image_resolution get_tex_extension_count_register( 3, 72) +# define pdf_pk_resolution get_tex_extension_count_register( 4, 72) +# define pdf_unique_resname get_tex_extension_count_register( 5, 0) +# define pdf_minor_version get_tex_extension_count_register( 6, 4) +# define pdf_pagebox get_tex_extension_count_register( 7, 0) +# define pdf_inclusion_errorlevel get_tex_extension_count_register( 8, 0) +# define pdf_gamma get_tex_extension_count_register( 9, 1000) +# define pdf_image_apply_gamma get_tex_extension_count_register(10, 0) +# define pdf_image_gamma get_tex_extension_count_register(11, 2200) +# define pdf_image_hicolor get_tex_extension_count_register(12, 1) +# define pdf_image_addfilename get_tex_extension_count_register(13, 1) +# define pdf_objcompresslevel get_tex_extension_count_register(14, 0) +# define pdf_inclusion_copy_font get_tex_extension_count_register(15, 0) +# define pdf_gen_tounicode get_tex_extension_count_register(16, 0) +# define pdf_replace_font get_tex_extension_count_register(17, 0) + +# define pdf_h_origin get_tex_extension_dimen_register(1, one_inch) +# define pdf_v_origin get_tex_extension_dimen_register(2, one_inch) +# define pdf_thread_margin get_tex_extension_dimen_register(3, 0) +# define pdf_dest_margin get_tex_extension_dimen_register(4, 0) +# define pdf_link_margin get_tex_extension_dimen_register(5, 0) + +# define pdf_page_attr get_tex_extension_toks_register(1) +# define pdf_page_resources get_tex_extension_toks_register(2) +# define pdf_pages_attr get_tex_extension_toks_register(3) +# define pdf_xform_attr get_tex_extension_toks_register(4) +# define pdf_xform_resources get_tex_extension_toks_register(5) +# define pdf_pk_mode get_tex_extension_toks_register(6) + +# define set_pdf_minor_version(i) set_tex_extension_count_register( 6,i) +# define set_pdf_compress_level(i) set_tex_extension_count_register( 1,i) +# define set_pdf_objcompresslevel(i) set_tex_extension_count_register(14,i) #endif /* PDFTABLES_H */ diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.h b/Build/source/texk/web2c/luatexdir/tex/commands.h index b14c59f783f..b047f837410 100644 --- a/Build/source/texk/web2c/luatexdir/tex/commands.h +++ b/Build/source/texk/web2c/luatexdir/tex/commands.h @@ -204,6 +204,8 @@ typedef enum { fi_or_else_cmd, /* delimiters for conditionals ( \.{\\else}, etc.~) */ cs_name_cmd, /* make a control sequence from tokens ( \.{\\csname} ) */ convert_cmd, /* convert to text ( \.{\\number}, \.{\\string}, etc.~) */ + variable_cmd, + feedback_cmd, the_cmd, /* expand an internal quantity ( \.{\\the} or \.{\\unexpanded}, \.{\\detokenize} ) */ top_bot_mark_cmd, /* inserted mark ( \.{\\topmark}, etc.~) */ call_cmd, /* non-long, non-outer control sequence */ @@ -266,21 +268,21 @@ typedef enum { pdf_variable_code, } convert_codes; -typedef enum { - pdf_font_name_code = 32, /* command code for \.{\\pdffeedback fontname} */ - pdf_font_objnum_code, /* command code for \.{\\pdffeedback fontobjnum} */ - pdf_font_size_code, /* command code for \.{\\pdffeedback fontsize} */ - pdf_page_ref_code, /* command code for \.{\\pdffeedback pageref} */ - pdf_xform_name_code, /* command code for \.{\\pdffeedback xformname} */ - pdf_creation_date_code, /* command code for \.{\\pdffeedback creationdate} */ - pdf_colorstack_init_code, /* command code for \.{\\pdffeedback colorstackinit} */ - pdf_last_obj_code, - pdf_last_annot_code, - pdf_retval_code, - pdf_last_link_code, - pdf_version_code, - pdf_revision_code, -} convert_codes_pdf; +/* typedef enum { */ +/* pdf_font_name_code = 32, */ +/* pdf_font_objnum_code, */ +/* pdf_font_size_code, */ +/* pdf_page_ref_code, */ +/* pdf_xform_name_code, */ +/* pdf_creation_date_code, */ +/* pdf_colorstack_init_code,*/ +/* pdf_last_obj_code, */ +/* pdf_last_annot_code, */ +/* pdf_retval_code, */ +/* pdf_last_link_code, */ +/* pdf_version_code, */ +/* pdf_revision_code, */ +/* } convert_codes_pdf; */ typedef enum { lastpenalty_code = 0, /* code for \.{\\lastpenalty} */ @@ -351,7 +353,6 @@ typedef enum { # define immediate_code 4 /* command modifier for \.{\\immediate} */ extern void initialize_commands(void); - extern void initialize_etex_commands(void); #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.w b/Build/source/texk/web2c/luatexdir/tex/commands.w index de4db31ee60..8cd6128b54d 100644 --- a/Build/source/texk/web2c/luatexdir/tex/commands.w +++ b/Build/source/texk/web2c/luatexdir/tex/commands.w @@ -689,11 +689,11 @@ void initialize_commands(void) primitive_luatex("latelua", normal_cmd, late_lua_code, 0); primitive_luatex("insertht", convert_cmd, insert_ht_code, 0); primitive_luatex("dviextension", extension_cmd, dvi_extension_code, 0); - primitive_luatex("dvifeedback", convert_cmd, dvi_feedback_code, 0); - primitive_luatex("dvivariable", convert_cmd, dvi_variable_code, 0); + primitive_luatex("dvifeedback", feedback_cmd, dvi_feedback_code, 0); + primitive_luatex("dvivariable", variable_cmd, dvi_variable_code, 0); primitive_luatex("pdfextension", extension_cmd, pdf_extension_code, 0); - primitive_luatex("pdffeedback", convert_cmd, pdf_feedback_code, 0); - primitive_luatex("pdfvariable", convert_cmd, pdf_variable_code, 0); + primitive_luatex("pdffeedback", feedback_cmd, pdf_feedback_code, 0); + primitive_luatex("pdfvariable", variable_cmd, pdf_variable_code, 0); primitive_luatex("mathoption", option_cmd, math_option_code, 0); /* diff --git a/Build/source/texk/web2c/luatexdir/tex/expand.w b/Build/source/texk/web2c/luatexdir/tex/expand.w index 5fa2cd7f08f..7ebb7b91ae0 100644 --- a/Build/source/texk/web2c/luatexdir/tex/expand.w +++ b/Build/source/texk/web2c/luatexdir/tex/expand.w @@ -271,6 +271,12 @@ void expand(void) else start_input(); break; + case variable_cmd: + do_variable(); + break; + case feedback_cmd: + do_variable(); + break; default: /* Complain about an undefined macro */ print_err("Undefined control sequence"); diff --git a/Build/source/texk/web2c/luatexdir/tex/extensions.h b/Build/source/texk/web2c/luatexdir/tex/extensions.h index 589a714445d..819bfa88b14 100644 --- a/Build/source/texk/web2c/luatexdir/tex/extensions.h +++ b/Build/source/texk/web2c/luatexdir/tex/extensions.h @@ -50,15 +50,6 @@ extern halfword write_loc; extern void do_extension(int immediate); -extern void do_extension_dvi(int immediate); -extern void do_extension_pdf(int immediate); - -extern void do_resource_dvi(int immediate, int code); -extern void do_resource_pdf(int immediate, int code); - -extern void do_feedback_dvi(); -extern void do_feedback_pdf(); - extern int pdf_last_annot; extern int pdf_last_link; extern int pdf_last_obj; @@ -104,11 +95,11 @@ extern halfword last_line_fill; /* the |par_fill_skip| glue node of the new para # define get_tex_attribute_register(j) attribute(j) # define get_tex_box_register(j) box(j) -extern int get_tex_extension_count_register(const char *s, int d); -extern void set_tex_extension_count_register(const char *s, int d); -extern int get_tex_extension_dimen_register(const char *s, int d); -extern void set_tex_extension_dimen_register(const char *s, int d); -extern int get_tex_extension_toks_register (const char *s); +extern int get_tex_extension_count_register(int i, int d); +extern void set_tex_extension_count_register(int i, int d); +extern int get_tex_extension_dimen_register(int i, int d); +extern void set_tex_extension_dimen_register(int i, int d); +extern int get_tex_extension_toks_register (int i); extern int set_tex_dimen_register(int j, scaled v); extern int set_tex_skip_register(int j, halfword v); @@ -167,37 +158,38 @@ typedef enum { /* for the moment there */ -typedef enum { - /* reserved, first needs to be larger than max extension_codes */ - pdf_literal_code = 32, - pdf_dest_code, - pdf_annot_code, - pdf_save_code, - pdf_restore_code, - pdf_setmatrix_code, - pdf_obj_code, - pdf_refobj_code, - pdf_colorstack_code, - pdf_start_link_code, - pdf_end_link_code, - pdf_link_data_code, - pdf_start_thread_code, - pdf_end_thread_code, - pdf_thread_code, - pdf_outline_code, - pdf_glyph_to_unicode_code, - pdf_catalog_code, - pdf_font_attr_code, - pdf_map_file_code, - pdf_map_line_code, - pdf_include_chars_code, - pdf_info_code, - pdf_names_code, - pdf_trailer_code, -} pdf_extension_codes; - -typedef enum { - dvi_literal_code = 32, /* alias for special */ -} dvi_extension_codes; +/* reserved, first needs to be larger than max extension_codes */ + +/* typedef enum { */ +/* pdf_literal_code = 32, */ +/* pdf_dest_code, */ +/* pdf_annot_code, */ +/* pdf_save_code, */ +/* pdf_restore_code, */ +/* pdf_setmatrix_code, */ +/* pdf_obj_code, */ +/* pdf_refobj_code, */ +/* pdf_colorstack_code, */ +/* pdf_start_link_code, */ +/* pdf_end_link_code, */ +/* pdf_link_data_code, */ +/* pdf_start_thread_code, */ +/* pdf_end_thread_code, */ +/* pdf_thread_code, */ +/* pdf_outline_code, */ +/* pdf_glyph_to_unicode_code, */ +/* pdf_catalog_code, */ +/* pdf_font_attr_code, */ +/* pdf_map_file_code, */ +/* pdf_map_line_code, */ +/* pdf_include_chars_code, */ +/* pdf_info_code, */ +/* pdf_names_code, */ +/* pdf_trailer_code, */ +/* } pdf_extension_codes; */ +/* */ +/* typedef enum { */ +/* dvi_literal_code = 32, */ +/* } dvi_extension_codes; */ #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/extensions.w b/Build/source/texk/web2c/luatexdir/tex/extensions.w index e2df4f23066..3bf7555fecf 100644 --- a/Build/source/texk/web2c/luatexdir/tex/extensions.w +++ b/Build/source/texk/web2c/luatexdir/tex/extensions.w @@ -128,7 +128,7 @@ int last_saved_image_pages ; int last_saved_box_index ; scaledpos last_position = { 0, 0 }; -void do_extension_dvi(int immediate) +static void do_extension_dvi(int immediate) { if (scan_keyword("literal")) { new_whatsit(special_node); @@ -140,204 +140,152 @@ void do_extension_dvi(int immediate) } } -void do_extension_pdf(int immediate) +static void do_extension_pdf(int immediate) { - int i, k; - - i = 0 ; - if (scan_keyword("literal")) i = pdf_literal_code ; - else if (scan_keyword("dest")) i = pdf_dest_code ; - else if (scan_keyword("annot")) i = pdf_annot_code ; - else if (scan_keyword("save")) i = pdf_save_code ; - else if (scan_keyword("restore")) i = pdf_restore_code ; - else if (scan_keyword("setmatrix")) i = pdf_setmatrix_code ; - else if (scan_keyword("obj")) i = pdf_obj_code ; - else if (scan_keyword("refobj")) i = pdf_refobj_code ; - else if (scan_keyword("colorstack")) i = pdf_colorstack_code ; - else if (scan_keyword("startlink")) i = pdf_start_link_code ; - else if (scan_keyword("endlink")) i = pdf_end_link_code ; - else if (scan_keyword("startthread")) i = pdf_start_thread_code ; - else if (scan_keyword("endthread")) i = pdf_end_thread_code ; - else if (scan_keyword("thread")) i = pdf_thread_code ; - else if (scan_keyword("outline")) i = pdf_outline_code ; - else if (scan_keyword("glyphtounicode")) i = pdf_glyph_to_unicode_code ; - else if (scan_keyword("catalog")) i = pdf_catalog_code ; - else if (scan_keyword("fontattr")) i = pdf_font_attr_code ; - else if (scan_keyword("mapfile")) i = pdf_map_file_code ; - else if (scan_keyword("mapline")) i = pdf_map_line_code ; - else if (scan_keyword("includechars")) i = pdf_include_chars_code ; - else if (scan_keyword("info")) i = pdf_info_code ; - else if (scan_keyword("names")) i = pdf_names_code ; - else if (scan_keyword("trailer")) i = pdf_trailer_code ; - - switch (i) { - case pdf_literal_code: - new_whatsit(pdf_literal_node); - if (scan_keyword("direct")) - set_pdf_literal_mode(tail, direct_always); - else if (scan_keyword("page")) - set_pdf_literal_mode(tail, direct_page); - else - set_pdf_literal_mode(tail, set_origin); - scan_pdf_ext_toks(); - set_pdf_literal_type(tail, normal); - set_pdf_literal_data(tail, def_ref); - break; - case pdf_dest_code: - scan_pdfdest(static_pdf); - break; - case pdf_annot_code: - scan_annot(static_pdf); - break; - case pdf_setmatrix_code: - new_whatsit(pdf_setmatrix_node); - scan_pdf_ext_toks(); - set_pdf_setmatrix_data(tail, def_ref); - break; - case pdf_save_code: - new_whatsit(pdf_save_node); - break; - case pdf_restore_code: - new_whatsit(pdf_restore_node); - break; - case pdf_obj_code: - scan_obj(static_pdf); - if (immediate) { - if (obj_data_ptr(static_pdf, pdf_last_obj) == 0) /* this object has not been initialized yet */ - normal_error("pdf backend","\\pdfextension obj 'reserveobjnum' cannot be used with \\immediate"); - pdf_write_obj(static_pdf, pdf_last_obj); - } - break; - case pdf_refobj_code: - scan_refobj(static_pdf); - break; - case pdf_colorstack_code: - scan_int(); - if (cur_val >= colorstackused()) { - print_err("Unknown color stack number "); - print_int(cur_val); - help3 - ("Allocate and initialize a color stack with \\pdfextension colorstackinit.", - "I'll use default color stack 0 here.", - "Proceed, with fingers crossed."); - error(); - cur_val = 0; - } - if (cur_val < 0) { - print_err("Invalid negative color stack number"); - help2("I'll use default color stack 0 here.", - "Proceed, with fingers crossed."); - error(); - cur_val = 0; - } - if (scan_keyword("set")) - i = colorstack_set; - else if (scan_keyword("push")) - i = colorstack_push; - else if (scan_keyword("pop")) - i = colorstack_pop; - else if (scan_keyword("current")) - i = colorstack_current; - else - i = -1; /* error */ - if (i >= 0) { - new_whatsit(pdf_colorstack_node); - set_pdf_colorstack_stack(tail, cur_val); - set_pdf_colorstack_cmd(tail, i); - set_pdf_colorstack_data(tail, null); - if (i <= colorstack_data) { - scan_pdf_ext_toks(); - set_pdf_colorstack_data(tail, def_ref); - } - } else { - print_err("Color stack action is missing"); - help3("The expected actions for \\pdfextension colorstack:", - " set, push, pop, current", - "I'll ignore the color stack command."); - error(); - } - break; - case pdf_start_link_code: - scan_startlink(static_pdf); - break; - case pdf_end_link_code: - if (abs(mode) == vmode) - normal_error("pdf backend", "\\pdfextension endlink cannot be used in vertical mode"); - new_whatsit(pdf_end_link_node); - break; - case pdf_start_thread_code: - new_annot_whatsit(pdf_start_thread_node); - scan_thread_id(); - break; - case pdf_end_thread_code: - new_whatsit(pdf_end_thread_node); - break; - case pdf_outline_code: - scan_pdfoutline(static_pdf); - break; - case pdf_glyph_to_unicode_code: - glyph_to_unicode(); - break; - case pdf_catalog_code: - scan_pdfcatalog(static_pdf); - break; - case pdf_font_attr_code: - /* - The font attributes are simply initialized to zero now, this is easier to deal with from C than an - empty \TeX{} string, and surely nobody will want to set font attr to a string containing a single zero, - as that would be nonsensical in the PDF output. - */ - scan_font_ident(); - k = cur_val; - if (k == null_font) - normal_error("pdf backend", "invalid font identifier"); - scan_pdf_ext_toks(); - set_pdf_font_attr(k, tokens_to_string(def_ref)); - if (str_length(pdf_font_attr(k)) == 0) { - flush_str((str_ptr - 1)); /* from |tokens_to_string| */ - set_pdf_font_attr(k, 0); + int i; + + if (scan_keyword("literal")) { + new_whatsit(pdf_literal_node); + if (scan_keyword("direct")) + set_pdf_literal_mode(tail, direct_always); + else if (scan_keyword("page")) + set_pdf_literal_mode(tail, direct_page); + else + set_pdf_literal_mode(tail, set_origin); + scan_pdf_ext_toks(); + set_pdf_literal_type(tail, normal); + set_pdf_literal_data(tail, def_ref); + } else if (scan_keyword("dest")) { + scan_pdfdest(static_pdf); + } else if (scan_keyword("annot")) { + scan_annot(static_pdf); + } else if (scan_keyword("save")) { + new_whatsit(pdf_save_node); + } else if (scan_keyword("restore")) { + new_whatsit(pdf_restore_node); + } else if (scan_keyword("setmatrix")) { + new_whatsit(pdf_setmatrix_node); + scan_pdf_ext_toks(); + set_pdf_setmatrix_data(tail, def_ref); + } else if (scan_keyword("obj")) { + scan_obj(static_pdf); + if (immediate) { + if (obj_data_ptr(static_pdf, pdf_last_obj) == 0) /* this object has not been initialized yet */ + normal_error("pdf backend","\\pdfextension obj 'reserveobjnum' cannot be used with \\immediate"); + pdf_write_obj(static_pdf, pdf_last_obj); + } + } else if (scan_keyword("refobj")) { + scan_refobj(static_pdf); + } else if (scan_keyword("colorstack")) { + scan_int(); + if (cur_val >= colorstackused()) { + print_err("Unknown color stack number "); + print_int(cur_val); + help3 + ("Allocate and initialize a color stack with \\pdfextension colorstackinit.", + "I'll use default color stack 0 here.", + "Proceed, with fingers crossed."); + error(); + cur_val = 0; + } + if (cur_val < 0) { + print_err("Invalid negative color stack number"); + help2("I'll use default color stack 0 here.", + "Proceed, with fingers crossed."); + error(); + cur_val = 0; + } + if (scan_keyword("set")) + i = colorstack_set; + else if (scan_keyword("push")) + i = colorstack_push; + else if (scan_keyword("pop")) + i = colorstack_pop; + else if (scan_keyword("current")) + i = colorstack_current; + else + i = -1; /* error */ + if (i >= 0) { + new_whatsit(pdf_colorstack_node); + set_pdf_colorstack_stack(tail, cur_val); + set_pdf_colorstack_cmd(tail, i); + set_pdf_colorstack_data(tail, null); + if (i <= colorstack_data) { + scan_pdf_ext_toks(); + set_pdf_colorstack_data(tail, def_ref); } - break; - case pdf_map_file_code: - scan_pdf_ext_toks(); - pdfmapfile(def_ref); - delete_token_ref(def_ref); - break; - case pdf_map_line_code: - scan_pdf_ext_toks(); - pdfmapline(def_ref); - delete_token_ref(def_ref); - break; - case pdf_include_chars_code: - pdf_include_chars(static_pdf); - break; - case pdf_info_code: - scan_pdf_ext_toks(); - pdf_info_toks = concat_tokens(pdf_info_toks, def_ref); - break; - case pdf_names_code: - scan_pdf_ext_toks(); - pdf_names_toks = concat_tokens(pdf_names_toks, def_ref); - break; - case pdf_thread_code: - new_annot_whatsit(pdf_thread_node); - scan_thread_id(); - break; - case pdf_trailer_code: - scan_pdf_ext_toks(); - pdf_trailer_toks = concat_tokens(pdf_trailer_toks, def_ref); - break; - default: - tex_error("unexpected use of \\pdfextension",null); - break ; + } else { + print_err("Color stack action is missing"); + help3("The expected actions for \\pdfextension colorstack:", + " set, push, pop, current", + "I'll ignore the color stack command."); + error(); + } + } else if (scan_keyword("startlink")) { + scan_startlink(static_pdf); + } else if (scan_keyword("endlink")) { + if (abs(mode) == vmode) + normal_error("pdf backend", "\\pdfextension endlink cannot be used in vertical mode"); + new_whatsit(pdf_end_link_node); + } else if (scan_keyword("startthread")) { + new_annot_whatsit(pdf_start_thread_node); + scan_thread_id(); + } else if (scan_keyword("endthread")) { + new_whatsit(pdf_end_thread_node); + } else if (scan_keyword("thread")) { + new_annot_whatsit(pdf_thread_node); + scan_thread_id(); + } else if (scan_keyword("outline")) { + scan_pdfoutline(static_pdf); + } else if (scan_keyword("glyphtounicode")) { + glyph_to_unicode(); + } else if (scan_keyword("catalog")) { + scan_pdfcatalog(static_pdf); + } else if (scan_keyword("fontattr")) { + /* + The font attributes are simply initialized to zero now, this is easier to deal with from C than an + empty \TeX{} string, and surely nobody will want to set font attr to a string containing a single zero, + as that would be nonsensical in the PDF output. + */ + scan_font_ident(); + i = cur_val; + if (i == null_font) + normal_error("pdf backend", "invalid font identifier"); + scan_pdf_ext_toks(); + set_pdf_font_attr(i, tokens_to_string(def_ref)); + if (str_length(pdf_font_attr(i)) == 0) { + flush_str((str_ptr - 1)); /* from |tokens_to_string| */ + set_pdf_font_attr(i, 0); + } + } else if (scan_keyword("mapfile")) { + scan_pdf_ext_toks(); + pdfmapfile(def_ref); + delete_token_ref(def_ref); + } else if (scan_keyword("mapline")) { + scan_pdf_ext_toks(); + pdfmapline(def_ref); + delete_token_ref(def_ref); + } else if (scan_keyword("includechars")) { + pdf_include_chars(static_pdf); + } else if (scan_keyword("info")) { + scan_pdf_ext_toks(); + pdf_info_toks = concat_tokens(pdf_info_toks, def_ref); + } else if (scan_keyword("names")) { + scan_pdf_ext_toks(); + pdf_names_toks = concat_tokens(pdf_names_toks, def_ref); + } else if (scan_keyword("trailer")) { + scan_pdf_ext_toks(); + pdf_trailer_toks = concat_tokens(pdf_trailer_toks, def_ref); + } else { + tex_error("unexpected use of \\pdfextension",null); } } -void do_resource_dvi(int immediate, int code) +static void do_resource_dvi(int immediate, int code) { } -void do_resource_pdf(int immediate, int code) +static void do_resource_pdf(int immediate, int code) { switch (code) { case use_box_resource_code: @@ -398,15 +346,8 @@ static void new_write_whatsit(int w, int check) scan_int(); if (cur_val < 0) cur_val = term_only; -#ifdef _MSC_VER - else if (cur_val > last_file_selector) { -/* In the original one, 16 or 17 becomes 143 = 127 + 16, so I don't - include (cur_val == write_target_direct) || (cur_val == write_target_special). - ak: */ -#else else if ((cur_val > last_file_selector) || (cur_val == write_target_direct) || (cur_val == write_target_special)) { /* hh: i need to check what 17 is supposed to do. so let's kind of reserve it */ -#endif cur_val = write_target_overflow; } } @@ -501,6 +442,7 @@ void do_extension(int immediate) if (get_o_mode() == OMODE_PDF) do_extension_pdf(immediate); break; + /* done */ default: if (immediate) { back_input(); @@ -1003,6 +945,8 @@ defines are not available. #define get_tex_attribute_register(j) attribute(j) #define get_tex_box_register(j) box(j) +/* + int get_tex_extension_count_register(const char *s, int d) { int cs; @@ -1045,7 +989,34 @@ int get_tex_extension_toks_register(const char *s) cs = string_lookup(s,strlen(s)); if ((cs == undefined_control_sequence || cs == undefined_cs_cmd)) return null; - return toks((equiv(cs) - toks_base)); /* a pointer to a token list */ + return toks((equiv(cs) - toks_base)); +} + +*/ + +int get_tex_extension_count_register(int i, int d) +{ + return (int) int_par(backend_int_base+i); +} + +void set_tex_extension_count_register(int i, int d) +{ + int_par(backend_int_base+i) = d; +} + +int get_tex_extension_dimen_register(int i, int d) +{ + return (int) dimen_par(backend_dimen_base+i); +} + +void set_tex_extension_dimen_register(int i, int d) +{ + dimen_par(backend_dimen_base+i) = d; +} + +int get_tex_extension_toks_register(int i) +{ + return equiv(backend_toks_base+i); /* brr */ } int set_tex_dimen_register(int j, scaled v) diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.h b/Build/source/texk/web2c/luatexdir/tex/textoken.h index 9da21492ce3..241d672264f 100644 --- a/Build/source/texk/web2c/luatexdir/tex/textoken.h +++ b/Build/source/texk/web2c/luatexdir/tex/textoken.h @@ -156,19 +156,11 @@ extern int scan_lua_state(void); extern void conv_toks(void); extern str_number the_convert_string(halfword c, int i); - -extern int conv_toks_dvi(halfword c); /* plugin */ -extern int conv_toks_pdf(halfword c); /* plugin */ - -extern int conv_var_dvi(halfword c); /* plugin */ -extern int conv_var_pdf(halfword c); /* plugin */ - -extern int the_convert_string_dvi(halfword c, int i); /* plugin */ -extern int the_convert_string_pdf(halfword c, int i); /* plugin */ +extern void do_variable(void); +extern void do_feedback(void); extern halfword lua_str_toks(lstring b); extern boolean in_lua_escape; -extern boolean is_convert(halfword c); # define closed 2 /* not open, or at end of file */ # define just_open 1 /* newly opened, first line not yet read */ diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.w b/Build/source/texk/web2c/luatexdir/tex/textoken.w index f98cd8ea223..1b1e9e5f095 100644 --- a/Build/source/texk/web2c/luatexdir/tex/textoken.w +++ b/Build/source/texk/web2c/luatexdir/tex/textoken.w @@ -56,8 +56,6 @@ also be a special flag that lies outside the bounds of |mem|, so we allow pointers to assume any |halfword| value. The minimum halfword value represents a null pointer. \TeX\ does not assume that |mem[null]| exists. - - @ Locations in |fixmem| are used for storing one-word records; a conventional \.{AVAIL} stack is used for allocation in this array. @@ -66,7 +64,6 @@ smemory_word *fixmem; /* the big dynamic storage area */ unsigned fix_mem_min; /* the smallest location of one-word memory in use */ unsigned fix_mem_max; /* the largest location of one-word memory in use */ - @ In order to study the memory requirements of particular applications, it is possible to prepare a version of \TeX\ that keeps track of current and maximum memory usage. When code between the delimiters |@!stat| $\ldots$ @@ -154,7 +151,6 @@ halfword get_avail(void) return (halfword) p; } - @ The procedure |flush_list(p)| frees an entire linked list of one-word nodes that starts at position |p|. @^inner loop@> @@ -276,7 +272,6 @@ void print_meaning(void) } } - @ The procedure |show_token_list|, which prints a symbolic form of the token list that starts at a given node |p|, illustrates these conventions. The token list being displayed should not begin with a reference @@ -304,6 +299,25 @@ form of control sequences that are not followed by a blank space, e.g., a real control sequence named \.{BAD} would come out `\.{\\BAD\ }'. @c +#define not_so_bad(p) \ + switch (m) { \ + case assign_int_cmd: \ + if (c >= (int_base+backend_int_base) && c <= (int_base+backend_int_last)) \ + p("[internal backend variable]"); \ + break; \ + case assign_dimen_cmd: \ + if (c >= (dimen_base+backend_dimen_base) && c <= (int_base+backend_dimen_last)) \ + p("[internal backend variable]"); \ + break; \ + case assign_toks_cmd: \ + if (c >= (backend_toks_base) && c <= (backend_toks_last)) \ + p("[internal backend variable]"); \ + break; \ + default: \ + p("BAD"); \ + break; \ + } + void show_token_list(int p, int q, int l) { int m, c; /* pieces of a token */ @@ -331,7 +345,7 @@ void show_token_list(int p, int q, int l) m = token_cmd(token_info(p)); c = token_chr(token_info(p)); if (token_info(p) < 0) { - tprint_esc("BAD."); + tprint_esc("BAD"); } else { /* Display the token $(|m|,|c|)$ */ /* The procedure usually ``learns'' the character code used for macro @@ -376,7 +390,7 @@ void show_token_list(int p, int q, int l) tprint("->"); break; default: - tprint_esc("BAD."); + not_so_bad(tprint); break; } } @@ -404,8 +418,6 @@ void token_show(halfword p) show_token_list(token_link(p), null, 10000000); } - - @ |delete_token_ref|, is called when a pointer to a token list's reference count is being removed. This means that the token list should disappear if the reference count was |null|, @@ -455,7 +467,6 @@ typedef enum { next_line_ok, next_line_return, static next_line_retval next_line(void); /* below */ - @ In case you are getting bored, here is a slightly less trivial routine: Given a string of lowercase letters, like `\.{pt}' or `\.{plus}' or `\.{width}', the |scan_keyword| routine checks to see whether the next @@ -625,7 +636,6 @@ it sets |cur_cmd=cur_chr=cur_cs=0| in the case that no more tokens appear on that line. (There might not be any tokens at all, if the |end_line_char| has |ignore| as its catcode.) - @ The value of |par_loc| is the |eqtb| address of `\.{\\par}'. This quantity is needed because a blank line of input is supposed to be exactly equivalent to the appearance of \.{\\par}; we must set |cur_cs:=par_loc| @@ -649,7 +659,6 @@ statements waiting to be input, it is changed by |luatokencall|. boolean force_eof; /* should the next \.{\\input} be aborted early? */ int luacstrings; /* how many lua strings are waiting to be input? */ - @ If the user has set the |pausing| parameter to some positive value, and if nonstop mode has not been selected, each line of input is displayed on the terminal and the transcript file, followed by `\.{=>}'. @@ -681,8 +690,6 @@ void firm_up_the_line(void) } } - - @ Before getting into |get_next|, let's consider the subroutine that is called when an `\.{\\outer}' control sequence has been scanned or when the end of a file has been reached. These two cases are distinguished @@ -965,30 +972,30 @@ static boolean get_next_file(void) @ @c #define is_hex(a) ((a>='0'&&a<='9')||(a>='a'&&a<='f')) -#define add_nybble(a) do { \ - if (a<='9') cur_chr=(cur_chr<<4)+a-'0'; \ - else cur_chr=(cur_chr<<4)+a-'a'+10; \ +#define add_nybble(a) do { \ + if (a<='9') cur_chr=(cur_chr<<4)+a-'0'; \ + else cur_chr=(cur_chr<<4)+a-'a'+10; \ } while (0) -#define hex_to_cur_chr do { \ - if (c<='9') cur_chr=c-'0'; \ - else cur_chr=c-'a'+10; \ - add_nybble(cc); \ +#define hex_to_cur_chr do { \ + if (c<='9') cur_chr=c-'0'; \ + else cur_chr=c-'a'+10; \ + add_nybble(cc); \ } while (0) -#define four_hex_to_cur_chr do { \ - hex_to_cur_chr; \ - add_nybble(ccc); add_nybble(cccc); \ +#define four_hex_to_cur_chr do { \ + hex_to_cur_chr; \ + add_nybble(ccc); add_nybble(cccc); \ } while (0) -#define five_hex_to_cur_chr do { \ - four_hex_to_cur_chr; \ - add_nybble(ccccc); \ +#define five_hex_to_cur_chr do { \ + four_hex_to_cur_chr; \ + add_nybble(ccccc); \ } while (0) -#define six_hex_to_cur_chr do { \ - five_hex_to_cur_chr; \ - add_nybble(cccccc); \ +#define six_hex_to_cur_chr do { \ + five_hex_to_cur_chr; \ + add_nybble(cccccc); \ } while (0) @@ -1241,7 +1248,6 @@ static boolean check_expanded_code(int *kk) return false; } - @ All of the easy branches of |get_next| have now been taken care of. There is one more branch. @@ -1443,7 +1449,6 @@ void get_next(void) } } - @ Since |get_next| is used so frequently in \TeX, it is convenient to define three related procedures that do a little more: @@ -1564,7 +1569,6 @@ halfword lua_str_toks(lstring b) return p; } - @ Incidentally, the main reason for wanting |str_toks| is the function |the_toks|, which has similar input/output characteristics. @@ -1738,7 +1742,7 @@ we have to create a temporary string that is destroyed immediately after. selector = old_setting; \ } -int conv_var_dvi(halfword c) +static int do_variable_dvi(halfword c) { return 0; } @@ -1746,85 +1750,63 @@ int conv_var_dvi(halfword c) #define backend_dimen(A) eqtb[scaled_base+(A)].hh.rh #define backend_count(A) eqtb[count_base+(A)].hh.rh -#define get_backend_count(cur_cs,name,index,default) { \ - no_new_control_sequence = false; \ - cur_cs = string_lookup(name,strlen(name)); \ - no_new_control_sequence = true; \ - if (eq_type(cur_cs) == undefined_cs_cmd) { \ - assert(index < backend_int_last); \ - primitive_tex(name, assign_int_cmd, int_base + index, int_base); \ - backend_count(cur_cs) = default ; \ - } \ - cur_tok = cur_cs + cs_token_flag; \ - back_input(); \ -} - -#define get_backend_dimen(cur_cs,name,index,default) { \ - no_new_control_sequence = false; \ - cur_cs = string_lookup(name,strlen(name)); \ - no_new_control_sequence = true; \ - if (eq_type(cur_cs) == undefined_cs_cmd) { \ - assert(index < backend_dimen_last); \ - primitive_tex(name, assign_dimen_cmd, dimen_base + index, dimen_base); \ - backend_dimen(cur_cs) = default ; \ - } \ - cur_tok = cur_cs + cs_token_flag; \ - back_input(); \ -} - -#define get_backend_toks(cur_cs,name,index) { \ - no_new_control_sequence = false; \ - cur_cs = string_lookup(name,strlen(name)); \ - no_new_control_sequence = true; \ - if (eq_type(cur_cs) == undefined_cs_cmd) { \ - assert(index < backend_toks_last); \ - primitive_tex(name, assign_toks_cmd, index, local_base); \ - } \ - cur_tok = cur_cs + cs_token_flag; \ - back_input(); \ -} - -int conv_var_pdf(halfword c) +#define do_variable_backend_int(i) \ + cur_cmd = assign_int_cmd; \ + cur_val = backend_int_base + i + int_base; \ + cur_tok = token_val(cur_cmd, cur_val); \ + back_input(); + +#define do_variable_backend_dimen(i) \ + cur_cmd = assign_dimen_cmd; \ + cur_val = backend_dimen_base + i + dimen_base; \ + cur_tok = token_val(cur_cmd, cur_val); \ + back_input(); + +#define do_variable_backend_toks(i) \ + cur_cmd = assign_toks_cmd; \ + cur_val = backend_toks_base + i ; /* + local_base ; */ \ + cur_tok = token_val(cur_cmd, cur_val); \ + back_input(); + +static int do_variable_pdf(halfword c) { - /* todo: optimize order, but hardly any access */ - - if (scan_keyword("compresslevel")) { get_backend_count(cur_cs,"pdf_compresslevel", backend_int_base + 1, 9); } - else if (scan_keyword("decimaldigits")) { get_backend_count(cur_cs,"pdf_decimaldigits", backend_int_base + 2, 3); } - else if (scan_keyword("imageresolution")) { get_backend_count(cur_cs,"pdf_imageresolution", backend_int_base + 3, 72); } - else if (scan_keyword("pkresolution")) { get_backend_count(cur_cs,"pdf_pkresolution", backend_int_base + 4, 72); } - else if (scan_keyword("uniqueresname")) { get_backend_count(cur_cs,"pdf_uniqueresname", backend_int_base + 5, 0); } - else if (scan_keyword("minorversion")) { get_backend_count(cur_cs,"pdf_minorversion", backend_int_base + 6, 4); } - else if (scan_keyword("pagebox")) { get_backend_count(cur_cs,"pdf_pagebox", backend_int_base + 7, 0); } - else if (scan_keyword("inclusionerrorlevel")) { get_backend_count(cur_cs,"pdf_inclusionerrorlevel", backend_int_base + 8, 0); } - else if (scan_keyword("gamma")) { get_backend_count(cur_cs,"pdf_gamma", backend_int_base + 9, 1000); } - else if (scan_keyword("imageapplygamma")) { get_backend_count(cur_cs,"pdf_imageapplygamma", backend_int_base + 10, 0); } - else if (scan_keyword("imagegamma")) { get_backend_count(cur_cs,"pdf_imagegamma", backend_int_base + 11, 2200); } - else if (scan_keyword("imagehicolor")) { get_backend_count(cur_cs,"pdf_imagehicolor", backend_int_base + 12, 1); } - else if (scan_keyword("imageaddfilename")) { get_backend_count(cur_cs,"pdf_imageaddfilename", backend_int_base + 12, 1); } - else if (scan_keyword("objcompresslevel")) { get_backend_count(cur_cs,"pdf_objcompresslevel", backend_int_base + 13, 0); } - else if (scan_keyword("inclusioncopyfonts")) { get_backend_count(cur_cs,"pdf_inclusioncopyfonts", backend_int_base + 14, 0); } - else if (scan_keyword("gentounicode")) { get_backend_count(cur_cs,"pdf_gentounicode", backend_int_base + 15, 0); } - else if (scan_keyword("replacefont")) { get_backend_count(cur_cs,"pdf_replacefont", backend_int_base + 16, 0); } - - else if (scan_keyword("horigin")) { get_backend_dimen(cur_cs,"pdf_horigin", backend_dimen_base + 1, one_inch); } - else if (scan_keyword("vorigin")) { get_backend_dimen(cur_cs,"pdf_vorigin", backend_dimen_base + 2, one_inch); } - else if (scan_keyword("threadmargin")) { get_backend_dimen(cur_cs,"pdf_threadmargin", backend_dimen_base + 3, 0); } - else if (scan_keyword("destmargin")) { get_backend_dimen(cur_cs,"pdf_destmargin", backend_dimen_base + 4, 0); } - else if (scan_keyword("linkmargin")) { get_backend_dimen(cur_cs,"pdf_linkmargin", backend_dimen_base + 5, 0); } - - else if (scan_keyword("pageattr")) { get_backend_toks (cur_cs,"pdf_pageattr", backend_toks_base + 1); } - else if (scan_keyword("pageresources")) { get_backend_toks (cur_cs,"pdf_pageresources", backend_toks_base + 2); } - else if (scan_keyword("pagesattr")) { get_backend_toks (cur_cs,"pdf_pagesattr", backend_toks_base + 3); } - else if (scan_keyword("xformattr")) { get_backend_toks (cur_cs,"pdf_xformattr", backend_toks_base + 4); } - else if (scan_keyword("xformresources")) { get_backend_toks (cur_cs,"pdf_xformresources", backend_toks_base + 5); } - else if (scan_keyword("pkmode")) { get_backend_toks (cur_cs,"pdf_pkmode", backend_toks_base + 6); } + if (scan_keyword("compresslevel")) { do_variable_backend_int( 1); } + else if (scan_keyword("decimaldigits")) { do_variable_backend_int( 2); } + else if (scan_keyword("imageresolution")) { do_variable_backend_int( 3); } + else if (scan_keyword("pkresolution")) { do_variable_backend_int( 4); } + else if (scan_keyword("uniqueresname")) { do_variable_backend_int( 5); } + else if (scan_keyword("minorversion")) { do_variable_backend_int( 6); } + else if (scan_keyword("pagebox")) { do_variable_backend_int( 7); } + else if (scan_keyword("inclusionerrorlevel")) { do_variable_backend_int( 8); } + else if (scan_keyword("gamma")) { do_variable_backend_int( 9); } + else if (scan_keyword("imageapplygamma")) { do_variable_backend_int(10); } + else if (scan_keyword("imagegamma")) { do_variable_backend_int(11); } + else if (scan_keyword("imagehicolor")) { do_variable_backend_int(12); } + else if (scan_keyword("imageaddfilename")) { do_variable_backend_int(13); } + else if (scan_keyword("objcompresslevel")) { do_variable_backend_int(14); } + else if (scan_keyword("inclusioncopyfonts")) { do_variable_backend_int(15); } + else if (scan_keyword("gentounicode")) { do_variable_backend_int(16); } + else if (scan_keyword("replacefont")) { do_variable_backend_int(17); } + + else if (scan_keyword("horigin")) { do_variable_backend_dimen(1); } + else if (scan_keyword("vorigin")) { do_variable_backend_dimen(2); } + else if (scan_keyword("threadmargin")) { do_variable_backend_dimen(3); } + else if (scan_keyword("destmargin")) { do_variable_backend_dimen(4); } + else if (scan_keyword("linkmargin")) { do_variable_backend_dimen(5); } + + else if (scan_keyword("pageattr")) { do_variable_backend_toks(1); } + else if (scan_keyword("pageresources")) { do_variable_backend_toks(2); } + else if (scan_keyword("pagesattr")) { do_variable_backend_toks(3); } + else if (scan_keyword("xformattr")) { do_variable_backend_toks(4); } + else if (scan_keyword("xformresources")) { do_variable_backend_toks(5); } + else if (scan_keyword("pkmode")) { do_variable_backend_toks(6); } else return 0; return 1; } -int conv_toks_dvi(halfword c) +static int do_feedback_dvi(halfword c) { return 0; } @@ -1834,7 +1816,7 @@ int conv_toks_dvi(halfword c) #define pdftex_version 40 /* these values will not change any more */ #define pdftex_revision "0" /* these values will not change any more */ -int conv_toks_pdf(halfword c) +static int do_feedback_pdf(halfword c) { int old_setting; /* holds |selector| setting */ int save_scanner_status; /* |scanner_status| upon entry */ @@ -1846,141 +1828,112 @@ int conv_toks_pdf(halfword c) str_number u = 0; /* third temp string, will become non-nil if a string is already being built */ char *str; /* color stack init str */ - if (scan_keyword("lastlink")) c = pdf_last_link_code; - else if (scan_keyword("retval")) c = pdf_retval_code; - else if (scan_keyword("lastobj")) c = pdf_last_obj_code; - else if (scan_keyword("lastannot")) c = pdf_last_annot_code; - else if (scan_keyword("xformname")) c = pdf_xform_name_code; - else if (scan_keyword("creationdate")) c = pdf_creation_date_code; - else if (scan_keyword("fontname")) c = pdf_font_name_code; - else if (scan_keyword("fontobjnum")) c = pdf_font_objnum_code; - else if (scan_keyword("fontsize")) c = pdf_font_size_code; - else if (scan_keyword("pageref")) c = pdf_page_ref_code; - else if (scan_keyword("colorstackinit")) c = pdf_colorstack_init_code; - else if (scan_keyword("version")) c = pdf_version_code; - else if (scan_keyword("revision")) c = pdf_revision_code; - - switch (c) { - case pdf_last_link_code: - push_selector; - print_int(pdf_last_link); - pop_selector; - break; - case pdf_retval_code: - push_selector; - print_int(pdf_retval); - pop_selector; - break; - case pdf_last_obj_code: - push_selector; - print_int(pdf_last_obj); - pop_selector; - break; - case pdf_last_annot_code: - push_selector; - print_int(pdf_last_annot); - pop_selector; - break; - case pdf_xform_name_code: - scan_int(); - check_obj_type(static_pdf, obj_type_xform, cur_val); - push_selector; - print_int(obj_info(static_pdf, cur_val)); - pop_selector; - break; - case pdf_creation_date_code: - ins_list(string_to_toks(getcreationdate(static_pdf))); - /* no further action */ - return 2; - break; - case pdf_font_name_code: - scan_font_ident(); - if (cur_val == null_font) - normal_error("pdf backend", "invalid font identifier when asking 'fontname'"); - pdf_check_vf(cur_val); - if (!font_used(cur_val)) - pdf_init_font(static_pdf, cur_val); - push_selector; - set_ff(cur_val); - print_int(obj_info(static_pdf, pdf_font_num(ff))); - pop_selector; - break; - case pdf_font_objnum_code: - scan_font_ident(); - if (cur_val == null_font) - normal_error("pdf backend", "invalid font identifier when asking 'objnum'"); - pdf_check_vf(cur_val); - if (!font_used(cur_val)) - pdf_init_font(static_pdf, cur_val); - push_selector; - set_ff(cur_val); - print_int(pdf_font_num(ff)); - pop_selector; - break; - case pdf_font_size_code: - scan_font_ident(); - if (cur_val == null_font) - normal_error("pdf backend", "invalid font identifier when asking 'fontsize'"); - push_selector; - print_scaled(font_size(cur_val)); - tprint("pt"); - pop_selector; - break; - case pdf_page_ref_code: - scan_int(); - if (cur_val <= 0) - normal_error("pdf backend", "invalid page number when asking 'pageref'"); - push_selector; - print_int(pdf_get_obj(static_pdf, obj_type_page, cur_val, false)); - pop_selector; - break; - case pdf_colorstack_init_code: - bool = scan_keyword("page"); - if (scan_keyword("direct")) - cur_val = direct_always; - else if (scan_keyword("page")) - cur_val = direct_page; - else - cur_val = set_origin; - save_scanner_status = scanner_status; - save_warning_index = warning_index; - save_def_ref = def_ref; - u = save_cur_string(); - scan_toks(false, true); /*hh-ls was scan_pdf_ext_toks();*/ - s = tokens_to_string(def_ref); - delete_token_ref(def_ref); - def_ref = save_def_ref; - warning_index = save_warning_index; - scanner_status = save_scanner_status; - str = makecstring(s); - cur_val = newcolorstack(str, cur_val, bool); - free(str); - flush_str(s); - cur_val_level = int_val_level; - if (cur_val < 0) { - print_err("Too many color stacks"); - help2("The number of color stacks is limited to 32768.", - "I'll use the default color stack 0 here."); - error(); - cur_val = 0; - restore_cur_string(u); - } - push_selector; - print_int(cur_val); - pop_selector; - break; - case pdf_version_code: - push_selector; - print_int(pdftex_version); - pop_selector; - break; - case pdf_revision_code: - ins_list(string_to_toks(pdftex_revision)); - return 2; - break; - default: - return 0; - break; + if (scan_keyword("lastlink")) { + push_selector; + print_int(pdf_last_link); + pop_selector; + } else if (scan_keyword("retval")) { + push_selector; + print_int(pdf_retval); + pop_selector; + } else if (scan_keyword("lastobj")) { + push_selector; + print_int(pdf_last_obj); + pop_selector; + } else if (scan_keyword("lastannot")) { + push_selector; + print_int(pdf_last_annot); + pop_selector; + } else if (scan_keyword("xformname")) { + scan_int(); + check_obj_type(static_pdf, obj_type_xform, cur_val); + push_selector; + print_int(obj_info(static_pdf, cur_val)); + pop_selector; + } else if (scan_keyword("creationdate")) { + ins_list(string_to_toks(getcreationdate(static_pdf))); + /* no further action */ + return 2; + } else if (scan_keyword("fontname")) { + scan_font_ident(); + if (cur_val == null_font) + normal_error("pdf backend", "invalid font identifier when asking 'fontname'"); + pdf_check_vf(cur_val); + if (!font_used(cur_val)) + pdf_init_font(static_pdf, cur_val); + push_selector; + set_ff(cur_val); + print_int(obj_info(static_pdf, pdf_font_num(ff))); + pop_selector; + } else if (scan_keyword("fontobjnum")) { + scan_font_ident(); + if (cur_val == null_font) + normal_error("pdf backend", "invalid font identifier when asking 'objnum'"); + pdf_check_vf(cur_val); + if (!font_used(cur_val)) + pdf_init_font(static_pdf, cur_val); + push_selector; + set_ff(cur_val); + print_int(pdf_font_num(ff)); + pop_selector; + } else if (scan_keyword("fontsize")) { + scan_font_ident(); + if (cur_val == null_font) + normal_error("pdf backend", "invalid font identifier when asking 'fontsize'"); + push_selector; + print_scaled(font_size(cur_val)); + tprint("pt"); + pop_selector; + } else if (scan_keyword("pageref")) { + scan_int(); + if (cur_val <= 0) + normal_error("pdf backend", "invalid page number when asking 'pageref'"); + push_selector; + print_int(pdf_get_obj(static_pdf, obj_type_page, cur_val, false)); + pop_selector; + } else if (scan_keyword("colorstackinit")) { + bool = scan_keyword("page"); + if (scan_keyword("direct")) + cur_val = direct_always; + else if (scan_keyword("page")) + cur_val = direct_page; + else + cur_val = set_origin; + save_scanner_status = scanner_status; + save_warning_index = warning_index; + save_def_ref = def_ref; + u = save_cur_string(); + scan_toks(false, true); /*hh-ls was scan_pdf_ext_toks();*/ + s = tokens_to_string(def_ref); + delete_token_ref(def_ref); + def_ref = save_def_ref; + warning_index = save_warning_index; + scanner_status = save_scanner_status; + str = makecstring(s); + cur_val = newcolorstack(str, cur_val, bool); + free(str); + flush_str(s); + cur_val_level = int_val_level; + if (cur_val < 0) { + print_err("Too many color stacks"); + help2("The number of color stacks is limited to 32768.", + "I'll use the default color stack 0 here."); + error(); + cur_val = 0; + restore_cur_string(u); + } + push_selector; + print_int(cur_val); + pop_selector; + } else if (scan_keyword("version")) { + push_selector; + print_int(pdftex_version); + pop_selector; + } else if (scan_keyword("revision")) { + ins_list(string_to_toks(pdftex_revision)); + return 2; + } else { + return 0; } return 1; } @@ -1998,7 +1951,6 @@ void conv_toks(void) str_number u = 0; /* third temp string, will become non-nil if a string is already being built */ int c = cur_chr; /* desired type of conversion */ str_number str; - int done = 1; int i = 0; /* Scan the argument for command |c| */ switch (c) { @@ -2284,21 +2236,10 @@ void conv_toks(void) tprint("pt"); pop_selector; break; - case dvi_variable_code: - done = conv_var_dvi(c); - if (done==0) - tex_error("unexpected use of \\dvivariable",null); - return; - break; - case pdf_variable_code: - done = conv_var_pdf(c); - if (done==0) - tex_error("unexpected use of \\pdfvariable",null); - return; - break; + /* case dvi_feedback_code: if (get_o_mode() == OMODE_DVI) - done = conv_toks_dvi(c); + done = do_feedback_dvi(c); else done = 0; if (done==0) @@ -2316,83 +2257,117 @@ void conv_toks(void) else if (done==2) return; break; + */ default: confusion("convert"); break; } + str = make_string(); + (void) str_toks(str_lstring(str)); + flush_str(str); + ins_list(token_link(temp_token_head)); +} +void do_feedback(void) +{ + int c = cur_chr; + str_number str; + int done = 1; + switch (c) { + case dvi_feedback_code: + if (get_o_mode() == OMODE_DVI) + done = do_feedback_dvi(c); + else + done = 0; + if (done==0) + tex_error("unexpected use of \\dvifeedback",null); + else if (done==2) + return; + break; + case pdf_feedback_code: + if (get_o_mode() == OMODE_PDF) + done = do_feedback_pdf(c); + else + done = 0; + if (done==0) + tex_error("unexpected use of \\pdffeedback",null); + else if (done==2) + return; + break; + default: + confusion("feedback"); + break; + } str = make_string(); (void) str_toks(str_lstring(str)); flush_str(str); ins_list(token_link(temp_token_head)); } +void do_variable(void) +{ + int c = cur_chr; + int done = 1; + switch (c) { + case dvi_variable_code: + done = do_variable_dvi(c); + if (done==0) + tex_error("unexpected use of \\dvivariable",null); + return; + break; + case pdf_variable_code: + done = do_variable_pdf(c); + if (done==0) + tex_error("unexpected use of \\pdfvariable",null); + return; + break; + default: + confusion("variable"); + break; + } +} + @ This boolean is keeping track of the lua string escape state @c boolean in_lua_escape; -@ probably not needed anymore -@c -boolean is_convert(halfword c) -{ - return (c == convert_cmd); -} - -int the_convert_string_dvi(halfword c, int i) +static int the_convert_string_dvi(halfword c, int i) { - return 0; + return 0 ; } -int the_convert_string_pdf(halfword c, int i) +static int the_convert_string_pdf(halfword c, int i) { int ff; - - if (scan_keyword("lastlink")) c = pdf_last_link_code; - else if (scan_keyword("retval")) c = pdf_retval_code; - else if (scan_keyword("lastobj")) c = pdf_last_obj_code; - else if (scan_keyword("lastannot")) c = pdf_last_annot_code; - else if (scan_keyword("xformname")) c = pdf_xform_name_code; - /* else if (scan_keyword("creationdate")) c = pdf_creation_date_code; */ - else if (scan_keyword("fontname")) c = pdf_font_name_code; - else if (scan_keyword("fontobjnum")) c = pdf_font_objnum_code; - else if (scan_keyword("fontsize")) c = pdf_font_size_code; - else if (scan_keyword("pageref")) c = pdf_page_ref_code; - /* else if (scan_keyword("colorstackinit")) c = pdf_colorstack_init_code; */ - - switch(c) { - case pdf_last_link_code: - print_int(pdf_last_link); - break; - case pdf_retval_code: - print_int(pdf_retval); - break; - case pdf_last_obj_code: - print_int(pdf_last_obj); - break; - case pdf_last_annot_code: - print_int(pdf_last_annot); - break; - case pdf_font_name_code: - set_ff(i); - print_int(obj_info(static_pdf, pdf_font_num(ff))); - break; - case pdf_font_objnum_code: - set_ff(i); - print_int(pdf_font_num(ff)); - break; - case pdf_font_size_code: - print_scaled(font_size(i)); - tprint("pt"); - break; - case pdf_page_ref_code: - print_int(pdf_get_obj(static_pdf, obj_type_page, i, false)); - break; - case pdf_xform_name_code: - print_int(obj_info(static_pdf, i)); - break; - default: - return 0; - break; + if (get_o_mode() != OMODE_PDF) { + return 0; + } else if (scan_keyword("lastlink")) { + print_int(pdf_last_link); + } else if (scan_keyword("retval")) { + print_int(pdf_retval); + } else if (scan_keyword("lastobj")) { + print_int(pdf_last_obj); + } else if (scan_keyword("lastannot")) { + print_int(pdf_last_annot); + } else if (scan_keyword("xformname")) { + print_int(obj_info(static_pdf, i)); + } else if (scan_keyword("creationdate")) { + return 0; + } else if (scan_keyword("fontname")) { + set_ff(i); + print_int(obj_info(static_pdf, pdf_font_num(ff))); + } else if (scan_keyword("fontobjnum")) { + set_ff(i); + print_int(pdf_font_num(ff)); + } else if (scan_keyword("fontsize")) { + print_scaled(font_size(i)); + tprint("pt"); + } else if (scan_keyword("pageref")) { + print_int(pdf_get_obj(static_pdf, obj_type_page, i, false)); + } else if (scan_keyword("colorstackinit")) { + return 0; + } else { + return 0; } return 1; } @@ -2458,24 +2433,21 @@ str_number the_convert_string(halfword c, int i) case font_identifier_code: print_font_identifier(i); break; + /* backend: this might become obsolete */ case dvi_feedback_code: - if (get_o_mode() == OMODE_DVI) - done = the_convert_string_dvi(c,i); - else - done = false; + done = the_convert_string_dvi(c,i); break; case pdf_feedback_code: - if (get_o_mode() == OMODE_PDF) - done = the_convert_string_pdf(c,i); - else - done = false; + done = the_convert_string_pdf(c,i); break; + /* done */ default: done = false; break; } - if (done) + if (done) { ret = make_string(); + } selector = old_setting; return ret; } @@ -2628,48 +2600,53 @@ str_number tokens_to_string(halfword p) } @ @c -#define make_room(a) \ - if ((unsigned)i+a+1>alloci) { \ - ret = xrealloc(ret,(alloci+64)); \ - alloci = alloci + 64; \ +#define make_room(a) \ + if ((unsigned)i+a+1>alloci) { \ + ret = xrealloc(ret,(alloci+64)); \ + alloci = alloci + 64; \ } - #define append_i_byte(a) ret[i++] = (char)(a) #define Print_char(a) make_room(1); append_i_byte(a) -#define Print_uchar(s) { \ - make_room(4); \ - if (s<=0x7F) { \ - append_i_byte(s); \ - } else if (s<=0x7FF) { \ - append_i_byte(0xC0 + (s / 0x40)); \ - append_i_byte(0x80 + (s % 0x40)); \ - } else if (s<=0xFFFF) { \ - append_i_byte(0xE0 + (s / 0x1000)); \ - append_i_byte(0x80 + ((s % 0x1000) / 0x40)); \ - append_i_byte(0x80 + ((s % 0x1000) % 0x40)); \ - } else if (s>=0x110000) { \ - append_i_byte(s-0x11000); \ - } else { \ - append_i_byte(0xF0 + (s / 0x40000)); \ - append_i_byte(0x80 + ((s % 0x40000) / 0x1000)); \ - append_i_byte(0x80 + (((s % 0x40000) % 0x1000) / 0x40)); \ - append_i_byte(0x80 + (((s % 0x40000) % 0x1000) % 0x40)); \ +#define Print_uchar(s) { \ + make_room(4); \ + if (s<=0x7F) { \ + append_i_byte(s); \ + } else if (s<=0x7FF) { \ + append_i_byte(0xC0 + (s / 0x40)); \ + append_i_byte(0x80 + (s % 0x40)); \ + } else if (s<=0xFFFF) { \ + append_i_byte(0xE0 + (s / 0x1000)); \ + append_i_byte(0x80 + ((s % 0x1000) / 0x40)); \ + append_i_byte(0x80 + ((s % 0x1000) % 0x40)); \ + } else if (s>=0x110000) { \ + append_i_byte(s-0x11000); \ + } else { \ + append_i_byte(0xF0 + (s / 0x40000)); \ + append_i_byte(0x80 + ((s % 0x40000) / 0x1000)); \ + append_i_byte(0x80 + (((s % 0x40000) % 0x1000) / 0x40)); \ + append_i_byte(0x80 + (((s % 0x40000) % 0x1000) % 0x40)); \ } } -#define Print_esc(b) { \ - const char *v = b; \ - if (e>0 && e<STRING_OFFSET) { \ - Print_uchar (e); \ - } \ - make_room(strlen(v)); \ - while (*v) { append_i_byte(*v); v++; } \ +#define Print_esc(b) { \ + const char *v = b; \ + if (e>0 && e<STRING_OFFSET) { \ + Print_uchar (e); \ + } \ + make_room(strlen(v)); \ + while (*v) { append_i_byte(*v); v++; } \ + } + +#define Print_str(b) { \ + const char *v = b; \ + make_room(strlen(v)); \ + while (*v) { append_i_byte(*v); v++; } \ } -#define is_cat_letter(a) \ +#define is_cat_letter(a) \ (get_char_cat_code(pool_to_unichar(str_string((a)))) == 11) @ the actual token conversion in this function is now functionally @@ -2748,7 +2725,7 @@ char *tokenlist_to_cstring(int pp, int inhibit_par, int *siz) } } else { if (infop < 0) { - Print_esc("BAD."); + Print_esc("BAD"); } else { m = token_cmd(infop); c = token_chr(infop); @@ -2793,7 +2770,7 @@ char *tokenlist_to_cstring(int pp, int inhibit_par, int *siz) } break; default: - Print_esc("BAD."); + not_so_bad(Print_esc); break; } } |