do_dump().
do_undump().
complain_line().
fix_date_and_time().
void init_prim (void)
{
no_new_control_sequence = false;
+ /* sec 0266 */
primitive("lineskip", assign_glue, glue_base + line_skip_code);
primitive("baselineskip", assign_glue, glue_base + baseline_skip_code);
primitive("parskip", assign_glue, glue_base + par_skip_code);
primitive("thinmuskip", assign_mu_glue, glue_base + thin_mu_skip_code);
primitive("medmuskip", assign_mu_glue, glue_base + med_mu_skip_code);
primitive("thickmuskip", assign_mu_glue, glue_base + thick_mu_skip_code);
+ /* sec 0230 */
primitive("output", assign_toks, output_routine_loc);
primitive("everypar", assign_toks, every_par_loc);
primitive("everymath", assign_toks, every_math_loc);
primitive("everyjob", assign_toks, every_job_loc);
primitive("everycr", assign_toks, every_cr_loc);
primitive("errhelp", assign_toks, err_help_loc);
+ /* sec 0238 */
primitive("pretolerance", assign_int, int_base + pretolerance_code);
primitive("tolerance", assign_int, int_base + tolerance_code);
primitive("linepenalty", assign_int, int_base + line_penalty_code);
primitive("righthyphenmin", assign_int, int_base + right_hyphen_min_code);
primitive("holdinginserts", assign_int, int_base + holding_inserts_code);
primitive("errorcontextlines", assign_int, int_base + error_context_lines_code);
+ /* sec 0248 */
primitive("parindent", assign_dimen, dimen_base + par_indent_code);
primitive("mathsurround", assign_dimen, dimen_base + math_surround_code);
primitive("lineskiplimit", assign_dimen, dimen_base + line_skip_limit_code);
primitive("lccode", def_code, lc_code_base);
primitive("uccode", def_code, uc_code_base);
primitive("sfcode", def_code, sf_code_base);
- primitive("delcode", def_code, (hash_size + 3474));
- primitive("textfont", def_family, (hash_size + 1835));
- primitive("scriptfont", def_family, (hash_size + 1851));
- primitive("scriptscriptfont", def_family, (hash_size + 1867));
+ primitive("delcode", def_code, del_code_base);
+ primitive("textfont", def_family, math_font_base);
+ primitive("scriptfont", def_family, math_font_base + script_size);
+ primitive("scriptscriptfont", def_family, math_font_base + script_script_size);
primitive("hyphenation", hyph_data, 0);
primitive("patterns", hyph_data, 1);
primitive("hyphenchar", assign_font_int, 0);
primitive("closein", in_stream, 0);
primitive("message", message, 0);
primitive("errmessage", message, 1);
- primitive("lowercase", case_shift, (hash_size + 2139));
- primitive("uppercase", case_shift, (hash_size + 2395));
+ primitive("lowercase", case_shift, lc_code_base);
+ primitive("uppercase", case_shift, uc_code_base);
primitive("show", xray, 0);
primitive("showbox", xray, 1);
primitive("showthe", xray, 2);
void check_fixed_align (int flag)
{
+ (void) flag;
+
if (test_align ((int) &mem_top, 4, "FIXED ALIGNMENT"))
{
puts("PLEASE RECOMPILE ME!\n");
void check_alloc_align (int flag)
{
+ (void) flag;
+
if (test_align ((int) eqtb, sizeof(eqtb[0]), "ALLOCATED ALIGNMENT"))
puts("PLEASE RECOMPILE ME!\n");
# Release version
# CFLAGS=/c /Ge /Gy /Gf /Ox /W4 /DMSDOS /DTeX /DPHARLAP /DNDEBUG /Ilib /YX
CFLAGS=/nologo /c /MT /GF /Gy /Ox /W4 /DMSDOS /DTeX /DPHARLAP /DNDEBUG \
- /I"kpathsea" /I"libharu/include" /I"libharu/win32/include" /I"zlib" \
- /I"libmd5"
+ /I"kpathsea" /I"zlib" /I"libmd5"
# Debugging version
# CFLAGS=/c /Ge /Gy /Gf /Od /Zi /W4 /DMSDOS /DTeX /DPHARLAP /Ilib /YX
objs = yandytex.obj itex.obj openinou.obj subroute.obj local.obj \
tex0.obj tex1.obj tex2.obj tex3.obj tex4.obj \
tex5.obj tex6.obj tex7.obj tex8.obj tex9.obj \
- yandy_pool.obj yandytex.res md5.obj yandy_backend_pdf.obj
+ yandy_pool.obj yandytex.res md5.obj
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
yandytex.exe: $(objs)
$(LINK) $(LFLAGS) yandytex itex openinou subroute local \
tex0 tex1 tex2 tex3 tex4 tex5 tex6 tex7 tex8 tex9 \
- yandy_pool yandytex.res md5 yandy_backend_pdf \
- kpathsea\kpathsea.lib libharu\libhpdf.lib libpng\libpng.lib zlib\zlib.lib
+ yandy_pool yandytex.res md5 \
+ kpathsea\kpathsea.lib libpng\libpng.lib zlib\zlib.lib \
+ dvipdfmx\libdvipdfmx.lib
del ..\yandy\bin\yandytex.exe
copy yandytex.exe ..\yandy\bin\yandytex.exe
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
-yandy_backend_pdf.obj: yandy_backend_pdf.c
- $(CC) $(CFLAGS) yandy_backend_pdf.c
-
md5.obj: libmd5\md5.c
$(CC) -Ilibmd5 $(CFLAGS) libmd5\md5.c
yandytex.res: yandytex.rc
- rc yandytex.rc
+ rc /nologo yandytex.rc
yandytex.obj: yandytex.c \
texd.h texmf.h texmfmem.h coerce.h yandy_macros.h
texd.h texmf.h texmfmem.h coerce.h yandy_macros.h
$(CC) /DINITEX $(CFLAGS) local.c
-# NOTE: cannot compile tex5.c and tex6.c with full optimizations ...
-
tex0.obj: tex0.c \
texd.h texmf.h texmfmem.h coerce.h yandy_macros.h
switch (cmd)
{
case left_brace:
- print_string("begin-group character ");
- print(chr_code);
+ chr_cmd("begin-group character ");
break;
case right_brace:
- print_string("end-group character ");
- print(chr_code);
+ chr_cmd("end-group character ");
break;
case math_shift:
- print_string("math shift character ");
- print(chr_code);
+ chr_cmd("math shift character ");
break;
case mac_param:
- print_string("macro parameter character ");
- print(chr_code);
+ chr_cmd("macro parameter character ");
break;
case sup_mark:
- print_string("superscript character ");
- print(chr_code);
+ chr_cmd("superscript character ");
break;
case sub_mark:
- print_string("subscript character ");
- print(chr_code);
+ chr_cmd("subscript character ");
break;
case endv:
- print_string("end of alignment template");
+ chr_cmd("end of alignment template");
break;
case spacer:
- print_string("blank space ");
- print(chr_code);
+ chr_cmd("blank space ");
break;
case letter:
- print_string("the letter ");
- print(chr_code);
+ chr_cmd("the letter ");
break;
case other_char:
- print_string("the character ");
- print(chr_code);
+ chr_cmd("the character ");
break;
case assign_glue:
case assign_mu_glue:
if (chr_code < skip_base)
- {
print_skip_param(chr_code - glue_base);
+ else if (chr_code < mu_skip_base)
+ {
+ print_esc("skip");
+ print_int(chr_code - skip_base);
}
else
{
- if (chr_code < mu_skip_base)
- {
- print_esc("skip");
- print_int(chr_code - skip_base);
- }
- else
- {
- print_esc("muskip");
- print_int(chr_code - mu_skip_base);
- }
+ print_esc("muskip");
+ print_int(chr_code - mu_skip_base);
}
break;
case assign_int:
if (chr_code < count_base)
- {
print_param(chr_code - int_base);
- }
else
{
print_esc("count");
case assign_dimen:
if (chr_code < scaled_base)
- {
print_length_param(chr_code - dimen_base);
- }
else
{
print_esc("dimen");
{
if (n < active_base)
print_char('?');
- else
- if (n < glue_base)
+ else if (n < glue_base)
+ {
+ sprint_cs(n);
+ print_char('=');
+ print_cmd_chr(eq_type(n), equiv(n));
+
+ if (eq_type(n) >= call)
+ {
+ print_char(':');
+ show_token_list(link(equiv(n)), 0, 32);
+ }
+ }
+ else if (n < local_base)
+ if (n < skip_base)
{
- sprint_cs(n);
+ print_skip_param(n - glue_base);
print_char('=');
- print_cmd_chr(eq_type(n), equiv(n));
-
- if (eq_type(n) >= call)
- {
- print_char(':');
- show_token_list(link(equiv(n)), 0, 32);
- }
+
+ if (n < glue_base + thin_mu_skip_code)
+ print_spec(equiv(n), "pt");
+ else
+ print_spec(equiv(n), "mu");
+ }
+ else if (n < mu_skip_base)
+ {
+ print_esc("skip");
+ print_int(n - skip_base);
+ print_char('=');
+ print_spec(equiv(n), "pt");
}
else
- if (n < local_base)
- if (n < skip_base)
- {
- print_skip_param(n - glue_base);
- print_char('=');
-
- if (n < glue_base + thin_mu_skip_code)
- print_spec(equiv(n), "pt");
- else
- print_spec(equiv(n), "mu");
- }
- else
- if (n < mu_skip_base)
- {
- print_esc("skip");
- print_int(n - skip_base);
- print_char('=');
- print_spec(equiv(n), "pt");
- }
- else
- {
- print_esc("muskip");
- print_int(n - mu_skip_base);
- print_char('=');
- print_spec(equiv(n), "mu");
- }
+ {
+ print_esc("muskip");
+ print_int(n - mu_skip_base);
+ print_char('=');
+ print_spec(equiv(n), "mu");
+ }
+ else if (n < int_base)
+ if (n == par_shape_loc)
+ {
+ print_esc("parshape");
+ print_char('=');
+
+ if (par_shape_ptr == 0)
+ print_char('0');
else
- if (n < int_base)
- if (n == par_shape_loc)
- {
- print_esc("parshape");
- print_char('=');
-
- if (par_shape_ptr == 0)
- print_char('0');
- else
- print_int(info(par_shape_ptr));
- }
- else
- if (n < toks_base)
- {
- print_cmd_chr(assign_toks, n);
- print_char('=');
-
- if (equiv(n) != 0)
- show_token_list(link(equiv(n)), 0, 32);
- }
- else
- if (n < box_base)
- {
- print_esc("toks");
- print_int(n - toks_base);
- print_char('=');
-
- if (equiv(n) != 0)
- show_token_list(link(equiv(n)), 0, 32);
- }
- else
- if (n < cur_font_loc)
- {
- print_esc("box");
- print_int(n - box_base);
- print_char('=');
-
- if (equiv(n) == 0)
- print_string("void");
- else
- {
- depth_threshold = 0;
- breadth_max = 1;
- show_node_list(equiv(n));
- }
- }
- else
- if (n < cat_code_base)
- {
- if (n == cur_font_loc)
- print_string("current font");
- else
- if (n < math_font_base + 16)
- {
- print_esc("textfont");
- print_int(n - math_font_base);
- }
- else
- if (n < math_font_base + 32)
- {
- print_esc("scriptfont");
- print_int(n - math_font_base - 16);
- }
- else
- {
- print_esc("scriptscriptfont");
- print_int(n - math_font_base - 32);
- }
-
- print_char('=');
- print_esc("");
- print(hash[font_id_base + equiv(n)].rh);
- }
- else
- if (n < math_code_base)
- {
- if (n < lc_code_base)
- {
- print_esc("catcode");
- print_int(n - cat_code_base);
- }
- else
- if (n < uc_code_base)
- {
- print_esc("lccode");
- print_int(n - lc_code_base);
- }
- else
- if (n < sf_code_base)
- {
- print_esc("uccode");
- print_int(n - uc_code_base);
- }
- else
- {
- print_esc("sfcode");
- print_int(n - sf_code_base);
- }
-
- print_char('=');
- print_int(equiv(n));
- }
- else
- {
- print_esc("mathcode");
- print_int(n - math_code_base);
- print_char('=');
- print_int(equiv(n));
- }
- else
- if (n < dimen_base)
+ print_int(info(par_shape_ptr));
+ }
+ else if (n < toks_base)
{
- if (n < count_base)
- print_param(n - int_base);
+ print_cmd_chr(assign_toks, n);
+ print_char('=');
+
+ if (equiv(n) != 0)
+ show_token_list(link(equiv(n)), 0, 32);
+ }
+ else if (n < box_base)
+ {
+ print_esc("toks");
+ print_int(n - toks_base);
+ print_char('=');
+
+ if (equiv(n) != 0)
+ show_token_list(link(equiv(n)), 0, 32);
+ }
+ else if (n < cur_font_loc)
+ {
+ print_esc("box");
+ print_int(n - box_base);
+ print_char('=');
+
+ if (equiv(n) == 0)
+ print_string("void");
else
- if (n < del_code_base)
- {
- print_esc("count");
- print_int(n - count_base);
- }
- else
- {
- print_esc("delcode");
- print_int(n - del_code_base);
- }
-
+ {
+ depth_threshold = 0;
+ breadth_max = 1;
+ show_node_list(equiv(n));
+ }
+ }
+ else if (n < cat_code_base)
+ {
+ if (n == cur_font_loc)
+ print_string("current font");
+ else if (n < math_font_base + 16)
+ {
+ print_esc("textfont");
+ print_int(n - math_font_base);
+ }
+ else if (n < math_font_base + 32)
+ {
+ print_esc("scriptfont");
+ print_int(n - math_font_base - 16);
+ }
+ else
+ {
+ print_esc("scriptscriptfont");
+ print_int(n - math_font_base - 32);
+ }
+
print_char('=');
- print_int(eqtb[n].cint);
+ print_esc("");
+ print(hash[font_id_base + equiv(n)].rh);
}
- else
- if (n <= eqtb_size)
+ else if (n < math_code_base)
+ {
+ if (n < lc_code_base)
{
- if (n < scaled_base)
- print_length_param(n - dimen_base);
- else
- {
- print_esc("dimen");
- print_int(n - scaled_base);
- }
-
- print_char('=');
- print_scaled(eqtb[n].cint);
- print_string("pt");
+ print_esc("catcode");
+ print_int(n - cat_code_base);
+ }
+ else if (n < uc_code_base)
+ {
+ print_esc("lccode");
+ print_int(n - lc_code_base);
+ }
+ else if (n < sf_code_base)
+ {
+ print_esc("uccode");
+ print_int(n - uc_code_base);
}
else
- print_char('?');
+ {
+ print_esc("sfcode");
+ print_int(n - sf_code_base);
+ }
+
+ print_char('=');
+ print_int(equiv(n));
+ }
+ else
+ {
+ print_esc("mathcode");
+ print_int(n - math_code_base);
+ print_char('=');
+ print_int(equiv(n));
+ }
+ else if (n < dimen_base)
+ {
+ if (n < count_base)
+ print_param(n - int_base);
+ else if (n < del_code_base)
+ {
+ print_esc("count");
+ print_int(n - count_base);
+ }
+ else
+ {
+ print_esc("delcode");
+ print_int(n - del_code_base);
+ }
+
+ print_char('=');
+ print_int(eqtb[n].cint);
+ }
+ else if (n <= eqtb_size)
+ {
+ if (n < scaled_base)
+ print_length_param(n - dimen_base);
+ else
+ {
+ print_esc("dimen");
+ print_int(n - scaled_base);
+ }
+
+ print_char('=');
+ print_scaled(eqtb[n].cint);
+ print_string("pt");
+ }
+ else
+ print_char('?');
}
#endif /* STAT */
/* sec 0259 */
break;
default:
- print_cmd_chr(assign_toks, t + (hash_size + 1307));
+ print_cmd_chr(assign_toks, t - output_text + output_routine_loc);
break;
}
else
loc = p;
}
-//#pragma optimize("", on) /* 98/Dec/10 experiment */
/* sec 0324 */
void end_token_list (void)
{
dvi_out(f - 1);
}
#else
- /* normal TeX 82 case */
else
{
dvi_out(fnt1);
}
#endif
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
#ifdef INCREASEFONTS
- /* fnt2 followed by f / 256, f % 256 */
else
{
dvi_out(fnt2);
dvi_out(((f - 1) & 255)); /* bottom byte */
}
#endif
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+
dvi_f = f;
}
{
switch (shipout_flag)
{
- case out_pdf_flag:
- pdf_ship_out(p);
- break;
case out_dvi_flag:
case out_xdv_flag:
dvi_ship_out_(p);
switch (shipout_flag)
{
- case out_pdf_flag:
- {
- if (total_pages == 0)
- {
- print_nl("No pages of output.");
- }
- else
- {
- HPDF_SaveToFile(yandy_pdf, pdf_file_name);
-
- print_nl("Output written on ");
-
- if (full_file_name_flag && pdf_file_name != NULL)
- print_char_string((unsigned char *) pdf_file_name);
- else
- slow_print(output_file_name);
-
- print_string(" (");
- print_int(total_pages);
- print_string(" page");
-
- if (total_pages != 1)
- print_char('s');
-
- print_string(").");
- }
-
- HPDF_Free(yandy_pdf);
- font_name_hash_free(gentbl);
- }
- break;
case out_dvi_flag:
case out_xdv_flag:
{
#define dvi_buf_size 16384
#endif
-#define hash_size 32768 // 9500 25000
#define hash_extra (255 - font_max)
-#define hash_prime 27197
+#define hash_prime 27197 // (prime ~ 85% * (hash_size + hash_extra))
+#define hash_size 32768 // 97280 9500 25000
#if (hash_extra != 255 - font_max)
#error ERROR: hash_extra not equal to (255 - font_max)
typedef char four_choices;
/* sec 0113 */
#include "texmfmem.h"
+#include "yandy_macros.h"
/* sec 0150 */
typedef char glue_ord;
/* sec 0212 */
void add_variable_space(int);
-void get_date_and_time (integer *minutes, integer *day,
- integer *month, integer *year);
-
char *unixify (char *);
-#include "yandy_macros.h"
#include "coerce.h"
/* sec 79 */
#define help5(...) tex_help(5, __VA_ARGS__)
#define help6(...) tex_help(6, __VA_ARGS__)
-/********BINDING WITH LIBHARU*********/
-typedef struct _mapping_table mapping_table;
-typedef struct _mapping_entry mapping_entry;
-EXTERN HPDF_Doc yandy_pdf;
-EXTERN HPDF_Page yandy_page;
-EXTERN HPDF_Font yandy_font[1024];
-EXTERN boolean pdf_doing_string;
-EXTERN boolean pdf_doing_text;
-EXTERN integer scaled_out;
EXTERN boolean shipout_flag;
-EXTERN mapping_table * gentbl;
-EXTERN mapping_table * font_name_hash_init (void);
-EXTERN void font_name_hash_free (mapping_table * tbl);
-EXTERN void pdf_ship_out(pointer p);
-EXTERN void pdf_vlist_out (void);
-EXTERN void pdf_hlist_out (void);
-EXTERN void pdf_begin_text(void);
-EXTERN void pdf_font_def(internal_font_number f);
-EXTERN void pdf_error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data);
-/********BINDING WITH LIBHARU*********/
#endif
\ No newline at end of file
#define INLINE inline
-#define dump_file fmt_file
-#define out_file dvi_file
-
/* Read a line of input as quickly as possible. */
extern boolean input_line (FILE *);
#define input_ln(stream, flag) input_line(stream)
#define gz_w_close gzclose
/* sec 0241 */
-#define fix_date_and_time() get_date_and_time (&(tex_time), &(day), &(month), &(year))
+extern void fix_date_and_time(void);
/* If we're running under Unix, use system calls instead of standard I/O
to read and write the output files; also, be able to make a core dump. */
!= (size_t) ((size_t)(b) - (size_t)(a) + 1)) \
FATAL_PERROR ("\n! dvi file")
+
+#ifdef COMPACTFORMAT
+extern int do_dump (char *, int, int, gzFile);
+extern int do_undump (char *, int, int, gzFile);
+#define dump_file gz_fmt_file
+#else
extern int do_dump (char *, int, int, FILE *);
extern int do_undump (char *, int, int, FILE *);
+#define dump_file fmt_file
+#endif
-/* Reading and writing the dump files. `(un)dumpthings' is called from
- the change file.*/
#define dumpthings(base, len) \
do_dump ((char *) &(base), sizeof (base), (int) (len), dump_file)
do_undump ((char *) &(base), sizeof (base), (int) (len), dump_file)
/* Use the above for all the other dumping and undumping. */
-#define generic_dump(x) dumpthings (x, 1)
-#define generic_undump(x) undumpthings (x, 1)
+#define generic_dump(x) dumpthings(x, 1)
+#define generic_undump(x) undumpthings(x, 1)
#define dump_wd generic_dump
#define undump_wd generic_undump
+++ /dev/null
-/* Copyright 2014 Clerk Ma
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA. */
-
-#define EXTERN extern
-
-#include "texd.h"
-
-boolean pdf_doing_string;
-boolean pdf_doing_text;
-static integer ten_pow[10] =
-{
- 1,
- 10,
- 100,
- 1000,
- 10000,
- 100000,
- 1000000,
- 10000000,
- 100000000,
- 1000000000
-};
-integer scaled_out;
-integer pdf_font_sum = 0;
-HPDF_Doc yandy_pdf;
-HPDF_Page yandy_page;
-HPDF_Font yandy_font[1024];
-
-mapping_table * gentbl;
-
-#define mapping_size 31627
-
-struct _mapping_table
-{
- mapping_entry * entries[mapping_size];
-};
-
-struct _mapping_entry
-{
- mapping_entry * next;
- char * key;
- int val;
-};
-
-unsigned int font_name_hash(const char * s)
-{
- const char * p;
- unsigned int h = 0, g;
-
- for (p = s; *p != '\0'; p++)
- {
- h = (h << 4) + *p;
-
- if ((g = h & 0xf0000000))
- {
- h = h ^ (g >> 24);
- h = h ^ g;
- }
- }
-
- return h;
-}
-
-mapping_table * font_name_hash_init (void)
-{
- mapping_table * temp_table;
- int i;
-
- temp_table = (mapping_table *) malloc(sizeof(mapping_table));
-
- for (i = 0; i < mapping_size; i++)
- temp_table->entries[i] = NULL;
-
- return temp_table;
-}
-
-void font_name_hash_free (mapping_table * tbl)
-{
- int i;
- mapping_entry *e, *next;
-
- for (i = 0; i < mapping_size; i++)
- for (e = tbl->entries[i]; e; e = next)
- {
- next = e->next;
- free(e->key);
- free(e);
- }
-
- free(tbl);
-}
-
-void font_name_hash_insert (mapping_table * tbl, const char *key, int val)
-{
- int i;
- mapping_entry * e;
-
- i = font_name_hash(key) % mapping_size;
- e = (mapping_entry *) malloc(sizeof(mapping_entry));
- e->next = tbl->entries[i];
- e->key = (char *) strdup(key);
- e->val = val;
- tbl->entries[i] = e;
-}
-
-int font_name_hash_lookup (mapping_table * tbl, const char *key)
-{
- int i;
- mapping_entry *e;
-
- i = font_name_hash(key) % mapping_size;
-
- for (e = tbl->entries[i]; e; e = e-> next)
- if (!strcmp(key, e->key))
- return e->val;
-
- return -1;
-}
-
-// report error.
-void pdf_error(const char * t, const char * p)
-{
- normalize_selector();
- print_err("Y&Y TeX error");
-
- if (t != NULL)
- {
- print('(');
- print_string(t);
- print(')');
- }
-
- print_string(": ");
- print_string(p);
- succumb();
-}
-// char to string.
-char * pdf_char_to_string(unsigned char i)
-{
- char str[2];
- str[0] = i;
- str[1] = '\0';
- return str;
-}
-// output one char: normal.
-void pdf_out(unsigned char i)
-{
- HPDF_PageAttr attr = (HPDF_PageAttr) yandy_page->attr;
- HPDF_Stream_WriteChar(attr->stream, i);
-}
-// octal number: 032, 009 etc.
-void pdf_print_octal(integer s)
-{
- char buf[HPDF_INT_LEN + 1];
- HPDF_PageAttr attr = (HPDF_PageAttr) yandy_page->attr;
- sprintf(buf, "%03o", s);
- HPDF_Stream_Write(attr->stream, (HPDF_BYTE *)buf, strlen(buf));
-}
-// output one char: normal or octal.
-void pdf_print_char(unsigned char s)
-{
- // 32 = '', 92 = '\', 40 = '(', 41 = ')'
- if ((s <= 32) || (s == 92) || (s == 40) || (s == 41) || (s > 127))
- {
- pdf_out(92);
- pdf_print_octal(s);
- }
- else
- {
- pdf_out(s);
- }
-}
-// equivlent: pdf_print in pdfTeX.
-void pdf_print_string(char * s)
-{
- HPDF_PageAttr attr = (HPDF_PageAttr) yandy_page->attr;
- HPDF_Stream_WriteStr(attr->stream, s);
-}
-// print one integer value: signed or unsigned.
-void pdf_print_int(int s)
-{
- char buf[HPDF_INT_LEN + 1];
- HPDF_PageAttr attr = (HPDF_PageAttr) yandy_page->attr;
- char* p = HPDF_IToA(buf, s, buf + HPDF_INT_LEN);
- HPDF_Stream_Write(attr->stream, (HPDF_BYTE *)buf, (HPDF_UINT)(p - buf));
-}
-// translate sp to bp.
-HPDF_REAL pdf_sp_to_bp(scaled s)
-{
- // 1 bp = 65781.76 sp
- return (HPDF_REAL) s / 65781.76;
-}
-// divides scaled s by scaled m.
-scaled divide_scaled(scaled s, scaled m, integer dd)
-{
- scaled q, r;
- integer sign, i;
-
- sign = 1;
-
- if (s < 0)
- {
- sign = -sign;
- s = -s;
- }
-
- if (m < 0)
- {
- sign = -sign;
- m = -m;
- }
-
- if (m == 0)
- pdf_error("arithmetic", "divided by zero");
- else if (m >= 0x7FFFFFFF / 10)
- pdf_error("arithmetic", "number too big");
-
- q = s / m;
- r = s % m;
-
- for (i = 1; i <= dd; i++)
- {
- q = 10 * q + (10 * r) / m;
- r = (10 * r) % m;
- }
-
- if (2 * r >= m)
- {
- incr(q);
- r = r - m;
- }
-
- scaled_out = sign * (s - (r / ten_pow[dd]));
- return sign * q;
-}
-scaled round_xn_over_d(scaled x, integer n, integer d)
-{
- boolean positive;
- nonnegative_integer t, u, v;
-
- if (x >= 0)
- positive = true;
- else
- {
- x = - (integer) x;
- positive = false;
- }
-
- t = (x % 32767L) * n;
- u = (x / 32768L) * n + (t / 32768L);
- v = (u % d) * 32768L + (t % 32768L);
-
- if (u / d >= 32768L)
- arith_error = true;
- else
- u = 32768L * (u / d) + (v / d);
-
- v = v % d;
-
- if (2 * v >= d)
- incr(u);
-
- if (positive)
- return u;
- else
- return -u;
-}
-// advance char width
-void adv_char_width(internal_font_number f, eight_bits c)
-{
- scaled w, s_out;
- integer s;
-
- w = char_width(f, char_info(f, c));
- divide_scaled(w, font_size[f], 4);
- pdf_delta_h = pdf_delta_h + scaled_out;
-}
-// print real value
-void pdf_print(integer m, integer d)
-{
- if (m < 0)
- {
- pdf_out('-');
- m = -m;
- }
-
- pdf_print_int(m / ten_pow[d]);
- m = m % ten_pow[d];
-
- if (m > 0)
- {
- pdf_out('.');
- decr(d);
-
- while (m < ten_pow[d])
- {
- pdf_out('0');
- decr(d);
- }
-
- while (m % 10 == 0)
- m = m / 10;
-
- pdf_print_int(m);
- }
-}
-// end the current string
-void pdf_end_string(void)
-{
- if (pdf_doing_string)
- {
- pdf_print_string(")] TJ\012");
- pdf_doing_string = false;
- }
-}
-// begin to draw a string
-void pdf_begin_string(internal_font_number f)
-{
- scaled s_out, v, v_out;
- integer s;
-
- if (!pdf_doing_text)
-// pdf_begin_text();
-
- if (f != dvi_f)
- {
- pdf_end_string();
- pdf_font_def(f);
- }
-
- s = divide_scaled(cur_h - pdf_delta_h, font_size[f], 3);
- s_out = scaled_out;
-
- if (abs(s) < 0100000)
- {
- s_out = divide_scaled(round_xn_over_d(cur_h - pdf_delta_h, 1000, 1000),
- font_size[f], 3);
-
- if (s < 0)
- s_out = -s_out;
- }
-
-// if (cur_v - pdf_v >= )
-}
-// end a text section.
-void pdf_end_text()
-{
- if (pdf_doing_text)
- {
- pdf_end_string();
- HPDF_Page_EndText(yandy_page);
- pdf_doing_text = false;
- }
-}
-// draw a rule.
-void pdf_set_rule(scaled x, scaled y, scaled w, scaled h)
-{
- if (h <= 65782)
- {
- HPDF_Page_SetLineWidth(yandy_page, h / 65535);
- HPDF_Page_MoveTo (yandy_page, (x / 65535 + 72), (841.89 - y / 65535 - 72));
- HPDF_Page_LineTo (yandy_page, (x / 65535 + 72 + w / 65535), (841.89 - y / 65535 - 72));
- HPDF_Page_Stroke (yandy_page);
- }
- else if (w <= 65782)
- {
- HPDF_Page_SetLineWidth(yandy_page, w / 65535);
- HPDF_Page_MoveTo (yandy_page, (x / 65535 + 72), (841.89 - y / 65535 - 72));
- HPDF_Page_LineTo (yandy_page, (x / 65535 + 72), (841.89 - y / 65535 - 72 + h / 65535));
- HPDF_Page_Stroke (yandy_page);
- }
-}
-void pdf_error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data)
-{
- printf ("Y&Y TeX error: error_no=%04X, detail_no=%u\n",
- (HPDF_UINT)error_no,
- (HPDF_UINT)detail_no);
- longjmp(jumpbuffer, 1);
-}
-
-void pdf_font_def (internal_font_number f)
-{
- int k;
- const char * fnt_name;
- char * afm_name;
- char * pfb_name;
- char * fnt_buffer = (char *) malloc(length(font_name[f]) + 1);
-
- memcpy(fnt_buffer, (const char *) str_pool + str_start[font_name[f]], length(font_name[f]));
- fnt_buffer[length(font_name[f])] = '\0';
-
- k = font_name_hash_lookup(gentbl, fnt_buffer);
-
- if (k == -1)
- {
- afm_name = kpse_find_file(fnt_buffer, kpse_afm_format, 1);
- pfb_name = kpse_find_file(fnt_buffer, kpse_type1_format, 1);
-
- if (afm_name != NULL && pfb_name != NULL)
- {
- font_name_hash_insert(gentbl, fnt_buffer, pdf_font_sum + 1);
- pdf_font_sum += 1;
- fnt_name = HPDF_LoadType1FontFromFile (yandy_pdf, afm_name, pfb_name);
- yandy_font[pdf_font_sum] = HPDF_GetFont(yandy_pdf, fnt_name, NULL);
- HPDF_Page_SetFontAndSize(yandy_page, yandy_font[pdf_font_sum], (font_size[f] / 65535));
- }
- else
- {
- HPDF_Page_SetFontAndSize(yandy_page, yandy_font[0], (font_size[f] / 65535));
- }
- }
- else
- {
- HPDF_Page_SetFontAndSize(yandy_page, yandy_font[k], (font_size[f] / 65535));
- }
-
- free(fnt_buffer);
-}
-
-void pdf_ship_out(pointer p)
-{
- char j, k;
-
- if (tracing_output > 0)
- {
- print_nl("");
- print_ln();
- print_string("Completed box being shipped out");
- }
-
- if (term_offset > max_print_line - 9)
- print_ln();
- else if ((term_offset > 0) || (file_offset > 0))
- print_char(' ');
-
- print_char('[');
- j = 9;
-
- while ((count(j) == 0) && (j > 0))
- decr(j);
-
- for (k = 0; k <= j; k++)
- {
- print_int(count(k));
-
- if (k < j)
- print_char('.');
- }
-
-#ifndef _WINDOWS
- fflush(stdout);
-#endif
-
- if (tracing_output > 0)
- {
- print_char(']');
- begin_diagnostic();
- show_box(p);
- end_diagnostic(true);
- }
-
- if ((height(p) > max_dimen) || (depth(p) > max_dimen) ||
- (height(p) + depth(p) + v_offset > max_dimen) ||
- (width(p) + h_offset > max_dimen))
- {
- print_err("Huge page cannot be shipped out");
- help2("The page just created is more than 18 feet tall or",
- "more than 18 feet wide, so I suspect something went wrong.");
- error();
-
- if (tracing_output <= 0)
- {
- begin_diagnostic();
- print_nl("The following box has been deleted:");
- show_box(p);
- end_diagnostic(true);
- }
-
- goto lab30;
- }
-
- 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;
-
- dvi_h = 0;
- dvi_v = 0;
- cur_h = h_offset;
- dvi_f = null_font;
-
- if (output_file_name == 0)
- {
- if (job_name == 0)
- open_log_file();
-
- pack_job_name(".pdf");
-
- while (!b_open_out(pdf_file))
- {
- prompt_file_name("file name for output", ".pdf");
- }
-
- output_file_name = b_make_name_string(pdf_file);
- }
-
- if (total_pages == 0)
- {
- gentbl = font_name_hash_init();
- yandy_pdf = HPDF_New (pdf_error_handler, NULL);
- HPDF_SetCompressionMode (yandy_pdf, HPDF_COMP_ALL);
- yandy_pdf -> pdf_version = HPDF_VER_17;
- HPDF_SetInfoAttr(yandy_pdf, HPDF_INFO_PRODUCER, "Y&Y TeX");
- yandy_font[0] = HPDF_GetFont (yandy_pdf, "Times-Roman", NULL);
- }
-
- yandy_page = HPDF_AddPage (yandy_pdf);
- HPDF_Page_SetSize (yandy_page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT);
-
- cur_v = height(p) + v_offset;
- temp_ptr = p;
-
- if (type(p) == vlist_node)
- pdf_vlist_out();
- else
- pdf_hlist_out();
-
- incr(total_pages);
- cur_s = -1;
-lab30:;
- if (tracing_output <= 0)
- print_char(']');
-
- dead_cycles = 0;
-
-#ifndef _WINDOWS
- fflush(stdout);
-#endif
-
- flush_node_list(p);
-}
-
-
-void pdf_hlist_out (void)
-{
- scaled base_line;
- scaled left_edge;
- scaled save_h, save_v;
- halfword this_box;
- int g_order;
- int g_sign;
- halfword p;
- halfword leader_box;
- scaled leader_wd;
- scaled lx;
- boolean outer_doing_leaders;
- scaled edge;
- real glue_temp;
- real cur_glue;
- scaled cur_g;
-
- cur_g = 0;
- cur_glue = 0.0;
- this_box = temp_ptr;
- g_order = glue_order(this_box);
- g_sign = glue_sign(this_box);
- p = list_ptr(this_box);
- incr(cur_s);
-
- base_line = cur_v;
- left_edge = cur_h;
-
- while (p != 0)
-lab21:
- if (is_char_node(p))
- {
- do
- {
- f = font(p);
- c = character(p);
-
- if (f != dvi_f)
- {
- if (!font_used[f])
- {
- font_used[f] = true;
- }
-
- dvi_f = f;
- }
-
- HPDF_Page_BeginText(yandy_page);
- pdf_font_def(f);
- HPDF_Page_MoveTextPos(yandy_page, pdf_sp_to_bp(cur_h) + 72, (841.89 - (pdf_sp_to_bp(cur_v) + 72)));
- HPDF_Page_ShowText(yandy_page, pdf_char_to_string(c));
- HPDF_Page_EndText(yandy_page);
- cur_h = cur_h + char_width(f, char_info(f, c));
- p = link(p);
- }
- while (((p >= hi_mem_min)));
-
- dvi_h = cur_h;
- }
- else
- {
- switch (type(p))
- {
- case hlist_node:
- case vlist_node:
- if (list_ptr(p) == 0)
- cur_h = cur_h + width(p);
- else
- {
- save_h = dvi_h;
- save_v = dvi_v;
- cur_v = base_line + shift_amount(p);
- temp_ptr = p;
- edge = cur_h;
-
- if (type(p) == vlist_node)
- pdf_vlist_out();
- else
- pdf_hlist_out();
-
- dvi_h = save_h;
- dvi_v = save_v;
- cur_h = edge + width(p);
- cur_v = base_line;
- }
- break;
-
- case rule_node:
- {
- rule_ht = height(p);
- rule_dp = depth(p);
- rule_wd = width(p);
- goto lab14;
- }
- break;
-
- case whatsit_node:
- //out_what(p);
- break;
-
- case glue_node:
- {
- g = glue_ptr(p);
- rule_wd = width(g) - cur_g;
-
- if (g_sign != normal)
- {
- if (g_sign == stretching)
- {
- if (stretch_order(g) == g_order)
- {
- cur_glue = cur_glue + stretch(g);
- glue_temp = glue_set(this_box) * cur_glue;
-
- if (glue_temp > 1000000000.0)
- glue_temp = 1000000000.0;
- else if (glue_temp < -1000000000.0)
- glue_temp = -1000000000.0;
-
- cur_g = round(glue_temp);
- }
- }
- else if (shrink_order(g) == g_order)
- {
- cur_glue = cur_glue - shrink(g);
- glue_temp = glue_set(this_box) * cur_glue;
-
- if (glue_temp > 1000000000.0)
- glue_temp = 1000000000.0;
- else if (glue_temp < -1000000000.0)
- glue_temp = -1000000000.0;
-
- cur_g = round(glue_temp);
- }
- }
-
- rule_wd = rule_wd + cur_g;
-
- if (subtype(p) >= a_leaders)
- {
- leader_box = leader_ptr(p);
-
- if (type(leader_box) == rule_node)
- {
- rule_ht = height(leader_box);
- rule_dp = depth(leader_box);
- goto lab14;
- }
-
- leader_wd = width(leader_box);
-
- if ((leader_wd > 0) && (rule_wd > 0))
- {
- rule_wd = rule_wd + 10;
- edge = cur_h + rule_wd;
- lx = 0;
-
- if (subtype(p) == a_leaders)
- {
- save_h = cur_h;
- cur_h = left_edge + leader_wd * ((cur_h - left_edge) / leader_wd);
-
- if (cur_h < save_h)
- cur_h = cur_h + leader_wd;
- }
- else
- {
- lq = rule_wd / leader_wd;
- lr = rule_wd % leader_wd;
-
- if (subtype(p) == c_leaders)
- cur_h = cur_h + (lr / 2);
- else
- {
- lx =(2 * lr + lq + 1) / (2 * lq + 2);
- cur_h = cur_h + ((lr - (lq - 1)* lx) / 2);
- }
- }
-
- while (cur_h + leader_wd <= edge)
- {
- cur_v = base_line + shift_amount(leader_box);
- //synch_v();
- dvi_v = cur_v;
- save_v = dvi_v;
- //synch_h();
- dvi_h = cur_h;
- save_h = dvi_h;
- temp_ptr = leader_box;
- outer_doing_leaders = doing_leaders;
- doing_leaders = true;
-
- if (type(leader_box) == vlist_node)
- pdf_vlist_out();
- else
- pdf_hlist_out();
-
- doing_leaders = outer_doing_leaders;
- dvi_v = save_v;
- dvi_h = save_h;
- cur_v = base_line;
- cur_h = save_h + leader_wd + lx;
- }
-
- cur_h = edge - 10;
- goto lab15;
- }
- }
-
- goto lab13;
- }
- break;
-
- case kern_node:
- case math_node:
- cur_h = cur_h + width(p);
- break;
-
- case ligature_node:
- {
- mem[lig_trick] = mem[lig_char(p)];
- link(lig_trick) = link(p);
- p = lig_trick;
- goto lab21;
- }
- break;
-
- default:
- break;
- }
-
- goto lab15;
-lab14:
- if ((rule_ht == -1073741824L)) /* - 2^30 */
- rule_ht = height(this_box);
-
- if ((rule_dp == -1073741824L)) /* - 2^30 */
- rule_dp = depth(this_box);
-
- rule_ht = rule_ht + rule_dp;
-
- if ((rule_ht > 0) && (rule_wd > 0))
- {
- cur_v = base_line + rule_dp;
- pdf_set_rule(cur_h, cur_v, rule_wd, rule_ht);
- cur_v = base_line;
- dvi_h = dvi_h + rule_wd;
- }
-lab13:
- cur_h = cur_h + rule_wd;
-lab15:
- p = link(p);
- }
-
- decr(cur_s);
-}
-/* following needs access to dvi_buf=zdvibuf see coerce.h */
-/* sec 0629 */
-void pdf_vlist_out (void)
-{
- scaled left_edge;
- scaled top_edge;
- scaled save_h, save_v;
- halfword this_box;
-/* glue_ord g_order; */
- int g_order; /* 95/Jan/7 */
-/* char g_sign; */
- int g_sign; /* 95/Jan/7 */
- halfword p;
- //integer save_loc;
- halfword leader_box;
- scaled leader_ht;
- scaled lx;
- boolean outer_doing_leaders;
- scaled edge;
- real glue_temp;
- real cur_glue;
- scaled cur_g;
-
- cur_g = 0;
- cur_glue = 0.0;
- this_box = temp_ptr;
- g_order = glue_order(this_box);
- g_sign = glue_sign(this_box);
- p = list_ptr(this_box);
- incr(cur_s);
-
- left_edge = cur_h;
- cur_v = cur_v - height(this_box);
- top_edge = cur_v;
-
- while (p != 0)
- {
- if ((p >= hi_mem_min))
- {
- confusion("vlistout");
- return; // abort_flag set
- }
- else
- {
- switch (type(p))
- {
- case hlist_node:
- case vlist_node:
- if (list_ptr(p) == 0)
- cur_v = cur_v + height(p) + depth(p);
- else
- {
- cur_v = cur_v + height(p);
- //synch_v();
- dvi_v = cur_v;
- save_h = dvi_h;
- save_v = dvi_v;
- cur_h = left_edge + shift_amount(p);
- temp_ptr = p;
-
- if (type(p) == vlist_node)
- pdf_vlist_out();
- else
- pdf_hlist_out();
-
- dvi_h = save_h;
- dvi_v = save_v;
- cur_v = save_v + depth(p);
- cur_h = left_edge;
- }
- break;
-
- case rule_node:
- {
- rule_ht = height(p);
- rule_dp = depth(p);
- rule_wd = width(p);
- goto lab14;
- }
- break;
-
- case whatsit_node:
- //out_what(p);
- break;
-
- case glue_node:
- {
- g = glue_ptr(p);
- rule_ht = width(g) - cur_g;
-
- if (g_sign != normal)
- {
- if (g_sign == stretching)
- {
- if (stretch_order(g) == g_order)
- {
- cur_glue = cur_glue + stretch(g);
- glue_temp = glue_set(this_box) * cur_glue;
-
- if (glue_temp > 1000000000.0)
- glue_temp = 1000000000.0;
- else if (glue_temp < -1000000000.0)
- glue_temp = -1000000000.0;
-
- cur_g = round(glue_temp);
- }
- }
- else if (shrink_order(g) == g_order) /* BUG FIX !!! */
- {
- cur_glue = cur_glue - shrink(g);
- glue_temp = glue_set(this_box) * cur_glue;
-
- if (glue_temp > 1000000000.0)
- glue_temp = 1000000000.0;
- else if (glue_temp < -1000000000.0)
- glue_temp = -1000000000.0;
-
- cur_g = round(glue_temp);
- }
- }
-
- rule_ht = rule_ht + cur_g;
-
- if (subtype(p) >= a_leaders)
- {
- leader_box = leader_ptr(p);
-
- if (type(leader_box) == rule_node)
- {
- rule_wd = width(leader_box);
- rule_dp = 0;
- goto lab14;
- }
-
- leader_ht = height(leader_box) + depth(leader_box);
-
- if ((leader_ht > 0) && (rule_ht > 0))
- {
- rule_ht = rule_ht + 10;
- edge = cur_v + rule_ht;
- lx = 0;
-
- if (subtype(p) == a_leaders)
- {
- save_v = cur_v;
- cur_v = top_edge + leader_ht * ((cur_v - top_edge) / leader_ht);
-
- if (cur_v < save_v)
- cur_v = cur_v + leader_ht;
- }
- else
- {
- lq = rule_ht / leader_ht;
- lr = rule_ht % leader_ht;
-
- if (subtype(p) == c_leaders)
- cur_v = cur_v + (lr / 2);
- else
- {
- lx = (2 * lr + lq + 1) / (2 * lq + 2);
- cur_v = cur_v + ((lr - (lq - 1) * lx) / 2);
- }
- }
-
- while (cur_v + leader_ht <= edge)
- {
- cur_h = left_edge + shift_amount(leader_box);
- //synch_h();
- dvi_h = cur_h;
- save_h = dvi_h;
- cur_v = cur_v + height(leader_box);
- //synch_v();
- dvi_v = cur_v;
- save_v = dvi_v;
- temp_ptr = leader_box;
- outer_doing_leaders = doing_leaders;
- doing_leaders = true;
-
- if (type(leader_box) == vlist_node)
- pdf_vlist_out();
- else
- pdf_hlist_out();
-
- doing_leaders = outer_doing_leaders;
- dvi_v = save_v;
- dvi_h = save_h;
- cur_h = left_edge;
- cur_v = save_v - height(leader_box) + leader_ht + lx;
- }
-
- cur_v = edge - 10;
- goto lab15;
- }
- }
-
- goto lab13;
- }
- break;
-
- case kern_node:
- cur_v = cur_v + width(p);
- break;
-
- default:
- break;
- }
- goto lab15;
-lab14:
- if ((rule_wd == -1073741824L)) /* -2^30 */
- rule_wd = width(this_box);
-
- rule_ht = rule_ht + rule_dp;
- cur_v = cur_v + rule_ht;
-
- if ((rule_ht > 0) && (rule_wd > 0))
- {
- pdf_set_rule(cur_h, cur_v, rule_wd, rule_ht);
- }
-
- goto lab15;
-lab13:
- cur_v = cur_v + rule_ht;
- }
-lab15:
- p = link(p);
- }
-
- decr(cur_s);
-}
#define frozen_dont_expand (frozen_control_sequence + 9) // (hash_size + hash_extra + 523)
#define frozen_null_font (frozen_control_sequence + 10) // (hash_size + hash_extra + 524)
#define font_id_base (frozen_null_font - font_base) // (hash_size + hash_extra + 524)
-#define undefined_control_sequence (frozen_null_font + 1025) // (hash_size + hash_extra + 781) = font_max + 2
- // (hash_size + (255 - 1023) + 1025 + 524)
- // (hash_size + 781)
+#define undefined_control_sequence (frozen_null_font + font_max + 2) // (hash_size + 781)
#define glue_base (undefined_control_sequence + 1) // (hash_size + 782)
/* sec 0224 */
#define line_skip_code 0 // 782
#define other_token 06000 // 3072 = 2^8 * other_char
#define match_token 06400 // 3328 = 2^8 * match
#define end_match_token 07000 // 3584 = 2^8 * end_match
+/* sec 0298 */
+#define chr_cmd(s) \
+do \
+{ \
+ print_string(s); \
+ print(chr_code); \
+} \
+while (0)
/* sec 0302 */
#define state cur_input.state_field
#define index cur_input.index_field
#include "texd.h"
-#define dump_default_var TEX_format_default
-#define dump_default " plain.fmt"
#define dump_ext_length 4
-#define dump_default_length format_default_length
#define edit_value tex_edit_value
extern char * replacement[];
{
int flag = 0, ret = 0;
-#ifdef WIN32
- _setmaxstdio(2048);
-#endif
-
gargc = ac;
gargv = av;
if (main_init(gargc, gargv))
return -1; // failure
- dump_default_var = dump_default;
- dump_default_length = strlen(dump_default_var + 1);
+ TEX_format_default = " plain.fmt";
+ format_default_length = strlen(TEX_format_default + 1);
jump_used = 0;
flag = main_program();
if (trace_flag)
- {
- sprintf(log_line, "EXITING at %s: flag = %d, ret = %d, jump_used = %d\n", "main", flag, ret, jump_used);
- show_line(log_line, 0);
- }
+ printf("EXITING at %s: flag = %d, ret = %d, jump_used = %d\n", "main", flag, ret, jump_used);
}
else
{
if (trace_flag)
- {
- sprintf(log_line, "EXITING at %s: flag = %d, ret = %d, jump_used = %d\n", "jump_out", flag, ret, jump_used);
- show_line(log_line, 0);
- }
+ printf("EXITING at %s: flag = %d, ret = %d, jump_used = %d\n", "jump_out", flag, ret, jump_used);
}
if (endit(flag) != 0)
}
}
-/* All our interrupt handler has to do is set TeX's or Metafont's global
- variable `interrupt'; then they will do everything needed. */
-
-static void catch_interrupt (int err)
+static void catch_interrupt(int err)
{
- (void) signal (SIGINT, SIG_IGN);
+ (void) signal(SIGINT, SIG_IGN);
if (interrupt++ >= 3)
exit(1);
- (void) signal (SIGINT, catch_interrupt);
+ (void) signal(SIGINT, catch_interrupt);
}
-/* Besides getting the date and time here, we also set up the interrupt
- handler, for no particularly good reason. It's just that since the
- `fix_date_and_time' routine is called early on (section 1337 in TeX,
- ``Get the first line of input and prepare to start''), this is as
- good a place as any. */
-
-void get_date_and_time (integer *sys_minutes,
- integer *sys_day,
- integer *sys_month,
- integer *sys_year)
+void fix_date_and_time (void)
{
time_t clock;
struct tm *tmptr;
- (void) time (&clock); /* - seconds since 1970 */
+ (void) time(&clock);
if (trace_flag)
- {
- sprintf(log_line, "The time is %u\n", clock);
- show_line(log_line, 0);
- }
+ printf("The time is %u\n", clock);
if (clock < 0)
puts("Time not available!\n");
if (tmptr == NULL)
{
- sprintf(log_line, "Cannot convert time (%0ld)!\n", clock);
- show_line(log_line, 1);
- *sys_year = 2038;
- *sys_month = 1;
- *sys_day = 18;
- *sys_minutes = 22 * 60 + 14;
+ printf("Cannot convert time (%0ld)!\n", clock);
+ year = 2038;
+ month = 1;
+ day = 18;
+ tex_time = 22 * 60 + 14;
}
else
{
- *sys_minutes = tmptr->tm_hour * 60 + tmptr->tm_min;
- *sys_day = tmptr->tm_mday;
- *sys_month = tmptr->tm_mon + 1;
- *sys_year = tmptr->tm_year + 1900;
+ tex_time = tmptr->tm_hour * 60 + tmptr->tm_min;
+ day = tmptr->tm_mday;
+ month = tmptr->tm_mon + 1;
+ year = tmptr->tm_year + 1900;
if (trace_flag)
- {
- sprintf(log_line, "%d-%d-%d %d:%d\n",
+ printf("%d-%d-%d %d:%d\n",
tmptr->tm_year + 1900,
tmptr->tm_mon + 1,
tmptr->tm_mday,
tmptr->tm_hour,
tmptr->tm_min);
- show_line(log_line, 0);
- }
}
{
sprintf(log_line, "! Unable to read an entire line---buf_size=%d.\n", buf_size);
#endif
- if (output == stderr)
- show_line(log_line, 1);
- else if (output == stdout)
- show_line(log_line, 0);
- else
- fputs(log_line, output); // never
-
+ fputs(log_line, output);
puts(" (File may have a line termination problem.)");
}
// putc(' ', output); /* putc('\n', output); */
*s++ = ' ';
*s++ = '\0';
- if (output == stderr)
- show_line(log_line, 1);
- else
- if (output == stdout)
- show_line(log_line, 0);
- else
- fputs(log_line, output); // log_file
+
+ fputs(log_line, output); // log_file
}
// split off for convenience and use in ConsoleInput
/* if (i == EOF && buffer[last] != '\n') buffer[last++] = '\n'; */
buffer[last] = ' '; /* space terminate */
+
if (last >= max_buf_stack)
max_buf_stack = last; /* remember longest line */
if (i == ' ' || i == '\t')
--last;
-/* else if (trimeof && i == 26) --last; */ /* 93/Nov/24 */
else
break;
}
-/* if (trimeof != 0 && i == EOF && last == first)
- return false; */ /* EOF and line empty */
-// #else
-// while (last > first
-// && isblank (buffer[last - 1]) && buffer[last - 1] != '\r')
-// --last;
-// #endif
/* following added to check source file integrity ASCII 32 - 127 */
/* allow space, tab, new-page - also allow return, newline ? */
}
#endif /* not WORDS_BIGENDIAN and not NO_FMTBASE_SWAP */
-/* Hmm, this could benefit from some on the fly compression - bkph */
-/* and complementary decompression on input - bkph */
-
-/* Here we write NITEMS items, each item being ITEM_SIZE bytes long.
- The pointer to the stuff to write is P, and we write to the file
- OUT_FILE. */
-
-int do_dump (char *p, int item_size, int nitems, FILE *out_file)
+#ifdef COMPACTFORMAT
+int do_dump(char *p, int item_size, int nitems, gzFile out_file)
+#else
+int do_dump(char *p, int item_size, int nitems, FILE *out_file)
+#endif
{
#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)
swap_items (p, nitems, item_size);
#endif
#ifdef COMPACTFORMAT
- if (gzwrite(gz_fmt_file, p, (item_size * nitems)) != (item_size * nitems))
+ if (gzwrite(out_file, p, (item_size * nitems)) != (item_size * nitems))
#else
- if ((int) fwrite (p, item_size, nitems, out_file) != nitems)
+ if ((int) fwrite(p, item_size, nitems, out_file) != nitems)
#endif
{
show_line("\n", 0);
return 0;
}
-/* Hmm, this could benefit from some on the fly decompression - bkph */
-
-/* Here is the dual of the writing routine. */
-int do_undump (char *p, int item_size, int nitems, FILE *in_file)
+#ifdef COMPACTFORMAT
+int do_undump(char *p, int item_size, int nitems, gzFile in_file)
+#else
+int do_undump(char *p, int item_size, int nitems, FILE *in_file)
+#endif
{
#ifdef COMPACTFORMAT
- if (gzread(gz_fmt_file, (void *) p, (unsigned int) (item_size * nitems)) <= 0)
+ if (gzread(in_file, (void *) p, (unsigned int) (item_size * nitems)) <= 0)
#else
if ((int) fread((void *) p, item_size, nitems, in_file) != nitems)
#endif
#endif
#include "zlib.h"
#include "md5.h"
-#include "hpdf.h"
-#include "hpdf_utils.h"
typedef long long integer;
typedef double glue_ratio;