Wed, 12 Mar 2003 06:39:22 +0000
changed bitblt_table_gen.c to generate both a header and a C source file (bitblt_tables.[ch]).
Makefile | file | annotate | diff | revisions | |
bitblt_table_gen.c | file | annotate | diff | revisions |
1.1 diff -r 25c6b1a63f93 -r f2e13c2ff575 Makefile 1.2 --- a/Makefile Wed Mar 12 06:02:46 2003 +0000 1.3 +++ b/Makefile Wed Mar 12 06:39:22 2003 +0000 1.4 @@ -1,6 +1,6 @@ 1.5 # t2p: build a PDF file out of one or more TIFF Class F Group 4 files 1.6 # Makefile 1.7 -# $Id: Makefile,v 1.21 2003/03/10 01:49:49 eric Exp $ 1.8 +# $Id: Makefile,v 1.22 2003/03/11 22:39:22 eric Exp $ 1.9 # Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 1.10 # 1.11 # This program is free software; you can redistribute it and/or modify 1.12 @@ -65,7 +65,7 @@ 1.13 bitblt.c bitblt_table_gen.c bitblt_g4.c g4_table_gen.c \ 1.14 pdf.c pdf_util.c pdf_prim.c pdf_bookmark.c pdf_name_tree.c pdf_g4.c 1.15 OSRCS = scanner.l parser.y 1.16 -HDRS = t2p.h semantics.h bitblt.h \ 1.17 +HDRS = t2p.h semantics.h bitblt.h bitblt_tables.h \ 1.18 pdf.h pdf_private.h pdf_util.h pdf_prim.h pdf_name_tree.h 1.19 MISC = COPYING Makefile 1.20 1.21 @@ -73,9 +73,9 @@ 1.22 DISTNAME = $(PACKAGE)-$(VERSION) 1.23 1.24 1.25 -AUTO_CSRCS = scanner.c parser.tab.c 1.26 -AUTO_HDRS = parser.tab.h bitblt_tables.h g4_tables.h 1.27 -AUTO_MISC = parser.output 1.28 +AUTO_CSRCS = scanner.c parser.tab.c bitblt_tables.c 1.29 +AUTO_HDRS = parser.tab.h g4_tables.h 1.30 +AUTO_MISC = parser.output bitblt_tables.h 1.31 1.32 1.33 -include Maketest 1.34 @@ -84,7 +84,8 @@ 1.35 all: $(TARGETS) $(TEST_TARGETS) 1.36 1.37 1.38 -t2p: t2p.o scanner.o semantics.o parser.tab.o bitblt.o bitblt_g4.o \ 1.39 +t2p: t2p.o scanner.o semantics.o parser.tab.o \ 1.40 + bitblt.o bitblt_g4.o bitblt_tables.o \ 1.41 pdf.o pdf_util.o pdf_prim.o pdf_bookmark.o pdf_name_tree.o \ 1.42 pdf_g4.o 1.43 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ 1.44 @@ -94,7 +95,10 @@ 1.45 1.46 1.47 bitblt_tables.h: bitblt_table_gen 1.48 - ./bitblt_table_gen >bitblt_tables.h 1.49 + ./bitblt_table_gen -h >bitblt_tables.h 1.50 + 1.51 +bitblt_tables.c: bitblt_table_gen 1.52 + ./bitblt_table_gen -c >bitblt_tables.c 1.53 1.54 bitblt_table_gen: bitblt_table_gen.o 1.55
2.1 diff -r 25c6b1a63f93 -r f2e13c2ff575 bitblt_table_gen.c 2.2 --- a/bitblt_table_gen.c Wed Mar 12 06:02:46 2003 +0000 2.3 +++ b/bitblt_table_gen.c Wed Mar 12 06:39:22 2003 +0000 2.4 @@ -4,7 +4,7 @@ 2.5 * will be compressed using ITU-T T.6 (G4) fax encoding. 2.6 * 2.7 * bitblt table generator 2.8 - * $Id: bitblt_table_gen.c,v 1.4 2003/03/05 12:44:33 eric Exp $ 2.9 + * $Id: bitblt_table_gen.c,v 1.5 2003/03/11 22:39:22 eric Exp $ 2.10 * Copyright 2003 Eric Smith <eric@brouhaha.com> 2.11 * 2.12 * This program is free software; you can redistribute it and/or modify 2.13 @@ -24,13 +24,23 @@ 2.14 */ 2.15 2.16 2.17 +#include <stdbool.h> 2.18 #include <stdio.h> 2.19 +#include <stdlib.h> 2.20 2.21 -void gen_bit_reverse_table (void) 2.22 +void gen_bit_reverse_table (bool header) 2.23 { 2.24 int i, j; 2.25 2.26 - printf ("static const uint8_t bit_reverse_byte [0x100] =\n"); 2.27 + if (header) 2.28 + printf ("extern "); 2.29 + printf ("const uint8_t bit_reverse_byte [0x100]"); 2.30 + if (header) 2.31 + { 2.32 + printf (";\n"); 2.33 + return; 2.34 + } 2.35 + printf (" =\n"); 2.36 printf ("{\n"); 2.37 for (i = 0; i < 0x100; i++) 2.38 { 2.39 @@ -73,11 +83,19 @@ 2.40 } 2.41 2.42 2.43 -void gen_run_length_table (int val, char *name) 2.44 +void gen_run_length_table (bool header, int val, char *name) 2.45 { 2.46 int i, j; 2.47 2.48 - printf ("static const uint8_t %s [8][256] =\n", name); 2.49 + if (header) 2.50 + printf ("extern "); 2.51 + printf ("const uint8_t %s [8][256]", name); 2.52 + if (header) 2.53 + { 2.54 + printf (";\n"); 2.55 + return; 2.56 + } 2.57 + printf (" =\n"); 2.58 printf ("{\n"); 2.59 for (i = 0; i < 8; i++) 2.60 { 2.61 @@ -105,15 +123,38 @@ 2.62 2.63 int main (int argc, char *argv[]) 2.64 { 2.65 + bool header; 2.66 + 2.67 + if (argc != 2) 2.68 + { 2.69 + fprintf (stderr, "wrong arg count\n"); 2.70 + exit (2); 2.71 + } 2.72 + if (strcmp (argv [1], "-h") == 0) 2.73 + header = 1; 2.74 + else if (strcmp (argv [1], "-c") == 0) 2.75 + header = 0; 2.76 + else 2.77 + { 2.78 + fprintf (stderr, "wrong args\n"); 2.79 + exit (2); 2.80 + } 2.81 + 2.82 printf ("/* This file is automatically generated; do not edit */\n"); 2.83 printf ("\n"); 2.84 2.85 - gen_bit_reverse_table (); 2.86 + if (! header) 2.87 + { 2.88 + printf ("#include <stdint.h>\n"); 2.89 + printf ("#include \"bitblt_tables.h\"\n"); 2.90 + printf ("\n"); 2.91 + } 2.92 + 2.93 + gen_bit_reverse_table (header); 2.94 printf ("\n"); 2.95 2.96 - gen_run_length_table (0, "rle_tab"); 2.97 + gen_run_length_table (header, 0, "rle_tab"); 2.98 printf ("\n"); 2.99 2.100 return (0); 2.101 } 2.102 -