|
|
1.1 root 1: /* takes the output fromt slvg | sort and puts it back into
2: * form suitable for btbuild -R
3: * it reduces the two byte codes, and it only keeps the
4: * last version of each record.
5: * the input format is
6: * key tab 8-bytes-of-sequence 4-byete-of-value-len value newline
7: */
8: #include "stdio.h"
9: #define BUF 20000
10: char bufa[BUF], bufb[BUF];
11: char *old = bufa;
12: char *new = bufb;
13: int len;
14:
15: main()
16: { char *p, *q;
17: int c, i;
18: loop:
19: for(p = new; (c = getchar()) != '\t' && c != EOF; *p++ = c)
20: if(p - new >= BUF) {
21: fprintf(stderr, "recompile slvg2 with more BUF\n");
22: exit(1);
23: }
24: if(c == EOF)
25: exit(0);
26: *p++ = 0;
27: for(i = 0; i < 8; i++)
28: getchar();
29: if((p - new != len || strcmp(old, new) != 0) && len > 0) {
30: out(old);
31: dorest();
32: }
33: len = p - new;
34: q = old;
35: old = new;
36: new = q;
37: ignore();
38: goto loop;
39: }
40:
41: out(s)
42: char *s;
43: { short n;
44: char c;
45: n = (len - 1)/2;
46: fwrite((char *)&n, 1, 2, stdout);
47: for(; *s; s++) {
48: c = (*s - '3') << 6;
49: c |= *++s- ' ';
50: putchar(c);
51: }
52: }
53:
54: ignore()
55: { int c;
56: while((c = getchar()) != '\n' && c != EOF)
57: ;
58: if(c == EOF)
59: exit(0);
60: }
61:
62: dorest()
63: { unsigned short n;
64: int i;
65: /* 4 bytes of length */
66: for(i = n = 0; i < 4; i++)
67: n |= (getchar() - 'a') << (4*i);
68: fwrite((char *)&n, 1, 2, stdout);
69: while((i = getchar()) != '\n' && i != EOF) {
70: n = (i - '3') << 6;
71: n |= getchar() - ' ';
72: putchar(n);
73: }
74: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.