From f0f474e3fcb4a1ae70f3727c2c4010495ada4d63 Mon Sep 17 00:00:00 2001 From: maqiyuan Date: Sun, 15 Jun 2014 22:02:26 +0800 Subject: [PATCH] 65535 fonts support (adjusted hash array). --- src/texsourc/itex.c | 40 +++++++++++----------- src/texsourc/makefile | 16 ++------- src/texsourc/tex1.c | 27 ++------------- src/texsourc/tex2.c | 4 +-- src/texsourc/tex3.c | 4 ++- src/texsourc/tex6.c | 25 ++++++++------ src/texsourc/tex7.c | 6 ++-- src/texsourc/texd.h | 76 ++++++++++++------------------------------ src/texsourc/yandytex.h | 29 ++++++++-------- src/web2c/putexdir/putex400.ch | 12 +++---- 10 files changed, 89 insertions(+), 150 deletions(-) diff --git a/src/texsourc/itex.c b/src/texsourc/itex.c index e9287db..d42c0ad 100644 --- a/src/texsourc/itex.c +++ b/src/texsourc/itex.c @@ -338,11 +338,11 @@ void line_break_ (integer final_widow_penalty) background[2 + stretch_order(q)] = stretch(q); background[2 + stretch_order(r)] = background[2 + stretch_order(r)] + stretch(r); background[6] = shrink(q) + shrink(r); - minimum_demerits = 1073741823L; /* 2^30 - 1 *//* 40000000 hex - 1 */ - minimal_demerits[tight_fit] = 1073741823L; - minimal_demerits[decent_fit] = 1073741823L; - minimal_demerits[loose_fit] = 1073741823L; - minimal_demerits[very_loose_fit] = 1073741823L; + minimum_demerits = awful_bad; + minimal_demerits[tight_fit] = awful_bad; + minimal_demerits[decent_fit] = awful_bad; + minimal_demerits[loose_fit] = awful_bad; + minimal_demerits[very_loose_fit] = awful_bad; if (par_shape_ptr == 0) if (hang_indent == 0) @@ -817,7 +817,7 @@ lab35:; if (link(active) != active) { r = link(active); - fewest_demerits = 1073741823L; /* 2^30 - 1 */ + fewest_demerits = awful_bad; do { @@ -883,10 +883,10 @@ lab35:; { cur_p = link(q); - if (type(q) == 2) - free_node(q, 7); + if (type(q) == delta_node) + free_node(q, delta_node_size); else - free_node(q, 3); + free_node(q, active_node_size); q = cur_p; } @@ -896,11 +896,11 @@ lab35:; while (q != 0) { cur_p = link(q); - free_node(q, 2); + free_node(q, passive_node_size); q = cur_p; } - if (! second_pass) + if (!second_pass) { #ifdef STAT if (tracing_paragraphs > 0) @@ -943,10 +943,10 @@ lab30: { cur_p = link(q); - if (type(q) == 2) - free_node(q, 7); + if (type(q) == delta_node) + free_node(q, delta_node_size); else - free_node(q, 3); + free_node(q, active_node_size); q = cur_p; } @@ -956,7 +956,7 @@ lab30: while (q != 0) { cur_p = link(q); - free_node(q, 2); + free_node(q, passive_node_size); q = cur_p; } @@ -2022,10 +2022,10 @@ void final_cleanup (void) print_string(" was incomplete)"); if_line = mem[cond_ptr + 1].cint; - cur_if = mem[cond_ptr].hh.b1; + cur_if = subtype(cond_ptr); temp_ptr = cond_ptr; - cond_ptr = mem[cond_ptr].hh.rh; - free_node(temp_ptr, 2); + cond_ptr = link(cond_ptr); + free_node(temp_ptr, if_node_size); } if (history != spotless) @@ -2145,7 +2145,7 @@ int main_program (void) bad = 15; #ifdef INCREASEFONTS - if (font_max > 1024) + if (font_max > 65535) #else if (font_max > 256) #endif @@ -3253,7 +3253,7 @@ void init_trie (void) trie_trc[0] = 63; trie_not_ready = false; } -#endif /* INITEX */ +#endif #ifdef INITEX /* sec 1302 */ diff --git a/src/texsourc/makefile b/src/texsourc/makefile index 8e6f46c..6601596 100644 --- a/src/texsourc/makefile +++ b/src/texsourc/makefile @@ -9,26 +9,16 @@ CC = cl LINK = link RC = rc -CFLAGS=/nologo /c /MT /GF /Gy /Ox /W4 /DMSDOS /DTeX /DPHARLAP /DNDEBUG \ +CFLAGS=/nologo /c /MT /GF /Gy /Ox /W4 /DMSDOS /DTeX \ /I"kpathsea" /I"zlib" /I"libmd5" -# Link with MS LINK -# LFLAGS=@yandytex.nt /MAP lib\libdos.lib -# Release version -# LFLAGS=/MAP lib\libdos.lib LFLAGS=/NOLOGO /MAP -# /MACHINE:X86 -# debugging version -# LFLAGS=@yandytex.nt /MAP /DEBUG /PDB:yandytex.pdb lib\libdos.lib -# LFLAGS=/MAP /DEBUG /PDB:yandytex.pdb 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_inlines.obj -# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### - yandytex.exe: $(objs) $(LINK) $(LFLAGS) yandytex itex openinou subroute local \ tex0 tex1 tex2 tex3 tex4 tex5 tex6 tex7 tex8 tex9 \ @@ -37,7 +27,7 @@ yandytex.exe: $(objs) dvipdfmx\libdvipdfmx.lib del ..\yandy\bin\yandytex.exe copy yandytex.exe ..\yandy\bin\yandytex.exe -# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### + md5.obj: libmd5\md5.c $(CC) -Ilibmd5 $(CFLAGS) libmd5\md5.c @@ -46,7 +36,7 @@ yandytex.res: yandytex.rc yandytex.obj: yandytex.c \ texd.h texmf.h texmfmem.h coerce.h yandy_macros.h - $(CC) /DINITEX /DINI $(CFLAGS) yandytex.c + $(CC) /DINITEX $(CFLAGS) yandytex.c itex.obj: itex.c \ texd.h texmf.h texmfmem.h coerce.h yandy_macros.h diff --git a/src/texsourc/tex1.c b/src/texsourc/tex1.c index 5f973b0..eb618ba 100644 --- a/src/texsourc/tex1.c +++ b/src/texsourc/tex1.c @@ -2269,14 +2269,6 @@ halfword id_lookup_(integer j, integer l) } while (!(text(hash_used) == 0)); -#ifdef SHORTHASH - if (hash_used > 65535L) /* debugging only 1996/Jan/20 */ - { - sprintf(log_line, "ERROR: %s too large %d\n", "hash entry", hash_used); - show_line(log_line, 1); - } -#endif - next(p) = hash_used; p = hash_used; } @@ -2293,21 +2285,7 @@ halfword id_lookup_(integer j, integer l) for (k = j; k <= j + l - 1; k++) append_char(buffer[k]); -#ifdef SHORTHASH - { - pool_pointer tempstring = make_string(); - - if (tempstring > 65535L) /* cannot happen */ - { - sprintf(log_line, "ERROR: %s too large %d\n", "string ptr", tempstring); - show_line(log_line, 1); - } - text(p) = tempstring; - } -#else text(p) = make_string(); -#endif - pool_ptr = pool_ptr + d; #ifdef STAT @@ -2316,10 +2294,9 @@ halfword id_lookup_(integer j, integer l) if (trace_flag) { str_pool[pool_ptr] = '\0'; - sprintf(log_line, " tex1 cs_count++ '%s' ", &str_pool[pool_ptr - l - d]); - show_line(log_line, 0); /* debugging */ + printf(" tex1.c cs_count++ '%s' ", &str_pool[pool_ptr - l - d]); } -#endif /* STAT */ +#endif } goto lab40; diff --git a/src/texsourc/tex2.c b/src/texsourc/tex2.c index 56498c0..da3c071 100644 --- a/src/texsourc/tex2.c +++ b/src/texsourc/tex2.c @@ -380,12 +380,12 @@ void show_context (void) for (q = p; q <= first_count - 1; q++) print_char(trick_buf[q % error_line]); - + print_ln(); for (q = 1; q <= n; q++) print_char(' '); - + if (m + n <= error_line) p = first_count + m; else diff --git a/src/texsourc/tex3.c b/src/texsourc/tex3.c index 4cacbbd..a299c10 100644 --- a/src/texsourc/tex3.c +++ b/src/texsourc/tex3.c @@ -360,9 +360,11 @@ lab31: if (cur_cmd != spacer) back_input(); } + lab40: cur_val = mult_and_add(savecurval, v, xn_over_d(v, f, 65536L), 1073741823L); /* 2^30 - 1 */ goto lab89; + lab45: if (mu) { @@ -455,7 +457,7 @@ lab89: help2("I can't work with sizes bigger than about 19 feet.", "Continue and I'll use the largest value I can."); error(); - cur_val = 1073741823L; /* 2^30 - 1 */ + cur_val = max_dimen; arith_error = false; } diff --git a/src/texsourc/tex6.c b/src/texsourc/tex6.c index 50bd0f3..1c41f83 100644 --- a/src/texsourc/tex6.c +++ b/src/texsourc/tex6.c @@ -333,7 +333,7 @@ lab30:; minimal_demerits[fit_class] = awful_bad; } - minimum_demerits = 1073741823L; /* 2^30 - 1 */ + minimum_demerits = awful_bad; if (r != active) { @@ -835,7 +835,7 @@ small_number reconstitute_(small_number j, small_number n, halfword bchar, halfw if (ligature_present) lft_hit = init_lft; - while (p != 0) /* 94/Mar/22 BUG FIX */ + while (p != 0) { append_charnode_to_t(character(p)); p = link(p); @@ -983,30 +983,33 @@ lab22: cur_l = rem_byte(q); ligature_present = true; - if (lig_stack != 0) /* BUG FIX */ + if (lig_stack != 0) { - if (mem[lig_stack + 1].hh.rh != 0) /* l.17828 ? */ + if (lig_ptr(lig_stack) != 0) { - mem[t].hh.rh = mem[lig_stack + 1].hh.rh; - t = mem[t].hh.rh; + link(t) = lig_ptr(lig_stack); + t = link(t); incr(j); } + p = lig_stack; - lig_stack = mem[p].hh.rh; - free_node(p, 2); - if (lig_stack == 0) /* if lig_stack=null ? */ + lig_stack = link(p); + free_node(p, small_node_size); + + if (lig_stack == 0) { if (j < n) cur_r = hu[j + 1]; else cur_r = bchar; + if (odd(hyf[j])) cur_rh = hchar; else cur_rh = 256; } else - cur_r = mem[lig_stack].hh.b1; + cur_r = character(lig_stack); } else if (j == n) goto lab30; @@ -1179,6 +1182,7 @@ lab45: z = trie_trl[z] + hc[l]; } } + lab40: for (j = 0; j <= lhyf - 1; j++) hyf[j] = 0; @@ -1191,6 +1195,7 @@ lab40: goto lab41; return; + lab41:; q = link(hb); link(hb) = 0; diff --git a/src/texsourc/tex7.c b/src/texsourc/tex7.c index 28f8244..8a06862 100644 --- a/src/texsourc/tex7.c +++ b/src/texsourc/tex7.c @@ -233,7 +233,7 @@ lab22: end_diagnostic(false); } -#endif /* STAT */ +#endif if (count(n) != 1000) best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * count(n); @@ -268,11 +268,11 @@ lab22: else b = badness(page_goal - page_total, page_so_far[2]); else if (page_total - page_goal > page_shrink) - b = awful_bad; /* 2^30 - 1 */ + b = awful_bad; else b = badness(page_total - page_goal, page_shrink); - if (b < awful_bad) /* 2^30 - 1 */ + if (b < awful_bad) if (pi <= eject_penalty) c = pi; else if (b < inf_bad) diff --git a/src/texsourc/texd.h b/src/texsourc/texd.h index 53acc2e..6e7229e 100644 --- a/src/texsourc/texd.h +++ b/src/texsourc/texd.h @@ -1,6 +1,6 @@ #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) */ @@ -14,12 +14,7 @@ #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 -#define SHORTFONTINFO #define INCREASETRIEOP #define COMPACTFORMAT @@ -29,8 +24,8 @@ #define file_name_size PATH_MAX // #define max_halfword 65535L /* for 32 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 */ @@ -91,7 +86,7 @@ EXTERN integer max_buf_stack; #endif #ifdef INCREASEFONTS - #define font_max 1023 + #define font_max 65535 //1023 (2^n - 1) #else #define font_max 255 #endif @@ -136,16 +131,12 @@ EXTERN integer max_buf_stack; #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 dvi_buf_size 16384 #define hash_extra (255 - font_max) #define hash_prime 27197 // (prime ~ 85% * (hash_size + hash_extra)) -#define hash_size 32768 // 97280 9500 25000 +#define hash_size 97280 // 32768 9500 25000 #if (hash_extra != 255 - font_max) #error ERROR: hash_extra not equal to (255 - font_max) @@ -249,14 +240,11 @@ 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 pointer lo_mem_max; @@ -309,19 +297,14 @@ EXTERN int old_setting; #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 @@ -330,31 +313,19 @@ EXTERN int old_setting; #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; @@ -448,7 +419,7 @@ EXTERN int cur_val; 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; @@ -535,7 +506,7 @@ EXTERN scaled pdf_delta_h, pdf_delta_v; 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; @@ -621,8 +592,6 @@ EXTERN small_number hyf_num[trie_op_size + 1]; 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; @@ -681,9 +650,6 @@ 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 diff --git a/src/texsourc/yandytex.h b/src/texsourc/yandytex.h index 7757a94..29f141e 100644 --- a/src/texsourc/yandytex.h +++ b/src/texsourc/yandytex.h @@ -20,17 +20,20 @@ #define WORDS_BIGENDIAN 0 -//#pragma warning(disable:4032) -#pragma warning(disable:4201) -#pragma warning(disable:4996) -#pragma warning(disable:4701) -//#pragma warning(disable:4100) -//#pragma warning(disable:4244) -#pragma warning(disable:4131) // old style declarator -#pragma warning(disable:4135) // conversion between different integral types -#pragma warning(disable:4127) // conditional expression is constant - -/* ``Standard'' headers. */ +#ifdef _WIN32 + #pragma warning(disable:4201) // nameless struct/union + #pragma warning(disable:4996) // a function that was marked with deprecated + #pragma warning(disable:4701) // potentially uninitialized local variable 'name' used + #pragma warning(disable:4131) // old style declarator + #pragma warning(disable:4135) // conversion between different integral types + #pragma warning(disable:4127) // conditional expression is constant +#endif + +#include +#include +#include +#include + #include #include #include @@ -46,10 +49,6 @@ #include #include #include -#include -#include -#include -#include #ifdef _WIN32 #include #else diff --git a/src/web2c/putexdir/putex400.ch b/src/web2c/putexdir/putex400.ch index e542fd4..bed194c 100644 --- a/src/web2c/putexdir/putex400.ch +++ b/src/web2c/putexdir/putex400.ch @@ -4,7 +4,7 @@ %%% Modified and patched version for TeX Live %%% %%% Copyright (C) 1997-2004 Chey-Woei Tsay -%%% Copyright (C) 2013 Clerk Ma +%%% Copyright (C) 2013-2014 Clerk Ma %%% %%% This is the change file of PUTeX. %%% @@ -25,8 +25,8 @@ %%% %%% %%% Version 4.0 -%%% add \PUXcatcode command to set catcodes of dbcs characters. -%%% remove print_dbchar (58, 59, 70, 318, print_chinese_int) +%%% add \PUXcatcode command to set catcodes of dbcs characters. +%%% remove print_dbchar (58, 59, 70, 318, print_chinese_int) %%% %%% Version 4.0-web2c %%% removed the MikTeX part. @@ -43,9 +43,9 @@ %%% see section 224 for cspace skip and cespace skip %%% %%% New Indices: -%%% @^Input Encoding Dependencies@> -%%% @^Modified for handling DBCS characters@> -%%% @^CJK Fonts Extension@> +%%% @^Input Encoding Dependencies@> +%%% @^Modified for handling DBCS characters@> +%%% @^CJK Fonts Extension@> @x \def\gglob{20, 26} % this should be the next two sections of "" -- 2.11.0