1.1 diff -r 6575fcfbdb1b -r 139b91f9a224 semantics.c 1.2 --- a/semantics.c Mon Dec 31 08:25:04 2001 +0000 1.3 +++ b/semantics.c Mon Dec 31 16:44:24 2001 +0000 1.4 @@ -5,6 +5,7 @@ 1.5 #include "type.h" 1.6 #include "semantics.h" 1.7 #include "parser.tab.h" 1.8 +#include "tiff2pdf.h" 1.9 1.10 1.11 typedef struct 1.12 @@ -53,7 +54,9 @@ 1.13 char *output_file; 1.14 bookmark_t *first_bookmark; 1.15 bookmark_t *last_bookmark; 1.16 - char *page_number_format; 1.17 + 1.18 + boolean has_page_label; 1.19 + page_label_t page_label; 1.20 } output_context_t; 1.21 1.22 1.23 @@ -312,10 +315,11 @@ 1.24 last_output_context->last_bookmark = new_bookmark; 1.25 } 1.26 1.27 -void output_set_page_number_format (char *format) 1.28 +void output_set_page_label (page_label_t label) 1.29 { 1.30 output_clone (); 1.31 - last_output_context->page_number_format = format; 1.32 + last_output_context->has_page_label = 1; 1.33 + last_output_context->page_label = label; 1.34 } 1.35 1.36 static void increment_output_page_count (int count) 1.37 @@ -408,11 +412,11 @@ 1.38 exit (2); 1.39 } 1.40 1.41 -static char *get_output_page_number_format (output_context_t *context) 1.42 +static page_label_t *get_output_page_label (output_context_t *context) 1.43 { 1.44 for (; context; context = context->parent) 1.45 - if (context->page_number_format) 1.46 - return (context->page_number_format); 1.47 + if (context->has_page_label) 1.48 + return (& context->page_label); 1.49 return (NULL); /* default */ 1.50 } 1.51 1.52 @@ -447,18 +451,87 @@ 1.53 if (page->bookmark_list) 1.54 { 1.55 for (bookmark = page->bookmark_list; bookmark; bookmark = bookmark->next) 1.56 - printf ("bookmark %d '%s'\n", bookmark->level, bookmark->name); 1.57 + printf ("bookmark %d \"%s\"\n", bookmark->level, bookmark->name); 1.58 } 1.59 for (i = page->range.first; i <= page->range.last; i++) 1.60 { 1.61 - printf ("file '%s' ", get_output_file (page->output_context)); 1.62 - printf ("format '%s' ", get_output_page_number_format (page->output_context)); 1.63 + page_label_t *label = get_output_page_label (page->output_context); 1.64 + printf ("file \"%s\" ", get_output_file (page->output_context)); 1.65 + if (label) 1.66 + { 1.67 + printf ("label "); 1.68 + if (label->prefix) 1.69 + printf ("\"%s\" ", label->prefix); 1.70 + if (label->style) 1.71 + printf ("'%c' ", label->style); 1.72 + } 1.73 printf ("page %d\n", i); 1.74 } 1.75 } 1.76 } 1.77 #endif /* SEMANTIC_DEBUG */ 1.78 1.79 + 1.80 +static inline int range_count (range_t range) 1.81 +{ 1.82 + return ((range.last - range.first) + 1); 1.83 +} 1.84 + 1.85 + 1.86 +void doit (void) 1.87 +{ 1.88 + input_image_t *image = NULL; 1.89 + output_page_t *page = NULL; 1.90 + int i = 0; 1.91 + int p = 0; 1.92 + int page_index = 0; 1.93 + input_attributes_t input_attributes; 1.94 + input_modifier_type_t parity; 1.95 + page_label_t *page_label; 1.96 + 1.97 + for (;;) 1.98 + { 1.99 + if ((! image) || (i >= range_count (image->range))) 1.100 + { 1.101 + if (image) 1.102 + image = image->next; 1.103 + else 1.104 + image = first_input_image; 1.105 + if (! image) 1.106 + return; 1.107 + i = 0; 1.108 + } 1.109 + 1.110 + if ((! page) || (p >= range_count (page->range))) 1.111 + { 1.112 + if (page) 1.113 + page = page->next; 1.114 + else 1.115 + page = first_output_page; 1.116 + p = 0; 1.117 + page_label = get_output_page_label (page->output_context); 1.118 + process_page_numbers (page_index, 1.119 + range_count (page->range), 1.120 + page->range.first, 1.121 + page_label); 1.122 + } 1.123 + 1.124 + parity = ((image->range.first + i) % 2) ? INPUT_MODIFIER_ODD : INPUT_MODIFIER_EVEN; 1.125 + 1.126 + memset (& input_attributes, 0, sizeof (input_attributes)); 1.127 + input_attributes.rotation = get_input_rotation (image->input_context, 1.128 + parity);; 1.129 + 1.130 + process_page (image->range.first + i, 1.131 + input_attributes, 1.132 + page->bookmark_list); 1.133 + i++; 1.134 + p++; 1.135 + page_index++; 1.136 + } 1.137 +} 1.138 + 1.139 + 1.140 boolean parse_spec_file (char *fn) 1.141 { 1.142 boolean result = 0;