15 a state machine for interpreting big5 (hk format).
18 big5proc(int c, Rune **r, long input_loc)
20 static enum { state0, state1 } state = state0;
22 long n, ch, f, cold = c;
26 case state0: /* idle state */
39 case state1: /* seen a font spec */
40 if(c >= 64 && c <= 126)
42 else if(c >= 161 && c <= 254)
47 EPR "%s: bad big5 glyph (from 0x%x,0x%lx) near byte %ld in %s\n",
48 argv0, lastc, cold, input_loc, file);
54 if(lastc >= 161 && lastc <= 254)
59 EPR "%s: bad big5 font %d (from 0x%x,0x%lx) near byte %ld in %s\n",
60 argv0, lastc-161, lastc, cold, input_loc, file);
74 EPR "%s: unknown big5 %ld (from 0x%x,0x%lx) near byte %ld in %s\n",
75 argv0, n, lastc, cold, input_loc, file);
85 big5_in(int fd, long *notused, struct convert *out)
97 while((n = read(fd, ibuf, sizeof ibuf)) > 0){
98 for(i = 0; i < n; i++){
99 big5proc(ibuf[i], &r, nin++);
110 big5proc(-1, &r, nin);
117 big5_out(Rune *base, int n, long *notused)
122 static int first = 1;
127 for(i = 0; i < NRUNE; i++)
129 for(i = 0; i < BIG5MAX; i++)
135 for(i = 0; i < n; i++){
147 *p++ = 0xA1 + (r/BIG5FONT);
156 EPR "%s: rune 0x%x not in output cs\n", argv0, r);
165 write(1, obuf, p-obuf);