Switch to side-by-side view

--- a/unac/unac.h
+++ b/unac/unac.h
@@ -35,7 +35,7 @@
 #define UNAC_BLOCK_SHIFT 4
 #define UNAC_BLOCK_MASK ((1 << UNAC_BLOCK_SHIFT) - 1)
 #define UNAC_BLOCK_SIZE (1 << UNAC_BLOCK_SHIFT)
-#define UNAC_BLOCK_COUNT 418
+#define UNAC_BLOCK_COUNT 422
 #define UNAC_INDEXES_SIZE (0x10000 >> UNAC_BLOCK_SHIFT)
 /* Generated by builder. Do not modify. End defines */
 
@@ -45,37 +45,30 @@
  * by <p> is returned in the <l> argument.
  * The C++ prototype of this macro would be:
  *
- * void unac_char(const unsigned short c, unsigned short*& p, int& l)
+ * void unac_char(const unsigned short c, unsigned short*& p, int& l, int o)
  *
  * See unac(3) in IMPLEMENTATION NOTES for more information about the
  * tables (unac_data_table, unac_positions) layout.
+ *
+ * Each transformed char has 3 possible outputs: unaccented, unaccented and
+ * folded, or just folded. These are kept at offset 0,1,2 in the position table
  */ 
-#define unac_char_utf16(c,p,l) \
-  { \
-    unsigned short index = unac_indexes[(c) >> UNAC_BLOCK_SHIFT]; \
-    unsigned char position = 2*((c) & UNAC_BLOCK_MASK);	          \
-    (p) = &(unac_data_table[index][unac_positions[index][position]]); \
-    (l) = unac_positions[index][position + 1] - unac_positions[index][position]; \
-    if((l) == 1 && *(p) == 0xFFFF) { \
-      (p) = 0; \
-      (l) = 0; \
-    } \
-  }
-
-/*
- * Save as unac_ but case-folded
- */ 
-#define unacfold_char_utf16(c,p,l)					\
+#define unac_uf_char_utf16_(c,p,l,o)					\
     {									\
-	unsigned short index = unac_indexes[(c) >> UNAC_BLOCK_SHIFT];	\
-	unsigned char position = 2*((c) & UNAC_BLOCK_MASK)+1;		\
+	unsigned short index = unac_indexes[(c) >> UNAC_BLOCK_SHIFT];   \
+	unsigned char position = 3*((c) & UNAC_BLOCK_MASK) + (o);	\
 	(p) = &(unac_data_table[index][unac_positions[index][position]]); \
-	(l) = unac_positions[index][position + 1] - unac_positions[index][position]; \
+	(l) = unac_positions[index][position + 1]			\
+	    - unac_positions[index][position];				\
 	if((l) == 1 && *(p) == 0xFFFF) {				\
 	    (p) = 0;							\
 	    (l) = 0;							\
 	}								\
     }
+
+#define unac_char_utf16(c,p,l) unac_uf_char_utf16_((c),(p),(l),0)
+#define unacfold_char_utf16(c,p,l) unac_uf_char_utf16_((c),(p),(l),1)
+#define fold_char_utf16(c,p,l) unac_uf_char_utf16_((c),(p),(l),2)
 
 /*
  * Return the unaccented equivalent of the UTF-16 string <in> of
@@ -94,6 +87,8 @@
 		char** out, size_t* out_length);
 int unacfold_string_utf16(const char* in, size_t in_length,
 			  char** out, size_t* out_length);
+int fold_string_utf16(const char* in, size_t in_length,
+		      char** out, size_t* out_length);
 
 /*
  * The semantic of this function is stricly equal to the function
@@ -110,6 +105,9 @@
 		const char* in, size_t in_length,
 		char** out, size_t* out_length);
 int unacfold_string(const char* charset,
+		const char* in, size_t in_length,
+		char** out, size_t* out_length);
+int fold_string(const char* charset,
 		const char* in, size_t in_length,
 		char** out, size_t* out_length);
 
@@ -180,7 +178,7 @@
 
 /* Generated by builder. Do not modify. Start declarations */
 extern unsigned short unac_indexes[UNAC_INDEXES_SIZE];
-extern unsigned char unac_positions[UNAC_BLOCK_COUNT][2*UNAC_BLOCK_SIZE + 1];
+extern unsigned char unac_positions[UNAC_BLOCK_COUNT][3*UNAC_BLOCK_SIZE + 1];
 extern unsigned short* unac_data_table[UNAC_BLOCK_COUNT];
 extern unsigned short unac_data0[];
 extern unsigned short unac_data1[];
@@ -600,6 +598,10 @@
 extern unsigned short unac_data415[];
 extern unsigned short unac_data416[];
 extern unsigned short unac_data417[];
+extern unsigned short unac_data418[];
+extern unsigned short unac_data419[];
+extern unsigned short unac_data420[];
+extern unsigned short unac_data421[];
 /* Generated by builder. Do not modify. End declarations */
 
 #ifdef __cplusplus