diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2014-02-06 18:33:34 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2014-02-06 18:33:34 +0000 |
commit | 7e86f2f686334cb3db458b4585dfce9c1b712bc4 (patch) | |
tree | 88b4a0536faefcada96437e7cddd3a36cfdee0a4 /filter | |
parent | b1564baed9db112cb1334027f1d141877d88fcf4 (diff) | |
download | cups-7e86f2f686334cb3db458b4585dfce9c1b712bc4.tar.gz |
Full sweep of all Clang warnings, plus some bug fixes for incorrect memcpy usage.
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11558 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'filter')
-rw-r--r-- | filter/commandtops.c | 29 | ||||
-rw-r--r-- | filter/common.c | 31 | ||||
-rw-r--r-- | filter/error.c | 40 | ||||
-rw-r--r-- | filter/gziptoany.c | 26 | ||||
-rw-r--r-- | filter/interpret.c | 27 | ||||
-rw-r--r-- | filter/pstops.c | 204 | ||||
-rw-r--r-- | filter/raster.c | 169 | ||||
-rw-r--r-- | filter/rasterbench.c | 33 | ||||
-rw-r--r-- | filter/rastertoepson.c | 123 | ||||
-rw-r--r-- | filter/rastertohp.c | 113 | ||||
-rw-r--r-- | filter/rastertolabel.c | 120 | ||||
-rw-r--r-- | filter/rastertopwg.c | 50 | ||||
-rw-r--r-- | filter/testraster.c | 60 |
13 files changed, 435 insertions, 590 deletions
diff --git a/filter/commandtops.c b/filter/commandtops.c index fd8e35a02..3f7691565 100644 --- a/filter/commandtops.c +++ b/filter/commandtops.c @@ -1,26 +1,15 @@ /* * "$Id$" * - * PostScript command filter for CUPS. + * PostScript command filter for CUPS. * - * Copyright 2008-2012 by Apple Inc. + * Copyright 2008-2014 by Apple Inc. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * - * Contents: - * - * main() - Process a CUPS command file. - * auto_configure() - Automatically configure the printer using - * PostScript query commands and/or SNMP lookups. - * begin_ps() - Send the standard PostScript prolog. - * end_ps() - Send the standard PostScript trailer. - * print_self_test_page() - Print a self-test page. - * report_levels() - Report supply levels. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -309,9 +298,7 @@ auto_configure(ppd_file_t *ppd, /* I - PPD file */ bufptr = buffer; buffer[0] = '\0'; - while ((bytes = cupsBackChannelRead(bufptr, - sizeof(buffer) - (bufptr - buffer) - 1, - 10.0)) > 0) + while ((bytes = cupsBackChannelRead(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer) - 1, 10.0)) > 0) { /* * No newline at the end? Go on reading ... diff --git a/filter/common.c b/filter/common.c index b80f4d5b5..3d45a2037 100644 --- a/filter/common.c +++ b/filter/common.c @@ -1,29 +1,18 @@ /* * "$Id$" * - * Common filter routines for CUPS. + * Common filter routines for CUPS. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * SetCommonOptions() - Set common filter options for media size, - * etc. - * UpdatePageVars() - Update the page variables for the orientation. - * WriteComment() - Write a DSC comment. - * WriteCommon() - Write common procedures... - * WriteLabelProlog() - Write the prolog with the classification - * and page label. - * WriteLabels() - Write the actual page labels. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -481,7 +470,7 @@ WriteTextComment(const char *name, /* I - Comment name ("Title", etc.) */ */ printf("%%%%%s: (", name); - len = 5 + strlen(name); + len = 5 + (int)strlen(name); while (*value) { diff --git a/filter/error.c b/filter/error.c index c1cd0d3b1..26d8511d4 100644 --- a/filter/error.c +++ b/filter/error.c @@ -1,27 +1,18 @@ /* * "$Id$" * - * Raster error handling for CUPS. + * Raster error handling for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * _cupsRasterAddError() - Add an error message to the error buffer. - * _cupsRasterClearError() - Clear the error buffer. - * cupsRasterErrorString() - Return the last error from a raster function. - * get_error_buffer() - Return a pointer to thread local storage. - * raster_init() - Initialize error buffer once. - * raster_destructor() - Free memory allocated by get_error_buffer(). + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -62,7 +53,7 @@ _cupsRasterAddError(const char *f, /* I - Printf-style error message */ /* Error buffer */ va_list ap; /* Pointer to additional arguments */ char s[2048]; /* Message string */ - size_t bytes; /* Bytes in message string */ + ssize_t bytes; /* Bytes in message string */ va_start(ap, f); @@ -74,10 +65,10 @@ _cupsRasterAddError(const char *f, /* I - Printf-style error message */ bytes ++; - if (bytes >= sizeof(s)) + if ((size_t)bytes >= sizeof(s)) return; - if (bytes > (size_t)(buf->end - buf->current)) + if (bytes > (ssize_t)(buf->end - buf->current)) { /* * Allocate more memory... @@ -87,7 +78,7 @@ _cupsRasterAddError(const char *f, /* I - Printf-style error message */ size_t size; /* Size of buffer */ - size = buf->end - buf->start + 2 * bytes + 1024; + size = (size_t)(buf->end - buf->start + 2 * bytes + 1024); if (buf->start) temp = realloc(buf->start, size); @@ -110,7 +101,7 @@ _cupsRasterAddError(const char *f, /* I - Printf-style error message */ * Append the message to the end of the current string... */ - memcpy(buf->current, s, bytes); + memcpy(buf->current, s, (size_t)bytes); buf->current += bytes - 1; } @@ -167,8 +158,7 @@ cupsRasterErrorString(void) * Local globals... */ -static pthread_key_t raster_key = -1; - /* Thread local storage key */ +static pthread_key_t raster_key = 0; /* Thread local storage key */ static pthread_once_t raster_key_once = PTHREAD_ONCE_INIT; /* One-time initialization object */ diff --git a/filter/gziptoany.c b/filter/gziptoany.c index a1b1e2b84..6744c3bfa 100644 --- a/filter/gziptoany.c +++ b/filter/gziptoany.c @@ -1,22 +1,18 @@ /* * "$Id$" * - * GZIP/raw pre-filter for CUPS. + * GZIP/raw pre-filter for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1993-2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1993-2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * main() - Copy (and uncompress) files to stdout. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -36,7 +32,7 @@ main(int argc, /* I - Number of command-line arguments */ { cups_file_t *fp; /* File */ char buffer[8192]; /* Data buffer */ - int bytes; /* Number of bytes read/written */ + ssize_t bytes; /* Number of bytes read/written */ int copies; /* Number of copies */ @@ -84,7 +80,7 @@ main(int argc, /* I - Number of command-line arguments */ cupsFileRewind(fp); while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0) - if (write(1, buffer, bytes) < bytes) + if (write(1, buffer, (size_t)bytes) < bytes) { _cupsLangPrintFilter(stderr, "ERROR", _("Unable to write uncompressed print data: %s"), diff --git a/filter/interpret.c b/filter/interpret.c index 307ad37d4..4b0a43e1a 100644 --- a/filter/interpret.c +++ b/filter/interpret.c @@ -379,9 +379,9 @@ cupsRasterInterpretPPD( * Compute the bitmap parameters... */ - h->cupsWidth = (int)((right - left) * h->cupsBorderlessScalingFactor * + h->cupsWidth = (unsigned)((right - left) * h->cupsBorderlessScalingFactor * h->HWResolution[0] / 72.0f + 0.5f); - h->cupsHeight = (int)((top - bottom) * h->cupsBorderlessScalingFactor * + h->cupsHeight = (unsigned)((top - bottom) * h->cupsBorderlessScalingFactor * h->HWResolution[1] / 72.0f + 0.5f); switch (h->cupsColorSpace) @@ -933,7 +933,7 @@ push_stack(_cups_ps_stack_t *st, /* I - Stack */ st->alloc_objs += 32; - if ((temp = realloc(st->objs, st->alloc_objs * + if ((temp = realloc(st->objs, (size_t)st->alloc_objs * sizeof(_cups_ps_obj_t))) == NULL) return (NULL); @@ -994,12 +994,12 @@ roll_stack(_cups_ps_stack_t *st, /* I - Stack */ s = -s; - if ((temp = calloc(s, sizeof(_cups_ps_obj_t))) == NULL) + if ((temp = calloc((size_t)s, sizeof(_cups_ps_obj_t))) == NULL) return (-1); - memcpy(temp, st->objs + n, s * sizeof(_cups_ps_obj_t)); - memmove(st->objs + n, st->objs + n + s, (c - s) * sizeof(_cups_ps_obj_t)); - memcpy(st->objs + n + c - s, temp, s * sizeof(_cups_ps_obj_t)); + memcpy(temp, st->objs + n, (size_t)s * sizeof(_cups_ps_obj_t)); + memmove(st->objs + n, st->objs + n + s, (size_t)(c - s) * sizeof(_cups_ps_obj_t)); + memcpy(st->objs + n + c - s, temp, (size_t)s * sizeof(_cups_ps_obj_t)); } else { @@ -1007,13 +1007,12 @@ roll_stack(_cups_ps_stack_t *st, /* I - Stack */ * Shift up... */ - if ((temp = calloc(s, sizeof(_cups_ps_obj_t))) == NULL) + if ((temp = calloc((size_t)s, sizeof(_cups_ps_obj_t))) == NULL) return (-1); - memcpy(temp, st->objs + n + c - s, s * sizeof(_cups_ps_obj_t)); - memmove(st->objs + n + s, st->objs + n, - (c - s) * sizeof(_cups_ps_obj_t)); - memcpy(st->objs + n, temp, s * sizeof(_cups_ps_obj_t)); + memcpy(temp, st->objs + n + c - s, (size_t)s * sizeof(_cups_ps_obj_t)); + memmove(st->objs + n + s, st->objs + n, (size_t)(c - s) * sizeof(_cups_ps_obj_t)); + memcpy(st->objs + n, temp, (size_t)s * sizeof(_cups_ps_obj_t)); } free(temp); @@ -1132,7 +1131,7 @@ scan_ps(_cups_ps_stack_t *st, /* I - Stack */ ch = (ch << 3) + *cur - '0'; } - *valptr++ = ch; + *valptr++ = (char)ch; } else if (*cur == '\r') { @@ -1209,7 +1208,7 @@ scan_ps(_cups_ps_stack_t *st, /* I - Stack */ ch |= tolower(*cur) - 'a' + 10; } - *valptr++ = ch; + *valptr++ = (char)ch; } if (*cur != '>') diff --git a/filter/pstops.c b/filter/pstops.c index 2230a8b61..bbaf758fb 100644 --- a/filter/pstops.c +++ b/filter/pstops.c @@ -1,51 +1,18 @@ /* * "$Id$" * - * PostScript filter for CUPS. + * PostScript filter for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1993-2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1993-2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * main() - Main entry. - * add_page() - Add a page to the pages array. - * cancel_job() - Flag the job as canceled. - * check_range() - Check to see if the current page is selected for - * printing. - * copy_bytes() - Copy bytes from the input file to stdout. - * copy_comments() - Copy all of the comments section. - * copy_dsc() - Copy a DSC-conforming document. - * copy_non_dsc() - Copy a document that does not conform to the DSC. - * copy_page() - Copy a page description. - * copy_prolog() - Copy the document prolog section. - * copy_setup() - Copy the document setup section. - * copy_trailer() - Copy the document trailer. - * do_prolog() - Send the necessary document prolog commands. - * do_setup() - Send the necessary document setup commands. - * doc_printf() - Send a formatted string to stdout and/or the temp - * file. - * doc_puts() - Send a nul-terminated string to stdout and/or the - * temp file. - * doc_write() - Send data to stdout and/or the temp file. - * end_nup() - End processing for N-up printing. - * include_feature() - Include a printer option/feature command. - * parse_text() - Parse a text value in a comment. - * set_pstops_options() - Set pstops options. - * skip_page() - Skip past a page that won't be printed. - * start_nup() - Start processing for N-up printing. - * write_label_prolog() - Write the prolog with the classification and page - * label. - * write_labels() - Write the actual page labels. - * write_options() - Write options provided via %%IncludeFeature. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -236,7 +203,7 @@ main(int argc, /* I - Number of command-line args */ int num_options; /* Number of print options */ cups_option_t *options; /* Print options */ char line[8192]; /* Line buffer */ - size_t len; /* Length of line buffer */ + ssize_t len; /* Length of line buffer */ #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* Actions for POSIX signals */ #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ @@ -306,7 +273,7 @@ main(int argc, /* I - Number of command-line args */ * Read the first line to see if we have DSC comments... */ - if ((len = cupsFileGetLine(fp, line, sizeof(line))) == 0) + if ((len = (ssize_t)cupsFileGetLine(fp, line, sizeof(line))) == 0) { fputs("DEBUG: The print file is empty.\n", stderr); return (1); @@ -355,13 +322,13 @@ main(int argc, /* I - Number of command-line args */ fputs("DEBUG: Skipping PJL header...\n", stderr); while (strstr(line, "ENTER LANGUAGE") == NULL && strncmp(line, "%!", 2)) - if ((len = cupsFileGetLine(fp, line, sizeof(line))) == 0) + if ((len = (ssize_t)cupsFileGetLine(fp, line, sizeof(line))) == 0) break; if (!strncmp(line, "%!", 2)) break; - if ((len = cupsFileGetLine(fp, line, sizeof(line))) == 0) + if ((len = (ssize_t)cupsFileGetLine(fp, line, sizeof(line))) == 0) break; } @@ -511,11 +478,11 @@ check_range(pstops_doc_t *doc, /* I - Document information */ { lower = 1; range ++; - upper = strtol(range, (char **)&range, 10); + upper = (int)strtol(range, (char **)&range, 10); } else { - lower = strtol(range, (char **)&range, 10); + lower = (int)strtol(range, (char **)&range, 10); if (*range == '-') { @@ -523,7 +490,7 @@ check_range(pstops_doc_t *doc, /* I - Document information */ if (!isdigit(*range & 255)) upper = 65535; else - upper = strtol(range, (char **)&range, 10); + upper = (int)strtol(range, (char **)&range, 10); } else upper = lower; @@ -569,14 +536,14 @@ copy_bytes(cups_file_t *fp, /* I - File to read from */ if (nleft > sizeof(buffer) || length == 0) nbytes = sizeof(buffer); else - nbytes = nleft; + nbytes = (ssize_t)nleft; - if ((nbytes = cupsFileRead(fp, buffer, nbytes)) < 1) + if ((nbytes = cupsFileRead(fp, buffer, (size_t)nbytes)) < 1) return; - nleft -= nbytes; + nleft -= (size_t)nbytes; - fwrite(buffer, 1, nbytes, stdout); + fwrite(buffer, 1, (size_t)nbytes, stdout); } } @@ -741,13 +708,13 @@ copy_comments(cups_file_t *fp, /* I - File to read from */ } else if (!strcmp(line, "%%EndComments")) { - linelen = cupsFileGetLine(fp, line, linesize); + linelen = (ssize_t)cupsFileGetLine(fp, line, linesize); break; } else if (strncmp(line, "%!", 2) && strncmp(line, "%cups", 5)) doc_printf(doc, "%s\n", line); - if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0) + if ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) == 0) break; } @@ -860,9 +827,9 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */ while (strncmp(line, "%%Page:", 7) && strncmp(line, "%%Trailer", 9)) { - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); - if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0) + if ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) == 0) break; } @@ -905,7 +872,7 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */ doc_puts(doc, "showpage\n"); end_nup(doc, doc->number_up); - pageinfo->length = cupsFileTell(doc->temp) - pageinfo->offset; + pageinfo->length = (ssize_t)(cupsFileTell(doc->temp) - pageinfo->offset); } if (doc->slow_duplex && (doc->page & 1)) @@ -929,7 +896,7 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */ doc_puts(doc, "showpage\n"); end_nup(doc, doc->number_up); - pageinfo->length = cupsFileTell(doc->temp) - pageinfo->offset; + pageinfo->length = (ssize_t)(cupsFileTell(doc->temp) - pageinfo->offset); } /* @@ -1006,7 +973,7 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */ if (!number) { pageinfo = (pstops_page_t *)cupsArrayFirst(doc->pages); - copy_bytes(doc->temp, 0, pageinfo->offset); + copy_bytes(doc->temp, 0, (size_t)pageinfo->offset); } /* @@ -1041,7 +1008,7 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */ pageinfo->bounding_box[2], pageinfo->bounding_box[3]); } - copy_bytes(doc->temp, pageinfo->offset, pageinfo->length); + copy_bytes(doc->temp, pageinfo->offset, (size_t)pageinfo->length); pageinfo = doc->slow_order ? (pstops_page_t *)cupsArrayPrev(doc->pages) : (pstops_page_t *)cupsArrayNext(doc->pages); @@ -1079,11 +1046,13 @@ copy_non_dsc(cups_file_t *fp, /* I - File to read from */ ssize_t linelen, /* I - Length of initial line */ size_t linesize) /* I - Size of line buffer */ { - int copy; /* Current copy */ - char buffer[8192]; /* Copy buffer */ - int bytes; /* Number of bytes copied */ + int copy; /* Current copy */ + char buffer[8192]; /* Copy buffer */ + ssize_t bytes; /* Number of bytes copied */ + (void)linesize; + /* * First let the user know that they are attempting to print a file * that may not print correctly... @@ -1175,17 +1144,17 @@ copy_non_dsc(cups_file_t *fp, /* I - File to read from */ puts("%%EndPageSetup"); puts("%%BeginDocument: nondsc"); - fwrite(line, linelen, 1, stdout); + fwrite(line, (size_t)linelen, 1, stdout); if (doc->temp) - cupsFileWrite(doc->temp, line, linelen); + cupsFileWrite(doc->temp, line, (size_t)linelen); while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0) { - fwrite(buffer, 1, bytes, stdout); + fwrite(buffer, 1, (size_t)bytes, stdout); if (doc->temp) - cupsFileWrite(doc->temp, buffer, bytes); + cupsFileWrite(doc->temp, buffer, (size_t)bytes); } puts("%%EndDocument"); @@ -1367,7 +1336,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */ memcpy(bounding_box, doc->bounding_box, sizeof(bounding_box)); - while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0) + while ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) > 0) { if (!strncmp(line, "%%PageBoundingBox:", 18)) { @@ -1400,24 +1369,24 @@ copy_page(cups_file_t *fp, /* I - File to read from */ switch (Orientation) { case 1 : /* Landscape */ - bounding_box[0] = PageLength - temp_bbox[3]; + bounding_box[0] = (int)(PageLength - temp_bbox[3]); bounding_box[1] = temp_bbox[0]; - bounding_box[2] = PageLength - temp_bbox[1]; + bounding_box[2] = (int)(PageLength - temp_bbox[1]); bounding_box[3] = temp_bbox[2]; break; case 2 : /* Reverse Portrait */ - bounding_box[0] = PageWidth - temp_bbox[2]; - bounding_box[1] = PageLength - temp_bbox[3]; - bounding_box[2] = PageWidth - temp_bbox[0]; - bounding_box[3] = PageLength - temp_bbox[1]; + bounding_box[0] = (int)(PageWidth - temp_bbox[2]); + bounding_box[1] = (int)(PageLength - temp_bbox[3]); + bounding_box[2] = (int)(PageWidth - temp_bbox[0]); + bounding_box[3] = (int)(PageLength - temp_bbox[1]); break; case 3 : /* Reverse Landscape */ bounding_box[0] = temp_bbox[1]; - bounding_box[1] = PageWidth - temp_bbox[2]; + bounding_box[1] = (int)(PageWidth - temp_bbox[2]); bounding_box[2] = temp_bbox[3]; - bounding_box[3] = PageWidth - temp_bbox[0]; + bounding_box[3] = (int)(PageWidth - temp_bbox[0]); break; } @@ -1550,7 +1519,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */ { int feature = 0; /* In a Begin/EndFeature block? */ - while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0) + while ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) > 0) { if (!strncmp(line, "%%EndPageSetup", 14)) break; @@ -1582,7 +1551,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */ break; if (!feature || (doc->number_up == 1 && !doc->fit_to_page)) - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); } /* @@ -1590,7 +1559,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */ */ if (linelen > 0 && !strncmp(line, "%%EndPageSetup", 14)) - linelen = cupsFileGetLine(fp, line, linesize); + linelen = (ssize_t)cupsFileGetLine(fp, line, linesize); } if (first_page) @@ -1639,14 +1608,14 @@ copy_page(cups_file_t *fp, /* I - File to read from */ else if (!strncmp(line, "%%BeginDocument", 15) || !strncmp(line, "%ADO_BeginApplication", 21)) { - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); level ++; } else if ((!strncmp(line, "%%EndDocument", 13) || !strncmp(line, "%ADO_EndApplication", 19)) && level > 0) { - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); level --; } @@ -1661,16 +1630,16 @@ copy_page(cups_file_t *fp, /* I - File to read from */ int bytes; /* Bytes of data */ - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); bytes = atoi(strchr(line, ':') + 1); while (bytes > 0) { - if (bytes > linesize) + if ((size_t)bytes > linesize) linelen = cupsFileRead(fp, line, linesize); else - linelen = cupsFileRead(fp, line, bytes); + linelen = cupsFileRead(fp, line, (size_t)bytes); if (linelen < 1) { @@ -1679,15 +1648,15 @@ copy_page(cups_file_t *fp, /* I - File to read from */ return (0); } - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); bytes -= linelen; } } else - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); } - while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0); + while ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) > 0); /* * Finish up this page and return... @@ -1695,7 +1664,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */ end_nup(doc, number); - pageinfo->length = cupsFileTell(doc->temp) - pageinfo->offset; + pageinfo->length = (ssize_t)(cupsFileTell(doc->temp) - pageinfo->offset); return (linelen); } @@ -1721,9 +1690,9 @@ copy_prolog(cups_file_t *fp, /* I - File to read from */ if (!strncmp(line, "%%BeginSetup", 12) || !strncmp(line, "%%Page:", 7)) break; - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); - if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0) + if ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) == 0) break; } @@ -1733,18 +1702,18 @@ copy_prolog(cups_file_t *fp, /* I - File to read from */ if (!strncmp(line, "%%BeginProlog", 13)) { - while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0) + while ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) > 0) { if (!strncmp(line, "%%EndProlog", 11) || !strncmp(line, "%%BeginSetup", 12) || !strncmp(line, "%%Page:", 7)) break; - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); } if (!strncmp(line, "%%EndProlog", 11)) - linelen = cupsFileGetLine(fp, line, linesize); + linelen = (ssize_t)cupsFileGetLine(fp, line, linesize); else fputs("DEBUG: The %%EndProlog comment is missing.\n", stderr); } @@ -1779,9 +1748,9 @@ copy_setup(cups_file_t *fp, /* I - File to read from */ if (!strncmp(line, "%%Page:", 7)) break; - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); - if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0) + if ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) == 0) break; } @@ -1808,14 +1777,14 @@ copy_setup(cups_file_t *fp, /* I - File to read from */ num_options = include_feature(ppd, line, num_options, &options); } else if (strncmp(line, "%%BeginSetup", 12)) - doc_write(doc, line, linelen); + doc_write(doc, line, (size_t)linelen); - if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0) + if ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) == 0) break; } if (!strncmp(line, "%%EndSetup", 10)) - linelen = cupsFileGetLine(fp, line, linesize); + linelen = (ssize_t)cupsFileGetLine(fp, line, linesize); else fputs("DEBUG: The %%EndSetup comment is missing.\n", stderr); } @@ -1852,6 +1821,8 @@ copy_trailer(cups_file_t *fp, /* I - File to read from */ * Write the trailer comments... */ + (void)ppd; + puts("%%Trailer"); while (linelen > 0) @@ -1861,9 +1832,9 @@ copy_trailer(cups_file_t *fp, /* I - File to read from */ else if (strncmp(line, "%%Trailer", 9) && strncmp(line, "%%Pages:", 8) && strncmp(line, "%%BoundingBox:", 14)) - fwrite(line, 1, linelen, stdout); + fwrite(line, 1, (size_t)linelen, stdout); - linelen = cupsFileGetLine(fp, line, linesize); + linelen = (ssize_t)cupsFileGetLine(fp, line, linesize); } fprintf(stderr, "DEBUG: Wrote %d pages...\n", number); @@ -2045,21 +2016,21 @@ doc_printf(pstops_doc_t *doc, /* I - Document information */ { va_list ap; /* Pointer to arguments */ char buffer[1024]; /* Output buffer */ - size_t bytes; /* Number of bytes to write */ + ssize_t bytes; /* Number of bytes to write */ va_start(ap, format); bytes = vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); - if (bytes > sizeof(buffer)) + if ((size_t)bytes > sizeof(buffer)) { _cupsLangPrintFilter(stderr, "ERROR", _("Buffer overflow detected, aborting.")); exit(1); } - doc_write(doc, buffer, bytes); + doc_write(doc, buffer, (size_t)bytes); } @@ -2705,7 +2676,7 @@ skip_page(cups_file_t *fp, /* I - File to read from */ level = 0; - while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0) + while ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) > 0) { if (level == 0 && (!strncmp(line, "%%Page:", 7) || !strncmp(line, "%%Trailer", 9))) @@ -2724,17 +2695,16 @@ skip_page(cups_file_t *fp, /* I - File to read from */ * Skip binary data... */ - int bytes; /* Bytes of data */ - + ssize_t bytes; /* Bytes of data */ bytes = atoi(strchr(line, ':') + 1); while (bytes > 0) { - if (bytes > linesize) - linelen = cupsFileRead(fp, line, linesize); + if ((size_t)bytes > linesize) + linelen = (ssize_t)cupsFileRead(fp, line, linesize); else - linelen = cupsFileRead(fp, line, bytes); + linelen = (ssize_t)cupsFileRead(fp, line, (size_t)bytes); if (linelen < 1) { @@ -2764,15 +2734,15 @@ start_nup(pstops_doc_t *doc, /* I - Document information */ { int pos; /* Position on page */ int x, y; /* Relative position of subpage */ - float w, l, /* Width and length of subpage */ + double w, l, /* Width and length of subpage */ tx, ty; /* Translation values for subpage */ - float pagew, /* Printable width of page */ + double pagew, /* Printable width of page */ pagel; /* Printable height of page */ int bboxx, /* BoundingBox X origin */ bboxy, /* BoundingBox Y origin */ bboxw, /* BoundingBox width */ bboxl; /* BoundingBox height */ - float margin = 0; /* Current margin for border */ + double margin = 0; /* Current margin for border */ if (doc->number_up > 1) @@ -2793,8 +2763,8 @@ start_nup(pstops_doc_t *doc, /* I - Document information */ { bboxx = 0; bboxy = 0; - bboxw = PageWidth; - bboxl = PageLength; + bboxw = (int)PageWidth; + bboxl = (int)PageLength; } fprintf(stderr, "DEBUG: pagew = %.1f, pagel = %.1f\n", pagew, pagel); @@ -3125,7 +3095,7 @@ start_nup(pstops_doc_t *doc, /* I - Document information */ if (doc->page_border && show_border) { int rects; /* Number of border rectangles */ - float fscale; /* Scaling value for points */ + double fscale; /* Scaling value for points */ rects = (doc->page_border & PSTOPS_BORDERDOUBLE) ? 2 : 1; @@ -3365,7 +3335,7 @@ write_options( { int i; /* Looping var */ ppd_option_t *option; /* PPD option */ - int min_order; /* Minimum OrderDependency value */ + float min_order; /* Minimum OrderDependency value */ char *doc_setup, /* DocumentSetup commands to send */ *any_setup; /* AnySetup commands to send */ diff --git a/filter/raster.c b/filter/raster.c index 801129e60..d9658d710 100644 --- a/filter/raster.c +++ b/filter/raster.c @@ -1,44 +1,20 @@ /* * "$Id$" * - * Raster file routines for CUPS. + * Raster file routines for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * This file is part of the CUPS Imaging library. + * This file is part of the CUPS Imaging library. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * cupsRasterClose() - Close a raster stream. - * cupsRasterOpen() - Open a raster stream using a file descriptor. - * cupsRasterOpenIO() - Open a raster stream using a callback function. - * cupsRasterReadHeader() - Read a raster page header and store it in a - * version 1 page header structure. - * cupsRasterReadHeader2() - Read a raster page header and store it in a - * version 2 page header structure. - * cupsRasterReadPixels() - Read raster pixels. - * cupsRasterWriteHeader() - Write a raster page header from a version 1 - * page header structure. - * cupsRasterWriteHeader2() - Write a raster page header from a version 2 - * page header structure. - * cupsRasterWritePixels() - Write raster pixels. - * cups_raster_read_header() - Read a raster page header. - * cups_raster_read() - Read through the raster buffer. - * cups_raster_update() - Update the raster header and row count for the - * current page. - * cups_raster_write() - Write a row of compressed raster data... - * cups_read_fd() - Read bytes from a file. - * cups_swap() - Swap bytes in raster data... - * cups_write_fd() - Write bytes to a file. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -62,7 +38,7 @@ struct _cups_raster_s /**** Raster stream data ****/ cups_raster_iocb_t iocb; /* IO callback */ cups_mode_t mode; /* Read/write mode */ cups_page_header2_t header; /* Raster header for current page */ - int count, /* Current row run-length count */ + unsigned count, /* Current row run-length count */ remaining, /* Remaining rows in page image */ bpp; /* Bytes per pixel/color */ unsigned char *pixels, /* Pixels for current row */ @@ -81,15 +57,15 @@ struct _cups_raster_s /**** Raster stream data ****/ * Local functions... */ -static int cups_raster_io(cups_raster_t *r, unsigned char *buf, int bytes); +static ssize_t cups_raster_io(cups_raster_t *r, unsigned char *buf, size_t bytes); static unsigned cups_raster_read_header(cups_raster_t *r); -static int cups_raster_read(cups_raster_t *r, unsigned char *buf, - int bytes); +static ssize_t cups_raster_read(cups_raster_t *r, unsigned char *buf, + size_t bytes); static void cups_raster_update(cups_raster_t *r); -static int cups_raster_write(cups_raster_t *r, +static ssize_t cups_raster_write(cups_raster_t *r, const unsigned char *pixels); static ssize_t cups_read_fd(void *ctx, unsigned char *buf, size_t bytes); -static void cups_swap(unsigned char *buf, int bytes); +static void cups_swap(unsigned char *buf, size_t bytes); static ssize_t cups_write_fd(void *ctx, unsigned char *buf, size_t bytes); @@ -244,8 +220,7 @@ cupsRasterOpenIO( break; } - if (cups_raster_io(r, (unsigned char *)&(r->sync), sizeof(r->sync)) - < sizeof(r->sync)) + if (cups_raster_io(r, (unsigned char *)&(r->sync), sizeof(r->sync)) < (ssize_t)sizeof(r->sync)) { _cupsRasterAddError("Unable to write raster stream header: %s\n", strerror(errno)); @@ -335,13 +310,13 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */ unsigned char *p, /* I - Pointer to pixel buffer */ unsigned len) /* I - Number of bytes to read */ { - int bytes; /* Bytes read */ + ssize_t bytes; /* Bytes read */ unsigned cupsBytesPerLine; /* cupsBytesPerLine value */ unsigned remaining; /* Bytes remaining */ unsigned char *ptr, /* Pointer to read buffer */ byte, /* Byte from file */ *temp; /* Pointer into buffer */ - int count; /* Repetition count */ + unsigned count; /* Repetition count */ if (r == NULL || r->mode != CUPS_RASTER_READ || r->remaining == 0 || @@ -409,7 +384,7 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */ ptr = r->pixels; temp = ptr; - bytes = cupsBytesPerLine; + bytes = (ssize_t)cupsBytesPerLine; while (bytes > 0) { @@ -426,10 +401,10 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */ * Copy N literal pixels... */ - count = (257 - byte) * r->bpp; + count = (unsigned)(257 - byte) * r->bpp; - if (count > bytes) - count = bytes; + if (count > (unsigned)bytes) + count = (unsigned)bytes; if (!cups_raster_read(r, temp, count)) return (0); @@ -444,8 +419,8 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */ */ count = (byte + 1) * r->bpp; - if (count > bytes) - count = bytes; + if (count > (unsigned)bytes) + count = (unsigned)bytes; if (count < r->bpp) break; @@ -475,7 +450,7 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */ r->header.cupsBitsPerPixel == 12 || r->header.cupsBitsPerPixel == 16) && r->swapped) - cups_swap(ptr, bytes); + cups_swap(ptr, (size_t)bytes); /* * Update pointers... @@ -483,14 +458,14 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */ if (remaining >= cupsBytesPerLine) { - bytes = cupsBytesPerLine; + bytes = (ssize_t)cupsBytesPerLine; r->pcurrent = r->pixels; r->count --; r->remaining --; } else { - bytes = remaining; + bytes = (ssize_t)remaining; r->pcurrent = r->pixels + bytes; } @@ -508,7 +483,7 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */ */ if ((unsigned)(bytes = (int)(r->pend - r->pcurrent)) > remaining) - bytes = remaining; + bytes = (ssize_t)remaining; memcpy(p, r->pcurrent, bytes); r->pcurrent += bytes; @@ -521,7 +496,7 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */ } } - remaining -= bytes; + remaining -= (unsigned)bytes; p += bytes; } @@ -755,7 +730,7 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */ unsigned char *p, /* I - Bytes to write */ unsigned len)/* I - Number of bytes to write */ { - int bytes; /* Bytes read */ + ssize_t bytes; /* Bytes read */ unsigned remaining; /* Bytes remaining */ @@ -817,24 +792,24 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */ * Write the byte-swapped buffer... */ - return (cups_raster_io(r, r->buffer, len)); + return ((unsigned)cups_raster_io(r, r->buffer, len)); } else - return (cups_raster_io(r, p, len)); + return ((unsigned)cups_raster_io(r, p, len)); } /* * Otherwise, compress each line... */ - for (remaining = len; remaining > 0; remaining -= bytes, p += bytes) + for (remaining = len; remaining > 0; remaining -= (unsigned)bytes, p += bytes) { /* * Figure out the number of remaining bytes on the current line... */ - if ((bytes = remaining) > (int)(r->pend - r->pcurrent)) - bytes = (int)(r->pend - r->pcurrent); + if ((bytes = (ssize_t)remaining) > (ssize_t)(r->pend - r->pcurrent)) + bytes = (ssize_t)(r->pend - r->pcurrent); if (r->count > 0) { @@ -842,7 +817,7 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */ * Check to see if this line is the same as the previous line... */ - if (memcmp(p, r->pcurrent, bytes)) + if (memcmp(p, r->pcurrent, (size_t)bytes)) { if (!cups_raster_write(r, r->pixels)) return (0); @@ -873,7 +848,7 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */ r->remaining --; if (r->remaining == 0) - return (cups_raster_write(r, r->pixels)); + return ((unsigned)cups_raster_write(r, r->pixels)); else if (r->count == 256) { if (cups_raster_write(r, r->pixels) == 0) @@ -913,7 +888,7 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */ r->remaining --; if (r->remaining == 0) - return (cups_raster_write(r, r->pixels)); + return ((unsigned)cups_raster_write(r, r->pixels)); } } } @@ -930,7 +905,7 @@ static unsigned /* O - 1 on success, 0 on fail */ cups_raster_read_header( cups_raster_t *r) /* I - Raster stream */ { - int len; /* Length for read/swap */ + size_t len; /* Length for read/swap */ if (r == NULL || r->mode != CUPS_RASTER_READ) @@ -951,7 +926,7 @@ cups_raster_read_header( memset(&(r->header), 0, sizeof(r->header)); - if (cups_raster_read(r, (unsigned char *)&(r->header), len) < len) + if (cups_raster_read(r, (unsigned char *)&(r->header), len) < (ssize_t)len) return (0); /* @@ -996,20 +971,20 @@ cups_raster_read_header( * 'cups_raster_io()' - Read/write bytes from a context, handling interruptions. */ -static int /* O - Bytes read or -1 */ +static ssize_t /* O - Bytes read/write or -1 */ cups_raster_io(cups_raster_t *r, /* I - Raster stream */ - unsigned char *buf, /* I - Buffer for read/write */ - int bytes) /* I - Number of bytes to read/write */ + unsigned char *buf, /* I - Buffer for read/write */ + size_t bytes) /* I - Number of bytes to read/write */ { - ssize_t count; /* Number of bytes read/written */ - size_t total; /* Total bytes read/written */ + ssize_t count, /* Number of bytes read/written */ + total; /* Total bytes read/written */ - DEBUG_printf(("4cups_raster_io(r=%p, buf=%p, bytes=%d)", r, buf, bytes)); + DEBUG_printf(("4cups_raster_io(r=%p, buf=%p, bytes=" CUPS_LLFMT ")", r, buf, CUPS_LLCAST bytes)); - for (total = 0; total < (size_t)bytes; total += count, buf += count) + for (total = 0; total < (ssize_t)bytes; total += count, buf += count) { - count = (*r->iocb)(r->ctx, buf, bytes - total); + count = (*r->iocb)(r->ctx, buf, bytes - (size_t)total); DEBUG_printf(("5cups_raster_io: count=%d, total=%d", (int)count, (int)total)); @@ -1019,7 +994,7 @@ cups_raster_io(cups_raster_t *r, /* I - Raster stream */ return (-1); } - return ((int)total); + return (total); } @@ -1027,17 +1002,17 @@ cups_raster_io(cups_raster_t *r, /* I - Raster stream */ * 'cups_raster_read()' - Read through the raster buffer. */ -static int /* O - Number of bytes read */ +static ssize_t /* O - Number of bytes read */ cups_raster_read(cups_raster_t *r, /* I - Raster stream */ unsigned char *buf, /* I - Buffer */ - int bytes) /* I - Number of bytes to read */ + size_t bytes) /* I - Number of bytes to read */ { - int count, /* Number of bytes read */ + ssize_t count, /* Number of bytes read */ remaining, /* Remaining bytes in buffer */ total; /* Total bytes read */ - DEBUG_printf(("cups_raster_read(r=%p, buf=%p, bytes=%d)\n", r, buf, bytes)); + DEBUG_printf(("cups_raster_read(r=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", r, buf, CUPS_LLCAST bytes)); if (!r->compressed) return (cups_raster_io(r, buf, bytes)); @@ -1046,20 +1021,19 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */ * Allocate a read buffer as needed... */ - count = 2 * r->header.cupsBytesPerLine; + count = (ssize_t)(2 * r->header.cupsBytesPerLine); if ((size_t)count > r->bufsize) { - int offset = (int)(r->bufptr - r->buffer); + ssize_t offset = r->bufptr - r->buffer; /* Offset to current start of buffer */ - int end = (int)(r->bufend - r->buffer); - /* Offset to current end of buffer */ + ssize_t end = r->bufend - r->buffer;/* Offset to current end of buffer */ unsigned char *rptr; /* Pointer in read buffer */ if (r->buffer) - rptr = realloc(r->buffer, count); + rptr = realloc(r->buffer, (size_t)count); else - rptr = malloc(count); + rptr = malloc((size_t)count); if (!rptr) return (0); @@ -1067,7 +1041,7 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */ r->buffer = rptr; r->bufptr = rptr + offset; r->bufend = rptr + end; - r->bufsize = count; + r->bufsize = (size_t)count; } /* @@ -1075,13 +1049,12 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */ */ for (total = 0, remaining = (int)(r->bufend - r->bufptr); - total < bytes; + total < (ssize_t)bytes; total += count, buf += count) { - count = bytes - total; + count = (ssize_t)bytes - total; - DEBUG_printf(("count=%d, remaining=%d, buf=%p, bufptr=%p, bufend=%p...\n", - count, remaining, buf, r->bufptr, r->bufend)); + DEBUG_printf(("count=" CUPS_LLFMT ", remaining=" CUPS_LLFMT ", buf=%p, bufptr=%p, bufend=%p...\n", CUPS_LLCAST count, CUPS_LLCAST remaining, buf, r->bufptr, r->bufend)); if (remaining == 0) { @@ -1104,7 +1077,7 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */ * Read directly into "buf"... */ - count = (*r->iocb)(r->ctx, buf, count); + count = (*r->iocb)(r->ctx, buf, (size_t)count); if (count <= 0) return (0); @@ -1290,7 +1263,7 @@ cups_raster_update(cups_raster_t *r) /* I - Raster stream */ * 'cups_raster_write()' - Write a row of compressed raster data... */ -static int /* O - Number of bytes written */ +static ssize_t /* O - Number of bytes written */ cups_raster_write( cups_raster_t *r, /* I - Raster stream */ const unsigned char *pixels) /* I - Pixel data to write */ @@ -1300,7 +1273,7 @@ cups_raster_write( *pend, /* End of raster buffer */ *plast; /* Pointer to last pixel */ unsigned char *wptr; /* Pointer into write buffer */ - int bpp, /* Bytes per pixel */ + unsigned bpp, /* Bytes per pixel */ count; /* Count */ @@ -1333,7 +1306,7 @@ cups_raster_write( pend = pixels + r->header.cupsBytesPerLine; plast = pend - bpp; wptr = r->buffer; - *wptr++ = r->count - 1; + *wptr++ = (unsigned char)(r->count - 1); /* * Write using a modified PackBits compression... @@ -1364,7 +1337,7 @@ cups_raster_write( if (memcmp(ptr, ptr + bpp, bpp)) break; - *wptr++ = count - 1; + *wptr++ = (unsigned char)(count - 1); for (count = bpp; count > 0; count --) *wptr++ = *ptr++; } @@ -1384,7 +1357,7 @@ cups_raster_write( ptr += bpp; } - *wptr++ = 257 - count; + *wptr++ = (unsigned char)(257 - count); count *= bpp; memcpy(wptr, start, count); @@ -1392,7 +1365,7 @@ cups_raster_write( } } - return (cups_raster_io(r, r->buffer, (int)(wptr - r->buffer))); + return (cups_raster_io(r, r->buffer, (size_t)(wptr - r->buffer))); } @@ -1428,7 +1401,7 @@ cups_read_fd(void *ctx, /* I - File descriptor as pointer */ static void cups_swap(unsigned char *buf, /* I - Buffer to swap */ - int bytes) /* I - Number of bytes to swap */ + size_t bytes) /* I - Number of bytes to swap */ { unsigned char even, odd; /* Temporary variables */ diff --git a/filter/rasterbench.c b/filter/rasterbench.c index 69e139d37..572a928a8 100644 --- a/filter/rasterbench.c +++ b/filter/rasterbench.c @@ -1,25 +1,18 @@ /* * "$Id$" * - * Raster benchmark program for CUPS. + * Raster benchmark program for CUPS. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * main() - Benchmark the raster read/write functions. - * compute_median() - Compute the median time for a test. - * read_test() - Benchmark the raster read functions. - * write_test() - Benchmark the raster write functions. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -181,7 +174,7 @@ get_time(void) static void read_test(int fd) /* I - File descriptor to read from */ { - int y; /* Looping var */ + unsigned y; /* Looping var */ cups_raster_t *r; /* Raster stream */ cups_page_header2_t header; /* Page header */ unsigned char buffer[8 * TEST_WIDTH]; @@ -263,8 +256,8 @@ static void write_test(int fd, /* I - File descriptor to write to */ cups_mode_t mode) /* I - Write mode */ { - int page, x, y; /* Looping vars */ - int count; /* Number of bytes to set */ + unsigned page, x, y; /* Looping vars */ + unsigned count; /* Number of bytes to set */ cups_raster_t *r; /* Raster stream */ cups_page_header2_t header; /* Page header */ unsigned char data[32][8 * TEST_WIDTH]; @@ -295,7 +288,7 @@ write_test(int fd, /* I - File descriptor to write to */ break; } - data[y][x] = CUPS_RAND(); + data[y][x] = (unsigned char)CUPS_RAND(); } } diff --git a/filter/rastertoepson.c b/filter/rastertoepson.c index 8257fec5b..3996dd808 100644 --- a/filter/rastertoepson.c +++ b/filter/rastertoepson.c @@ -1,28 +1,18 @@ /* * "$Id$" * - * EPSON ESC/P and ESC/P2 filter for CUPS. + * EPSON ESC/P and ESC/P2 filter for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1993-2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1993-2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * Setup() - Prepare the printer for printing. - * StartPage() - Start a page of graphics. - * EndPage() - Finish a page of graphics. - * Shutdown() - Shutdown the printer. - * CompressData() - Compress a line of graphics. - * OutputLine() - Output a line of graphics. - * main() - Main entry and processing of driver. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -66,17 +56,17 @@ unsigned char *Planes[6], /* Output buffers */ *CompBuffer, /* Compression buffer */ *LineBuffers[2]; /* Line bitmap buffers */ int Model, /* Model number */ - NumPlanes, /* Number of color planes */ + EjectPage, /* Eject the page when done? */ + Shingling, /* Shingle output? */ + Canceled; /* Has the current job been canceled? */ +unsigned NumPlanes, /* Number of color planes */ Feed, /* Number of lines to skip */ - EjectPage; /* Eject the page when done? */ -int DotBit, /* Bit in buffers */ + DotBit, /* Bit in buffers */ DotBytes, /* # bytes in a dot column */ DotColumns, /* # columns in 1/60 inch */ LineCount, /* # of lines processed */ EvenOffset, /* Offset into 'even' buffers */ - OddOffset, /* Offset into 'odd' buffers */ - Shingling, /* Shingle output? */ - Canceled; /* Has the current job been canceled? */ + OddOffset; /* Offset into 'odd' buffers */ /* @@ -89,8 +79,8 @@ void EndPage(const cups_page_header2_t *header); void Shutdown(void); void CancelJob(int sig); -void CompressData(const unsigned char *line, int length, int plane, - int type, int xstep, int ystep); +void CompressData(const unsigned char *line, unsigned length, unsigned plane, + unsigned type, unsigned xstep, unsigned ystep); void OutputLine(const cups_page_header2_t *header); void OutputRows(const cups_page_header2_t *header, int row); @@ -125,8 +115,8 @@ StartPage( const ppd_file_t *ppd, /* I - PPD file */ const cups_page_header2_t *header) /* I - Page header */ { - int n, t; /* Numbers */ - int plane; /* Looping var */ + int n, t; /* Numbers */ + unsigned plane; /* Looping var */ /* @@ -223,15 +213,14 @@ StartPage( putchar(0x05); } - n = header->PageSize[1] * header->HWResolution[1] / 72.0; + n = (int)(header->PageSize[1] * header->HWResolution[1] / 72.0); pwrite("\033(C\002\000", 5); /* Page length */ putchar(n); putchar(n >> 8); if (ppd) - t = (ppd->sizes[1].length - ppd->sizes[1].top) * - header->HWResolution[1] / 72.0; + t = (int)((ppd->sizes[1].length - ppd->sizes[1].top) * header->HWResolution[1] / 72.0); else t = 0; @@ -296,8 +285,7 @@ StartPage( if (DotBytes) { - if ((LineBuffers[0] = calloc(DotBytes, - header->cupsWidth * (Shingling + 1))) == NULL) + if ((LineBuffers[0] = calloc((size_t)DotBytes, header->cupsWidth * (size_t)(Shingling + 1))) == NULL) { fputs("ERROR: Unable to allocate memory\n", stderr); exit(1); @@ -398,11 +386,11 @@ CancelJob(int sig) /* I - Signal */ void CompressData(const unsigned char *line, /* I - Data to compress */ - int length,/* I - Number of bytes */ - int plane, /* I - Color plane */ - int type, /* I - Type of compression */ - int xstep, /* I - X resolution */ - int ystep) /* I - Y resolution */ + unsigned length,/* I - Number of bytes */ + unsigned plane, /* I - Color plane */ + unsigned type, /* I - Type of compression */ + unsigned xstep, /* I - X resolution */ + unsigned ystep) /* I - Y resolution */ { const unsigned char *line_ptr, /* Current byte pointer */ *line_end, /* End-of-line byte pointer */ @@ -509,7 +497,7 @@ CompressData(const unsigned char *line, /* I - Data to compress */ count ++; } - *comp_ptr++ = 257 - count; + *comp_ptr++ = (unsigned char)(257 - count); *comp_ptr++ = *line_ptr++; } else @@ -530,7 +518,7 @@ CompressData(const unsigned char *line, /* I - Data to compress */ count ++; } - *comp_ptr++ = count - 1; + *comp_ptr++ = (unsigned char)(count - 1); memcpy(comp_ptr, start, count); comp_ptr += count; @@ -572,12 +560,12 @@ CompressData(const unsigned char *line, /* I - Data to compress */ length *= 8; printf("\033."); /* Raster graphics */ - putchar(type); - putchar(ystep); - putchar(xstep); + putchar((int)type); + putchar((int)ystep); + putchar((int)xstep); putchar(1); - putchar(length); - putchar(length >> 8); + putchar((int)length); + putchar((int)(length >> 8)); } else { @@ -587,15 +575,15 @@ CompressData(const unsigned char *line, /* I - Data to compress */ printf("\033i"); putchar(ctable[plane]); - putchar(type); + putchar((int)type); putchar(1); - putchar(length & 255); - putchar(length >> 8); + putchar((int)length); + putchar((int)(length >> 8)); putchar(1); putchar(0); } - pwrite(line_ptr, line_end - line_ptr); + pwrite(line_ptr, (size_t)(line_end - line_ptr)); fflush(stdout); } @@ -610,11 +598,11 @@ OutputLine( { if (header->cupsRowCount) { - int width; + unsigned width; unsigned char *tempptr, *evenptr, *oddptr; - register int x; + unsigned int x; unsigned char bit; const unsigned char *pixel; unsigned char *temp; @@ -724,10 +712,9 @@ OutputLine( } else { - int plane; /* Current plane */ - int bytes; /* Bytes per plane */ - int xstep, ystep; /* X & Y resolutions */ - + unsigned plane; /* Current plane */ + unsigned bytes; /* Bytes per plane */ + unsigned xstep, ystep; /* X & Y resolutions */ /* * Write a single line of bitmap data as needed... @@ -744,7 +731,7 @@ OutputLine( */ if (!Planes[plane][0] && - memcmp(Planes[plane], Planes[plane] + 1, bytes - 1) == 0) + memcmp(Planes[plane], Planes[plane] + 1, (size_t)bytes - 1) == 0) continue; /* @@ -754,14 +741,13 @@ OutputLine( if (Feed > 0) { pwrite("\033(v\002\000", 5); /* Relative vertical position */ - putchar(Feed); - putchar(Feed >> 8); + putchar((int)Feed); + putchar((int)(Feed >> 8)); Feed = 0; } - CompressData(Planes[plane], bytes, plane, header->cupsCompression, xstep, - ystep); + CompressData(Planes[plane], bytes, plane, header->cupsCompression, xstep, ystep); } Feed ++; @@ -778,8 +764,8 @@ OutputRows( const cups_page_header2_t *header, /* I - Page image header */ int row) /* I - Row number (0 or 1) */ { - unsigned i, n; /* Looping vars */ - int dot_count, /* Number of bytes to print */ + unsigned i, n, /* Looping vars */ + dot_count, /* Number of bytes to print */ dot_min; /* Minimum number of bytes */ unsigned char *dot_ptr, /* Pointer to print data */ *ptr; /* Current data */ @@ -788,8 +774,7 @@ OutputRows( dot_min = DotBytes * DotColumns; if (LineBuffers[row][0] != 0 || - memcmp(LineBuffers[row], LineBuffers[row] + 1, - header->cupsWidth * DotBytes - 1)) + memcmp(LineBuffers[row], LineBuffers[row] + 1, header->cupsWidth * DotBytes - 1)) { /* * Skip leading space... @@ -867,7 +852,7 @@ OutputRows( break; } - n = (unsigned)dot_count / DotBytes; + n = dot_count / DotBytes; putchar(n & 255); putchar(n / 256); @@ -958,7 +943,7 @@ main(int argc, /* I - Number of command-line arguments */ cups_page_header2_t header; /* Page header from file */ ppd_file_t *ppd; /* PPD file */ int page; /* Current page */ - int y; /* Current line */ + unsigned y; /* Current line */ #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* Actions for POSIX signals */ #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ @@ -1090,9 +1075,9 @@ main(int argc, /* I - Number of command-line arguments */ if ((y & 127) == 0) { _cupsLangPrintFilter(stderr, "INFO", - _("Printing page %d, %d%% complete."), + _("Printing page %d, %u%% complete."), page, 100 * y / header.cupsHeight); - fprintf(stderr, "ATTR: job-media-progress=%d\n", + fprintf(stderr, "ATTR: job-media-progress=%u\n", 100 * y / header.cupsHeight); } diff --git a/filter/rastertohp.c b/filter/rastertohp.c index ee6358ba9..42d43c8f5 100644 --- a/filter/rastertohp.c +++ b/filter/rastertohp.c @@ -1,29 +1,18 @@ /* * "$Id$" * - * Hewlett-Packard Page Control Language filter for CUPS. + * Hewlett-Packard Page Control Language filter for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1993-2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1993-2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * Setup() - Prepare the printer for printing. - * StartPage() - Start a page of graphics. - * EndPage() - Finish a page of graphics. - * Shutdown() - Shutdown the printer. - * CancelJob() - Cancel the current job... - * CompressData() - Compress a line of graphics. - * OutputLine() - Output a line of graphics. - * main() - Main entry and processing of driver. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -47,10 +36,10 @@ unsigned char *Planes[4], /* Output buffers */ *CompBuffer, /* Compression buffer */ *BitBuffer; /* Buffer for output bits */ -int NumPlanes, /* Number of color planes */ +unsigned NumPlanes, /* Number of color planes */ ColorBits, /* Number of bits per color */ - Feed, /* Number of lines to skip */ - Duplex, /* Current duplex mode */ + Feed; /* Number of lines to skip */ +int Duplex, /* Current duplex mode */ Page, /* Current page number */ Canceled; /* Has the current job been canceled? */ @@ -65,7 +54,7 @@ void EndPage(void); void Shutdown(void); void CancelJob(int sig); -void CompressData(unsigned char *line, int length, int plane, int type); +void CompressData(unsigned char *line, unsigned length, unsigned plane, unsigned type); void OutputLine(cups_page_header2_t *header); @@ -93,7 +82,7 @@ void StartPage(ppd_file_t *ppd, /* I - PPD file */ cups_page_header2_t *header) /* I - Page header */ { - int plane; /* Looping var */ + unsigned plane; /* Looping var */ /* @@ -287,33 +276,33 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ printf("\033*g26W"); putchar(2); /* Format 2 */ - putchar(NumPlanes); /* Output planes */ + putchar((int)NumPlanes); /* Output planes */ - putchar(header->HWResolution[0] >> 8); /* Black resolution */ - putchar(header->HWResolution[0]); - putchar(header->HWResolution[1] >> 8); - putchar(header->HWResolution[1]); + putchar((int)(header->HWResolution[0] >> 8));/* Black resolution */ + putchar((int)header->HWResolution[0]); + putchar((int)(header->HWResolution[1] >> 8)); + putchar((int)header->HWResolution[1]); putchar(0); putchar(1 << ColorBits); /* # of black levels */ - putchar(header->HWResolution[0] >> 8); /* Cyan resolution */ - putchar(header->HWResolution[0]); - putchar(header->HWResolution[1] >> 8); - putchar(header->HWResolution[1]); + putchar((int)(header->HWResolution[0] >> 8));/* Cyan resolution */ + putchar((int)header->HWResolution[0]); + putchar((int)(header->HWResolution[1] >> 8)); + putchar((int)header->HWResolution[1]); putchar(0); putchar(1 << ColorBits); /* # of cyan levels */ - putchar(header->HWResolution[0] >> 8); /* Magenta resolution */ - putchar(header->HWResolution[0]); - putchar(header->HWResolution[1] >> 8); - putchar(header->HWResolution[1]); + putchar((int)(header->HWResolution[0] >> 8));/* Magenta resolution */ + putchar((int)header->HWResolution[0]); + putchar((int)(header->HWResolution[1] >> 8)); + putchar((int)header->HWResolution[1]); putchar(0); putchar(1 << ColorBits); /* # of magenta levels */ - putchar(header->HWResolution[0] >> 8); /* Yellow resolution */ - putchar(header->HWResolution[0]); - putchar(header->HWResolution[1] >> 8); - putchar(header->HWResolution[1]); + putchar((int)(header->HWResolution[0] >> 8));/* Yellow resolution */ + putchar((int)header->HWResolution[0]); + putchar((int)(header->HWResolution[1] >> 8)); + putchar((int)header->HWResolution[1]); putchar(0); putchar(1 << ColorBits); /* # of yellow levels */ @@ -321,7 +310,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ } else { - printf("\033*t%dR", header->HWResolution[0]); + printf("\033*t%uR", header->HWResolution[0]); /* Set resolution */ if (header->cupsColorSpace == CUPS_CSPACE_KCMY) @@ -341,8 +330,8 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ * Set size and position of graphics... */ - printf("\033*r%dS", header->cupsWidth); /* Set width */ - printf("\033*r%dT", header->cupsHeight); /* Set height */ + printf("\033*r%uS", header->cupsWidth); /* Set width */ + printf("\033*r%uT", header->cupsHeight); /* Set height */ printf("\033&a0H"); /* Set horizontal position */ @@ -356,7 +345,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ printf("\033*r1A"); /* Start graphics */ if (header->cupsCompression) - printf("\033*b%dM", /* Set compression */ + printf("\033*b%uM", /* Set compression */ header->cupsCompression); Feed = 0; /* No blank lines yet */ @@ -463,15 +452,15 @@ CancelJob(int sig) /* I - Signal */ void CompressData(unsigned char *line, /* I - Data to compress */ - int length, /* I - Number of bytes */ - int plane, /* I - Color plane */ - int type) /* I - Type of compression */ + unsigned length, /* I - Number of bytes */ + unsigned plane, /* I - Color plane */ + unsigned type) /* I - Type of compression */ { unsigned char *line_ptr, /* Current byte pointer */ *line_end, /* End-of-line byte pointer */ *comp_ptr, /* Pointer into compression buffer */ *start; /* Start of compression sequence */ - int count; /* Count of bytes for output */ + unsigned count; /* Count of bytes for output */ switch (type) @@ -501,7 +490,7 @@ CompressData(unsigned char *line, /* I - Data to compress */ count < 256; count ++); - comp_ptr[0] = count - 1; + comp_ptr[0] = (unsigned char)(count - 1); comp_ptr[1] = line_ptr[0]; } @@ -546,7 +535,7 @@ CompressData(unsigned char *line, /* I - Data to compress */ count ++; } - *comp_ptr++ = 257 - count; + *comp_ptr++ = (unsigned char)(257 - count); *comp_ptr++ = *line_ptr++; } else @@ -567,7 +556,7 @@ CompressData(unsigned char *line, /* I - Data to compress */ count ++; } - *comp_ptr++ = count - 1; + *comp_ptr++ = (unsigned char)(count - 1); memcpy(comp_ptr, start, count); comp_ptr += count; @@ -584,7 +573,7 @@ CompressData(unsigned char *line, /* I - Data to compress */ */ printf("\033*b%d%c", (int)(line_end - line_ptr), plane); - fwrite(line_ptr, line_end - line_ptr, 1, stdout); + fwrite(line_ptr, (size_t)(line_end - line_ptr), 1, stdout); } @@ -595,7 +584,7 @@ CompressData(unsigned char *line, /* I - Data to compress */ void OutputLine(cups_page_header2_t *header) /* I - Page header */ { - int plane, /* Current plane */ + unsigned plane, /* Current plane */ bytes, /* Bytes to write */ count; /* Bytes to convert */ unsigned char bit, /* Current plane data */ @@ -644,15 +633,15 @@ OutputLine(cups_page_header2_t *header) /* I - Page header */ { bit = plane_ptr[0]; - bit0 = ((bit & 64) << 1) | ((bit & 16) << 2) | ((bit & 4) << 3) | ((bit & 1) << 4); - bit1 = (bit & 128) | ((bit & 32) << 1) | ((bit & 8) << 2) | ((bit & 2) << 3); + bit0 = (unsigned char)(((bit & 64) << 1) | ((bit & 16) << 2) | ((bit & 4) << 3) | ((bit & 1) << 4)); + bit1 = (unsigned char)((bit & 128) | ((bit & 32) << 1) | ((bit & 8) << 2) | ((bit & 2) << 3)); if (count > 1) { bit = plane_ptr[1]; - bit0 |= (bit & 1) | ((bit & 4) >> 1) | ((bit & 16) >> 2) | ((bit & 64) >> 3); - bit1 |= ((bit & 2) >> 1) | ((bit & 8) >> 2) | ((bit & 32) >> 3) | ((bit & 128) >> 4); + bit0 |= (unsigned char)((bit & 1) | ((bit & 4) >> 1) | ((bit & 16) >> 2) | ((bit & 64) >> 3)); + bit1 |= (unsigned char)(((bit & 2) >> 1) | ((bit & 8) >> 2) | ((bit & 32) >> 3) | ((bit & 128) >> 4)); } bit_ptr[0] = bit0; @@ -683,7 +672,7 @@ main(int argc, /* I - Number of command-line arguments */ int fd; /* File descriptor */ cups_raster_t *ras; /* Raster stream for printing */ cups_page_header2_t header; /* Page header from file */ - int y; /* Current line */ + unsigned y; /* Current line */ ppd_file_t *ppd; /* PPD file */ #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* Actions for POSIX signals */ @@ -814,9 +803,9 @@ main(int argc, /* I - Number of command-line arguments */ if ((y & 127) == 0) { _cupsLangPrintFilter(stderr, "INFO", - _("Printing page %d, %d%% complete."), + _("Printing page %d, %u%% complete."), Page, 100 * y / header.cupsHeight); - fprintf(stderr, "ATTR: job-media-progress=%d\n", + fprintf(stderr, "ATTR: job-media-progress=%u\n", 100 * y / header.cupsHeight); } diff --git a/filter/rastertolabel.c b/filter/rastertolabel.c index f5d80256a..bcd5ca1d9 100644 --- a/filter/rastertolabel.c +++ b/filter/rastertolabel.c @@ -1,29 +1,18 @@ /* * "$Id$" * - * Label printer filter for CUPS. + * Label printer filter for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 2001-2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 2001-2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * Setup() - Prepare the printer for printing. - * StartPage() - Start a page of graphics. - * EndPage() - Finish a page of graphics. - * CancelJob() - Cancel the current job... - * OutputLine() - Output a line of graphics. - * PCLCompress() - Output a PCL (mode 3) compressed line. - * ZPLCompress() - Output a run-length compression sequence. - * main() - Main entry and processing of driver. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -78,10 +67,10 @@ unsigned char *Buffer; /* Output buffer */ unsigned char *CompBuffer; /* Compression buffer */ unsigned char *LastBuffer; /* Last buffer */ +unsigned Feed; /* Number of lines to skip */ int LastSet; /* Number of repeat characters */ int ModelNumber, /* cupsModelNumber attribute */ Page, /* Current page */ - Feed, /* Number of lines to skip */ Canceled; /* Non-zero if job is canceled */ @@ -93,9 +82,9 @@ void Setup(ppd_file_t *ppd); void StartPage(ppd_file_t *ppd, cups_page_header2_t *header); void EndPage(ppd_file_t *ppd, cups_page_header2_t *header); void CancelJob(int sig); -void OutputLine(ppd_file_t *ppd, cups_page_header2_t *header, int y); -void PCLCompress(unsigned char *line, int length); -void ZPLCompress(char repeat_char, int repeat_count); +void OutputLine(ppd_file_t *ppd, cups_page_header2_t *header, unsigned y); +void PCLCompress(unsigned char *line, unsigned length); +void ZPLCompress(unsigned char repeat_char, unsigned repeat_count); /* @@ -169,7 +158,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ cups_page_header2_t *header) /* I - Page header */ { ppd_choice_t *choice; /* Marked choice */ - int length; /* Actual label length */ + unsigned length; /* Actual label length */ /* @@ -289,7 +278,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((choice = ppdFindMarkedChoice(ppd, "zePrintRate")) != NULL && strcmp(choice->choice, "Default")) { - float val = atof(choice->choice); + double val = atof(choice->choice); if (val >= 3.0) printf("S%.0f\n", val); @@ -302,13 +291,13 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ */ if (header->cupsCompression > 0 && header->cupsCompression <= 100) - printf("D%d\n", 15 * header->cupsCompression / 100); + printf("D%u\n", 15 * header->cupsCompression / 100); /* * Set label size... */ - printf("q%d\n", (header->cupsWidth + 7) & ~7); + printf("q%u\n", (header->cupsWidth + 7) & ~7U); break; case ZEBRA_ZPL : @@ -317,13 +306,13 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ */ if (header->cupsCompression > 0 && header->cupsCompression <= 100) - printf("~SD%02d\n", 30 * header->cupsCompression / 100); + printf("~SD%02u\n", 30 * header->cupsCompression / 100); /* * Start bitmap graphics... */ - printf("~DGR:CUPS.GRF,%d,%d,\n", + printf("~DGR:CUPS.GRF,%u,%u,\n", header->cupsHeight * header->cupsBytesPerLine, header->cupsBytesPerLine); @@ -344,8 +333,8 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ printf("! 0 %u %u %u %u\r\n", header->HWResolution[0], header->HWResolution[1], header->cupsHeight, header->NumCopies); - printf("PAGE-WIDTH %d\r\n", header->cupsWidth); - printf("PAGE-HEIGHT %d\r\n", header->cupsWidth); + printf("PAGE-WIDTH %u\r\n", header->cupsWidth); + printf("PAGE-HEIGHT %u\r\n", header->cupsWidth); break; case INTELLITECH_PCL : @@ -391,14 +380,15 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ break; default : /* Custom size */ - printf("\033!f%dZ", header->PageSize[1] * 300 / 72); + printf("\033!f%uZ", header->PageSize[1] * 300 / 72); break; } - printf("\033&l%dP", /* Set page length */ + printf("\033&l%uP", /* Set page length */ header->PageSize[1] / 12); printf("\033&l0E"); /* Set top margin to 0 */ - printf("\033&l%dX", header->NumCopies); + if (header->NumCopies) + printf("\033&l%uX", header->NumCopies); /* Set number copies */ printf("\033&l0L"); /* Turn off perforation skip */ @@ -409,11 +399,11 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if (Page == 1) { if (header->cupsRowFeed) /* inPrintRate */ - printf("\033!p%dS", header->cupsRowFeed); + printf("\033!p%uS", header->cupsRowFeed); - if (header->cupsCompression != ~0) + if (header->cupsCompression != ~0U) /* inPrintDensity */ - printf("\033&d%dA", 30 * header->cupsCompression / 100 - 15); + printf("\033&d%uA", 30 * header->cupsCompression / 100 - 15); if ((choice = ppdFindMarkedChoice(ppd, "inPrintMode")) != NULL) { @@ -424,14 +414,14 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ fputs("\033!p1M", stdout); if (header->cupsRowCount) /* inTearInterval */ - printf("\033!n%dT", header->cupsRowCount); + printf("\033!n%uT", header->cupsRowCount); } else { fputs("\033!p2M", stdout); if (header->cupsRowStep) /* inCutInterval */ - printf("\033!n%dC", header->cupsRowStep); + printf("\033!n%uC", header->cupsRowStep); } } } @@ -440,12 +430,12 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ * Setup graphics... */ - printf("\033*t%dR", header->HWResolution[0]); + printf("\033*t%uR", header->HWResolution[0]); /* Set resolution */ - printf("\033*r%dS", header->cupsWidth); + printf("\033*r%uS", header->cupsWidth); /* Set width */ - printf("\033*r%dT", header->cupsHeight); + printf("\033*r%uT", header->cupsHeight); /* Set height */ printf("\033&a0H"); /* Set horizontal position */ @@ -741,17 +731,19 @@ CancelJob(int sig) /* I - Signal */ void OutputLine(ppd_file_t *ppd, /* I - PPD file */ cups_page_header2_t *header, /* I - Page header */ - int y) /* I - Line number */ + unsigned y) /* I - Line number */ { - int i; /* Looping var */ + unsigned i; /* Looping var */ unsigned char *ptr; /* Pointer into buffer */ unsigned char *compptr; /* Pointer into compression buffer */ - char repeat_char; /* Repeated character */ - int repeat_count; /* Number of repeated characters */ - static const char *hex = "0123456789ABCDEF"; + unsigned char repeat_char; /* Repeated character */ + unsigned repeat_count; /* Number of repeated characters */ + static const unsigned char *hex = (const unsigned char *)"0123456789ABCDEF"; /* Hex digits */ + (void)ppd; + switch (ModelNumber) { case DYMO_3x0 : @@ -908,14 +900,14 @@ OutputLine(ppd_file_t *ppd, /* I - PPD file */ void PCLCompress(unsigned char *line, /* I - Line to compress */ - int length) /* I - Length of line */ + unsigned length) /* I - Length of line */ { unsigned char *line_ptr, /* Current byte pointer */ *line_end, /* End-of-line byte pointer */ *comp_ptr, /* Pointer into compression buffer */ *start, /* Start of compression sequence */ *seed; /* Seed buffer pointer */ - int count, /* Count of bytes for output */ + unsigned count, /* Count of bytes for output */ offset; /* Offset of bytes for output */ @@ -945,7 +937,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */ offset = 0; - if ((count = line_end - line_ptr) > 8) + if ((count = (unsigned)(line_end - line_ptr)) > 8) count = 8; line_ptr += count; @@ -966,7 +958,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */ if (line_ptr == line_end) break; - offset = line_ptr - start; + offset = (unsigned)(line_ptr - start); /* * Find up to 8 non-matching bytes... @@ -995,7 +987,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */ * Output multi-byte offset... */ - *comp_ptr++ = ((count - 1) << 5) | 31; + *comp_ptr++ = (unsigned char)(((count - 1) << 5) | 31); offset -= 31; while (offset >= 255) @@ -1004,7 +996,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */ offset -= 255; } - *comp_ptr++ = offset; + *comp_ptr++ = (unsigned char)offset; } else { @@ -1012,7 +1004,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */ * Output single-byte offset... */ - *comp_ptr++ = ((count - 1) << 5) | offset; + *comp_ptr++ = (unsigned char)(((count - 1) << 5) | offset); } memcpy(comp_ptr, start, count); @@ -1024,7 +1016,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */ */ printf("\033*b%dW", (int)(comp_ptr - CompBuffer)); - fwrite(CompBuffer, comp_ptr - CompBuffer, 1, stdout); + fwrite(CompBuffer, (size_t)(comp_ptr - CompBuffer), 1, stdout); /* * Save this line as a "seed" buffer for the next... @@ -1040,8 +1032,8 @@ PCLCompress(unsigned char *line, /* I - Line to compress */ */ void -ZPLCompress(char repeat_char, /* I - Character to repeat */ - int repeat_count) /* I - Number of repeated characters */ +ZPLCompress(unsigned char repeat_char, /* I - Character to repeat */ + unsigned repeat_count) /* I - Number of repeated characters */ { if (repeat_count > 1) { @@ -1062,7 +1054,7 @@ ZPLCompress(char repeat_char, /* I - Character to repeat */ if (repeat_count >= 20) { - putchar('f' + repeat_count / 20); + putchar((int)('f' + repeat_count / 20)); repeat_count %= 20; } @@ -1071,14 +1063,14 @@ ZPLCompress(char repeat_char, /* I - Character to repeat */ */ if (repeat_count > 0) - putchar('F' + repeat_count); + putchar((int)('F' + repeat_count)); } /* * Then the character to be repeated... */ - putchar(repeat_char); + putchar((int)repeat_char); } @@ -1093,7 +1085,7 @@ main(int argc, /* I - Number of command-line arguments */ int fd; /* File descriptor */ cups_raster_t *ras; /* Raster stream for printing */ cups_page_header2_t header; /* Page header from file */ - int y; /* Current line */ + unsigned y; /* Current line */ ppd_file_t *ppd; /* PPD file */ int num_options; /* Number of options */ cups_option_t *options; /* Options */ @@ -1235,9 +1227,9 @@ main(int argc, /* I - Number of command-line arguments */ if ((y & 15) == 0) { _cupsLangPrintFilter(stderr, "INFO", - _("Printing page %d, %d%% complete."), + _("Printing page %d, %u%% complete."), Page, 100 * y / header.cupsHeight); - fprintf(stderr, "ATTR: job-media-progress=%d\n", + fprintf(stderr, "ATTR: job-media-progress=%u\n", 100 * y / header.cupsHeight); } diff --git a/filter/rastertopwg.c b/filter/rastertopwg.c index 622aa605a..0116fb173 100644 --- a/filter/rastertopwg.c +++ b/filter/rastertopwg.c @@ -1,21 +1,17 @@ /* * "$Id$" * - * CUPS raster to PWG raster format filter for CUPS. + * CUPS raster to PWG raster format filter for CUPS. * - * Copyright 2011 Apple Inc. + * Copyright 2011, 2014 Apple Inc. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright law. - * Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright law. + * Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * main() - Main entry for filter. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -41,9 +37,9 @@ main(int argc, /* I - Number of command-line args */ *outras; /* Output raster stream */ cups_page_header2_t inheader, /* Input raster page header */ outheader; /* Output raster page header */ - int y; /* Current line */ + unsigned y; /* Current line */ unsigned char *line; /* Line buffer */ - int page = 0, /* Current page */ + unsigned page = 0, /* Current page */ page_width, /* Actual page width */ page_height, /* Actual page height */ page_top, /* Top margin */ @@ -101,14 +97,10 @@ main(int argc, /* I - Number of command-line args */ fprintf(stderr, "PAGE: %d %d\n", page, inheader.NumCopies); - page_width = (int)(inheader.cupsPageSize[0] * inheader.HWResolution[0] / - 72.0); - page_height = (int)(inheader.cupsPageSize[1] * inheader.HWResolution[1] / - 72.0); - page_left = (int)(inheader.cupsImagingBBox[0] * - inheader.HWResolution[0] / 72.0); - page_bottom = (int)(inheader.cupsImagingBBox[1] * - inheader.HWResolution[1] / 72.0); + page_width = (unsigned)(inheader.cupsPageSize[0] * inheader.HWResolution[0] / 72.0); + page_height = (unsigned)(inheader.cupsPageSize[1] * inheader.HWResolution[1] / 72.0); + page_left = (unsigned)(inheader.cupsImagingBBox[0] * inheader.HWResolution[0] / 72.0); + page_bottom = (unsigned)(inheader.cupsImagingBBox[1] * inheader.HWResolution[1] / 72.0); page_top = page_height - page_bottom - inheader.cupsHeight; linesize = (page_width * inheader.cupsBitsPerPixel + 7) / 8; lineoffset = page_left * inheader.cupsBitsPerPixel / 8; /* Round down */ @@ -199,7 +191,7 @@ main(int argc, /* I - Number of command-line args */ if ((val = cupsGetOption("print-quality", num_options, options)) != NULL) { - int quality = atoi(val); /* print-quality value */ + unsigned quality = (unsigned)atoi(val); /* print-quality value */ if (quality >= IPP_QUALITY_DRAFT && quality <= IPP_QUALITY_HIGH) outheader.cupsInteger[8] = quality; @@ -270,7 +262,7 @@ main(int argc, /* I - Number of command-line args */ { if (inheader.Tumble) { - outheader.cupsInteger[1] = -1;/* CrossFeedTransform */ + outheader.cupsInteger[1] = ~0U;/* CrossFeedTransform */ outheader.cupsInteger[2] = 1; /* FeedTransform */ outheader.cupsInteger[3] = page_width - page_left - @@ -286,7 +278,7 @@ main(int argc, /* I - Number of command-line args */ else { outheader.cupsInteger[1] = 1; /* CrossFeedTransform */ - outheader.cupsInteger[2] = -1;/* FeedTransform */ + outheader.cupsInteger[2] = ~0U;/* FeedTransform */ outheader.cupsInteger[3] = page_left; /* ImageBoxLeft */ @@ -302,8 +294,8 @@ main(int argc, /* I - Number of command-line args */ { if (inheader.Tumble) { - outheader.cupsInteger[1] = -1;/* CrossFeedTransform */ - outheader.cupsInteger[2] = -1;/* FeedTransform */ + outheader.cupsInteger[1] = ~0U;/* CrossFeedTransform */ + outheader.cupsInteger[2] = ~0U;/* FeedTransform */ outheader.cupsInteger[3] = page_width - page_left - inheader.cupsWidth; @@ -334,8 +326,8 @@ main(int argc, /* I - Number of command-line args */ { if (inheader.Tumble) { - outheader.cupsInteger[1] = -1;/* CrossFeedTransform */ - outheader.cupsInteger[2] = -1;/* FeedTransform */ + outheader.cupsInteger[1] = ~0U;/* CrossFeedTransform */ + outheader.cupsInteger[2] = ~0U;/* FeedTransform */ outheader.cupsInteger[3] = page_width - page_left - inheader.cupsWidth; diff --git a/filter/testraster.c b/filter/testraster.c index 8920e2e77..d2f152dba 100644 --- a/filter/testraster.c +++ b/filter/testraster.c @@ -1,27 +1,18 @@ /* * "$Id$" * - * Raster test program routines for CUPS. + * Raster test program routines for CUPS. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * main() - Test the raster functions. - * do_ppd_tests() - Test the default option commands in a PPD file. - * do_ps_tests() - Test standard PostScript commands. - * do_ras_file() - Test reading of a raster file. - * do_raster_tests() - Test reading and writing of raster data. - * print_changes() - Print differences in the page header. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -29,6 +20,7 @@ */ #include <cups/raster-private.h> +#include <math.h> /* @@ -172,13 +164,12 @@ static cups_page_header2_t setpagedevice_header = 1, /* cupsRowFeed */ 1, /* cupsRowStep */ 0, /* cupsNumColors */ - 1.001, /* cupsBorderlessScalingFactor */ - { 612.0, 792.1 }, /* cupsPageSize */ - { 0.0, 0.0, 0.0, 0.0 }, /* cupsImagingBBox */ + 1.001f, /* cupsBorderlessScalingFactor */ + { 612.0f, 792.1f }, /* cupsPageSize */ + { 0.0f, 0.0f, 0.0f, 0.0f }, /* cupsImagingBBox */ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, /* cupsInteger[16] */ - { 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1, 9.1, 10.1, 11.1, 12.1, 13.1, - 14.1, 15.1, 16.1 }, /* cupsReal[16] */ + { 1.1f, 2.1f, 3.1f, 4.1f, 5.1f, 6.1f, 7.1f, 8.1f, 9.1f, 10.1f, 11.1f, 12.1f, 13.1f, 14.1f, 15.1f, 16.1f }, /* cupsReal[16] */ { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" }, /* cupsString[16] */ "Marker Type", /* cupsMarkerType */ @@ -519,7 +510,7 @@ do_ras_file(const char *filename) /* I - Filename */ static int /* O - Number of errors */ do_raster_tests(cups_mode_t mode) /* O - Write mode */ { - int page, x, y; /* Looping vars */ + unsigned page, x, y; /* Looping vars */ FILE *fp; /* Raster file */ cups_raster_t *r; /* Raster stream */ cups_page_header2_t header, /* Page header */ @@ -610,7 +601,7 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ else { for (x = 0; x < header.cupsBytesPerLine; x ++) - data[x] = x; + data[x] = (unsigned char)x; for (y = 0; y < 64; y ++) if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) @@ -636,7 +627,7 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */ else { for (x = 0; x < header.cupsBytesPerLine; x ++) - data[x] = x / 4; + data[x] = (unsigned char)(x / 4); for (y = 0; y < 64; y ++) if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) @@ -1020,22 +1011,21 @@ print_changes( printf(" cupsNumColors %d, expected %d\n", header->cupsNumColors, expected->cupsNumColors); - if (header->cupsBorderlessScalingFactor != - expected->cupsBorderlessScalingFactor) + if (fabs(header->cupsBorderlessScalingFactor - expected->cupsBorderlessScalingFactor) > 0.001) printf(" cupsBorderlessScalingFactor %g, expected %g\n", header->cupsBorderlessScalingFactor, expected->cupsBorderlessScalingFactor); - if (header->cupsPageSize[0] != expected->cupsPageSize[0] || - header->cupsPageSize[1] != expected->cupsPageSize[1]) + if (fabs(header->cupsPageSize[0] - expected->cupsPageSize[0]) > 0.001 || + fabs(header->cupsPageSize[1] - expected->cupsPageSize[1]) > 0.001) printf(" cupsPageSize [%g %g], expected [%g %g]\n", header->cupsPageSize[0], header->cupsPageSize[1], expected->cupsPageSize[0], expected->cupsPageSize[1]); - if (header->cupsImagingBBox[0] != expected->cupsImagingBBox[0] || - header->cupsImagingBBox[1] != expected->cupsImagingBBox[1] || - header->cupsImagingBBox[2] != expected->cupsImagingBBox[2] || - header->cupsImagingBBox[3] != expected->cupsImagingBBox[3]) + if (fabs(header->cupsImagingBBox[0] - expected->cupsImagingBBox[0]) > 0.001 || + fabs(header->cupsImagingBBox[1] - expected->cupsImagingBBox[1]) > 0.001 || + fabs(header->cupsImagingBBox[2] - expected->cupsImagingBBox[2]) > 0.001 || + fabs(header->cupsImagingBBox[3] - expected->cupsImagingBBox[3]) > 0.001) printf(" cupsImagingBBox [%g %g %g %g], expected [%g %g %g %g]\n", header->cupsImagingBBox[0], header->cupsImagingBBox[1], header->cupsImagingBBox[2], header->cupsImagingBBox[3], @@ -1048,7 +1038,7 @@ print_changes( expected->cupsInteger[i]); for (i = 0; i < 16; i ++) - if (header->cupsReal[i] != expected->cupsReal[i]) + if (fabs(header->cupsReal[i] - expected->cupsReal[i]) > 0.001) printf(" cupsReal%d %g, expected %g\n", i, header->cupsReal[i], expected->cupsReal[i]); |