summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2010-03-24 18:00:22 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2010-03-24 18:00:22 +0000
commit2256310fae2a2c24e5d062a51b4de574b148c738 (patch)
tree86c8326f77d1a6e08ec4cc53fd836912388bf7bf /Build
parentb43a81e1ba916e7daaf0559ae06791e720533e7e (diff)
bibtex8/bibtexu: reallocate arrays when needed, same as in bibtex
git-svn-id: svn://tug.org/texlive/trunk@17548 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/bibtex8/ChangeLog8
-rw-r--r--Build/source/texk/bibtex8/bibtex-1.c20
-rw-r--r--Build/source/texk/bibtex8/bibtex-2.c8
-rw-r--r--Build/source/texk/bibtex8/bibtex-3.c52
-rw-r--r--Build/source/texk/bibtex8/bibtex-4.c14
-rw-r--r--Build/source/texk/bibtex8/bibtex.c2
-rw-r--r--Build/source/texk/bibtex8/bibtex.h34
-rw-r--r--Build/source/texk/bibtex8/gblprocs.h1
-rw-r--r--Build/source/texk/bibtex8/gblvars.h14
-rwxr-xr-xBuild/source/texk/bibtex8/tests/bibtex-mem.test13
-rw-r--r--Build/source/texk/bibtex8/utils.c165
-rw-r--r--Build/source/texk/bibtexu/ChangeLog8
-rw-r--r--Build/source/texk/bibtexu/bibtex-1.c20
-rw-r--r--Build/source/texk/bibtexu/bibtex-2.c9
-rw-r--r--Build/source/texk/bibtexu/bibtex-3.c52
-rw-r--r--Build/source/texk/bibtexu/bibtex-4.c14
-rw-r--r--Build/source/texk/bibtexu/bibtex.c2
-rw-r--r--Build/source/texk/bibtexu/bibtex.h34
-rw-r--r--Build/source/texk/bibtexu/gblprocs.h1
-rw-r--r--Build/source/texk/bibtexu/gblvars.h14
-rw-r--r--Build/source/texk/bibtexu/utils.c165
21 files changed, 401 insertions, 249 deletions
diff --git a/Build/source/texk/bibtex8/ChangeLog b/Build/source/texk/bibtex8/ChangeLog
index 195e05f8fd3..528deb82818 100644
--- a/Build/source/texk/bibtex8/ChangeLog
+++ b/Build/source/texk/bibtex8/ChangeLog
@@ -1,3 +1,11 @@
+2010-03-24 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * 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 <peb@mppmu.mpg.de>
* utils.c: Default csfile and Max_Strings from env or config.
diff --git a/Build/source/texk/bibtex8/bibtex-1.c b/Build/source/texk/bibtex8/bibtex-1.c
index cb382cdce56..3c4fde5119c 100644
--- a/Build/source/texk/bibtex8/bibtex-1.c
+++ b/Build/source/texk/bibtex8/bibtex-1.c
@@ -2321,7 +2321,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
@@ -2561,9 +2561,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
@@ -2760,7 +2772,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/bibtex8/bibtex-2.c b/Build/source/texk/bibtex8/bibtex-2.c
index bb8b298218f..60dce110243 100644
--- a/Build/source/texk/bibtex8/bibtex-2.c
+++ b/Build/source/texk/bibtex8/bibtex-2.c
@@ -616,7 +616,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
push_lit_stk (make_string (), STK_STR);
@@ -2209,10 +2209,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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
@@ -2698,7 +2698,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/bibtex8/bibtex-3.c b/Build/source/texk/bibtex8/bibtex-3.c
index 308cbed1425..aba857a3e2b 100644
--- a/Build/source/texk/bibtex8/bibtex-3.c
+++ b/Build/source/texk/bibtex8/bibtex-3.c
@@ -351,10 +351,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
@@ -867,9 +867,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
@@ -1759,6 +1762,22 @@ 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.
+ ***************************************************************************/
+#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
* ~~~~~~~~~~~~~~~~~~~
* This recursive function reads and stores the list of functions
@@ -1768,12 +1787,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)
@@ -2071,7 +2094,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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
@@ -2239,23 +2262,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
* ~~~~~~~~~~~~~~~~~~~
* And another.
diff --git a/Build/source/texk/bibtex8/bibtex-4.c b/Build/source/texk/bibtex8/bibtex-4.c
index 07cf8d0f0e7..7af0293e206 100644
--- a/Build/source/texk/bibtex8/bibtex-4.c
+++ b/Build/source/texk/bibtex8/bibtex-4.c
@@ -1314,10 +1314,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
@@ -1376,14 +1376,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/bibtex8/bibtex.c b/Build/source/texk/bibtex8/bibtex.c
index ced981fdee4..204083b3888 100644
--- a/Build/source/texk/bibtex8/bibtex.c
+++ b/Build/source/texk/bibtex8/bibtex.c
@@ -404,7 +404,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/bibtex8/bibtex.h b/Build/source/texk/bibtex8/bibtex.h
index ae6ef197af3..c5454b15285 100644
--- a/Build/source/texk/bibtex8/bibtex.h
+++ b/Build/source/texk/bibtex8/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
@@ -946,20 +944,6 @@
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
* ~~~~~~~~~~~~~~~~~~~
* This module marks the implicit function as being quoted, generates a
@@ -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/bibtex8/gblprocs.h b/Build/source/texk/bibtex8/gblprocs.h
index e02845828a3..c52e7aa9518 100644
--- a/Build/source/texk/bibtex8/gblprocs.h
+++ b/Build/source/texk/bibtex8/gblprocs.h
@@ -274,7 +274,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/bibtex8/gblvars.h b/Build/source/texk/bibtex8/gblvars.h
index bfd77a4a1e9..39903ac88c8 100644
--- a/Build/source/texk/bibtex8/gblvars.h
+++ b/Build/source/texk/bibtex8/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;
@@ -445,11 +445,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/bibtex8/tests/bibtex-mem.test b/Build/source/texk/bibtex8/tests/bibtex-mem.test
index 19d50f6c402..45b03cfa45a 100755
--- a/Build/source/texk/bibtex8/tests/bibtex-mem.test
+++ b/Build/source/texk/bibtex8/tests/bibtex-mem.test
@@ -47,21 +47,18 @@ for t in 1 2 3; do
mk_aux memdata$t >tests/memtest$t.aux
+ env=
+
case $t in
1) mk_bib 0 >tests/memtest.bib;;
2) mk_bib 1 >>tests/memtest.bib;;
- 3) exit 0;; # requires larger constants
+ 3) env='ent_str_size=2000 glob_str_size=2000';;
esac
-# memtest3 requires:
-# SINGLE_FN_SPACE 200 (100)
-# ENT_STR_SIZE 2000 (250)
-# GLOB_STR_SIZE 2000 (1000)
-# MAX_GLOB_STRS 50 (10)
-
echo "Running memtest$t ..."
- TEXMFCNF=$srcdir/../kpathsea \
+ eval $env \
+ TEXMFCNF=$srcdir/../kpathsea \
BSTINPUTS=$srcdir/../web2c/tests:$srcdir/csf \
BIBINPUTS=./tests \
./bibtex8 tests/memtest$t || exit 1
diff --git a/Build/source/texk/bibtex8/utils.c b/Build/source/texk/bibtex8/utils.c
index 17e853015d7..4f4fff105c4 100644
--- a/Build/source/texk/bibtex8/utils.c
+++ b/Build/source/texk/bibtex8/utils.c
@@ -239,15 +239,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];
@@ -262,8 +266,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 ... ");
@@ -310,7 +312,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;
@@ -334,16 +336,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];
@@ -370,6 +380,18 @@ static void allocate_arrays (void)
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];
*/
bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
@@ -1127,15 +1149,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);
@@ -1200,6 +1222,75 @@ void report_search_paths (void)
/*-
**============================================================================
+** 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 = "bibtex8";
+ 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()
**
** We use the algorithm from Knuth's \.{primes.web} to compute
@@ -1208,7 +1299,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
@@ -1245,7 +1335,7 @@ static void compute_hash_prime (void)
} while (!j_prime);
primes[++k] = Hash_Prime = j;
}
-}
+} /* compute_hash_prime() */
/*-
@@ -1283,34 +1373,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;
@@ -1322,14 +1389,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;
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 <peb@mppmu.mpg.de>
+
+ * 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 <peb@mppmu.mpg.de>
* 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
@@ -1767,6 +1770,22 @@ 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.
+ ***************************************************************************/
+#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
* ~~~~~~~~~~~~~~~~~~~
* This recursive function reads and stores the list of functions
@@ -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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
@@ -2247,23 +2270,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
* ~~~~~~~~~~~~~~~~~~~
* And another.
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
@@ -946,20 +944,6 @@
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
* ~~~~~~~~~~~~~~~~~~~
* This module marks the implicit function as being quoted, generates a
@@ -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];
@@ -378,6 +388,18 @@ static void allocate_arrays (void)
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];
*/
bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
@@ -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);
@@ -1228,6 +1250,75 @@ void report_search_paths (void)
/*-
**============================================================================
+** 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()
**
** We use the algorithm from Knuth's \.{primes.web} to compute
@@ -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;