summaryrefslogtreecommitdiff
path: root/Build/source/texk
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk')
-rw-r--r--Build/source/texk/bibtex8/ChangeLog60
-rw-r--r--Build/source/texk/bibtex8/Makefile.am11
-rw-r--r--Build/source/texk/bibtex8/Makefile.in116
-rw-r--r--Build/source/texk/bibtex8/bibtex-1.c38
-rw-r--r--Build/source/texk/bibtex8/bibtex-2.c27
-rw-r--r--Build/source/texk/bibtex8/bibtex-3.c4
-rw-r--r--Build/source/texk/bibtex8/bibtex-4.c1
-rw-r--r--Build/source/texk/bibtex8/bibtex.c3
-rw-r--r--Build/source/texk/bibtex8/bibtex.h38
-rw-r--r--Build/source/texk/bibtex8/datatype.h2
-rw-r--r--Build/source/texk/bibtex8/gblvars.h24
-rwxr-xr-xBuild/source/texk/bibtex8/tests/bibtex.test14
-rw-r--r--Build/source/texk/bibtex8/utils.c305
-rw-r--r--Build/source/texk/bibtex8/utils.h5
-rw-r--r--Build/source/texk/bibtexu/ChangeLog58
-rw-r--r--Build/source/texk/bibtexu/Makefile.am11
-rw-r--r--Build/source/texk/bibtexu/Makefile.in116
-rw-r--r--Build/source/texk/bibtexu/bibtex-1.c38
-rw-r--r--Build/source/texk/bibtexu/bibtex-2.c27
-rw-r--r--Build/source/texk/bibtexu/bibtex-3.c4
-rw-r--r--Build/source/texk/bibtexu/bibtex-4.c1
-rw-r--r--Build/source/texk/bibtexu/bibtex.c3
-rw-r--r--Build/source/texk/bibtexu/bibtex.h38
-rw-r--r--Build/source/texk/bibtexu/datatype.h2
-rw-r--r--Build/source/texk/bibtexu/gblvars.h24
-rwxr-xr-xBuild/source/texk/bibtexu/tests/bibtex.test16
-rw-r--r--Build/source/texk/bibtexu/utils.c303
-rw-r--r--Build/source/texk/bibtexu/utils.h5
28 files changed, 973 insertions, 321 deletions
diff --git a/Build/source/texk/bibtex8/ChangeLog b/Build/source/texk/bibtex8/ChangeLog
index 287ae694bf7..bc92dac5b76 100644
--- a/Build/source/texk/bibtex8/ChangeLog
+++ b/Build/source/texk/bibtex8/ChangeLog
@@ -1,3 +1,63 @@
+2010-03-15 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * tests/bibtex.test: New shell script to test 7-bit mode.
+ * Makefile.am (TESTS, EXTRA_DIST, DISTCLEANFILES): Adapted.
+
+ * bibtex-1.c, bibtex-2.c: Reallocate bib_file, bib_list, and
+ s_preamble as needed.
+
+ * datatype.h (BufType_T): Declare as pointer instead of array.
+ * gblvars.h, utils.c: Dynamically allocate buffer, ex_buf,
+ out_buf, and sv_buffer.
+ * bibtex-1.c (add_out_pool): Call buffer_overflow to reallocate.
+ (buffer_overflow): Reallocate buffer, ex_buf, name_sep_char,
+ name_tok, out_buf, and sv_buffer as needed.
+
+ * utils.c (c8read_csf): Drastically reduce sx array size.
+
+2010-03-14 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * bibtex-1.c: Reallocate entry_ints, field_info as needed.
+ * bibtex-3.c: Reallocate wiz_functions as needed.
+ * gblvars.h, utils.c: Dynamically allocate bib_file, bib_list,
+ name_sep_char, name_tok, and s_preamble.
+ * gblvars.h (M_entints, M_fields, M_wiz_fn_space): Removed.
+ * utils.c (parse_cmd_line, usage): Ignore/remove --mentints,
+ --mfields, and --mwizfuns.
+
+ * bibtex-4.c: Added check for str_pool overflow (from bibtex).
+
+ * gblvars.h (Buf_Size, Max_Bib_Files): New global vars.
+ * utils.c: Set Buf_Size=BUF_SIZE, Max_Bib_Files=MAX_BIB_FILES.
+ Allocate bib_file, bib_list, name_sep_char, name_tok, and
+ s_preamble.[A
+ * bibtex-1.c, bibtex-2.c: Use Buf_Size and Max_Bib_Files.
+
+2010-03-13 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ Dynamic allocation of arrays.
+ * bibtex.h (MYRETALLOC, BIB_XRETALLOC, BIB_XRETALLOC_NOSET):
+ Preprocessor macros used to reallocate arrays.
+ * utils.[ch] (myrealloc): New function.
+ (mymalloc, myrealloc): Allocate at least 1 byte, to avoid NULL.
+ (checkdbg, checklong): Declare as static.
+
+ * bibtex-2.c (pool_overflow): Reallocate str_pool as needed.
+ * gblvars.h (M_pool): Removed.
+ * utils.c (parse_cmd_line, usage): Ignore/remove --mpool.
+
+ * utils.c (usage): This is bibtex8, not bibtex.
+
+2010-03-12 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ Determine hash_size from max_strings and compute hash_prime.
+ * bibtex.c (main): Don't call allocate_arrays.
+ Print newline after fatal error message.
+ * utils.c (allocate_arrays): Declare as static.
+ (compute_hash_prime): New function, using allocated arrays.
+ (set_array_sizes): Call allocate_arrays and compute_hash_prime.
+ * utils.h (allocate_arrays): Remove.
+
2010-03-10 Peter Breitenlohner <peb@mppmu.mpg.de>
* bibtex.h: Adapt to bibtex.web final 0.99d from Oren.
diff --git a/Build/source/texk/bibtex8/Makefile.am b/Build/source/texk/bibtex8/Makefile.am
index 4e37a61529a..a1c987f885c 100644
--- a/Build/source/texk/bibtex8/Makefile.am
+++ b/Build/source/texk/bibtex8/Makefile.am
@@ -59,9 +59,18 @@ dist_btdoc_DATA = \
csfile.txt \
file_id.diz
+## Tests.
+##
+TESTS = tests/bibtex.test
+EXTRA_DIST = $(TESTS)
+DISTCLEANFILES =
+
+## bibtex.test
+DISTCLEANFILES += tests/xexampl.aux tests/xexampl.bbl tests/xexampl.blg
+
## Not used
##
-EXTRA_DIST = \
+EXTRA_DIST += \
bt371csf.zip \
dos-dj.mak \
dos-emx.mak \
diff --git a/Build/source/texk/bibtex8/Makefile.in b/Build/source/texk/bibtex8/Makefile.in
index 40e7e931c59..7da1677e846 100644
--- a/Build/source/texk/bibtex8/Makefile.in
+++ b/Build/source/texk/bibtex8/Makefile.in
@@ -117,6 +117,8 @@ am__base_list = \
DATA = $(dist_btdoc_DATA) $(dist_csf_DATA)
ETAGS = etags
CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@@ -284,17 +286,11 @@ dist_btdoc_DATA = \
csfile.txt \
file_id.diz
-EXTRA_DIST = \
- bt371csf.zip \
- dos-dj.mak \
- dos-emx.mak \
- os2.mak \
- unix.mak \
- csf/00readme.txt \
- csf/COPYING \
- csf/HISTORY \
+TESTS = tests/bibtex.test
+EXTRA_DIST = $(TESTS) bt371csf.zip dos-dj.mak dos-emx.mak os2.mak \
+ unix.mak csf/00readme.txt csf/COPYING csf/HISTORY \
csf/file_id.diz
-
+DISTCLEANFILES = tests/xexampl.aux tests/xexampl.bbl tests/xexampl.blg
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -533,6 +529,98 @@ GTAGS:
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@@ -681,6 +769,7 @@ distcleancheck: distclean
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile $(PROGRAMS) $(DATA) config.h
installdirs:
@@ -708,6 +797,7 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@@ -786,10 +876,10 @@ ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-dist_btdocDATA \
uninstall-dist_csfDATA
-.MAKE: all install-am install-strip
+.MAKE: all check-am install-am install-strip
-.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
- clean-binPROGRAMS clean-generic clean-libtool ctags dist \
+.PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \
+ clean clean-binPROGRAMS clean-generic clean-libtool ctags dist \
dist-all dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ \
dist-xz dist-zip distcheck distclean distclean-compile \
distclean-generic distclean-hdr distclean-libtool \
diff --git a/Build/source/texk/bibtex8/bibtex-1.c b/Build/source/texk/bibtex8/bibtex-1.c
index c9282bdd9dc..c78d3c52e1a 100644
--- a/Build/source/texk/bibtex8/bibtex-1.c
+++ b/Build/source/texk/bibtex8/bibtex-1.c
@@ -203,7 +203,7 @@ void add_buf_pool (StrNumber_T p_str)
BEGIN
p_ptr1 = str_start[p_str];
p_ptr2 = str_start[p_str + 1];
- if ((ex_buf_length + (p_ptr2 - p_ptr1)) > BUF_SIZE)
+ if ((ex_buf_length + (p_ptr2 - p_ptr1)) > Buf_Size)
BEGIN
buffer_overflow ();
END
@@ -304,9 +304,9 @@ BEGIN
p_ptr1 = str_start[p_str];
p_ptr2 = str_start[p_str + 1];
- if ((out_buf_length + (p_ptr2 - p_ptr1)) > BUF_SIZE)
+ if ((out_buf_length + (p_ptr2 - p_ptr1)) > Buf_Size)
BEGIN
- BIBTEX_OVERFLOW ("output buffer size ", BUF_SIZE);
+ buffer_overflow ();
END
out_buf_ptr = out_buf_length;
while (p_ptr1 < p_ptr2)
@@ -502,9 +502,14 @@ BEGIN
* the |s_bib_extension| string, the resulting file name can be opened.
***************************************************************************/
BEGIN
- if (bib_ptr == MAX_BIB_FILES)
+ if (bib_ptr == Max_Bib_Files)
BEGIN
- BIBTEX_OVERFLOW ("number of database files ", MAX_BIB_FILES);
+ BIB_XRETALLOC_NOSET ("bib_file", bib_file, AlphaFile_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
+ BIB_XRETALLOC_NOSET ("bib_list", bib_list, StrNumber_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
+ BIB_XRETALLOC ("s_preamble", s_preamble, StrNumber_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
END
CUR_BIB_STR = hash_text[str_lookup (buffer, buf_ptr1, TOKEN_LEN,
BIB_FILE_ILK, DO_INSERT)];
@@ -1121,7 +1126,7 @@ END
***************************************************************************/
void bib_field_too_long_print (void)
BEGIN
- BIB_ERR2 ("Your field is more than %ld characters", (long) BUF_SIZE);
+ BIB_ERR2 ("Your field is more than %ld characters", (long) Buf_Size);
Exit_Label: DO_NOTHING;
END
@@ -2346,8 +2351,8 @@ BEGIN
BEGIN
if ((num_ent_ints * num_cites) > Max_Ent_Ints)
BEGIN
- PRINT2 ("%ld: ", (long) (num_ent_ints * num_cites));
- BIBTEX_OVERFLOW ("total number of integer entry-variables ", Max_Ent_Ints);
+ BIB_XRETALLOC ("entry_ints", entry_ints, Integer_T,
+ Max_Ent_Ints, (long) (num_ent_ints + 1) * (num_cites + 1));
END
int_ent_ptr = 0;
while (int_ent_ptr < (num_ent_ints * num_cites))
@@ -2651,7 +2656,18 @@ END
***************************************************************************/
void buffer_overflow (void)
BEGIN
- BIBTEX_OVERFLOW ("buffer size ", BUF_SIZE);
+ BIB_XRETALLOC_NOSET ("buffer", buffer, ASCIICode_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
+ BIB_XRETALLOC_NOSET ("ex_buf", ex_buf, ASCIICode_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
+ BIB_XRETALLOC_NOSET ("name_sep_char", name_sep_char, ASCIICode_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
+ BIB_XRETALLOC_NOSET ("name_tok", name_tok, BufPointer_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
+ BIB_XRETALLOC_NOSET ("out_buf", out_buf, ASCIICode_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
+ BIB_XRETALLOC ("sv_buffer", sv_buffer, ASCIICode_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 46 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
@@ -2784,8 +2800,8 @@ void check_field_overflow (Integer_T total_fields)
BEGIN
if (total_fields > Max_Fields)
BEGIN
- PRINT_LN2 ("%ld fields:", (long) total_fields);
- BIBTEX_OVERFLOW ("total number of fields ", Max_Fields);
+ BIB_XRETALLOC ("field_info", field_info, StrNumber_T,
+ Max_Fields, Max_Fields + MAX_FIELDS);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 226 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
diff --git a/Build/source/texk/bibtex8/bibtex-2.c b/Build/source/texk/bibtex8/bibtex-2.c
index 7dbba35a03b..e64d68ef22c 100644
--- a/Build/source/texk/bibtex8/bibtex-2.c
+++ b/Build/source/texk/bibtex8/bibtex-2.c
@@ -898,7 +898,7 @@ BEGIN
name_bf_ptr = name_tok[cur_token];
name_bf_xptr = name_tok[cur_token + 1];
if (ex_buf_length + (name_bf_xptr - name_bf_ptr)
- > BUF_SIZE)
+ > Buf_Size)
BEGIN
buffer_overflow ();
END
@@ -943,7 +943,7 @@ BEGIN
* still by not having a matching |right_brace|).
***************************************************************************/
BEGIN
- if ((ex_buf_ptr + 2) > BUF_SIZE)
+ if ((ex_buf_ptr + 2) > Buf_Size)
BEGIN
buffer_overflow ();
END
@@ -1015,7 +1015,7 @@ Loop_Exit_Label: DO_NOTHING;
else
BEGIN
if ((ex_buf_length + (sp_xptr2 - sp_xptr1))
- > BUF_SIZE)
+ > Buf_Size)
BEGIN
buffer_overflow ();
END
@@ -1337,10 +1337,14 @@ BEGIN
* value.
***************************************************************************/
BEGIN
- if (preamble_ptr == MAX_BIB_FILES)
+ if (preamble_ptr == Max_Bib_Files)
BEGIN
- BIB_ERR2 ("You've exceeded %ld preamble commands",
- (long) MAX_BIB_FILES);
+ BIB_XRETALLOC_NOSET ("bib_file", bib_file, AlphaFile_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
+ BIB_XRETALLOC_NOSET ("bib_list", bib_list, StrNumber_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
+ BIB_XRETALLOC ("s_preamble", s_preamble, StrNumber_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
END
EAT_BIB_WHITE_AND_EOF_CHECK;
if (SCAN_CHAR == LEFT_BRACE)
@@ -2165,7 +2169,7 @@ BEGIN
if (MAX_PRINT_LINE <= MIN_PRINT_LINE)
bad = 10 * bad + 2;
- if (MAX_PRINT_LINE >= BUF_SIZE)
+ if (MAX_PRINT_LINE >= Buf_Size)
bad = 10 * bad + 3;
if (Hash_Prime < 128)
@@ -2196,10 +2200,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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
@@ -2762,7 +2766,7 @@ BEGIN
BEGIN
while ( ! eoln (f))
BEGIN
- if (last >= BUF_SIZE)
+ if (last >= Buf_Size)
BEGIN
buffer_overflow ();
END
@@ -3306,7 +3310,8 @@ END
***************************************************************************/
void pool_overflow (void)
BEGIN
- BIBTEX_OVERFLOW ("pool size ", Pool_Size);
+ BIB_XRETALLOC ("str_pool", str_pool, ASCIICode_T,
+ Pool_Size, Pool_Size + POOL_SIZE);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 53 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
diff --git a/Build/source/texk/bibtex8/bibtex-3.c b/Build/source/texk/bibtex8/bibtex-3.c
index f1438e97927..037d1f0cdf1 100644
--- a/Build/source/texk/bibtex8/bibtex-3.c
+++ b/Build/source/texk/bibtex8/bibtex-3.c
@@ -2060,8 +2060,8 @@ Next_Token_Label:
INSERT_FN_LOC (END_OF_DEF);
if ((single_ptr + wiz_def_ptr) > Wiz_Fn_Space)
BEGIN
- PRINT2 ("%ld: ", (long) (single_ptr + wiz_def_ptr));
- BIBTEX_OVERFLOW ("wizard-defined function space ", Wiz_Fn_Space);
+ BIB_XRETALLOC ("wiz_functions", wiz_functions, HashPtr2_T,
+ Wiz_Fn_Space, Wiz_Fn_Space + WIZ_FN_SPACE);
END
FN_INFO[fn_hash_loc] = wiz_def_ptr;
copy_ptr = 0;
diff --git a/Build/source/texk/bibtex8/bibtex-4.c b/Build/source/texk/bibtex8/bibtex-4.c
index 512a2d7ee7d..1627614cb59 100644
--- a/Build/source/texk/bibtex8/bibtex-4.c
+++ b/Build/source/texk/bibtex8/bibtex-4.c
@@ -1994,6 +1994,7 @@ BEGIN
sp_end = str_start[pop_lit3 + 1] - (pop_lit2 - 1);
sp_ptr = sp_end - pop_lit1;
END
+ STR_ROOM (sp_end - sp_ptr);
while (sp_ptr < sp_end)
BEGIN
APPEND_CHAR (str_pool[sp_ptr]);
diff --git a/Build/source/texk/bibtex8/bibtex.c b/Build/source/texk/bibtex8/bibtex.c
index 52b4fb5c9e9..7bb7e9135bf 100644
--- a/Build/source/texk/bibtex8/bibtex.c
+++ b/Build/source/texk/bibtex8/bibtex.c
@@ -270,7 +270,6 @@ BEGIN
parse_cmd_line (argc, argv);
set_array_sizes ();
- allocate_arrays ();
report_search_paths ();
initialize ();
@@ -446,7 +445,7 @@ Close_Up_Shop_Label:
END
break;
case FATAL_MESSAGE:
- PRINT ("(That was a fatal error)");
+ PRINT_LN ("(That was a fatal error)");
break;
default:
PRINT ("History is bunk");
diff --git a/Build/source/texk/bibtex8/bibtex.h b/Build/source/texk/bibtex8/bibtex.h
index 8ce8b5e752e..57225a9e1e8 100644
--- a/Build/source/texk/bibtex8/bibtex.h
+++ b/Build/source/texk/bibtex8/bibtex.h
@@ -269,14 +269,14 @@
#define BUF_SIZE 10000
#define MAX_CITES 2000
-#define MAX_ENT_INTS 10000
-#define MAX_ENT_STRS 10000
-#define MAX_FIELDS 17250L
+#define MAX_ENT_INTS 3000
+#define MAX_ENT_STRS 3000
+#define MAX_FIELDS 5000
#define MAX_STRINGS 12000
#define POOL_SIZE 65000L
#define MIN_CROSSREFS 2
-#define WIZ_FN_SPACE 5000
+#define WIZ_FN_SPACE 3000
#define SINGLE_FN_SPACE 100
#define ENT_STR_SIZE 250
#define GLOB_STR_SIZE 1000
@@ -980,7 +980,7 @@
* sure it will fit; for use in |int_to_ASCII|.
***************************************************************************/
#define APPEND_INT_CHAR(X) {\
- if (int_ptr == BUF_SIZE)\
+ if (int_ptr == Buf_Size)\
{ buffer_overflow ();}\
int_buf[int_ptr] = (X);\
INCR (int_ptr); }
@@ -1125,7 +1125,7 @@
* will fit; since it's so low level, it's implemented as a macro.
***************************************************************************/
#define COPY_CHAR(X) {\
- if (FIELD_END == BUF_SIZE)\
+ if (FIELD_END == Buf_Size)\
{ BIB_FIELD_TOO_LONG_ERR; }\
else\
{ FIELD_VL_STR[FIELD_END] = (X);\
@@ -1305,7 +1305,7 @@
ex_buf[ex_buf_ptr] = (X);\
INCR(ex_buf_ptr);}
#define APPEND_EX_BUF_CHAR_AND_CHECK(X) {\
- if (ex_buf_ptr == BUF_SIZE) {buffer_overflow ();}; \
+ if (ex_buf_ptr == Buf_Size) {buffer_overflow ();}; \
APPEND_EX_BUF_CHAR(X)}
/***************************************************************************
@@ -1470,5 +1470,29 @@
#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]
+
+/***************************************************************************
+ * WEB section number: N/A
+ * ~~~~~~~~~~~~~~~~~~~
+ * Macros adapted from Kpathsea (lib.h) and Web2C (cpascal.h) to dynamically
+ * resize arrays.
+ ***************************************************************************/
+/* Reallocate N items of type T for ARRAY using myrealloc. */
+#define MYRETALLOC(array, addr, n, t) ((addr) = (t *) myrealloc(addr, (n) * sizeof(t), array))
+/* BibTeX needs this to dynamically reallocate arrays. Too bad we can't
+ rely on stringification, or we could avoid the ARRAY_NAME arg.
+ Actually allocate one more than requests, so we can index the last
+ entry, as Pascal wants to do. */
+#define BIB_XRETALLOC_NOSET(array_name, array_var, type, 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) sizeof (type), new_size, size_var); \
+ MYRETALLOC (array_name, array_var, new_size + 1, type)
+/* Same as above, but also increase SIZE_VAR for the last (or only) array. */
+#define BIB_XRETALLOC(array_name, array_var, type, size_var, new_size) do { \
+ BIB_XRETALLOC_NOSET(array_name, array_var, type, size_var, new_size); \
+ size_var = new_size; \
+} while (0)
+
#endif /* __BIBTEX_H__ */
diff --git a/Build/source/texk/bibtex8/datatype.h b/Build/source/texk/bibtex8/datatype.h
index ab9d2c03127..986d27d1c13 100644
--- a/Build/source/texk/bibtex8/datatype.h
+++ b/Build/source/texk/bibtex8/datatype.h
@@ -147,7 +147,7 @@ typedef Integer16_T AuxNumber_T;
typedef Integer16_T BibNumber_T;
typedef Integer16_T BltInRange_T;
typedef Integer16_T BufPointer_T;
-typedef ASCIICode_T BufType_T[BUF_SIZE + 1];
+typedef ASCIICode_T *BufType_T;
typedef Integer16_T CiteNumber_T;
typedef Integer16_T FieldLoc_T;
typedef Integer8_T FnClass_T;
diff --git a/Build/source/texk/bibtex8/gblvars.h b/Build/source/texk/bibtex8/gblvars.h
index d28672e530c..63bc744df38 100644
--- a/Build/source/texk/bibtex8/gblvars.h
+++ b/Build/source/texk/bibtex8/gblvars.h
@@ -171,7 +171,6 @@ __EXTERN__ AlphaFile_T bst_file;
__EXTERN__ Integer_T bst_line_num;
__EXTERN__ Boolean_T bst_seen;
__EXTERN__ StrNumber_T bst_str;
-__EXTERN__ BufType_T buffer;
__EXTERN__ BufPointer_T buf_ptr1;
__EXTERN__ BufPointer_T buf_ptr2;
@@ -203,7 +202,6 @@ __EXTERN__ CiteNumber_T entry_cite_ptr;
__EXTERN__ Boolean_T entry_seen;
__EXTERN__ HashLoc_T entry_type_loc;
__EXTERN__ Integer_T err_count;
-__EXTERN__ BufType_T ex_buf;
__EXTERN__ BufPointer_T ex_buf_length;
__EXTERN__ BufPointer_T ex_buf_ptr;
__EXTERN__ BufPointer_T ex_buf_xptr;
@@ -265,7 +263,6 @@ __EXTERN__ BufPointer_T num_tokens;
__EXTERN__ Integer8_T number_of_command_line_args;
__EXTERN__ CiteNumber_T old_num_cites;
-__EXTERN__ BufType_T out_buf;
__EXTERN__ BufPointer_T out_buf_length;
__EXTERN__ BufPointer_T out_buf_ptr;
@@ -320,7 +317,6 @@ __EXTERN__ UChar_T str_glb_ptr;
__EXTERN__ Integer_T string_width;
__EXTERN__ StrNumber_T str_num;
__EXTERN__ StrNumber_T str_ptr;
-__EXTERN__ BufType_T sv_buffer;
__EXTERN__ BufPointer_T sv_ptr1;
__EXTERN__ BufPointer_T sv_ptr2;
@@ -357,8 +353,6 @@ __EXTERN__ Integer_T total_ex_count;
__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__ AlphaFile_T bib_file[MAX_BIB_FILES + 1];
-__EXTERN__ StrNumber_T bib_list[MAX_BIB_FILES + 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];
@@ -366,10 +360,7 @@ __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__ ASCIICode_T name_sep_char[BUF_SIZE + 1];
-__EXTERN__ BufPointer_T name_tok[BUF_SIZE + 1];
__EXTERN__ unsigned char name_of_file[FILE_NAME_SIZE + 1];
-__EXTERN__ StrNumber_T s_preamble[MAX_BIB_FILES + 1];
__EXTERN__ unsigned char xchr[LAST_ASCII_CHAR + 1];
__EXTERN__ ASCIICode_T xord[LAST_TEXT_CHAR + 1];
@@ -403,11 +394,15 @@ __EXTERN__ int c8order[LAST_TEXT_CHAR + 1];
** DYNAMICALLY ALLOCATED GLOBAL ARRAYS DECLARED HERE
**----------------------------------------------------------------------------
*/
+__EXTERN__ AlphaFile_T *bib_file;
+__EXTERN__ StrNumber_T *bib_list;
+__EXTERN__ ASCIICode_T *buffer;
__EXTERN__ StrNumber_T *cite_info;
__EXTERN__ StrNumber_T *cite_list;
__EXTERN__ Boolean_T *entry_exists;
__EXTERN__ Integer_T *entry_ints;
__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];
@@ -415,8 +410,13 @@ __EXTERN__ StrIlk_T *hash_ilk;
__EXTERN__ HashPointer_T *hash_next;
__EXTERN__ StrNumber_T *hash_text;
__EXTERN__ Integer_T *ilk_info;
+__EXTERN__ ASCIICode_T *name_sep_char;
+__EXTERN__ BufPointer_T *name_tok;
+__EXTERN__ ASCIICode_T *out_buf;
+__EXTERN__ StrNumber_T *s_preamble;
__EXTERN__ ASCIICode_T *str_pool;
__EXTERN__ PoolPointer_T *str_start;
+__EXTERN__ ASCIICode_T *sv_buffer;
__EXTERN__ HashPtr2_T *type_list;
__EXTERN__ HashPtr2_T *wiz_functions;
@@ -436,13 +436,9 @@ __EXTERN__ Boolean_T Flag_stats;
__EXTERN__ Boolean_T Flag_trace;
__EXTERN__ Boolean_T Flag_wolfgang;
__EXTERN__ Integer_T M_cites;
-__EXTERN__ Integer_T M_entints;
__EXTERN__ Integer_T M_entstrs;
-__EXTERN__ Integer_T M_fields;
__EXTERN__ Integer_T M_min_crossrefs;
-__EXTERN__ Integer_T M_pool;
__EXTERN__ Integer_T M_strings;
-__EXTERN__ Integer_T M_wiz_fn_space;
__EXTERN__ char *Str_auxfile;
__EXTERN__ char *Str_csfile;
@@ -454,8 +450,10 @@ __EXTERN__ char *Str_csfile;
** now be set dynamically from the command line.
**----------------------------------------------------------------------------
*/
+__EXTERN__ Integer_T Buf_Size;
__EXTERN__ Integer_T Hash_Prime;
__EXTERN__ Integer_T Hash_Size;
+__EXTERN__ Integer_T Max_Bib_Files;
__EXTERN__ Integer_T Max_Cites;
__EXTERN__ Integer_T Max_Ent_Ints;
__EXTERN__ Integer_T Max_Ent_Strs;
diff --git a/Build/source/texk/bibtex8/tests/bibtex.test b/Build/source/texk/bibtex8/tests/bibtex.test
new file mode 100755
index 00000000000..7673ba1ef56
--- /dev/null
+++ b/Build/source/texk/bibtex8/tests/bibtex.test
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+# Copyright (C) 2010 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+test -d tests || mkdir -p tests
+
+cp $srcdir/../web2c/tests/exampl.aux tests/xexampl.aux
+
+TEXMFCNF=$srcdir/../kpathsea \
+ BSTINPUTS=$srcdir/../web2c/tests \
+ BIBINPUTS=$srcdir/../web2c/tests \
+ ./bibtex8 -7 tests/xexampl || test $? = 1 || exit 1
+
diff --git a/Build/source/texk/bibtex8/utils.c b/Build/source/texk/bibtex8/utils.c
index df05b868cb8..b3f386cd454 100644
--- a/Build/source/texk/bibtex8/utils.c
+++ b/Build/source/texk/bibtex8/utils.c
@@ -24,15 +24,13 @@
** the program. The functions are declared in alphabetical order.
** Functions defined in this module are:
**
-** allocate_arrays
-** checkdbg
-** checklong
** close_file
** debug_msg
** find_file
** open_ip_file
** open_op_file
** mymalloc
+** myrealloc
** parse_cmd_line
** report_bibtex_capacity
** report_search_paths
@@ -188,12 +186,12 @@ static struct option long_options[] = {
{"min_crossrefs", VALUE_REQD, 0, 'M'},
{"mcites", VALUE_REQD, 0, '\x0A'},
- {"mentints", VALUE_REQD, 0, '\x0B'},
+ {"mentints", VALUE_REQD, 0, '\x0B'}, /* obsolete */
{"mentstrs", VALUE_REQD, 0, '\x0C'},
- {"mfields", VALUE_REQD, 0, '\x0D'},
- {"mpool", VALUE_REQD, 0, '\x0E'},
+ {"mfields", VALUE_REQD, 0, '\x0D'}, /* obsolete */
+ {"mpool", VALUE_REQD, 0, '\x0E'}, /* obsolete */
{"mstrings", VALUE_REQD, 0, '\x0F'},
- {"mwizfuns", VALUE_REQD, 0, '\x10'},
+ {"mwizfuns", VALUE_REQD, 0, '\x10'}, /* obsolete */
{0, 0, 0, 0}
};
@@ -232,25 +230,34 @@ static int sort_weight;
** Allocate memory dynamically for the large arrays whose size is set
** dynamically, depending on the amount memory of memory available.
**
+** AlphaFile_T bib_file[Max_Bib_Files + 1];
+** StrNumber_T bib_list[Max_Bib_Files + 1];
+** ASCIICode_T buffer[Buf_Size + 1];
** StrNumber_T cite_info[Max_Cites + 1];
** StrNumber_T cite_list[Max_Cites + 1];
** Boolean_T entry_exists[Max_Cites + 1];
-** Integer_T entry_ints[Max_Ent_Ints + 1];
+** Integer_T entry_ints[Max_Ent_Ints + 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];
-** 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];
-** ASCIICode_T str_pool[Pool_Size + 1];
-** PoolPointer_T str_start[Max_Strings + 1];
+** FnClass_T fn_type[Hash_Size + 1];
+** ASCIICode_T global_strs[MAX_GLOB_STRS + 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];
+** ASCIICode_T name_sep_char[Buf_Size + 1];
+** BufPointer_T name_tok[Buf_Size + 1];
+** ASCIICode_T out_buf[Buf_Size + 1];
+** StrNumber_T s_preamble[Max_Bib_Files + 1];
+** ASCIICode_T str_pool[Pool_Size + 1];
+** PoolPointer_T str_start[Max_Strings + 1];
+** ASCIICode_T sv_buffer[Buf_Size + 1];
** HashPtr2_T type_list[Max_Cites + 1];
-** HashPtr2_T wiz_functions[Wiz_Fn_Space + 1];
+** HashPtr2_T wiz_functions[Wiz_Fn_Space + 1];
**============================================================================
*/
-void allocate_arrays (void)
+static void allocate_arrays (void)
{
unsigned long bytes_required;
ASCIICode_T *dummy_ptr;
@@ -259,6 +266,24 @@ void allocate_arrays (void)
debug_msg (DBG_MEM, "Starting to allocate memory for arrays ... ");
/*
+ ** AlphaFile_T bib_file[Max_Bib_Files + 1];
+ */
+ bytes_required = (Max_Bib_Files + 1) * (unsigned long) sizeof (AlphaFile_T);
+ bib_file = (AlphaFile_T *) mymalloc (bytes_required, "bib_file");
+
+ /*
+ ** StrNumber_T bib_list[Max_Bib_Files + 1];
+ */
+ bytes_required = (Max_Bib_Files + 1) * (unsigned long) sizeof (StrNumber_T);
+ bib_list = (StrNumber_T *) mymalloc (bytes_required, "bib_list");
+
+ /*
+ ** ASCIICode_T buffer[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
+ buffer = (ASCIICode_T *) mymalloc (bytes_required, "buffer");
+
+ /*
** StrNumber_T cite_info[Max_Cites + 1];
*/
bytes_required = (Max_Cites + 1) * (unsigned long) sizeof (StrNumber_T);
@@ -291,6 +316,11 @@ void allocate_arrays (void)
entry_strs = (ASCIICode_T *) mymalloc (bytes_required, "entry_strs");
+ /*
+ ** ASCIICode_T ex_buf[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
+ ex_buf = (ASCIICode_T *) mymalloc (bytes_required, "ex_buf");
/*
** StrNumber_T field_info[Max_Fields + 1];
@@ -310,7 +340,6 @@ void allocate_arrays (void)
bytes_required = (unsigned long) (MAX_GLOB_STRS)
* (GLOB_STR_SIZE + 1)
* (unsigned long) sizeof (ASCIICode_T);
- dummy_ptr = (ASCIICode_T *) NULL;
dummy_ptr = (ASCIICode_T *) mymalloc (bytes_required, "global_strs");
for (row = 0; row < (MAX_GLOB_STRS + 1); row++) {
@@ -342,6 +371,30 @@ void allocate_arrays (void)
ilk_info = (Integer_T *) mymalloc (bytes_required, "ilk_info");
/*
+ ** ASCIICode_T name_sep_char[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
+ name_sep_char = (ASCIICode_T *) mymalloc (bytes_required, "name_sep_char");
+
+ /*
+ ** BufPointer_T name_tok[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (BufPointer_T);
+ name_tok = (BufPointer_T *) mymalloc (bytes_required, "name_tok");
+
+ /*
+ ** ASCIICode_T out_buf[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
+ out_buf = (ASCIICode_T *) mymalloc (bytes_required, "out_buf");
+
+ /*
+ ** StrNumber_T s_preamble[Max_Bib_Files + 1];
+ */
+ bytes_required = (Max_Bib_Files + 1) * (unsigned long) sizeof (StrNumber_T);
+ s_preamble = (StrNumber_T *) mymalloc (bytes_required, "s_preamble");
+
+ /*
** ASCIICode_T str_pool[Pool_Size + 1];
*/
bytes_required = (Pool_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
@@ -354,6 +407,12 @@ void allocate_arrays (void)
str_start = (PoolPointer_T *) mymalloc (bytes_required, "str_start");
/*
+ ** ASCIICode_T sv_buffer[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
+ sv_buffer = (ASCIICode_T *) mymalloc (bytes_required, "sv_buffer");
+
+ /*
** HashPtr2_T type_list[Max_Cites + 1];
*/
bytes_required = (Max_Cites + 1) * (unsigned long) sizeof (HashPtr2_T);
@@ -378,7 +437,7 @@ void allocate_arrays (void)
** integer. Return 0 (no debugging) if a valid option was not parsed.
**============================================================================
*/
-int checkdbg (char *str)
+static int checkdbg (char *str)
{
int dbgval = 0;
@@ -412,7 +471,7 @@ int checkdbg (char *str)
** Return -1 if a valid integer was not parsed.
**============================================================================
*/
-long checklong (char *str)
+static long checklong (char *str)
{
long value;
char *endptr;
@@ -616,13 +675,14 @@ int find_file (const char *envvar_name, const char *fallback_path,
** Allocate memory for a specified array and check whether the allocation
** was successful. If not, issue an error message and cause the program
** to stop with a fatal exit status.
+** Allocate at least 1 byte, otherwise malloc may return NULL.
**============================================================================
*/
void *mymalloc (const unsigned long bytes_required, const char *array_name)
{
void *ptr;
- ptr = malloc (bytes_required);
+ ptr = malloc (bytes_required ? bytes_required : 1);
if (ptr == NULL) {
printf ("\nFatal error: couldn't allocate %lu bytes for array `%s'",
@@ -642,6 +702,41 @@ void *mymalloc (const unsigned long bytes_required, const char *array_name)
/*-
**============================================================================
+** myrealloc()
+**
+** Reallocate memory for a specified array and check whether the allocation
+** was successful. If not, issue an error message and cause the program
+** to stop with a fatal exit status.
+** Allocate at least 1 byte, otherwise realloc may return NULL.
+**============================================================================
+*/
+void *myrealloc (void *old_ptr, const unsigned long bytes_required, const char *array_name)
+{
+ void *ptr;
+
+ if (old_ptr == NULL)
+ return mymalloc (bytes_required, array_name);
+
+ ptr = realloc (old_ptr, bytes_required ? bytes_required : 1);
+
+ if (ptr == NULL) {
+ printf ("\nFatal error: couldn't reallocate %lu bytes for array `%s'",
+ bytes_required, array_name);
+ mark_fatal ();
+ debug_msg (DBG_MISC, "calling longjmp (Exit_Program_Flag) ... ");
+ longjmp (Exit_Program_Flag, 1);
+ } else {
+ debug_msg (DBG_MEM, "reallocated %7lu bytes for array `%s'",
+ bytes_required, array_name);
+ }
+
+ return (ptr);
+} /* myrealloc () */
+
+
+
+/*-
+**============================================================================
** open_ip_file()
**
** Open a file for input after locating it using one of the five predefined
@@ -845,12 +940,12 @@ FILE *open_op_file (void)
** referenced entry in the citation list
** (default = 2)
** --mcites ## allow ## \\cites in the .aux files
-** --mentints ## allow ## integer entries in the .bib databases
+** --mentints ## ignored
** --mentstrs ## allow ## string entries in the .bib databases
-** --mfields ## allow ## fields in the .bib databases
-** --mpool ## set the string pool to ## bytes
+** --mfields ## ignored
+** --mpool ## ignored
** --mstrings ## allow ## unique strings
-** --mwizfuns ## allow ## wizard functions
+** --mwizfuns ## ignored
**============================================================================
*/
void parse_cmd_line (int argc, char **argv)
@@ -947,12 +1042,7 @@ void parse_cmd_line (int argc, char **argv)
break;
case '\x0B': /**************** --mentints ***************/
- M_entints = checklong (optarg);
- if (M_entints < 0) {
- mark_fatal ();
- usage ("invalid max number of integer entries `%s'\n",
- optarg);
- }
+ (void) checklong (optarg); /******** ignored ********/
break;
case '\x0C': /**************** --mentstrs ***************/
@@ -965,19 +1055,8 @@ void parse_cmd_line (int argc, char **argv)
break;
case '\x0D': /**************** --mfields ****************/
- M_fields = checklong (optarg);
- if (M_fields < 0) {
- mark_fatal ();
- usage ("invalid max number of fields `%s'\n", optarg);
- }
- break;
-
case '\x0E': /**************** --mpool *****************/
- M_pool = checklong (optarg);
- if (M_pool < 0) {
- mark_fatal ();
- usage ("invalid pool size `%s'\n", optarg);
- }
+ (void) checklong (optarg); /******** ignored ********/
break;
case '\x0F': /**************** --mstrings ***************/
@@ -989,11 +1068,7 @@ void parse_cmd_line (int argc, char **argv)
break;
case '\x10': /**************** --mwizfuns ***************/
- M_wiz_fn_space = checklong (optarg);
- if (M_wiz_fn_space < 0) {
- mark_fatal ();
- usage ("invalid max wizard functions `%s'\n", optarg);
- }
+ (void) checklong (optarg); /******** ignored ********/
break;
default: /**************** Unknown argument ********/
@@ -1094,14 +1169,14 @@ void report_bibtex_capacity (void)
if (log_file != NULL) {
FPRINTF (log_file, "BibTeX's capacity set as follows:\n\n");
LOG_CAPACITY (AUX_STACK_SIZE);
- LOG_CAPACITY (BUF_SIZE);
+ LOG_CAPACITY (Buf_Size);
LOG_CAPACITY (ENT_STR_SIZE);
LOG_CAPACITY (FILE_NAME_SIZE);
LOG_CAPACITY (GLOB_STR_SIZE);
LOG_CAPACITY (Hash_Prime);
LOG_CAPACITY (Hash_Size);
LOG_CAPACITY (LIT_STK_SIZE);
- LOG_CAPACITY (MAX_BIB_FILES);
+ LOG_CAPACITY (Max_Bib_Files);
LOG_CAPACITY (Max_Cites);
LOG_CAPACITY (Max_Ent_Ints);
LOG_CAPACITY (Max_Ent_Strs);
@@ -1169,6 +1244,55 @@ void report_search_paths (void)
} /* report_search_paths() */
+/*-
+**============================================================================
+** compute_hash_prime()
+**
+** We use the algorithm from Knuth's \.{primes.web} to compute
+** |hash_prime| as the smallest prime number not less than 85\%
+** of |hash_size| (and |>=128|).
+**
+** 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
+#define mult hash_text
+static void compute_hash_prime (void)
+{
+ Integer32_T Hash_Want = (Hash_Size / 20) * 17; /* 85\% of |hash_size| */
+ Integer32_T k = 1; /*number of prime numbers $p_i$ in |primes| */
+ Integer32_T j = 1; /* a prime number candidate */
+ Integer32_T o = 2; /* number of odd multiples of primes in |mult| */
+ Integer32_T square = 9; /* $p_o^2$ */
+ Integer32_T n; /* loop index */
+ Boolean_T j_prime; /* is |j| a prime? */
+
+ debug_msg (DBG_MEM, "Computing Hash_Prime ... ");
+
+ primes[k] = Hash_Prime = 2;
+ while (Hash_Prime < Hash_Want) {
+ do {
+ j += 2;
+ if (j == square) {
+ mult[o++] = j;
+ j += 2;
+ square = primes[o] * primes[o];
+ }
+ n = 2;
+ j_prime = TRUE;
+ while ((n < o) && j_prime) {
+ while (mult[n] < j)
+ mult[n] += 2 * primes[n];
+ if (mult[n++] == j)
+ j_prime = FALSE;
+ }
+ } while (!j_prime);
+ primes[++k] = Hash_Prime = j;
+ }
+}
+
/*-
**============================================================================
@@ -1183,15 +1307,17 @@ void report_search_paths (void)
**
** Parameter Cmd Standard --big --huge --wolfgang
** ------------------------------------------------------------------
-** Hash_Prime N 4,253 8,501 16,319 30,011
-** Hash_Size N 5,000 10,000 19,000 35,000
+** Buf_Size *** initialy 20000, increased as required ***
+** Hash_Prime *** computed from Hash_Size ***
+** Hash_Size *** determined from Max_Strings ***
+** Max_Bib_Files *** initialy 20, increased as required ***
** Max_Cites Y 750 2,000 5,000 7,500
-** Max_Ent_Ints Y 3,000 4,000 5,000 7,500
+** Max_Ent_Ints *** initialy 3000, increased as required ***
** Max_Ent_Strs Y 3,000 6,000 10,000 10,000
-** Max_Fields Y 17,250 30,000 85,000 125,000
+** Max_Fields *** initialy 5000, increased as required ***
** Max_Strings Y 4,000 10,000 19,000 30,000
-** Pool_Size Y 65,530 130,000 500,000 750,000
-** Wiz_Fn_Space Y 3,000 6,000 10,000 10,000
+** Pool_Size *** initialy 65,000, increased as required ***
+** Wiz_Fn_Space *** initialy 3000, increased as required ***
** ------------------------------------------------------------------
**
**============================================================================
@@ -1200,80 +1326,67 @@ void set_array_sizes (void)
{
debug_msg (DBG_MEM, "Setting BibTeX's capacity ... ");
- Hash_Prime = 4253;
- Hash_Size = 5000;
Max_Cites = 750;
- Max_Ent_Ints = 3000;
Max_Ent_Strs = 3000;
- Max_Fields = 17250;
Max_Strings = 4000;
Min_Crossrefs = 2;
- Pool_Size = 65530;
- Wiz_Fn_Space = 3000;
if (Flag_big) {
- Hash_Prime = 8501;
- Hash_Size = 10000;
Max_Cites = 2000;
- Max_Ent_Ints = 3000;
Max_Ent_Strs = 5000;
- Max_Fields = 30000;
Max_Strings = 10000;
- Pool_Size = 130000;
- Wiz_Fn_Space = 6000;
}
if (Flag_huge) {
- Hash_Prime = 16319;
- Hash_Size = 19000;
Max_Cites = 5000;
- Max_Ent_Ints = 5000;
Max_Ent_Strs = 10000;
- Max_Fields = 85000L;
Max_Strings = 19000;
- Pool_Size = 500000L;
- Wiz_Fn_Space = 10000;
}
if (Flag_wolfgang) {
- Hash_Prime = 30011;
- Hash_Size = 35000;
Max_Cites = 7500;
- Max_Ent_Ints = 7500;
Max_Ent_Strs = 10000;
- Max_Fields = 125000L;
Max_Strings = 30000;
- Pool_Size = 750000L;
- Wiz_Fn_Space = 10000;
}
+ Buf_Size = BUF_SIZE;
+
+ Max_Bib_Files = MAX_BIB_FILES;
+
if (M_cites > 0)
Max_Cites = M_cites;
- if (M_entints > 0)
- Max_Ent_Ints = M_entints;
+ Max_Ent_Ints = MAX_ENT_INTS;
if (M_entstrs > 0)
Max_Ent_Strs = M_entstrs;
- if (M_fields > 0)
- Max_Fields = M_fields;
+ Max_Fields = MAX_FIELDS;
if (M_min_crossrefs > 0)
Min_Crossrefs = M_min_crossrefs;
- if (M_pool > 0)
- Pool_Size = M_pool;
+ Pool_Size = POOL_SIZE;
if (M_strings > 0)
- Max_Strings = M_strings ;
+ 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;
+
- if (M_wiz_fn_space > 0)
- Wiz_Fn_Space = M_wiz_fn_space;
+ allocate_arrays ();
+ compute_hash_prime ();
debug_msg (DBG_MEM, "Hash_Prime = %d, Hash_Size = %d",
Hash_Prime, Hash_Size);
+ debug_msg (DBG_MEM, "Buf_Size = %d, Max_Bib_Files = %d",
+ Buf_Size, Max_Bib_Files);
debug_msg (DBG_MEM, "Max_Cites = %d, Max_Ent_Ints = %d",
Max_Cites, Max_Ent_Ints);
debug_msg (DBG_MEM, "Max_Ent_Strs = %d, Max_Fields = %d",
@@ -1346,7 +1459,7 @@ void usage (const char *printf_fmt, ...)
fprintf (stderr, "\n");
}
- FSO ("\nUsage: bibtex [options] aux-file\n\n");
+ FSO ("\nUsage: bibtex8 [options] aux-file\n\n");
FSO (" Valid options are:\n\n");
FSO (" -? --help display this help text\n");
FSO (" -7 --traditional operate in the original 7-bit mode\n");
@@ -1374,12 +1487,8 @@ void usage (const char *printf_fmt, ...)
FSO (" -W --wolfgang set really huge BibTeX capacity for Wolfgang\n");
FSO (" -M --min_crossrefs ## set min_crossrefs to ##\n");
FSO (" --mcites ## allow ## \\cites in the .aux files\n");
- FSO (" --mentints ## allow ## integer entries in the .bib databases\n");
FSO (" --mentstrs ## allow ## string entries in the .bib databases\n");
- FSO (" --mfields ## allow ## fields in the .bib databases\n");
- FSO (" --mpool ## set the string pool to ## bytes\n");
FSO (" --mstrings ## allow ## unique strings\n");
- FSO (" --mwizfuns ## allow ## wizard functions\n");
debug_msg (DBG_MISC, "calling longjmp (Exit_Program_Flag) ... ");
longjmp (Exit_Program_Flag, 1);
@@ -1583,7 +1692,9 @@ int c8read_csf (void)
{
int c, i;
int in_comment;
- char sx[BUF_SIZE + 1];
+#define SX_BUF_SIZE 15
+ /* a section name: "order", "uppercase", "lowercase", or "lowupcase". */
+ char sx[SX_BUF_SIZE + 1];
#ifndef KPATHSEA
char *value;
#endif
@@ -1706,7 +1817,7 @@ int c8read_csf (void)
sx[i++] = c;
else
break;
- } while (!feof (c8_cs_file) && (i < BUF_SIZE));
+ } while (!feof (c8_cs_file) && (i < SX_BUF_SIZE));
sx[i] = '\0';
/*
diff --git a/Build/source/texk/bibtex8/utils.h b/Build/source/texk/bibtex8/utils.h
index 7d0a0bf095a..f75e0760bff 100644
--- a/Build/source/texk/bibtex8/utils.h
+++ b/Build/source/texk/bibtex8/utils.h
@@ -104,9 +104,6 @@
/*
** Declaration of public functions defined in utils.c
*/
-void allocate_arrays (void);
-int checkdbg (char *str);
-long checklong (char *str);
void close_file (const AlphaFile_T file_pointer);
void CDECL debug_msg (const int status, const char *printf_fmt, ...);
#ifndef KPATHSEA
@@ -118,6 +115,8 @@ FILE *open_ip_file (Integer_T search_path);
FILE *open_op_file (void);
void *mymalloc (const unsigned long bytes_required,
const char *var_name);
+void *myrealloc (void *old_ptr, const unsigned long bytes_required,
+ const char *var_name);
void parse_cmd_line (int argc, char **argv);
void report_bibtex_capacity (void);
void report_search_paths (void);
diff --git a/Build/source/texk/bibtexu/ChangeLog b/Build/source/texk/bibtexu/ChangeLog
index 19e412a3862..9167bc45137 100644
--- a/Build/source/texk/bibtexu/ChangeLog
+++ b/Build/source/texk/bibtexu/ChangeLog
@@ -1,3 +1,61 @@
+2010-03-15 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * tests/bibtex.test: New shell script to test 7-bit mode.
+ * Makefile.am (TESTS, EXTRA_DIST, DISTCLEANFILES): Adapted.
+
+ * bibtex-1.c, bibtex-2.c: Reallocate bib_file, bib_list, and
+ s_preamble as needed.
+
+ * datatype.h (BufType_T): Declare as pointer instead of array.
+ * gblvars.h, utils.c: Dynamically allocate buffer, ex_buf,
+ out_buf, and sv_buffer.
+ * bibtex-1.c (add_out_pool): Call buffer_overflow to reallocate.
+ (buffer_overflow): Reallocate buffer, ex_buf, name_sep_char,
+ name_tok, out_buf, and sv_buffer as needed.
+
+ * utils.c (c8read_csf): Drastically reduce sx array size.
+
+2010-03-14 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * bibtex-1.c: Reallocate entry_ints, field_info as needed.
+ * bibtex-3.c: Reallocate wiz_functions as needed.
+ * gblvars.h, utils.c: Dynamically allocate bib_file, bib_list,
+ name_sep_char, name_tok, and s_preamble.
+ * gblvars.h (M_entints, M_fields, M_wiz_fn_space): Removed.
+ * utils.c (parse_cmd_line, usage): Ignore/remove --mentints,
+ --mfields, and --mwizfuns.
+
+ * bibtex-4.c: Added check for str_pool overflow (from bibtex).
+
+ * gblvars.h (Buf_Size, Max_Bib_Files): New global vars.
+ * utils.c: Set Buf_Size=BUF_SIZE, Max_Bib_Files=MAX_BIB_FILES.
+ Allocate bib_file, bib_list, name_sep_char, name_tok, and
+ s_preamble.[A
+ * bibtex-1.c, bibtex-2.c: Use Buf_Size and Max_Bib_Files.
+
+2010-03-13 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ Dynamic allocation of arrays.
+ * bibtex.h (MYRETALLOC, BIB_XRETALLOC, BIB_XRETALLOC_NOSET):
+ Preprocessor macros used to reallocate arrays.
+ * utils.[ch] (myrealloc): New function.
+ (mymalloc, myrealloc): Allocate at least 1 byte, to avoid NULL.
+ (checkdbg, checklong): Declare as static.
+
+ * bibtex-2.c (pool_overflow): Reallocate str_pool as needed.
+ * gblvars.h (M_pool): Removed.
+ * utils.c (parse_cmd_line, usage): Ignore/remove --mpool.
+
+2010-03-12 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ Determine hash_size from max_strings and compute hash_prime.
+ * bibtex.c (main): Don't call allocate_arrays.
+ Print newline after fatal error message.
+ * utils.c (allocate_arrays): Declare as static.
+ (compute_hash_prime): New function, using allocated arrays.
+ (set_array_sizes): Call allocate_arrays and compute_hash_prime.
+ * utils.h (allocate_arrays): Remove.
+
2010-03-10 Peter Breitenlohner <peb@mppmu.mpg.de>
* bibtex.h: Adapt to bibtex.web final 0.99d from Oren.
diff --git a/Build/source/texk/bibtexu/Makefile.am b/Build/source/texk/bibtexu/Makefile.am
index eb82edbd396..cc535b4c766 100644
--- a/Build/source/texk/bibtexu/Makefile.am
+++ b/Build/source/texk/bibtexu/Makefile.am
@@ -64,9 +64,18 @@ dist_btdoc_DATA = \
csfile.txt \
file_id.diz
+## Tests.
+##
+TESTS = tests/bibtex.test
+EXTRA_DIST = $(TESTS)
+DISTCLEANFILES =
+
+## bibtex.test
+DISTCLEANFILES += tests/xexampl.aux tests/xexampl.bbl tests/xexampl.blg
+
## Not used
##
-EXTRA_DIST = \
+EXTRA_DIST += \
bt371csf.zip \
dos-dj.mak \
dos-emx.mak \
diff --git a/Build/source/texk/bibtexu/Makefile.in b/Build/source/texk/bibtexu/Makefile.in
index 054d9c0ce8f..ab32d8502fa 100644
--- a/Build/source/texk/bibtexu/Makefile.in
+++ b/Build/source/texk/bibtexu/Makefile.in
@@ -127,6 +127,8 @@ am__base_list = \
DATA = $(dist_btdoc_DATA) $(dist_csf_DATA)
ETAGS = etags
CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@@ -308,17 +310,11 @@ dist_btdoc_DATA = \
csfile.txt \
file_id.diz
-EXTRA_DIST = \
- bt371csf.zip \
- dos-dj.mak \
- dos-emx.mak \
- os2.mak \
- unix.mak \
- csf/00readme.txt \
- csf/COPYING \
- csf/HISTORY \
+TESTS = tests/bibtex.test
+EXTRA_DIST = $(TESTS) bt371csf.zip dos-dj.mak dos-emx.mak os2.mak \
+ unix.mak csf/00readme.txt csf/COPYING csf/HISTORY \
csf/file_id.diz
-
+DISTCLEANFILES = tests/xexampl.aux tests/xexampl.bbl tests/xexampl.blg
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -579,6 +575,98 @@ GTAGS:
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@@ -727,6 +815,7 @@ distcleancheck: distclean
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile $(PROGRAMS) $(DATA) config.h
installdirs:
@@ -754,6 +843,7 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@@ -832,10 +922,10 @@ ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-dist_btdocDATA \
uninstall-dist_csfDATA
-.MAKE: all install-am install-strip
+.MAKE: all check-am install-am install-strip
-.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
- clean-binPROGRAMS clean-generic clean-libtool ctags dist \
+.PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \
+ clean clean-binPROGRAMS clean-generic clean-libtool ctags dist \
dist-all dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ \
dist-xz dist-zip distcheck distclean distclean-compile \
distclean-generic distclean-hdr distclean-libtool \
diff --git a/Build/source/texk/bibtexu/bibtex-1.c b/Build/source/texk/bibtexu/bibtex-1.c
index cc29f1c2cf4..5f575fc353e 100644
--- a/Build/source/texk/bibtexu/bibtex-1.c
+++ b/Build/source/texk/bibtexu/bibtex-1.c
@@ -208,7 +208,7 @@ void add_buf_pool (StrNumber_T p_str)
BEGIN
p_ptr1 = str_start[p_str];
p_ptr2 = str_start[p_str + 1];
- if ((ex_buf_length + (p_ptr2 - p_ptr1)) > BUF_SIZE)
+ if ((ex_buf_length + (p_ptr2 - p_ptr1)) > Buf_Size)
BEGIN
buffer_overflow ();
END
@@ -309,9 +309,9 @@ BEGIN
p_ptr1 = str_start[p_str];
p_ptr2 = str_start[p_str + 1];
- if ((out_buf_length + (p_ptr2 - p_ptr1)) > BUF_SIZE)
+ if ((out_buf_length + (p_ptr2 - p_ptr1)) > Buf_Size)
BEGIN
- BIBTEX_OVERFLOW ("output buffer size ", BUF_SIZE);
+ buffer_overflow ();
END
out_buf_ptr = out_buf_length;
while (p_ptr1 < p_ptr2)
@@ -507,9 +507,14 @@ BEGIN
* the |s_bib_extension| string, the resulting file name can be opened.
***************************************************************************/
BEGIN
- if (bib_ptr == MAX_BIB_FILES)
+ if (bib_ptr == Max_Bib_Files)
BEGIN
- BIBTEX_OVERFLOW ("number of database files ", MAX_BIB_FILES);
+ BIB_XRETALLOC_NOSET ("bib_file", bib_file, AlphaFile_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
+ BIB_XRETALLOC_NOSET ("bib_list", bib_list, StrNumber_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
+ BIB_XRETALLOC ("s_preamble", s_preamble, StrNumber_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
END
CUR_BIB_STR = hash_text[str_lookup (buffer, buf_ptr1, TOKEN_LEN,
BIB_FILE_ILK, DO_INSERT)];
@@ -1126,7 +1131,7 @@ END
***************************************************************************/
void bib_field_too_long_print (void)
BEGIN
- BIB_ERR2 ("Your field is more than %ld characters", (long) BUF_SIZE);
+ BIB_ERR2 ("Your field is more than %ld characters", (long) Buf_Size);
Exit_Label: DO_NOTHING;
END
@@ -2357,8 +2362,8 @@ BEGIN
BEGIN
if ((num_ent_ints * num_cites) > Max_Ent_Ints)
BEGIN
- PRINT2 ("%ld: ", (long) (num_ent_ints * num_cites));
- BIBTEX_OVERFLOW ("total number of integer entry-variables ", Max_Ent_Ints);
+ BIB_XRETALLOC ("entry_ints", entry_ints, Integer_T,
+ Max_Ent_Ints, (long) (num_ent_ints + 1) * (num_cites + 1));
END
int_ent_ptr = 0;
while (int_ent_ptr < (num_ent_ints * num_cites))
@@ -2662,7 +2667,18 @@ END
***************************************************************************/
void buffer_overflow (void)
BEGIN
- BIBTEX_OVERFLOW ("buffer size ", BUF_SIZE);
+ BIB_XRETALLOC_NOSET ("buffer", buffer, ASCIICode_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
+ BIB_XRETALLOC_NOSET ("ex_buf", ex_buf, ASCIICode_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
+ BIB_XRETALLOC_NOSET ("name_sep_char", name_sep_char, ASCIICode_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
+ BIB_XRETALLOC_NOSET ("name_tok", name_tok, BufPointer_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
+ BIB_XRETALLOC_NOSET ("out_buf", out_buf, ASCIICode_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
+ BIB_XRETALLOC ("sv_buffer", sv_buffer, ASCIICode_T,
+ Buf_Size, Buf_Size + BUF_SIZE);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 46 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
@@ -2795,8 +2811,8 @@ void check_field_overflow (Integer_T total_fields)
BEGIN
if (total_fields > Max_Fields)
BEGIN
- PRINT_LN2 ("%ld fields:", (long) total_fields);
- BIBTEX_OVERFLOW ("total number of fields ", Max_Fields);
+ BIB_XRETALLOC ("field_info", field_info, StrNumber_T,
+ Max_Fields, Max_Fields + MAX_FIELDS);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 226 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
diff --git a/Build/source/texk/bibtexu/bibtex-2.c b/Build/source/texk/bibtexu/bibtex-2.c
index 4a3b4e7b73e..d6e25a10b6d 100644
--- a/Build/source/texk/bibtexu/bibtex-2.c
+++ b/Build/source/texk/bibtexu/bibtex-2.c
@@ -910,7 +910,7 @@ BEGIN
name_bf_ptr = name_tok[cur_token];
name_bf_xptr = name_tok[cur_token + 1];
if (ex_buf_length + (name_bf_xptr - name_bf_ptr)
- > BUF_SIZE)
+ > Buf_Size)
BEGIN
buffer_overflow ();
END
@@ -988,7 +988,7 @@ For output the first character which is encodage UTF-8, we sould discuter differ
* still by not having a matching |right_brace|).
***************************************************************************/
BEGIN
- if ((ex_buf_ptr + 2) > BUF_SIZE)
+ if ((ex_buf_ptr + 2) > Buf_Size)
BEGIN
buffer_overflow ();
END
@@ -1060,7 +1060,7 @@ Loop_Exit_Label: DO_NOTHING;
else
BEGIN
if ((ex_buf_length + (sp_xptr2 - sp_xptr1))
- > BUF_SIZE)
+ > Buf_Size)
BEGIN
buffer_overflow ();
END
@@ -1383,10 +1383,14 @@ BEGIN
* value.
***************************************************************************/
BEGIN
- if (preamble_ptr == MAX_BIB_FILES)
+ if (preamble_ptr == Max_Bib_Files)
BEGIN
- BIB_ERR2 ("You've exceeded %ld preamble commands",
- (long) MAX_BIB_FILES);
+ BIB_XRETALLOC_NOSET ("bib_file", bib_file, AlphaFile_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
+ BIB_XRETALLOC_NOSET ("bib_list", bib_list, StrNumber_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
+ BIB_XRETALLOC ("s_preamble", s_preamble, StrNumber_T,
+ Max_Bib_Files, Max_Bib_Files + MAX_BIB_FILES);
END
EAT_BIB_WHITE_AND_EOF_CHECK;
if (SCAN_CHAR == LEFT_BRACE)
@@ -2211,7 +2215,7 @@ BEGIN
if (MAX_PRINT_LINE <= MIN_PRINT_LINE)
bad = 10 * bad + 2;
- if (MAX_PRINT_LINE >= BUF_SIZE)
+ if (MAX_PRINT_LINE >= Buf_Size)
bad = 10 * bad + 3;
if (Hash_Prime < 128)
@@ -2242,10 +2246,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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
@@ -2808,7 +2812,7 @@ BEGIN
BEGIN
while ( ! eoln (f))
BEGIN
- if (last >= BUF_SIZE)
+ if (last >= Buf_Size)
BEGIN
buffer_overflow ();
END
@@ -3553,7 +3557,8 @@ END
***************************************************************************/
void pool_overflow (void)
BEGIN
- BIBTEX_OVERFLOW ("pool size ", Pool_Size);
+ BIB_XRETALLOC ("str_pool", str_pool, ASCIICode_T,
+ Pool_Size, Pool_Size + POOL_SIZE);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 53 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
diff --git a/Build/source/texk/bibtexu/bibtex-3.c b/Build/source/texk/bibtexu/bibtex-3.c
index b6805fe1a03..bc02cf14b6b 100644
--- a/Build/source/texk/bibtexu/bibtex-3.c
+++ b/Build/source/texk/bibtexu/bibtex-3.c
@@ -2068,8 +2068,8 @@ Next_Token_Label:
INSERT_FN_LOC (END_OF_DEF);
if ((single_ptr + wiz_def_ptr) > Wiz_Fn_Space)
BEGIN
- PRINT2 ("%ld: ", (long) (single_ptr + wiz_def_ptr));
- BIBTEX_OVERFLOW ("wizard-defined function space ", Wiz_Fn_Space);
+ BIB_XRETALLOC ("wiz_functions", wiz_functions, HashPtr2_T,
+ Wiz_Fn_Space, Wiz_Fn_Space + WIZ_FN_SPACE);
END
FN_INFO[fn_hash_loc] = wiz_def_ptr;
copy_ptr = 0;
diff --git a/Build/source/texk/bibtexu/bibtex-4.c b/Build/source/texk/bibtexu/bibtex-4.c
index c47d992c9af..6119dd5542e 100644
--- a/Build/source/texk/bibtexu/bibtex-4.c
+++ b/Build/source/texk/bibtexu/bibtex-4.c
@@ -2267,6 +2267,7 @@ BEGIN
END
+ STR_ROOM (sp_end - sp_ptr);
while (sp_ptr < sp_end)
BEGIN
APPEND_CHAR (str_pool[sp_ptr]);
diff --git a/Build/source/texk/bibtexu/bibtex.c b/Build/source/texk/bibtexu/bibtex.c
index 7cd1a86fdae..63b4103bceb 100644
--- a/Build/source/texk/bibtexu/bibtex.c
+++ b/Build/source/texk/bibtexu/bibtex.c
@@ -281,7 +281,6 @@ BEGIN
parse_cmd_line (argc, argv);
set_array_sizes ();
- allocate_arrays ();
report_search_paths ();
initialize ();
@@ -457,7 +456,7 @@ Close_Up_Shop_Label:
END
break;
case FATAL_MESSAGE:
- PRINT ("(That was a fatal error)");
+ PRINT_LN ("(That was a fatal error)");
break;
default:
PRINT ("History is bunk");
diff --git a/Build/source/texk/bibtexu/bibtex.h b/Build/source/texk/bibtexu/bibtex.h
index 8110c6319ed..416387a7dea 100644
--- a/Build/source/texk/bibtexu/bibtex.h
+++ b/Build/source/texk/bibtexu/bibtex.h
@@ -269,14 +269,14 @@
#define BUF_SIZE 10000
#define MAX_CITES 2000
-#define MAX_ENT_INTS 10000
-#define MAX_ENT_STRS 10000
-#define MAX_FIELDS 17250L
+#define MAX_ENT_INTS 3000
+#define MAX_ENT_STRS 3000
+#define MAX_FIELDS 5000
#define MAX_STRINGS 12000
#define POOL_SIZE 65000L
#define MIN_CROSSREFS 2
-#define WIZ_FN_SPACE 5000
+#define WIZ_FN_SPACE 3000
#define SINGLE_FN_SPACE 100
#define ENT_STR_SIZE 250
#define GLOB_STR_SIZE 1000
@@ -980,7 +980,7 @@
* sure it will fit; for use in |int_to_ASCII|.
***************************************************************************/
#define APPEND_INT_CHAR(X) {\
- if (int_ptr == BUF_SIZE)\
+ if (int_ptr == Buf_Size)\
{ buffer_overflow ();}\
int_buf[int_ptr] = (X);\
INCR (int_ptr); }
@@ -1125,7 +1125,7 @@
* will fit; since it's so low level, it's implemented as a macro.
***************************************************************************/
#define COPY_CHAR(X) {\
- if (FIELD_END == BUF_SIZE)\
+ if (FIELD_END == Buf_Size)\
{ BIB_FIELD_TOO_LONG_ERR; }\
else\
{ FIELD_VL_STR[FIELD_END] = (X);\
@@ -1305,7 +1305,7 @@
ex_buf[ex_buf_ptr] = (X);\
INCR(ex_buf_ptr);}
#define APPEND_EX_BUF_CHAR_AND_CHECK(X) {\
- if (ex_buf_ptr == BUF_SIZE) {buffer_overflow ();}; \
+ if (ex_buf_ptr == Buf_Size) {buffer_overflow ();}; \
APPEND_EX_BUF_CHAR(X)}
/***************************************************************************
@@ -1470,5 +1470,29 @@
#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]
+
+/***************************************************************************
+ * WEB section number: N/A
+ * ~~~~~~~~~~~~~~~~~~~
+ * Macros adapted from Kpathsea (lib.h) and Web2C (cpascal.h) to dynamically
+ * resize arrays.
+ ***************************************************************************/
+/* Reallocate N items of type T for ARRAY using myrealloc. */
+#define MYRETALLOC(array, addr, n, t) ((addr) = (t *) myrealloc(addr, (n) * sizeof(t), array))
+/* BibTeX needs this to dynamically reallocate arrays. Too bad we can't
+ rely on stringification, or we could avoid the ARRAY_NAME arg.
+ Actually allocate one more than requests, so we can index the last
+ entry, as Pascal wants to do. */
+#define BIB_XRETALLOC_NOSET(array_name, array_var, type, 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) sizeof (type), new_size, size_var); \
+ MYRETALLOC (array_name, array_var, new_size + 1, type)
+/* Same as above, but also increase SIZE_VAR for the last (or only) array. */
+#define BIB_XRETALLOC(array_name, array_var, type, size_var, new_size) do { \
+ BIB_XRETALLOC_NOSET(array_name, array_var, type, size_var, new_size); \
+ size_var = new_size; \
+} while (0)
+
#endif /* __BIBTEX_H__ */
diff --git a/Build/source/texk/bibtexu/datatype.h b/Build/source/texk/bibtexu/datatype.h
index ab9d2c03127..986d27d1c13 100644
--- a/Build/source/texk/bibtexu/datatype.h
+++ b/Build/source/texk/bibtexu/datatype.h
@@ -147,7 +147,7 @@ typedef Integer16_T AuxNumber_T;
typedef Integer16_T BibNumber_T;
typedef Integer16_T BltInRange_T;
typedef Integer16_T BufPointer_T;
-typedef ASCIICode_T BufType_T[BUF_SIZE + 1];
+typedef ASCIICode_T *BufType_T;
typedef Integer16_T CiteNumber_T;
typedef Integer16_T FieldLoc_T;
typedef Integer8_T FnClass_T;
diff --git a/Build/source/texk/bibtexu/gblvars.h b/Build/source/texk/bibtexu/gblvars.h
index 1d200e1b560..584438e2969 100644
--- a/Build/source/texk/bibtexu/gblvars.h
+++ b/Build/source/texk/bibtexu/gblvars.h
@@ -171,7 +171,6 @@ __EXTERN__ AlphaFile_T bst_file;
__EXTERN__ Integer_T bst_line_num;
__EXTERN__ Boolean_T bst_seen;
__EXTERN__ StrNumber_T bst_str;
-__EXTERN__ BufType_T buffer;
__EXTERN__ BufPointer_T buf_ptr1;
__EXTERN__ BufPointer_T buf_ptr2;
@@ -203,7 +202,6 @@ __EXTERN__ CiteNumber_T entry_cite_ptr;
__EXTERN__ Boolean_T entry_seen;
__EXTERN__ HashLoc_T entry_type_loc;
__EXTERN__ Integer_T err_count;
-__EXTERN__ BufType_T ex_buf;
__EXTERN__ BufPointer_T ex_buf_length;
__EXTERN__ BufPointer_T ex_buf_ptr;
__EXTERN__ BufPointer_T ex_buf_xptr;
@@ -265,7 +263,6 @@ __EXTERN__ BufPointer_T num_tokens;
__EXTERN__ Integer8_T number_of_command_line_args;
__EXTERN__ CiteNumber_T old_num_cites;
-__EXTERN__ BufType_T out_buf;
__EXTERN__ BufPointer_T out_buf_length;
__EXTERN__ BufPointer_T out_buf_ptr;
@@ -320,7 +317,6 @@ __EXTERN__ UChar_T str_glb_ptr;
__EXTERN__ Integer_T string_width;
__EXTERN__ StrNumber_T str_num;
__EXTERN__ StrNumber_T str_ptr;
-__EXTERN__ BufType_T sv_buffer;
__EXTERN__ BufPointer_T sv_ptr1;
__EXTERN__ BufPointer_T sv_ptr2;
@@ -357,8 +353,6 @@ __EXTERN__ Integer_T total_ex_count;
__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__ AlphaFile_T bib_file[MAX_BIB_FILES + 1];
-__EXTERN__ StrNumber_T bib_list[MAX_BIB_FILES + 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];
@@ -366,10 +360,7 @@ __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__ ASCIICode_T name_sep_char[BUF_SIZE + 1];
-__EXTERN__ BufPointer_T name_tok[BUF_SIZE + 1];
__EXTERN__ unsigned char name_of_file[FILE_NAME_SIZE + 1];
-__EXTERN__ StrNumber_T s_preamble[MAX_BIB_FILES + 1];
__EXTERN__ unsigned char xchr[LAST_ASCII_CHAR + 1];
__EXTERN__ ASCIICode_T xord[LAST_TEXT_CHAR + 1];
@@ -403,11 +394,15 @@ __EXTERN__ int c8order[LAST_TEXT_CHAR + 1];
** DYNAMICALLY ALLOCATED GLOBAL ARRAYS DECLARED HERE
**----------------------------------------------------------------------------
*/
+__EXTERN__ AlphaFile_T *bib_file;
+__EXTERN__ StrNumber_T *bib_list;
+__EXTERN__ ASCIICode_T *buffer;
__EXTERN__ StrNumber_T *cite_info;
__EXTERN__ StrNumber_T *cite_list;
__EXTERN__ Boolean_T *entry_exists;
__EXTERN__ Integer_T *entry_ints;
__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];
@@ -415,8 +410,13 @@ __EXTERN__ StrIlk_T *hash_ilk;
__EXTERN__ HashPointer_T *hash_next;
__EXTERN__ StrNumber_T *hash_text;
__EXTERN__ Integer_T *ilk_info;
+__EXTERN__ ASCIICode_T *name_sep_char;
+__EXTERN__ BufPointer_T *name_tok;
+__EXTERN__ ASCIICode_T *out_buf;
+__EXTERN__ StrNumber_T *s_preamble;
__EXTERN__ ASCIICode_T *str_pool;
__EXTERN__ PoolPointer_T *str_start;
+__EXTERN__ ASCIICode_T *sv_buffer;
__EXTERN__ HashPtr2_T *type_list;
__EXTERN__ HashPtr2_T *wiz_functions;
@@ -441,13 +441,9 @@ __EXTERN__ Boolean_T Flag_stats;
__EXTERN__ Boolean_T Flag_trace;
__EXTERN__ Boolean_T Flag_wolfgang;
__EXTERN__ Integer_T M_cites;
-__EXTERN__ Integer_T M_entints;
__EXTERN__ Integer_T M_entstrs;
-__EXTERN__ Integer_T M_fields;
__EXTERN__ Integer_T M_min_crossrefs;
-__EXTERN__ Integer_T M_pool;
__EXTERN__ Integer_T M_strings;
-__EXTERN__ Integer_T M_wiz_fn_space;
__EXTERN__ char *Str_auxfile;
__EXTERN__ char *Str_csfile;
@@ -459,8 +455,10 @@ __EXTERN__ char *Str_csfile;
** now be set dynamically from the command line.
**----------------------------------------------------------------------------
*/
+__EXTERN__ Integer_T Buf_Size;
__EXTERN__ Integer_T Hash_Prime;
__EXTERN__ Integer_T Hash_Size;
+__EXTERN__ Integer_T Max_Bib_Files;
__EXTERN__ Integer_T Max_Cites;
__EXTERN__ Integer_T Max_Ent_Ints;
__EXTERN__ Integer_T Max_Ent_Strs;
diff --git a/Build/source/texk/bibtexu/tests/bibtex.test b/Build/source/texk/bibtexu/tests/bibtex.test
new file mode 100755
index 00000000000..b4f24bd4c6c
--- /dev/null
+++ b/Build/source/texk/bibtexu/tests/bibtex.test
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+# Copyright (C) 2010 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+exit 77
+
+test -d tests || mkdir -p tests
+
+cp $srcdir/../web2c/tests/exampl.aux tests/xexampl.aux
+
+TEXMFCNF=$srcdir/../kpathsea \
+ BSTINPUTS=$srcdir/../web2c/tests \
+ BIBINPUTS=$srcdir/../web2c/tests \
+ ./bibtexu tests/xexampl || test $? = 1 || exit 1
+
diff --git a/Build/source/texk/bibtexu/utils.c b/Build/source/texk/bibtexu/utils.c
index 6ab08ff5d80..7200a149a4b 100644
--- a/Build/source/texk/bibtexu/utils.c
+++ b/Build/source/texk/bibtexu/utils.c
@@ -24,15 +24,13 @@
** the program. The functions are declared in alphabetical order.
** Functions defined in this module are:
**
-** allocate_arrays
-** checkdbg
-** checklong
** close_file
** debug_msg
** find_file
** open_ip_file
** open_op_file
** mymalloc
+** myrealloc
** parse_cmd_line
** report_bibtex_capacity
** report_search_paths
@@ -196,12 +194,12 @@ static struct option long_options[] = {
{"min_crossrefs", VALUE_REQD, 0, 'M'},
{"mcites", VALUE_REQD, 0, '\x0A'},
- {"mentints", VALUE_REQD, 0, '\x0B'},
+ {"mentints", VALUE_REQD, 0, '\x0B'}, /* obsolete */
{"mentstrs", VALUE_REQD, 0, '\x0C'},
- {"mfields", VALUE_REQD, 0, '\x0D'},
- {"mpool", VALUE_REQD, 0, '\x0E'},
+ {"mfields", VALUE_REQD, 0, '\x0D'}, /* obsolete */
+ {"mpool", VALUE_REQD, 0, '\x0E'}, /* obsolete */
{"mstrings", VALUE_REQD, 0, '\x0F'},
- {"mwizfuns", VALUE_REQD, 0, '\x10'},
+ {"mwizfuns", VALUE_REQD, 0, '\x10'}, /* obsolete */
{0, 0, 0, 0}
};
@@ -240,25 +238,34 @@ static int sort_weight;
** Allocate memory dynamically for the large arrays whose size is set
** dynamically, depending on the amount memory of memory available.
**
+** AlphaFile_T bib_file[Max_Bib_Files + 1];
+** StrNumber_T bib_list[Max_Bib_Files + 1];
+** ASCIICode_T buffer[Buf_Size + 1];
** StrNumber_T cite_info[Max_Cites + 1];
** StrNumber_T cite_list[Max_Cites + 1];
** Boolean_T entry_exists[Max_Cites + 1];
-** Integer_T entry_ints[Max_Ent_Ints + 1];
+** Integer_T entry_ints[Max_Ent_Ints + 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];
-** 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];
-** ASCIICode_T str_pool[Pool_Size + 1];
-** PoolPointer_T str_start[Max_Strings + 1];
+** FnClass_T fn_type[Hash_Size + 1];
+** ASCIICode_T global_strs[MAX_GLOB_STRS + 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];
+** ASCIICode_T name_sep_char[Buf_Size + 1];
+** BufPointer_T name_tok[Buf_Size + 1];
+** ASCIICode_T out_buf[Buf_Size + 1];
+** StrNumber_T s_preamble[Max_Bib_Files + 1];
+** ASCIICode_T str_pool[Pool_Size + 1];
+** PoolPointer_T str_start[Max_Strings + 1];
+** ASCIICode_T sv_buffer[Buf_Size + 1];
** HashPtr2_T type_list[Max_Cites + 1];
-** HashPtr2_T wiz_functions[Wiz_Fn_Space + 1];
+** HashPtr2_T wiz_functions[Wiz_Fn_Space + 1];
**============================================================================
*/
-void allocate_arrays (void)
+static void allocate_arrays (void)
{
unsigned long bytes_required;
ASCIICode_T *dummy_ptr;
@@ -267,6 +274,24 @@ void allocate_arrays (void)
debug_msg (DBG_MEM, "Starting to allocate memory for arrays ... ");
/*
+ ** AlphaFile_T bib_file[Max_Bib_Files + 1];
+ */
+ bytes_required = (Max_Bib_Files + 1) * (unsigned long) sizeof (AlphaFile_T);
+ bib_file = (AlphaFile_T *) mymalloc (bytes_required, "bib_file");
+
+ /*
+ ** StrNumber_T bib_list[Max_Bib_Files + 1];
+ */
+ bytes_required = (Max_Bib_Files + 1) * (unsigned long) sizeof (StrNumber_T);
+ bib_list = (StrNumber_T *) mymalloc (bytes_required, "bib_list");
+
+ /*
+ ** ASCIICode_T buffer[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
+ buffer = (ASCIICode_T *) mymalloc (bytes_required, "buffer");
+
+ /*
** StrNumber_T cite_info[Max_Cites + 1];
*/
bytes_required = (Max_Cites + 1) * (unsigned long) sizeof (StrNumber_T);
@@ -299,6 +324,11 @@ void allocate_arrays (void)
entry_strs = (ASCIICode_T *) mymalloc (bytes_required, "entry_strs");
+ /*
+ ** ASCIICode_T ex_buf[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
+ ex_buf = (ASCIICode_T *) mymalloc (bytes_required, "ex_buf");
/*
** StrNumber_T field_info[Max_Fields + 1];
@@ -318,7 +348,6 @@ void allocate_arrays (void)
bytes_required = (unsigned long) (MAX_GLOB_STRS)
* (GLOB_STR_SIZE + 1)
* (unsigned long) sizeof (ASCIICode_T);
- dummy_ptr = (ASCIICode_T *) NULL;
dummy_ptr = (ASCIICode_T *) mymalloc (bytes_required, "global_strs");
for (row = 0; row < (MAX_GLOB_STRS + 1); row++) {
@@ -350,6 +379,30 @@ void allocate_arrays (void)
ilk_info = (Integer_T *) mymalloc (bytes_required, "ilk_info");
/*
+ ** ASCIICode_T name_sep_char[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
+ name_sep_char = (ASCIICode_T *) mymalloc (bytes_required, "name_sep_char");
+
+ /*
+ ** BufPointer_T name_tok[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (BufPointer_T);
+ name_tok = (BufPointer_T *) mymalloc (bytes_required, "name_tok");
+
+ /*
+ ** ASCIICode_T out_buf[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
+ out_buf = (ASCIICode_T *) mymalloc (bytes_required, "out_buf");
+
+ /*
+ ** StrNumber_T s_preamble[Max_Bib_Files + 1];
+ */
+ bytes_required = (Max_Bib_Files + 1) * (unsigned long) sizeof (StrNumber_T);
+ s_preamble = (StrNumber_T *) mymalloc (bytes_required, "s_preamble");
+
+ /*
** ASCIICode_T str_pool[Pool_Size + 1];
*/
bytes_required = (Pool_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
@@ -362,6 +415,12 @@ void allocate_arrays (void)
str_start = (PoolPointer_T *) mymalloc (bytes_required, "str_start");
/*
+ ** ASCIICode_T sv_buffer[Buf_Size + 1];
+ */
+ bytes_required = (Buf_Size + 1) * (unsigned long) sizeof (ASCIICode_T);
+ sv_buffer = (ASCIICode_T *) mymalloc (bytes_required, "sv_buffer");
+
+ /*
** HashPtr2_T type_list[Max_Cites + 1];
*/
bytes_required = (Max_Cites + 1) * (unsigned long) sizeof (HashPtr2_T);
@@ -386,7 +445,7 @@ void allocate_arrays (void)
** integer. Return 0 (no debugging) if a valid option was not parsed.
**============================================================================
*/
-int checkdbg (char *str)
+static int checkdbg (char *str)
{
int dbgval = 0;
@@ -420,7 +479,7 @@ int checkdbg (char *str)
** Return -1 if a valid integer was not parsed.
**============================================================================
*/
-long checklong (char *str)
+static long checklong (char *str)
{
long value;
char *endptr;
@@ -632,13 +691,14 @@ int find_file (const char *envvar_name, const char *fallback_path,
** Allocate memory for a specified array and check whether the allocation
** was successful. If not, issue an error message and cause the program
** to stop with a fatal exit status.
+** Allocate at least 1 byte, otherwise malloc may return NULL.
**============================================================================
*/
void *mymalloc (const unsigned long bytes_required, const char *array_name)
{
void *ptr;
- ptr = malloc (bytes_required);
+ ptr = malloc (bytes_required ? bytes_required : 1);
if (ptr == NULL) {
printf ("\nFatal error: couldn't allocate %lu bytes for array `%s'",
@@ -658,6 +718,41 @@ void *mymalloc (const unsigned long bytes_required, const char *array_name)
/*-
**============================================================================
+** myrealloc()
+**
+** Reallocate memory for a specified array and check whether the allocation
+** was successful. If not, issue an error message and cause the program
+** to stop with a fatal exit status.
+** Allocate at least 1 byte, otherwise realloc may return NULL.
+**============================================================================
+*/
+void *myrealloc (void *old_ptr, const unsigned long bytes_required, const char *array_name)
+{
+ void *ptr;
+
+ if (old_ptr == NULL)
+ return mymalloc (bytes_required, array_name);
+
+ ptr = realloc (old_ptr, bytes_required ? bytes_required : 1);
+
+ if (ptr == NULL) {
+ printf ("\nFatal error: couldn't reallocate %lu bytes for array `%s'",
+ bytes_required, array_name);
+ mark_fatal ();
+ debug_msg (DBG_MISC, "calling longjmp (Exit_Program_Flag) ... ");
+ longjmp (Exit_Program_Flag, 1);
+ } else {
+ debug_msg (DBG_MEM, "reallocated %7lu bytes for array `%s'",
+ bytes_required, array_name);
+ }
+
+ return (ptr);
+} /* myrealloc () */
+
+
+
+/*-
+**============================================================================
** open_ip_file()
**
** Open a file for input after locating it using one of the five predefined
@@ -861,12 +956,12 @@ FILE *open_op_file (void)
** referenced entry in the citation list
** (default = 2)
** --mcites ## allow ## \\cites in the .aux files
-** --mentints ## allow ## integer entries in the .bib databases
+** --mentints ## ignored
** --mentstrs ## allow ## string entries in the .bib databases
-** --mfields ## allow ## fields in the .bib databases
-** --mpool ## set the string pool to ## bytes
+** --mfields ## ignored
+** --mpool ## ignored
** --mstrings ## allow ## unique strings
-** --mwizfuns ## allow ## wizard functions
+** --mwizfuns ## ignored
**============================================================================
*/
void parse_cmd_line (int argc, char **argv)
@@ -975,12 +1070,7 @@ Get the option, and change the flag. 23/sep/2009
break;
case '\x0B': /**************** --mentints ***************/
- M_entints = checklong (optarg);
- if (M_entints < 0) {
- mark_fatal ();
- usage ("invalid max number of integer entries `%s'\n",
- optarg);
- }
+ (void) checklong (optarg); /******** ignored ********/
break;
case '\x0C': /**************** --mentstrs ***************/
@@ -993,19 +1083,8 @@ Get the option, and change the flag. 23/sep/2009
break;
case '\x0D': /**************** --mfields ****************/
- M_fields = checklong (optarg);
- if (M_fields < 0) {
- mark_fatal ();
- usage ("invalid max number of fields `%s'\n", optarg);
- }
- break;
-
case '\x0E': /**************** --mpool *****************/
- M_pool = checklong (optarg);
- if (M_pool < 0) {
- mark_fatal ();
- usage ("invalid pool size `%s'\n", optarg);
- }
+ (void) checklong (optarg); /******** ignored ********/
break;
case '\x0F': /**************** --mstrings ***************/
@@ -1017,11 +1096,7 @@ Get the option, and change the flag. 23/sep/2009
break;
case '\x10': /**************** --mwizfuns ***************/
- M_wiz_fn_space = checklong (optarg);
- if (M_wiz_fn_space < 0) {
- mark_fatal ();
- usage ("invalid max wizard functions `%s'\n", optarg);
- }
+ (void) checklong (optarg); /******** ignored ********/
break;
default: /**************** Unknown argument ********/
@@ -1122,14 +1197,14 @@ void report_bibtex_capacity (void)
if (log_file != NULL) {
FPRINTF (log_file, "BibTeX's capacity set as follows:\n\n");
LOG_CAPACITY (AUX_STACK_SIZE);
- LOG_CAPACITY (BUF_SIZE);
+ LOG_CAPACITY (Buf_Size);
LOG_CAPACITY (ENT_STR_SIZE);
LOG_CAPACITY (FILE_NAME_SIZE);
LOG_CAPACITY (GLOB_STR_SIZE);
LOG_CAPACITY (Hash_Prime);
LOG_CAPACITY (Hash_Size);
LOG_CAPACITY (LIT_STK_SIZE);
- LOG_CAPACITY (MAX_BIB_FILES);
+ LOG_CAPACITY (Max_Bib_Files);
LOG_CAPACITY (Max_Cites);
LOG_CAPACITY (Max_Ent_Ints);
LOG_CAPACITY (Max_Ent_Strs);
@@ -1197,6 +1272,55 @@ void report_search_paths (void)
} /* report_search_paths() */
+/*-
+**============================================================================
+** compute_hash_prime()
+**
+** We use the algorithm from Knuth's \.{primes.web} to compute
+** |hash_prime| as the smallest prime number not less than 85\%
+** of |hash_size| (and |>=128|).
+**
+** 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
+#define mult hash_text
+static void compute_hash_prime (void)
+{
+ Integer32_T Hash_Want = (Hash_Size / 20) * 17; /* 85\% of |hash_size| */
+ Integer32_T k = 1; /*number of prime numbers $p_i$ in |primes| */
+ Integer32_T j = 1; /* a prime number candidate */
+ Integer32_T o = 2; /* number of odd multiples of primes in |mult| */
+ Integer32_T square = 9; /* $p_o^2$ */
+ Integer32_T n; /* loop index */
+ Boolean_T j_prime; /* is |j| a prime? */
+
+ debug_msg (DBG_MEM, "Computing Hash_Prime ... ");
+
+ primes[k] = Hash_Prime = 2;
+ while (Hash_Prime < Hash_Want) {
+ do {
+ j += 2;
+ if (j == square) {
+ mult[o++] = j;
+ j += 2;
+ square = primes[o] * primes[o];
+ }
+ n = 2;
+ j_prime = TRUE;
+ while ((n < o) && j_prime) {
+ while (mult[n] < j)
+ mult[n] += 2 * primes[n];
+ if (mult[n++] == j)
+ j_prime = FALSE;
+ }
+ } while (!j_prime);
+ primes[++k] = Hash_Prime = j;
+ }
+}
+
/*-
**============================================================================
@@ -1211,15 +1335,17 @@ void report_search_paths (void)
**
** Parameter Cmd Standard --big --huge --wolfgang
** ------------------------------------------------------------------
-** Hash_Prime N 4,253 8,501 16,319 30,011
-** Hash_Size N 5,000 10,000 19,000 35,000
+** Buf_Size *** initialy 20000, increased as required ***
+** Hash_Prime *** computed from Hash_Size ***
+** Hash_Size *** determined from Max_Strings ***
+** Max_Bib_Files *** initialy 20, increased as required ***
** Max_Cites Y 750 2,000 5,000 7,500
-** Max_Ent_Ints Y 3,000 4,000 5,000 7,500
+** Max_Ent_Ints *** initialy 3000, increased as required ***
** Max_Ent_Strs Y 3,000 6,000 10,000 10,000
-** Max_Fields Y 17,250 30,000 85,000 125,000
+** Max_Fields *** initialy 5000, increased as required ***
** Max_Strings Y 4,000 10,000 19,000 30,000
-** Pool_Size Y 65,530 130,000 500,000 750,000
-** Wiz_Fn_Space Y 3,000 6,000 10,000 10,000
+** Pool_Size *** initialy 65,000, increased as required ***
+** Wiz_Fn_Space *** initialy 3000, increased as required ***
** ------------------------------------------------------------------
**
**============================================================================
@@ -1228,80 +1354,67 @@ void set_array_sizes (void)
{
debug_msg (DBG_MEM, "Setting BibTeX's capacity ... ");
- Hash_Prime = 4253;
- Hash_Size = 5000;
Max_Cites = 750;
- Max_Ent_Ints = 3000;
Max_Ent_Strs = 3000;
- Max_Fields = 17250;
Max_Strings = 4000;
Min_Crossrefs = 2;
- Pool_Size = 65530;
- Wiz_Fn_Space = 3000;
if (Flag_big) {
- Hash_Prime = 8501;
- Hash_Size = 10000;
Max_Cites = 2000;
- Max_Ent_Ints = 3000;
Max_Ent_Strs = 5000;
- Max_Fields = 30000;
Max_Strings = 10000;
- Pool_Size = 130000;
- Wiz_Fn_Space = 6000;
}
if (Flag_huge) {
- Hash_Prime = 16319;
- Hash_Size = 19000;
Max_Cites = 5000;
- Max_Ent_Ints = 5000;
Max_Ent_Strs = 10000;
- Max_Fields = 85000L;
Max_Strings = 19000;
- Pool_Size = 500000L;
- Wiz_Fn_Space = 10000;
}
if (Flag_wolfgang) {
- Hash_Prime = 30011;
- Hash_Size = 35000;
Max_Cites = 7500;
- Max_Ent_Ints = 7500;
Max_Ent_Strs = 10000;
- Max_Fields = 125000L;
Max_Strings = 30000;
- Pool_Size = 750000L;
- Wiz_Fn_Space = 10000;
}
+ Buf_Size = BUF_SIZE;
+
+ Max_Bib_Files = MAX_BIB_FILES;
+
if (M_cites > 0)
Max_Cites = M_cites;
- if (M_entints > 0)
- Max_Ent_Ints = M_entints;
+ Max_Ent_Ints = MAX_ENT_INTS;
if (M_entstrs > 0)
Max_Ent_Strs = M_entstrs;
- if (M_fields > 0)
- Max_Fields = M_fields;
+ Max_Fields = MAX_FIELDS;
if (M_min_crossrefs > 0)
Min_Crossrefs = M_min_crossrefs;
- if (M_pool > 0)
- Pool_Size = M_pool;
+ Pool_Size = POOL_SIZE;
if (M_strings > 0)
- Max_Strings = M_strings ;
+ 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;
+
- if (M_wiz_fn_space > 0)
- Wiz_Fn_Space = M_wiz_fn_space;
+ allocate_arrays ();
+ compute_hash_prime ();
debug_msg (DBG_MEM, "Hash_Prime = %d, Hash_Size = %d",
Hash_Prime, Hash_Size);
+ debug_msg (DBG_MEM, "Buf_Size = %d, Max_Bib_Files = %d",
+ Buf_Size, Max_Bib_Files);
debug_msg (DBG_MEM, "Max_Cites = %d, Max_Ent_Ints = %d",
Max_Cites, Max_Ent_Ints);
debug_msg (DBG_MEM, "Max_Ent_Strs = %d, Max_Fields = %d",
@@ -1401,12 +1514,8 @@ void usage (const char *printf_fmt, ...)
FSO (" -W --wolfgang set really huge BibTeX capacity for Wolfgang\n");
FSO (" -M --min_crossrefs ## set min_crossrefs to ##\n");
FSO (" --mcites ## allow ## \\cites in the .aux files\n");
- FSO (" --mentints ## allow ## integer entries in the .bib databases\n");
FSO (" --mentstrs ## allow ## string entries in the .bib databases\n");
- FSO (" --mfields ## allow ## fields in the .bib databases\n");
- FSO (" --mpool ## set the string pool to ## bytes\n");
FSO (" --mstrings ## allow ## unique strings\n");
- FSO (" --mwizfuns ## allow ## wizard functions\n");
debug_msg (DBG_MISC, "calling longjmp (Exit_Program_Flag) ... ");
longjmp (Exit_Program_Flag, 1);
@@ -1610,7 +1719,9 @@ int c8read_csf (void)
{
int c, i;
int in_comment;
- char sx[BUF_SIZE + 1];
+#define SX_BUF_SIZE 15
+ /* a section name: "order", "uppercase", "lowercase", or "lowupcase". */
+ char sx[SX_BUF_SIZE + 1];
#ifndef KPATHSEA
char *value;
#endif
@@ -1733,7 +1844,7 @@ int c8read_csf (void)
sx[i++] = c;
else
break;
- } while (!feof (c8_cs_file) && (i < BUF_SIZE));
+ } while (!feof (c8_cs_file) && (i < SX_BUF_SIZE));
sx[i] = '\0';
/*
diff --git a/Build/source/texk/bibtexu/utils.h b/Build/source/texk/bibtexu/utils.h
index 28a76fd6c70..c36e8170c13 100644
--- a/Build/source/texk/bibtexu/utils.h
+++ b/Build/source/texk/bibtexu/utils.h
@@ -107,9 +107,6 @@
/*
** Declaration of public functions defined in utils.c
*/
-void allocate_arrays (void);
-int checkdbg (char *str);
-long checklong (char *str);
void close_file (const AlphaFile_T file_pointer);
//void close_u_file (const UFILE * u_file_pointer);
void CDECL debug_msg (const int status, const char *printf_fmt, ...);
@@ -124,6 +121,8 @@ FILE *open_op_file (void);
//UFILE *open_op_u_file (void);
void *mymalloc (const unsigned long bytes_required,
const char *var_name);
+void *myrealloc (void *old_ptr, const unsigned long bytes_required,
+ const char *var_name);
void parse_cmd_line (int argc, char **argv);
void report_bibtex_capacity (void);
void report_search_paths (void);