From 41e050122555719daad3bc3da47e3d559e39c42f Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Mon, 16 Jul 2012 07:18:37 +0000 Subject: ps2pkm: ANSI C in mag.c and ps2pk.c Pass proper args to kpse_set_program_name() git-svn-id: svn://tug.org/texlive/trunk@27072 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/ps2pkm/ChangeLog | 8 ++++ Build/source/texk/ps2pkm/mag.c | 17 ++++---- Build/source/texk/ps2pkm/ps2pk.c | 66 +++++++++++++++++-------------- Build/source/texk/ps2pkm/tests/ps2pk.test | 4 ++ 4 files changed, 58 insertions(+), 37 deletions(-) (limited to 'Build') diff --git a/Build/source/texk/ps2pkm/ChangeLog b/Build/source/texk/ps2pkm/ChangeLog index 9d81d99fee5..9deaa83dd10 100644 --- a/Build/source/texk/ps2pkm/ChangeLog +++ b/Build/source/texk/ps2pkm/ChangeLog @@ -1,3 +1,11 @@ +2012-07-15 Peter Breitenlohner + + * ps2pk.c: Invoke kpse_set_program_name() with original argv[0] + and program name string. + * mag.c, ps2pk.c: ANSI C function declarations and definitions. + No nested function declarations. Declare functions as static. + * tests/ps2pk.test: Set environment for kpatsea file search. + 2012-07-12 Akira Kakuto * pk2bm.c: Cast arg2 of readchar() to avoid MSVC warning. diff --git a/Build/source/texk/ps2pkm/mag.c b/Build/source/texk/ps2pkm/mag.c index f5c341bbc74..af27eaa9c51 100644 --- a/Build/source/texk/ps2pkm/mag.c +++ b/Build/source/texk/ps2pkm/mag.c @@ -80,15 +80,15 @@ int invert = 0; float DPI = 300.0; +/* Prototypes */ +static int fontsize(double); +static double stepsize(double); + int main(int argc, char *argv[]) { float sz, arg; int c; char *myname = "mag"; short done; - /* prototypes */ - int fontsize(double); - double stepsize(double); - while (--argc > 0 && (*++argv)[0] == '-') { if (isdigit((int)(*argv)[1])) { /* allow negative numbers as arguments */ break; @@ -134,13 +134,16 @@ int main(int argc, char *argv[]) { return 0; } -int fontsize(x) double x; +static int +fontsize(double x) { return(DPI*pow(1.2, x) + 0.5); } -double stepsize(x) double x; -{ double s; +static double +stepsize(double x) +{ + double s; s=(log(x)-log(DPI))/log(1.2); if (s>=0) return floor(10*s+0.5)/10; return -floor(10*(-s)+0.5)/10; diff --git a/Build/source/texk/ps2pkm/ps2pk.c b/Build/source/texk/ps2pkm/ps2pk.c index 5fa885b0e1a..7574650425d 100644 --- a/Build/source/texk/ps2pkm/ps2pk.c +++ b/Build/source/texk/ps2pkm/ps2pk.c @@ -231,9 +231,17 @@ UINT32 checksum(encoding, int [256]); UINT32 old_checksum(encoding, int [256]); UINT32 (*pchecksum)(encoding, int [256]) = checksum; -main(argc, argv) -int argc; char *argv[]; -{ char *argp, c; +/* Prototypes */ +static int next_pixel(void); +static void print_pixmap(void); +static void first_pixel(CharInfoRec *); +static INT32 TFMwidth(int); +static int h_escapement(int); +static void add_option(const char *, const char *); + +main(int argc, char *argv[]) +{ + char *argp, c; int done, i; char *myname = "ps2pk", *psname, *psbasename, *afmname = NULL, *encname = NULL, *psfile = NULL, *psfilebn, pkname[80], @@ -251,14 +259,10 @@ int argc; char *argv[]; int WX[256]; float efactor = 1.0, slant = 0.0; - - /* proto's */ - int next_pixel(); - void print_pixmap(); - void first_pixel(CharInfoRec *); - INT32 TFMwidth(int); - int h_escapement(int); - void add_option(char *, char *); + +#ifdef KPATHSEA + kpse_set_program_name(argv[0], "ps2pk"); +#endif while (--argc > 0 && (*++argv)[0] == '-') { done=0; @@ -351,10 +355,6 @@ int argc; char *argv[]; psname = argv[0]; argc--; argv++; -#ifdef KPATHSEA - kpse_set_program_name(myname, NULL); -#endif - #ifndef KPATHSEA if (ps_resource(psname)) { /* if psname does neither contain a DIRSEP or `.' character @@ -581,8 +581,10 @@ static int row, col; static int data, bitno; static unsigned char *p_data; -int next_pixel() -{ int pixel; +static int +next_pixel(void) +{ + int pixel; while (row < H) { if (col++ < W) { @@ -595,7 +597,8 @@ int next_pixel() fatal("Not that many pixels!\n"); } -void first_pixel(CharInfoRec *G) +static void +first_pixel(CharInfoRec *G) { row = col = 0; p_data = (unsigned char *) G->bits; @@ -604,8 +607,10 @@ void first_pixel(CharInfoRec *G) bitno = 0; } -void print_pixmap() -{ int c, r; +static void +print_pixmap(void) +{ + int c, r; unsigned char *save_p_data; save_p_data = p_data; @@ -625,7 +630,8 @@ void print_pixmap() an integer representation for fractions. The decimal point is left from bit 20. (The method is `stolen' from afm2tfm.) */ -INT32 TFMwidth(int wx) +static INT32 +TFMwidth(int wx) { return (((wx / 1000) << 20) + (((wx % 1000) << 20) + 500) / 1000) ; @@ -634,7 +640,8 @@ INT32 TFMwidth(int wx) static float HXU = -1.0; /* horizontal pixels per design unit */ /* the horizontal escapent is the number of pixels to next origin */ -int h_escapement(int wx) +static int +h_escapement(int wx) { if (HXU == -1.0) HXU = (pointsize * x_resolution) / 72270.0; @@ -642,7 +649,9 @@ int h_escapement(int wx) } /* add ps2pk option to string */ -void add_option(char *option, char *value) { +static void +add_option(const char *option, const char *value) +{ static char *p_args = NULL; if (p_args == NULL) { @@ -665,22 +674,19 @@ int CheckFSFormat(format, fmask, bit, Byte, scan, glyph, image) } -long MakeAtom(p, len, foo) - char *p; - unsigned int len; - Bool foo; +long MakeAtom(char *p, unsigned int len, Bool foo) { return (long)p; } -GetClientResolutions(resP) - int *resP; +GetClientResolutions(int *resP) { *resP = 0; } char *Xalloc(size_t size) -{ char *p; +{ + char *p; p = malloc(size); if (p == NULL) fatal("Out of memory\n"); return p; diff --git a/Build/source/texk/ps2pkm/tests/ps2pk.test b/Build/source/texk/ps2pkm/tests/ps2pk.test index 103b717273c..eae7c950266 100755 --- a/Build/source/texk/ps2pkm/tests/ps2pk.test +++ b/Build/source/texk/ps2pkm/tests/ps2pk.test @@ -3,6 +3,10 @@ # Copyright (C) 2012 Peter Breitenlohner # You may freely use, modify and/or distribute this file. +TEXMFCNF=$srcdir/../kpathsea +TEXFONTS=. +export TEXMFCNF TEXFONTS + rm -f Symbol* cp $srcdir/tests/Symbol.afm $srcdir/tests/Symbol.pfb . -- cgit v1.2.3