When documenting s0 and s1, get then the right way around.
[sgt/charset] / iso2022.c
index 87317b5..726770d 100644 (file)
--- a/iso2022.c
+++ b/iso2022.c
@@ -144,8 +144,7 @@ static void do_utf8(long int input_chr,
 
     ustate.s1 = 0;
     ustate.s0 = state->s0 & 0x03ffffffL;
-    utf8 = charset_find_spec(CS_UTF8);
-    utf8->read(utf8, input_chr, &ustate, emit, emitctx);
+    read_utf8(NULL, input_chr, &ustate, emit, emitctx);
     state->s0 = (state->s0 & ~0x03ffffffL) | (ustate.s0 & 0x03ffffffL);
 }
 
@@ -191,14 +190,16 @@ static void read_iso2022(charset_spec const *charset, long int input_chr,
 
     /* dump_state(state); */
     /*
-     * We've got 64 bits of state to play with.
-     *
-     * Locking-shift state: 2 bits each GL/GR
-     * Single-shift state: 2 bits
-     * Charset designation state: n bits each G0/G1/G2/G3
-     * MBCS/esc seq accumulation: 14 bits (assume max 4-byte sets)
-     * MBCS state: 2 bits (off, ESC, GL, GR)
-     * For no good reason, put long-term state in s1, short term in s0.
+     * We have to make fairly efficient use of the 64 bits of state
+     * available to us.  Long-term state goes in s1, and consists of
+     * the identities of the character sets designated as G0/G1/G2/G3
+     * and the locking-shift states for GL and GR.  Short-term state
+     * goes in s0: The bottom half of s0 accumulates characters for an
+     * escape sequence or a multi-byte character, while the top three
+     * bits indicate what they're being accumulated for.  After DOCS,
+     * the bottom 29 bits of state are available for the DOCS function
+     * to use -- the UTF-8 one uses the bottom 26 for UTF-8 decoding
+     * and the top two to recognised ESC % @.
      *
      * s0[31:29] = state enum
      * s0[24:0] = accumulated bytes
@@ -467,8 +468,16 @@ static void read_iso2022(charset_spec const *charset, long int input_chr,
     }
 }
 
+static int write_iso2022(charset_spec const *charset, long int input_chr,
+                        charset_state *state,
+                        void (*emit)(void *ctx, long int output),
+                        void *emitctx)
+{
+    return FALSE;
+}
+
 const charset_spec charset_CS_ISO2022 = {
-    CS_ISO2022, read_iso2022, NULL, NULL
+    CS_ISO2022, read_iso2022, write_iso2022, NULL
 };
 
 #ifdef TESTMODE