*** empty log message ***

Sun, 30 Dec 2001 04:16:46 +0000

author
eric
date
Sun, 30 Dec 2001 04:16:46 +0000
changeset 15
dda3d673b82b
parent 14
4c261fbf8c77
child 16
dbf5e39b1658

*** empty log message ***

Makefile file | annotate | diff | revisions
parser.y file | annotate | diff | revisions
scanner.l file | annotate | diff | revisions
t2p.h file | annotate | diff | revisions
tumble.h file | annotate | diff | revisions
     1.1 --- a/Makefile	Sun Dec 30 04:16:46 2001 +0000
     1.2 +++ b/Makefile	Sun Dec 30 04:16:46 2001 +0000
     1.3 @@ -1,6 +1,6 @@
     1.4  # tiff2pdf: build a PDF file out of one or more TIFF Class F Group 4 files
     1.5  # Makefile
     1.6 -# $Id: Makefile,v 1.5 2001/12/29 10:59:17 eric Exp $
     1.7 +# $Id: Makefile,v 1.6 2001/12/29 20:16:46 eric Exp $
     1.8  # Copyright 2001 Eric Smith <eric@brouhaha.com>
     1.9  #
    1.10  # This program is free software; you can redistribute it and/or modify
    1.11 @@ -28,14 +28,33 @@
    1.12  HDRS = type.h bitblt.h tiff2pdf.h
    1.13  MISC = Makefile scanner.l parser.y
    1.14  
    1.15 +TARGETS = tiff2pdf bitblt_test
    1.16 +
    1.17 +AUTO_SRCS = scanner.c parser.tab.c
    1.18 +AUTO_HDRS = parser.tab.h
    1.19 +AUTO_MISC = parser.output
    1.20 +
    1.21  tiff2pdf: tiff2pdf.o scanner.o parser.tab.o
    1.22  
    1.23  bitblt_test: bitblt_test.o bitblt.o
    1.24  
    1.25  
    1.26 -%.tab.c %.tab.h: %.y
    1.27 +clean:
    1.28 +	rm -f *.o *.d $(TARGETS) $(AUTO_SRCS) $(AUTO_HDRS) $(AUTO_MISC) 
    1.29 +
    1.30 +
    1.31 +%.tab.c %.tab.h %.output: %.y
    1.32  	$(YACC) $(YFLAGS) $<
    1.33  
    1.34  # %.c: %.l
    1.35  # 	$(LEX) $(LFLAGS) $<
    1.36  
    1.37 +
    1.38 +ALL_SRCS = $(SRCS) $(AUTO_SRCS)
    1.39 +
    1.40 +DEPENDS = $(ALL_SRCS:.c=.d)
    1.41 +
    1.42 +%.d: %.c
    1.43 +	$(CC) -M -MG $(CFLAGS) $< | sed -e 's@ /[^ ]*@@g' -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
    1.44 +
    1.45 +include $(DEPENDS)
     2.1 --- a/parser.y	Sun Dec 30 04:16:46 2001 +0000
     2.2 +++ b/parser.y	Sun Dec 30 04:16:46 2001 +0000
     2.3 @@ -69,16 +69,16 @@
     2.4  	| INTEGER { $$.first = $1; $$.last = $1; } ;
     2.5  
     2.6  image_ranges:
     2.7 -	range
     2.8 -	| image_ranges ',' range ;
     2.9 +	range { input_images ($1.first, $1.last); }
    2.10 +	| image_ranges ',' range { input_images ($3.first, $3.last); } ;
    2.11  
    2.12  
    2.13  input_file_clause:
    2.14  	FILE_KEYWORD STRING  ';'  { open_tiff_input_file ($2) } ;
    2.15  
    2.16  image_clause:
    2.17 -	IMAGE INTEGER ';'
    2.18 -	| IMAGE INTEGER modifier_clause_list ';' ;
    2.19 +	IMAGE INTEGER ';' { input_images ($2, $2); }
    2.20 +	| IMAGE INTEGER modifier_clause_list ';' { input_images ($2, $2); } ;
    2.21  
    2.22  images_clause:
    2.23  	IMAGES image_ranges ';'
    2.24 @@ -155,12 +155,12 @@
    2.25  	FILE_KEYWORD STRING  ';' { open_pdf_output_file ($2) } ;
    2.26  
    2.27  page_ranges:
    2.28 -	range
    2.29 -	| page_ranges ',' range ;
    2.30 +	range { output_pages ($1.first, $1.last); }
    2.31 +	| page_ranges ',' range { output_pages ($3.first, $3.last); } ;
    2.32  
    2.33  page_clause:
    2.34 -	PAGE INTEGER ';'
    2.35 -	| PAGE STRING ',' INTEGER ';' ;
    2.36 +	PAGE INTEGER ';' { output_pages ($2, $2); }
    2.37 +	| PAGE STRING ',' INTEGER ';' { output_pages ($4, $4); } ;
    2.38  
    2.39  pages_clause:
    2.40  	PAGES page_ranges ';'
     3.1 --- a/scanner.l	Sun Dec 30 04:16:46 2001 +0000
     3.2 +++ b/scanner.l	Sun Dec 30 04:16:46 2001 +0000
     3.3 @@ -1,25 +1,36 @@
     3.4  /*
     3.5 -$Id: scanner.l,v 1.7 2001/12/29 17:54:43 eric Exp $
     3.6 +$Id: scanner.l,v 1.8 2001/12/29 20:16:46 eric Exp $
     3.7  */
     3.8  
     3.9  %option case-insensitive
    3.10  %option noyywrap
    3.11  
    3.12  %{
    3.13 +#include <stdio.h>
    3.14  #include <string.h>
    3.15  #include "parser.tab.h"
    3.16 +#include "type.h"
    3.17 +#include "tiff2pdf.h"
    3.18 +
    3.19 +#ifdef SCANNER_DEBUG
    3.20 +#define LDBG(x) printf x
    3.21 +#else
    3.22 +#define LDBG(x)
    3.23 +#endif
    3.24  %}
    3.25  
    3.26  
    3.27  digit [0-9]
    3.28  alpha [a-zA-Z]
    3.29 +dot [\.]
    3.30  
    3.31  %%
    3.32  
    3.33 -\.\.		{ return (ELIPSIS); }
    3.34 +[\,;{}]		{ return (yytext [0]); }
    3.35 +{dot}{dot}	{ LDBG(("elipsis\n")); return (ELIPSIS); }
    3.36  
    3.37 -{digit}+	{ yylval.integer = atoi (yytext); return (INTEGER); }
    3.38 -{digit}+.{digit}* { yylval.fp = atof (yytext); return (FLOAT); }
    3.39 +{digit}+	{ yylval.integer = atoi (yytext); LDBG(("integer %d\n", yylval.integer)); return (INTEGER); }
    3.40 +{digit}+\.{digit}+ { yylval.fp = atof (yytext); return (FLOAT); }
    3.41  
    3.42  a		{ yylval.size.width = 8.5 * 25.4;
    3.43  		  yylval.size.height = 11.0 * 25.4;
    3.44 @@ -57,12 +68,21 @@
    3.45  rotate		{ return (ROTATE); }
    3.46  size		{ return (SIZE); }
    3.47  
    3.48 -\".*\"		{ yylval.string = strdup (yytext); return (STRING); }
    3.49 +\".*\"		{ 
    3.50 +                  int len = strlen (yytext) - 2;
    3.51 +                  yylval.string = malloc (len + 1);
    3.52 +                  memcpy (yylval.string, yytext + 1, len);
    3.53 +                  yylval.string [len] = '\0';
    3.54 +		  LDBG (("string \"%s\"\n", yylval.string));
    3.55 +                  return (STRING);
    3.56 +                }
    3.57  
    3.58 -[ \t\n]+	/* whitespace */
    3.59 +[ \t]+		/* whitespace */
    3.60 +\n		{ line++; }
    3.61  
    3.62  --.*		/* Ada/VHDL style one-line comment */
    3.63 +#.*		/* shell-style one-line comment */
    3.64  
    3.65 -.		{ printf( "Unrecognized character: %s\n", yytext ); }
    3.66 +.		{ fprintf (stderr, "Unrecognized character: %s\n", yytext); }
    3.67  
    3.68  %%
     4.1 --- a/t2p.h	Sun Dec 30 04:16:46 2001 +0000
     4.2 +++ b/t2p.h	Sun Dec 30 04:16:46 2001 +0000
     4.3 @@ -1,3 +1,5 @@
     4.4 +extern int line;
     4.5 +
     4.6  boolean open_tiff_input_file (char *name);
     4.7  boolean close_tiff_input_file (void);
     4.8  
     4.9 @@ -5,3 +7,13 @@
    4.10  boolean close_pdf_output_file (void);
    4.11  
    4.12  boolean process_page (int image);  /* range 1 .. n */
    4.13 +
    4.14 +void input_images (int first, int last);
    4.15 +void output_pages (int first, int last);
    4.16 +
    4.17 +
    4.18 +
    4.19 +
    4.20 +
    4.21 +
    4.22 +
     5.1 --- a/tumble.h	Sun Dec 30 04:16:46 2001 +0000
     5.2 +++ b/tumble.h	Sun Dec 30 04:16:46 2001 +0000
     5.3 @@ -1,3 +1,5 @@
     5.4 +extern int line;
     5.5 +
     5.6  boolean open_tiff_input_file (char *name);
     5.7  boolean close_tiff_input_file (void);
     5.8  
     5.9 @@ -5,3 +7,13 @@
    5.10  boolean close_pdf_output_file (void);
    5.11  
    5.12  boolean process_page (int image);  /* range 1 .. n */
    5.13 +
    5.14 +void input_images (int first, int last);
    5.15 +void output_pages (int first, int last);
    5.16 +
    5.17 +
    5.18 +
    5.19 +
    5.20 +
    5.21 +
    5.22 +