diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-04-23 13:07:21 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-04-23 13:07:21 +0000 |
commit | d64e27494d29684b840753c87fc3e8a5b6ec3694 (patch) | |
tree | d111d1c03bf74ddb42039b778e338787ba176ee5 /Build/source/texk/web2c/ptexdir | |
parent | 57c7d41397ed1ec0e244316a88a33bd2b0324ec1 (diff) |
more pTeX fixes
git-svn-id: svn://tug.org/texlive/trunk@17974 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/ptexdir')
-rw-r--r-- | Build/source/texk/web2c/ptexdir/ChangeLog | 9 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/am/ptex.am | 9 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/kanji.h | 4 | ||||
-rwxr-xr-x | Build/source/texk/web2c/ptexdir/pbibtex-longline-test.pl | 38 | ||||
-rwxr-xr-x | Build/source/texk/web2c/ptexdir/pbibtex-mem.test | 69 | ||||
-rwxr-xr-x | Build/source/texk/web2c/ptexdir/pbibtex-openout-test.pl | 22 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/pbibtex.ch | 13 | ||||
-rwxr-xr-x | Build/source/texk/web2c/ptexdir/pbibtex.test | 14 |
8 files changed, 174 insertions, 4 deletions
diff --git a/Build/source/texk/web2c/ptexdir/ChangeLog b/Build/source/texk/web2c/ptexdir/ChangeLog index 588ea2908ce..ce52dcdf827 100644 --- a/Build/source/texk/web2c/ptexdir/ChangeLog +++ b/Build/source/texk/web2c/ptexdir/ChangeLog @@ -1,3 +1,12 @@ +2010-04-23 Peter Breitenlohner <peb@mppmu.mpg.de> + + * pbibtex.ch, kanji.h: Use input_line2() with five arguments + for correct handling of buffer_overflow. + + * pbibtex-longline-test.pl, pbibtex-openout-test.pl, + pbibtex-mem.test, pbibtex.test: New tests. + * am/ptex.am: Add them. + 2010-04-22 Peter Breitenlohner <peb@mppmu.mpg.de> * pdvitype.ch: Remove unnecessary change. diff --git a/Build/source/texk/web2c/ptexdir/am/ptex.am b/Build/source/texk/web2c/ptexdir/am/ptex.am index 14cb8361c65..d621d079cca 100644 --- a/Build/source/texk/web2c/ptexdir/am/ptex.am +++ b/Build/source/texk/web2c/ptexdir/am/ptex.am @@ -12,6 +12,7 @@ pweb_programs = pbibtex pdvitype ppltotf ptftopl # pTeX Tests # ptex_tests = \ + ptexdir/pbibtex.test \ ptexdir/pdvitype.test \ ptexdir/ppltotf.test \ ptexdir/ptftopl.test \ @@ -118,6 +119,9 @@ pbibtex.web: tie$(EXEEXT) bibtex.web bibtex.ch $(tie) -m pbibtex.web bibtex.web bibtex.ch EXTRA_DIST += ptexdir/pbibtex.ch web2c/cvtbib.sed +ptex_tests += ptexdir/pbibtex-openout-test.pl ptexdir/pbibtex-longline-test.pl +ptex_tests += ptexdir/pbibtex-mem.test + ## pDVItype ## nodist_pdvitype_SOURCES = pdvitype.c pdvitype.h @@ -183,6 +187,11 @@ endif PTEX ## Test data and results ## +## ptexdir/pbibtex.test +DISTCLEANFILES += tests/xexampl.aux tests/xexampl.bbl tests/xexampl.blg +## ptexdir/pbibtex-mem.test +EXTRA_DIST += tests/memdata1.bst tests/memdata2.bst tests/memdata3.bst +DISTCLEANFILES += tests/memtest* ## ptexdir/pdvitype.test DISTCLEANFILES += tests/xstory.dvityp tests/xpagenum.typ ## ptexdir/ppltotf.test diff --git a/Build/source/texk/web2c/ptexdir/kanji.h b/Build/source/texk/web2c/ptexdir/kanji.h index 6d514f6bdc7..901c5903c72 100644 --- a/Build/source/texk/web2c/ptexdir/kanji.h +++ b/Build/source/texk/web2c/ptexdir/kanji.h @@ -30,7 +30,11 @@ extern integer kcatcodekey(integer c); #define putc(c,fp) putc2(c,fp) #endif /* !PRESERVE_PUTC */ +#ifdef PBIBTEX +#define inputline2(fp,buff,pos,size,ptr) input_line2(fp,buff,pos,size,ptr) +#else #define inputline2(fp,buff,pos,size) input_line2(fp,buff,pos,size,NULL) +#endif #ifdef MP #undef TEXMFPOOLNAME diff --git a/Build/source/texk/web2c/ptexdir/pbibtex-longline-test.pl b/Build/source/texk/web2c/ptexdir/pbibtex-longline-test.pl new file mode 100755 index 00000000000..a7db4dadea6 --- /dev/null +++ b/Build/source/texk/web2c/ptexdir/pbibtex-longline-test.pl @@ -0,0 +1,38 @@ +#!/usr/bin/env perl +# $Id: pbibtex-openout-test.pl 17085 2010-02-18 18:03:18Z karl $ +# Public domain. Originally written 2010, Karl Berry. +# Check that pbibtex does not break long strings (change in 2010). + +# srcdir = web2c (in the source tree) +BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `cd \`dirname $0\`/.. && pwd`); } +require "$srcdir/../tests/common-test.pl"; + +exit (&main ()); + +sub main +{ + # The blg and bbl file names are based on the aux name and cannot be + # overridden. We can't write to the aux (source) directory, though, + # because that's an absolute path and openout_any=p. Therefore, copy + # the input files to our working directory. + for my $ext ("aux", "bib") { + &test_file_copy ("$srcdir/tests/longline.$ext", "./longline.$ext"); + } + + # Run pBibTeX, quit if it fails. + my $ret = &test_run ("./pbibtex", "./longline.aux"); + return 1 if $ret != 0; + + # There should be lines longer than 80 chars in the output. + # (In older versions of pBibTeX, they are forcibly split, with a %.) + local *IN; + $IN = "longline.bbl"; + open (IN) || die "open($IN) failed: $!"; + while (<IN>) { + last if length ($_) >= 80; + } + + # We failed if all lines were < 80. + my $bad = ! (length $_ >= 80); + return $bad; +} diff --git a/Build/source/texk/web2c/ptexdir/pbibtex-mem.test b/Build/source/texk/web2c/ptexdir/pbibtex-mem.test new file mode 100755 index 00000000000..69773b5f751 --- /dev/null +++ b/Build/source/texk/web2c/ptexdir/pbibtex-mem.test @@ -0,0 +1,69 @@ +#! /bin/sh + +# Copyright (C) 2010 Peter Breitenlohner <tex-live@tug.org> +# You may freely use, modify and/or distribute this file. + +# Using test data from Philipp Lehman <lehman@gmx.net> + +test -d tests || mkdir -p tests + +# Create bib data +mk_bib () { + for i + do + for j in 0 1 2 3 4 5 6 7 8 9; do + for k in 0 1 2 3 4 5 6 7 8 9; do + for l in 0 1 2 3 4 5 6 7 8 9; do + cat <<EOF +@Type{key$i$j$k$l, + field001 = {Value 001}, + field002 = {Value 002}, + field003 = {Value 003}, + field004 = {Value 004}, + field005 = {Value 005}, + field006 = {Value 006}, + field007 = {Value 007}, + field008 = {Value 008}, + field009 = {Value 009}, + field010 = {Value 010} +} + +EOF + done + done + done + done +} + +# Create aux data +mk_aux () { + cat <<EOF +\relax +\citation{*} +\bibstyle{$1} +\bibdata{memtest} +EOF +} + +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) env='ent_str_size=2000 glob_str_size=2000';; + esac + + echo "Running memtest$t ..." + + eval $env \ + TEXMFCNF=$srcdir/../kpathsea \ + BSTINPUTS=$srcdir/tests \ + BIBINPUTS=./tests \ + ./pbibtex tests/memtest$t || exit 1 + +done + diff --git a/Build/source/texk/web2c/ptexdir/pbibtex-openout-test.pl b/Build/source/texk/web2c/ptexdir/pbibtex-openout-test.pl new file mode 100755 index 00000000000..c733f60b691 --- /dev/null +++ b/Build/source/texk/web2c/ptexdir/pbibtex-openout-test.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +# $Id: pbibtex-openout-test.pl 17384 2010-03-08 18:49:47Z karl $ +# Public domain. Originally written 2010, Karl Berry. +# Check that pbibtex respects openout_any. + +# srcdir = web2c (in the source tree) +BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `cd \`dirname $0\`/.. && pwd`); } +require "$srcdir/../tests/common-test.pl"; + +exit (&main ()); + +sub main +{ + $ENV{"openout_any"} = "p"; # should already be in texmf.cnf, but ... + + # .blg open of abs path should fail: + my $ret = &test_run ("./pbibtex", "$srcdir/exampl.aux"); + + # The test fails if the program succeeded. Could also check the output. + my $bad = ($ret == 0); + return $bad; +} diff --git a/Build/source/texk/web2c/ptexdir/pbibtex.ch b/Build/source/texk/web2c/ptexdir/pbibtex.ch index c2f36651dda..fae1c10b497 100644 --- a/Build/source/texk/web2c/ptexdir/pbibtex.ch +++ b/Build/source/texk/web2c/ptexdir/pbibtex.ch @@ -188,6 +188,12 @@ for i:=@'240 to 254 do char_width[i]:=514; @z @x [48] JBibTeX and dynamic buf_size. +label loop_exit; +@y +label loop_exit; +var i:c_int_type; +@z +@x [still 48] JBibTeX and dynamic buf_size. while (not eoln(f)) do begin if (last >= buf_size) then @@ -197,12 +203,11 @@ for i:=@'240 to 254 do char_width[i]:=514; end; vgetc (f); {skip the eol} @y - last := input_line2(f,buffer,last,buf_size); - while (not eof(f)) and (last > 0) and (buffer[last-1] <> xord[10]) - and (buffer[last-1] <> xord[13]) do + last := input_line2(f,buffer,last,buf_size,address_of(i)); + while (not eof(f)) and (last > 0) and (i <> 10) and (i <> 13) do begin buffer_overflow; - last := input_line2(f,buffer,last,buf_size); + last := input_line2(f,buffer,last,buf_size,address_of(i)); end; @z diff --git a/Build/source/texk/web2c/ptexdir/pbibtex.test b/Build/source/texk/web2c/ptexdir/pbibtex.test new file mode 100755 index 00000000000..32b9f0b1e8a --- /dev/null +++ b/Build/source/texk/web2c/ptexdir/pbibtex.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/tests/exampl.aux tests/xexampl.aux + +TEXMFCNF=$srcdir/../kpathsea \ + BSTINPUTS=$srcdir/tests \ + BIBINPUTS=$srcdir/tests \ + ./pbibtex tests/xexampl || exit 1 + |