summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/nkf/nkf-utf8/config.h11
-rw-r--r--ext/nkf/nkf-utf8/nkf.c18
-rwxr-xr-xext/nkf/nkf-utf8/nkf.h12
3 files changed, 27 insertions, 14 deletions
diff --git a/ext/nkf/nkf-utf8/config.h b/ext/nkf/nkf-utf8/config.h
index 473be76a8e..50daa891fa 100644
--- a/ext/nkf/nkf-utf8/config.h
+++ b/ext/nkf/nkf-utf8/config.h
@@ -40,12 +40,13 @@
/*
* Select Default Output Encoding
*
- * If not defined, locale encoding is used.
*/
-/* #define DEFAULT_CODE_JIS */
-/* #define DEFAULT_CODE_SJIS */
-/* #define DEFAULT_CODE_EUC */
-/* #define DEFAULT_CODE_UTF8 */
+/* #define DEFAULT_CODE_JIS */
+/* #define DEFAULT_CODE_SJIS */
+/* #define DEFAULT_CODE_EUC */
+/* #define DEFAULT_CODE_UTF8 */
+/* #define DEFAULT_CODE_LOCALE */
#endif /* _CONFIG_H_ */
+
diff --git a/ext/nkf/nkf-utf8/nkf.c b/ext/nkf/nkf-utf8/nkf.c
index b51ece582c..9bf96fdb93 100644
--- a/ext/nkf/nkf-utf8/nkf.c
+++ b/ext/nkf/nkf-utf8/nkf.c
@@ -258,6 +258,8 @@ struct {
#define DEFAULT_ENCIDX EUC_JP
#elif defined(DEFAULT_CODE_UTF8)
#define DEFAULT_ENCIDX UTF_8
+#else
+#define DEFAULT_ENCIDX 0
#endif
@@ -714,7 +716,7 @@ static nkf_encoding *nkf_enc_find(const char *name)
nkf_enc_to_index(enc) == CP50221 ||\
nkf_enc_to_index(enc) == CP50222)
-#ifndef DEFAULT_ENCIDX
+#ifdef DEFAULT_CODE_LOCALE
static char* nkf_locale_charmap()
{
#ifdef HAVE_LANGINFO_H
@@ -735,16 +737,16 @@ static nkf_encoding* nkf_locale_encoding()
if (enc < 0) enc = 0;
return enc;
}
-#endif
+#endif /* DEFAULT_CODE_LOCALE */
static nkf_encoding* nkf_default_encoding()
{
-#ifdef DEFAULT_ENCIDX
- return nkf_enc_from_index(DEFAULT_ENCIDX);
-#else
+#ifdef DEFAULT_CODE_LOCALE
nkf_encoding *enc = nkf_locale_encoding();
if (enc <= 0) enc = nkf_enc_from_index(ISO_2022_JP);
return enc;
+#else
+ return nkf_enc_from_index(DEFAULT_ENCIDX);
#endif
}
@@ -837,11 +839,13 @@ void show_configuration(void)
);
fprintf(HELP_OUTPUT,
" Default output encoding: "
-#ifdef DEFAULT_ENCIDX
+#ifdef DEFAULT_CODE_LOCALE
"%s\n", nkf_enc_name(nkf_default_encoding())
-#else
+#elif DEFAULT_ENCIDX
"%s (%s)\n", nkf_locale_encoding() ? "LOCALE" : "DEFAULT",
nkf_enc_name(nkf_default_encoding())
+#else
+ "NONE"
#endif
);
fprintf(HELP_OUTPUT,
diff --git a/ext/nkf/nkf-utf8/nkf.h b/ext/nkf/nkf-utf8/nkf.h
index 30efd4b5dd..a27015416f 100755
--- a/ext/nkf/nkf-utf8/nkf.h
+++ b/ext/nkf/nkf-utf8/nkf.h
@@ -5,7 +5,6 @@
* $Id: nkf.h,v 1.2 2008/01/23 09:10:25 naruse Exp $
*/
-
#ifndef NKF_H
/* Wrapper of configurations */
@@ -144,10 +143,16 @@ void setbinmode(FILE *fp)
#endif
#endif
+#ifdef DEFAULT_CODE_LOCALE
+
#ifndef __WIN32__ /* not win32 is posix */
+#ifndef HAVE_LANGINFO_H
#define HAVE_LANGINFO_H
+#endif
+#ifndef HAVE_LOCALE_H
#define HAVE_LOCALE_H
#endif
+#endif
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
@@ -156,6 +161,8 @@ void setbinmode(FILE *fp)
#include <locale.h>
#endif
+#endif /* DEFAULT_CODE_LOCALE */
+
#define FALSE 0
#define TRUE 1
@@ -163,4 +170,5 @@ void setbinmode(FILE *fp)
#include "nkf32.h"
#endif
-#endif
+#endif /* NKF_H */
+