1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2008-01-27 08:55:31 +00:00
parent b1e6c052cd
commit 4aa64b35fa
4 changed files with 31 additions and 14 deletions

View file

@ -1,3 +1,7 @@
Sun Jan 27 17:54:48 2008 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/nkf.c: raise error when no output encoding is given.
Sun Jan 27 17:20:10 2008 Tanaka Akira <akr@fsij.org>
* string.c (rb_str_succ): don't increment/decrement codepoint.

View file

@ -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_ */

View file

@ -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,

View file

@ -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 */