From 4b03ba0b3e4f12e432a169961697a7d7776cfb17 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 11 Apr 2010 00:54:05 +0000 Subject: snprintf for afm2tfm; add (very) basic test for it git-svn-id: svn://tug.org/texlive/trunk@17798 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipsk/ChangeLog | 7 ++ Build/source/texk/dvipsk/Makefile.am | 3 +- Build/source/texk/dvipsk/Makefile.in | 3 +- Build/source/texk/dvipsk/afm2tfm-test.pl | 19 +++++ Build/source/texk/dvipsk/afm2tfm.c | 112 +++++++++++++++--------------- Build/source/texk/tests/ChangeLog | 4 ++ Build/source/texk/tests/common-test.pl | 3 +- Build/source/texk/tests/texmf/afmtest.afm | 23 ++++++ 8 files changed, 116 insertions(+), 58 deletions(-) create mode 100755 Build/source/texk/dvipsk/afm2tfm-test.pl create mode 100644 Build/source/texk/tests/texmf/afmtest.afm (limited to 'Build/source/texk') diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog index 314a2e2b061..4b2a5cf53e4 100644 --- a/Build/source/texk/dvipsk/ChangeLog +++ b/Build/source/texk/dvipsk/ChangeLog @@ -1,3 +1,10 @@ +2010-04-11 Karl Berry + + * afm2tfm.c (staticligkern): restore spaces around semicolons, + accidentally removed in source cleanup. + + * afm2tfm.c (throughout): use snprintf where needed. + 2010-03-29 Karl Berry * loadfont.c, diff --git a/Build/source/texk/dvipsk/Makefile.am b/Build/source/texk/dvipsk/Makefile.am index 9affa4a738c..76d6e96664d 100644 --- a/Build/source/texk/dvipsk/Makefile.am +++ b/Build/source/texk/dvipsk/Makefile.am @@ -110,7 +110,8 @@ EXTRA_DIST = $(dist_prologues) texc.script CLEANFILES = $(prologues) texc.lpro ## dvips tests -TESTS = beginfontk1.test dvips.test pfbincl.test quotecmd-test.pl +TESTS = afm2tfm-test.pl +TESTS += beginfontk1.test dvips.test pfbincl.test quotecmd-test.pl TESTS_ENVIRONMENT = TEXMFCNF=$(srcdir)/../kpathsea TEXCONFIG=$(srcdir)/testdata TESTS_ENVIRONMENT += TEXFONTS=$(srcdir)/testdata diff --git a/Build/source/texk/dvipsk/Makefile.in b/Build/source/texk/dvipsk/Makefile.in index 80a97855af5..14a6bbb0239 100644 --- a/Build/source/texk/dvipsk/Makefile.in +++ b/Build/source/texk/dvipsk/Makefile.in @@ -405,7 +405,8 @@ EXTRA_DIST = $(dist_prologues) texc.script NEWS TODO beginfontk1.test \ mvs psfonts.map tex vmcms vms CLEANFILES = $(prologues) texc.lpro dvipstst.ps missfont.log mtest.ps \ pfbincl.ps -TESTS = beginfontk1.test dvips.test pfbincl.test quotecmd-test.pl +TESTS = afm2tfm-test.pl beginfontk1.test dvips.test pfbincl.test \ + quotecmd-test.pl TESTS_ENVIRONMENT = TEXMFCNF=$(srcdir)/../kpathsea \ TEXCONFIG=$(srcdir)/testdata TEXFONTS=$(srcdir)/testdata \ TEXPSHEADERS=$(srcdir)/testdata diff --git a/Build/source/texk/dvipsk/afm2tfm-test.pl b/Build/source/texk/dvipsk/afm2tfm-test.pl new file mode 100755 index 00000000000..69704ae0f0d --- /dev/null +++ b/Build/source/texk/dvipsk/afm2tfm-test.pl @@ -0,0 +1,19 @@ +#!/usr/bin/env perl +# $Id$ +# Public domain. Originally written 2010, Karl Berry. +# Check that afm2tfm functions at all. + +BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `dirname $0`); } +require "$srcdir/../tests/common-test.pl"; + +exit (&main ()); + +sub main +{ + my $outfile = "afmtest.tfm"; + my @args = ("afmtest.afm", $outfile); # should be found via kpse + my $ret = &test_run ("./afm2tfm", @args); + + my $bad = ! -f $outfile; # tfm should have been created + return $bad; +} diff --git a/Build/source/texk/dvipsk/afm2tfm.c b/Build/source/texk/dvipsk/afm2tfm.c index 4c56b0091eb..e0d79f05bb8 100644 --- a/Build/source/texk/dvipsk/afm2tfm.c +++ b/Build/source/texk/dvipsk/afm2tfm.c @@ -104,55 +104,55 @@ struct encoding staticencoding = { * than to build the structures ourselves. */ const char *staticligkern[] = { - "% LIGKERN space l =: lslash; space L =: Lslash;", - "% LIGKERN question quoteleft =: questiondown;", - "% LIGKERN exclam quoteleft =: exclamdown;", - "% LIGKERN hyphen hyphen =: endash; endash hyphen =: emdash;", - "% LIGKERN quoteleft quoteleft =: quotedblleft;", - "% LIGKERN quoteright quoteright =: quotedblright;", - "% LIGKERN space {} *; * {} space; zero {} *; * {} zero;", - "% LIGKERN one {} *; * {} one; two {} *; * {} two;", - "% LIGKERN three {} *; * {} three; four {} *; * {} four;", - "% LIGKERN five {} *; * {} five; six {} *; * {} six;", - "% LIGKERN seven {} *; * {} seven; eight {} *; * {} eight;", - "% LIGKERN nine {} *; * {} nine;", + "% LIGKERN space l =: lslash ; space L =: Lslash ;", + "% LIGKERN question quoteleft =: questiondown ;", + "% LIGKERN exclam quoteleft =: exclamdown ;", + "% LIGKERN hyphen hyphen =: endash ; endash hyphen =: emdash ;", + "% LIGKERN quoteleft quoteleft =: quotedblleft ;", + "% LIGKERN quoteright quoteright =: quotedblright ;", + "% LIGKERN space {} * ; * {} space ; zero {} * ; * {} zero ;", + "% LIGKERN one {} * ; * {} one ; two {} * ; * {} two ;", + "% LIGKERN three {} * ; * {} three ; four {} * ; * {} four ;", + "% LIGKERN five {} * ; * {} five ; six {} * ; * {} six ;", + "% LIGKERN seven {} * ; * {} seven ; eight {} * ; * {} eight ;", + "% LIGKERN nine {} * ; * {} nine ;", /* Kern accented characters the same way as their base. */ - "% LIGKERN Aacute <> A; aacute <> a;", - "% LIGKERN Acircumflex <> A; acircumflex <> a;", - "% LIGKERN Adieresis <> A; adieresis <> a;", - "% LIGKERN Agrave <> A; agrave <> a;", - "% LIGKERN Aring <> A; aring <> a;", - "% LIGKERN Atilde <> A; atilde <> a;", - "% LIGKERN Ccedilla <> C; ccedilla <> c;", - "% LIGKERN Eacute <> E; eacute <> e;", - "% LIGKERN Ecircumflex <> E; ecircumflex <> e;", - "% LIGKERN Edieresis <> E; edieresis <> e;", - "% LIGKERN Egrave <> E; egrave <> e;", - "% LIGKERN Iacute <> I; iacute <> i;", - "% LIGKERN Icircumflex <> I; icircumflex <> i;", - "% LIGKERN Idieresis <> I; idieresis <> i;", - "% LIGKERN Igrave <> I; igrave <> i;", - "% LIGKERN Ntilde <> N; ntilde <> n;", - "% LIGKERN Oacute <> O; oacute <> o;", - "% LIGKERN Ocircumflex <> O; ocircumflex <> o;", - "% LIGKERN Odieresis <> O; odieresis <> o;", - "% LIGKERN Ograve <> O; ograve <> o;", - "% LIGKERN Oslash <> O; oslash <> o;", - "% LIGKERN Otilde <> O; otilde <> o;", - "% LIGKERN Scaron <> S; scaron <> s;", - "% LIGKERN Uacute <> U; uacute <> u;", - "% LIGKERN Ucircumflex <> U; ucircumflex <> u;", - "% LIGKERN Udieresis <> U; udieresis <> u;", - "% LIGKERN Ugrave <> U; ugrave <> u;", - "% LIGKERN Yacute <> Y; yacute <> y;", - "% LIGKERN Ydieresis <> Y; ydieresis <> y;", - "% LIGKERN Zcaron <> Z; zcaron <> z;", + "% LIGKERN Aacute <> A ; aacute <> a ;", + "% LIGKERN Acircumflex <> A ; acircumflex <> a ;", + "% LIGKERN Adieresis <> A ; adieresis <> a ;", + "% LIGKERN Agrave <> A ; agrave <> a ;", + "% LIGKERN Aring <> A ; aring <> a ;", + "% LIGKERN Atilde <> A ; atilde <> a ;", + "% LIGKERN Ccedilla <> C ; ccedilla <> c ;", + "% LIGKERN Eacute <> E ; eacute <> e ;", + "% LIGKERN Ecircumflex <> E ; ecircumflex <> e ;", + "% LIGKERN Edieresis <> E ; edieresis <> e ;", + "% LIGKERN Egrave <> E ; egrave <> e ;", + "% LIGKERN Iacute <> I ; iacute <> i ;", + "% LIGKERN Icircumflex <> I ; icircumflex <> i ;", + "% LIGKERN Idieresis <> I ; idieresis <> i ;", + "% LIGKERN Igrave <> I ; igrave <> i ;", + "% LIGKERN Ntilde <> N ; ntilde <> n ;", + "% LIGKERN Oacute <> O ; oacute <> o ;", + "% LIGKERN Ocircumflex <> O ; ocircumflex <> o ;", + "% LIGKERN Odieresis <> O ; odieresis <> o ;", + "% LIGKERN Ograve <> O ; ograve <> o ;", + "% LIGKERN Oslash <> O ; oslash <> o ;", + "% LIGKERN Otilde <> O ; otilde <> o ;", + "% LIGKERN Scaron <> S ; scaron <> s ;", + "% LIGKERN Uacute <> U ; uacute <> u ;", + "% LIGKERN Ucircumflex <> U ; ucircumflex <> u ;", + "% LIGKERN Udieresis <> U ; udieresis <> u ;", + "% LIGKERN Ugrave <> U ; ugrave <> u ;", + "% LIGKERN Yacute <> Y ; yacute <> y ;", + "% LIGKERN Ydieresis <> Y ; ydieresis <> y ;", + "% LIGKERN Zcaron <> Z ; zcaron <> z ;", /* * These next are only included for deficient afm files that * have the lig characters but not the lig commands. */ - "% LIGKERN f i =: fi; f l =: fl; f f =: ff; ff i =: ffi;", - "% LIGKERN ff l =: ffl;", + "% LIGKERN f i =: fi ; f l =: fl ; f f =: ff ; ff i =: ffi ;", + "% LIGKERN ff l =: ffl ;", 0 }; /* * The above layout corresponds to TeX Typewriter Type and is compatible @@ -1262,14 +1262,15 @@ vchar(int c) return (vcharbuf); } -char vnamebuf[100]; +char vnamebuf[1000]; static char * vname(int c) { if (!forceoctal && ISALNUM (c)) { vnamebuf[0] = 0; } else if (c >= 0 && c < 256) { - sprintf (vnamebuf, " (comment %s)", texptrs[c]->adobename); + snprintf (vnamebuf, sizeof (vnamebuf), + " (comment %s)", texptrs[c]->adobename); } return vnamebuf; } @@ -1289,7 +1290,7 @@ writevpl(void) voutln2("(VTITLE Created by %s)", titlebuf); voutln("(COMMENT Please edit that VTITLE if you edit this file)"); - (void)sprintf(obuffer, "TeX-%s%s%s%s", outname, + snprintf(obuffer, sizeof(obuffer), "TeX-%s%s%s%s", outname, (efactor==1.0? "" : "-E"), (slant==0.0? "" : "-S"), (makevpl==1? "" : "-CSC")); if (strlen(obuffer)>19) { /* too long, will retain first 9 and last 10 */ @@ -1309,9 +1310,10 @@ writevpl(void) #endif if (strcmp (outencoding->name, base_encoding) == 0) { - sprintf(tbuf, "%s", outencoding->name); + snprintf(tbuf, sizeof(tbuf), "%s", outencoding->name); } else { - sprintf(tbuf, "%s + %s", base_encoding, outencoding->name); + snprintf(tbuf, sizeof(tbuf), "%s + %s", base_encoding, + outencoding->name); } if (strlen(tbuf) > 39) { @@ -1577,13 +1579,13 @@ openfiles(int argc, char **argv) #if defined(MSDOS) || defined(OS2) || defined(ATARIST) /* Make VPL file identical to that created under Unix */ - (void)sprintf(titlebuf, "afm2tfm %s", argv[1]); + snprintf(titlebuf, sizeof(titlebuf), "afm2tfm %s", argv[1]); #else #ifdef VMCMS /* Make VPL file identical to that created under Unix */ - (void)sprintf(titlebuf, "afm2tfm %s", argv[1]); + snprintf(titlebuf, sizeof(titlebuf), "afm2tfm %s", argv[1]); #else - (void)sprintf(titlebuf, "%s %s", argv[0], argv[1]); + snprintf(titlebuf, sizeof(titlebuf), "%s %s", argv[0], argv[1]); #endif #endif (void)strcpy(inname, argv[1]); @@ -1669,11 +1671,11 @@ case 'u': pedantic = 1; arginc = 1; break; -default: (void)fprintf(stderr, "Unknown option %s %s will be ignored.\n", - argv[2], argv[3]); +default: fprintf(stderr, "Unknown option %s %s ignored.\n", argv[2], argv[3]); } for (i=0; i + + * common-test.pl (AFMFONTS): set also. + 2010-03-08 Karl Berry * texmf/: new subdir. diff --git a/Build/source/texk/tests/common-test.pl b/Build/source/texk/tests/common-test.pl index fe7f9d0bdb6..e12b6f46be8 100644 --- a/Build/source/texk/tests/common-test.pl +++ b/Build/source/texk/tests/common-test.pl @@ -5,7 +5,8 @@ # srcdir must be a sibling dir to kpathsea, e.g., web2c. $ENV{"TEXMFCNF"} = "$srcdir/../kpathsea"; -$ENV{"BIBINPUTS"} +$ENV{"AFMFONTS"} + = $ENV{"BIBINPUTS"} = $ENV{"BSTINPUTS"} = $ENV{"TEXINPUTS"} = ".:$srcdir/tests:$srcdir/../tests/texmf//"; diff --git a/Build/source/texk/tests/texmf/afmtest.afm b/Build/source/texk/tests/texmf/afmtest.afm new file mode 100644 index 00000000000..ab46eaa4edd --- /dev/null +++ b/Build/source/texk/tests/texmf/afmtest.afm @@ -0,0 +1,23 @@ +StartFontMetrics 2.0 +Comment $Id$ +Comment Public domain. Originally written by Karl Berry. +Comment Creation Date: 11apr10 +FontName Afmtest +FullName AFM Test +FamilyName Afmtest +Weight Invisible +ItalicAngle 0 +IsFixedPitch false +FontBBox 0 0 0 0 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.000 +Notice Public domain. +EncodingScheme SpaceOnly +CapHeight 1000 +XHeight 500 +Ascender 1000 +Descender -250 +StartCharMetrics 1 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +EndFontMetrics -- cgit v1.2.3