head 1.4; access; symbols pkgsrc-2013Q2:1.4.0.54 pkgsrc-2013Q2-base:1.4 pkgsrc-2012Q4:1.4.0.52 pkgsrc-2012Q4-base:1.4 pkgsrc-2011Q4:1.4.0.50 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q2:1.4.0.48 pkgsrc-2011Q2-base:1.4 pkgsrc-2009Q4:1.4.0.46 pkgsrc-2009Q4-base:1.4 pkgsrc-2008Q4:1.4.0.44 pkgsrc-2008Q4-base:1.4 pkgsrc-2008Q3:1.4.0.42 pkgsrc-2008Q3-base:1.4 cube-native-xorg:1.4.0.40 cube-native-xorg-base:1.4 pkgsrc-2008Q2:1.4.0.38 pkgsrc-2008Q2-base:1.4 pkgsrc-2008Q1:1.4.0.36 pkgsrc-2008Q1-base:1.4 pkgsrc-2007Q4:1.4.0.34 pkgsrc-2007Q4-base:1.4 pkgsrc-2007Q3:1.4.0.32 pkgsrc-2007Q3-base:1.4 pkgsrc-2007Q2:1.4.0.30 pkgsrc-2007Q2-base:1.4 pkgsrc-2007Q1:1.4.0.28 pkgsrc-2007Q1-base:1.4 pkgsrc-2006Q4:1.4.0.26 pkgsrc-2006Q4-base:1.4 pkgsrc-2006Q3:1.4.0.24 pkgsrc-2006Q3-base:1.4 pkgsrc-2006Q2:1.4.0.22 pkgsrc-2006Q2-base:1.4 pkgsrc-2006Q1:1.4.0.20 pkgsrc-2006Q1-base:1.4 pkgsrc-2005Q4:1.4.0.18 pkgsrc-2005Q4-base:1.4 pkgsrc-2005Q3:1.4.0.16 pkgsrc-2005Q3-base:1.4 pkgsrc-2005Q2:1.4.0.14 pkgsrc-2005Q2-base:1.4 pkgsrc-2005Q1:1.4.0.12 pkgsrc-2005Q1-base:1.4 pkgsrc-2004Q4:1.4.0.10 pkgsrc-2004Q4-base:1.4 pkgsrc-2004Q3:1.4.0.8 pkgsrc-2004Q3-base:1.4 pkgsrc-2004Q2:1.4.0.6 pkgsrc-2004Q2-base:1.4 pkgsrc-2004Q1:1.4.0.4 pkgsrc-2004Q1-base:1.4 pkgsrc-2003Q4:1.4.0.2 pkgsrc-2003Q4-base:1.4 buildlink2-base:1.4 netbsd-1-4-PATCH002:1.3 comdex-fall-1999:1.3 netbsd-1-4-PATCH001:1.3 netbsd-1-4-RELEASE:1.3 netbsd-1-3-PATCH003:1.2; locks; strict; comment @# @; 1.4 date 2000.05.17.10.13.23; author tron; state dead; branches; next 1.3; 1.3 date 99.01.10.23.52.17; author tron; state Exp; branches; next 1.2; 1.2 date 98.08.07.10.40.50; author agc; state Exp; branches; next 1.1; 1.1 date 98.07.15.19.52.56; author tron; state Exp; branches; next ; desc @@ 1.4 log @Update "netpbm" package to version 9.2. There are too many changes and bug fixes to list here. Main new features are shared libraries, JPEG and JBIG support. @ text @$NetBSD: patch-bd,v 1.3 1999/01/10 23:52:17 tron Exp $ --- ppm/ppmtoxpm.c.orig Mon Jan 31 08:44:41 1994 +++ ppm/ppmtoxpm.c Sun Jan 10 23:48:41 1999 @@@@ -27,11 +27,25 @@@@ ** ** - lowercase conversion of RGB names def'ed out, ** considered harmful. +** +** Michael Pall (pall@@rz.uni-karlsruhe.de) - 29 Nov 93: +** - Use the algorithm from xpm-lib for pixel encoding +** (base 93 not base 28 -> saves a lot of space for colorful xpms) */ +#include +#include #include "ppm.h" #include "ppmcmap.h" +#if defined(SYSV) || defined(SVR4) +#include +#ifndef index +#define index strchr +#endif +#else /* SYSV */ +#include +#endif /* SYSV */ /* Max number of colors allowed in ppm input. */ #define MAXCOLORS 256 @@@@ -39,15 +53,19 @@@@ /* Max number of rgb mnemonics allowed in rgb text file. */ #define MAX_RGBNAMES 1024 -/* Lower bound and upper bound of character-pixels printed in XPM output. - Be careful, don't want the character '"' in this range. */ -/*#define LOW_CHAR '#' <-- minimum ascii character allowed */ -/*#define HIGH_CHAR '~' <-- maximum ascii character allowed */ -#define LOW_CHAR '`' -#define HIGH_CHAR 'z' +#define MAXPRINTABLE 92 /* number of printable ascii chars + * minus \ and " for string compat + * and ? to avoid ANSI trigraphs. */ + +static char *printable = +" .XoO+@@#$%&*=-;:>,<1234567890qwertyuipasdfghjklzxcvbnmMNBVCZ\ +ASDFGHJKLPIUYTREWQ!~^/()_`'][{}|"; + #define max(a,b) ((a) > (b) ? (a) : (b)) +void read_rgb_names(); /* forward reference */ +void gen_cmap(); /* forward reference */ typedef struct { /* rgb values and ascii names (from * rgb text file) */ @@@@ -62,17 +80,8 @@@@ * mnemonic or #rgb value */ } cixel_map; - -/* prototypes/forward reference */ -static void read_rgb_names ARGS((char *, rgb_names *, int *)); -static char * gen_numstr ARGS((int, int, int)); -static void gen_cmap ARGS((colorhist_vector, int, pixval, int, rgb_names *, int, cixel_map *, int *)); - - pixel **pixels; - -int main(argc, argv) int argc; char *argv[]; @@@@ -88,11 +97,11 @@@@ /* Used for rgb value -> rgb mnemonic mapping */ int map_rgb_names = 0; - rgb_names *rgbn; /* rgb_names rgbn[MAX_RGBNAMES]; */ + rgb_names rgbn[MAX_RGBNAMES]; int rgbn_max; /* Used for rgb value -> character-pixel string mapping */ - cixel_map *cmap; /* cixel_map cmap[MAXCOLORS]; */ + cixel_map cmap[MAXCOLORS]; int charspp; /* chars per pixel */ char out_name[100], rgb_fname[100], *cp; @@@@ -188,17 +197,9 @@@@ * If a rgb text file was specified, read in the rgb mnemonics. Does not * return if fatal error occurs. */ - rgbn = (rgb_names *) malloc(MAX_RGBNAMES * sizeof(rgb_names)); - if (rgbn == (rgb_names *) NULL) - pm_error("out of memory"); - if (map_rgb_names) read_rgb_names(rgb_fname, rgbn, &rgbn_max); - cmap = (cixel_map *)malloc(ncolors * sizeof(cixel_map)); - if (cmap == (cixel_map *) NULL) - pm_error("out of memory"); - /* Now generate the character-pixel colormap table. */ gen_cmap(chv, ncolors, maxval, map_rgb_names, rgbn, rgbn_max, cmap, &charspp); @@@@ -231,12 +232,12 @@@@ /* This routine reads a rgb text file. It stores the rgb values (0->65535) and the rgb mnemonics (malloc'ed) into the "rgbn" array. Returns the number of entries stored in "rgbn_max". */ -static void read_rgb_names(rgb_fname, rgbn, rgbn_max) char *rgb_fname; - rgb_names *rgbn; - int *rgbn_max; + rgb_names rgbn[MAX_RGBNAMES]; +int *rgbn_max; + { FILE *rgbf; int i, items, red, green, blue; @@@@ -303,16 +304,16 @@@@ } /* read_rgb_names */ /*---------------------------------------------------------------------------*/ -/* Given a number and a base, (base == HIGH_CHAR-LOW_CHAR+1), this routine +/* Given a number and a base (MAXPRINTABLE), this routine prints the number into a malloc'ed string and returns it. The length of the string is specified by "digits". The ascii characters of the printed - number range from LOW_CHAR to HIGH_CHAR. The string is LOW_CHAR filled, - (e.g. if LOW_CHAR==0, HIGH_CHAR==1, digits==5, i=3, routine would return - the malloc'ed string "00011"). */ -static + number range from printable[0] to printable[MAXPRINTABLE]. The string is + printable[0] filled, (e.g. if printable[0]==0, printable[1]==1, + MAXPRINTABLE==2, digits==5, i=3, routine would return the malloc'ed + string "00011"). */ char * -gen_numstr(i, base, digits) - int i, base, digits; +gen_numstr(i, digits) + int i, digits; { char *str, *p; int d; @@@@ -325,9 +326,9 @@@@ p = str + digits; *p-- = '\0'; /* nul terminate string */ while (p >= str) { - d = i % base; - i /= base; - *p-- = (char) ((int) LOW_CHAR + d); + d = i % MAXPRINTABLE; + i /= MAXPRINTABLE; + *p-- = printable[d]; } return str; @@@@ -336,7 +337,6 @@@@ /*---------------------------------------------------------------------------*/ /* This routine generates the character-pixel colormap table. */ -static void gen_cmap(chv, ncolors, maxval, map_rgb_names, rgbn, rgbn_max, cmap, charspp) @@@@ -348,16 +348,16 @@@@ * == unsigned short) */ int map_rgb_names; /* == 1 if mapping rgb values to rgb * mnemonics */ - rgb_names *rgbn; /* rgb mnemonics from rgb text file */ + rgb_names rgbn[MAX_RGBNAMES]; /* rgb mnemonics from rgb text file */ int rgbn_max; /* number of rgb mnemonics in table */ /* output: */ -cixel_map *cmap; /* pixel strings and ascii rgb +cixel_map cmap[MAXCOLORS]; /* pixel strings and ascii rgb * colors */ int *charspp; /* characters per pixel */ { - int i, j, base, cpp, mval, red, green, blue, r, g, b, matched; + int i, j, cpp, mval, red, green, blue, r, g, b, matched; char *str; /* @@@@ -365,9 +365,8 @@@@ * to be forced to link with libm.a, so using a division loop rather * than a log function. */ - base = (int) HIGH_CHAR - (int) LOW_CHAR + 1; for (cpp = 0, j = ncolors; j; cpp++) - j /= base; + j /= MAXPRINTABLE; *charspp = cpp; /* @@@@ -392,10 +391,11 @@@@ /* * The character-pixel string is simply a printed number in base - * "base" where the digits of the number range from LOW_CHAR to - * HIGH_CHAR and the printed length of the number is "cpp". + * MAXPRINTABLE where the digits of the number range from + * printable[0] .. printable[MAXPRINTABLE-1] and the printed length + * of the number is "cpp". */ - cmap[i].cixel = gen_numstr(i, base, cpp); + cmap[i].cixel = gen_numstr(i, cpp); /* Fetch the rgb value of the current colormap entry. */ red = PPM_GETR(chv[i].color); @ 1.3 log @Major cleanup of "netpbm" package based on patches supply by John F. Woods in PR pkg/6763 and Rob Windsor in PR pkg/6779. @ text @d1 1 a1 1 $NetBSD$ @ 1.2 log @Add NetBSD RCS Ids. @ text @d3 211 a213 16 --- ./pbm/pbmtext.c.orig Wed Oct 27 03:27:04 1993 +++ ./pbm/pbmtext.c Sat Jul 20 21:48:12 1996 @@@@ -105,10 +105,12 @@@@ else { /* Read text from stdin. */ lines = 0; - while ( gets( buf ) != NULL ) + while ( fgets( buf, sizeof(buf), stdin ) != NULL ) { int l; + char *nl = strchr(buf, '\n'); + if (nl) *nl = 0; fix_control_chars( buf ); l = strlen( buf ); if ( lines >= maxlines ) @ 1.1 log @Add well known fixes for "netpbm-1mar1994" supplied by John F. Woods in PR pkg/5723. @ text @d1 2 @