From: NARUSE, Yui Date: Tue, 22 Jan 2008 08:05:37 +0000 (+0000) Subject: * refactoring. X-Git-Tag: v2_0_9~55 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;ds=sidebyside;h=5175b12453a222317e41ba22fcc0d42775506765;p=nkf%2Fnkf.git * refactoring. --- diff --git a/nkf.c b/nkf.c index e87e9c5..b6e98b2 100644 --- a/nkf.c +++ b/nkf.c @@ -30,9 +30,9 @@ * 現在、nkf は SorceForge にてメンテナンスが続けられています。 * http://sourceforge.jp/projects/nkf/ ***********************************************************************/ -/* $Id: nkf.c,v 1.163 2008/01/11 00:45:06 naruse Exp $ */ +/* $Id: nkf.c,v 1.164 2008/01/21 23:05:37 naruse Exp $ */ #define NKF_VERSION "2.0.8" -#define NKF_RELEASE_DATE "2008-01-11" +#define NKF_RELEASE_DATE "2008-01-21" #define COPY_RIGHT \ "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),2000 S. Kono, COW\n" \ "Copyright (C) 2002-2008 Kono, Furukawa, Naruse, mastodon" @@ -384,6 +384,7 @@ struct { {"BINARY", BINARY}, {NULL, -1} }; + #if defined(DEFAULT_CODE_JIS) #define DEFAULT_ENCODING ISO_2022_JP #elif defined(DEFAULT_CODE_SJIS) @@ -471,6 +472,7 @@ struct input_code{ static char *input_codename = NULL; /* NULL: unestablished, "": BINARY */ static nkf_encoding *input_encoding = NULL; static nkf_encoding *output_encoding = NULL; +static void set_output_encoding(nkf_encoding *enc); #if !defined(PERL_XS) && !defined(WIN32DLL) static nkf_char noconvert(FILE *f); @@ -973,32 +975,6 @@ int main(int argc, char **argv) for (argc--,argv++; (argc > 0) && **argv == '-'; argc--, argv++) { cp = (unsigned char *)*argv; options(cp); - if (guess_f) { -#ifdef CHECK_OPTION - int debug_f_back = debug_f; -#endif -#ifdef EXEC_IO - int exec_f_back = exec_f; -#endif -#ifdef X0212_ENABLE - int x0212_f_back = x0212_f; -#endif - int x0213_f_back = x0213_f; - int guess_f_back = guess_f; - reinit(); - guess_f = guess_f_back; - mime_f = FALSE; -#ifdef CHECK_OPTION - debug_f = debug_f_back; -#endif -#ifdef EXEC_IO - exec_f = exec_f_back; -#endif -#ifdef X0212_ENABLE - x0212_f = x0212_f_back; -#endif - x0213_f = x0213_f_back; - } #ifdef EXEC_IO if (exec_f){ int fds[2], pid; @@ -1028,6 +1004,33 @@ int main(int argc, char **argv) #endif } + if (guess_f) { +#ifdef CHECK_OPTION + int debug_f_back = debug_f; +#endif +#ifdef EXEC_IO + int exec_f_back = exec_f; +#endif +#ifdef X0212_ENABLE + int x0212_f_back = x0212_f; +#endif + int x0213_f_back = x0213_f; + int guess_f_back = guess_f; + reinit(); + guess_f = guess_f_back; + mime_f = FALSE; +#ifdef CHECK_OPTION + debug_f = debug_f_back; +#endif +#ifdef EXEC_IO + exec_f = exec_f_back; +#endif +#ifdef X0212_ENABLE + x0212_f = x0212_f_back; +#endif + x0213_f = x0213_f_back; + } + if (binmode_f == TRUE) #if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__)) if (freopen("","wb",stdout) == NULL) @@ -1352,280 +1355,290 @@ static const struct { {"prefix=", ""}, }; -static int option_mode = 0; - -void options(unsigned char *cp) +static void set_input_encoding(nkf_encoding *enc) { - nkf_char i, j; - unsigned char *p; - unsigned char *cp_back = NULL; - char codeset[32]; - nkf_encoding *enc; - - if (option_mode==1) - return; - while(*cp && *cp++!='-'); - while (*cp || cp_back) { - if(!*cp){ - cp = cp_back; - cp_back = NULL; - continue; - } - p = 0; - switch (*cp++) { - case '-': /* literal options */ - if (!*cp || *cp == SP) { /* ignore the rest of arguments */ - option_mode = 1; - return; - } - for (i=0;ihiragana, 2 hiragana->katakana, 3 both\n"); - fprintf(HELP_OUTPUT,"m[BQN0] MIME decode [B:base64,Q:quoted,N:non-strict,0:no decode]\n"); + fprintf(HELP_OUTPUT,"m[BQSN0] MIME decode [B:base64,Q:quoted,S:strict,N:non-strict,0:no decode]\n"); fprintf(HELP_OUTPUT,"M[BQ] MIME encode [B:base64 Q:quoted]\n"); fprintf(HELP_OUTPUT,"l ISO8859-1 (Latin-1) support\n"); fprintf(HELP_OUTPUT,"f/F Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nl\n");