From 5b48b537a2eaf06d4e40dfe25541afa54b1dbf3f Mon Sep 17 00:00:00 2001 From: Eric Smith Date: Sat, 29 Dec 2001 18:59:47 +0000 Subject: [PATCH] *** empty log message *** --- Makefile | 8 +++++--- parser.y | 13 +++++++++---- scanner.l | 12 +++++++++--- t2p.c | 14 ++++++++++---- tumble.c | 14 ++++++++++---- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index ddaa6e6..297c99b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # tiff2pdf: build a PDF file out of one or more TIFF Class F Group 4 files # Makefile -# $Id: Makefile,v 1.4 2001/12/29 09:44:27 eric Exp $ +# $Id: Makefile,v 1.5 2001/12/29 10:59:17 eric Exp $ # Copyright 2001 Eric Smith # # This program is free software; you can redistribute it and/or modify @@ -24,12 +24,14 @@ LDLIBS = -g -ltiff -lm -L/usr/local/lib/panda -lpanda -lpng YACC = bison YFLAGS = -d -v +SRCS = bitblt.c bitblt_test.c tiff2pdf.c +HDRS = type.h bitblt.h tiff2pdf.h +MISC = Makefile scanner.l parser.y + tiff2pdf: tiff2pdf.o scanner.o parser.tab.o bitblt_test: bitblt_test.o bitblt.o -pandamain: pandamain.o - %.tab.c %.tab.h: %.y $(YACC) $(YFLAGS) $< diff --git a/parser.y b/parser.y index 6ae119a..02a4d81 100644 --- a/parser.y +++ b/parser.y @@ -73,8 +73,8 @@ image_ranges: | image_ranges ',' range ; -file_clause: - FILE_KEYWORD STRING ';' ; +input_file_clause: + FILE_KEYWORD STRING ';' { open_tiff_input_file ($2) } ; image_clause: IMAGE INTEGER ';' @@ -135,7 +135,7 @@ part_clauses: | part_clauses part_clause; input_clause: - file_clause + input_file_clause | image_clause | images_clause | modifier_clause @@ -151,6 +151,9 @@ input_clause_list: input_statement: INPUT input_clauses ; +output_file_clause: + FILE_KEYWORD STRING ';' { open_pdf_output_file ($2) } ; + page_ranges: range | page_ranges ',' range ; @@ -168,7 +171,9 @@ bookmark_clause: | BOOKMARK STRING ';' ; output_clause: - page_clause | pages_clause | bookmark_clause + output_file_clause + | page_clause | pages_clause + | bookmark_clause | output_clause_list ; output_clauses: diff --git a/scanner.l b/scanner.l index 565b389..2adc6b4 100644 --- a/scanner.l +++ b/scanner.l @@ -1,8 +1,13 @@ +/* +$Id: scanner.l,v 1.6 2001/12/29 10:59:33 eric Exp $ +*/ + %option case-insensitive %{ #include "parser.tab.h" -}% +%} + digit [0-9] alpha [a-zA-Z] @@ -12,7 +17,7 @@ alpha [a-zA-Z] \.\. { return (ELIPSIS); } {digit}+ { yylval.integer = atoi (yytext); return (INTEGER); } -{digit}+.{digit}* { yylval.float = atof (yytext); return (FLOAT); } +{digit}+.{digit}* { yylval.fp = atof (yytext); return (FLOAT); } a { yylval.size.width = 8.5 * 25.4; yylval.size.height = 11.0 * 25.4; @@ -50,7 +55,7 @@ resolution { return (RESOLUTION) ; } rotate { return (ROTATE); } size { return (SIZE); } -\".*\" { yylval.string = newstr (yytext); return (STRING); } +\".*\" { yylval.string = strdup (yytext); return (STRING); } [ \t\n]+ /* whitespace */ @@ -58,3 +63,4 @@ size { return (SIZE); } . { printf( "Unrecognized character: %s\n", yytext ); } +%% diff --git a/t2p.c b/t2p.c index 8b5f2cb..a50b4b0 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.1 2001/12/29 09:44:24 eric Exp $ + * $Id: t2p.c,v 1.2 2001/12/29 10:59:47 eric Exp $ * Copyright 2001 Eric Smith * * This program is free software; you can redistribute it and/or modify @@ -32,6 +32,7 @@ #include "tiff2pdf.h" +FILE *yyin; TIFF *in; panda_pdf *out; @@ -206,10 +207,14 @@ boolean process_page (int image) /* range 1 .. n */ } +void yyerror (char *s) +{ + fprintf (stderr, "%s\n", s); +} + int main (int argc, char *argv[]) { - FILE *spec; int result = 0; panda_init (); @@ -221,8 +226,8 @@ int main (int argc, char *argv[]) goto fail; } - spec = fopen (argv [2], "r"); - if (! spec) + yyin = fopen (argv [2], "r"); + if (! yyin) { fprintf (stderr, "can't open spec file '%s'\n", argv [2]); result = 3; @@ -232,6 +237,7 @@ int main (int argc, char *argv[]) yyparse (); fail: + fclose (yyin); close_tiff_input_file (); close_pdf_output_file (); return (result); diff --git a/tumble.c b/tumble.c index 8cdae13..2431c9d 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.1 2001/12/29 09:44:24 eric Exp $ + * $Id: tumble.c,v 1.2 2001/12/29 10:59:47 eric Exp $ * Copyright 2001 Eric Smith * * This program is free software; you can redistribute it and/or modify @@ -32,6 +32,7 @@ #include "tiff2pdf.h" +FILE *yyin; TIFF *in; panda_pdf *out; @@ -206,10 +207,14 @@ boolean process_page (int image) /* range 1 .. n */ } +void yyerror (char *s) +{ + fprintf (stderr, "%s\n", s); +} + int main (int argc, char *argv[]) { - FILE *spec; int result = 0; panda_init (); @@ -221,8 +226,8 @@ int main (int argc, char *argv[]) goto fail; } - spec = fopen (argv [2], "r"); - if (! spec) + yyin = fopen (argv [2], "r"); + if (! yyin) { fprintf (stderr, "can't open spec file '%s'\n", argv [2]); result = 3; @@ -232,6 +237,7 @@ int main (int argc, char *argv[]) yyparse (); fail: + fclose (yyin); close_tiff_input_file (); close_pdf_output_file (); return (result);