diff --git a/parser.y b/parser.y index e4648b0..759efd3 100644 --- a/parser.y +++ b/parser.y @@ -1,7 +1,7 @@ %{ #include #include "type.h" - #include "tiff2pdf.h" + #include "semantics.h" %} %union { @@ -74,7 +74,7 @@ image_ranges: input_file_clause: - FILE_KEYWORD STRING ';' { open_tiff_input_file ($2) } ; + FILE_KEYWORD STRING ';' { input_set_file ($2) } ; image_clause: IMAGE INTEGER ';' { input_images ($2, $2); } @@ -152,7 +152,7 @@ input_statement: INPUT input_clauses ; output_file_clause: - FILE_KEYWORD STRING ';' { open_pdf_output_file ($2) } ; + FILE_KEYWORD STRING ';' { output_set_file ($2) } ; page_ranges: range { output_pages ($1.first, $1.last); } diff --git a/scanner.l b/scanner.l index 3fac259..81abb0c 100644 --- a/scanner.l +++ b/scanner.l @@ -1,5 +1,5 @@ /* -$Id: scanner.l,v 1.8 2001/12/29 20:16:46 eric Exp $ +$Id: scanner.l,v 1.9 2001/12/30 08:29:50 eric Exp $ */ %option case-insensitive @@ -10,7 +10,7 @@ $Id: scanner.l,v 1.8 2001/12/29 20:16:46 eric Exp $ #include #include "parser.tab.h" #include "type.h" -#include "tiff2pdf.h" +#include "semantics.h" #ifdef SCANNER_DEBUG #define LDBG(x) printf x diff --git a/t2p.c b/t2p.c index 04c05a4..6d61b11 100644 --- a/t2p.c +++ b/t2p.c @@ -1,7 +1,7 @@ /* * tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4 * Main program - * $Id: t2p.c,v 1.3 2001/12/29 20:16:46 eric Exp $ + * $Id: t2p.c,v 1.4 2001/12/30 08:29:50 eric Exp $ * Copyright 2001 Eric Smith * * This program is free software; you can redistribute it and/or modify @@ -29,12 +29,10 @@ #include "type.h" #include "bitblt.h" #include "parser.tab.h" +#include "semantics.h" #include "tiff2pdf.h" -int line; - -FILE *yyin; TIFF *in; panda_pdf *out; @@ -209,29 +207,6 @@ boolean process_page (int image) /* range 1 .. n */ } -void input_images (int first, int last) -{ - if (first == last) - printf ("image %d\n", first); - else - printf ("iamges %d..%d\n", first, last); -} - -void output_pages (int first, int last) -{ - if (first == last) - printf ("page %d\n", first); - else - printf ("pages %d..%d\n", first, last); -} - - -void yyerror (char *s) -{ - fprintf (stderr, "%d: %s\n", line, s); -} - - int main (int argc, char *argv[]) { int result = 0; @@ -245,21 +220,10 @@ int main (int argc, char *argv[]) goto fail; } - yyin = fopen (argv [1], "r"); - if (! yyin) - { - fprintf (stderr, "can't open spec file '%s'\n", argv [1]); - result = 3; - goto fail; - } - - line = 1; - - yyparse (); - + if (! parse_spec_file (argv [1])) + goto fail; + fail: - if (yyin) - fclose (yyin); close_tiff_input_file (); close_pdf_output_file (); return (result); diff --git a/t2p.h b/t2p.h index 0b6cd1b..f49fcaf 100644 --- a/t2p.h +++ b/t2p.h @@ -1,5 +1,3 @@ -extern int line; - boolean open_tiff_input_file (char *name); boolean close_tiff_input_file (void); @@ -8,9 +6,6 @@ boolean close_pdf_output_file (void); boolean process_page (int image); /* range 1 .. n */ -void input_images (int first, int last); -void output_pages (int first, int last); - diff --git a/tumble.c b/tumble.c index a17a833..0cd9b33 100644 --- a/tumble.c +++ b/tumble.c @@ -1,7 +1,7 @@ /* * tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4 * Main program - * $Id: tumble.c,v 1.3 2001/12/29 20:16:46 eric Exp $ + * $Id: tumble.c,v 1.4 2001/12/30 08:29:50 eric Exp $ * Copyright 2001 Eric Smith * * This program is free software; you can redistribute it and/or modify @@ -29,12 +29,10 @@ #include "type.h" #include "bitblt.h" #include "parser.tab.h" +#include "semantics.h" #include "tiff2pdf.h" -int line; - -FILE *yyin; TIFF *in; panda_pdf *out; @@ -209,29 +207,6 @@ boolean process_page (int image) /* range 1 .. n */ } -void input_images (int first, int last) -{ - if (first == last) - printf ("image %d\n", first); - else - printf ("iamges %d..%d\n", first, last); -} - -void output_pages (int first, int last) -{ - if (first == last) - printf ("page %d\n", first); - else - printf ("pages %d..%d\n", first, last); -} - - -void yyerror (char *s) -{ - fprintf (stderr, "%d: %s\n", line, s); -} - - int main (int argc, char *argv[]) { int result = 0; @@ -245,21 +220,10 @@ int main (int argc, char *argv[]) goto fail; } - yyin = fopen (argv [1], "r"); - if (! yyin) - { - fprintf (stderr, "can't open spec file '%s'\n", argv [1]); - result = 3; - goto fail; - } - - line = 1; - - yyparse (); - + if (! parse_spec_file (argv [1])) + goto fail; + fail: - if (yyin) - fclose (yyin); close_tiff_input_file (); close_pdf_output_file (); return (result); diff --git a/tumble.h b/tumble.h index 0b6cd1b..f49fcaf 100644 --- a/tumble.h +++ b/tumble.h @@ -1,5 +1,3 @@ -extern int line; - boolean open_tiff_input_file (char *name); boolean close_tiff_input_file (void); @@ -8,9 +6,6 @@ boolean close_pdf_output_file (void); boolean process_page (int image); /* range 1 .. n */ -void input_images (int first, int last); -void output_pages (int first, int last); -