--- ray/src/px/psign.c 1994/02/28 09:25:31 2.16 +++ ray/src/px/psign.c 2011/05/20 02:06:39 2.27 @@ -1,23 +1,22 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: psign.c,v 2.27 2011/05/20 02:06:39 greg Exp $"; #endif - /* * psign.c - produce picture from text. * * 7/1/87 */ -#include "standard.h" +#include "copyright.h" -#include "color.h" +#include +#include "platform.h" +#include "standard.h" +#include "resolu.h" +#include "color.h" #include "font.h" -#include "paths.h" - #ifndef SSS #define SSS 3 /* super-sample size */ #endif @@ -40,6 +39,12 @@ unsigned char *ourbitmap; /* our output bitmap */ int xsiz, ysiz; /* bitmap dimensions */ int xdim; /* size of horizontal scan (bytes) */ + /* conflicting def's in param.h */ +#undef tstbit +#undef setbit +#undef clrbit +#undef tglbit + #define bitop(x,y,op) (ourbitmap[(y)*xdim+((x)>>3)] op (1<<((x)&7))) #define tstbit(x,y) bitop(x,y,&) #define setbit(x,y) bitop(x,y,|=) @@ -48,8 +53,6 @@ int xdim; /* size of horizontal scan (bytes) */ FONT *ourfont; /* our font */ -char *libpath; /* library search path */ - typedef struct line { char *s; /* line w/o LF */ short *sp; /* character spacing */ @@ -60,15 +63,24 @@ LINE *ourtext; /* our text */ int nlines, maxline; /* text dimensions */ int maxwidth; /* maximum line width (dvi) */ +static void makemap(void); +static void get_text(FILE *fp); +static void arg_text(int ac, char *av[]); +static void maptext(void); +static void mapglyph(GLYPH *gl, int tx0, int ty0); +static void mapcoord(int p[2], int tx, int ty); +static void mapedge(int x, int y, int run, int rise); +static void writemap(FILE *fp); -main(argc, argv) -int argc; -char *argv[]; + +int +main( + int argc, + char *argv[] +) { int an; -#ifdef MSDOS - setmode(fileno(stdout), O_BINARY); -#endif + SET_FILE_BINARY(stdout); for (an = 1; an < argc && argv[an][0] == '-'; an++) switch (argv[an][1]) { case 'c': /* color */ @@ -126,12 +138,10 @@ unkopt: exit(1); } /* load font file */ - if ((libpath = getenv(ULIBVAR)) == NULL) - libpath = DEFPATH; ourfont = getfont(fontfile); /* get text */ if (an == argc) - gettext(stdin); + get_text(stdin); else arg_text(argc-an, argv+an); @@ -151,7 +161,8 @@ unkopt: } -makemap() /* create the bit map */ +static void +makemap(void) /* create the bit map */ { double pictaspect; @@ -207,15 +218,17 @@ makemap() /* create the bit map */ if (ysiz % SSS) ysiz += SSS - ysiz%SSS; xdim = (xsiz+7)/8; - ourbitmap = (BYTE *)bmalloc(ysiz*xdim); + ourbitmap = (uby8 *)bmalloc(ysiz*xdim); if (ourbitmap == NULL) error(SYSTEM, "Out of memory in makemap"); - bzero((char *)ourbitmap, ysiz*xdim); + memset((char *)ourbitmap, '\0', ysiz*xdim); } -gettext(fp) /* get text from a file */ -FILE *fp; +static void +get_text( /* get text from a file */ + FILE *fp +) { char buf[MAXLINE]; register LINE *curl; @@ -229,9 +242,9 @@ FILE *fp; if (curl == NULL) goto memerr; len = strlen(buf); - curl->s = malloc(len); + curl->s = (char *)malloc(len); curl->sp = (short *)malloc(sizeof(short)*len--); - if (curl->s == NULL | curl->sp == NULL) + if ((curl->s == NULL) | (curl->sp == NULL)) goto memerr; if (len > maxline) maxline = len; @@ -253,20 +266,22 @@ FILE *fp; } return; memerr: - error(SYSTEM, "Out of memory in gettext"); + error(SYSTEM, "Out of memory in get_text"); } -arg_text(ac, av) /* get text from arguments */ -int ac; -char *av[]; +static void +arg_text( /* get text from arguments */ + int ac, + char *av[] +) { register char *cp; ourtext = (LINE *)malloc(sizeof(LINE)); if (ourtext == NULL) goto memerr; - ourtext->s = malloc(MAXLINE); + ourtext->s = (char *)malloc(MAXLINE); if (ourtext->s == NULL) goto memerr; for (cp = ourtext->s; ac-- > 0; av++) { @@ -295,7 +310,8 @@ memerr: } -maptext() /* map our text */ +static void +maptext(void) /* map our text */ { register LINE *curl; int l, len; @@ -311,9 +327,12 @@ maptext() /* map our text */ } -mapglyph(gl, tx0, ty0) /* convert a glyph */ -GLYPH *gl; -int tx0, ty0; +static void +mapglyph( /* convert a glyph */ + GLYPH *gl, + int tx0, + int ty0 +) { int n; register GORD *gp; @@ -334,8 +353,12 @@ int tx0, ty0; } -mapcoord(p, tx, ty) /* map text to picture coordinates */ -int p[2], tx, ty; +static void +mapcoord( /* map text to picture coordinates */ + int p[2], + int tx, + int ty +) { tx = (long)tx*cwidth >> 8; ty = (long)ty*cheight >> 8; @@ -361,9 +384,13 @@ int p[2], tx, ty; } -mapedge(x, y, run, rise) /* map an edge */ -register int x, y; -int run, rise; +static void +mapedge( /* map an edge */ + register int x, + register int y, + int run, + int rise +) { int xstep; int rise2, run2; @@ -398,8 +425,10 @@ int run, rise; } -writemap(fp) /* write out bitmap */ -FILE *fp; +static void +writemap( /* write out bitmap */ + FILE *fp +) { COLR pixval[SSS*SSS+1]; /* possible pixel values */ COLOR ctmp0, ctmp1; @@ -444,5 +473,5 @@ FILE *fp; exit(1); } } - free((char *)scanout); + free((void *)scanout); }