rastertoescpx: added handling of empty input
@@ -1747,6 +1747,7 @@ main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
int fd; /* File descriptor */
+ int empty = 1;
cups_raster_t *ras; /* Raster stream for printing */
cups_page_header2_t header; /* Page header from file */
int page; /* Current page */
@@ -1837,12 +1838,6 @@ main(int argc, /* I - Number of command-line arguments */
signal(SIGTERM, CancelJob);
#endif /* HAVE_SIGSET */
- /*
- * Initialize the print device...
- */
-
- Setup(ppd);
-
/*
* Process pages as needed...
*/
@@ -1855,6 +1850,15 @@ main(int argc, /* I - Number of command-line arguments */
* Write a status message with the page number and number of copies.
*/
+ if (empty)
+ {
+ /*
+ * Initialize the print device...
+ */
+ Setup(ppd);
+ empty = 0;
+ }
+
if (Canceled)
break;
@@ -1901,6 +1905,7 @@ main(int argc, /* I - Number of command-line arguments */
break;
}
+ if (!empty)
Shutdown(ppd);
cupsFreeOptions(num_options, options);
@@ -1914,6 +1919,11 @@ main(int argc, /* I - Number of command-line arguments */
if (DotBuffers[i] != NULL)
free(DotBuffers[i]);
+ if (empty)
+ {
+ fprintf(stderr, "DEBUG: Input is empty, outputting empty file.\n");
+ return 0;
+ }
return (page == 0);
}
