1 /* Copyright 2007, 2008 Taco Hoekwater.
2 You may freely use, modify and/or distribute this file. */
13 static const char __svn_version
[] =
14 "$Id: makecpool.c 1230 2008-05-03 11:11:32Z oneiros $ $URL: svn://scm.foundry.supelec.fr/svn/luatex/trunk/src/texk/web2c/luatexdir/makecpool.c $";
16 int main(int argc
, char *argv
[])
25 setmode(fileno(stdout
), _O_BINARY
);
29 "%s: need exactly one argument (base name).\n",
33 strcpy(filename
, argv
[1]);
34 strcat(filename
, ".pool");
35 fh
= fopen(filename
, "r");
37 fprintf(stderr
, "%s: can't open %s for reading.\n", argv
[0], filename
);
40 if (strstr(filename
, "luatex.pool") != NULL
)
42 else if (strstr(filename
, "mf.pool") != NULL
)
45 " * This file is auto-generated by makecpool.\n"
49 "#define EXTERN extern\n"
50 "#include \"%sd.h\"\n"
51 "#include <stdio.h>\n"
52 "#include <string.h>\n"
54 "static const char *poolfilearr[] = {\n", argv
[0], argv
[1], argv
[1]);
55 while (fgets(data
, 1024, fh
)) {
57 int len
= strlen(data
);
58 int o
= 0; /* skip first bytes */
59 if (data
[len
- 1] == '\n') {
65 if (data
[0] >= '0' && data
[0] <= '9' && data
[1] >= '0'
70 for (i
= o
; i
< len
; i
++) {
71 if (data
[i
] == '"' || data
[i
] == '\\')
74 printf("\" \""); /* suppress trigraphs */
81 "int loadpoolstrings (integer spare_size) {\n"
85 " while ((s = poolfilearr[j++])) {\n"
86 " int l = strlen (s);\n"
87 " i += l;\n" " if (i>=spare_size) return 0;\n");
89 printf(" while (l-- > 0) str_pool[pool_ptr++] = *s++;\n"
90 " g = make_string();\n");
92 printf(" while (l-- > 0) strpool[poolptr++] = *s++;\n"
93 " g = makestring();\n");
95 printf(" strref[g]= 127;\n");
96 printf(" }\n" " return g;\n" "}\n");