OSDN Git Service

TortoiseMerge Basic Support Git patch created by format patch
[tortoisegit/TortoiseGitJp.git] / src / TortoiseMerge / libsvn_diff / maketree.c
1 /* maketree.c -- make inffixed.h table for decoding fixed codes\r
2  * Copyright (C) 1995-2002 Mark Adler\r
3  * For conditions of distribution and use, see copyright notice in zlib.h \r
4  */\r
5 \r
6 /* WARNING: this file should *not* be used by applications. It is\r
7    part of the implementation of the compression library and is\r
8    subject to change. Applications should only use zlib.h.\r
9  */\r
10 \r
11 /* This program is included in the distribution for completeness.\r
12    You do not need to compile or run this program since inffixed.h\r
13    is already included in the distribution.  To use this program\r
14    you need to compile zlib with BUILDFIXED defined and then compile\r
15    and link this program with the zlib library.  Then the output of\r
16    this program can be piped to inffixed.h. */\r
17 \r
18 #include <stdio.h>\r
19 #include <stdlib.h>\r
20 #include "zutil.h"\r
21 #include "inftrees.h"\r
22 \r
23 /* simplify the use of the inflate_huft type with some defines */\r
24 #define exop word.what.Exop\r
25 #define bits word.what.Bits\r
26 \r
27 /* generate initialization table for an inflate_huft structure array */\r
28 void maketree(uInt b, inflate_huft *t)\r
29 {\r
30   int i, e;\r
31 \r
32   i = 0;\r
33   while (1)\r
34   {\r
35     e = t[i].exop;\r
36     if (e && (e & (16+64)) == 0)        /* table pointer */\r
37     {\r
38       fprintf(stderr, "maketree: cannot initialize sub-tables!\n");\r
39       exit(1);\r
40     }\r
41     if (i % 4 == 0)\r
42       printf("\n   ");\r
43     printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base);\r
44     if (++i == (1<<b))\r
45       break;\r
46     putchar(',');\r
47   }\r
48   puts("");\r
49 }\r
50 \r
51 /* create the fixed tables in C initialization syntax */\r
52 void main(void)\r
53 {\r
54   int r;\r
55   uInt bl, bd;\r
56   inflate_huft *tl, *td;\r
57   z_stream z;\r
58 \r
59   z.zalloc = zcalloc;\r
60   z.opaque = (voidpf)0;\r
61   z.zfree = zcfree;\r
62   r = inflate_trees_fixed(&bl, &bd, &tl, &td, &z);\r
63   if (r)\r
64   {\r
65     fprintf(stderr, "inflate_trees_fixed error %d\n", r);\r
66     return;\r
67   }\r
68   puts("/* inffixed.h -- table for decoding fixed codes");\r
69   puts(" * Generated automatically by the maketree.c program");\r
70   puts(" */");\r
71   puts("");\r
72   puts("/* WARNING: this file should *not* be used by applications. It is");\r
73   puts("   part of the implementation of the compression library and is");\r
74   puts("   subject to change. Applications should only use zlib.h.");\r
75   puts(" */");\r
76   puts("");\r
77   printf("local uInt fixed_bl = %d;\n", bl);\r
78   printf("local uInt fixed_bd = %d;\n", bd);\r
79   printf("local inflate_huft fixed_tl[] = {");\r
80   maketree(bl, tl);\r
81   puts("  };");\r
82   printf("local inflate_huft fixed_td[] = {");\r
83   maketree(bd, td);\r
84   puts("  };");\r
85 }\r