-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+#ifndef _YANDYTEX_TEXD_H
+#define _YANDYTEX_TEXD_H
+
#define ALLOCATEINI /* allocate iniTeX (550 k) trie_c, trie_o, trie_l, trie_r, trie_hash, trie_taken */
#define ALLOCATEMAIN /* allocate main memory for TeX (2 Meg) zmem = zzzaa */
#define ALLOCATEFONT /* allocate font_info (800 k) (dynamically now) */
#define ALLOCATEPARAMSTACK /* experiment to dynamically deal with param_stack 99/Jan/21 */
#define ALLOCATEBUFFER /* experiment to dynamically deal with input buffer 99/Jan/22 */
#define INCREASEFIXED
-/* increase number of fonts - quarterword 16 bit - max_quarterword limit */
-/* there may still be some bugs with this however ... also may slow down */
-/* also: should split use of quarterword for (i) font from (ii) char */
-/* for example, xeq_level ? hyphenation trie_trc ? */
#define INCREASEFONTS
-/* make font_info array fmemoryword == 32 bit instead of memory_word = 64 bit */
-#define SHORTFONTINFO
-/* make hash table htwo_halves == 32 bit instead of two_halves == 64 bit */
-/* increase trie_op_size from 751 to 3001 96/Oct/12 */
#define INCREASETRIEOP
#define COMPACTFORMAT
#define STAT
#include "texmf.h"
+#define file_name_size PATH_MAX
+
// #define max_halfword 65535L /* for 32 bit memory word */
-// #define max_halfword 262143L /* for 36 bit memory word */
-#define min_halfword -2147483647L /* for 64 bit memory word (signed) */
-#define max_halfword 2147483647L /* for 64 bit memory word (signed) */
+#define min_halfword -2147483647L /* LONG_MIN, for 64 bit memory word (signed) */
+#define max_halfword 2147483647L /* LONG_MAX, for 64 bit memory word (signed) */
#define block_size 1000 /* block_size for variable length node alloc */
-/* min_quarterword assumed 0 -- i.e. we use unsigned types for quarterword */
#define min_quarterword 0
#ifdef INCREASEFONTS
#define max_quarterword 65535L
#endif
#ifdef INCREASEFONTS
- #define font_max 1023
+ #define font_max 65535 //1023 (2^n - 1)
#else
#define font_max 255
#endif
#define max_trie_op 500
#endif
-#ifdef ALLOCATEDVIBUF
- #define default_dvi_buf_size 16384
- EXTERN int dvi_buf_size;
-#else
- #define dvi_buf_size 16384
-#endif
-/* #define hash_size 9500 */
-/* #define hash_size 25000 */
-#define hash_size 32768
-/* trick to try and get around eqtb_extra problem */
+#define dvi_buf_size 16384
+
#define hash_extra (255 - font_max)
-/* hash prime about 85% of hash_size (+ hash_extra) */
-#define hash_prime 27197
+#define hash_prime 27197 // (prime ~ 85% * (hash_size + hash_extra))
+#define hash_size 97280 // 32768 9500 25000
#if (hash_extra != 255 - font_max)
#error ERROR: hash_extra not equal to (255 - font_max)
/* typedef unsigned long halfword; NO NO: since mem_min may be < 0 */
/* sec 0113 */
typedef long halfword;
+typedef halfword pointer;
typedef char two_choices;
typedef char four_choices;
/* sec 0113 */
#include "texmfmem.h"
+#include "yandy_macros.h"
/* sec 0150 */
typedef char glue_ord;
/* sec 0212 */
/* sec 0920 */
typedef integer trie_op_code;
/* sec 0925 */
-typedef integer trie_pointer;
-/* typedef short hyph_pointer; */
+typedef integer trie_pointer;
typedef integer hyph_pointer;
EXTERN integer bad;
EXTERN ASCII_code xord[256];
EXTERN ASCII_code xchr[256];
-EXTERN unsigned char name_of_file[PATHMAX + 4];
+EXTERN unsigned char name_of_file[file_name_size + 4];
EXTERN integer name_length;
#ifdef ALLOCATESTRING
EXTERN integer trick_count;
EXTERN integer first_count;
EXTERN int interaction;
-EXTERN bool deletions_allowed;
-EXTERN bool set_box_allowed;
+EXTERN boolean deletions_allowed;
+EXTERN boolean set_box_allowed;
EXTERN int history;
EXTERN int error_count;
EXTERN char * help_line[6];
EXTERN int help_ptr;
-EXTERN bool use_err_help;
-EXTERN volatile integer interrupt; /* bkph - do avoid compiler optimization */
-EXTERN bool OK_to_interrupt;
-EXTERN bool arith_error;
+EXTERN boolean use_err_help;
+EXTERN volatile integer interrupt;
+EXTERN boolean OK_to_interrupt;
+EXTERN boolean arith_error;
EXTERN scaled tex_remainder;
EXTERN halfword temp_ptr;
+/* sec 0116 */
#ifdef ALLOCATEMAIN
- EXTERN memory_word * main_memory; /* remembered so can be free() later */
+ EXTERN memory_word * main_memory;
EXTERN memory_word * mem;
#else
- EXTERN memory_word
- /* #define zmem (zzzaa - (int)(mem_min)) */
- /* zzzaa[mem_max - mem_min + 1]; */
+ EXTERN memory_word zzzaa[mem_max - mem_bot + 1];
#define zmem (zzzaa - (int)(mem_bot))
- zzzaa[mem_max - mem_bot + 1];
#endif
-EXTERN halfword lo_mem_max;
-EXTERN halfword hi_mem_min;
+EXTERN pointer lo_mem_max;
+EXTERN pointer hi_mem_min;
EXTERN integer var_used, dyn_used;
-EXTERN halfword avail;
-EXTERN halfword mem_end;
-EXTERN halfword mem_start;
+/* sec 0118 */
+EXTERN pointer avail;
+EXTERN pointer mem_end;
+EXTERN halfword mem_start; // for yandytex
+/* sec 0124 */
EXTERN halfword rover;
-
+/* sec 0165 */
/* NOTE: the following really also need to be dynamically allocated */
#ifdef DEBUG
#ifdef ALLOCATEMAIN
#ifdef ALLOCATEMAIN
EXTERN char *zzzac;
#else
-/* EXTERN bool */ /* save (4 - 1) * mem_max - mem_min */
+/* EXTERN boolean */ /* save (4 - 1) * mem_max - mem_min */
EXTERN char
/* #define wasfree (zzzac - (int)(mem_min)) */
#define wasfree (zzzac - (int)(mem_bot))
#endif
EXTERN halfword was_mem_end, was_lo_max, was_hi_min;
-EXTERN bool panicking;
+EXTERN boolean panicking;
#endif /* DEBUG */
EXTERN integer font_in_short_display;
#define eqtb_extra 0
#endif
-/* Probably require eqtb_extra to be zero, so hash_extra = 255 - font_max */
#if (eqtb_extra != 0)
#error ERROR: eqtb_extra is not zero (need hash_extra equal 255 - font_max)
#endif
-#ifdef ALLOCATEZEQTB
- EXTERN memory_word * zeqtb;
+#ifdef INCREASEFONTS
+ EXTERN memory_word eqtb[eqtb_size + 1 + eqtb_extra];
#else
- #ifdef INCREASEFONTS
- EXTERN memory_word eqtb[(hash_size + 4007) + eqtb_extra];
- #else
- EXTERN memory_word zeqtb[(hash_size + 4007)];
- #endif
+ EXTERN memory_word eqtb[eqtb_size + 1];
#endif
#ifdef INCREASEFONTS
#define xeq_level (zzzad - (int_base))
#endif
-EXTERN quarterword zzzad[844];
-/* region 5 & 6 int_base to eqtb_size: 13507 - 12663 */
+EXTERN quarterword zzzad[eqtb_size - int_base + 1];
#ifdef ALLOCATEHASH
- #ifdef SHORTHASH
- EXTERN htwo_halves *zzzae;
- #else
- EXTERN two_halves *zzzae;
- #endif
-
- #define hash (zzzae - 514)
+ EXTERN two_halves *zzzae;
+ #define hash (zzzae - hash_base)
#else
- #ifdef SHORTHASH
- EXTERN htwo_halves
- #else
- EXTERN two_halves
- #endif
-
- #define hash (zzzae - 514)
-
#ifdef INCREASEFONTS
- zzzae[hash_size + 267 + eqtb_extra];
+ EXTERN two_halves zzzae[undefined_control_sequence - hash_base + eqtb_extra];
#else
- zzzae[hash_size + 267];
+ EXTERN two_halves zzzae[undefined_control_sequence - hash_base];
#endif
+
+ #define hash (zzzae - hash_base)
#endif
EXTERN halfword hash_used;
-EXTERN bool no_new_control_sequence;
+EXTERN boolean no_new_control_sequence;
EXTERN integer cs_count;
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
EXTERN integer base_ptr;
EXTERN halfword par_loc;
EXTERN halfword par_token;
-EXTERN bool force_eof;
+EXTERN boolean force_eof;
EXTERN halfword cur_mark[6];
EXTERN int long_state;
EXTERN halfword pstack[10];
EXTERN int cur_val_level;
EXTERN int radix;
EXTERN int cur_order;
-EXTERN alpha_file read_file[16]; /* hard wired limit in TeX */
+EXTERN alpha_file read_file[16];
EXTERN char read_open[20];
EXTERN halfword cond_ptr;
EXTERN int if_limit;
EXTERN pool_pointer ext_delimiter;
EXTERN integer format_default_length;
EXTERN char * TEX_format_default;
-EXTERN bool name_in_progress;
-EXTERN bool log_opened;
-EXTERN bool quoted_file_name;
+EXTERN boolean name_in_progress;
+EXTERN boolean log_opened;
+EXTERN boolean quoted_file_name;
EXTERN str_number job_name;
EXTERN str_number output_file_name;
EXTERN str_number texmf_log_name;
EXTERN eight_bits font_bc[font_max + 1];
EXTERN eight_bits font_ec[font_max + 1];
EXTERN halfword font_glue[font_max + 1];
-EXTERN bool font_used[font_max + 1];
+EXTERN boolean font_used[font_max + 1];
EXTERN integer hyphen_char[font_max + 1];
EXTERN integer skew_char[font_max + 1];
EXTERN font_index bchar_label[font_max + 1];
EXTERN short font_bchar[font_max + 1];
-/* don't change above to int or format file will be incompatible */
EXTERN short font_false_bchar[font_max + 1];
-/* don't change above to int or format file will be incompatible */
EXTERN integer char_base[font_max + 1];
EXTERN integer width_base[font_max + 1];
EXTERN integer height_base[font_max + 1];
EXTERN integer max_push;
EXTERN integer last_bop;
EXTERN integer dead_cycles;
-EXTERN bool doing_leaders;
+EXTERN boolean doing_leaders;
EXTERN int c, f;
EXTERN scaled rule_ht, rule_dp, rule_wd;
EXTERN halfword g;
EXTERN scaled cur_h, cur_v;
EXTERN internal_font_number dvi_f;
EXTERN internal_font_number pdf_f;
-EXTERN integer cur_s; /* sec 616 */
+EXTERN integer cur_s;
EXTERN scaled total_stretch[4], total_shrink[4];
EXTERN integer last_badness;
EXTERN halfword adjust_tail;
EXTERN int cur_style;
EXTERN int cur_size;
EXTERN scaled cur_mu;
-EXTERN bool mlist_penalties;
+EXTERN boolean mlist_penalties;
EXTERN internal_font_number cur_f;
EXTERN int cur_c;
EXTERN four_quarters cur_i;
EXTERN scaled cur_active_width[8];
EXTERN scaled background[8];
EXTERN scaled break_width[8];
-EXTERN bool no_shrink_error_yet;
+EXTERN boolean no_shrink_error_yet;
EXTERN halfword cur_p;
-EXTERN bool second_pass;
-EXTERN bool final_pass;
+EXTERN boolean second_pass;
+EXTERN boolean final_pass;
EXTERN integer threshold;
EXTERN integer minimal_demerits[4];
EXTERN integer minimum_demerits;
EXTERN halfword hyfbchar;
EXTERN char hyf[68];
EXTERN halfword init_list;
-EXTERN bool init_lig;
-EXTERN bool init_lft;
+EXTERN boolean init_lig;
+EXTERN boolean init_lft;
EXTERN int hyphen_passed;
EXTERN int cur_l, cur_r;
EXTERN halfword cur_q;
EXTERN halfword lig_stack;
-EXTERN bool ligature_present;
-EXTERN bool lft_hit, rt_hit;
+EXTERN boolean ligature_present;
+EXTERN boolean lft_hit, rt_hit;
#ifdef ALLOCATETRIES
EXTERN halfword * trie_trl;
EXTERN trie_op_code hyf_next[trie_op_size + 1];
EXTERN integer op_start[256];
-/* if ALLOCATEHYPHEN is true, then hyphen_prime is a variable */
-/* otherwise it is a pre-processor defined constant */
#ifdef ALLOCATEHYPHEN
#define default_hyphen_prime 1009
EXTERN str_number * hyph_word;
EXTERN trie_pointer *trie_l; /* left subtrie links */
EXTERN trie_pointer *trie_r; /* right subtrie links */
EXTERN trie_pointer *trie_hash; /* used to identify equivlent subtries */
- #else /* end ALLOCATEINI */
+ #else
EXTERN packed_ASCII_code trie_c[trie_size + 1];
EXTERN trie_op_code trie_o[trie_size + 1];
EXTERN trie_pointer trie_l[trie_size + 1];
EXTERN trie_pointer trie_r[trie_size + 1];
EXTERN trie_pointer trie_hash[trie_size + 1];
- #endif /* end not ALLOCATEINI */
+ #endif
+
EXTERN trie_pointer trie_ptr;
-#endif /* INITEX */
+#endif
#ifdef INITEX
#ifdef ALLOCATEINI
- EXTERN char *trie_taken;
+ EXTERN char * trie_taken;
#else
- EXTERN bool trie_taken[trie_size + 1];
+ EXTERN boolean trie_taken[trie_size + 1];
#endif
EXTERN trie_pointer trie_min[256];
EXTERN trie_pointer trie_max;
- EXTERN bool trie_not_ready;
-#endif /* INITEX */
+ EXTERN boolean trie_not_ready;
+#endif
EXTERN scaled best_height_plus_depth;
EXTERN halfword page_tail;
EXTERN int page_contents;
-/* do *some* sanity checking here --- rather than in TeX later 96/Jan/18 */
-/* (cannot catch everything here, since some is now dynamic) */
-
#if (half_error_line < 30) || (half_error_line > error_line - 15)
#error ERROR: (half_error_line < 30) || (half_error_line > error_line - 15) BAD 1
#endif
EXTERN integer last_penalty;
EXTERN scaled last_kern;
EXTERN integer insert_penalties;
-EXTERN bool output_active;
+EXTERN boolean output_active;
+/* sec 1032 */
EXTERN internal_font_number main_f;
-
EXTERN four_quarters main_i;
EXTERN four_quarters main_j;
-
EXTERN font_index main_k;
-EXTERN halfword main_p;
+EXTERN pointer main_p;
EXTERN integer main_s;
EXTERN halfword bchar;
EXTERN halfword false_bchar;
-EXTERN bool cancel_boundary;
-EXTERN bool ins_disc;
-EXTERN halfword cur_box;
+EXTERN boolean cancel_boundary;
+EXTERN boolean ins_disc;
+/* sec 1074 */
+EXTERN pointer cur_box;
EXTERN halfword after_token;
-EXTERN bool long_help_seen;
+EXTERN boolean long_help_seen;
EXTERN str_number format_ident;
EXTERN word_file fmt_file;
EXTERN gzFile gz_fmt_file;
EXTERN integer ready_already;
/* sec 1342 */
EXTERN alpha_file write_file[16];
-EXTERN bool write_open[18];
+EXTERN boolean write_open[18];
/* sec 1345 */
-EXTERN halfword write_loc;
+EXTERN pointer write_loc;
EXTERN pool_pointer edit_name_start;
EXTERN integer edit_name_length, edit_line;
EXTERN int tfm_temp;
-/* new stuff defined in local.c - bkph */
-EXTERN bool is_initex;
-EXTERN bool verbose_flag;
-EXTERN bool trace_flag;
-EXTERN bool debug_flag;
-EXTERN bool open_trace_flag;
-EXTERN bool knuth_flag;
-EXTERN bool no_interrupts;
-EXTERN bool c_style_flag;
-EXTERN bool non_ascii;
-EXTERN bool key_replace;
-EXTERN bool deslash;
-EXTERN bool trimeof;
-EXTERN bool allow_patterns;
-EXTERN bool show_fonts_used;
-EXTERN bool reset_exceptions;
-EXTERN bool show_current;
-EXTERN bool return_flag;
-EXTERN bool want_version;
-EXTERN bool civilize_flag;
-EXTERN bool show_numeric;
-EXTERN bool restrict_to_ascii;
-EXTERN bool show_missing;
-EXTERN bool full_file_name_flag;
-EXTERN bool save_strings_flag;
+/* new variables defined in local.c */
+EXTERN boolean is_initex;
+EXTERN boolean verbose_flag;
+EXTERN boolean trace_flag;
+EXTERN boolean debug_flag;
+EXTERN boolean open_trace_flag;
+EXTERN boolean knuth_flag;
+EXTERN boolean no_interrupts;
+EXTERN boolean c_style_flag;
+EXTERN boolean non_ascii;
+EXTERN boolean key_replace;
+EXTERN boolean deslash;
+EXTERN boolean trimeof;
+EXTERN boolean allow_patterns;
+EXTERN boolean show_fonts_used;
+EXTERN boolean reset_exceptions;
+EXTERN boolean show_current;
+EXTERN boolean return_flag;
+EXTERN boolean want_version;
+EXTERN boolean civilize_flag;
+EXTERN boolean show_numeric;
+EXTERN boolean restrict_to_ascii;
+EXTERN boolean show_missing;
+EXTERN boolean full_file_name_flag;
EXTERN int mem_initex;
EXTERN int mem_extra_high;
EXTERN int mem_extra_low;
EXTERN int show_in_dos;
EXTERN int show_fmt_flag;
EXTERN int show_tfm_flag;
-EXTERN bool show_texinput_flag;
-EXTERN bool truncate_long_lines;
-EXTERN bool show_cs_names;
+EXTERN boolean show_texinput_flag;
+EXTERN boolean truncate_long_lines;
+EXTERN boolean show_cs_names;
EXTERN int tab_step;
EXTERN int pseudo_tilde;
EXTERN int pseudo_space;
EXTERN char * source_direct;
EXTERN char * format_name;
EXTERN char * encoding_name;
-EXTERN bool format_specific;
-EXTERN bool encoding_specific;
-EXTERN bool show_line_break_stats;
+EXTERN boolean show_line_break_stats;
EXTERN int first_pass_count;
EXTERN int second_pass_count;
EXTERN int final_pass_count;
EXTERN FILE * errout;
EXTERN int font_dimen_zero;
EXTERN int ignore_frozen;
-EXTERN bool suppress_f_ligs;
-EXTERN int abort_flag;
-EXTERN int err_level;
+EXTERN boolean suppress_f_ligs;
EXTERN int jump_used;
EXTERN jmp_buf jumpbuffer;
extern int current_pool_size;
char *grabenv(char *);
void stamp_it (char *);
void stampcopy (char *);
-bool prime (int);
+boolean prime (int);
int endit (int);
void uexit (int unix_code);
void add_variable_space(int);
-void get_date_and_time (integer *minutes, integer *day,
- integer *month, integer *year);
-
char *unixify (char *);
-/****************************************************************************/
#include "coerce.h"
-#include "yandy_macros.h"
-/****************************************************************************/
+
/* sec 79 */
-extern void synch_h(void);
-extern void synch_v(void);
-extern void set_cur_lang(void);
-extern str_number make_string_pool (char *s);
-extern char * md5_file(FILE * in_file);
-extern INLINE void str_room_ (int val);
-#define str_room(a) str_room_((int) a)
-extern INLINE void tail_append_ (pointer val);
+extern inline void push_input(void);
+extern inline void pop_input(void);
+extern inline void print_err (const char * s);
+extern inline void ensure_dvi_open(void);
+extern inline void write_dvi(size_t a, size_t b);
+extern inline void prompt_input(const char *s);
+extern inline void synch_h(void);
+extern inline void synch_v(void);
+extern inline void set_cur_lang(void);
+extern char * md5_file (FILE * in_file);
+extern inline void str_room (int val);
+extern inline void tail_append_ (pointer val);
#define tail_append(a) tail_append_((pointer) a)
-extern INLINE void tex_help (unsigned int n, ...);
-extern INLINE void append_char(ASCII_code c);
-extern INLINE void append_lc_hex(ASCII_code c);
-extern INLINE void succumb(void);
-extern INLINE void dvi_out_ (ASCII_code op);
+extern inline void tex_help (unsigned int n, ...);
+extern inline void append_char(ASCII_code c);
+extern inline void append_lc_hex(ASCII_code c);
+extern inline void succumb(void);
+extern inline void dvi_out_ (ASCII_code op);
#define dvi_out(op) dvi_out_((ASCII_code) (op))
-extern INLINE void free_avail_(halfword p);
+extern inline void free_avail_(halfword p);
#define free_avail(p) free_avail_((halfword) (p))
-extern INLINE void flush_string (void);
-extern int load_pool_strings (integer spare_size);
+extern inline void flush_string (void);
+extern str_number load_pool_strings (integer spare_size);
+extern str_number make_string_pool (const char *s);
#define help0() tex_help(0)
#define help1(...) tex_help(1, __VA_ARGS__)
#define help2(...) tex_help(2, __VA_ARGS__)
#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 bool pdf_doing_string;
-EXTERN bool pdf_doing_text;
-EXTERN integer scaled_out;
-EXTERN bool pdf_output_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*********/
\ No newline at end of file
+EXTERN boolean shipout_flag;
+#endif
\ No newline at end of file