]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
rastertoescpx: added handling of empty input 197/head
authorJaiLuthra1 <luthrajaiji@gmail.com>
Thu, 30 Jan 2020 12:35:15 +0000 (18:05 +0530)
committerJaiLuthra1 <luthrajaiji@gmail.com>
Thu, 30 Jan 2020 12:35:15 +0000 (18:05 +0530)
filter/rastertoescpx.c

index 79d310c3cad99a756793787c44505fa17d6e9c55..217f63c44e90a685e8b2514169f1c03a5f2a47c6 100644 (file)
@@ -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,7 +1905,8 @@ main(int  argc,                           /* I - Number of command-line arguments */
       break;
   }
 
-  Shutdown(ppd);
+  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);
 }