mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* original nkf2 revision 1.47
* mime encode/decode are improved * --cp932inv turns on as default * add long name option --cp932 which turns on all CP932 option git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3cf6e46e62
commit
32e79507bb
1 changed files with 32 additions and 22 deletions
|
@ -41,7 +41,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#define NKF_VERSION "2.0.4"
|
#define NKF_VERSION "2.0.4"
|
||||||
#define NKF_RELEASE_DATE "2004-11-15"
|
#define NKF_RELEASE_DATE "2004-12-01"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
static char *CopyRight =
|
static char *CopyRight =
|
||||||
|
@ -433,7 +433,7 @@ STATIC int cp932_f = TRUE;
|
||||||
#define CP932_TABLE_BEGIN (0xfa)
|
#define CP932_TABLE_BEGIN (0xfa)
|
||||||
#define CP932_TABLE_END (0xfc)
|
#define CP932_TABLE_END (0xfc)
|
||||||
|
|
||||||
STATIC int cp932inv_f = FALSE;
|
STATIC int cp932inv_f = TRUE;
|
||||||
#define CP932INV_TABLE_BEGIN (0xed)
|
#define CP932INV_TABLE_BEGIN (0xed)
|
||||||
#define CP932INV_TABLE_END (0xee)
|
#define CP932INV_TABLE_END (0xee)
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ main(argc, argv)
|
||||||
FILE *fin;
|
FILE *fin;
|
||||||
unsigned char *cp;
|
unsigned char *cp;
|
||||||
|
|
||||||
char *outfname;
|
char *outfname = NULL;
|
||||||
char *origfname;
|
char *origfname;
|
||||||
|
|
||||||
#ifdef EASYWIN /*Easy Win */
|
#ifdef EASYWIN /*Easy Win */
|
||||||
|
@ -723,8 +723,8 @@ main(argc, argv)
|
||||||
return(-1);
|
return(-1);
|
||||||
} else {
|
} else {
|
||||||
#ifdef OVERWRITE
|
#ifdef OVERWRITE
|
||||||
int fd;
|
int fd = 0;
|
||||||
int fd_backup;
|
int fd_backup = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* reopen file for stdout */
|
/* reopen file for stdout */
|
||||||
|
@ -893,6 +893,8 @@ struct {
|
||||||
{"katakana","h2"},
|
{"katakana","h2"},
|
||||||
{"katakana-hiragana","h3"},
|
{"katakana-hiragana","h3"},
|
||||||
{"guess", "g"},
|
{"guess", "g"},
|
||||||
|
{"cp932", ""},
|
||||||
|
{"no-cp932", ""},
|
||||||
#ifdef UTF8_OUTPUT_ENABLE
|
#ifdef UTF8_OUTPUT_ENABLE
|
||||||
{"utf8", "w"},
|
{"utf8", "w"},
|
||||||
{"utf16", "w16"},
|
{"utf16", "w16"},
|
||||||
|
@ -917,7 +919,6 @@ struct {
|
||||||
{"debug", ""},
|
{"debug", ""},
|
||||||
#endif
|
#endif
|
||||||
#ifdef SHIFTJIS_CP932
|
#ifdef SHIFTJIS_CP932
|
||||||
{"no-cp932", ""},
|
|
||||||
{"cp932inv", ""},
|
{"cp932inv", ""},
|
||||||
#endif
|
#endif
|
||||||
#ifdef EXEC_IO
|
#ifdef EXEC_IO
|
||||||
|
@ -934,7 +935,7 @@ options(cp)
|
||||||
unsigned char *cp;
|
unsigned char *cp;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned char *p;
|
unsigned char *p = NULL;
|
||||||
|
|
||||||
if (option_mode==1)
|
if (option_mode==1)
|
||||||
return;
|
return;
|
||||||
|
@ -997,11 +998,27 @@ options(cp)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (strcmp(long_option[i].name, "cp932") == 0){
|
||||||
#ifdef SHIFTJIS_CP932
|
#ifdef SHIFTJIS_CP932
|
||||||
if (strcmp(long_option[i].name, "no-cp932") == 0){
|
cp932_f = TRUE;
|
||||||
cp932_f = FALSE;
|
cp932inv_f = TRUE;
|
||||||
|
#endif
|
||||||
|
#ifdef UTF8_OUTPUT_ENABLE
|
||||||
|
ms_ucs_map_f = TRUE;
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (strcmp(long_option[i].name, "no-cp932") == 0){
|
||||||
|
#ifdef SHIFTJIS_CP932
|
||||||
|
cp932_f = FALSE;
|
||||||
|
cp932inv_f = FALSE;
|
||||||
|
#endif
|
||||||
|
#ifdef UTF8_OUTPUT_ENABLE
|
||||||
|
ms_ucs_map_f = FALSE;
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#ifdef SHIFTJIS_CP932
|
||||||
if (strcmp(long_option[i].name, "cp932inv") == 0){
|
if (strcmp(long_option[i].name, "cp932inv") == 0){
|
||||||
cp932inv_f = TRUE;
|
cp932inv_f = TRUE;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1660,21 +1677,17 @@ code_status(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PERL_XS
|
|
||||||
#define STD_GC_BUFSIZE (256)
|
#define STD_GC_BUFSIZE (256)
|
||||||
int std_gc_buf[STD_GC_BUFSIZE];
|
int std_gc_buf[STD_GC_BUFSIZE];
|
||||||
int std_gc_ndx;
|
int std_gc_ndx;
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
std_getc(f)
|
std_getc(f)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
{
|
{
|
||||||
#ifdef PERL_XS
|
|
||||||
if (std_gc_ndx){
|
if (std_gc_ndx){
|
||||||
return std_gc_buf[--std_gc_ndx];
|
return std_gc_buf[--std_gc_ndx];
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return getc(f);
|
return getc(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1683,14 +1696,11 @@ std_ungetc(c,f)
|
||||||
int c;
|
int c;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
{
|
{
|
||||||
#ifdef PERL_XS
|
|
||||||
if (std_gc_ndx == STD_GC_BUFSIZE){
|
if (std_gc_ndx == STD_GC_BUFSIZE){
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
std_gc_buf[std_gc_ndx++] = c;
|
std_gc_buf[std_gc_ndx++] = c;
|
||||||
return c;
|
return c;
|
||||||
#endif
|
|
||||||
return ungetc(c,f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2069,6 +2079,7 @@ kanji_convert(f)
|
||||||
} else if ((c1 == NL || c1 == CR) && broken_f&4) {
|
} else if ((c1 == NL || c1 == CR) && broken_f&4) {
|
||||||
input_mode = ASCII; set_iconv(FALSE, 0);
|
input_mode = ASCII; set_iconv(FALSE, 0);
|
||||||
SEND;
|
SEND;
|
||||||
|
/*
|
||||||
} else if (c1 == NL && mime_f && !mime_decode_mode ) {
|
} else if (c1 == NL && mime_f && !mime_decode_mode ) {
|
||||||
if ((c1=(*i_getc)(f))!=EOF && c1 == SPACE) {
|
if ((c1=(*i_getc)(f))!=EOF && c1 == SPACE) {
|
||||||
i_ungetc(SPACE,f);
|
i_ungetc(SPACE,f);
|
||||||
|
@ -2095,6 +2106,7 @@ kanji_convert(f)
|
||||||
}
|
}
|
||||||
c1 = CR;
|
c1 = CR;
|
||||||
SEND;
|
SEND;
|
||||||
|
*/
|
||||||
} else
|
} else
|
||||||
SEND;
|
SEND;
|
||||||
}
|
}
|
||||||
|
@ -4229,7 +4241,7 @@ reinit()
|
||||||
#endif
|
#endif
|
||||||
#ifdef SHIFTJIS_CP932
|
#ifdef SHIFTJIS_CP932
|
||||||
cp932_f = TRUE;
|
cp932_f = TRUE;
|
||||||
cp932inv_f = FALSE;
|
cp932inv_f = TRUE;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -4240,6 +4252,7 @@ reinit()
|
||||||
#ifdef UTF8_INPUT_ENABLE
|
#ifdef UTF8_INPUT_ENABLE
|
||||||
utf16_mode = UTF16LE_INPUT;
|
utf16_mode = UTF16LE_INPUT;
|
||||||
#endif
|
#endif
|
||||||
|
mimeout_buf_count = 0;
|
||||||
mimeout_mode = 0;
|
mimeout_mode = 0;
|
||||||
base64_count = 0;
|
base64_count = 0;
|
||||||
f_line = 0;
|
f_line = 0;
|
||||||
|
@ -4348,16 +4361,13 @@ usage()
|
||||||
fprintf(stderr," --fj,--unix,--mac,--windows convert for the system\n");
|
fprintf(stderr," --fj,--unix,--mac,--windows convert for the system\n");
|
||||||
fprintf(stderr," --jis,--euc,--sjis,--utf8,--utf16,--mime,--base64 convert for the code\n");
|
fprintf(stderr," --jis,--euc,--sjis,--utf8,--utf16,--mime,--base64 convert for the code\n");
|
||||||
fprintf(stderr," --hiragana, --katakana Hiragana/Katakana Conversion\n");
|
fprintf(stderr," --hiragana, --katakana Hiragana/Katakana Conversion\n");
|
||||||
|
fprintf(stderr," --cp932, --no-cp932 CP932 compatible\n");
|
||||||
#ifdef INPUT_OPTION
|
#ifdef INPUT_OPTION
|
||||||
fprintf(stderr," --cap-input, --url-input Convert hex after ':' or '%'\n");
|
fprintf(stderr," --cap-input, --url-input Convert hex after ':' or '%%'\n");
|
||||||
#endif
|
#endif
|
||||||
#ifdef NUMCHAR_OPTION
|
#ifdef NUMCHAR_OPTION
|
||||||
fprintf(stderr," --numchar-input Convert Unicode Character Reference\n");
|
fprintf(stderr," --numchar-input Convert Unicode Character Reference\n");
|
||||||
#endif
|
#endif
|
||||||
#ifdef SHIFTJIS_CP932
|
|
||||||
fprintf(stderr," --no-cp932 Don't convert Shift_JIS FAxx-FCxx to equivalnet CP932\n");
|
|
||||||
fprintf(stderr," --cp932inv convert Shift_JIS EDxx-EFxx to equivalnet CP932 FAxx-FCxx\n");
|
|
||||||
#endif
|
|
||||||
#ifdef UTF8_OUTPUT_ENABLE
|
#ifdef UTF8_OUTPUT_ENABLE
|
||||||
fprintf(stderr," --ms-ucs-map Microsoft UCS Mapping Compatible\n");
|
fprintf(stderr," --ms-ucs-map Microsoft UCS Mapping Compatible\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue