From 832e032be763ec6acf1cf13225b0d72f1b867a18 Mon Sep 17 00:00:00 2001 From: "NARUSE, Yui" Date: Sat, 17 Mar 2012 20:50:17 +0900 Subject: [PATCH] Show "(BOM)" if the byte sequence has BOM. http://sourceforge.jp/ticket/browse.php?group_id=248&tid=26325 --- nkf.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/nkf.c b/nkf.c index b9df10e..ee855d8 100644 --- a/nkf.c +++ b/nkf.c @@ -20,11 +20,11 @@ * * 3. This notice may not be removed or altered from any source distribution. */ -#define NKF_VERSION "2.1.2" -#define NKF_RELEASE_DATE "2011-09-08" +#define NKF_VERSION "2.1.3" +#define NKF_RELEASE_DATE "2012-03-17" #define COPY_RIGHT \ "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \ - "Copyright (C) 1996-2011, The nkf Project." + "Copyright (C) 1996-2012, The nkf Project." #include "config.h" #include "nkf.h" @@ -356,6 +356,7 @@ static int no_cp932ext_f = FALSE; /* ignore ZERO WIDTH NO-BREAK SPACE */ static int no_best_fit_chars_f = FALSE; static int input_endian = ENDIAN_BIG; +static int input_bom_f = FALSE; static nkf_char unicode_subchar = '?'; /* the regular substitution character */ static void (*encode_fallback)(nkf_char c) = NULL; static void w_status(struct input_code *, nkf_char); @@ -3202,6 +3203,7 @@ check_bom(FILE *f) set_iconv(TRUE, w_iconv32); } if (iconv == w_iconv32) { + input_bom_f = TRUE; input_endian = ENDIAN_BIG; return; } @@ -3232,6 +3234,7 @@ check_bom(FILE *f) set_iconv(TRUE, w_iconv); } if (iconv == w_iconv) { + input_bom_f = TRUE; return; } (*i_ungetc)(0xBF,f); @@ -3260,6 +3263,7 @@ check_bom(FILE *f) } if (iconv == w_iconv16) { input_endian = ENDIAN_BIG; + input_bom_f = TRUE; return; } (*i_ungetc)(0xFF,f); @@ -3275,6 +3279,7 @@ check_bom(FILE *f) } if (iconv == w_iconv32) { input_endian = ENDIAN_LITTLE; + input_bom_f = TRUE; return; } (*i_ungetc)(0x00,f); @@ -3286,6 +3291,7 @@ check_bom(FILE *f) } if (iconv == w_iconv16) { input_endian = ENDIAN_LITTLE; + input_bom_f = TRUE; return; } (*i_ungetc)(0xFE,f); @@ -4190,12 +4196,13 @@ print_guessed_code(char *filename) if (guess_f == 1) { printf("%s\n", input_codename); } else { - printf("%s%s%s\n", + printf("%s%s%s%s\n", input_codename, iconv != w_iconv16 && iconv != w_iconv32 ? "" : input_endian == ENDIAN_LITTLE ? " LE" : input_endian == ENDIAN_BIG ? " BE" : "[BUG]", + input_bom_f ? " (BOM)" : "", input_eol == CR ? " (CR)" : input_eol == LF ? " (LF)" : input_eol == CRLF ? " (CRLF)" : -- 2.11.0