[前][次][番号順一覧][スレッド一覧]

ruby-changes:3780

From: ko1@a...
Date: Sun, 27 Jan 2008 17:55:46 +0900 (JST)
Subject: [ruby-changes:3780] naruse - Ruby:r15269 (trunk): * ext/nkf/nkf.c: raise error when no output encoding is given.

naruse	2008-01-27 17:55:31 +0900 (Sun, 27 Jan 2008)

  New Revision: 15269

  Modified files:
    trunk/ChangeLog
    trunk/ext/nkf/nkf-utf8/config.h
    trunk/ext/nkf/nkf-utf8/nkf.c
    trunk/ext/nkf/nkf-utf8/nkf.h

  Log:
    * ext/nkf/nkf.c: raise error when no output encoding is given.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/nkf/nkf-utf8/nkf.h?r1=15269&r2=15268&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15269&r2=15268&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/nkf/nkf-utf8/config.h?r1=15269&r2=15268&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/nkf/nkf-utf8/nkf.c?r1=15269&r2=15268&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15268)
+++ ChangeLog	(revision 15269)
@@ -1,3 +1,7 @@
+Sun Jan 27 17:54:48 2008  NARUSE, Yui  <naruse@r...>
+
+	* ext/nkf/nkf.c: raise error when no output encoding is given.
+
 Sun Jan 27 17:20:10 2008  Tanaka Akira  <akr@f...>
 
 	* string.c (rb_str_succ): don't increment/decrement codepoint.
Index: ext/nkf/nkf-utf8/nkf.c
===================================================================
--- ext/nkf/nkf-utf8/nkf.c	(revision 15268)
+++ ext/nkf/nkf-utf8/nkf.c	(revision 15269)
@@ -258,6 +258,8 @@
 #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 @@
     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 @@
     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 @@
 	   );
     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,
Index: ext/nkf/nkf-utf8/nkf.h
===================================================================
--- ext/nkf/nkf-utf8/nkf.h	(revision 15268)
+++ ext/nkf/nkf-utf8/nkf.h	(revision 15269)
@@ -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 @@
 #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 @@
 #include <locale.h>
 #endif
 
+#endif /* DEFAULT_CODE_LOCALE */
+
 #define         FALSE   0
 #define         TRUE    1
 
@@ -163,4 +170,5 @@
 #include "nkf32.h"
 #endif
 
-#endif
+#endif /* NKF_H */
+
Index: ext/nkf/nkf-utf8/config.h
===================================================================
--- ext/nkf/nkf-utf8/config.h	(revision 15268)
+++ ext/nkf/nkf-utf8/config.h	(revision 15269)
@@ -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_ */
+

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]