summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/mpdir/makecpool.c
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2006-11-20 14:43:48 +0000
committerTaco Hoekwater <taco@elvenkind.com>2006-11-20 14:43:48 +0000
commit5952e40b396499c0cd62bdbcf1853538873b76c1 (patch)
tree968b37e966ba1825e2de091a071774af1a7ffa9b /Build/source/texk/web2c/mpdir/makecpool.c
parent9fcf4d90b8b3a11712287d4ddf3fd47614a7ea68 (diff)
Metapost 0.99 sources, except dmp
git-svn-id: svn://tug.org/texlive/trunk@2470 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/mpdir/makecpool.c')
-rw-r--r--Build/source/texk/web2c/mpdir/makecpool.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/mpdir/makecpool.c b/Build/source/texk/web2c/mpdir/makecpool.c
new file mode 100644
index 00000000000..02ce0f94bea
--- /dev/null
+++ b/Build/source/texk/web2c/mpdir/makecpool.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[]) {
+ if (argc!=3) {
+ puts("Need exactly two arguments: pool_name and header_name");
+ exit(1);
+ }
+ char *filename = argv[1];
+ char *headername = argv[2];
+ FILE *fh = fopen(filename,"r");
+ char data[1024];
+ printf(
+ "/* This file is auto-generated by makecpool */\n"
+ "\n"
+ "#include <stdio.h>\n"
+ "#include \"%s\"\n"
+ "\n"
+ "static char *poolfilearr[] = {\n",headername);
+ while (fgets(data,1024,fh)) {
+ int len = strlen(data);
+ int o = 0; // skip first o characters
+ int i;
+ if (data[len-1]=='\n') { // chomp;
+ data[len-1] = 0;
+ len--;
+ }
+ if (data[0]=='*') break; // last if /^\*/;
+ if (data[0]>='0' && data[0]<='9' && data[1]>='0' && data[1]<='9') {
+ o=2; // $data =~ s/^\d\d//;
+ }
+ printf(" \"");
+ for (i=o; i<len; i++) {
+ if (data[i]=='"' || data[i]=='\\') putchar('\\');
+ if (data[i]=='?') printf("\" \""); /* suppress trigraphs */
+ putchar(data[i]);
+ } // $data =~ s/(["\\])/\\$1/g;
+ printf("\",\n");
+ }
+ fclose(fh);
+ printf(" NULL };\n"
+ "int loadpoolstrings (integer spare_size) {\n"
+ " strnumber g=0;\n"
+ " int i=0,j=0;\n"
+ " char *s;\n"
+ " while ((s = poolfilearr[j++])) {\n"
+ " int l = strlen (s);\n"
+ " i += l;\n"
+ " if (i>=spare_size) return 0;\n"
+ " while (l-- > 0) strpool[poolptr++] = *s++;\n"
+ " g = makestring();\n"
+ " strref[g]= 127;\n"
+ " }\n"
+ " return g;\n"
+ "}\n");
+ return 0;
+}