From 2256310fae2a2c24e5d062a51b4de574b148c738 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Wed, 24 Mar 2010 18:00:22 +0000 Subject: bibtex8/bibtexu: reallocate arrays when needed, same as in bibtex git-svn-id: svn://tug.org/texlive/trunk@17548 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/bibtexu/ChangeLog | 8 ++ Build/source/texk/bibtexu/bibtex-1.c | 20 ++++- Build/source/texk/bibtexu/bibtex-2.c | 9 +- Build/source/texk/bibtexu/bibtex-3.c | 52 ++++++----- Build/source/texk/bibtexu/bibtex-4.c | 14 +-- Build/source/texk/bibtexu/bibtex.c | 2 +- Build/source/texk/bibtexu/bibtex.h | 34 +++----- Build/source/texk/bibtexu/gblprocs.h | 1 - Build/source/texk/bibtexu/gblvars.h | 14 +-- Build/source/texk/bibtexu/utils.c | 165 ++++++++++++++++++++++++----------- 10 files changed, 198 insertions(+), 121 deletions(-) (limited to 'Build/source/texk/bibtexu') diff --git a/Build/source/texk/bibtexu/ChangeLog b/Build/source/texk/bibtexu/ChangeLog index 683eb167a66..084c8821b04 100644 --- a/Build/source/texk/bibtexu/ChangeLog +++ b/Build/source/texk/bibtexu/ChangeLog @@ -1,3 +1,11 @@ +2010-03-24 Peter Breitenlohner + + * bibtex*.[ch], gblvars.h, utils.c: Obtain Ent_Str_Size and + Glob_Str_Size from environment or config file. + Dynamically allocate global strings arrays, literal stack + arrays, and single function space instances; reallocate them + as required. + 2010-03-19 Peter Breitenlohner * utils.c: Default csfile and Max_Strings from env or config. diff --git a/Build/source/texk/bibtexu/bibtex-1.c b/Build/source/texk/bibtexu/bibtex-1.c index 02ef546fc63..d37e83f5df0 100644 --- a/Build/source/texk/bibtexu/bibtex-1.c +++ b/Build/source/texk/bibtexu/bibtex-1.c @@ -2332,7 +2332,7 @@ BEGIN BEGIN str_ent_ptr = (num_ent_strs + 1) * (num_cites + 1); entry_strs = (ASCIICode_T *) mymalloc ((unsigned long) sizeof (ASCIICode_T) - * (unsigned long) (ENT_STR_SIZE + 1) + * (unsigned long) (Ent_Str_Size + 1) * (unsigned long) str_ent_ptr, "entry_strs"); while (str_ent_ptr > 0) BEGIN @@ -2572,9 +2572,21 @@ BEGIN CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc); fn_type[fn_loc] = STR_GLOBAL_VAR; FN_INFO[fn_loc] = num_glb_strs; - if (num_glb_strs == MAX_GLOB_STRS) + if (num_glb_strs == Max_Glob_Strs) BEGIN - BIBTEX_OVERFLOW ("number of string global-variables ", MAX_GLOB_STRS); + BIB_XRETALLOC_NOSET ("glb_str_ptr", glb_str_ptr, StrNumber_T, + Max_Glob_Strs, Max_Glob_Strs + MAX_GLOB_STRS); + BIB_XRETALLOC_STRING ("global_strs", global_strs, Glob_Str_Size, + Max_Glob_Strs, Max_Glob_Strs + MAX_GLOB_STRS); + BIB_XRETALLOC ("glb_str_end", glb_str_end, Integer_T, + Max_Glob_Strs, Max_Glob_Strs + MAX_GLOB_STRS); + str_glb_ptr = num_glb_strs; + while (str_glb_ptr < Max_Glob_Strs) + BEGIN + glb_str_ptr[str_glb_ptr] = 0; + glb_str_end[str_glb_ptr] = 0; + INCR (str_glb_ptr); + END END INCR (num_glb_strs); END @@ -2771,7 +2783,7 @@ BEGIN BEGIN field_ptr = Max_Fields; BIB_XRETALLOC ("field_info", field_info, StrNumber_T, - Max_Fields, Max_Fields + MAX_FIELDS); + Max_Fields, total_fields + MAX_FIELDS); /* Initialize to |missing|. */ while (field_ptr < Max_Fields) BEGIN diff --git a/Build/source/texk/bibtexu/bibtex-2.c b/Build/source/texk/bibtexu/bibtex-2.c index 713a1a40c08..4385fa3c346 100644 --- a/Build/source/texk/bibtexu/bibtex-2.c +++ b/Build/source/texk/bibtexu/bibtex-2.c @@ -624,8 +624,7 @@ End_While_Label: DO_NOTHING; glob_chr_ptr = 0; while (glob_chr_ptr < glb_str_end[str_glb_ptr]) BEGIN - APPEND_CHAR (global_strs[str_glb_ptr][glob_chr_ptr]); - + APPEND_CHAR (GLOBAL_STRS(str_glb_ptr, glob_chr_ptr)); INCR (glob_chr_ptr); END @@ -2255,10 +2254,10 @@ BEGIN if (Max_Cites > Max_Strings) bad = 10 * bad + 8; - if (ENT_STR_SIZE > Buf_Size) + if (Ent_Str_Size > Buf_Size) bad = 10 * bad + 9; - if (GLOB_STR_SIZE > Buf_Size) + if (Glob_Str_Size > Buf_Size) bad = 100 * bad + 11; /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 17 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -2744,7 +2743,7 @@ BEGIN num_ent_strs = 0; num_fields = 0; str_glb_ptr = 0; - while (str_glb_ptr < MAX_GLOB_STRS) + while (str_glb_ptr < Max_Glob_Strs) BEGIN glb_str_ptr[str_glb_ptr] = 0; glb_str_end[str_glb_ptr] = 0; diff --git a/Build/source/texk/bibtexu/bibtex-3.c b/Build/source/texk/bibtexu/bibtex-3.c index 4de2c06448e..b1d6cd01f0c 100644 --- a/Build/source/texk/bibtexu/bibtex-3.c +++ b/Build/source/texk/bibtexu/bibtex-3.c @@ -359,10 +359,10 @@ BEGIN INCR (num_ent_strs); pre_define ("entry.max$ ", 10, BST_FN_ILK); fn_type[pre_def_loc] = INT_GLOBAL_VAR; - FN_INFO[pre_def_loc] = ENT_STR_SIZE; + FN_INFO[pre_def_loc] = Ent_Str_Size; pre_define ("global.max$ ", 11, BST_FN_ILK); fn_type[pre_def_loc] = INT_GLOBAL_VAR; - FN_INFO[pre_def_loc] = GLOB_STR_SIZE; + FN_INFO[pre_def_loc] = Glob_Str_Size; /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 340 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ END @@ -875,9 +875,12 @@ BEGIN } /* end if (Flag_trace) */ #endif /* TRACE */ - if (lit_stk_ptr == LIT_STK_SIZE) + if (lit_stk_ptr == Lit_Stk_Size) BEGIN - BIBTEX_OVERFLOW ("literal-stack size ", LIT_STK_SIZE); + BIB_XRETALLOC_NOSET ("lit_stack", lit_stack, Integer_T, + Lit_Stk_Size, Lit_Stk_Size + LIT_STK_SIZE); + BIB_XRETALLOC ("lit_stk_type", lit_stk_type, StkType_T, + Lit_Stk_Size, Lit_Stk_Size + LIT_STK_SIZE); END INCR (lit_stk_ptr); END @@ -1766,6 +1769,22 @@ END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 253 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +/*************************************************************************** + * WEB section number: 188 + * ~~~~~~~~~~~~~~~~~~~ + * This macro inserts a hash-table location (or one of the two + * special markers |quote_next_fn| and |end_of_def|) into the + * |singl_function| array, which will later be copied into the + * |wiz_functions| array. + ***************************************************************************/ +#define INSERT_FN_LOC(X) {\ + singl_function[single_ptr] = (X);\ + if (single_ptr == Single_Fn_Space)\ + {BIB_XRETALLOC ("singl_function", singl_function, HashPtr2_T,\ + Single_Fn_Space, Single_Fn_Space + Single_Fn_Space);}\ + INCR (single_ptr);} + + /*************************************************************************** * WEB section number: 187 * ~~~~~~~~~~~~~~~~~~~ @@ -1776,12 +1795,16 @@ END void scan_fn_def (HashLoc_T fn_hash_loc) BEGIN typedef Integer_T FnDefLoc_T; - HashPtr2_T singl_function[SINGLE_FN_SPACE + 1]; + HashPtr2_T *singl_function; FnDefLoc_T single_ptr; FnDefLoc_T copy_ptr; BufPointer_T end_of_num; HashLoc_T impl_fn_loc; + Integer_T Single_Fn_Space; + Single_Fn_Space = SINGLE_FN_SPACE; + singl_function = (HashPtr2_T *) mymalloc ((Single_Fn_Space + 1) + * (unsigned long) sizeof (HashPtr2_T), "singl_function"); EAT_BST_WHITE_AND_EOF_CHECK ("function"); single_ptr = 0; while (SCAN_CHAR != RIGHT_BRACE) @@ -2079,7 +2102,7 @@ Next_Token_Label: /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 200 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ INCR (buf_ptr2); -Exit_Label: DO_NOTHING; +Exit_Label: free (singl_function); END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 187 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -2246,23 +2269,6 @@ END -/*************************************************************************** - * WEB section number: 188 - * ~~~~~~~~~~~~~~~~~~~ - * This macro inserts a hash-table location (or one of the two - * special markers |quote_next_fn| and |end_of_def|) into the - * |singl_function| array, which will later be copied into the - * |wiz_functions| array. - ***************************************************************************/ -void singl_fn_overflow (void) -BEGIN - BIBTEX_OVERFLOW ("single function space ", SINGLE_FN_SPACE); -END -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 188 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - - - - /*************************************************************************** * WEB section number: 186 * ~~~~~~~~~~~~~~~~~~~ diff --git a/Build/source/texk/bibtexu/bibtex-4.c b/Build/source/texk/bibtexu/bibtex-4.c index 3131d287c12..6257b5b7a3a 100644 --- a/Build/source/texk/bibtexu/bibtex-4.c +++ b/Build/source/texk/bibtexu/bibtex-4.c @@ -1450,10 +1450,10 @@ BEGIN ent_chr_ptr = 0; sp_ptr = str_start[pop_lit2]; sp_xptr1 = str_start[pop_lit2 + 1]; - if ((sp_xptr1 - sp_ptr) > ENT_STR_SIZE) + if ((sp_xptr1 - sp_ptr) > Ent_Str_Size) BEGIN - BST_STRING_SIZE_EXCEEDED (ENT_STR_SIZE, ", the entry"); - sp_xptr1 = sp_ptr + ENT_STR_SIZE; + BST_STRING_SIZE_EXCEEDED (Ent_Str_Size, ", the entry"); + sp_xptr1 = sp_ptr + Ent_Str_Size; END while (sp_ptr < sp_xptr1) BEGIN @@ -1516,14 +1516,14 @@ BEGIN glob_chr_ptr = 0; sp_ptr = str_start[pop_lit2]; sp_end = str_start[pop_lit2 + 1]; - if ((sp_end - sp_ptr) > GLOB_STR_SIZE) + if ((sp_end - sp_ptr) > Glob_Str_Size) BEGIN - BST_STRING_SIZE_EXCEEDED (GLOB_STR_SIZE, ", the global"); - sp_end = sp_ptr + GLOB_STR_SIZE; + BST_STRING_SIZE_EXCEEDED (Glob_Str_Size, ", the global"); + sp_end = sp_ptr + Glob_Str_Size; END while (sp_ptr < sp_end) BEGIN - global_strs[str_glb_ptr][glob_chr_ptr] = str_pool[sp_ptr]; + GLOBAL_STRS(str_glb_ptr, glob_chr_ptr) = str_pool[sp_ptr]; INCR (glob_chr_ptr); INCR (sp_ptr); END diff --git a/Build/source/texk/bibtexu/bibtex.c b/Build/source/texk/bibtexu/bibtex.c index 0184451dc34..7fb13f7b358 100644 --- a/Build/source/texk/bibtexu/bibtex.c +++ b/Build/source/texk/bibtexu/bibtex.c @@ -415,7 +415,7 @@ Close_Up_Shop_Label: (long) hash_used, (long) Hash_Size); TRACE_PR_LN3 (" Strings: %6ld out of %ld", (long) str_ptr, (long) Max_Strings); - TRACE_PR_LN3 (" String pool: %6ld out of %ld", + TRACE_PR_LN3 (" Free string pool: %6ld out of %ld", (long) pool_ptr, (long) Pool_Size); TRACE_PR_LN3 (" Wizard functions: %6ld out of %ld", (long) wiz_def_ptr, (long) Wiz_Fn_Space); diff --git a/Build/source/texk/bibtexu/bibtex.h b/Build/source/texk/bibtexu/bibtex.h index 1210419cb28..337ba446cfd 100644 --- a/Build/source/texk/bibtexu/bibtex.h +++ b/Build/source/texk/bibtexu/bibtex.h @@ -270,15 +270,15 @@ #define BUF_SIZE 10000 #define MAX_CITES 750 #define MAX_FIELDS 5000 -#define MAX_STRINGS 12000 +#define MAX_STRINGS 4000 #define POOL_SIZE 65000L #define MIN_CROSSREFS 2 #define WIZ_FN_SPACE 3000 -#define SINGLE_FN_SPACE 100 -#define ENT_STR_SIZE 250 +#define SINGLE_FN_SPACE 50 +#define ENT_STR_SIZE 100 #define GLOB_STR_SIZE 1000 -#define LIT_STK_SIZE 100 +#define LIT_STK_SIZE 50 /*************************************************************************** @@ -289,7 +289,6 @@ * themselves. ***************************************************************************/ #define HASH_SIZE 5000 -#define HASH_PRIME 4253 #ifdef MSDOS # define FILE_NAME_SIZE 64 @@ -298,7 +297,6 @@ #endif /* MSDOS */ #define MAX_GLOB_STRS 10 -#define MAX_GLOB_STR_MINUS_1 (MAX_GLOB_STRS - 1) /*************************************************************************** * WEB section number: 18 @@ -945,20 +943,6 @@ skip_illegal_stuff_after_token ();\ goto Next_Token_Label;} -/*************************************************************************** - * WEB section number: 188 - * ~~~~~~~~~~~~~~~~~~~ - * This macro inserts a hash-table location (or one of the two - * special markers |quote_next_fn| and |end_of_def|) into the - * |singl_function| array, which will later be copied into the - * |wiz_functions| array. - ***************************************************************************/ -#define INSERT_FN_LOC(X) {\ - singl_function[single_ptr] = (X);\ - if (single_ptr == SINGLE_FN_SPACE)\ - {singl_fn_overflow();}\ - INCR (single_ptr);} - /*************************************************************************** * WEB section number: 194 * ~~~~~~~~~~~~~~~~~~~ @@ -1465,8 +1449,8 @@ * accessing a 2D array by converting the row/col into an offset from the * beginning of a 1D array. ***************************************************************************/ -#define ENTRY_STRS(_r,_c) entry_strs[(_r * (ENT_STR_SIZE+1)) + _c] -#define GLOBAL_STRS(_r,_c) global_strs[(_r * (GLOB_STR_SIZE+1)) + _c] +#define ENTRY_STRS(_r,_c) entry_strs[(_r * (Ent_Str_Size+1)) + _c] +#define GLOBAL_STRS(_r,_c) global_strs[(_r * (Glob_Str_Size+1)) + _c] /*************************************************************************** @@ -1491,6 +1475,12 @@ BIB_XRETALLOC_NOSET(array_name, array_var, type, size_var, new_size); \ size_var = new_size; \ } while (0) +/* Same as above, but for the pseudo-TYPE ASCIICode_T[LENGTH+1]. */ +#define BIB_XRETALLOC_STRING(array_name, array_var, length, size_var, new_size) \ + if (log_file != NULL)\ + fprintf (log_file, "Reallocated %s (elt_size=%d) to %ld items from %ld.\n", \ + array_name, (int) (length + 1), new_size, size_var); \ + MYRETALLOC (array_name, array_var, new_size * (length + 1), ASCIICode_T) #endif /* __BIBTEX_H__ */ diff --git a/Build/source/texk/bibtexu/gblprocs.h b/Build/source/texk/bibtexu/gblprocs.h index 3429598a977..f2fc4a22c93 100644 --- a/Build/source/texk/bibtexu/gblprocs.h +++ b/Build/source/texk/bibtexu/gblprocs.h @@ -291,7 +291,6 @@ void scan_identifier (ASCIICode_T char1, Boolean_T scan_integer (void); Boolean_T scan_nonneg_integer (void); Boolean_T scan_white_space (void); -void singl_fn_overflow (void); void skip_illegal_stuff_after_token (void); void skip_stuff_at_sp_brace_level_gr (void); void skip_token_print (void); diff --git a/Build/source/texk/bibtexu/gblvars.h b/Build/source/texk/bibtexu/gblvars.h index c6a3aae71ea..353460a1ff5 100644 --- a/Build/source/texk/bibtexu/gblvars.h +++ b/Build/source/texk/bibtexu/gblvars.h @@ -350,12 +350,8 @@ __EXTERN__ AlphaFile_T aux_file[AUX_STACK_SIZE + 1]; __EXTERN__ StrNumber_T aux_list[AUX_STACK_SIZE + 1]; __EXTERN__ Integer_T aux_ln_stack[AUX_STACK_SIZE + 1]; __EXTERN__ Integer_T char_width[LAST_ASCII_CHAR + 1]; -__EXTERN__ Integer_T glb_str_end[MAX_GLOB_STRS]; -__EXTERN__ StrNumber_T glb_str_ptr[MAX_GLOB_STRS]; __EXTERN__ IDType_T id_class[LAST_ASCII_CHAR + 1]; __EXTERN__ LexType_T lex_class[LAST_ASCII_CHAR + 1]; -__EXTERN__ Integer_T lit_stack[LIT_STK_SIZE + 1]; -__EXTERN__ StkType_T lit_stk_type[LIT_STK_SIZE + 1]; __EXTERN__ unsigned char xchr[LAST_ASCII_CHAR + 1]; __EXTERN__ ASCIICode_T xord[LAST_TEXT_CHAR + 1]; @@ -400,11 +396,15 @@ __EXTERN__ ASCIICode_T *entry_strs; __EXTERN__ ASCIICode_T *ex_buf; __EXTERN__ StrNumber_T *field_info; __EXTERN__ FnClass_T *fn_type; -__EXTERN__ ASCIICode_T *global_strs[MAX_GLOB_STRS + 1]; +__EXTERN__ Integer_T *glb_str_end; +__EXTERN__ StrNumber_T *glb_str_ptr; +__EXTERN__ ASCIICode_T *global_strs; __EXTERN__ StrIlk_T *hash_ilk; __EXTERN__ HashPointer_T *hash_next; __EXTERN__ StrNumber_T *hash_text; __EXTERN__ Integer_T *ilk_info; +__EXTERN__ Integer_T *lit_stack; +__EXTERN__ StkType_T *lit_stk_type; __EXTERN__ unsigned char *name_of_file; __EXTERN__ ASCIICode_T *name_sep_char; __EXTERN__ BufPointer_T *name_tok; @@ -450,11 +450,15 @@ __EXTERN__ char *Str_csfile; **---------------------------------------------------------------------------- */ __EXTERN__ Integer_T Buf_Size; +__EXTERN__ Integer_T Ent_Str_Size; +__EXTERN__ Integer_T Glob_Str_Size; __EXTERN__ Integer_T Hash_Prime; __EXTERN__ Integer_T Hash_Size; +__EXTERN__ Integer_T Lit_Stk_Size; __EXTERN__ Integer_T Max_Bib_Files; __EXTERN__ Integer_T Max_Cites; __EXTERN__ Integer_T Max_Fields; +__EXTERN__ Integer_T Max_Glob_Strs; __EXTERN__ Integer_T Max_Strings; __EXTERN__ Integer_T Min_Crossrefs; __EXTERN__ Integer_T Pool_Size; diff --git a/Build/source/texk/bibtexu/utils.c b/Build/source/texk/bibtexu/utils.c index 63f7044317a..b6f9fffc455 100644 --- a/Build/source/texk/bibtexu/utils.c +++ b/Build/source/texk/bibtexu/utils.c @@ -247,15 +247,19 @@ static int sort_weight; ** StrNumber_T cite_list[Max_Cites + 1]; ** Boolean_T entry_exists[Max_Cites + 1]; ** Integer_T entry_ints[Max_Ent_Ints + 1]; -** ASCIICode_T entry_strs[Max_Ent_Strs + 1][ENT_STR_SIZE + 1]; +** ASCIICode_T entry_strs[Max_Ent_Strs + 1][Ent_Str_Size + 1]; ** ASCIICode_T ex_buf[Buf_Size + 1]; ** StrNumber_T field_info[Max_Fields + 1]; ** FnClass_T fn_type[Hash_Size + 1]; -** ASCIICode_T global_strs[MAX_GLOB_STRS + 1]; +** Integer_T glb_str_end[Max_Glob_Strs]; +** StrNumber_T glb_str_ptr[Max_Glob_Strs]; +** ASCIICode_T global_strs[Max_Glob_Strs][Glob_Str_Size + 1];; ** StrIlk_T hash_ilk[Hash_Size + 1]; ** HashPointer_T hash_next[Hash_Size + 1]; ** StrNumber_T hash_text[Hash_Size + 1]; ** Integer_T ilk_info[Hash_Size + 1]; +** Integer_T lit_stack[Lit_Stk_Size + 1]; +** StkType_T lit_stk_type[Lit_Stk_Size + 1]; ** ASCIICode_T name_sep_char[Buf_Size + 1]; ** BufPointer_T name_tok[Buf_Size + 1]; ** ASCIICode_T out_buf[Buf_Size + 1]; @@ -270,8 +274,6 @@ static int sort_weight; static void allocate_arrays (void) { unsigned long bytes_required; - ASCIICode_T *dummy_ptr; - int row; debug_msg (DBG_MEM, "Starting to allocate memory for arrays ... "); @@ -318,7 +320,7 @@ static void allocate_arrays (void) entry_ints = NULL; /* - ** ASCIICode_T entry_strs[Max_Ent_Strs + 1][ENT_STR_SIZE + 1]; + ** ASCIICode_T entry_strs[Max_Ent_Strs + 1][Ent_Str_Size + 1]; ** allocated when num_ent_strs and num_cites are known */ entry_strs = NULL; @@ -342,16 +344,24 @@ static void allocate_arrays (void) fn_type = (FnClass_T *) mymalloc (bytes_required, "fn_type"); /* - ** ASCIICode_T global_strs[MAX_GLOB_STRS][GLOB_STR_SIZE + 1]; + ** Integer_T glb_str_end[Max_Glob_Strs]; */ - bytes_required = (unsigned long) (MAX_GLOB_STRS) - * (GLOB_STR_SIZE + 1) - * (unsigned long) sizeof (ASCIICode_T); - dummy_ptr = (ASCIICode_T *) mymalloc (bytes_required, "global_strs"); + bytes_required = Max_Glob_Strs * (unsigned long) sizeof (Integer_T); + glb_str_end = (Integer_T *) mymalloc (bytes_required, "glb_str_end"); - for (row = 0; row < (MAX_GLOB_STRS + 1); row++) { - global_strs[row] = dummy_ptr + (row * (GLOB_STR_SIZE + 1)); - } + /* + ** StrNumber_T glb_str_ptr[Max_Glob_Strs]; + */ + bytes_required = Max_Glob_Strs * (unsigned long) sizeof (StrNumber_T); + glb_str_ptr = (StrNumber_T *) mymalloc (bytes_required, "glb_str_ptr"); + + /* + ** ASCIICode_T global_strs[Max_Glob_Strs][Glob_Str_Size + 1]; + */ + bytes_required = (unsigned long) (Max_Glob_Strs) + * (Glob_Str_Size + 1) + * (unsigned long) sizeof (ASCIICode_T); + global_strs = (ASCIICode_T *) mymalloc (bytes_required, "global_strs"); /* ** StrIlk_T hash_ilk[Hash_Size + 1]; @@ -377,6 +387,18 @@ static void allocate_arrays (void) bytes_required = (Hash_Size + 1) * (unsigned long) sizeof (Integer_T); ilk_info = (Integer_T *) mymalloc (bytes_required, "ilk_info"); + /* + ** Integer_T lit_stack[Lit_Stk_Size + 1]; + */ + bytes_required = (Lit_Stk_Size + 1) * (unsigned long) sizeof (Integer_T); + lit_stack = (Integer_T *) mymalloc (bytes_required, "lit_stack"); + + /* + ** StkType_T lit_stk_type[Lit_Stk_Size + 1]; + */ + bytes_required = (Lit_Stk_Size + 1) * (unsigned long) sizeof (StkType_T); + lit_stk_type = (StkType_T *) mymalloc (bytes_required, "lit_stk_type"); + /* ** ASCIICode_T name_sep_char[Buf_Size + 1]; */ @@ -1155,15 +1177,15 @@ void report_bibtex_capacity (void) FPRINTF (log_file, "BibTeX's capacity set as follows:\n\n"); LOG_CAPACITY (AUX_STACK_SIZE); LOG_CAPACITY (Buf_Size); - LOG_CAPACITY (ENT_STR_SIZE); - LOG_CAPACITY (GLOB_STR_SIZE); + LOG_CAPACITY (Ent_Str_Size); + LOG_CAPACITY (Glob_Str_Size); LOG_CAPACITY (Hash_Prime); LOG_CAPACITY (Hash_Size); - LOG_CAPACITY (LIT_STK_SIZE); + LOG_CAPACITY (Lit_Stk_Size); LOG_CAPACITY (Max_Bib_Files); LOG_CAPACITY (Max_Cites); LOG_CAPACITY (Max_Fields); - LOG_CAPACITY (MAX_GLOB_STRS); + LOG_CAPACITY (Max_Glob_Strs); LOG_CAPACITY (MAX_PRINT_LINE); LOG_CAPACITY (Max_Strings); LOG_CAPACITY (Min_Crossrefs); @@ -1226,6 +1248,75 @@ void report_search_paths (void) } /* report_search_paths() */ +/*- +**============================================================================ +** setup_bound_variable() +** +** Obtain parameters from environment or configuration file, +** or use the default value. +**============================================================================ +*/ +static void setup_bound_variable (Integer_T *var, const char *name, + unsigned long def_value) +{ +#ifdef KPATHSEA + char *expansion = kpse_var_value (name); + const char *me = program_invocation_name; + const char *src = " or texmf.cnf"; +#else + char *expansion = getenv (name); + const char *me = "bibtexu"; + const char *src = ""; +#endif + + *var = def_value; + if (expansion) { + int conf_val = atoi (expansion); + if (conf_val < def_value) + fprintf (stderr, + "%s: Bad value (%ld) in environment%s for %s, keeping %ld.\n", + me, (long) conf_val, src, name, def_value); + else + *var = conf_val; +#ifdef KPATHSEA + free (expansion); +#endif + } +} /* setup_bound_variable() */ + +/*- +**============================================================================ +** setup_params() +** +** Determine |ent_str_size|, |glob_str_size|, and |max_strings| from the +** environment, configuration file, or default value. Set +** |hash_size:=max_strings|, but not less than |HASH_SIZE|. +**============================================================================ +*/ +static void setup_params (void) +{ + setup_bound_variable (&Ent_Str_Size, "ent_str_size", ENT_STR_SIZE); + setup_bound_variable (&Glob_Str_Size, "glob_str_size", GLOB_STR_SIZE); + setup_bound_variable (&Max_Strings, "max_strings", MAX_STRINGS); + + /* Obsolete: Max_Strings specified via command line. */ + if (Flag_big) + Max_Strings = 10000; + if (Flag_huge) + Max_Strings = 19000; + if (Flag_wolfgang) + Max_Strings = 30000; + if (M_strings > 0) + Max_Strings = M_strings; + + if (Max_Strings < MAX_STRINGS) + Max_Strings = MAX_STRINGS; + Hash_Size = Max_Strings; + if (Hash_Size < HASH_SIZE) + Hash_Size = HASH_SIZE; +} /* setup_params() */ + + /*- **============================================================================ ** compute_hash_prime() @@ -1236,7 +1327,6 @@ void report_search_paths (void) ** ** This algorithm uses two arrays |primes| and |mult|. We use the ** already allocated |hash_next| and |hash_text| for that purpose. -** **============================================================================ */ #define primes hash_next @@ -1273,7 +1363,7 @@ static void compute_hash_prime (void) } while (!j_prime); primes[++k] = Hash_Prime = j; } -} +} /* compute_hash_prime() */ /*- @@ -1311,34 +1401,11 @@ void set_array_sizes (void) Max_Strings = 4000; Min_Crossrefs = 2; - { - char *expansion = kpse_var_value ("max_strings"); - if (expansion) { - int conf_val = atoi (expansion); - if (conf_val < Max_Strings) - fprintf (stderr, - "%s: Bad value (%ld) in texmf.cnf for max_strings, keeping %ld.\n", - program_invocation_name, (long) conf_val, (long) Max_Strings); - else - Max_Strings = conf_val; - free (expansion); - } - } - - if (Flag_big) { - Max_Strings = 10000; - } - - if (Flag_huge) { - Max_Strings = 19000; - } - - if (Flag_wolfgang) { - Max_Strings = 30000; - } - + setup_params (); Buf_Size = BUF_SIZE; + Lit_Stk_Size = LIT_STK_SIZE; + Max_Bib_Files = MAX_BIB_FILES; Max_Cites = MAX_CITES; @@ -1350,14 +1417,6 @@ void set_array_sizes (void) Pool_Size = POOL_SIZE; - if (M_strings > 0) - Max_Strings = M_strings; - if (Max_Strings < 4000) - Max_Strings = 4000; - Hash_Size = Max_Strings; - if (Hash_Size < 5000) - Hash_Size = 5000; - Wiz_Fn_Space = WIZ_FN_SPACE; -- cgit v1.2.3