aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ChangeLog.ja5
-rw-r--r--src/codeconv.c137
-rw-r--r--src/codeconv.h23
4 files changed, 57 insertions, 113 deletions
diff --git a/ChangeLog b/ChangeLog
index da61a53a..3219af66 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2005-01-26
+ * src/codeconv.[ch]: made encoding-specific functions static, and
+ removed redundant code.
+
+2005-01-26
+
* src/procmime.c:
procmime_scan_content_type()
procmime_scan_content_disposition(): removed raw ISO-2022-JP to
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 53befcbf..0ecb1787 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,10 @@
2005-01-26
+ * src/codeconv.[ch]: 特定のエンコーディング用の関数を static にし、
+ 余分なコードを削除。
+
+2005-01-26
+
* src/procmime.c:
procmime_scan_content_type()
procmime_scan_content_disposition(): 生の ISO-2022-JP から EUC-JP
diff --git a/src/codeconv.c b/src/codeconv.c
index 3063b4f0..2ce49b2d 100644
--- a/src/codeconv.c
+++ b/src/codeconv.c
@@ -104,7 +104,28 @@ typedef enum
state = JIS_AUXKANJI; \
}
-void conv_jistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_jistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_sjistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf);
+
+static void conv_jistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_sjistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_euctoutf8(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_anytoutf8(gchar *outbuf, gint outlen, const gchar *inbuf);
+
+static void conv_unreadable_eucjp(gchar *str);
+static void conv_unreadable_8bit(gchar *str);
+static void conv_unreadable_latin(gchar *str);
+
+static void conv_jistodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_sjistodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_euctodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+
+static void conv_anytodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_ustodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_noconv(gchar *outbuf, gint outlen, const gchar *inbuf);
+
+static void conv_jistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
{
const guchar *in = inbuf;
guchar *out = outbuf;
@@ -239,7 +260,7 @@ static gint conv_jis_hantozen(guchar *outbuf, guchar jis_code, guchar sound_sym)
return 1;
}
-void conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf)
{
const guchar *in = inbuf;
guchar *out = outbuf;
@@ -327,7 +348,7 @@ void conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf)
*out = '\0';
}
-void conv_sjistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_sjistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
{
const guchar *in = inbuf;
guchar *out = outbuf;
@@ -373,7 +394,7 @@ void conv_sjistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
*out = '\0';
}
-void conv_jistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_jistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
{
static iconv_t cd = (iconv_t)-1;
static gboolean iconv_ok = TRUE;
@@ -410,7 +431,7 @@ void conv_jistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
strncpy2(outbuf, inbuf, outlen);
}
-void conv_sjistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_sjistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
{
gchar *tmpstr;
@@ -422,7 +443,7 @@ void conv_sjistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
strncpy2(outbuf, inbuf, outlen);
}
-void conv_euctoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_euctoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
{
gchar *tmpstr;
@@ -434,22 +455,7 @@ void conv_euctoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
strncpy2(outbuf, inbuf, outlen);
}
-void conv_anytoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
-{
- switch (conv_guess_ja_encoding(inbuf)) {
- case C_ISO_2022_JP:
- conv_jistoeuc(outbuf, outlen, inbuf);
- break;
- case C_SHIFT_JIS:
- conv_sjistoeuc(outbuf, outlen, inbuf);
- break;
- default:
- strncpy2(outbuf, inbuf, outlen);
- break;
- }
-}
-
-void conv_anytoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_anytoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
{
switch (conv_guess_ja_encoding(inbuf)) {
case C_ISO_2022_JP:
@@ -467,18 +473,6 @@ void conv_anytoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
}
}
-void conv_anytojis(gchar *outbuf, gint outlen, const gchar *inbuf)
-{
- switch (conv_guess_ja_encoding(inbuf)) {
- case C_EUC_JP:
- conv_euctojis(outbuf, outlen, inbuf);
- break;
- default:
- strncpy2(outbuf, inbuf, outlen);
- break;
- }
-}
-
static gchar valid_eucjp_tbl[][96] = {
/* 0xa2a0 - 0xa2ff */
{ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
@@ -561,7 +555,7 @@ static gboolean isprintableeuckanji(guchar c1, guchar c2)
return TRUE;
}
-void conv_unreadable_eucjp(gchar *str)
+static void conv_unreadable_eucjp(gchar *str)
{
register guchar *p = str;
@@ -604,7 +598,7 @@ void conv_unreadable_eucjp(gchar *str)
}
}
-void conv_unreadable_8bit(gchar *str)
+static void conv_unreadable_8bit(gchar *str)
{
register guchar *p = str;
@@ -617,7 +611,7 @@ void conv_unreadable_8bit(gchar *str)
}
}
-void conv_unreadable_latin(gchar *str)
+static void conv_unreadable_latin(gchar *str)
{
register guchar *p = str;
@@ -631,34 +625,6 @@ void conv_unreadable_latin(gchar *str)
}
}
-void conv_unreadable_locale(gchar *str)
-{
- switch (conv_get_locale_charset()) {
- case C_US_ASCII:
- case C_ISO_8859_1:
- case C_ISO_8859_2:
- case C_ISO_8859_3:
- case C_ISO_8859_4:
- case C_ISO_8859_5:
- case C_ISO_8859_6:
- case C_ISO_8859_7:
- case C_ISO_8859_8:
- case C_ISO_8859_9:
- case C_ISO_8859_10:
- case C_ISO_8859_11:
- case C_ISO_8859_13:
- case C_ISO_8859_14:
- case C_ISO_8859_15:
- conv_unreadable_latin(str);
- break;
- case C_EUC_JP:
- conv_unreadable_eucjp(str);
- break;
- default:
- break;
- }
-}
-
#define NCV '\0'
void conv_mb_alnum(gchar *str)
@@ -767,17 +733,17 @@ CharSet conv_guess_ja_encoding(const gchar *str)
return guessed;
}
-void conv_jistodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_jistodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
{
conv_jistoutf8(outbuf, outlen, inbuf);
}
-void conv_sjistodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_sjistodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
{
conv_sjistoutf8(outbuf, outlen, inbuf);
}
-void conv_euctodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_euctodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
{
conv_euctoutf8(outbuf, outlen, inbuf);
}
@@ -787,23 +753,17 @@ void conv_utf8todisp(gchar *outbuf, gint outlen, const gchar *inbuf)
strncpy2(outbuf, inbuf, outlen);
}
-void conv_anytodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_anytodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
{
conv_anytoutf8(outbuf, outlen, inbuf);
}
-void conv_ustodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_ustodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
{
strncpy2(outbuf, inbuf, outlen);
conv_unreadable_8bit(outbuf);
}
-void conv_latintodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
-{
- strncpy2(outbuf, inbuf, outlen);
- //conv_unreadable_latin(outbuf);
-}
-
void conv_localetodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
{
gchar *tmpstr;
@@ -817,7 +777,7 @@ void conv_localetodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
strncpy2(outbuf, inbuf, outlen);
}
-void conv_noconv(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_noconv(gchar *outbuf, gint outlen, const gchar *inbuf)
{
strncpy2(outbuf, inbuf, outlen);
}
@@ -906,20 +866,7 @@ CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
return conv_ustodisp;
switch (src_charset) {
- case C_ISO_2022_JP:
- case C_ISO_2022_JP_2:
- case C_ISO_2022_JP_3:
- if (dest_charset == C_AUTO)
- code_conv = conv_jistodisp;
- else if (dest_charset == C_EUC_JP)
- code_conv = conv_jistoeuc;
- else if (dest_charset == C_UTF_8)
- code_conv = conv_jistoutf8;
- break;
case C_US_ASCII:
- if (dest_charset == C_AUTO)
- code_conv = conv_ustodisp;
- break;
case C_ISO_8859_1:
case C_ISO_8859_2:
case C_ISO_8859_3:
@@ -935,6 +882,16 @@ CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
case C_ISO_8859_14:
case C_ISO_8859_15:
break;
+ case C_ISO_2022_JP:
+ case C_ISO_2022_JP_2:
+ case C_ISO_2022_JP_3:
+ if (dest_charset == C_AUTO)
+ code_conv = conv_jistodisp;
+ else if (dest_charset == C_EUC_JP)
+ code_conv = conv_jistoeuc;
+ else if (dest_charset == C_UTF_8)
+ code_conv = conv_jistoutf8;
+ break;
case C_SHIFT_JIS:
if (dest_charset == C_AUTO)
code_conv = conv_sjistodisp;
diff --git a/src/codeconv.h b/src/codeconv.h
index 11252aa1..e416249f 100644
--- a/src/codeconv.h
+++ b/src/codeconv.h
@@ -169,34 +169,11 @@ struct _CodeConverter
#define C_INTERNAL C_UTF_8
#define CS_INTERNAL CS_UTF_8
-void conv_jistoeuc (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_euctojis (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_sjistoeuc (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_anytoeuc (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_anytojis (gchar *outbuf, gint outlen, const gchar *inbuf);
-
-void conv_jistoutf8 (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_sjistoutf8 (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_euctoutf8 (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_anytoutf8 (gchar *outbuf, gint outlen, const gchar *inbuf);
-
-void conv_unreadable_eucjp (gchar *str);
-void conv_unreadable_8bit (gchar *str);
-void conv_unreadable_latin (gchar *str);
-void conv_unreadable_locale (gchar *str);
-
//void conv_mb_alnum(gchar *str);
CharSet conv_guess_ja_encoding(const gchar *str);
-void conv_jistodisp (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_sjistodisp (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_euctodisp (gchar *outbuf, gint outlen, const gchar *inbuf);
void conv_utf8todisp (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_anytodisp (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_ustodisp (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_latintodisp (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_noconv (gchar *outbuf, gint outlen, const gchar *inbuf);
void conv_localetodisp (gchar *outbuf, gint outlen, const gchar *inbuf);
CodeConverter *conv_code_converter_new (const gchar *src_charset);