summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/bibtex.ch
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-12-16 18:16:30 +0000
committerKarl Berry <karl@freefriends.org>2019-12-16 18:16:30 +0000
commit1c398269e793c4732b0be99d99602b65bbdc1a22 (patch)
tree1d35051180e502c97bc9f606ea982c8657f937e5 /Build/source/texk/web2c/bibtex.ch
parentde7f45879c92c00942b701fb706d874f2f993450 (diff)
bibtex: reallocate on long field values instead of giving up
git-svn-id: svn://tug.org/texlive/trunk@53145 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/bibtex.ch')
-rw-r--r--Build/source/texk/web2c/bibtex.ch33
1 files changed, 32 insertions, 1 deletions
diff --git a/Build/source/texk/web2c/bibtex.ch b/Build/source/texk/web2c/bibtex.ch
index ddaad73a2d8..888b06803a3 100644
--- a/Build/source/texk/web2c/bibtex.ch
+++ b/Build/source/texk/web2c/bibtex.ch
@@ -449,7 +449,7 @@ File closing will be done in C, too.
@!buffer:buf_type; {usually, lines of characters being read}
@z
-@x [42] Dyanmic buf_size.
+@x [42] Dynamic buf_size.
@!buf_pointer = 0..buf_size; {an index into a |buf_type|}
@!buf_type = array[buf_pointer] of ASCII_code; {for various buffers}
@y
@@ -460,6 +460,12 @@ File closing will be done in C, too.
@x [46] Dynamic buf_size.
overflow('buffer size ',buf_size);
@y
+{These are all the arrays of |buf_type| or that use |buf_pointer|, that
+is, they all depend on the |buf_size| value. Therefore we have to
+reallocate them all at once, even though only one of them has
+overflowed. The alternative seems worse: even more surgery on the program,
+to have a separate variable for each array size instead of the common
+|buf_size|.}
BIB_XRETALLOC_NOSET ('buffer', buffer, ASCII_code,
buf_size, buf_size + BUF_SIZE);
BIB_XRETALLOC_NOSET ('sv_buffer', sv_buffer, ASCII_code,
@@ -1314,6 +1320,31 @@ begin
end;
@z
+% emacs-page
+@x [251] Reallocate field_vl_str (aka ex_buf); see tests/bibtex-bigauth.test.
+@d copy_char(#) == begin
+ if (field_end = buf_size) then
+ bib_field_too_long_err
+ else
+ begin
+ field_vl_str[field_end] := #;
+ incr(field_end);
+ end;
+ end
+@y
+@d copy_char(#) == begin
+ {We don't always increment by 1, so have to check |>=|.}
+ if (field_end >= buf_size) then
+ begin
+ log_pr ('Field filled up at ', #, ', reallocating.');
+ log_pr_newline;
+ buffer_overflow; {reallocates all |buf_size| buffers}
+ end;
+ field_vl_str[field_end] := #;
+ incr(field_end);
+ end
+@z
+
@x [263] Add check for fieldinfo[] overflow.
field_ptr := entry_cite_ptr * num_fields + fn_info[field_name_loc];
@y