diff options
author | 2020-03-19 13:53:45 +0100 | |
---|---|---|
committer | 2020-08-13 11:28:25 +0200 | |
commit | dc2ba49207af71193f1390d84bba4e15aeea0ce0 (patch) | |
tree | 79c2a51cb5fa2b87800b1113e0015a7108cd2eb3 /contrib | |
parent | Import Ghostscript 9.50 (diff) | |
download | ghostscript-gpl-patches-dc2ba49207af71193f1390d84bba4e15aeea0ce0.tar.gz ghostscript-gpl-patches-dc2ba49207af71193f1390d84bba4e15aeea0ce0.tar.bz2 ghostscript-gpl-patches-dc2ba49207af71193f1390d84bba4e15aeea0ce0.zip |
Import Ghostscript 9.52ghostscript-9.52
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'contrib')
37 files changed, 1316 insertions, 735 deletions
diff --git a/contrib/contrib.mak b/contrib/contrib.mak index 5411ae90..bb266407 100644 --- a/contrib/contrib.mak +++ b/contrib/contrib.mak @@ -141,6 +141,30 @@ CONTRIBSRC=$(CONTRIBDIR)$(D) ###### ----------------------- End of catalog ----------------------- ###### +### --------------------- The Apple printer devices --------------------- ### +### Note: these drivers were contributed by users. ### +### ### +### Maintained by Mike Galatean contact via https://bugs.ghostscript.com ### +### ### + +appledmp_=$(DEVOBJ)gdevadmp.$(OBJ) + +$(DEVOBJ)gdevadmp.$(OBJ) : $(CONTRIBSRC)gdevadmp.c $(PDEVH) $(CONTRIB_MAK) $(MAKEDIRS) + $(DEVCC) $(DEVO_)gdevadmp.$(OBJ) $(C_) $(CONTRIBSRC)gdevadmp.c + +$(DD)appledmp.dev : $(appledmp_) $(DD)page.dev $(CONTRIB_MAK) $(MAKEDIRS) + $(SETPDEV) $(DD)appledmp $(appledmp_) + +$(DD)iwhi.dev : $(appledmp_) $(DD)page.dev $(CONTRIB_MAK) $(MAKEDIRS) + $(SETPDEV) $(DD)iwhi $(appledmp_) + +$(DD)iwlo.dev : $(appledmp_) $(DD)page.dev $(CONTRIB_MAK) $(MAKEDIRS) + $(SETPDEV) $(DD)iwlo $(appledmp_) + +$(DD)iwlq.dev : $(appledmp_) $(DD)page.dev $(CONTRIB_MAK) $(MAKEDIRS) + $(SETPDEV) $(DD)iwlq $(appledmp_) + + ### ----------------- The BJC-210/240/250/250ex/265/1000 ---------------- ### ### @@ -1200,15 +1224,15 @@ $(DD)rpdl.dev : $(rpdl_) $(DD)page.dev \ ### ---------- RICOH RPDL IV(600dpi) printer devices ---------- ### #rpdl_=$(DEVOBJ)gdevrpdl.$(OBJ) #$(DEVOBJ)gdevrpdl.$(OBJ) : $(JAPSRC)gdevrpdl.c \ - $(CONTRIB_MAK) $(MAKEDIRS) +# $(CONTRIB_MAK) $(MAKEDIRS) # $(DEVCC) $(DEVO_)gdevrpdl.$(OBJ) $(C_) $(JAPSRC)gdevrpdl.c # #$(DD)nx100f.dev : $(rpdl_) $(DD)page.dev \ - $(CONTRIB_MAK) $(MAKEDIRS) +# $(CONTRIB_MAK) $(MAKEDIRS) # $(SETPDEV2) $(DD)nx100f $(rpdl_) # #$(DD)nx100v.dev : $(rpdl_) $(DD)page.dev \ - $(CONTRIB_MAK) $(MAKEDIRS) +# $(CONTRIB_MAK) $(MAKEDIRS) # $(SETPDEV2) $(DD)nx100v $(rpdl_) ### ------------ The ALPS Micro Dry printer devices ------------ ### diff --git a/contrib/eplaser/gdevescv.c b/contrib/eplaser/gdevescv.c index afcbdfd7..c7bd29e1 100644 --- a/contrib/eplaser/gdevescv.c +++ b/contrib/eplaser/gdevescv.c @@ -33,6 +33,15 @@ */ +#include <stdlib.h> /* for abs() and free */ + +/* Get this definition in before we read memento.h */ +static void +unvectored_free(void *x) +{ + free(x); +} + #if ( 6 > GS_VERSION_MAJOR ) #include <string.h> @@ -59,7 +68,6 @@ #else /* 6 <= GS_VERSION_MAJOR */ #include "math_.h" -#include <stdlib.h> /* for abs() */ #include <sys/utsname.h> /* for uname(2) */ #include <ctype.h> /* for toupper(3) */ @@ -969,7 +977,11 @@ escv_beginpage(gx_device_vector * vdev) { time_t t; +#ifdef CLUSTER + memset(&t, 0, sizeof(t)); +#else time(&t); +#endif lputs(s, " DATE=\""); { @@ -977,8 +989,14 @@ escv_beginpage(gx_device_vector * vdev) char str[32]; size_t i; +#ifdef CLUSTER + memset(&tm, 0, sizeof(tm)); + strcpy(str, "1970/01/01 00:00:00"); + i = strlen(str); +#else tm = localtime( &t ); i = strftime(str, 30, "%Y/%m/%d %H:%M:%S", tm); +#endif if ( 30 >= i ) str[i] = '\0'; @@ -1014,7 +1032,8 @@ escv_beginpage(gx_device_vector * vdev) if (sysname) { lputs(s, sysname ); - free (sysname); + /* Carefully avoid memento interfering here. */ + unvectored_free(sysname); sysname = NULL; } } @@ -2035,6 +2054,7 @@ escv_put_params(gx_device * dev, gs_param_list * plist) ecode = code; pmediae: param_signal_error(plist, param_name, ecode); + /* Fall through. */ case 1: if(!pdev->MediaType){ pdev->MediaType = 0; diff --git a/contrib/gdevadmp.c b/contrib/gdevadmp.c new file mode 100644 index 00000000..d48c0dab --- /dev/null +++ b/contrib/gdevadmp.c @@ -0,0 +1,410 @@ +/* Copyright (C) 2001-2019 Artifex Software, Inc. + All Rights Reserved. + + This software is provided AS-IS with no warranty, either express or + implied. + + This software is distributed under license and may not be copied, + modified or distributed except as expressly authorized under the terms + of the license contained in the file LICENSE in this distribution. + + Refer to licensing information at http://www.artifex.com or contact + Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, + CA 94945, U.S.A., +1(415)492-9861, for further information. +*/ + +/* + * Apple DMP / Imagewriter driver + * + * This is a modification of Mark Wedel's Apple DMP and + * Jonathan Luckey's Imagewriter II driver to + * support the Imagewriter LQ's higher resolution (320x216): + * appledmp: 120dpi x 72dpi is still supported (yuck) + * iwlo: 160dpi x 72dpi + * iwhi: 160dpi x 144dpi + * iwlq: 320dpi x 216dpi + * + * This is also my first attempt to work with gs. I have not included the LQ's + * ability to print in colour. Perhaps at a later date I will tackle that. + * + * BTW, to get your Imagewriter LQ serial printer to work with a PC, attach it + * with a nullmodem serial cable. + * + * Scott Barker (barkers@cuug.ab.ca) + */ + +/* + * This is a modification of Mark Wedel's Apple DMP driver to + * support 2 higher resolutions: + * appledmp: 120dpi x 72dpi is still supported (yuck) + * iwlo: 160dpi x 72dpi + * iwhi: 160dpi x 144dpi + * + * The Imagewriter II is a bit odd. In pinfeed mode, it thinks its + * First line is 1 inch from the top of the page. If you set the top + * form so that it starts printing at the top of the page, and print + * to near the bottom, it thinks it has run onto the next page and + * the formfeed will skip a whole page. As a work around, I reverse + * the paper about a 1.5 inches at the end of the page before the + * formfeed to make it think its on the 'right' page. bah. hack! + * + * This is my first attempt to work with gs, so your milage may vary + * + * Jonathan Luckey (luckey@rtfm.mlb.fl.us) + */ + +/* This is a bare bones driver I developed for my apple Dot Matrix Printer. + * This code originally was from the epson driver, but I removed a lot + * of stuff that was not needed. + * + * The Dot Matrix Printer was a predecessor to the apple Imagewriter. Its + * main difference being that it was parallel. + * + * This code should work fine on Imagewriters, as they have a superset + * of commands compared to the DMP printer. + * + * This driver does not produce the smalles output files possible. To + * do that, it should look through the output strings and find repeat + * occurances of characters, and use the escape sequence that allows + * printing repeat sequences. However, as I see it, this the limiting + * factor in printing is not transmission speed to the printer itself, + * but rather, how fast the print head can move. This is assuming the + * printer is set up with a reasonable speed (9600 bps) + * + * WHAT THE CODE DOES AND DOES NOT DO: + * + * To print out images, it sets the printer for unidirection printing + * and 15 cpi (120 dpi). IT sets line feed to 1/9 of an inch (72 dpi). + * When finished, it sets things back to bidirection print, 1/8" line + * feeds, and 12 cpi. There does not appear to be a way to reset + * things to initial values. + * + * This code does not set for 8 bit characters (which is required). It + * also assumes that carriage return/newline is needed, and not just + * carriage return. These are all switch settings on the DMP, and + * I have configured them for 8 bit data and cr only. + * + * You can search for the strings Init and Reset to find the strings + * that set up the printer and clear things when finished, and change + * them to meet your needs. + * + * Also, you need to make sure that the printer daemon (assuming unix) + * doesn't change the data as it is being printed. I have set my + * printcap file (sunos 4.1.1) with the string: + * ms=pass8,-opost + * and it works fine. + * + * Feel free to improve this code if you want. However, please make + * sure that the old DMP will still be supported by any changes. This + * may mean making an imagewriter device, and just copying this file + * to something like gdevimage.c. + * + * The limiting factor of the DMP is the vertical resolution. However, I + * see no way to do anything about this. Horizontal resolution could + * be increased by using 17 cpi (136 dpi). I believe the Imagewriter + * supports 24 cpi (192 dpi). However, the higher dpi, the slower + * the printing. + * + * Dot Matrix Code by Mark Wedel (master@cats.ucsc.edu) + * + * + * As of Oct 2019, maintained by Mike Galatean (contact through https://bugs.ghostscript.com ) + * + */ + +#include "gdevprn.h" + +/* The device descriptors */ +static dev_proc_print_page(dmp_print_page); + +/* Standard DMP device */ +const gx_device_printer far_data gs_appledmp_device = +prn_device(prn_bg_procs, "appledmp", /* The print_page proc is compatible with allowing bg printing */ + 85, /* width_10ths, 8.5" */ + 110, /* height_10ths, 11" */ + 120, 72, /* X_DPI, Y_DPI */ + 0, 0.5, 0.5, 0, /* margins */ + 1, dmp_print_page); + +/* lowrez Imagewriter device */ +const gx_device_printer far_data gs_iwlo_device = +prn_device(prn_bg_procs, "iwlo", /* The print_page proc is compatible with allowing bg printing */ + 85, /* width_10ths, 8.5" */ + 110, /* height_10ths, 11" */ + 160, 72, /* X_DPI, Y_DPI */ + 0, 0.5, 0.5, 0, /* margins */ + 1, dmp_print_page); + +/* hirez Imagewriter device */ +const gx_device_printer far_data gs_iwhi_device = +prn_device(prn_bg_procs, "iwhi", /* The print_page proc is compatible with allowing bg printing */ + 85, /* width_10ths, 8.5" */ + 110, /* height_10ths, 11" */ + 160, 144, /* X_DPI, Y_DPI */ + 0, 0.5, 0.5, 0, /* margins */ + 1, dmp_print_page); + +/* LQ hirez Imagewriter device */ +const gx_device_printer far_data gs_iwlq_device = +prn_device(prn_bg_procs, "iwlq", /* The print_page proc is compatible with allowing bg printing */ + 85, /* width_10ths, 8.5" */ + 110, /* height_10ths, 11" */ + 320, 216, + 0, 0, 0.5, 0, /* margins */ + 1, dmp_print_page); + +/* ------ Internal routines ------ */ + +#define DMP 1 +#define IWLO 2 +#define IWHI 3 +#define IWLQ 4 + +/* Send the page to the printer. */ +static int +dmp_print_page(gx_device_printer *pdev, gp_file *gprn_stream) +{ + int dev_type; + + int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev); + /* Note that in_size is a multiple of 8. */ + int in_size = line_size * 8; + /* FIXME: It would be better if this device used the gp_file and the gp_ API, + * rather than this "back door" approach + */ + FILE *prn_stream = gp_get_file(gprn_stream); + + + byte *buf1 = (byte *)gs_malloc(pdev->memory, in_size, 1, "dmp_print_page(buf1)"); + byte *buf2 = (byte *)gs_malloc(pdev->memory, in_size, 1, "dmp_print_page(buf2)"); + byte *prn = (byte *)gs_malloc(pdev->memory, 3*in_size, 1, "dmp_print_page(prn)"); + + byte *in = buf1; + byte *out = buf2; + int lnum = 0; + + /* Check allocations */ + if ( buf1 == 0 || buf2 == 0 || prn == 0 ) + { + if ( buf1 ) + gs_free(pdev->memory, (char *)buf1, in_size, 1, + "dmp_print_page(buf1)"); + if ( buf2 ) + gs_free(pdev->memory, (char *)buf2, in_size, 1, + "dmp_print_page(buf2)"); + if ( prn ) + gs_free(pdev->memory, (char *)prn, in_size, 1, + "dmp_print_page(prn)"); + return_error(gs_error_VMerror); + } + + if ( pdev->y_pixels_per_inch == 216 ) + dev_type = IWLQ; + else if ( pdev->y_pixels_per_inch == 144 ) + dev_type = IWHI; + else if ( pdev->x_pixels_per_inch == 160 ) + dev_type = IWLO; + else + dev_type = DMP; + + /* Initialize the printer and reset the margins. */ + + fputs("\r\n\033>\033T16", prn_stream); + + switch(dev_type) + { + case IWLQ: + fputs("\033P\033a3", prn_stream); + break; + case IWHI: + case IWLO: + fputs("\033P", prn_stream); + break; + case DMP: + default: + fputs("\033q", prn_stream); + break; + } + + /* Print lines of graphics */ + while ( lnum < pdev->height ) + { + byte *inp; + byte *in_end; + byte *out_end; + int lcnt,ltmp; + int count, passes; + byte *prn_blk, *prn_end, *prn_tmp; + +/* The apple DMP printer seems to be odd in that the bit order on + * each line is reverse what might be expected. Meaning, an + * underscore would be done as a series of 0x80, while on overscore + * would be done as a series of 0x01. So we get each + * scan line in reverse order. + */ + + switch (dev_type) + { + case IWLQ: passes = 3; break; + case IWHI: passes = 2; break; + case IWLO: + case DMP: + default: passes = 1; break; + } + + for (count = 0; count < passes; count++) + { + for (lcnt=0; lcnt<8; lcnt++) + { + switch(dev_type) + { + case IWLQ: ltmp = lcnt + 8*count; break; + case IWHI: ltmp = 2*lcnt + count; break; + case IWLO: + case DMP: + default: ltmp = lcnt; break; + } + + if ((lnum+ltmp)>pdev->height) + memset(in+lcnt*line_size,0,line_size); + else + gdev_prn_copy_scan_lines(pdev, + lnum+ltmp, in + line_size*(7 - lcnt), + line_size); + } + + out_end = out; + inp = in; + in_end = inp + line_size; + for ( ; inp < in_end; inp++, out_end += 8 ) + { + gdev_prn_transpose_8x8(inp, line_size, + out_end, 1); + } + + out_end = out; + + switch (dev_type) + { + case IWLQ: prn_end = prn + count; break; + case IWHI: prn_end = prn + in_size*count; break; + case IWLO: + case DMP: + default: prn_end = prn; break; + } + + while ( (int)(out_end-out) < in_size) + { + *prn_end = *(out_end++); + if ((dev_type) == IWLQ) prn_end += 3; + else prn_end++; + } + } + + switch (dev_type) + { + case IWLQ: + prn_blk = prn; + prn_end = prn_blk + in_size * 3; + while (prn_end > prn && prn_end[-1] == 0 && + prn_end[-2] == 0 && prn_end[-3] == 0) + { + prn_end -= 3; + } + while (prn_blk < prn_end && prn_blk[0] == 0 && + prn_blk[1] == 0 && prn_blk[2] == 0) + { + prn_blk += 3; + } + if (prn_end != prn_blk) + { + if ((prn_blk - prn) > 7) + fprintf(prn_stream,"\033U%04d%c%c%c", + (int)((prn_blk - prn)/3), + 0, 0, 0); + else + prn_blk = prn; + fprintf(prn_stream,"\033C%04d", + (int)((prn_end - prn_blk)/3)); + fwrite(prn_blk, 1, (int)(prn_end - prn_blk), + prn_stream); + } + break; + case IWHI: + for (count = 0; count < 2; count++) + { + prn_blk = prn_tmp = prn + in_size*count; + prn_end = prn_blk + in_size; + while (prn_end > prn_blk && prn_end[-1] == 0) + prn_end--; + while (prn_blk < prn_end && prn_blk[0] == 0) + prn_blk++; + if (prn_end != prn_blk) + { + if ((prn_blk - prn_tmp) > 7) + fprintf(prn_stream, + "\033V%04d%c", + (int)(prn_blk-prn_tmp), + 0); + else + prn_blk = prn_tmp; + fprintf(prn_stream,"\033G%04d", + (int)(prn_end - prn_blk)); + fwrite(prn_blk, 1, + (int)(prn_end - prn_blk), + prn_stream); + } + if (!count) fputs("\033T01\r\n",prn_stream); + } + fputs("\033T15",prn_stream); + break; + case IWLO: + case DMP: + default: + prn_blk = prn; + prn_end = prn_blk + in_size; + while (prn_end > prn_blk && prn_end[-1] == 0) + prn_end--; + while (prn_blk < prn_end && prn_blk[0] == 0) + prn_blk++; + if (prn_end != prn_blk) + { + if ((prn_blk - prn) > 7) + fprintf(prn_stream,"\033V%04d%c", + (int)(prn_blk - prn), 0); + else + prn_blk = prn; + fprintf(prn_stream,"\033G%04d", + (int)(prn_end - prn_blk)); + fwrite(prn_blk, 1, (int)(prn_end - prn_blk), + prn_stream); + } + break; + } + + fputs("\r\n",prn_stream); + + switch (dev_type) + { + case IWLQ: lnum += 24 ; break; + case IWHI: lnum += 16 ; break; + case IWLO: + case DMP: + default: lnum += 8 ; break; + } + } + + /* ImageWriter will skip a whole page if too close to end */ + /* so skip back more than an inch */ + if ( !(dev_type == DMP) ) + fputs("\033T99\n\n\033r\n\n\n\n\033f", prn_stream); + + /* Formfeed and Reset printer */ + fputs("\033T16\f\033<\033B\033E", prn_stream); + fflush(prn_stream); + + gs_free(pdev->memory, (char *)prn, in_size, 1, "dmp_print_page(prn)"); + gs_free(pdev->memory, (char *)buf2, in_size, 1, "dmp_print_page(buf2)"); + gs_free(pdev->memory, (char *)buf1, in_size, 1, "dmp_print_page(buf1)"); + return 0; +} diff --git a/contrib/gdevbjc_.c b/contrib/gdevbjc_.c index a5c7627a..a661ba0d 100644 --- a/contrib/gdevbjc_.c +++ b/contrib/gdevbjc_.c @@ -220,7 +220,8 @@ const gx_device_bjc_printer gs_bjcmono_device = bjc_device(bjcmono_procs, "bjcmono", DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS, X_DPI, Y_DPI, - (3.4 / 25.4), (7.0 / 25.4), (3.4 / 25.4), (3.0 / 25.4), + (float)(3.4 / 25.4), (float)(7.0 / 25.4), + (float)(3.4 / 25.4), (float)(3.0 / 25.4), 1, /* num components */ 1, /* depth */ 1, /* max gray */ @@ -242,7 +243,8 @@ const gx_device_bjc_printer gs_bjcgray_device = bjc_device(bjcgray_procs, "bjcgray", DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS, X_DPI, Y_DPI, - (3.4 / 25.4), (7.0 / 25.4), (3.4 / 25.4), (3.0 / 25.4), + (float)(3.4 / 25.4), (float)(7.0 / 25.4), + (float)(3.4 / 25.4), (float)(3.0 / 25.4), 1, /* num components */ 8, /* depth */ 255, /* max gray */ @@ -264,7 +266,8 @@ const gx_device_bjc_printer gs_bjccmyk_device = bjc_device(bjc_cmykcolor_procs, "bjccmyk", DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS, X_DPI, Y_DPI, - (3.4 / 25.4), (7.0 / 25.4), (3.4 / 25.4), (3.0 / 25.4), + (float)(3.4 / 25.4), (float)(7.0 / 25.4), + (float)(3.4 / 25.4), (float)(3.0 / 25.4), 4, /* num components */ 4, /* depth */ 1, /* max gray */ @@ -286,7 +289,8 @@ const gx_device_bjc_printer gs_bjccolor_device = bjc_device(bjc_truecolor_procs, "bjccolor", DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS, X_DPI, Y_DPI, - (3.4 / 25.4), (7.0 / 25.4), (3.4 / 25.4), (3.0 / 25.4), + (float)(3.4 / 25.4), (float)(7.0 / 25.4), + (float)(3.4 / 25.4), (float)(3.0 / 25.4), 4, /* num components */ 32, /* depth */ 255, /* max gray */ @@ -386,8 +390,9 @@ gdev_bjc_get_params(gx_device * pdev, gs_param_list * plist) { const gx_device_bjc_printer * ppdev = (gx_device_bjc_printer *)pdev; - int code = gdev_prn_get_params(pdev, plist); - if (code < 0 || + int code; + (void) ( + (code = gdev_prn_get_params(pdev, plist)) < 0 || (code = param_write_string(plist, "PrinterType", ¶mValueToParam(strPrinterType, ppdev->printerType)->p_string)) < 0 || (code = param_write_string(plist, "Feeder", @@ -413,8 +418,8 @@ gdev_bjc_get_params(gx_device * pdev, gs_param_list * plist) (code = param_write_float(plist, "Gamma", &ppdev->gamma)) < 0 || (code = param_write_float(plist, "RedGamma", &ppdev->redGamma)) < 0 || (code = param_write_float(plist, "GreenGamma", &ppdev->greenGamma)) < 0 || - (code = param_write_float(plist, "BlueGamma", &ppdev->blueGamma)) < 0) - return code; + (code = param_write_float(plist, "BlueGamma", &ppdev->blueGamma)) < 0 + ); return code; } @@ -570,8 +575,8 @@ bjc_print_page_mono(gx_device_printer * pdev, gp_file * file) ((ppdev->ink & INK_K) ? 0x11: 0x10)); /* black or color */ char ink = 0x01; /* regular ink type */ char compress = (ppdev->compress == true ? 0x01 : 0x00); /* compression or not */ - int x_resolution = pdev->HWResolution[0]; - int y_resolution = pdev->HWResolution[1]; + int x_resolution = (int)pdev->HWResolution[0]; + int y_resolution = (int)pdev->HWResolution[1]; int length = 0/*x71*/, lm = 0/*x01*/, rm = 0/*x01*/, top = 0/*x50*/; byte inkc = ppdev->ink; byte mask_array[] = { 0xff, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe }; @@ -643,8 +648,8 @@ bjc_print_page_gray(gx_device_printer * pdev, gp_file * file) ((ppdev->ink & INK_K) ? 0x11: 0x10)); /* black or color */ char ink = 0x01; /* regular ink type */ char compress = (ppdev->compress == true ? 0x01 : 0x00); /* compression or not */ - int x_resolution = pdev->HWResolution[0]; - int y_resolution = pdev->HWResolution[1]; + int x_resolution = (int)pdev->HWResolution[0]; + int y_resolution = (int)pdev->HWResolution[1]; int length = 0/*x71*/, lm = 0/*x01*/, rm = 0/*x01*/, top = 0/*x50*/; byte inkc = ppdev->ink; byte mask_array[] = { 0xff, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe }; @@ -730,8 +735,8 @@ bjc_print_page_cmyk(gx_device_printer * pdev, gp_file * file) char color = 0x10; /* color */ char ink = 0x01; /* regular ink type */ char compress = (ppdev->compress == true ? 0x01 : 0x00); /* compression or not */ - int x_resolution = pdev->HWResolution[0]; - int y_resolution = pdev->HWResolution[1]; + int x_resolution = (int)pdev->HWResolution[0]; + int y_resolution = (int)pdev->HWResolution[1]; int length = 0/*x71*/, lm = 0/*x01*/, rm = 0/*x01*/, top = 0/*x50*/; int plane; byte mask_array[] = { 0xff, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe }; @@ -851,8 +856,8 @@ bjc_print_page_color(gx_device_printer * pdev, gp_file * file) char color = 0x10; /* color */ char ink = 0x01; /* regular ink type */ char compress = (ppdev->compress == true ? 0x01 : 0x00); /* compression or not */ - int x_resolution = pdev->HWResolution[0]; - int y_resolution = pdev->HWResolution[1]; + int x_resolution = (int)pdev->HWResolution[0]; + int y_resolution = (int)pdev->HWResolution[1]; int length = 0/*x71*/, lm = 0/*x01*/, rm = 0/*x01*/, top = 0/*x50*/; byte mask_array[] = { 0xff, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe }; byte lastmask = mask_array[pdev->width % 8]; diff --git a/contrib/gdevbjc_.h b/contrib/gdevbjc_.h index de32a510..92f5448c 100644 --- a/contrib/gdevbjc_.h +++ b/contrib/gdevbjc_.h @@ -135,8 +135,8 @@ typedef struct gx_device_bjc_printer_s gx_device_bjc_printer; xdpi, ydpi,\ ncomp, depth, mg, mc, dg, dc,\ -(lo) * (xdpi), -(to) * (ydpi),\ - (lm) * 72.0, (bm) * 72.0,\ - (rm) * 72.0, (tm) * 72.0\ + (lm) * 72.0f, (bm) * 72.0f,\ + (rm) * 72.0f, (tm) * 72.0f\ ),\ prn_device_body_rest_(print_page) diff --git a/contrib/gdevbjca.c b/contrib/gdevbjca.c index a023f0ee..142ddee4 100644 --- a/contrib/gdevbjca.c +++ b/contrib/gdevbjca.c @@ -342,12 +342,14 @@ bjc_compress(const byte *row, uint raster, byte *compressed) register byte test, test2; test = *exam; - while ( exam < end_row ) { - test2 = *++exam; + while ( ++exam < end_row ) { + test2 = *exam; if ( test == test2 ) break; test = test2; } + /* exam points to the byte that didn't match, or end_row + * if we ran out of data. */ /* Find out how long the run is */ end_dis = exam - 1; @@ -464,7 +466,11 @@ uint bjc_rand(gx_device_bjc_printer *dev) void bjc_init_tresh(gx_device_bjc_printer *dev, int rnd) { +#ifdef CLUSTER + int i=0; +#else int i=(int)(time(NULL) & 0x0ff); +#endif float delta=40.64*rnd; for(;i>0;i--) bjc_rand(dev); for(i=-512; i<512; i++) dev->bjc_treshold[i+512] = @@ -655,12 +661,15 @@ FloydSteinbergDitheringC(gx_device_bjc_printer *dev, for( i=width; i>0; i--, row+=4, err_vect+=3) { /*separate components */ /* C + K */ - err_corrC = dev->bjc_gamma_tableC[ (*row) + (*(row+3))] - + dev->FloydSteinbergC; - err_corrM = dev->bjc_gamma_tableM[(*(row+1)) + (*(row+3))] - + dev->FloydSteinbergM; - err_corrY = dev->bjc_gamma_tableY[(*(row+2)) + (*(row+3))] - + dev->FloydSteinbergY; + int v = row[0] + row[3]; + if (v > 255) v = 255; + err_corrC = dev->bjc_gamma_tableC[v] + dev->FloydSteinbergC; + v = row[1] + row[3]; + if (v > 255) v = 255; + err_corrM = dev->bjc_gamma_tableM[v] + dev->FloydSteinbergM; + v = row[2] + row[3]; + if (v > 255) v = 255; + err_corrY = dev->bjc_gamma_tableY[v] + dev->FloydSteinbergY; if(err_corrC > 4080 && limit_extr) err_corrC = 4080; if(err_corrM > 4080 && limit_extr) err_corrM = 4080; @@ -751,12 +760,15 @@ FloydSteinbergDitheringC(gx_device_bjc_printer *dev, for( i=width; i>0; i--, row-=4, err_vect-=3) { - err_corrC = dev->bjc_gamma_tableC[ (*row) + (*(row+3))] - + dev->FloydSteinbergC; - err_corrM = dev->bjc_gamma_tableM[(*(row+1)) + (*(row+3))] - + dev->FloydSteinbergM; - err_corrY = dev->bjc_gamma_tableY[(*(row+2)) + (*(row+3))] - + dev->FloydSteinbergY; + int v = row[0] + row[3]; + if (v > 255) v = 255; + err_corrC = dev->bjc_gamma_tableC[v] + dev->FloydSteinbergC; + v = row[1] + row[3]; + if (v > 255) v = 255; + err_corrM = dev->bjc_gamma_tableM[v] + dev->FloydSteinbergM; + v = row[2] + row[3]; + if (v > 255) v = 255; + err_corrY = dev->bjc_gamma_tableY[v] + dev->FloydSteinbergY; if(err_corrC > 4080 && limit_extr) err_corrC = 4080; if(err_corrM > 4080 && limit_extr) err_corrM = 4080; diff --git a/contrib/gdevcd8.c b/contrib/gdevcd8.c index bc5a741b..23532c0f 100644 --- a/contrib/gdevcd8.c +++ b/contrib/gdevcd8.c @@ -438,10 +438,10 @@ static int (* const rescale_color_plane[2][2]) (int, const byte *, const byte *, * Drivers stuff. * */ -#define DESKJET_PRINT_LIMIT 0.04 /* 'real' top margin? */ +#define DESKJET_PRINT_LIMIT 0.04f /* 'real' top margin? */ /* Margins are left, bottom, right, top. */ -#define DESKJET_MARGINS_LETTER 0.25, 0.50, 0.25, 0.167 -#define DESKJET_MARGINS_A4 0.13, 0.46, 0.13, 0.04 +#define DESKJET_MARGINS_LETTER 0.25f, 0.50f, 0.25f, 0.167f +#define DESKJET_MARGINS_A4 0.13f, 0.46f, 0.13f, 0.04f /* Define bits-per-pixel - default is 32-bit cmyk-mode */ #ifndef BITSPERPIXEL # define BITSPERPIXEL 32 @@ -891,20 +891,20 @@ hp_colour_open(gx_device * pdev) /* margins for DJ1600C from manual */ static const float m_cdj1600[4] = { - 0.25, 0.5, 0.25, 0.5 + 0.25f, 0.5f, 0.25f, 0.5f }; /* margins for HP2200C */ static const float chp2200_a4[4] = { - 0.13, 0.46, 0.13, 0.08 + 0.13f, 0.46f, 0.13f, 0.08f }; static const float chp2200_letter[4] = { - 0.25, 0.46, 0.25, 0.08 + 0.25f, 0.46f, 0.25f, 0.08f }; /* margins for DNJ500C */ static const float cdnj500[4] = { - 0.00, 0.00, 0.00, 0.00 + 0.00f, 0.00f, 0.00f, 0.00f }; const float *m = (float *)0; @@ -1043,7 +1043,8 @@ hp_colour_open(gx_device * pdev) default: assert(0); } - gx_device_set_margins(pdev, m, true); + if (m != NULL) + gx_device_set_margins(pdev, m, true); return gdev_prn_open(pdev); } @@ -1091,13 +1092,13 @@ cdj850_put_params(gx_device * pdev, gs_param_list * plist) code = cdj_put_param_int(plist, "BitsPerPixel", &bpp, 1, 32, code); code = cdj_put_param_int(plist, "Quality", &quality, 0, 2, code); code = cdj_put_param_int(plist, "Papertype", &papertype, 0, 4, code); - code = cdj_put_param_float(plist, "MasterGamma", &mastergamma, 0.1, 9.0, code); - code = cdj_put_param_float(plist, "GammaValC", &gammavalc, 0.0, 9.0, code); - code = cdj_put_param_float(plist, "GammaValM", &gammavalm, 0.0, 9.0, code); - code = cdj_put_param_float(plist, "GammaValY", &gammavaly, 0.0, 9.0, code); - code = cdj_put_param_float(plist, "GammaValK", &gammavalk, 0.0, 9.0, code); - code = cdj_put_param_float(plist, "BlackCorrect", &blackcorrect, 0.0, - 9.0, code); + code = cdj_put_param_float(plist, "MasterGamma", &mastergamma, 0.1f, 9.0f, code); + code = cdj_put_param_float(plist, "GammaValC", &gammavalc, 0.0f, 9.0f, code); + code = cdj_put_param_float(plist, "GammaValM", &gammavalm, 0.0f, 9.0f, code); + code = cdj_put_param_float(plist, "GammaValY", &gammavaly, 0.0f, 9.0f, code); + code = cdj_put_param_float(plist, "GammaValK", &gammavalk, 0.0f, 9.0f, code); + code = cdj_put_param_float(plist, "BlackCorrect", &blackcorrect, 0.0f, + 9.0f, code); if (code < 0) return code; @@ -1830,8 +1831,8 @@ cdnj500_print_page(gx_device_printer * pdev, gp_file * prn_stream) /* |Horz Res |Vert Rez |compr|orien|bits |planes*/ /* x,y resolution for color planes, assume x=y */ - int xres = cdj850->x_pixels_per_inch; - int yres = cdj850->y_pixels_per_inch; + int xres = (int)cdj850->x_pixels_per_inch; + int yres = (int)cdj850->y_pixels_per_inch; gs_memory_t *mem = pdev->memory; int width_in_pixels = pdev->width; @@ -2002,7 +2003,7 @@ send_scan_lines(gx_device_printer * pdev, word rmask = ~(word) 0 << ((-pdev->width * misc_vars->storage_bpp) & (W * 8 - 1)); - lend = pdev->height - (dev_t_margin(pdev) + dev_b_margin(pdev)) * y_dpi; + lend = (int)(pdev->height - (dev_t_margin(pdev) + dev_b_margin(pdev)) * y_dpi); error_values->c = error_values->m = error_values->y = error_values->k = 0; @@ -3136,11 +3137,11 @@ cdj850_start_raster_mode(gx_device_printer * pdev, int paper_size, init.a[25] = cdj850->intensities; /* Intensity levels yellow */ /* black plane resolution */ - assign_dpi(cdj850->x_pixels_per_inch, init.a + 2); - assign_dpi(cdj850->y_pixels_per_inch, init.a + 4); + assign_dpi((int)cdj850->x_pixels_per_inch, init.a + 2); + assign_dpi((int)cdj850->y_pixels_per_inch, init.a + 4); /* color plane resolution */ - xres = cdj850->x_pixels_per_inch / (cdj850->xscal + 1); - yres = cdj850->y_pixels_per_inch / (cdj850->yscal + 1); + xres = (int)(cdj850->x_pixels_per_inch / (cdj850->xscal + 1)); + yres = (int)(cdj850->y_pixels_per_inch / (cdj850->yscal + 1)); /* cyan */ assign_dpi(xres, init.a + 8); assign_dpi(yres, init.a + 10); @@ -3195,11 +3196,11 @@ cdj880_start_raster_mode(gx_device_printer * pdev, int paper_size, init.a[25] = cdj850->intensities; /* Intensity levels yellow */ /* black plane resolution */ - assign_dpi(cdj850->x_pixels_per_inch, init.a + 2); - assign_dpi(cdj850->y_pixels_per_inch, init.a + 4); + assign_dpi((int)cdj850->x_pixels_per_inch, init.a + 2); + assign_dpi((int)cdj850->y_pixels_per_inch, init.a + 4); /* color plane resolution */ - xres = cdj850->x_pixels_per_inch / (cdj850->xscal + 1); - yres = cdj850->y_pixels_per_inch / (cdj850->yscal + 1); + xres = (int)(cdj850->x_pixels_per_inch / (cdj850->xscal + 1)); + yres = (int)(cdj850->y_pixels_per_inch / (cdj850->yscal + 1)); /* cyan */ assign_dpi(xres, init.a + 8); assign_dpi(yres, init.a + 10); @@ -3261,8 +3262,8 @@ chp2200_start_raster_mode(gx_device_printer * pdev, int paper_size, /* |Horz Res |Vert Rez |compr|orien|bits |planes*/ /* x,y resolution for color planes, assume x=y */ - int xres = cdj850->x_pixels_per_inch; - int yres = cdj850->y_pixels_per_inch; + int xres = (int)cdj850->x_pixels_per_inch; + int yres = (int)cdj850->y_pixels_per_inch; int width_in_pixels = cdj850->width; /* Exit from any previous language */ @@ -3322,7 +3323,7 @@ cdnj500_start_raster_mode(gx_device_printer * pdev, int paper_size, gp_file * prn_stream) { /* x,y resolution for color planes, assume x=y */ - int xres = cdj850->x_pixels_per_inch; + int xres = (int)cdj850->x_pixels_per_inch; float x = pdev->width / pdev->x_pixels_per_inch * 10; float y = pdev->height / pdev->y_pixels_per_inch * 10; @@ -3817,7 +3818,7 @@ gdev_pcl_map_color_rgb(gx_device * pdev, gx_color_index color, break; case 16: { - gx_color_value c = (gx_color_value) color ^ 0xffff; + gx_color_index c = (gx_color_index) color ^ 0xffff; ushort value = c >> 11; prgb[0] = ((value << 11) + (value << 6) + (value << 1) + @@ -3832,7 +3833,7 @@ gdev_pcl_map_color_rgb(gx_device * pdev, gx_color_index color, break; case 24: { - gx_color_value c = (gx_color_value) color ^ 0xffffff; + gx_color_index c = (gx_color_index) color ^ 0xffffff; prgb[0] = gx_color_value_from_byte(c >> 16); prgb[1] = gx_color_value_from_byte((c >> 8) & 0xff); @@ -3998,8 +3999,9 @@ static void cdj1600_start_raster_mode(gx_device_printer * pdev, int paper_size, gp_file * prn_stream) { - uint raster_width = pdev->width - - pdev->x_pixels_per_inch * (dev_l_margin(pdev) + dev_r_margin(pdev)); + uint raster_width = (int)(pdev->width - + pdev->x_pixels_per_inch * + (dev_l_margin(pdev) + dev_r_margin(pdev))); /* switch to PCL control language */ gp_fputs("\033%-12345X@PJL enter language = PCL\n", prn_stream); diff --git a/contrib/gdevdj9.c b/contrib/gdevdj9.c index 1191a322..1800b3cb 100644 --- a/contrib/gdevdj9.c +++ b/contrib/gdevdj9.c @@ -289,8 +289,8 @@ static int cdj970_write_trailer(gx_device *, gp_file *); #define DESKJET_PRINT_LIMIT 0.04 /* 'real' top margin? */ /* Margins are left, bottom, right, top. */ -#define DESKJET_MARGINS_LETTER 0.25, 0.50, 0.25, 0.167 -#define DESKJET_MARGINS_A4 0.13, 0.46, 0.13, 0.04 +#define DESKJET_MARGINS_LETTER 0.25f, 0.50f, 0.25f, 0.167f +#define DESKJET_MARGINS_A4 0.13f, 0.46f, 0.13f, 0.04f /* Define bits-per-pixel - default is 32-bit cmyk-mode */ #ifndef BITSPERPIXEL # define BITSPERPIXEL 32 @@ -574,26 +574,55 @@ static int cdj_set_bpp(gx_device *, int, int); static int hp_colour_open(gx_device * pdev) { - int retCode; + int retCode = 0; + + /* Change the margins if necessary. */ + static const float dj_a4[4] = { + DESKJET_MARGINS_A4 + }; + + static const float dj_letter[4] = { + DESKJET_MARGINS_LETTER + }; + const float *m = (float *)0; cdj970->PageCtr = 0; + /* quality setup */ + if (cdj970->quality == DRAFT) { + gx_device_set_resolution((gx_device *) pdev, 300.0, 300.0); + cdj970->xscal = 0; + cdj970->yscal = 0; + cdj970->intensities = 2; + } else if (cdj970->quality == NORMAL) { + gx_device_set_resolution((gx_device *) pdev, 600.0, 600.0); + cdj970->xscal = 1; + cdj970->yscal = 1; + /* intensities = 4 from initialization */ + } else { /* quality == PRESENTATION */ + gx_device_set_resolution((gx_device *) pdev, 600.0, 600.0); + cdj970->xscal = 0; + cdj970->yscal = 0; + /* intensities = 4 from initialization */ + } + + m = (gdev_pcl_paper_size((gx_device *) pdev) == + PAPER_SIZE_A4 ? dj_a4 : dj_letter); + + gx_device_set_margins((gx_device *) pdev, m, true); + /* Set up colour params if put_params has not already done so */ if (pdev->color_info.num_components == 0) { - int code = cdj_set_bpp(pdev, pdev->color_info.depth, + retCode = cdj_set_bpp(pdev, pdev->color_info.depth, pdev->color_info.num_components); - if (code < 0) - return code; + if (retCode < 0) + return retCode; } retCode = gdev_prn_open(pdev); - if (retCode < 0) - return (retCode); - else { + if (retCode >= 0) { retCode = gdev_prn_open_printer(pdev, true); - if (retCode < 0) - return (retCode); } return 0; @@ -604,9 +633,10 @@ hp_colour_open(gx_device * pdev) static int cdj970_get_params(gx_device * pdev, gs_param_list * plist) { - int code = gdev_prn_get_params(pdev, plist); - - if (code < 0 || + int code; + + (void) ( + (code = gdev_prn_get_params(pdev, plist)) < 0 || (code = param_write_int(plist, "Quality", &cdj970->quality)) < 0 || (code = param_write_int(plist, "Duplex", &cdj970->duplex)) < 0 || (code = param_write_int(plist, "Papertype", &cdj970->papertype)) < 0 @@ -623,9 +653,8 @@ cdj970_get_params(gx_device * pdev, gs_param_list * plist) param_write_float(plist, "GammaValK", &cdj970->gammavalk)) < 0 || (code = param_write_float(plist, "BlackCorrect", - &cdj970->blackcorrect)) < 0) - - return (code); + &cdj970->blackcorrect)) < 0 + ); return (code); } @@ -647,26 +676,25 @@ cdj970_put_params(gx_device * pdev, gs_param_list * plist) int bpp = 0; int code = 0; - code = cdj_put_param_int(plist, "BitsPerPixel", &bpp, 1, 32, code); - code = cdj_put_param_int(plist, "Quality", &quality, 0, 2, code); - code = cdj_put_param_int(plist, "Papertype", &papertype, 0, 4, code); - code = cdj_put_param_int(plist, "Duplex", &duplex, 0, 2, code); - code = - cdj_put_param_float(plist, "MasterGamma", &mastergamma, 0.1, 9.0, - code); - code = - cdj_put_param_float(plist, "GammaValC", &gammavalc, 0.0, 9.0, code); - code = - cdj_put_param_float(plist, "GammaValM", &gammavalm, 0.0, 9.0, code); - code = - cdj_put_param_float(plist, "GammaValY", &gammavaly, 0.0, 9.0, code); - code = - cdj_put_param_float(plist, "GammaValK", &gammavalk, 0.0, 9.0, code); - code = - cdj_put_param_float(plist, "BlackCorrect", &blackcorrect, 0.0, 9.0, - code); - - if (code < 0) + if ((code = cdj_put_param_int(plist, "BitsPerPixel", &bpp, 1, 32, code)) < 0) + return code; + if ((code = cdj_put_param_int(plist, "Quality", &quality, 0, 2, code)) < 0) + return code; + if ((code = cdj_put_param_int(plist, "Papertype", &papertype, 0, 4, code)) < 0) + return code; + if ((code = cdj_put_param_int(plist, "Duplex", &duplex, 0, 2, code)) < 0) + return code; + if ((code = cdj_put_param_float(plist, "MasterGamma", &mastergamma, 0.1f, 9.0, code)) < 0) + return code; + if ((code = cdj_put_param_float(plist, "GammaValC", &gammavalc, 0.0, 9.0, code)) < 0) + return code; + if ((code = cdj_put_param_float(plist, "GammaValM", &gammavalm, 0.0, 9.0, code)) < 0) + return code; + if ((code = cdj_put_param_float(plist, "GammaValY", &gammavaly, 0.0, 9.0, code)) < 0) + return code; + if ((code = cdj_put_param_float(plist, "GammaValK", &gammavalk, 0.0, 9.0, code)) < 0) + return code; + if ((code = cdj_put_param_float(plist, "BlackCorrect", &blackcorrect, 0.0, 9.0, code)) < 0) return code; code = cdj_put_param_bpp(pdev, plist, bpp, bpp, 0); @@ -674,7 +702,11 @@ cdj970_put_params(gx_device * pdev, gs_param_list * plist) if (code < 0) return code; - cdj970->quality = quality; + if (cdj970->quality != quality) { + if (pdev->is_open) + gs_closedevice(pdev); /* quality can change resolution, force re-open */ + cdj970->quality = quality; + } cdj970->papertype = papertype; cdj970->duplex = duplex; cdj970->mastergamma = mastergamma; @@ -684,7 +716,7 @@ cdj970_put_params(gx_device * pdev, gs_param_list * plist) cdj970->gammavalk = gammavalk; cdj970->blackcorrect = blackcorrect; - return 0; + return code; } /**********************************************************************************/ @@ -783,47 +815,6 @@ cdj970_terminate_page(gx_device_printer * pdev, gp_file * prn_stream) gp_fputs("\033*rC\f\033&l-2H", prn_stream); /* End Graphics, Reset */ } -/* cdj970_one_time_initialisation: -----------------------------------------------------------------------------------*/ -static void -cdj970_one_time_initialisation(gx_device_printer * pdev) -{ - /* Change the margins if necessary. */ - static const float dj_a4[4] = { - DESKJET_MARGINS_A4 - }; - - static const float dj_letter[4] = { - DESKJET_MARGINS_LETTER - }; - const float *m = (float *)0; - - /* quality setup */ - if (cdj970->quality == DRAFT) { - gx_device_set_resolution((gx_device *) pdev, 300.0, 300.0); - cdj970->xscal = 0; - cdj970->yscal = 0; - cdj970->intensities = 2; - } else if (cdj970->quality == NORMAL) { - gx_device_set_resolution((gx_device *) pdev, 600.0, 600.0); - cdj970->xscal = 1; - cdj970->yscal = 1; - /* intensities = 4 from initialization */ - } else { /* quality == PRESENTATION */ - gx_device_set_resolution((gx_device *) pdev, 600.0, 600.0); - cdj970->xscal = 0; - cdj970->yscal = 0; - /* intensities = 4 from initialization */ - } - - m = (gdev_pcl_paper_size((gx_device *) pdev) == - PAPER_SIZE_A4 ? dj_a4 : dj_letter); - - gx_device_set_margins((gx_device *) pdev, m, true); - - cdj970_write_header((gx_device *) pdev, pdev->file); -} - /* cdj970_print_page: Here comes the hp970 output routine ----------------------------------------------------------------------------------*/ static int @@ -836,7 +827,7 @@ cdj970_print_page(gx_device_printer * pdev, gp_file * prn_stream) Gamma gamma; if (cdj970->PageCtr == 0 && cdj970->ptype == DJ970C) { - cdj970_one_time_initialisation(pdev); + cdj970_write_header((gx_device *)pdev, prn_stream); } /* make a local writable copy of the Gamma tables */ @@ -986,7 +977,7 @@ send_scan_lines(gx_device_printer * pdev, word rmask = ~(word) 0 << ((-pdev->width * misc_vars->storage_bpp) & (W * 8 - 1)); - lend = pdev->height - (dev_t_margin(pdev) + dev_b_margin(pdev)) * y_dpi; + lend = (int)(pdev->height - (dev_t_margin(pdev) + dev_b_margin(pdev)) * y_dpi); error_values->c = error_values->m = error_values->y = error_values->k = 0; @@ -1298,8 +1289,8 @@ do_black_correction(float kvalue, int kcorrect[256]) *col4 += ucr; /* add removed black to black */\ kadd = ucr + *(kcorrect + ucr);\ uca_fac = 1.0 + (kadd/255.0);\ - *col1 *= uca_fac;\ - *col2 *= uca_fac;\ + *col1 = (byte)(*col1 * uca_fac);\ + *col2 = (byte)(*col2 * uca_fac);\ } /* do_gcr: Since resolution can be different on different planes, we need to @@ -2000,12 +1991,12 @@ cdj970_start_raster_mode(gx_device_printer * pdev, init.a[25] = cdj970->intensities; /* Intensity levels yellow */ /* black plane resolution */ - assign_dpi(cdj970->x_pixels_per_inch, init.a + 2); - assign_dpi(cdj970->y_pixels_per_inch, init.a + 4); + assign_dpi((int)cdj970->x_pixels_per_inch, init.a + 2); + assign_dpi((int)cdj970->y_pixels_per_inch, init.a + 4); /* color plane resolution */ - xres = cdj970->x_pixels_per_inch / (cdj970->xscal + 1); - yres = cdj970->y_pixels_per_inch / (cdj970->yscal + 1); + xres = (int)(cdj970->x_pixels_per_inch / (cdj970->xscal + 1)); + yres = (int)(cdj970->y_pixels_per_inch / (cdj970->yscal + 1)); /* cyan */ assign_dpi(xres, init.a + 8); @@ -2279,6 +2270,10 @@ cdj_set_bpp(gx_device * pdev, int bpp, int ccomps) ci->dither_colors = (bpp >= 8 ? 5 : bpp > 1 ? 2 : 0); } + if (ci->depth != ((bpp > 1) && (bpp < 8) ? 8 : bpp)) { + if (pdev->is_open) + gs_closedevice(pdev); /* depth changed, make sure we re-open */ + } ci->depth = ((bpp > 1) && (bpp < 8) ? 8 : bpp); return (0); @@ -2548,7 +2543,7 @@ gdev_pcl_map_color_rgb(gx_device * pdev, } break; case 16:{ - gx_color_value c = (gx_color_value) color ^ 0xffff; + gx_color_index c = (gx_color_index) color ^ 0xffff; ushort value = c >> 11; prgb[0] = ((value << 11) + (value << 6) + (value << 1) + @@ -2563,7 +2558,7 @@ gdev_pcl_map_color_rgb(gx_device * pdev, break; case 24:{ - gx_color_value c = (gx_color_value) color ^ 0xffffff; + gx_color_index c = (gx_color_index) color ^ 0xffffff; prgb[0] = gx_color_value_from_byte(c >> 16); prgb[1] = gx_color_value_from_byte((c >> 8) & 0xff); @@ -2572,7 +2567,7 @@ gdev_pcl_map_color_rgb(gx_device * pdev, break; case 32:{ - gx_color_value w = + gx_color_index w = gx_maxcol - gx_color_value_from_byte(color >> 24); prgb[0] = w - gx_color_value_from_byte((color >> 16) & 0xff); @@ -2597,16 +2592,16 @@ cdj_put_param_bpp(gx_device * pdev, gs_param_list * plist, int new_bpp, int real_bpp, int ccomps) { - if (new_bpp == 0 && ccomps == 0) - return gdev_prn_put_params(pdev, plist); - else { - gx_device_color_info save_info; - int save_bpp; - int code; + int code = 0; + int save_bpp; + gx_device_color_info save_info; - save_info = pdev->color_info; - save_bpp = save_info.depth; + save_info = pdev->color_info; + save_bpp = save_info.depth; + if (new_bpp == 0 && ccomps == 0) { + code = gdev_prn_put_params(pdev, plist); + } else { if (save_bpp == 8 && save_ccomps == 3 && !cprn_device->cmyk) save_bpp = 3; @@ -2630,12 +2625,21 @@ cdj_put_param_bpp(gx_device * pdev, if ((cdj970->color_info.depth != save_bpp || (ccomps != 0 && ccomps != save_ccomps)) && pdev->is_open) - return (gs_closedevice(pdev)); + gs_closedevice(pdev); + } - return (0); + /* check for valid resolutions */ + if (pdev->HWResolution[0] != pdev->HWResolution[1] || + (pdev->HWResolution[0] != 300.0 && pdev->HWResolution[0] != 600.0) ) { + param_signal_error(plist, "HWResolution", gs_error_rangecheck); + emprintf1(pdev->memory, "\ncdj970: Invalid resolution: '%f'. Only 300 or 600 supported.\n\n", + pdev->HWResolution[0]); + cdj_set_bpp(pdev, save_bpp, save_ccomps); + return gs_error_rangecheck; + } + return code; #undef save_ccomps - } } /* cdj970_write_header: diff --git a/contrib/gdevgdi.c b/contrib/gdevgdi.c index 60bd5c19..cdd148ba 100644 --- a/contrib/gdevgdi.c +++ b/contrib/gdevgdi.c @@ -71,8 +71,8 @@ #define GDI_COMP_MODITIFF 6 #define GDI_COMP_NOSEND 0x7f -#define GDI_MARGINS_A4 0.167, 0.167, 0.167, 0.167 -#define GDI_MARGINS_LETTER 0.167, 0.167, 0.167, 0.167 +#define GDI_MARGINS_A4 0.167f, 0.167f, 0.167f, 0.167f +#define GDI_MARGINS_LETTER 0.167f, 0.167f, 0.167f, 0.167f /*#define GDI_MARGINS_A4 0.0, 0.0, 0.0, 0.0*/ /*#define GDI_MARGINS_LETTER 0.0, 0.0, 0.0, 0.0*/ @@ -484,12 +484,15 @@ unsigned long FrameTiffComp(unsigned char *pubDest, case 1: *TgtPtr++ = 0x00; ulret++; + /* Fall through. */ case 2: *TgtPtr++ = 0x00; ulret++; + /* Fall through. */ case 3: *TgtPtr++ = 0x00; ulret++; + /* Fall through. */ default: break; } @@ -500,10 +503,13 @@ unsigned long FrameTiffComp(unsigned char *pubDest, { case 1: ulret++; + /* Fall through. */ case 2: ulret++; + /* Fall through. */ case 3: ulret++; + /* Fall through. */ default: break; } @@ -542,11 +548,14 @@ unsigned int FrameTiff_Comp(unsigned char *lpSrcBuf, unsigned char *lpTgtBuf, un if(ubFirst == ubSecond) /* case of data match */ { + #if 0 + /* This code causes coverity problems, and has no affect. */ usEndCnt = usCount; if (usCount > 16384) { usEndCnt = 16384; } + #endif usEndCnt = usCount - 2; while (usEndCnt--) { @@ -583,11 +592,14 @@ unsigned int FrameTiff_Comp(unsigned char *lpSrcBuf, unsigned char *lpTgtBuf, un ubMisCnt = 0; if (usCount > 2) { + #if 0 + /* This code causes coverity problems, and has no affect. */ usEndCnt = usCount; if (usCount > 16384) { usEndCnt = 16384; } + #endif usEndCnt = usCount - 2; /* usEndCnt = usCount - 2; original*/ /* 19990824 by LSM : for end file while (usEndCnt--)*/ @@ -680,11 +692,14 @@ unsigned int PreTiffComp(unsigned char *lpSrcBuf, unsigned int nSrcBytes) if(ubFirst == ubSecond) /* case of data match */ { + #if 0 + /* This code causes coverity problems, and has no affect. */ usEndCnt = usCount; if (usCount > 16384) { usEndCnt = 16384; } + #endif usEndCnt = usCount - 2; while (usEndCnt--) { @@ -716,12 +731,15 @@ unsigned int PreTiffComp(unsigned char *lpSrcBuf, unsigned int nSrcBytes) ubMisCnt = 0; if (usCount > 2) { + #if 0 + /* This code causes coverity problems, and has no affect. */ usEndCnt = usCount; if (usCount > 16384) { usEndCnt = 16384; } /* usEndCnt = usCount - 2;*/ + #endif usEndCnt = usCount - 2; /* 19990824 by LSM : for Last file while (usEndCnt--)*/ while (usEndCnt--) diff --git a/contrib/gdevhl12.c b/contrib/gdevhl12.c index 481d2a7a..9f4d617c 100644 --- a/contrib/gdevhl12.c +++ b/contrib/gdevhl12.c @@ -481,7 +481,7 @@ hl1250_compress_band(gp_file * prn_stream, hl1250_state_t * s, unsigned int band break; } if (s->out_count) { - gp_fprintf(prn_stream, "\033*b%uW", s->out_count * sizeof(u16) + 9); + gp_fprintf(prn_stream, "\033*b%luW", s->out_count * sizeof(u16) + 9); put_be16(prn_stream, s->out_count * sizeof(u16) + 7); put_be16(prn_stream, s->xl * 16); put_be16(prn_stream, band + ytop); diff --git a/contrib/gdevln03.c b/contrib/gdevln03.c index 700afabe..88cf8a1f 100644 --- a/contrib/gdevln03.c +++ b/contrib/gdevln03.c @@ -239,7 +239,7 @@ gx_device_printer gs_sxlcrt_device = "sxlcrt", 180, 110, - 42.6667, 32.0, + 42.6667f, 32.0, 0, 0, 0, 0, 1, sxlcrt_print_page); diff --git a/contrib/gdevlx32.c b/contrib/gdevlx32.c index 5193cfe2..b06c7ec1 100644 --- a/contrib/gdevlx32.c +++ b/contrib/gdevlx32.c @@ -138,9 +138,9 @@ static int qualify_buffer(pagedata *gendata); static int roll_buffer(pagedata *gendata); static void calclinemargins(pagedata *gendata, byte *data, int mask, int *left, int *right); static void calcbufmargins(pagedata *gendata,int head); -static void print_color_page(pagedata *gendata); +static int print_color_page(pagedata *gendata); static void print_mono_page(pagedata *gendata); -static void print_photo_page(pagedata *gendata); +static int print_photo_page(pagedata *gendata); /* Codes for the color indexes. */ #define WHITE 0x00 /* Pure white */ @@ -239,12 +239,12 @@ static void print_photo_page(pagedata *gendata); * it's quite hard to know, from inside a printer driver, if we are * printing on envelopes or on standard paper, so we just ignore that. */ -#define LXM3200_TOP_MARGIN 0.070 -#define LXM3200_BOTTOM_MARGIN 0.200 -#define LXM3200_A4_LEFT_MARGIN 0.135 -#define LXM3200_LETTER_LEFT_MARGIN 0.250 -#define LXM3200_A4_RIGHT_MARGIN 0.135 -#define LXM3200_LETTER_RIGHT_MARGIN 0.250 +#define LXM3200_TOP_MARGIN 0.070f +#define LXM3200_BOTTOM_MARGIN 0.200f +#define LXM3200_A4_LEFT_MARGIN 0.135f +#define LXM3200_LETTER_LEFT_MARGIN 0.250f +#define LXM3200_A4_RIGHT_MARGIN 0.135f +#define LXM3200_LETTER_RIGHT_MARGIN 0.250f /* Offsets for the top and bootom start of the printing frame. */ #define LXM3200_A4_TOPOFFSET 84 @@ -563,6 +563,7 @@ lxm3200_map_color_rgb(gx_device *dev, gx_color_index color, static int lxm3200_print_page(gx_device_printer *pdev, gp_file *prn_stream) { + int code = 0; lxm_device *dev = (lxm_device *)pdev; pagedata *gendata; @@ -766,11 +767,13 @@ lxm3200_print_page(gx_device_printer *pdev, gp_file *prn_stream) switch(gendata->rendermode) { case LXM3200_P: - print_photo_page(gendata); + code = print_photo_page(gendata); + if (code < 0) goto end; break; case LXM3200_C: - print_color_page(gendata); + code = print_color_page(gendata); + if (code < 0) goto end; break; case LXM3200_M: @@ -782,11 +785,13 @@ lxm3200_print_page(gx_device_printer *pdev, gp_file *prn_stream) /* Output the end-of-page epilogue */ outputepilogue(gendata); + end: + /* Free the allocated resources */ freeresources(dev); /* Done. Bye bye, see you on next page. */ - return(0); + return code; } /* Function that Ghostscript calls to ask the driver @@ -1243,8 +1248,13 @@ finalizeheader(pagedata *gendata, int vskip, int newhead) */ dir = (header[2] & 0x01 ? LEFT : RIGHT); - /* Retrieve the horizontal offset for the next stripe */ - offs2 = gendata->dev->hoffset[newhead][gendata->direction]; + /* Retrieve the horizontal offset for the next stripe. We don't do this + if newhead is negative, because otherwise we would be out of bounds in + gendata->dev->hoffset[]; offs2 isn't actually used in this case anyway. + */ + if (newhead >= 0) { + offs2 = gendata->dev->hoffset[newhead][gendata->direction]; + } /* Calculate the separation adjust in 1200ths of an inch */ if(newhead == LEFT) @@ -1263,7 +1273,9 @@ finalizeheader(pagedata *gendata, int vskip, int newhead) vskip *= gendata->yrmul; /* Calculate absolute starting position of new stripe */ - nstartabs = newstart + offs2; + if (newhead >= 0) { + nstartabs = newstart + offs2; + } /* Calculate absolute ending position of this stripe * by summing (with proper sign) the starting position @@ -1726,6 +1738,19 @@ encode_bw_buf(pagedata *gendata) left = gendata->left - csep; right = gendata->right + 2*csep; } + /* Make sure we don't try to write data to the left of 0, or the right of the + * media. In the absence of a physical pritner to try this on, we'll have to + * hope the comment above is correct and we can simply not bother with the + * optimisation for accelerating the print head. The right edge one seems + * bonkers, why would we care about accelerating the head when we have + * already started printing ? + * This is to fix bug #701905, accessing beyond the end of gendata->outdata + * in 'convbuf' because right - left > number bytes in scan line. + */ + if (left < 0) + left = 0; + if (right > gendata->numbytes) + right = gendata->numbytes; /* Number of columns in a full row */ numcols = right - left; @@ -2220,7 +2245,7 @@ static int fill_mono_buffer(pagedata *gendata, int vline) { byte *in_data, *data; - int i, ret, ofs; + int i, ret, ofs, code = 0; /* Initialize the "data" pointer, that will be used to * scan all the lines in the buffer, and the "ofs" pointer @@ -2242,8 +2267,10 @@ fill_mono_buffer(pagedata *gendata, int vline) while(vline < gendata->numvlines) { /* Ask Ghostscript for one rasterized line */ - gdev_prn_get_bits((gx_device_printer *)gendata->dev, + code = gdev_prn_get_bits((gx_device_printer *)gendata->dev, vline, data+ofs, &in_data); + if (code < 0) + return code; /* And check if it's all zero: if not, break out of * the loop. This nice trick with memcpy it's by Stephen @@ -2301,8 +2328,10 @@ fill_mono_buffer(pagedata *gendata, int vline) /* If we are not at the end of the page, copy one more * scanline into the buffer. */ - gdev_prn_get_bits((gx_device_printer *)gendata->dev, + code = gdev_prn_get_bits((gx_device_printer *)gendata->dev, vline, data+ofs, &in_data); + if (code < 0) + return code; if(in_data != data+ofs)memcpy(data+ofs, in_data, gendata->numrbytes); } @@ -2333,7 +2362,7 @@ static int init_buffer(pagedata *gendata) { byte *in_data, *data; - int i, ret, p1, p2, ofs; + int i, ret, p1, p2, ofs, code = 0; data = gendata->scanbuf; ofs = gendata->goffset; @@ -2375,8 +2404,11 @@ init_buffer(pagedata *gendata) if(i < gendata->numvlines) { - gdev_prn_get_bits((gx_device_printer *)gendata->dev, + code = gdev_prn_get_bits((gx_device_printer *)gendata->dev, i, data+ofs, &in_data); + if (code < 0) + return code; + if(in_data != data+ofs)memcpy(data+ofs, in_data, gendata->numrbytes); } @@ -2562,8 +2594,10 @@ roll_buffer(pagedata *gendata) memset(data, 0, gendata->numbytes); if(vl < gendata->numvlines) { - gdev_prn_get_bits((gx_device_printer *)gendata->dev, - vl, data+ofs, &in_data); + int code = gdev_prn_get_bits((gx_device_printer *)gendata->dev, vl, data+ofs, &in_data); + if (code < 0) { + return code; + } if(in_data != data+ofs)memcpy(data+ofs, in_data, gendata->numrbytes); } vl++; @@ -2714,7 +2748,7 @@ calcbufmargins(pagedata *gendata, int head) * This is the main routine that prints in * standard color mode. */ -static void +static int print_color_page(pagedata *gendata) { int res, lline, cmask; @@ -2735,12 +2769,15 @@ print_color_page(pagedata *gendata) */ res = init_buffer(gendata); while(res == 0)res = roll_buffer(gendata); + if (res < 0) { + return res; + } /* If this buffer happens to be the last one, * and empty as well, we had a blank page. * Just exit without ado. */ - if(res == LAST)return; + if(res == LAST)return 0; /* This is the first non-blank line of the * page: issue a vertical skip command to @@ -3082,6 +3119,8 @@ print_color_page(pagedata *gendata) * by the trailing sequence). */ finalizeheader(gendata, 0, -1); + + return 0; } /* This is the equivalent of print_color_page() @@ -3189,7 +3228,7 @@ print_mono_page(pagedata *gendata) * no need to care for different heights of the * printing pens (i.e.: no "lastblack" tricks). */ -static void +static int print_photo_page(pagedata *gendata) { int res, lline; @@ -3197,7 +3236,11 @@ print_photo_page(pagedata *gendata) res = init_buffer(gendata); while(res == 0)res = roll_buffer(gendata); - if(res == LAST)return; + if (res < 0) { + return res; + } + + if(res == LAST)return 0; skiplines(gendata, gendata->curvline, COLTOPSTART); lline = gendata->curvline; @@ -3256,6 +3299,9 @@ print_photo_page(pagedata *gendata) } res = roll_buffer(gendata); + if (res < 0) { + return res; + } while(!(res & LAST)) { @@ -3315,6 +3361,9 @@ print_photo_page(pagedata *gendata) } res = roll_buffer(gendata); + if (res < 0) { + return res; + } } switch(res) @@ -3331,6 +3380,7 @@ print_photo_page(pagedata *gendata) encode_col_buf(gendata, LEFT); lline++; } + break; case RHDATA: calcbufmargins(gendata, RIGHT); @@ -3369,4 +3419,5 @@ print_photo_page(pagedata *gendata) } finalizeheader(gendata, 0, -1); + return 0; } diff --git a/contrib/gdevlx7.c b/contrib/gdevlx7.c index 9f0f127b..37f9697f 100644 --- a/contrib/gdevlx7.c +++ b/contrib/gdevlx7.c @@ -581,6 +581,7 @@ lxmgen_print_page(gx_device_printer *pdev, gp_file *prn_stream) int lr_shift=((lxm_device*)pdev)->headSeparation; byte *obp[LX7_BSW_H]; /* pointers to buffer lines */ int bufHeight; + int code = 0; /* initiate vres mapping variable */ vres=LXR_600; /* default vertical resolution */ @@ -689,19 +690,24 @@ lxmgen_print_page(gx_device_printer *pdev, gp_file *prn_stream) int c1200; /* testing empty line for 1200dpi... */ /* copy one line & test for all zeroes */ - gdev_prn_get_bits(pdev, pheight-prest, /* current line No. */ + code = gdev_prn_get_bits(pdev, pheight-prest, /* current line No. */ pbuf, /* our buffer if needed */ &ppbuf); /* returns pointer to scanline * either our buffer or * gs internal data buffer */ + if (code < 0) + goto error; + if (vres==LXR_1200 && (pheight-prest+LXH_DSKIP1<pheight)) { - gdev_prn_get_bits(pdev, pheight-prest+LXH_DSKIP1, + code = gdev_prn_get_bits(pdev, pheight-prest+LXH_DSKIP1, /* current line No. */ pbuf+bwidth, /* our buffer if needed */ &ppbuf2); c1200=LX_LINE_EMPTY(ppbuf2,bwidth); + if (code < 0) + goto error; } else c1200=1; @@ -791,13 +797,14 @@ lxmgen_print_page(gx_device_printer *pdev, gp_file *prn_stream) /* eject page */ lex_eject(prn_stream); +error: gs_free(pdev->memory->non_gc_memory, (char*)pbuf,rpbufsize, 1, "lxmgen_print_page(pbuf)"); gs_free(pdev->memory->non_gc_memory, (char*)outbuf,OUT_BUF_SIZE, 1, "lxmgen_print_page(outbuf)"); #ifdef DEBUG dprintf1("[%s] print_page() end\n",pdev->dname); #endif - return 0; + return code; } static int diff --git a/contrib/gdevmd2k.c b/contrib/gdevmd2k.c index ed45e981..86202774 100644 --- a/contrib/gdevmd2k.c +++ b/contrib/gdevmd2k.c @@ -28,11 +28,11 @@ #include <stdlib.h> #include <limits.h> -#define MM_PER_INCH 25.4 -#define TOP_MARGIN 12. / MM_PER_INCH -#define BOTTOM_MARGIN 15. / MM_PER_INCH -#define LEFT_MARGIN 3.4 / MM_PER_INCH -#define RIGHT_MARGIN 3.4 / MM_PER_INCH +#define MM_PER_INCH 25.4f +#define TOP_MARGIN 12.f / MM_PER_INCH +#define BOTTOM_MARGIN 15.f / MM_PER_INCH +#define LEFT_MARGIN 3.4f / MM_PER_INCH +#define RIGHT_MARGIN 3.4f / MM_PER_INCH /* The device descriptor */ static dev_proc_open_device(alps_open); @@ -110,8 +110,8 @@ typedef enum { static int alps_open(gx_device *pdev) { - int xdpi = pdev->x_pixels_per_inch; - int ydpi = pdev->y_pixels_per_inch; + int xdpi = (int)pdev->x_pixels_per_inch; + int ydpi = (int)pdev->y_pixels_per_inch; const float margins[4] = { LEFT_MARGIN, BOTTOM_MARGIN, @@ -129,10 +129,10 @@ alps_open(gx_device *pdev) return_error(gs_error_rangecheck); density = (xdpi == 300 ? 0.75 : xdpi == 600 ? 0.44 : 0.4); - dev_alps->cyan *= density; - dev_alps->magenta *= density; - dev_alps->yellow *= density; - dev_alps->black *= density; + dev_alps->cyan = (int)(dev_alps->cyan * density); + dev_alps->magenta = (int)(dev_alps->magenta * density); + dev_alps->yellow = (int)(dev_alps->yellow * density); + dev_alps->black = (int)(dev_alps->black * density); return gdev_prn_open(pdev); } @@ -402,15 +402,17 @@ runlength(byte *out, byte *in, int length) return p_out - out; } -#define write_short(data, stream) { \ - gp_fputc((unsigned char) (data), stream); \ - gp_fputc((unsigned short) (data) >> 8, stream); \ +static void write_short(unsigned data, gp_file* stream) +{ + gp_fputc((unsigned char) (data), stream); + gp_fputc((unsigned short) (data) >> 8, stream); } -#define alps_cmd(cmd1, data, cmd2, stream) { \ - gp_fwrite(cmd1, 1, 3, stream); \ - write_short(data, stream); \ - gp_fputc(cmd2, stream); \ +static void alps_cmd(const char* cmd1, unsigned data, int cmd2, gp_file* stream) +{ + gp_fwrite(cmd1, 1, 3, stream); + write_short(data, stream); + gp_fputc(cmd2, stream); } static void @@ -449,8 +451,8 @@ alps_init(gx_device_printer *pdev, gp_file *prn_stream, alps_printer_type ptype) : pdev->x_pixels_per_inch == 600 ? 3 : 4), prn_stream); gp_fputc(0122, prn_stream); - height = (pdev->MediaSize[1] - pdev->HWMargins[1] - pdev->HWMargins[3]) - * pdev->y_pixels_per_inch / 72.; + height = (short)((pdev->MediaSize[1] - pdev->HWMargins[1] - pdev->HWMargins[3]) + * pdev->y_pixels_per_inch / 72.); alps_cmd("\033\046\154", height, 0120, prn_stream); /* if -dReverseSide ... */ @@ -486,7 +488,7 @@ alps_print_page(gx_device_printer *pdev, gp_file *prn_stream, int c_comp, num_comp = pdev->color_info.num_components; int n_comp = (dev_alps->mediaType == 1 ? 3 : num_comp); int *error, *ep; - int i, j; + int i, j, code = 0; /* allocate memory */ work = (byte *)gs_malloc(pdev->memory->non_gc_memory, 3+sizeof(int), line_size, @@ -528,19 +530,23 @@ alps_print_page(gx_device_printer *pdev, gp_file *prn_stream, for(y = 0; y < y_height; y ++) { uint len = line_size; - gdev_prn_get_bits(pdev, y, in, &dp); + code = gdev_prn_get_bits(pdev, y, in, &dp); + if (code < 0) + return code; switch (pdev->color_info.depth) { case 4: /* get a component of CMYK from raster data */ len = cmyk_to_bit(work, dp, len, c_comp); dp = work; + /* Fall through. */ case 1: /* remove trailing 0s */ for( ; len > 0 && dp[len-1] == 0; len --); break; case 32: dp += c_comp; + /* Fall through. */ case 8: outP = work; ep = error; diff --git a/contrib/gdevop4w.c b/contrib/gdevop4w.c index 3109cc67..a92f6e63 100644 --- a/contrib/gdevop4w.c +++ b/contrib/gdevop4w.c @@ -81,8 +81,8 @@ * inexact paperlength which is set to 117 10ths. * Somebody should check for letter sized paper. I left it at 0.07". */ -#define OKI4W_MARGINS_LETTER 0.125, 0.25, 0.125, 0.07 -#define OKI4W_MARGINS_A4 0.125, 0.25, 0.125, 0.07 +#define OKI4W_MARGINS_LETTER 0.125f, 0.25f, 0.125f, 0.07f +#define OKI4W_MARGINS_A4 0.125f, 0.25f, 0.125f, 0.07f /* We round up the LINE_SIZE to a multiple of a ulong for faster scanning. */ #define word ulong @@ -137,6 +137,8 @@ oki4w_open(gx_device *pdev) static int oki4w_close(gx_device *pdev) { + /* RJW: We must call the close entry point for the class. */ + return gdev_prn_close(pdev); /* if ( pdev->Duplex_set >= 0 && pdev->Duplex ) { gdev_prn_open_printer(pdev, 1); @@ -152,79 +154,6 @@ oki4w_close(gx_device *pdev) /* ------ Internal routines ------ */ -static int -oki_compress(byte *src, byte *dst, int count) -{ - int dcnt = 0; - byte lastval = *src; - int run = 1; - src++; - count--; - while (count-- > 0) { - byte newval = *src++; - if (newval == lastval) { - run++; - } else { - /* end of run, flush data */ - if (run == 1) { - byte *backptr = dst++; - *dst++ = lastval; - dcnt++; - lastval = newval; - while (run < 128 && count > 0) { - run++; - newval = *src++; - *dst++ = newval; - dcnt++; - count--; - if (newval == lastval) { - break; - } - } - if (newval == lastval) { - run--; - dst--; - dcnt--; - } - *backptr = dst - backptr - 2; - if (newval == lastval) { - run = 2; - } else { - run = 1; - } - continue; - } - while (run > 128) { - *dst++ = 0x81; - *dst++ = lastval; - run -= 128; - dcnt += 2; - } - if (run > 0) { - *dst++ = (0x101 - run) & 0xff; - *dst++ = lastval; - dcnt += 2; - } - lastval = newval; - run = 1; - } - } - /* end of run, flush data */ - while (run > 128) { - *dst++ = 0x81; - *dst++ = lastval; - run -= 128; - dcnt += 2; - } - if (run > 0) { - *dst++ = (0x101 - run) & 0xff; - *dst++ = lastval; - dcnt += 2; - } - - return dcnt; -} - /* Send the page to the printer. For speed, compress each scan line, */ /* since computer-to-printer communication time is often a bottleneck. */ static int @@ -241,8 +170,8 @@ oki4w_print_page(gx_device_printer *pdev, gp_file *prn_stream) #define data ((byte *)data_words) #define out_row ((byte *)out_row_words) byte *out_data; - int x_dpi = pdev->x_pixels_per_inch; - int y_dpi = pdev->y_pixels_per_inch; + int x_dpi = (int)pdev->x_pixels_per_inch; + int y_dpi = (int)pdev->y_pixels_per_inch; int y_dots_per_pixel = x_dpi / y_dpi; int dpi_code, compress_code; int num_rows = dev_print_scan_lines(pdev); @@ -264,14 +193,12 @@ oki4w_print_page(gx_device_printer *pdev, gp_file *prn_stream) if (y_dpi == 150) { dpi_code = 3; - compress_code = 2; } else if (y_dpi == 300) { dpi_code = 5; - compress_code = 2; } else { dpi_code = 7; - compress_code = 2; } + compress_code = 2; /* Initialize printer. */ /* if ( pdev->PageCount == 0 ) { */ @@ -332,13 +259,8 @@ oki4w_print_page(gx_device_printer *pdev, gp_file *prn_stream) num_blank_lines = 0; /* Compress the data */ - if (compress_code == 6) { - out_count = oki_compress(data, out_data, - (end_data - data_words) * W); - } else { - out_count = gdev_pcl_mode2compress(data_words, - end_data, out_data); - } + out_count = gdev_pcl_mode2compress(data_words, + end_data, out_data); /* Transfer the data */ for (i = 0; i < y_dots_per_pixel; ++i) { diff --git a/contrib/japanese/gdev10v.c b/contrib/japanese/gdev10v.c index 510a74e8..f4c349d1 100644 --- a/contrib/japanese/gdev10v.c +++ b/contrib/japanese/gdev10v.c @@ -68,13 +68,26 @@ static dev_proc_print_page(bj10v_print_page); static dev_proc_get_initial_matrix(bj10v_get_initial_matrix); #endif +static int +bj10v_open(gx_device * pdev) +{ + if (pdev->HWResolution[0] < 180 || + pdev->HWResolution[1] < 180) + { + emprintf(pdev->memory, "device requires a resolution of at least 180dpi\n"); + return_error(gs_error_rangecheck); + } + return gdev_prn_open(pdev); +} + + #if 0 gx_device_procs prn_bj10v_procs = prn_matrix_procs(gdev_prn_open, bj10v_get_initial_matrix, gdev_prn_output_page, gdev_prn_close); #endif gx_device_procs prn_bj10v_procs = - prn_procs(gdev_prn_open, gdev_prn_output_page, gdev_prn_close); + prn_procs(bj10v_open, gdev_prn_output_page, gdev_prn_close); gx_device_printer gs_bj10v_device = prn_device(prn_bj10v_procs, "bj10v", @@ -196,8 +209,8 @@ bj10v_output_run(byte *data, int dnum, int bytes, static int bj10v_print_page(gx_device_printer *pdev, gp_file *prn_stream) { int line_size = gdev_prn_raster((gx_device *)pdev); - int xres = pdev->x_pixels_per_inch; - int yres = pdev->y_pixels_per_inch; + int xres = (int)pdev->x_pixels_per_inch; + int yres = (int)pdev->y_pixels_per_inch; const char *mode = (yres == 180 ? (xres == 180 ? "\052\047" : "\052\050") : "|*"); @@ -206,7 +219,8 @@ bj10v_print_page(gx_device_printer *pdev, gp_file *prn_stream) int x_skip_unit = bytes_per_column * (xres / 180); int y_skip_unit = (yres / 180); byte *in = (byte *)gs_malloc(pdev->memory->non_gc_memory, 8, line_size, "bj10v_print_page(in)"); - byte *out = (byte *)gs_malloc(pdev->memory->non_gc_memory, bits_per_column, line_size, "bj10v_print_page(out)"); + /* We need one extra byte in <out> for our sentinel. */ + byte *out = (byte *)gs_malloc(pdev->memory->non_gc_memory, bits_per_column * line_size + 1, 1, "bj10v_print_page(out)"); int lnum = 0; int y_skip = 0; int code = 0; diff --git a/contrib/japanese/gdevalps.c b/contrib/japanese/gdevalps.c index e6af9cf1..9d3122ac 100644 --- a/contrib/japanese/gdevalps.c +++ b/contrib/japanese/gdevalps.c @@ -43,9 +43,9 @@ /* Alps Micro Dry 600dpi monochrome printer driver */ #include "gdevprn.h" -#define MD_TOP_MARGIN 0.47 -#define MD_BOTTOM_MARGIN 0.59 -#define MD_SIDE_MARGIN 0.13 +#define MD_TOP_MARGIN 0.47f +#define MD_BOTTOM_MARGIN 0.59f +#define MD_SIDE_MARGIN 0.13f #define X_DPI 600 #define Y_DPI 600 @@ -155,13 +155,20 @@ static const char end_md[] = { static int md_open(gx_device *pdev) { - static const float md_margins[4] = - { MD_SIDE_MARGIN, MD_BOTTOM_MARGIN, - MD_SIDE_MARGIN, MD_TOP_MARGIN - }; - - gx_device_set_margins(pdev, md_margins, true); - return gdev_prn_open(pdev); + static const float md_margins[4] = + { + MD_SIDE_MARGIN, MD_BOTTOM_MARGIN, + MD_SIDE_MARGIN, MD_TOP_MARGIN + }; + + if (pdev->HWResolution[0] != 600) + { + emprintf(pdev->memory, "device must have an X resolution of 600dpi\n"); + return_error(gs_error_rangecheck); + } + + gx_device_set_margins(pdev, md_margins, true); + return gdev_prn_open(pdev); } /* MD5000 monochrome mode entrance. */ diff --git a/contrib/japanese/gdevespg.c b/contrib/japanese/gdevespg.c index 18ce6ca4..2f182134 100644 --- a/contrib/japanese/gdevespg.c +++ b/contrib/japanese/gdevespg.c @@ -66,8 +66,8 @@ static const char *epson_remote_start = "\033\001@EJL \r\n"; static int escpage_open(gx_device * pdev) { - int xdpi = pdev->x_pixels_per_inch; - int ydpi = pdev->y_pixels_per_inch; + int xdpi = (int)pdev->x_pixels_per_inch; + int ydpi = (int)pdev->y_pixels_per_inch; /* Resolution Check */ if (xdpi != ydpi) @@ -81,8 +81,8 @@ escpage_open(gx_device * pdev) static int lp2000_open(gx_device * pdev) { - int xdpi = pdev->x_pixels_per_inch; - int ydpi = pdev->y_pixels_per_inch; + int xdpi = (int)pdev->x_pixels_per_inch; + int ydpi = (int)pdev->y_pixels_per_inch; /* Resolution Check */ if (xdpi != ydpi) @@ -273,21 +273,21 @@ escpage_paper_set(gx_device_printer * pdev, gp_file * fp) int width, height, w, h, wp, hp, bLandscape; EpagPaperTable *pt; - width = pdev->MediaSize[0]; - height = pdev->MediaSize[1]; + width = (int)pdev->MediaSize[0]; + height = (int)pdev->MediaSize[1]; if (width < height) { bLandscape = 0; w = width; h = height; - wp = width / 72.0 * pdev->x_pixels_per_inch; - hp = height / 72.0 * pdev->y_pixels_per_inch; + wp = (int)(width / 72.0 * pdev->x_pixels_per_inch); + hp = (int)(height / 72.0 * pdev->y_pixels_per_inch); } else { bLandscape = 1; w = height; h = width; - wp = height / 72.0 * pdev->y_pixels_per_inch; - hp = width / 72.0 * pdev->x_pixels_per_inch; + wp = (int)(height / 72.0 * pdev->y_pixels_per_inch); + hp = (int)(width / 72.0 * pdev->x_pixels_per_inch); } for (pt = epagPaperTable; pt->escpage > 0; pt++) diff --git a/contrib/japanese/gdevlbp3.c b/contrib/japanese/gdevlbp3.c index 096aecf6..8cbc2ce8 100644 --- a/contrib/japanese/gdevlbp3.c +++ b/contrib/japanese/gdevlbp3.c @@ -137,8 +137,8 @@ BoundImage(gx_device_printer *pDev, struct bounding *pBox) height*10/Yres < 98 ? a5 :\ height*10/Yres < 109 ? b5 :\ height*10/Yres < 116 ? letter : a4; - Xsize = Xres * mm_to_inch(PaperInfo[paper].w-100) / 160; - Ysize = Yres * mm_to_inch(PaperInfo[paper].h-100) / 10; + Xsize = (int)(Xres * mm_to_inch(PaperInfo[paper].w-100) / 160); + Ysize = (int)(Yres * mm_to_inch(PaperInfo[paper].h-100) / 10); /* ----==== Allocate momory ====---- */ if (LineSize < Xsize*2+1) { LineSize = Xsize*2+1; diff --git a/contrib/japanese/gdevmjc.c b/contrib/japanese/gdevmjc.c index 85fa6a8a..b132167d 100644 --- a/contrib/japanese/gdevmjc.c +++ b/contrib/japanese/gdevmjc.c @@ -113,9 +113,9 @@ copies. */ /* Margins are left, bottom, right, top. */ /* left bottom right top */ -#define MJ700V2C_MARGINS_A4 0.118, 0.52, 0.118, 0.33465 -#define MJ6000C_MARGINS_A2 0.948, 0.52, 1.969, 0.33465 -#define MJ8000C_MARGINS_A2 0.194, 0.52, 0.194, 0.33465 +#define MJ700V2C_MARGINS_A4 0.118f, 0.52f, 0.118f, 0.33465f +#define MJ6000C_MARGINS_A2 0.948f, 0.52f, 1.969f, 0.33465f +#define MJ8000C_MARGINS_A2 0.194f, 0.52f, 0.194f, 0.33465f /* Define bits-per-pixel for generic drivers - default is 24-bit mode */ #ifndef BITSPERPIXEL @@ -296,8 +296,8 @@ mjcmyk_device(mj8000c_procs, "mj8000c", 360, 360, BITSPERPIXEL, static int gdev_mjc_paper_size(gx_device *dev) { - int width = dev->MediaSize[0]; - int height = dev->MediaSize[1]; + int width = (int)dev->MediaSize[0]; + int height = (int)dev->MediaSize[1]; if (width == 1190 && height == 1684) return PAPER_SIZE_A2; @@ -333,8 +333,8 @@ mj8000c_open(gx_device * pdev) static int mj_open(gx_device *pdev, int ptype) { /* Change the margins if necessary. */ - int xdpi = pdev->x_pixels_per_inch; - int ydpi = pdev->y_pixels_per_inch; + int xdpi = (int)pdev->x_pixels_per_inch; + int ydpi = (int)pdev->y_pixels_per_inch; static const float mj_margin[4] = { MJ700V2C_MARGINS_A4 }; static const float mj6000c_a2[4] = { MJ6000C_MARGINS_A2 }; @@ -365,7 +365,7 @@ mj_open(gx_device *pdev, int ptype) gx_device_set_margins(pdev, m, true); if (mj->colorcomp == 3) - mj->density = mj->density * 720 / ydpi * 1.5; + mj->density = (int)(mj->density * 720 / ydpi) * 1.5; else mj->density = mj->density * 720 / ydpi; @@ -440,6 +440,7 @@ mj_put_params(gx_device *pdev, gs_param_list *plist, int ptype) code = put_param_int(plist, "Magenta", &magenta, 0, INT_MAX, code); code = put_param_int(plist, "Yellow", &yellow, 0, INT_MAX, code); code = put_param_int(plist, "Black", &black, 0, INT_MAX, code); + (void) code; if ((code = param_read_bool(plist, (param_name = "Unidirectional"), @@ -667,7 +668,7 @@ mj_raster_cmd(int c_id, int in_size, byte* in, byte* buf2, ** walk forward, looking for matches: */ - for( q++ ; *q == *p && q < in_end ; q++ ) { + for( q++ ; q < in_end && *q == *p ; q++ ) { if( (q-p) >= 128 ) { if( p > inp ) { count = p - inp; @@ -998,7 +999,6 @@ mj_print_page(gx_device_printer * pdev, gp_file * prn_stream, int ptype) plane_size = calc_buffsize(line_size, storage_bpp); if (bits_per_pixel == 1) { /* Data printed direct from i/p */ - databuff_size = 0; /* so no data buffer required, */ outbuff_size = plane_size * 4; /* but need separate output buffers */ } @@ -1053,6 +1053,7 @@ mj_print_page(gx_device_printer * pdev, gp_file * prn_stream, int ptype) p += xtalbuff_size; Kbuf[1] = p; p += xtalbuff_size; + (void) p; } storage = (word *) gs_malloc(pdev->memory->non_gc_memory, storage_size_words, W, "mj_colour_print_page"); @@ -1105,7 +1106,6 @@ mj_print_page(gx_device_printer * pdev, gp_file * prn_stream, int ptype) p += plane_size; } if (bits_per_pixel == 1) { - out_data = out_row = p; /* size is outbuff_size * 4 */ data[1] += databuff_size; /* coincides with plane_data pointers */ data[3] += databuff_size; } @@ -1174,17 +1174,14 @@ mj_print_page(gx_device_printer * pdev, gp_file * prn_stream, int ptype) #define MOFFSET (pdev->t_margin - MJ700V2C_PRINT_LIMIT) /* Print position */ { - int MJ_MARGIN_MM = 55; - uint top_skip = ( MJ_MARGIN_MM * pdev->y_pixels_per_inch ) / 254; - top_skip = (top_skip ^ (-1)) & 65536; gp_fwrite("\033(V\2\0\0\0",sizeof(byte), 7, prn_stream); gp_fwrite("\033(v\2\0\0\xff",sizeof(byte), 7, prn_stream); } /* Send each scan line in turn */ { - long int lend = pdev->height - - (dev_t_margin_points(pdev) + dev_b_margin_points(pdev)); + long int lend = (int)(pdev->height - + (dev_t_margin_points(pdev) + dev_b_margin_points(pdev))); int cErr, mErr, yErr, kErr; int this_pass, i; long int lnum; @@ -1441,14 +1438,6 @@ mj_color_correct(gx_color_value *Rptr ,gx_color_value *Gptr , gx_color_value *Bp *Gptr = M; *Bptr = Y; return; - } else if (G>B) { /* R=G>B */ - D = G-B; - Wa = R; - H = 256; - } else { /* B>R=G */ - D = G-B; - Wa = R; - H = 1024; } } @@ -1504,7 +1493,10 @@ mj_color_correct(gx_color_value *Rptr ,gx_color_value *Gptr , gx_color_value *Bp if (Y<0) Y=0; - if(H>256 && H<1024){ /* green correct */ + /* 2019-10-29 this used to be 'if(H>256 && H<1024)', which can then go + beyond bounds of the 512-element grnsep2[]. So have patched up to avoid + this, but without any proper idea about what's going on. */ + if(H>256 && H<768){ /* green correct */ short work; work=(((long)grnsep[M]*(long)grnsep2[H-256])>>16); C+=work; @@ -1613,12 +1605,12 @@ gdev_mjc_map_color_rgb(gx_device *pdev, gx_color_index color, prgb[2] = -(c >> 2); } else - { gx_color_value value = (gx_color_value)color ^ 0xff; + { gx_color_index value = (gx_color_index)color ^ 0xff; prgb[0] = prgb[1] = prgb[2] = (value << 8) + value; } break; case 16: - { gx_color_value c = (gx_color_value)color ^ 0xffff; + { gx_color_index c = (gx_color_index)color ^ 0xffff; ushort value = c >> 11; prgb[0] = ((value << 11) + (value << 6) + (value << 1) + (value >> 4)) >> (16 - gx_color_value_bits); @@ -1631,7 +1623,7 @@ gdev_mjc_map_color_rgb(gx_device *pdev, gx_color_index color, } break; case 24: - { gx_color_value c = (gx_color_value)color ^ 0xffffff; + { gx_color_index c = (gx_color_index)color ^ 0xffffff; prgb[0] = gx_color_value_from_byte(c >> 16); prgb[1] = gx_color_value_from_byte((c >> 8) & 0xff); prgb[2] = gx_color_value_from_byte(c & 0xff); diff --git a/contrib/japanese/gdevnpdl.c b/contrib/japanese/gdevnpdl.c index 4ecace50..9deadaee 100644 --- a/contrib/japanese/gdevnpdl.c +++ b/contrib/japanese/gdevnpdl.c @@ -71,45 +71,45 @@ * The commented values are from the PC-PR1000E/4 User's Manual. */ /* margins of A3 paper */ -#define L_MARGIN_A3 0.20 -#define B_MARGIN_A3 0.24 -#define R_MARGIN_A3 0.20 -#define T_MARGIN_A3 0.20 +#define L_MARGIN_A3 0.20f +#define B_MARGIN_A3 0.24f +#define R_MARGIN_A3 0.20f +#define T_MARGIN_A3 0.20f /* margins of A4 paper */ -#define L_MARGIN_A4 0.31 -#define B_MARGIN_A4 0.20 -#define R_MARGIN_A4 0.16 -#define T_MARGIN_A4 0.20 +#define L_MARGIN_A4 0.31f +#define B_MARGIN_A4 0.20f +#define R_MARGIN_A4 0.16f +#define T_MARGIN_A4 0.20f /* margins of A5 paper */ -#define L_MARGIN_A5 0.31 -#define B_MARGIN_A5 0.16 -#define R_MARGIN_A5 0.16 -#define T_MARGIN_A5 0.20 +#define L_MARGIN_A5 0.31f +#define B_MARGIN_A5 0.16f +#define R_MARGIN_A5 0.16f +#define T_MARGIN_A5 0.20f /* margins of B4 paper */ -#define L_MARGIN_B4 0.31 -#define B_MARGIN_B4 0.24 -#define R_MARGIN_B4 0.31 -#define T_MARGIN_B4 0.20 +#define L_MARGIN_B4 0.31f +#define B_MARGIN_B4 0.24f +#define R_MARGIN_B4 0.31f +#define T_MARGIN_B4 0.20f /* margins of B5 paper */ -#define L_MARGIN_B5 0.31 -#define B_MARGIN_B5 0.24 -#define R_MARGIN_B5 0.16 -#define T_MARGIN_B5 0.20 +#define L_MARGIN_B5 0.31f +#define B_MARGIN_B5 0.24f +#define R_MARGIN_B5 0.16f +#define T_MARGIN_B5 0.20f /* margins of letter size paper */ -#define L_MARGIN_LETTER 0.31 -#define B_MARGIN_LETTER 0.24 -#define R_MARGIN_LETTER 0.20 -#define T_MARGIN_LETTER 0.20 +#define L_MARGIN_LETTER 0.31f +#define B_MARGIN_LETTER 0.24f +#define R_MARGIN_LETTER 0.20f +#define T_MARGIN_LETTER 0.20f /* margins of postcard size paper */ -#define L_MARGIN_POSTCARD 0.31 -#define B_MARGIN_POSTCARD 0.12 -#define R_MARGIN_POSTCARD 0.24 -#define T_MARGIN_POSTCARD 0.20 +#define L_MARGIN_POSTCARD 0.31f +#define B_MARGIN_POSTCARD 0.12f +#define R_MARGIN_POSTCARD 0.24f +#define T_MARGIN_POSTCARD 0.20f /* margins of env4 size paper */ -#define L_MARGIN_ENV4 0.20 -#define B_MARGIN_ENV4 0.20 -#define R_MARGIN_ENV4 0.20 -#define T_MARGIN_ENV4 0.20 +#define L_MARGIN_ENV4 0.20f +#define B_MARGIN_ENV4 0.20f +#define R_MARGIN_ENV4 0.20f +#define T_MARGIN_ENV4 0.20f /* The device descriptors */ static dev_proc_open_device(npdl_open); @@ -527,8 +527,8 @@ npdl_set_page_layout(gx_device * dev) static int npdl_open(gx_device * dev) { - int xdpi = dev->x_pixels_per_inch; - int ydpi = dev->y_pixels_per_inch; + int xdpi = (int)dev->x_pixels_per_inch; + int ydpi = (int)dev->y_pixels_per_inch; /* Print Resolution Check */ if (xdpi != ydpi) diff --git a/contrib/japanese/gdevp201.c b/contrib/japanese/gdevp201.c index 11f8f98e..1d3f4607 100644 --- a/contrib/japanese/gdevp201.c +++ b/contrib/japanese/gdevp201.c @@ -134,6 +134,9 @@ pr201_print_page(gx_device_printer *pdev, gp_file *prn_stream) byte *in, *out; int lnum, skip; int head_pins, lr_pitch, x_dpi; + int code = 0; + byte mask; + int endidx = pdev->width>>3; switch (check_mode(pdev->dname)){ case PR201: @@ -160,6 +163,11 @@ pr201_print_page(gx_device_printer *pdev, gp_file *prn_stream) if(in == 0 || out == 0) return -1; + if (pdev->width & 7) + mask = ~(255>>(pdev->width & 7)); + else + mask = 255, endidx--; + /* Initialize printer */ gp_fputs("\033cl", pdev->file); /* Software Reset */ gp_fputs("\033P", pdev->file); /* Proportional Mode */ @@ -173,17 +181,26 @@ pr201_print_page(gx_device_printer *pdev, gp_file *prn_stream) lnum = 0; skip = 0; while(lnum < height) { - byte *inp, *outp, *out_beg, *out_end; - int x, y, num_lines, size, mod; - - /* Copy scan lines */ - if(gdev_prn_copy_scan_lines(pdev, lnum, in, chunk_size) < 0) - break; + byte *inp, *outp, *out_beg, *out_end, *p; + int x, y, num_lines, size, mod, i; /* The number of lines to process */ if((num_lines = height - lnum) > bits_per_column) num_lines = bits_per_column; + /* Copy scan lines */ + for (i = 0, p = in; i < num_lines; i++, p += line_size) { + code = gdev_prn_get_bits(pdev, lnum + i, p, NULL); + if (code < 0) + goto error; + p[endidx] &= mask; + } + + /* Ensure we have a full stripe of line data */ + for (; i < bits_per_column; i++, p += line_size) { + memset(p, 0, line_size); + } + /* Test for all zero */ size = line_size * num_lines; if(in[0] == 0 && @@ -242,7 +259,7 @@ pr201_print_page(gx_device_printer *pdev, gp_file *prn_stream) out_beg -= (out_beg - out) % bytes_per_column; /* Dot addressing */ - gp_fprintf(pdev->file, "\033F%04d", + gp_fprintf(pdev->file, "\033F%04" PRIdSIZE, (out_beg - out) / bytes_per_column); /* Dot graphics */ @@ -264,10 +281,11 @@ pr201_print_page(gx_device_printer *pdev, gp_file *prn_stream) gp_fputc('\f',pdev->file); gp_fflush(pdev->file); +error: gs_free(pdev->memory->non_gc_memory, (char *)out, bits_per_column, line_size, "pr201_print_page(out)"); gs_free(pdev->memory->non_gc_memory, (char *)in, bits_per_column, line_size, "pr201_print_page(in)"); - return 0; + return code; } diff --git a/contrib/japanese/gdevrpdl.c b/contrib/japanese/gdevrpdl.c index dee81bb5..d7e561f5 100644 --- a/contrib/japanese/gdevrpdl.c +++ b/contrib/japanese/gdevrpdl.c @@ -48,8 +48,8 @@ lprn_device(gx_device_lprn, rpdl_prn_procs, "rpdl", static int rpdl_open(gx_device * pdev) { - int xdpi = pdev->x_pixels_per_inch; - int ydpi = pdev->y_pixels_per_inch; + int xdpi = (int)pdev->x_pixels_per_inch; + int ydpi = (int)pdev->y_pixels_per_inch; /* Resolution Check */ if (xdpi != ydpi) @@ -238,8 +238,8 @@ rpdl_paper_set(gx_device_printer * pdev, gp_file * prn_stream) /* Page size match tolerance in points */ #define TOL 5 - width = pdev->MediaSize[0]; - height = pdev->MediaSize[1]; + width = (int)pdev->MediaSize[0]; + height = (int)pdev->MediaSize[1]; if (width < height) { w = width; diff --git a/contrib/lips4/gdevl4r.c b/contrib/lips4/gdevl4r.c index 9272a6be..f5015b1d 100644 --- a/contrib/lips4/gdevl4r.c +++ b/contrib/lips4/gdevl4r.c @@ -56,9 +56,9 @@ static dev_proc_image_out(lips4_image_out); (int)((long)(DEFAULT_WIDTH_10THS) * (xdpi) / 10),\ (int)((long)(DEFAULT_HEIGHT_10THS) * (ydpi) / 10),\ xdpi, ydpi, color_bits,\ - -(lm) * (xdpi), -(tm) * (ydpi),\ - (lm) * 72.0, (bm) * 72.0,\ - (rm) * 72.0, (tm) * 72.0\ + (float)(-(lm) * (xdpi)), (float)(-(tm) * (ydpi)),\ + (float)((lm) * 72.0), (float)((bm) * 72.0f),\ + (float)((rm) * 72.0), (float)((tm) * 72.0f)\ ),\ lp_device_body_rest_(print_page_copies, image_out),\ cassetFeed, username, LIPS_PJL_DEFAULT,\ @@ -71,9 +71,9 @@ static dev_proc_image_out(lips4_image_out); (int)((long)(DEFAULT_WIDTH_10THS) * (xdpi) / 10),\ (int)((long)(DEFAULT_HEIGHT_10THS) * (ydpi) / 10),\ xdpi, ydpi, color_bits,\ - -(lm) * (xdpi), -(tm) * (ydpi),\ - (lm) * 72.0, (bm) * 72.0,\ - (rm) * 72.0, (tm) * 72.0\ + (float)(-(lm) * (xdpi)), (float)(-(tm) * (ydpi)),\ + (float)((lm) * 72.0), (float)((bm) * 72.0),\ + (float)((rm) * 72.0), (float)((tm) * 72.0)\ ),\ lp_duplex_device_body_rest_(print_page_copies, image_out),\ cassetFeed,\ @@ -214,10 +214,10 @@ lips4_open(gx_device * pdev) static int lips_open(gx_device * pdev, lips_printer_type ptype) { - int width = pdev->MediaSize[0]; - int height = pdev->MediaSize[1]; - int xdpi = pdev->x_pixels_per_inch; - int ydpi = pdev->y_pixels_per_inch; + int width = (int)pdev->MediaSize[0]; + int height = (int)pdev->MediaSize[1]; + int xdpi = (int)pdev->x_pixels_per_inch; + int ydpi = (int)pdev->y_pixels_per_inch; /* Paper Size Check */ if (width <= height) { /* portrait */ @@ -437,6 +437,7 @@ lips_put_params(gx_device * pdev, gs_param_list * plist) default: ecode = code; userne:param_signal_error(plist, param_name, ecode); + /* Fall through. */ case 1: usern.data = 0; break; @@ -502,7 +503,7 @@ lips4_put_params(gx_device * pdev, gs_param_list * plist) (param_name = LIPS_OPTION_MEDIATYPE), &pmedia)) { case 0: - if (pmedia.size > LIPS_MEDIACHAR_MAX) { + if (pmedia.size >= LIPS_MEDIACHAR_MAX) { ecode = gs_error_limitcheck; goto pmediae; } else { /* Check the validity of ``MediaType'' characters */ @@ -520,6 +521,7 @@ lips4_put_params(gx_device * pdev, gs_param_list * plist) default: ecode = code; pmediae:param_signal_error(plist, param_name, ecode); + /* Fall through. */ case 1: pmedia.data = 0; break; @@ -645,12 +647,15 @@ lips4type_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream, int { if (!(lprn->CompBuf = gs_malloc(pdev->memory->non_gc_memory, bpl * 3 / 2 + 1, maxY, "(CompBuf)"))) return_error(gs_error_VMerror); - if (!(lprn->CompBuf2 = gs_malloc(pdev->memory->non_gc_memory, bpl * 3 / 2 + 1, maxY, "(CompBuf2)"))) + + /* This buffer is used by lips_rle_encode(), which can require double + input size plus 2 bytes. */ + if (!(lprn->CompBuf2 = gs_malloc(pdev->memory->non_gc_memory, bpl * 2 + 2, maxY, "(CompBuf2)"))) return_error(gs_error_VMerror); if (lprn->NegativePrint) { - int rm = pdev->width - (dev_l_margin(pdev) + dev_r_margin(pdev)) * pdev->x_pixels_per_inch; - int bm = pdev->height - (dev_t_margin(pdev) + dev_b_margin(pdev)) * pdev->y_pixels_per_inch; + int rm = (int)(pdev->width - (dev_l_margin(pdev) + dev_r_margin(pdev)) * pdev->x_pixels_per_inch); + int bm = (int)(pdev->height - (dev_t_margin(pdev) + dev_b_margin(pdev)) * pdev->y_pixels_per_inch); /* Draw black rectangle */ gp_fprintf(prn_stream, "%c{%c%da%c%de%c;;;3}", @@ -822,11 +827,13 @@ lips4_image_out(gx_device_printer * pdev, gp_file * prn_stream, int x, int y, in gp_fwrite(lprn->TmpBuf, 1, width / 8 * height, prn_stream); } } else { + /* 2019-11-28: changed two occurrencies of 'Len' to 'Len_rle' here, but + unable to test. */ gs_sprintf(comp_str, "%c%d;%d;%d;10;%d.r", LIPS_CSI, - Len, width / 8, (int)pdev->x_pixels_per_inch, height); + Len_rle, width / 8, (int)pdev->x_pixels_per_inch, height); if (Len_rle < width / 8 * height - strlen(comp_str) + strlen(raw_str)) { gp_fprintf(prn_stream, "%s", comp_str); - gp_fwrite(lprn->CompBuf2, 1, Len, prn_stream); + gp_fwrite(lprn->CompBuf2, 1, Len_rle, prn_stream); } else { /* compression result is bad. */ gp_fprintf(prn_stream, "%s", raw_str); @@ -941,8 +948,8 @@ lips_job_start(gx_device_printer * pdev, lips_printer_type ptype, gp_file * prn_ gx_device_lips *const lips = (gx_device_lips *) pdev; gx_device_lips4 *const lips4 = (gx_device_lips4 *) pdev; int prev_paper_size, prev_paper_width, prev_paper_height, paper_size; - int width = pdev->MediaSize[0]; - int height = pdev->MediaSize[1]; + int width = (int)pdev->MediaSize[0]; + int height = (int)pdev->MediaSize[1]; int tm, lm, rm, bm; if (pdev->PageCount == 0) { @@ -1168,14 +1175,14 @@ lips_job_start(gx_device_printer * pdev, lips_printer_type ptype, gp_file * prn_ } if (prev_paper_size != paper_size) { /* Top Margin: 63/300 inch + 5 mm */ - tm = (63. / 300. + 5. / MMETER_PER_INCH - dev_t_margin(pdev)) * pdev->x_pixels_per_inch; + tm = (int)((63. / 300. + 5. / MMETER_PER_INCH - dev_t_margin(pdev)) * pdev->x_pixels_per_inch); if (tm > 0) gp_fprintf(prn_stream, "%c%dk", LIPS_CSI, tm); if (tm < 0) gp_fprintf(prn_stream, "%c%de", LIPS_CSI, -tm); /* Left Margin: 5 mm left */ - lm = (5. / MMETER_PER_INCH - dev_l_margin(pdev)) * pdev->x_pixels_per_inch; + lm = (int)((5. / MMETER_PER_INCH - dev_l_margin(pdev)) * pdev->x_pixels_per_inch); if (lm > 0) gp_fprintf(prn_stream, "%c%dj", LIPS_CSI, lm); if (lm < 0) @@ -1185,10 +1192,10 @@ lips_job_start(gx_device_printer * pdev, lips_printer_type ptype, gp_file * prn_ gp_fprintf(prn_stream, "%c0;2t", LIPS_CSI); /* Bottom Margin: height */ - bm = pdev->height - (dev_t_margin(pdev) + dev_b_margin(pdev)) * pdev->y_pixels_per_inch; + bm = (int)(pdev->height - (dev_t_margin(pdev) + dev_b_margin(pdev)) * pdev->y_pixels_per_inch); gp_fprintf(prn_stream, "%c%de", LIPS_CSI, bm); /* Right Margin: width */ - rm = pdev->width - (dev_l_margin(pdev) + dev_r_margin(pdev)) * pdev->x_pixels_per_inch; + rm = (int)(pdev->width - (dev_l_margin(pdev) + dev_r_margin(pdev)) * pdev->x_pixels_per_inch); gp_fprintf(prn_stream, "%c%da", LIPS_CSI, rm); gp_fprintf(prn_stream, "%c1;3t", LIPS_CSI); diff --git a/contrib/lips4/gdevl4v.c b/contrib/lips4/gdevl4v.c index eb4f31a1..47b3fd17 100644 --- a/contrib/lips4/gdevl4v.c +++ b/contrib/lips4/gdevl4v.c @@ -572,18 +572,10 @@ lips4v_copy_text_char(gx_device * dev, const byte * data, } } /* ʸ»ú¥»¥Ã¥È¡¦¥¢¥µ¥¤¥óÈÖ¹æÁªÂòÌ¿Îá2 */ - if (download) { - if (pdev->current_font != ccode / 128) { - gs_sprintf(cset_number, "%c%d%%v", LIPS_CSI, ccode / 128); - lputs(s, cset_number); - pdev->current_font = ccode / 128; - } - } else { - if (pdev->current_font != ccode / 128) { - gs_sprintf(cset_number, "%c%d%%v", LIPS_CSI, ccode / 128); - lputs(s, cset_number); - pdev->current_font = ccode / 128; - } + if (pdev->current_font != ccode / 128) { + gs_sprintf(cset_number, "%c%d%%v", LIPS_CSI, ccode / 128); + lputs(s, cset_number); + pdev->current_font = ccode / 128; } /* ¥«¥é¡¼ */ @@ -1313,9 +1305,10 @@ lips4v_beginpath(gx_device_vector * vdev, gx_path_type_t type) if (type & gx_path_type_clip) { lputs(s, "P(10"); sputc(s, LIPS_IS2); - } else + } else { lputs(s, "P(00"); sputc(s, LIPS_IS2); + } return 0; } @@ -1396,11 +1389,11 @@ lips4v_endpath(gx_device_vector * vdev, gx_path_type_t type) lputs(s, "P)"); sputc(s, LIPS_IS2); if (type & gx_path_type_rule) { - if (type & gx_path_type_winding_number) { - lputs(s, "}I1"); + if (type & gx_path_type_even_odd) { + lputs(s, "}I0"); sputc(s, LIPS_IS2); } else { - lputs(s, "}I0"); + lputs(s, "}I1"); sputc(s, LIPS_IS2); } } @@ -1640,6 +1633,7 @@ lips4v_put_params(gx_device * dev, gs_param_list * plist) default: ecode = code; casse:param_signal_error(plist, param_name, ecode); + /* Fall through. */ case 1: break; } @@ -1665,6 +1659,7 @@ lips4v_put_params(gx_device * dev, gs_param_list * plist) default: ecode = code; pmediae:param_signal_error(plist, param_name, ecode); + /* Fall through. */ case 1: pmedia.data = 0; break; @@ -1695,6 +1690,7 @@ lips4v_put_params(gx_device * dev, gs_param_list * plist) default: ecode = code; userne:param_signal_error(plist, param_name, ecode); + /* Fall through. */ case 1: usern.data = 0; break; @@ -1716,6 +1712,7 @@ lips4v_put_params(gx_device * dev, gs_param_list * plist) default: ecode = code; nupe:param_signal_error(plist, param_name, ecode); + /* Fall through. */ case 1: break; } @@ -1736,6 +1733,7 @@ lips4v_put_params(gx_device * dev, gs_param_list * plist) default: ecode = code; tden:param_signal_error(plist, param_name, ecode); + /* Fall through. */ case 1: break; } @@ -1771,6 +1769,7 @@ lips4v_put_params(gx_device * dev, gs_param_list * plist) } ecode = code; param_signal_error(plist, param_name, ecode); + /* Fall through. */ case 1: break; } @@ -1795,6 +1794,7 @@ lips4v_put_params(gx_device * dev, gs_param_list * plist) default: ecode = code; bppe:param_signal_error(plist, param_name, ecode); + /* Fall through. */ case 1: break; } @@ -2469,9 +2469,10 @@ lips4v_image_end_image(gx_image_enum_common_t * info, bool draw_last) if (pdev->OneBitMask) pdev->OneBitMask = false; - else + else { lputs(s, "}Q1100"); sputc(s, LIPS_IS2); /* End of Image */ + } pdev->MaskReverse = -1; diff --git a/contrib/lips4/gdevlips.c b/contrib/lips4/gdevlips.c index 11aa8323..6dd07047 100644 --- a/contrib/lips4/gdevlips.c +++ b/contrib/lips4/gdevlips.c @@ -145,7 +145,7 @@ GetNumSameData(const byte * curPtr, const int maxnum) if (1 == maxnum) { return (1); } - while (*curPtr == *(curPtr + count) && maxnum > count) { + while (maxnum > count && *curPtr == *(curPtr + count)) { count++; } @@ -160,7 +160,7 @@ GetNumWrongData(const byte * curPtr, const int maxnum) if (1 == maxnum) { return (1); } - while (*(curPtr + count) != *(curPtr + count + 1) && maxnum > count) { + while (maxnum > count+1 && *(curPtr + count) != *(curPtr + count + 1)) { count++; } diff --git a/contrib/lips4/gdevlips.h b/contrib/lips4/gdevlips.h index 0083d70f..1e3dd72c 100644 --- a/contrib/lips4/gdevlips.h +++ b/contrib/lips4/gdevlips.h @@ -114,29 +114,29 @@ #define LIPS4_COMPRESS_DEFAULT FALSE #define LIPS2P_DPI_DEFAULT 240 -#define LIPS2P_LEFT_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define LIPS2P_BOTTOM_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define LIPS2P_RIGHT_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define LIPS2P_TOP_MARGIN_DEFAULT 5. / MMETER_PER_INCH +#define LIPS2P_LEFT_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define LIPS2P_BOTTOM_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define LIPS2P_RIGHT_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define LIPS2P_TOP_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) #define LIPS3_DPI_DEFAULT 300 -#define LIPS3_LEFT_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define LIPS3_BOTTOM_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define LIPS3_RIGHT_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define LIPS3_TOP_MARGIN_DEFAULT 5. / MMETER_PER_INCH +#define LIPS3_LEFT_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define LIPS3_BOTTOM_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define LIPS3_RIGHT_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define LIPS3_TOP_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) #define BJC880J_DPI_DEFAULT 360 -#define BJC880J_LEFT_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define BJC880J_BOTTOM_MARGIN_DEFAULT 8. / MMETER_PER_INCH -#define BJC880J_RIGHT_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define BJC880J_TOP_MARGIN_DEFAULT 2. / MMETER_PER_INCH +#define BJC880J_LEFT_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define BJC880J_BOTTOM_MARGIN_DEFAULT (float)(8. / MMETER_PER_INCH) +#define BJC880J_RIGHT_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define BJC880J_TOP_MARGIN_DEFAULT (float)(2. / MMETER_PER_INCH) #define LIPS4_DPI_DEFAULT 600 -#define LIPS4_LEFT_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define LIPS4_BOTTOM_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define LIPS4_RIGHT_MARGIN_DEFAULT 5. / MMETER_PER_INCH -#define LIPS4_TOP_MARGIN_DEFAULT 5. / MMETER_PER_INCH +#define LIPS4_LEFT_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define LIPS4_BOTTOM_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define LIPS4_RIGHT_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) +#define LIPS4_TOP_MARGIN_DEFAULT (float)(5. / MMETER_PER_INCH) /* Define the default resolutions. */ diff --git a/contrib/lips4/gdevlprn.c b/contrib/lips4/gdevlprn.c index df8f862e..7461e46e 100644 --- a/contrib/lips4/gdevlprn.c +++ b/contrib/lips4/gdevlprn.c @@ -334,9 +334,16 @@ lprn_is_black(gx_device_printer * pdev, int r, int h, int bx) y0 = (r + h - bh) % maxY; for (y = 0; y < bh; y++) { p = &lprn->ImageBuf[(y0 + y) * bpl + bx * lprn->nBw]; - for (x = 0; x < lprn->nBw; x++) + for (x = 0; x < lprn->nBw; x++) { + /* bpl isn't necessarily a multiple of lprn->nBw, so + we need to explicitly stop after the last byte in this + line to avoid accessing either the next line's data or + going off the end of our buffer completely. This avoids + https://bugs.ghostscript.com/show_bug.cgi?id=701785. */ + if (bx * lprn->nBw + x >= bpl) break; if (p[x] != 0) return 1; + } } return 0; } diff --git a/contrib/opvp/gdevopvp.c b/contrib/opvp/gdevopvp.c index cb2921e6..70475add 100644 --- a/contrib/opvp/gdevopvp.c +++ b/contrib/opvp/gdevopvp.c @@ -1796,6 +1796,7 @@ opvp_load_vector_driver(void) } OpenPrinter_0_2 = NULL; ErrorNo = NULL; + dlclose(h); } i++; } @@ -2505,15 +2506,12 @@ opvp_map_rgb_color(gx_device *dev, b = prgb[2]; #endif -#if !(ENABLE_SIMPLE_MODE) - pdev = (gx_device_opvp *)dev; - r = -1; -#endif - cs = OPVP_CSPACE_STANDARDRGB; - #if ENABLE_SIMPLE_MODE cs = colorSpace; #else + pdev = (gx_device_opvp *)dev; + r = -1; + cs = OPVP_CSPACE_STANDARDRGB; if (pdev->is_open) { /* call GetColorSpace */ if (apiEntry->opvpGetColorSpace) { @@ -2560,7 +2558,11 @@ opvp_map_rgb_color(gx_device *dev, } else { k = 0; } - return (k + (y << 8) + (m << 16) + (c << 24)); + return (gx_color_index) k + + ((gx_color_index) y << 8) + + ((gx_color_index) m << 16) + + ((gx_color_index) c << 24) + ; break; case OPVP_CSPACE_DEVICEGRAY: #if GS_VERSION_MAJOR >= 8 @@ -3581,13 +3583,17 @@ opvp_fill_mask( const gx_clip_path *pcpath) { if (vector) { + int code; #if GS_VERSION_MAJOR >= 8 /* for gs 8.15 */ - gdev_vector_update_fill_color((gx_device_vector *)dev, NULL, pdcolor); + code = gdev_vector_update_fill_color((gx_device_vector *)dev, NULL, pdcolor); #else - gdev_vector_update_fill_color((gx_device_vector *)dev, pdcolor); + code = gdev_vector_update_fill_color((gx_device_vector *)dev, pdcolor); #endif - gdev_vector_update_clip_path((gx_device_vector *)dev, pcpath); - gdev_vector_update_log_op((gx_device_vector *)dev, lop); + if (code < 0) return code; + code = gdev_vector_update_clip_path((gx_device_vector *)dev, pcpath); + if (code < 0) return code; + code = gdev_vector_update_log_op((gx_device_vector *)dev, lop); + if (code < 0) return code; } return gx_default_fill_mask(dev, data, data_x, raster, id, @@ -4023,6 +4029,10 @@ opvp_image_plane_data( if (buf) { /* Adjust image data gamma */ pbe = (bbox_image_enum *)vinfo->bbox_info; + if (!pbe) { + ecode = gs_note_error(gs_error_invalidaccess); + goto end; + } tinfo = (gx_image_enum *)pbe->target_info; pgs = tinfo->pgs; @@ -4339,20 +4349,16 @@ opvp_image_plane_data( for (i = 0; i < height; i++) { ptr = buf + raster_length * i; for (j = 0; j < vinfo->width; j++) { - ptr[j*3] = min(255, frac2cv(gx_map_color_frac(pgs, - cv2frac(ptr[j*3]), effective_transfer[0]))); - ptr[j*3+1] = min(255, frac2cv(gx_map_color_frac(pgs, - cv2frac(ptr[j*3+1]), effective_transfer[1]))); - ptr[j*3+2] = min(255, frac2cv(gx_map_color_frac(pgs, - cv2frac(ptr[j*3+2]), effective_transfer[2]))); + ptr[j*3+0] = frac2byte(gx_map_color_frac(pgs, byte2frac(ptr[j*3+0]), effective_transfer[0])); + ptr[j*3+1] = frac2byte(gx_map_color_frac(pgs, byte2frac(ptr[j*3+1]), effective_transfer[1])); + ptr[j*3+2] = frac2byte(gx_map_color_frac(pgs, byte2frac(ptr[j*3+2]), effective_transfer[2])); } } } else if (vinfo->bits_per_pixel == 8) { /* 8bit Gray image */ for (i = 0; i < height; i++) { ptr = buf + raster_length * i; for (j=0; j < vinfo->width; j++) { - ptr[j] = min(255, frac2cv(gx_map_color_frac(pgs, - cv2frac(ptr[j]), effective_transfer[3]))); + ptr[j] = frac2byte(gx_map_color_frac(pgs, byte2frac(ptr[j]), effective_transfer[3])); } } } @@ -4361,20 +4367,16 @@ opvp_image_plane_data( for (i = 0; i < height; i++) { ptr = buf + raster_length * i; for (j = 0; j < vinfo->width; j++) { - ptr[j*3] = min(255, frac2cv(gx_map_color_frac(pgs, - cv2frac(ptr[j*3]), effective_transfer.colored.red))); - ptr[j*3+1] = min(255, frac2cv(gx_map_color_frac(pgs, - cv2frac(ptr[j*3+1]), effective_transfer.colored.green))); - ptr[j*3+2] = min(255, frac2cv(gx_map_color_frac(pgs, - cv2frac(ptr[j*3+2]), effective_transfer.colored.blue))); + ptr[j*3+0] = frac2byte(gx_map_color_frac(pgs, byte2frac(ptr[j*3+0]), effective_transfer.colored.red)); + ptr[j*3+1] = frac2byte(gx_map_color_frac(pgs, byte2frac(ptr[j*3+1]), effective_transfer.colored.green)); + ptr[j*3+2] = frac2byte(gx_map_color_frac(pgs, byte2frac(ptr[j*3+2]), effective_transfer.colored.blue)); } } } else if (vinfo->bits_per_pixel == 8) { /* 8bit Gray image */ for (i = 0; i < height; i++) { ptr = buf + raster_length * i; for (j = 0; j < vinfo->width; j++) { - ptr[j] = min(255, frac2cv(gx_map_color_frac(pgs, - cv2frac(ptr[j]), effective_transfer.colored.gray))); + ptr[j] = frac2byte(gx_map_color_frac(pgs, byte2frac(ptr[j]), effective_transfer.colored.gray)); } } } @@ -4385,14 +4387,15 @@ opvp_image_plane_data( apiEntry->opvpTransferDrawImage(printerContext, raster_length * height, (void *)buf); } - if (buf) { - free(buf); /* free buffer */ - } } vinfo->y += height; ecode = (vinfo->y >= vinfo->height); +end: + if (buf) { + free(buf); /* free buffer */ + } return ecode; } @@ -4833,7 +4836,6 @@ opvp_vector_dopath( int i; int pop = 0; int npoints = 0; - int *cp_num = NULL; _fPoint *points = NULL; opvp_point_t *opvp_p = NULL; _fPoint current; @@ -4912,11 +4914,6 @@ opvp_vector_dopath( break; case gs_pe_curveto: /* npoints */ - if (!cp_num) - cp_num = calloc(sizeof(int), 2); - cp_num[0] = npoints; - cp_num[1] = 0; - /* call BezierPath */ if (apiEntry->opvpBezierPath) { r = apiEntry->opvpBezierPath( @@ -4938,7 +4935,6 @@ opvp_vector_dopath( /* reset */ npoints = 1; - if (cp_num) free(cp_num), cp_num = NULL; points = realloc(points, sizeof(_fPoint)); points[0] = current; #endif @@ -5066,7 +5062,6 @@ opvp_vector_dopath( #ifdef OPVP_OPT_MULTI_PATH if (points) free(points); if (opvp_p) free(opvp_p); - if (cp_num) free(cp_num); #endif return ecode; } diff --git a/contrib/pcl3/eprn/eprnrend.c b/contrib/pcl3/eprn/eprnrend.c index 9abe9007..2da1f9c6 100644 --- a/contrib/pcl3/eprn/eprnrend.c +++ b/contrib/pcl3/eprn/eprnrend.c @@ -240,7 +240,7 @@ gx_color_index eprn_map_rgb_color_for_RGB_flex(gx_device *device, gx_color_value red = cv[0], green = cv[1], blue = cv[2]; gx_color_index value = 0; gx_color_value step; - unsigned int level; + gx_color_index level; const eprn_Eprn *eprn = &((eprn_Device *)device)->eprn; #ifdef EPRN_TRACE @@ -466,7 +466,7 @@ gx_color_index eprn_map_cmyk_color_flex(gx_device *device, gx_color_value cyan = cv[0], magenta = cv[1], yellow = cv[2], black = cv[3]; gx_color_index value = 0; gx_color_value step; - unsigned int level; + gx_color_index level; const eprn_Eprn *eprn = &((eprn_Device *)device)->eprn; #ifdef EPRN_TRACE diff --git a/contrib/pcl3/eprn/gdeveprn.c b/contrib/pcl3/eprn/gdeveprn.c index e7b1cb5b..d99895fd 100644 --- a/contrib/pcl3/eprn/gdeveprn.c +++ b/contrib/pcl3/eprn/gdeveprn.c @@ -836,11 +836,12 @@ int eprn_set_page_layout(eprn_Device *dev) ******************************************************************************/ -void eprn_init_device(eprn_Device *dev, const eprn_PrinterDescription *desc) +int eprn_init_device(eprn_Device *dev, const eprn_PrinterDescription *desc) { eprn_Eprn *eprn = &dev->eprn; int j; float hres, vres; + int code; if (dev->is_open) gs_closedevice((gx_device *)dev); @@ -867,9 +868,11 @@ void eprn_init_device(eprn_Device *dev, const eprn_PrinterDescription *desc) eprn->intensity_rendering = eprn_IR_halftones; hres = dev->HWResolution[0]; vres = dev->HWResolution[1]; - eprn_check_colour_info(desc->colour_info, &eprn->colour_model, + code = eprn_check_colour_info(desc->colour_info, &eprn->colour_model, &hres, &vres, &eprn->black_levels, &eprn->non_black_levels); - + if (code) { + return code; + } if (eprn->pagecount_file != NULL) { gs_free(dev->memory->non_gc_memory, eprn->pagecount_file, strlen(eprn->pagecount_file) + 1, sizeof(char), "eprn_init_device"); @@ -878,7 +881,7 @@ void eprn_init_device(eprn_Device *dev, const eprn_PrinterDescription *desc) eprn->media_position_set = false; - return; + return 0; } /****************************************************************************** diff --git a/contrib/pcl3/eprn/gdeveprn.h b/contrib/pcl3/eprn/gdeveprn.h index e0c08927..e71799bd 100644 --- a/contrib/pcl3/eprn/gdeveprn.h +++ b/contrib/pcl3/eprn/gdeveprn.h @@ -632,7 +632,7 @@ typedef struct { preceding each function's implementation. */ /* Initialize the eprn device for another printer model */ -extern void eprn_init_device(eprn_Device *dev, +extern int eprn_init_device(eprn_Device *dev, const eprn_PrinterDescription *desc); /* Modify the information on supported media sizes and associated hardware diff --git a/contrib/pcl3/eprn/mediasize.c b/contrib/pcl3/eprn/mediasize.c index 8cfe3d91..21c6a26f 100644 --- a/contrib/pcl3/eprn/mediasize.c +++ b/contrib/pcl3/eprn/mediasize.c @@ -100,11 +100,11 @@ static const ms_SizeDescription list[] = { /* Media called by this name may vary up to 0.5" in dimension (PPD 4.3). */ {sn(A4), {210*BP_PER_MM, 297*BP_PER_MM}}, {sn(Folio), {210*BP_PER_MM, 330*BP_PER_MM}}, - {sn(Quarto), {8.5*BP_PER_IN, 10.83*BP_PER_IN}}, /* 215.9 x 275.1 mm + {sn(Quarto), {8.5f*BP_PER_IN, 10.83f*BP_PER_IN}}, /* 215.9 x 275.1 mm PPD 4.3 uses bp values for the definition, but this does not agree with the mm values it specifies. The inch specifications fit. */ - {sn(Letter), {8.5*BP_PER_IN, 11.0*BP_PER_IN}}, /* 215.9 x 279.4 mm */ - {sn(Legal), {8.5*BP_PER_IN, 14.0*BP_PER_IN}}, /* 215.9 x 355.6 mm */ + {sn(Letter), {8.5f*BP_PER_IN, 11.0f*BP_PER_IN}}, /* 215.9 x 279.4 mm */ + {sn(Legal), {8.5f*BP_PER_IN, 14.0f*BP_PER_IN}}, /* 215.9 x 355.6 mm */ {sn(EnvKaku3), {216*BP_PER_MM, 277*BP_PER_MM}}, {sn(SuperA), {227*BP_PER_MM, 356*BP_PER_MM}}, {sn(ARCHA), {9*BP_PER_IN, 12*BP_PER_IN}}, /* 228.6 x 304.8 mm */ diff --git a/contrib/pcl3/eprn/mediasize.h b/contrib/pcl3/eprn/mediasize.h index 8553b6ea..4033ad21 100644 --- a/contrib/pcl3/eprn/mediasize.h +++ b/contrib/pcl3/eprn/mediasize.h @@ -20,10 +20,10 @@ All these macros resolve to floating point numbers. */ /* Millimetres per inch */ -#define MM_PER_IN 25.4 +#define MM_PER_IN 25.4f /* Big points (units in PostScript's default user space) per inch */ -#define BP_PER_IN 72.0 +#define BP_PER_IN 72.0f /* Big points per millimetre */ #define BP_PER_MM (BP_PER_IN/MM_PER_IN) diff --git a/contrib/pcl3/src/gdevpcl3.c b/contrib/pcl3/src/gdevpcl3.c index 7582c9bc..6b6468e0 100644 --- a/contrib/pcl3/src/gdevpcl3.c +++ b/contrib/pcl3/src/gdevpcl3.c @@ -897,7 +897,11 @@ static int pcl3_put_params(gx_device *device, gs_param_list *plist) if (dev->is_open) gs_closedevice(device); dev->printer = subdevice_list[j].value; dev->initialized = false; - eprn_init_device((eprn_Device *)dev, &pcl3_printers[dev->printer].desc); + rc = eprn_init_device((eprn_Device *)dev, &pcl3_printers[dev->printer].desc); + if (rc < 0) { + last_error = rc; + param_signal_error(plist, pname, last_error); + } } else { eprintf1("%s" ERRPREF "Unknown subdevice name: `", epref); @@ -1378,8 +1382,8 @@ static int pcl3_open_device(gx_device *device) /* Per-colorant information */ for (j = 0; j < data->number_of_colorants; j++) { - data->colorant_array[j].hres = dev->HWResolution[0] + 0.5; - data->colorant_array[j].vres = dev->HWResolution[1] + 0.5; + data->colorant_array[j].hres = (int)(dev->HWResolution[0] + 0.5); + data->colorant_array[j].vres = (int)(dev->HWResolution[1] + 0.5); } if (data->palette == pcl_CMY || data->palette == pcl_RGB) for (j = 0; j < 3; j++) @@ -1443,18 +1447,19 @@ static int pcl3_close_device(gx_device *device) ******************************************************************************/ -/* Macro to handle return codes from calls to pclgen routines */ -#define guard(call) \ - if ((rc = (call)) != 0) { \ - if (rc > 0) return_error(gs_error_Fatal); /* bugs are fatal :-) */ \ - return_error(gs_error_ioerror); /* actually any environment error */ \ - } +/* Function to convert return codes from calls to pclgen routines. */ +static int convert(int code) +{ + if (code > 0) return gs_error_Fatal; + if (code < 0) return gs_error_ioerror; + return 0; +} static int pcl3_print_page(gx_device_printer *device, gp_file *out) { int blank_lines, - rc; + rc = 0; pcl3_Device *dev = (pcl3_Device *)device; const char *epref = dev->eprn.CUPS_messages? CUPS_ERRPREF: ""; pcl_RasterData rd; @@ -1463,75 +1468,95 @@ static int pcl3_print_page(gx_device_printer *device, gp_file *out) *lengths, planes; + /* Make sure out cleanup code will cope with partially-initialised data. */ + memset(&rd, 0, sizeof(pcl_RasterData)); /* Belt and braces. */ + planes = 0; + lengths = NULL; + rd.next = NULL; + rd.previous = NULL; + rd.workspace[0] = NULL; + rd.workspace[1] = NULL; + /* If this is a new file or we've decided to re-configure, initialize the printer first */ if (gdev_prn_file_is_new(device) || !dev->configured || dev->configure_every_page) { - guard(pcl3_init_file(device->memory, out, &dev->file_data)) + rc = convert(pcl3_init_file(device->memory, out, &dev->file_data)); + if (rc) { + (void) gs_note_error(rc); + goto end; + } dev->configured = true; } /* Initialize raster data structure */ - memset(&rd, 0, sizeof(pcl_RasterData)); rd.global = &dev->file_data; planes = eprn_number_of_bitplanes((eprn_Device *)dev); lengths = (unsigned int *)malloc(planes*sizeof(unsigned int)); + if (!lengths) { + rc = gs_note_error(gs_error_VMerror); + goto end; + } + eprn_number_of_octets((eprn_Device *)dev, lengths); rd.next = (pcl_OctetString *)malloc(planes*sizeof(pcl_OctetString)); - if (pcl_cm_is_differential(dev->file_data.compression)) + if (!rd.next) { + rc = gs_note_error(gs_error_VMerror); + goto end; + } + for (j=0; j<planes; j++) { /* Make sure we can free at any point. */ + rd.next[j].str = NULL; + } + if (pcl_cm_is_differential(dev->file_data.compression)) { rd.previous = (pcl_OctetString *)malloc(planes*sizeof(pcl_OctetString)); - if (lengths == NULL || rd.next == NULL || - (pcl_cm_is_differential(dev->file_data.compression) && - rd.previous == NULL)) { - free(lengths); free(rd.next); free(rd.previous); - eprintf1("%s" ERRPREF "Memory allocation failure from malloc().\n", - epref); - return_error(gs_error_VMerror); + if (!rd.previous) { + rc = gs_note_error(gs_error_VMerror); + goto end; + } + for (j=0; j<planes; j++) { /* Make sure we can free at any point. */ + rd.previous[j].str = NULL; + } + for (j = 0; j < planes; j++) { + rd.previous[j].str = (pcl_Octet *)malloc(lengths[j]*sizeof(eprn_Octet)); + if (!rd.previous[j].str) { + rc = gs_note_error(gs_error_VMerror); + goto end; + } + } } - eprn_number_of_octets((eprn_Device *)dev, lengths); rd.width = 8*lengths[0]; /* all colorants have equal resolution */ - for (j = 0; j < planes; j++) + for (j = 0; j < planes; j++) { rd.next[j].str = (pcl_Octet *)malloc(lengths[j]*sizeof(eprn_Octet)); + if (!rd.next[j].str) { + rc = gs_note_error(gs_error_VMerror); + goto end; + } + } /* Note: 'pcl_Octet' must be identical with 'eprn_Octet'. */ - if (pcl_cm_is_differential(dev->file_data.compression)) - for (j = 0; j < planes; j++) - rd.previous[j].str = (pcl_Octet *)malloc(lengths[j]*sizeof(eprn_Octet)); rd.workspace_allocated = lengths[0]; for (j = 1; j < planes; j++) if (lengths[j] > rd.workspace_allocated) rd.workspace_allocated = lengths[j]; for (j = 0; - j < 2 && (j != 1 || dev->file_data.compression == pcl_cm_delta); j++) + j < 2 && (j != 1 || dev->file_data.compression == pcl_cm_delta); j++) { rd.workspace[j] = (pcl_Octet *)malloc(rd.workspace_allocated*sizeof(pcl_Octet)); - - /* Collective check for allocation failures */ - j = 0; - while (j < planes && rd.next[j].str != NULL) j++; - if (j == planes && pcl_cm_is_differential(dev->file_data.compression)) { - j = 0; - while (j < planes && rd.previous[j].str != NULL) j++; - if (j == planes && dev->file_data.compression == pcl_cm_delta && - rd.workspace[1] == NULL) j = 0; - } - if (j < planes || rd.workspace[0] == NULL) { - /* Free everything. Note that free(NULL) is legal and we did a memset() - with 0 on 'rd'. */ - for (j = 0; j < planes; j++) { - free(rd.next[j].str); - if (pcl_cm_is_differential(dev->file_data.compression)) - free(rd.previous[j].str); + if (!rd.workspace[j]) { + rc = gs_note_error(gs_error_VMerror); + goto end; } - free(lengths); free(rd.next); free(rd.previous); - for (j = 0; j < 2; j++) free(rd.workspace[j]); - - eprintf1("%s" ERRPREF "Memory allocation failure from malloc().\n", - epref); - return_error(gs_error_VMerror); } /* Open the page and start raster mode */ - guard(pcl3_begin_page(out, &dev->file_data)) - guard(pcl3_begin_raster(out, &rd)) + rc = convert(pcl3_begin_page(out, &dev->file_data)); + if (rc) { + (void) gs_note_error(rc); + goto end; + } + rc = convert(pcl3_begin_raster(out, &rd)); + if (rc) { + (void) gs_note_error(rc); + goto end; + } /* Loop over scan lines */ blank_lines = 0; @@ -1565,25 +1590,56 @@ static int pcl3_print_page(gx_device_printer *device, gp_file *out) if (j == planes) blank_lines++; else { if (blank_lines > 0) { - guard(pcl3_skip_groups(out, &rd, blank_lines)) + rc = convert(pcl3_skip_groups(out, &rd, blank_lines)); + if (rc) { + (void) gs_note_error(rc); + goto end; + } blank_lines = 0; } - guard(pcl3_transfer_group(out, &rd)) + rc = convert(pcl3_transfer_group(out, &rd)); + if (rc) { + (void) gs_note_error(rc); + goto end; + } } } /* Terminate raster mode and close the page */ - guard(pcl3_end_raster(out, &rd)) - guard(pcl3_end_page(out, &dev->file_data)) + rc = convert(pcl3_end_raster(out, &rd)); + if (rc) { + (void) gs_note_error(rc); + goto end; + } + rc = convert(pcl3_end_page(out, &dev->file_data)); + if (rc) { + (void) gs_note_error(rc); + goto end; + } +end: /* Free dynamic storage */ - for (j = 0; j < planes; j++) free(rd.next[j].str); - if (pcl_cm_is_differential(dev->file_data.compression)) - for (j = 0; j < planes; j++) free(rd.previous[j].str); - for (j = 0; j < 2; j++) free(rd.workspace[j]); - free(lengths); free(rd.next); free(rd.previous); + if (rd.next) { + for (j = 0; j < planes; j++) { + free(rd.next[j].str); + } + } + if (rd.previous) { + for (j = 0; j < planes; j++) { + free(rd.previous[j].str); + } + } + for (j = 0; j < 2; j++) { + free(rd.workspace[j]); + } + free(lengths); + free(rd.next); + free(rd.previous); - return 0; -} + if (rc == gs_error_VMerror) { + eprintf1("%s" ERRPREF "Memory allocation failure from malloc().\n", + epref); + } -#undef guard + return rc; +} diff --git a/contrib/pcl3/src/pclcap.c b/contrib/pcl3/src/pclcap.c index f07b93a2..77f52aa8 100644 --- a/contrib/pcl3/src/pclcap.c +++ b/contrib/pcl3/src/pclcap.c @@ -110,15 +110,15 @@ static const eprn_PageDescription Note that BPD05054 gives different margins. */ {ms_Letter, - 0.25*BP_PER_IN, (0.5-0.08)*BP_PER_IN, 0.25*BP_PER_IN, 0.08*BP_PER_IN}, + 0.25f*BP_PER_IN, (0.5f-0.08f)*BP_PER_IN, 0.25f*BP_PER_IN, 0.08f*BP_PER_IN}, {ms_Legal, - 0.25*BP_PER_IN, (0.5-0.08)*BP_PER_IN, 0.25*BP_PER_IN, 0.08*BP_PER_IN}, + 0.25f*BP_PER_IN, (0.5f-0.08f)*BP_PER_IN, 0.25f*BP_PER_IN, 0.08f*BP_PER_IN}, {ms_A4, - 0.125*BP_PER_IN, (0.5-0.08)*BP_PER_IN, 3.6*BP_PER_MM, 0.08*BP_PER_IN}, + 0.125f*BP_PER_IN, (0.5f-0.08f)*BP_PER_IN, 3.6f*BP_PER_MM, 0.08f*BP_PER_IN}, {ms_Executive, - 0.25*BP_PER_IN, (0.5-0.08)*BP_PER_IN, 0.25*BP_PER_IN, 0.08*BP_PER_IN}, + 0.25f*BP_PER_IN, (0.5f-0.08f)*BP_PER_IN, 0.25f*BP_PER_IN, 0.08f*BP_PER_IN}, {ms_JISB5, - 3.175*BP_PER_MM, (0.5-0.08)*BP_PER_IN, 3.25*BP_PER_MM, 0.08*BP_PER_IN}, + 3.175f*BP_PER_MM, (0.5f-0.08f)*BP_PER_IN, 3.25f*BP_PER_MM, 0.08f*BP_PER_IN}, /* DJ3/4 p. 21: "Envelopes are printed in the landscape mode". As the margins are given such that the largest value is designated as "bottom" and the bottom is designated on page 19 as a long edge, I conclude that @@ -126,9 +126,9 @@ static const eprn_PageDescription dimensions for Env10 in portrait and EnvDL in landscape orientation. */ {ms_Env10 | MS_TRANSVERSE_FLAG, - 0.125*BP_PER_IN, (0.5-0.08)*BP_PER_IN, 0.08*BP_PER_IN, 0.08*BP_PER_IN}, + 0.125f*BP_PER_IN, (0.5f-0.08f)*BP_PER_IN, 0.08f*BP_PER_IN, 0.08f*BP_PER_IN}, {ms_EnvDL | MS_TRANSVERSE_FLAG, - 0.125*BP_PER_IN, (0.5-0.08)*BP_PER_IN, 0.11*BP_PER_IN, 0.08*BP_PER_IN}, + 0.125f*BP_PER_IN, (0.5f-0.08f)*BP_PER_IN, 0.11f*BP_PER_IN, 0.08f*BP_PER_IN}, {ms_none} }, hpdj500_sizes[] = { @@ -139,13 +139,13 @@ static const eprn_PageDescription well. Order of margins: left, bottom, right, top. */ {ms_Letter, - 0.25*BP_PER_IN, 0.57*BP_PER_IN, 0.25*BP_PER_IN, 0.1*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.57f*BP_PER_IN, 0.25f*BP_PER_IN, 0.1f*BP_PER_IN}, {ms_Legal, - 0.25*BP_PER_IN, 0.57*BP_PER_IN, 0.25*BP_PER_IN, 0.1*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.57f*BP_PER_IN, 0.25f*BP_PER_IN, 0.1f*BP_PER_IN}, {ms_A4, - 3.1*BP_PER_MM, 0.57*BP_PER_IN, 3.6*BP_PER_MM, 0.1*BP_PER_IN}, + 3.1f*BP_PER_MM, 0.57f*BP_PER_IN, 3.6f*BP_PER_MM, 0.1f*BP_PER_IN}, {ms_Env10 | MS_TRANSVERSE_FLAG, /* Margins from BPD05054 */ - 0.75*BP_PER_IN, 0.57*BP_PER_IN, 0.75*BP_PER_IN, 0.1*BP_PER_IN}, + 0.75f*BP_PER_IN, 0.57f*BP_PER_IN, 0.75f*BP_PER_IN, 0.1f*BP_PER_IN}, {ms_none} }, hpdj500c_sizes[] = { @@ -156,16 +156,16 @@ static const eprn_PageDescription 0.17 inches more at the bottom. Order of margins: left, bottom, right, top. */ {ms_Letter, - 0.25*BP_PER_IN, 0.4*BP_PER_IN, 0.25*BP_PER_IN, 0.1*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.4f*BP_PER_IN, 0.25f*BP_PER_IN, 0.1f*BP_PER_IN}, {ms_Legal, - 0.25*BP_PER_IN, 0.4*BP_PER_IN, 0.25*BP_PER_IN, 0.1*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.4f*BP_PER_IN, 0.25f*BP_PER_IN, 0.1f*BP_PER_IN}, {ms_A4, - 3.1*BP_PER_MM, 0.4*BP_PER_IN, 3.6*BP_PER_MM, 0.1*BP_PER_IN}, + 3.1f*BP_PER_MM, 0.4f*BP_PER_IN, 3.6f*BP_PER_MM, 0.1f*BP_PER_IN}, {ms_Env10 | MS_TRANSVERSE_FLAG, /* Margins from BPD05054, but I've chosen 0.4 in for the bottom margin instead of 0.57 in as listed there because it looks to me like the colour bottom. Compare with the DJ 500. */ - 0.75*BP_PER_IN, 0.4*BP_PER_IN, 0.75*BP_PER_IN, 0.1*BP_PER_IN}, + 0.75f*BP_PER_IN, 0.4f*BP_PER_IN, 0.75f*BP_PER_IN, 0.1f*BP_PER_IN}, {ms_none} }, common_sizes[] = { /* DJs 510, 520, 550C und 560C for printing in black */ @@ -175,19 +175,19 @@ static const eprn_PageDescription For colour, the bottom margin must be increased by 0.13 inches. Order of margins: left, bottom, right, top. */ {ms_Letter, - 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Legal, - 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Executive, - 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.20*BP_PER_IN, 0.04*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.20f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_A4, - 3.1*BP_PER_MM, 0.46*BP_PER_IN, 3.6*BP_PER_MM, 0.04*BP_PER_IN}, + 3.1f*BP_PER_MM, 0.46f*BP_PER_IN, 3.6f*BP_PER_MM, 0.04f*BP_PER_IN}, /* Envelopes are supported according the TRG500, the margins are from BPD05054. */ {ms_Env10, /* given in landscape by HP */ - 0.123*BP_PER_IN, 0.71*BP_PER_IN, 0.125*BP_PER_IN, 0.04*BP_PER_IN}, + 0.123f*BP_PER_IN, 0.71f*BP_PER_IN, 0.125f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_EnvDL, /* given in landscape by HP */ - 3.1*BP_PER_MM, 18.0*BP_PER_MM, 3.6*BP_PER_MM, 1.0*BP_PER_MM}, + 3.1f*BP_PER_MM, 18.0f*BP_PER_MM, 3.6f*BP_PER_MM, 1.0f*BP_PER_MM}, {ms_none} }, hpdj540_sizes[] = { @@ -197,25 +197,25 @@ static const eprn_PageDescription colour, the resulting data agree with those in the DG, pp. 65-66. Order of margins: left, bottom, right, top. */ {ms_Executive, - 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_Letter, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_Legal, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_A4, 3.2*BP_PER_MM, 11.7*BP_PER_MM, 3.2*BP_PER_MM, 0.04*BP_PER_IN}, - {ms_A5, 3.2*BP_PER_MM, 18.0*BP_PER_MM, 3.2*BP_PER_MM, 0.04*BP_PER_IN}, - {ms_JISB5, 4.2*BP_PER_MM, 11.7*BP_PER_MM, 4.2*BP_PER_MM, 0.04*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_Letter, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_Legal, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_A4, 3.2f*BP_PER_MM, 11.7f*BP_PER_MM, 3.2f*BP_PER_MM, 0.04f*BP_PER_IN}, + {ms_A5, 3.2f*BP_PER_MM, 18.0f*BP_PER_MM, 3.2f*BP_PER_MM, 0.04f*BP_PER_IN}, + {ms_JISB5, 4.2f*BP_PER_MM, 11.7f*BP_PER_MM, 4.2f*BP_PER_MM, 0.04f*BP_PER_IN}, {ms_Index4x6in, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Index5x8in, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_A6 | PCL_CARD_FLAG, - 3.2*BP_PER_MM, 18.0*BP_PER_MM, 3.2*BP_PER_MM, 0.04*BP_PER_IN}, - {ms_Env10, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 3.2f*BP_PER_MM, 18.0f*BP_PER_MM, 3.2f*BP_PER_MM, 0.04f*BP_PER_IN}, + {ms_Env10, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, /* given in landscape by HP */ - {ms_EnvDL, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + {ms_EnvDL, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, /* given in landscape by HP */ - {ms_EnvC6, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + {ms_EnvC6, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, /* given in landscape by HP */ - {ms_Postcard, 4.2*BP_PER_MM, 18.0*BP_PER_MM, 4.2*BP_PER_MM, 0.04*BP_PER_IN}, + {ms_Postcard, 4.2f*BP_PER_MM, 18.0f*BP_PER_MM, 4.2f*BP_PER_MM, 0.04f*BP_PER_IN}, {ms_none} }, hpdj660c_sizes[] = { @@ -228,34 +228,34 @@ static const eprn_PageDescription contradiction with DG because BPD02519 gives different values for printing from Windows. */ - {ms_Letter, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_Legal, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, + {ms_Letter, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_Legal, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Executive, - 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_A4, 0.13*BP_PER_IN, 0.46*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_A5, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_JISB5, 0.17*BP_PER_IN, 0.46*BP_PER_IN, 0.17*BP_PER_IN, 0.04*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_A4, 0.13f*BP_PER_IN, 0.46f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_A5, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_JISB5, 0.17f*BP_PER_IN, 0.46f*BP_PER_IN, 0.17f*BP_PER_IN, 0.04f*BP_PER_IN}, /* The bottom margin for JISB5 is given with large differences. BPD02519 specifies it as 0.46 in for black from DOS, 0.59 in DOS/colour (agreeing with +0.13 in for 'bottom_increment') and the same for Windows black or colour. BPD05054 gives 0.84 in without distinguishing between black and colour, and the DG gives 0.59 in. */ - {ms_Env10, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + {ms_Env10, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, /* given in landscape by HP */ - {ms_EnvDL, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + {ms_EnvDL, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, /* given in landscape by HP */ - {ms_EnvC6, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + {ms_EnvC6, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, /* given in landscape by HP */ {ms_Index4x6in, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Index5x8in, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_A6 | PCL_CARD_FLAG, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Postcard, - 0.17*BP_PER_IN, 0.71*BP_PER_IN, 0.17*BP_PER_IN, 0.04*BP_PER_IN}, + 0.17f*BP_PER_IN, 0.71f*BP_PER_IN, 0.17f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_EnvUS_A2, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, /* Supported (BPD02925, BPD05054, DG), margins from BPD05054 agreeing with DG p. 70 */ {ms_none} @@ -276,30 +276,30 @@ static const eprn_PageDescription (0.83 in vs. 0.59 in). The DJ 690C does support banner printing (DJ6/8 p. 9). */ - {ms_Letter, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_A4, 0.13*BP_PER_IN, 0.46*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_Legal, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_Env10, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + {ms_Letter, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_A4, 0.13f*BP_PER_IN, 0.46f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_Legal, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_Env10, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Executive, - 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_EnvDL, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_A5, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_JISB5, 0.17*BP_PER_IN, 0.46*BP_PER_IN, 0.17*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_EnvC6, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_EnvDL, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_A5, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_JISB5, 0.17f*BP_PER_IN, 0.46f*BP_PER_IN, 0.17f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_EnvC6, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Index4x6in, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Index5x8in, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_A6 | PCL_CARD_FLAG, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Postcard, - 0.17*BP_PER_IN, 0.71*BP_PER_IN, 0.17*BP_PER_IN, 0.04*BP_PER_IN}, + 0.17f*BP_PER_IN, 0.71f*BP_PER_IN, 0.17f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_EnvUS_A2, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Letter | MS_BIG_FLAG, /* banner */ - 0.25*BP_PER_IN, 0.0, 0.25*BP_PER_IN, 0.0}, + 0.25f*BP_PER_IN, 0.0f, 0.25f*BP_PER_IN, 0.0f}, {ms_A4 | MS_BIG_FLAG, /* banner */ - 0.13*BP_PER_IN, 0.0, 0.13*BP_PER_IN, 0.0}, + 0.13f*BP_PER_IN, 0.0f, 0.13f*BP_PER_IN, 0.0f}, /* BPD05054 claims left and right margins of 0.25 in. */ {ms_none} }, @@ -311,27 +311,27 @@ static const eprn_PageDescription series 800 DeskJets. */ {ms_Executive, - 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_Letter, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_Legal, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_A5, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_A4, 0.13*BP_PER_IN, 0.46*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_JISB5, 0.17*BP_PER_IN, 0.46*BP_PER_IN, 0.17*BP_PER_IN, 0.04*BP_PER_IN}, + 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_Letter, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_Legal, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_A5, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_A4, 0.13f*BP_PER_IN, 0.46f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_JISB5, 0.17f*BP_PER_IN, 0.46f*BP_PER_IN, 0.17f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Postcard, - 0.17*BP_PER_IN, 0.71*BP_PER_IN, 0.17*BP_PER_IN, 0.04*BP_PER_IN}, + 0.17f*BP_PER_IN, 0.71f*BP_PER_IN, 0.17f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_DoublePostcard, /* not present in 'hpdj660c_sizes[]'; guessed */ - 0.17*BP_PER_IN, 0.71*BP_PER_IN, 0.17*BP_PER_IN, 0.04*BP_PER_IN}, + 0.17f*BP_PER_IN, 0.71f*BP_PER_IN, 0.17f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_A6 | PCL_CARD_FLAG, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Index4x6in, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_Index5x8in, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_Env10, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_EnvDL, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, - {ms_EnvC6, 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_Env10, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_EnvDL, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, + {ms_EnvC6, 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_EnvUS_A2, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_none} }, hpdj850c_sizes[] = { @@ -347,11 +347,11 @@ static const eprn_PageDescription First some shorthand notation for margin types. The order is: left, bottom, right, top. */ -#define type1 6.4*BP_PER_MM, 11.7*BP_PER_MM, 6.4*BP_PER_MM, 1.0*BP_PER_MM -#define type2 3.4*BP_PER_MM, 11.7*BP_PER_MM, 3.4*BP_PER_MM, 1.0*BP_PER_MM -#define type3 3.4*BP_PER_MM, 11.7*BP_PER_MM, 3.4*BP_PER_MM, 11.7*BP_PER_MM -#define type4 3.2*BP_PER_MM, 11.7*BP_PER_MM, 3.2*BP_PER_MM, 1.0*BP_PER_MM -#define type5 3.2*BP_PER_MM, 22.0*BP_PER_MM, 3.2*BP_PER_MM, 1.0*BP_PER_MM +#define type1 6.4f*BP_PER_MM, 11.7f*BP_PER_MM, 6.4f*BP_PER_MM, 1.0f*BP_PER_MM +#define type2 3.4f*BP_PER_MM, 11.7f*BP_PER_MM, 3.4f*BP_PER_MM, 1.0f*BP_PER_MM +#define type3 3.4f*BP_PER_MM, 11.7f*BP_PER_MM, 3.4f*BP_PER_MM, 11.7f*BP_PER_MM +#define type4 3.2f*BP_PER_MM, 11.7f*BP_PER_MM, 3.2f*BP_PER_MM, 1.0f*BP_PER_MM +#define type5 3.2f*BP_PER_MM, 22.0f*BP_PER_MM, 3.2f*BP_PER_MM, 1.0f*BP_PER_MM {ms_Letter, type1}, {ms_Legal, type1}, {ms_Executive, type1}, @@ -388,70 +388,70 @@ static const eprn_PageDescription hpdj1120c_sizes[] = { /* These values are from DJ1120C, pp. 11-12, and from BPD05567. I don't consider them particularly trustworthy. */ - {ms_Executive, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, - 0.12*BP_PER_IN}, - {ms_Letter, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, - 0.12*BP_PER_IN}, - {ms_Legal, 0.25*BP_PER_IN, 0.46*BP_PER_IN, 0.25*BP_PER_IN, - 0.12*BP_PER_IN}, - {ms_Tabloid, 0.20*BP_PER_IN, 0.46*BP_PER_IN, 0.20*BP_PER_IN, - 0.12*BP_PER_IN}, - {ms_Statement, 0.20*BP_PER_IN, 0.46*BP_PER_IN, 0.20*BP_PER_IN, - 0.12*BP_PER_IN}, /* Not in BPD05567. */ - {ms_HPSuperB, 0.20*BP_PER_IN, 0.46*BP_PER_IN, 0.20*BP_PER_IN, - 0.12*BP_PER_IN}, - {ms_A6, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, /* Not in BPD05567. */ - {ms_A5, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_Executive, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, + 0.12f*BP_PER_IN}, + {ms_Letter, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, + 0.12f*BP_PER_IN}, + {ms_Legal, 0.25f*BP_PER_IN, 0.46f*BP_PER_IN, 0.25f*BP_PER_IN, + 0.12f*BP_PER_IN}, + {ms_Tabloid, 0.20f*BP_PER_IN, 0.46f*BP_PER_IN, 0.20f*BP_PER_IN, + 0.12f*BP_PER_IN}, + {ms_Statement, 0.20f*BP_PER_IN, 0.46f*BP_PER_IN, 0.20f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* Not in BPD05567. */ + {ms_HPSuperB, 0.20f*BP_PER_IN, 0.46f*BP_PER_IN, 0.20f*BP_PER_IN, + 0.12f*BP_PER_IN}, + {ms_A6, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* Not in BPD05567. */ + {ms_A5, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_A4, 0.20*BP_PER_IN, 0.46*BP_PER_IN, 0.20*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_A4, 0.20f*BP_PER_IN, 0.46f*BP_PER_IN, 0.20f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.13 in, 0.46 in, 0.13 in, 0.12 in. */ - {ms_A3, 0.20*BP_PER_IN, 0.46*BP_PER_IN, 0.20*BP_PER_IN, - 0.12*BP_PER_IN}, /* Only in BPD05567. */ - {ms_JISB5, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_A3, 0.20f*BP_PER_IN, 0.46f*BP_PER_IN, 0.20f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* Only in BPD05567. */ + {ms_JISB5, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_JISB4, 0.20*BP_PER_IN, 0.46*BP_PER_IN, 0.20*BP_PER_IN, - 0.12*BP_PER_IN}, /* Not in BPD05567. */ - {ms_Postcard, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_JISB4, 0.20f*BP_PER_IN, 0.46f*BP_PER_IN, 0.20f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* Not in BPD05567. */ + {ms_Postcard, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_A6 | PCL_CARD_FLAG, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_A6 | PCL_CARD_FLAG, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_Index4x6in, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_Index4x6in, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_Index5x8in, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_Index5x8in, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_Env10, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_Env10, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_EnvDL, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_EnvDL, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_EnvC6, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_EnvC6, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_EnvUS_A2, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_EnvUS_A2, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_EnvChou3, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_EnvChou3, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_EnvChou4, 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, - 0.12*BP_PER_IN}, + {ms_EnvChou4, 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* BPD05567: 0.12 in, 0.46 in, 0.12 in, 0.12 in. */ - {ms_EnvKaku2, 0.20*BP_PER_IN, 0.46*BP_PER_IN, 0.20*BP_PER_IN, - 0.12*BP_PER_IN}, /* Not in BPD05567. */ + {ms_EnvKaku2, 0.20f*BP_PER_IN, 0.46f*BP_PER_IN, 0.20f*BP_PER_IN, + 0.12f*BP_PER_IN}, /* Not in BPD05567. */ /* Banners are listed only in BPD05567: */ {ms_Letter | MS_BIG_FLAG, - 0.25*BP_PER_IN, 0, 0.25*BP_PER_IN, 0.04*BP_PER_IN}, + 0.25f*BP_PER_IN, 0, 0.25f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_A4 | MS_BIG_FLAG, - 0.13*BP_PER_IN, 0, 0.13*BP_PER_IN, 0.04*BP_PER_IN}, + 0.13f*BP_PER_IN, 0, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN}, {ms_none} }; @@ -480,13 +480,13 @@ static const eprn_CustomPageDescription */ { /* Page width 7.12 to 8.5 in */ ms_CustomPageSize, - 0.13*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, 0.04*BP_PER_IN, - 7.12*BP_PER_IN, 8.5*BP_PER_IN, 5.83*BP_PER_IN, 14*BP_PER_IN + 0.13f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, 0.04f*BP_PER_IN, + 7.12f*BP_PER_IN, 8.5f*BP_PER_IN, 5.83f*BP_PER_IN, 14*BP_PER_IN }, { /* Page width 5 to 7.12 in */ ms_CustomPageSize, - 0.13*BP_PER_IN, 0.71*BP_PER_IN, 0.125*BP_PER_IN, 0.04*BP_PER_IN, - 5*BP_PER_IN, 7.12*BP_PER_IN, 5.83*BP_PER_IN, 14*BP_PER_IN + 0.13f*BP_PER_IN, 0.71f*BP_PER_IN, 0.125f*BP_PER_IN, 0.04f*BP_PER_IN, + 5*BP_PER_IN, 7.12f*BP_PER_IN, 5.83f*BP_PER_IN, 14*BP_PER_IN }, {ms_none, 0, 0, 0, 0, 0, 0, 0, 0} }, @@ -494,8 +494,8 @@ static const eprn_CustomPageDescription /* Ranges from DJ6/8 p. 23, margins from A4 for the DJ 660C (BPD02519) */ { ms_CustomPageSize, - 0.13*BP_PER_IN, 0.46*BP_PER_IN, 0.13*BP_PER_IN, 0.04*BP_PER_IN, - 5*BP_PER_IN, 8.5*BP_PER_IN, 148*BP_PER_MM, 14*BP_PER_IN + 0.13f*BP_PER_IN, 0.46f*BP_PER_IN, 0.13f*BP_PER_IN, 0.04f*BP_PER_IN, + 5*BP_PER_IN, 8.5f*BP_PER_IN, 148*BP_PER_MM, 14*BP_PER_IN }, {ms_none, 0, 0, 0, 0, 0, 0, 0, 0} }, @@ -520,7 +520,7 @@ static const eprn_CustomPageDescription { /* Taken from DJ1120C pp. 10 and 12. The minimum sizes are guessed (smallest supported discrete dimensions) */ ms_CustomPageSize, - 0.125*BP_PER_IN, 0.46*BP_PER_IN, 0.125*BP_PER_IN, 0.12*BP_PER_IN, + 0.125f*BP_PER_IN, 0.46f*BP_PER_IN, 0.125f*BP_PER_IN, 0.12f*BP_PER_IN, 90*BP_PER_MM, 13*BP_PER_IN, 146*BP_PER_MM, 19*BP_PER_IN, }, {ms_none, 0, 0, 0, 0, 0, 0, 0, 0} @@ -533,7 +533,7 @@ static const eprn_CustomPageDescription { ms_CustomPageSize, type2, /* use DJ 850C margins */ - 1.0E-37, 1.0E37, 1.0E-37, 1.0E37 + 1.0E-37f, 1.0E37f, 1.0E-37f, 1.0E37f }, {ms_none, 0, 0, 0, 0, 0, 0, 0, 0} }; @@ -731,36 +731,36 @@ const pcl_PrinterDescription pcl3_printers[] = { { HPDJ500, pcl_level_3plus_DJ500, {"HP DeskJet 500", hpdj500_sizes, NULL, 0.0, ci_old_mono } }, { HPDJ500C, pcl_level_3plus_S5, - { "HP DeskJet 500C", hpdj500c_sizes, NULL, 0.17*BP_PER_IN, ci_hpdj500c } }, + { "HP DeskJet 500C", hpdj500c_sizes, NULL, 0.17f*BP_PER_IN, ci_hpdj500c } }, { HPDJ510, pcl_level_3plus_S5, { "HP DeskJet 510", common_sizes, NULL, 0.0, ci_old_mono } }, { HPDJ520, pcl_level_3plus_S5, { "HP DeskJet 520", common_sizes, NULL, 0.0, ci_old_mono } }, { HPDJ540, pcl_level_3plus_S68, { "HP DeskJet 540", hpdj540_sizes, hpdj540_custom_sizes, - 0.13*BP_PER_IN, ci_hpdj540 } }, + 0.13f*BP_PER_IN, ci_hpdj540 } }, { HPDJ550C, pcl_level_3plus_S5, - { "HP DeskJet 550C", common_sizes, NULL, 0.13*BP_PER_IN, ci_hpdj5xx_cmyk }}, + { "HP DeskJet 550C", common_sizes, NULL, 0.13f*BP_PER_IN, ci_hpdj5xx_cmyk }}, { HPDJ560C, pcl_level_3plus_S5, - { "HP DeskJet 560C", common_sizes, NULL, 0.13*BP_PER_IN, ci_hpdj5xx_cmyk }}, + { "HP DeskJet 560C", common_sizes, NULL, 0.13f*BP_PER_IN, ci_hpdj5xx_cmyk }}, { pcl3_generic_old, pcl_level_3plus_ERG_both, { "unspecified PCL-3+ printer (old)", common_sizes, NULL, 0.0, ci_any } }, { HPDJ600, pcl_level_3plus_S68, { "HP DeskJet 600", hpdj6xx_and_8xx_sizes, hpdj_6xx_and_8xx_custom_sizes, - 0.13*BP_PER_IN, ci_hpdj600 } }, + 0.13f*BP_PER_IN, ci_hpdj600 } }, { HPDJ660C, pcl_level_3plus_S68, { "HP DeskJet 660C", hpdj660c_sizes, hpdj_6xx_and_8xx_custom_sizes, - 0.13*BP_PER_IN, ci_hpdj6xx } }, + 0.13f*BP_PER_IN, ci_hpdj6xx } }, { HPDJ670C, pcl_level_3plus_S68, { "HP DeskJet 670C", hpdj660c_sizes, hpdj_6xx_and_8xx_custom_sizes, - 0.13*BP_PER_IN, ci_hpdj6xx } }, + 0.13f*BP_PER_IN, ci_hpdj6xx } }, /* This printer can be treated as the DJ 660C (DJ6/8 p. 2). */ { HPDJ680C, pcl_level_3plus_S68, { "HP DeskJet 680C", hpdj680c_sizes, hpdj_6xx_and_8xx_custom_sizes, - 0.13*BP_PER_IN, ci_hpdj6xx } }, + 0.13f*BP_PER_IN, ci_hpdj6xx } }, { HPDJ690C, pcl_level_3plus_S68, { "HP DeskJet 690C", hpdj680c_sizes, hpdj_6xx_and_8xx_custom_sizes, - 0.13*BP_PER_IN, ci_hpdj6xx } }, + 0.13f*BP_PER_IN, ci_hpdj6xx } }, { HPDJ850C, pcl_level_3plus_S68, { "HP DeskJet 850C", hpdj850c_sizes, hpdj850c_custom_sizes, 0.0, ci_hpdj85x } }, diff --git a/contrib/pcl3/src/pclgen.c b/contrib/pcl3/src/pclgen.c index 0670d886..e6a9c963 100644 --- a/contrib/pcl3/src/pclgen.c +++ b/contrib/pcl3/src/pclgen.c @@ -150,7 +150,7 @@ static void send_ERG(gp_file *out, pcl_Level level) int pcl3_init_file(gs_memory_t *mem, gp_file *out, pcl_FileData *data) { - pcl_bool needs_CRD = (data->level == pcl_level_3plus_CRD_only); + pcl_bool needs_CRD = (data && data->level == pcl_level_3plus_CRD_only); /* Do we need Configure Raster Data? */ int j; const pcl_ColorantState *colorant = NULL; @@ -469,7 +469,7 @@ int pcl3_init_file(gs_memory_t *mem, gp_file *out, pcl_FileData *data) gp_fprintf(out, "\033*r%dU", /* PCL: Set Number of Planes per Row/Simple Color */ data->palette == pcl_RGB? 3: /* RGB palette */ - -data->number_of_colorants); /* (K)(CMY) palette */ + -(int)data->number_of_colorants); /* (K)(CMY) palette */ /* Configure Raster Data */ if (needs_CRD) { |