9 a state machine for interpreting big5 (hk format).
12 big5proc(int c, Rune **r, long input_loc)
14 static enum { state0, state1 } state = state0;
16 long n, ch, f, cold = c;
20 case state0: /* idle state */
33 case state1: /* seen a font spec */
34 if(c >= 64 && c <= 126)
36 else if(c >= 161 && c <= 254)
41 warn("bad big5 glyph (from 0x%x,0x%lx) near byte %ld in %s",
42 lastc, cold, input_loc, file);
48 if(lastc >= 161 && lastc <= 254)
53 warn("bad big5 font %d (from 0x%x,0x%lx) near byte %ld in %s",
54 lastc-161, lastc, cold, input_loc, file);
68 warn("unknown big5 %ld (from 0x%x,0x%lx) near byte %ld in %s",
69 n, lastc, cold, input_loc, file);
79 big5_in(int fd, long *, struct convert *out)
90 while((n = read(fd, ibuf, sizeof ibuf)) > 0){
91 for(i = 0; i < n; i++){
92 big5proc(ibuf[i], &r, nin++);
103 big5proc(-1, &r, nin);
110 big5_out(Rune *base, int n, long *)
115 static int first = 1;
119 for(i = 0; i < NRUNE; i++)
121 for(i = 0; i < BIG5MAX; i++)
127 for(i = 0; i < n; i++){
132 if(r < NRUNE && tab[r] != -1){
139 *p++ = 0xA1 + (r/BIG5FONT);
148 warn("rune 0x%x not in output cs", r);
157 write(1, obuf, p-obuf);