From 6f855519650fde622bd6326b68315d8cf2650380 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 6 Aug 2013 23:52:15 +0000 Subject: do not ignore text on a non-terminated final line, plus new test; move all kpse tests to subdir git-svn-id: svn://tug.org/texlive/trunk@31370 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/kpathsea/ChangeLog | 7 +++ Build/source/texk/kpathsea/Makefile.am | 4 +- Build/source/texk/kpathsea/Makefile.in | 7 ++- Build/source/texk/kpathsea/kpseaccess.test | 50 ---------------------- Build/source/texk/kpathsea/kpsereadlink.test | 13 ------ Build/source/texk/kpathsea/kpsestat.test | 19 -------- Build/source/texk/kpathsea/kpsewhich.test | 21 --------- Build/source/texk/kpathsea/line.c | 15 ++++--- Build/source/texk/kpathsea/tests/cnfnewline.test | 16 +++++++ .../texk/kpathsea/tests/cnfnewline/texmf.cnf | 1 + Build/source/texk/kpathsea/tests/kpseaccess.test | 50 ++++++++++++++++++++++ Build/source/texk/kpathsea/tests/kpsereadlink.test | 13 ++++++ Build/source/texk/kpathsea/tests/kpsestat.test | 19 ++++++++ Build/source/texk/kpathsea/tests/kpsewhich.test | 21 +++++++++ 14 files changed, 143 insertions(+), 113 deletions(-) delete mode 100755 Build/source/texk/kpathsea/kpseaccess.test delete mode 100755 Build/source/texk/kpathsea/kpsereadlink.test delete mode 100755 Build/source/texk/kpathsea/kpsestat.test delete mode 100755 Build/source/texk/kpathsea/kpsewhich.test create mode 100755 Build/source/texk/kpathsea/tests/cnfnewline.test create mode 100644 Build/source/texk/kpathsea/tests/cnfnewline/texmf.cnf create mode 100755 Build/source/texk/kpathsea/tests/kpseaccess.test create mode 100755 Build/source/texk/kpathsea/tests/kpsereadlink.test create mode 100755 Build/source/texk/kpathsea/tests/kpsestat.test create mode 100755 Build/source/texk/kpathsea/tests/kpsewhich.test (limited to 'Build') diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index a86834b3847..4937bbdb3e7 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,5 +1,12 @@ 2013-08-07 Karl Berry + * line.c (read_line): only at EOF if loc==0, i.e., do not ignore a + non-terminated last "line" of a file; distressingly common on Windows. + * Makefile.am (TESTS): add cnfnewline.test; + move all *.test to tests/ subdir. + (EXTRA_DIST): add tests/cnfnewline/texmf.cnf, a file without a + final newline. + * kpsewhich.test: also check that we can read the environment variable that we set. diff --git a/Build/source/texk/kpathsea/Makefile.am b/Build/source/texk/kpathsea/Makefile.am index 029fe0cd950..46e103d41eb 100644 --- a/Build/source/texk/kpathsea/Makefile.am +++ b/Build/source/texk/kpathsea/Makefile.am @@ -303,9 +303,11 @@ install-exec-hook: install-bin-links uninstall-hook: uninstall-bin-links ## The tests -TESTS = kpseaccess.test kpsereadlink.test kpsestat.test kpsewhich.test +TESTS = tests/cnfnewline.test tests/kpseaccess.test +TESTS += tests/kpsereadlink.test tests/kpsestat.test tests/kpsewhich.test TESTS_ENVIRONMENT = LN_S='$(LN_S)' LT_OBJDIR='$(LT_OBJDIR)' EXTRA_DIST += $(TESTS) +EXTRA_DIST += tests/cnfnewline/texmf.cnf # Rebuild rebuild_prereq = diff --git a/Build/source/texk/kpathsea/Makefile.in b/Build/source/texk/kpathsea/Makefile.in index 97fbc457996..ea6bb2b27ec 100644 --- a/Build/source/texk/kpathsea/Makefile.in +++ b/Build/source/texk/kpathsea/Makefile.in @@ -682,7 +682,8 @@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I ../../m4 SUBDIRS = . doc man $(am__append_6) EXTRA_DIST = BUGS PROJECTS putenv.c strcasecmp.c strtol.c strstr.c \ - bsnl.awk cnf-to-paths.awk $(TESTS) mktex.cnf + bsnl.awk cnf-to-paths.awk $(TESTS) tests/cnfnewline/texmf.cnf \ + mktex.cnf AM_CPPFLAGS = -I$(top_builddir)/.. -I$(top_srcdir)/.. AM_CFLAGS = $(WARNING_CFLAGS) lib_LTLIBRARIES = libkpathsea.la @@ -781,7 +782,9 @@ dist_web2c_DATA = mktex.opt mktexdir.opt mktexnam.opt dist_noinst_SCRIPTS = mktexlsr mktexmf mktexpk mktextfm dist_noinst_DATA = texmf.cnf bin_links = mktexlsr:texhash -TESTS = kpseaccess.test kpsereadlink.test kpsestat.test kpsewhich.test +TESTS = tests/cnfnewline.test tests/kpseaccess.test \ + tests/kpsereadlink.test tests/kpsestat.test \ + tests/kpsewhich.test TESTS_ENVIRONMENT = LN_S='$(LN_S)' LT_OBJDIR='$(LT_OBJDIR)' # Rebuild diff --git a/Build/source/texk/kpathsea/kpseaccess.test b/Build/source/texk/kpathsea/kpseaccess.test deleted file mode 100755 index 5006bcf1afa..00000000000 --- a/Build/source/texk/kpathsea/kpseaccess.test +++ /dev/null @@ -1,50 +0,0 @@ -#! /bin/sh - -# Copyright (C) 2010 Peter Breitenlohner -# You may freely use, modify and/or distribute this file. - -ret=0 - -pass () { - echo "***** unexpected success of './kpseaccess $@'" - ret=77 -} - -fail () { - echo "***** unexpected failure of './kpseaccess $@'" - ret=77 -} - -./kpseaccess '' nonesuch && exit 1 -./kpseaccess - nonesuch && exit 1 -./kpseaccess r nonesuch && exit 1 -./kpseaccess w nonesuch && exit 1 -./kpseaccess x nonesuch && exit 1 - -./kpseaccess '' access.o || exit 1 -./kpseaccess - access.o || exit 1 -./kpseaccess rw access.o || exit 1 -# From the access(3p) POSIX manpage: -# If the process has appropriate privileges, an implementation may indicate -# success for X_OK even if none of the execute file permission bits are set. -./kpseaccess x access.o && pass x access.o - -# Testing write access to kpseaccess itself might fail with ETXTBSY. -./kpseaccess rwx kpsewhich || { - fail rwx kpsewhich - ./kpseaccess r kpsewhich || fail r kpsewhich - ./kpseaccess w kpsewhich || fail w kpsewhich - ./kpseaccess x kpsewhich || fail x kpsewhich -} - -./kpseaccess r $srcdir/access.c || exit 1 -./kpseaccess x $srcdir/access.c && pass x $srcdir/access.c - -if ./kpseaccess w $srcdir/access.c; then - echo 'file "$srcdir/access.c" is writable' -else - echo 'file "$srcdir/access.c" is not writable' -fi - -exit $ret - diff --git a/Build/source/texk/kpathsea/kpsereadlink.test b/Build/source/texk/kpathsea/kpsereadlink.test deleted file mode 100755 index 7770a00bd03..00000000000 --- a/Build/source/texk/kpathsea/kpsereadlink.test +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/sh - -# Copyright (C) 2010 Peter Breitenlohner -# You may freely use, modify and/or distribute this file. - -test "x$LN_S" = 'xln -s' || exit 77 - -./kpsereadlink $LT_OBJDIR/libkpathsea.lai && exit 1 - -link=`./kpsereadlink $LT_OBJDIR/libkpathsea.la` || exit 1 - -test "x$link" = x../libkpathsea.la || exit 1 - diff --git a/Build/source/texk/kpathsea/kpsestat.test b/Build/source/texk/kpathsea/kpsestat.test deleted file mode 100755 index 8e1cf8526a4..00000000000 --- a/Build/source/texk/kpathsea/kpsestat.test +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/sh - -# Copyright (C) 2010 Peter Breitenlohner -# You may freely use, modify and/or distribute this file. - -./kpsestat = nonesuch 2>/dev/null && exit 1 - -for f in . kpsestat kpsestat.o; do - echo "kpsestat = $f => `./kpsestat = $f`" -done - -for m in -rw g-r u-w o+x -rw,u+s -rw,g+s -rw,o+t; do - echo "kpsestat $m kpsestat.o => `./kpsestat $m kpsestat.o`" -done - -echo "kpsestat = \$srcdir => `./kpsestat = $srcdir`" -echo "kpsestat = \$srcdir/ => `./kpsestat = $srcdir/`" -echo "kpsestat = \$srcdir/kpsestat.c => `./kpsestat = $srcdir/kpsestat.c`" - diff --git a/Build/source/texk/kpathsea/kpsewhich.test b/Build/source/texk/kpathsea/kpsewhich.test deleted file mode 100755 index b15f2b35400..00000000000 --- a/Build/source/texk/kpathsea/kpsewhich.test +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/sh -# Copyright 2010-2013 Peter Breitenlohner -# You may freely use, modify and/or distribute this file. - -TEXMFCNF=$srcdir -export TEXMFCNF - -./kpsewhich --var-value=TEXMFCNF || exit 1 # environment variable - -./kpsewhich --var-value=TEXMFMAIN || exit 1 - -./kpsewhich --expand-var=\$TEXMFMAIN || exit 1 - -TEXINPUTS=$srcdir/../tests/texmf \ - ./kpsewhich --all plain || exit 1 - -AFMFONTS=$srcdir/../tests/texmf \ - ./kpsewhich afmtest.afm || exit 1 - -BSTINPUTS=$srcdir/../tests/texmf \ - ./kpsewhich plain.bst || exit 1 diff --git a/Build/source/texk/kpathsea/line.c b/Build/source/texk/kpathsea/line.c index 9d8e4e9eb13..c26303a3012 100644 --- a/Build/source/texk/kpathsea/line.c +++ b/Build/source/texk/kpathsea/line.c @@ -43,11 +43,15 @@ read_line (FILE *f) } } - /* If we read anything, return it. This can't represent a last - ``line'' which doesn't end in a newline, but so what. */ - if (c != EOF) { + /* If we read anything, return it, even a partial last-line-if-file + which is not properly terminated. */ + if (loc == 0 && c == EOF) { + /* At end of file. */ + free (line); + line = NULL; + } else { /* Terminate the string. We can't represent nulls in the file, - either. Again, it doesn't matter. */ + but this doesn't matter. */ line[loc] = 0; /* Absorb LF of a CRLF pair. */ if (c == '\r') { @@ -56,9 +60,6 @@ read_line (FILE *f) ungetc (c, f); } } - } else { /* At end of file. */ - free (line); - line = NULL; } return line; diff --git a/Build/source/texk/kpathsea/tests/cnfnewline.test b/Build/source/texk/kpathsea/tests/cnfnewline.test new file mode 100755 index 00000000000..d1e64d7d6ad --- /dev/null +++ b/Build/source/texk/kpathsea/tests/cnfnewline.test @@ -0,0 +1,16 @@ +#!/bin/sh +# Copyright 2013 Peter Breitenlohner +# You may freely use, modify and/or distribute this file. + +TEXMFCNF=$srcdir/tests/cnfnewline; export TEXMFCNF + +val=`./kpsewhich --debug=-1 --var-value=lastvar` +test x"$val" = xlastval || exit 1 + +# verbose for testing. +#if test x"$val" = xlastval; then +# echo "$0: ok" +#else +# echo "$0: bad, got \`$val'" +# exit 1 +#fi diff --git a/Build/source/texk/kpathsea/tests/cnfnewline/texmf.cnf b/Build/source/texk/kpathsea/tests/cnfnewline/texmf.cnf new file mode 100644 index 00000000000..a3a189023f4 --- /dev/null +++ b/Build/source/texk/kpathsea/tests/cnfnewline/texmf.cnf @@ -0,0 +1 @@ +lastvar = lastval # with comment, but no final newline \ No newline at end of file diff --git a/Build/source/texk/kpathsea/tests/kpseaccess.test b/Build/source/texk/kpathsea/tests/kpseaccess.test new file mode 100755 index 00000000000..5006bcf1afa --- /dev/null +++ b/Build/source/texk/kpathsea/tests/kpseaccess.test @@ -0,0 +1,50 @@ +#! /bin/sh + +# Copyright (C) 2010 Peter Breitenlohner +# You may freely use, modify and/or distribute this file. + +ret=0 + +pass () { + echo "***** unexpected success of './kpseaccess $@'" + ret=77 +} + +fail () { + echo "***** unexpected failure of './kpseaccess $@'" + ret=77 +} + +./kpseaccess '' nonesuch && exit 1 +./kpseaccess - nonesuch && exit 1 +./kpseaccess r nonesuch && exit 1 +./kpseaccess w nonesuch && exit 1 +./kpseaccess x nonesuch && exit 1 + +./kpseaccess '' access.o || exit 1 +./kpseaccess - access.o || exit 1 +./kpseaccess rw access.o || exit 1 +# From the access(3p) POSIX manpage: +# If the process has appropriate privileges, an implementation may indicate +# success for X_OK even if none of the execute file permission bits are set. +./kpseaccess x access.o && pass x access.o + +# Testing write access to kpseaccess itself might fail with ETXTBSY. +./kpseaccess rwx kpsewhich || { + fail rwx kpsewhich + ./kpseaccess r kpsewhich || fail r kpsewhich + ./kpseaccess w kpsewhich || fail w kpsewhich + ./kpseaccess x kpsewhich || fail x kpsewhich +} + +./kpseaccess r $srcdir/access.c || exit 1 +./kpseaccess x $srcdir/access.c && pass x $srcdir/access.c + +if ./kpseaccess w $srcdir/access.c; then + echo 'file "$srcdir/access.c" is writable' +else + echo 'file "$srcdir/access.c" is not writable' +fi + +exit $ret + diff --git a/Build/source/texk/kpathsea/tests/kpsereadlink.test b/Build/source/texk/kpathsea/tests/kpsereadlink.test new file mode 100755 index 00000000000..7770a00bd03 --- /dev/null +++ b/Build/source/texk/kpathsea/tests/kpsereadlink.test @@ -0,0 +1,13 @@ +#! /bin/sh + +# Copyright (C) 2010 Peter Breitenlohner +# You may freely use, modify and/or distribute this file. + +test "x$LN_S" = 'xln -s' || exit 77 + +./kpsereadlink $LT_OBJDIR/libkpathsea.lai && exit 1 + +link=`./kpsereadlink $LT_OBJDIR/libkpathsea.la` || exit 1 + +test "x$link" = x../libkpathsea.la || exit 1 + diff --git a/Build/source/texk/kpathsea/tests/kpsestat.test b/Build/source/texk/kpathsea/tests/kpsestat.test new file mode 100755 index 00000000000..8e1cf8526a4 --- /dev/null +++ b/Build/source/texk/kpathsea/tests/kpsestat.test @@ -0,0 +1,19 @@ +#! /bin/sh + +# Copyright (C) 2010 Peter Breitenlohner +# You may freely use, modify and/or distribute this file. + +./kpsestat = nonesuch 2>/dev/null && exit 1 + +for f in . kpsestat kpsestat.o; do + echo "kpsestat = $f => `./kpsestat = $f`" +done + +for m in -rw g-r u-w o+x -rw,u+s -rw,g+s -rw,o+t; do + echo "kpsestat $m kpsestat.o => `./kpsestat $m kpsestat.o`" +done + +echo "kpsestat = \$srcdir => `./kpsestat = $srcdir`" +echo "kpsestat = \$srcdir/ => `./kpsestat = $srcdir/`" +echo "kpsestat = \$srcdir/kpsestat.c => `./kpsestat = $srcdir/kpsestat.c`" + diff --git a/Build/source/texk/kpathsea/tests/kpsewhich.test b/Build/source/texk/kpathsea/tests/kpsewhich.test new file mode 100755 index 00000000000..b15f2b35400 --- /dev/null +++ b/Build/source/texk/kpathsea/tests/kpsewhich.test @@ -0,0 +1,21 @@ +#! /bin/sh +# Copyright 2010-2013 Peter Breitenlohner +# You may freely use, modify and/or distribute this file. + +TEXMFCNF=$srcdir +export TEXMFCNF + +./kpsewhich --var-value=TEXMFCNF || exit 1 # environment variable + +./kpsewhich --var-value=TEXMFMAIN || exit 1 + +./kpsewhich --expand-var=\$TEXMFMAIN || exit 1 + +TEXINPUTS=$srcdir/../tests/texmf \ + ./kpsewhich --all plain || exit 1 + +AFMFONTS=$srcdir/../tests/texmf \ + ./kpsewhich afmtest.afm || exit 1 + +BSTINPUTS=$srcdir/../tests/texmf \ + ./kpsewhich plain.bst || exit 1 -- cgit v1.2.3