Sun, 30 Dec 2001 17:09:08 +0000
*** empty log message ***
parser.y | file | annotate | diff | revisions | |
scanner.l | file | annotate | diff | revisions | |
semantics.c | file | annotate | diff | revisions | |
semantics.h | file | annotate | diff | revisions | |
t2p.c | file | annotate | diff | revisions | |
tumble.c | file | annotate | diff | revisions |
1.1 diff -r d4699dfddcc0 -r 3de372e4b230 parser.y 1.2 --- a/parser.y Sun Dec 30 16:29:50 2001 +0000 1.3 +++ b/parser.y Sun Dec 30 17:09:08 2001 +0000 1.4 @@ -8,8 +8,8 @@ 1.5 int integer; 1.6 double fp; 1.7 char *string; 1.8 - struct { double width; double height; } size; 1.9 - struct { int first; int last; } range; 1.10 + page_size_t size; 1.11 + range_t range; 1.12 } 1.13 1.14 %token <integer> INTEGER
2.1 diff -r d4699dfddcc0 -r 3de372e4b230 scanner.l 2.2 --- a/scanner.l Sun Dec 30 16:29:50 2001 +0000 2.3 +++ b/scanner.l Sun Dec 30 17:09:08 2001 +0000 2.4 @@ -1,5 +1,5 @@ 2.5 /* 2.6 -$Id: scanner.l,v 1.9 2001/12/30 08:29:50 eric Exp $ 2.7 +$Id: scanner.l,v 1.10 2001/12/30 09:09:08 eric Exp $ 2.8 */ 2.9 2.10 %option case-insensitive 2.11 @@ -8,9 +8,9 @@ 2.12 %{ 2.13 #include <stdio.h> 2.14 #include <string.h> 2.15 -#include "parser.tab.h" 2.16 #include "type.h" 2.17 #include "semantics.h" 2.18 +#include "parser.tab.h" 2.19 2.20 #ifdef SCANNER_DEBUG 2.21 #define LDBG(x) printf x
3.1 diff -r d4699dfddcc0 -r 3de372e4b230 semantics.c 3.2 --- a/semantics.c Sun Dec 30 16:29:50 2001 +0000 3.3 +++ b/semantics.c Sun Dec 30 17:09:08 2001 +0000 3.4 @@ -1,24 +1,55 @@ 3.5 +#include <stdlib.h> 3.6 +#include <string.h> 3.7 #include <stdio.h> 3.8 3.9 #include "type.h" 3.10 +#include "semantics.h" 3.11 #include "parser.tab.h" 3.12 -#include "semantics.h" 3.13 3.14 3.15 FILE *yyin; 3.16 int line; /* line number in spec file */ 3.17 3.18 3.19 -int input_count; /* total input pages in spec */ 3.20 -int output_count; /* total output pages in spec */ 3.21 +int input_page_count; /* total input pages in spec */ 3.22 +int output_page_count; /* total output pages in spec */ 3.23 + 3.24 + 3.25 +input_context_t *current_input_context; 3.26 3.27 3.28 void input_push_context (input_context_type_t type) 3.29 { 3.30 + input_context_t *new_input_context; 3.31 + 3.32 + new_input_context = malloc (sizeof (input_context_t)); 3.33 + if (! new_input_context) 3.34 + { 3.35 + fprintf (stderr, "failed to calloc an input context\n"); 3.36 + return; 3.37 + } 3.38 + 3.39 + if (current_input_context) 3.40 + { 3.41 + memcpy (new_input_context, current_input_context, sizeof (input_context_t)); 3.42 + new_input_context->page_count = 0; 3.43 + } 3.44 + else 3.45 + memset (new_input_context, 0, sizeof (input_context_t)); 3.46 + 3.47 + new_input_context->parent_input_context = current_input_context; 3.48 + current_input_context = new_input_context; 3.49 }; 3.50 3.51 void input_pop_context (void) 3.52 { 3.53 + if (! current_input_context) 3.54 + { 3.55 + fprintf (stderr, "failed to pop an input context\n"); 3.56 + return; 3.57 + } 3.58 + 3.59 + current_input_context = current_input_context->parent_input_context; 3.60 }; 3.61 3.62 void input_set_file (char *name) 3.63 @@ -27,20 +58,25 @@ 3.64 3.65 void input_images (int first, int last) 3.66 { 3.67 - input_count += ((last - first) + 1); 3.68 + input_page_count += ((last - first) + 1); 3.69 if (first == last) 3.70 printf ("image %d\n", first); 3.71 else 3.72 - printf ("iamges %d..%d\n", first, last); 3.73 + printf ("images %d..%d\n", first, last); 3.74 } 3.75 3.76 + 3.77 +void output_push_context (void) 3.78 +{ 3.79 +}; 3.80 + 3.81 void output_set_file (char *name) 3.82 { 3.83 }; 3.84 3.85 void output_pages (int first, int last) 3.86 { 3.87 - output_count += ((last - first) + 1); 3.88 + output_page_count += ((last - first) + 1); 3.89 if (first == last) 3.90 printf ("page %d\n", first); 3.91 else 3.92 @@ -67,8 +103,20 @@ 3.93 3.94 line = 1; 3.95 3.96 + input_push_context (INPUT_CONTEXT_ALL); /* create initial input context */ 3.97 + output_push_context (); /* create initial output context */ 3.98 + 3.99 yyparse (); 3.100 3.101 + if (input_page_count != output_page_count) 3.102 + { 3.103 + fprintf (stderr, "input page count %d != output page count %d\n", 3.104 + input_page_count, output_page_count); 3.105 + goto fail; 3.106 + } 3.107 + 3.108 + fprintf (stderr, "%d pages specified\n", input_page_count); 3.109 + 3.110 result = 1; 3.111 3.112 fail:
4.1 diff -r d4699dfddcc0 -r 3de372e4b230 semantics.h 4.2 --- a/semantics.h Sun Dec 30 16:29:50 2001 +0000 4.3 +++ b/semantics.h Sun Dec 30 17:09:08 2001 +0000 4.4 @@ -1,3 +1,23 @@ 4.5 +typedef struct 4.6 +{ 4.7 + double width; 4.8 + double height; 4.9 +} page_size_t; 4.10 + 4.11 +typedef struct 4.12 +{ 4.13 + int first; 4.14 + int last; 4.15 + } range_t; 4.16 + 4.17 +typedef struct 4.18 +{ 4.19 + double left; 4.20 + double right; 4.21 + double top; 4.22 + double bottom; 4.23 +} crop_t; 4.24 + 4.25 typedef enum 4.26 { 4.27 INPUT_CONTEXT_ALL, 4.28 @@ -6,11 +26,44 @@ 4.29 } input_context_type_t; 4.30 4.31 4.32 +typedef struct 4.33 +{ 4.34 + boolean has_size; 4.35 + page_size_t size; 4.36 + 4.37 + boolean has_rotation; 4.38 + int rotation; 4.39 + 4.40 + boolean has_crop; 4.41 + crop_t crop; 4.42 +} input_modifiers_t; 4.43 + 4.44 + 4.45 +typedef enum 4.46 +{ 4.47 + INPUT_MODIFIER_ALL, 4.48 + INPUT_MODIFIER_ODD, 4.49 + INPUT_MODIFIER_EVEN, 4.50 + INPUT_MODIFIER_TYPE_COUNT /* must be last */ 4.51 +} input_modifier_type_t; 4.52 + 4.53 + 4.54 +typedef struct input_context_t 4.55 +{ 4.56 + struct input_context_t *parent_input_context; 4.57 + 4.58 + int page_count; /* how many pages reference this context, 4.59 + including those from subcontexts */ 4.60 + 4.61 + input_modifiers_t modifiers [INPUT_MODIFIER_TYPE_COUNT]; 4.62 +} input_context_t; 4.63 + 4.64 + 4.65 extern int line; /* line number in spec file */ 4.66 4.67 4.68 -extern int input_count; /* total input pages in spec */ 4.69 -extern int output_count; /* total output pages in spec */ 4.70 +extern int input_page_count; /* total input pages in spec */ 4.71 +extern int output_page_count; /* total output pages in spec */ 4.72 4.73 4.74 boolean parse_spec_file (char *fn);
5.1 diff -r d4699dfddcc0 -r 3de372e4b230 t2p.c 5.2 --- a/t2p.c Sun Dec 30 16:29:50 2001 +0000 5.3 +++ b/t2p.c Sun Dec 30 17:09:08 2001 +0000 5.4 @@ -1,7 +1,7 @@ 5.5 /* 5.6 * tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4 5.7 * Main program 5.8 - * $Id: t2p.c,v 1.4 2001/12/30 08:29:50 eric Exp $ 5.9 + * $Id: t2p.c,v 1.5 2001/12/30 09:09:08 eric Exp $ 5.10 * Copyright 2001 Eric Smith <eric@brouhaha.com> 5.11 * 5.12 * This program is free software; you can redistribute it and/or modify 5.13 @@ -28,8 +28,8 @@ 5.14 5.15 #include "type.h" 5.16 #include "bitblt.h" 5.17 +#include "semantics.h" 5.18 #include "parser.tab.h" 5.19 -#include "semantics.h" 5.20 #include "tiff2pdf.h" 5.21 5.22
6.1 diff -r d4699dfddcc0 -r 3de372e4b230 tumble.c 6.2 --- a/tumble.c Sun Dec 30 16:29:50 2001 +0000 6.3 +++ b/tumble.c Sun Dec 30 17:09:08 2001 +0000 6.4 @@ -1,7 +1,7 @@ 6.5 /* 6.6 * tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4 6.7 * Main program 6.8 - * $Id: tumble.c,v 1.4 2001/12/30 08:29:50 eric Exp $ 6.9 + * $Id: tumble.c,v 1.5 2001/12/30 09:09:08 eric Exp $ 6.10 * Copyright 2001 Eric Smith <eric@brouhaha.com> 6.11 * 6.12 * This program is free software; you can redistribute it and/or modify 6.13 @@ -28,8 +28,8 @@ 6.14 6.15 #include "type.h" 6.16 #include "bitblt.h" 6.17 +#include "semantics.h" 6.18 #include "parser.tab.h" 6.19 -#include "semantics.h" 6.20 #include "tiff2pdf.h" 6.21 6.22