Wed, 19 Feb 2003 10:20:05 +0000
fix error reporting in process_specs(). rename some functions for clarity.
semantics.c | file | annotate | diff | revisions |
1.1 diff -r 72cde0ca6b0c -r 43a9b9f27403 semantics.c 1.2 --- a/semantics.c Wed Feb 19 10:17:12 2003 +0000 1.3 +++ b/semantics.c Wed Feb 19 10:20:05 2003 +0000 1.4 @@ -4,7 +4,7 @@ 1.5 * will be compressed using ITU-T T.6 (G4) fax encoding. 1.6 * 1.7 * Semantic routines for spec file parser 1.8 - * $Id: semantics.c,v 1.16 2003/01/21 10:30:49 eric Exp $ 1.9 + * $Id: semantics.c,v 1.17 2003/02/19 02:20:05 eric Exp $ 1.10 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 1.11 * 1.12 * This program is free software; you can redistribute it and/or modify 1.13 @@ -449,7 +449,7 @@ 1.14 } 1.15 1.16 1.17 -static char *get_input_file (input_context_t *context) 1.18 +static char *get_input_filename (input_context_t *context) 1.19 { 1.20 for (; context; context = context->parent) 1.21 if (context->input_file) 1.22 @@ -498,7 +498,7 @@ 1.23 return (0); /* default */ 1.24 } 1.25 1.26 -static char *get_output_file (output_context_t *context) 1.27 +static char *get_output_filename (output_context_t *context) 1.28 { 1.29 for (; context; context = context->parent) 1.30 if (context->output_file) 1.31 @@ -547,7 +547,7 @@ 1.32 parity, 1.33 & page_size); 1.34 printf ("file '%s' image %d", 1.35 - get_input_file (image->input_context), 1.36 + get_input_filename (image->input_context), 1.37 i); 1.38 if (has_rotation) 1.39 printf (" rotation %d", rotation); 1.40 @@ -575,7 +575,7 @@ 1.41 for (i = page->range.first; i <= page->range.last; i++) 1.42 { 1.43 page_label_t *label = get_output_page_label (page->output_context); 1.44 - printf ("file \"%s\" ", get_output_file (page->output_context)); 1.45 + printf ("file \"%s\" ", get_output_filename (page->output_context)); 1.46 if (label) 1.47 { 1.48 printf ("label "); 1.49 @@ -658,27 +658,41 @@ 1.50 { 1.51 if ((! image) || (i >= range_count (image->range))) 1.52 { 1.53 + char *input_fn; 1.54 if (image) 1.55 image = image->next; 1.56 else 1.57 image = first_input_image; 1.58 if (! image) 1.59 - return (0); 1.60 + return (1); /* done */ 1.61 i = 0; 1.62 - if (! open_tiff_input_file (get_input_file (image->input_context))) 1.63 - return (0); 1.64 + input_fn = get_input_filename (image->input_context); 1.65 + if (verbose) 1.66 + fprintf (stderr, "opening TIFF file '%s'\n", input_fn); 1.67 + if (! open_tiff_input_file (input_fn)) 1.68 + { 1.69 + fprintf (stderr, "error opening TIFF file '%s'\n", input_fn); 1.70 + return (0); 1.71 + } 1.72 } 1.73 1.74 if ((! page) || (p >= range_count (page->range))) 1.75 { 1.76 + char *output_fn; 1.77 if (page) 1.78 page = page->next; 1.79 else 1.80 page = first_output_page; 1.81 p = 0; 1.82 - if (! open_pdf_output_file (get_output_file (page->output_context), 1.83 + output_fn = get_output_filename (page->output_context); 1.84 + if (verbose) 1.85 + fprintf (stderr, "opening PDF file '%s'\n", output_fn); 1.86 + if (! open_pdf_output_file (output_fn, 1.87 get_output_file_attributes (page->output_context))) 1.88 - return (0); 1.89 + { 1.90 + fprintf (stderr, "error opening PDF file '%s'\n", output_fn); 1.91 + return (0); 1.92 + } 1.93 page_label = get_output_page_label (page->output_context); 1.94 process_page_numbers (page_index, 1.95 range_count (page->range), 1.96 @@ -699,14 +713,17 @@ 1.97 parity, 1.98 & input_attributes.page_size); 1.99 1.100 + if (verbose) 1.101 + fprintf (stderr, "processing image %d\n", image->range.first + i); 1.102 if (! process_page (image->range.first + i, 1.103 input_attributes, 1.104 page->bookmark_list)) 1.105 - return (0); 1.106 + { 1.107 + fprintf (stderr, "error processing image %d\n", image->range.first + i); 1.108 + return (0); 1.109 + } 1.110 i++; 1.111 p++; 1.112 page_index++; 1.113 } 1.114 - 1.115 - return (1); 1.116 }