summaryrefslogtreecommitdiff
path: root/ext/kconv/kconv.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/kconv/kconv.c')
-rw-r--r--ext/kconv/kconv.c222
1 files changed, 110 insertions, 112 deletions
diff --git a/ext/kconv/kconv.c b/ext/kconv/kconv.c
index fd6c3be..791b34b 100644
--- a/ext/kconv/kconv.c
+++ b/ext/kconv/kconv.c
@@ -33,6 +33,8 @@ static char *Version =
static char *Patchlevel =
"5/9612/Shinji Kono, COW matz";
+#include "ruby.h"
+
/*
**
**
@@ -128,8 +130,10 @@ static char *Patchlevel =
#include <windows.h>
#endif
+#ifndef FALSE
#define FALSE 0
#define TRUE 1
+#endif
/* state of output_mode and input_mode */
@@ -242,8 +246,104 @@ static int output_mode = ASCII, /* output kanji mode */
static int mime_mode = FALSE; /* MIME mode B base64, Q hex */
/* X0208 -> ASCII translation table */
+/* X0201 / X0208 conversion tables */
+
+/* X0201 kana conversion table */
+/* 90-9F A0-DF */
+static unsigned char cv[]= {
+0x21,0x21,0x21,0x23,0x21,0x56,0x21,0x57,
+0x21,0x22,0x21,0x26,0x25,0x72,0x25,0x21,
+0x25,0x23,0x25,0x25,0x25,0x27,0x25,0x29,
+0x25,0x63,0x25,0x65,0x25,0x67,0x25,0x43,
+0x21,0x3c,0x25,0x22,0x25,0x24,0x25,0x26,
+0x25,0x28,0x25,0x2a,0x25,0x2b,0x25,0x2d,
+0x25,0x2f,0x25,0x31,0x25,0x33,0x25,0x35,
+0x25,0x37,0x25,0x39,0x25,0x3b,0x25,0x3d,
+0x25,0x3f,0x25,0x41,0x25,0x44,0x25,0x46,
+0x25,0x48,0x25,0x4a,0x25,0x4b,0x25,0x4c,
+0x25,0x4d,0x25,0x4e,0x25,0x4f,0x25,0x52,
+0x25,0x55,0x25,0x58,0x25,0x5b,0x25,0x5e,
+0x25,0x5f,0x25,0x60,0x25,0x61,0x25,0x62,
+0x25,0x64,0x25,0x66,0x25,0x68,0x25,0x69,
+0x25,0x6a,0x25,0x6b,0x25,0x6c,0x25,0x6d,
+0x25,0x6f,0x25,0x73,0x21,0x2b,0x21,0x2c,
+0x00,0x00};
+
-static unsigned char cv[],dv[],ev[],fv[];
+/* X0201 kana conversion table for daguten */
+/* 90-9F A0-DF */
+static unsigned char dv[]= {
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x25,0x2c,0x25,0x2e,
+0x25,0x30,0x25,0x32,0x25,0x34,0x25,0x36,
+0x25,0x38,0x25,0x3a,0x25,0x3c,0x25,0x3e,
+0x25,0x40,0x25,0x42,0x25,0x45,0x25,0x47,
+0x25,0x49,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x25,0x50,0x25,0x53,
+0x25,0x56,0x25,0x59,0x25,0x5c,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00};
+
+/* X0201 kana conversion table for han-daguten */
+/* 90-9F A0-DF */
+static unsigned char ev[]= {
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x25,0x51,0x25,0x54,
+0x25,0x57,0x25,0x5a,0x25,0x5d,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00};
+
+
+/* X0208 kigou conversion table */
+/* 0x8140 - 0x819e */
+static unsigned char fv[] = {
+0x00,0x00,0x00,0x00,0x2c,0x2e,0x00,0x3a,
+0x3b,0x3f,0x21,0x00,0x00,0x27,0x60,0x00,
+0x5e,0x00,0x5f,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x2f,
+0x5c,0x00,0x00,0x7c,0x00,0x00,0x60,0x27,
+0x22,0x22,0x28,0x29,0x00,0x00,0x5b,0x5d,
+0x7b,0x7d,0x3c,0x3e,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x2b,0x2d,0x00,0x00,
+0x00,0x3d,0x00,0x3c,0x3e,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x24,0x00,0x00,0x25,0x23,0x26,0x2a,0x40,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+} ;
+
+
+/* This converts =?ISO-2022-JP?B?HOGE HOGE?= */
+
+static unsigned char *mime_pattern[] = {
+ (unsigned char *)"\075?ISO-8859-1?Q?",
+ (unsigned char *)"\075?ISO-2022-JP?B?",
+ (unsigned char *)"\075?ISO-2022-JP?Q?",
+ NULL
+};
+
+static int mime_encode[] = {
+ 'Q', 'B', 'Q',
+ 0
+};
#ifdef notdef
static int file_out = FALSE;
@@ -1002,7 +1102,7 @@ h_conv (c2, c1)
-int
+static int
push_hold_buf (c2, c1)
int c2,
c1;
@@ -1274,7 +1374,7 @@ j_oconv (c2, c1)
This is the main difference from fmt.
*/
-int
+static int
fold(c2,c1)
register int c2,c1;
{
@@ -1397,7 +1497,7 @@ register int c2,c1;
}
}
-int
+static int
pre_convert(c1,c2)
register int c1,c2;
{
@@ -1438,112 +1538,12 @@ register int c1,c2;
}
-/* X0201 / X0208 conversion tables */
-
-/* X0201 kana conversion table */
-/* 90-9F A0-DF */
-unsigned char cv[]= {
-0x21,0x21,0x21,0x23,0x21,0x56,0x21,0x57,
-0x21,0x22,0x21,0x26,0x25,0x72,0x25,0x21,
-0x25,0x23,0x25,0x25,0x25,0x27,0x25,0x29,
-0x25,0x63,0x25,0x65,0x25,0x67,0x25,0x43,
-0x21,0x3c,0x25,0x22,0x25,0x24,0x25,0x26,
-0x25,0x28,0x25,0x2a,0x25,0x2b,0x25,0x2d,
-0x25,0x2f,0x25,0x31,0x25,0x33,0x25,0x35,
-0x25,0x37,0x25,0x39,0x25,0x3b,0x25,0x3d,
-0x25,0x3f,0x25,0x41,0x25,0x44,0x25,0x46,
-0x25,0x48,0x25,0x4a,0x25,0x4b,0x25,0x4c,
-0x25,0x4d,0x25,0x4e,0x25,0x4f,0x25,0x52,
-0x25,0x55,0x25,0x58,0x25,0x5b,0x25,0x5e,
-0x25,0x5f,0x25,0x60,0x25,0x61,0x25,0x62,
-0x25,0x64,0x25,0x66,0x25,0x68,0x25,0x69,
-0x25,0x6a,0x25,0x6b,0x25,0x6c,0x25,0x6d,
-0x25,0x6f,0x25,0x73,0x21,0x2b,0x21,0x2c,
-0x00,0x00};
-
-
-/* X0201 kana conversion table for daguten */
-/* 90-9F A0-DF */
-unsigned char dv[]= {
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x25,0x2c,0x25,0x2e,
-0x25,0x30,0x25,0x32,0x25,0x34,0x25,0x36,
-0x25,0x38,0x25,0x3a,0x25,0x3c,0x25,0x3e,
-0x25,0x40,0x25,0x42,0x25,0x45,0x25,0x47,
-0x25,0x49,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x25,0x50,0x25,0x53,
-0x25,0x56,0x25,0x59,0x25,0x5c,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00};
-
-/* X0201 kana conversion table for han-daguten */
-/* 90-9F A0-DF */
-unsigned char ev[]= {
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x25,0x51,0x25,0x54,
-0x25,0x57,0x25,0x5a,0x25,0x5d,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00};
-
-
-/* X0208 kigou conversion table */
-/* 0x8140 - 0x819e */
-unsigned char fv[] = {
-
-0x00,0x00,0x00,0x00,0x2c,0x2e,0x00,0x3a,
-0x3b,0x3f,0x21,0x00,0x00,0x27,0x60,0x00,
-0x5e,0x00,0x5f,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x2f,
-0x5c,0x00,0x00,0x7c,0x00,0x00,0x60,0x27,
-0x22,0x22,0x28,0x29,0x00,0x00,0x5b,0x5d,
-0x7b,0x7d,0x3c,0x3e,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x2b,0x2d,0x00,0x00,
-0x00,0x3d,0x00,0x3c,0x3e,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x24,0x00,0x00,0x25,0x23,0x26,0x2a,0x40,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-} ;
-
-
-/* This converts =?ISO-2022-JP?B?HOGE HOGE?= */
-
-unsigned char *mime_pattern[] = {
- (unsigned char *)"\075?ISO-8859-1?Q?",
- (unsigned char *)"\075?ISO-2022-JP?B?",
- (unsigned char *)"\075?ISO-2022-JP?Q?",
- NULL
-};
-
-int mime_encode[] = {
- 'Q', 'B', 'Q',
- 0
-};
-
-int iso8859_f_save;
+static int iso8859_f_save;
#define nkf_toupper(c) (('a'<=c && c<='z')?(c-('a'-'A')):c)
/* I don't trust portablity of toupper */
-int
+static int
mime_begin()
{
int c1;
@@ -1594,7 +1594,7 @@ mime_begin()
#define mime_getc0() (mimebuf_f?_GETC():Fifo(mime_input++))
#define mime_ungetc0(c) (mimebuf_f?_UNGETC(c):mime_input--)
-int
+static int
mime_getc()
{
int c1, c2, c3, c4, cc;
@@ -1705,7 +1705,7 @@ mime_getc()
return Fifo(mime_top++);
}
-int
+static int
mime_ungetc(c)
unsigned int c;
{
@@ -1714,7 +1714,7 @@ unsigned int c;
}
-int
+static int
mime_integrity(p)
unsigned char *p;
{
@@ -1749,7 +1749,7 @@ unsigned char *p;
return 1;
}
-int
+static int
base64decode(c)
int c;
{
@@ -1820,8 +1820,6 @@ usage()
}
#endif /* notdef */
-#include "ruby.h"
-
static VALUE
kconv_kconv(argc, argv)
int argc;