1: Better documentation of how read_iso2022() stores its state.
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sun, 18 Sep 2005 13:31:00 +0000 (13:31 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sun, 18 Sep 2005 13:31:00 +0000 (13:31 +0000)
2: Minimal write_iso2022(): it can't encode anything, but promises not to
   segfault.

git-svn-id: svn://svn.tartarus.org/sgt/charset@6328 cda61777-01e9-0310-a592-d414129be87e

iso2022.c

index 642475c..1853be7 100644 (file)
--- a/iso2022.c
+++ b/iso2022.c
@@ -190,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 s0, 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 s1: The bottom half of s1 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
@@ -466,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