nkfのGitリポジトリのfork
Revision | 832e032be763ec6acf1cf13225b0d72f1b867a18 (tree) |
---|---|
Time | 2012-03-17 20:50:17 |
Author | NARUSE, Yui <naruse@user...> |
Commiter | NARUSE, Yui |
Show "(BOM)" if the byte sequence has BOM.
http://sourceforge.jp/ticket/browse.php?group_id=248&tid=26325
@@ -20,11 +20,11 @@ | ||
20 | 20 | * |
21 | 21 | * 3. This notice may not be removed or altered from any source distribution. |
22 | 22 | */ |
23 | -#define NKF_VERSION "2.1.2" | |
24 | -#define NKF_RELEASE_DATE "2011-09-08" | |
23 | +#define NKF_VERSION "2.1.3" | |
24 | +#define NKF_RELEASE_DATE "2012-03-17" | |
25 | 25 | #define COPY_RIGHT \ |
26 | 26 | "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \ |
27 | - "Copyright (C) 1996-2011, The nkf Project." | |
27 | + "Copyright (C) 1996-2012, The nkf Project." | |
28 | 28 | |
29 | 29 | #include "config.h" |
30 | 30 | #include "nkf.h" |
@@ -356,6 +356,7 @@ static int no_cp932ext_f = FALSE; | ||
356 | 356 | /* ignore ZERO WIDTH NO-BREAK SPACE */ |
357 | 357 | static int no_best_fit_chars_f = FALSE; |
358 | 358 | static int input_endian = ENDIAN_BIG; |
359 | +static int input_bom_f = FALSE; | |
359 | 360 | static nkf_char unicode_subchar = '?'; /* the regular substitution character */ |
360 | 361 | static void (*encode_fallback)(nkf_char c) = NULL; |
361 | 362 | static void w_status(struct input_code *, nkf_char); |
@@ -3202,6 +3203,7 @@ check_bom(FILE *f) | ||
3202 | 3203 | set_iconv(TRUE, w_iconv32); |
3203 | 3204 | } |
3204 | 3205 | if (iconv == w_iconv32) { |
3206 | + input_bom_f = TRUE; | |
3205 | 3207 | input_endian = ENDIAN_BIG; |
3206 | 3208 | return; |
3207 | 3209 | } |
@@ -3232,6 +3234,7 @@ check_bom(FILE *f) | ||
3232 | 3234 | set_iconv(TRUE, w_iconv); |
3233 | 3235 | } |
3234 | 3236 | if (iconv == w_iconv) { |
3237 | + input_bom_f = TRUE; | |
3235 | 3238 | return; |
3236 | 3239 | } |
3237 | 3240 | (*i_ungetc)(0xBF,f); |
@@ -3260,6 +3263,7 @@ check_bom(FILE *f) | ||
3260 | 3263 | } |
3261 | 3264 | if (iconv == w_iconv16) { |
3262 | 3265 | input_endian = ENDIAN_BIG; |
3266 | + input_bom_f = TRUE; | |
3263 | 3267 | return; |
3264 | 3268 | } |
3265 | 3269 | (*i_ungetc)(0xFF,f); |
@@ -3275,6 +3279,7 @@ check_bom(FILE *f) | ||
3275 | 3279 | } |
3276 | 3280 | if (iconv == w_iconv32) { |
3277 | 3281 | input_endian = ENDIAN_LITTLE; |
3282 | + input_bom_f = TRUE; | |
3278 | 3283 | return; |
3279 | 3284 | } |
3280 | 3285 | (*i_ungetc)(0x00,f); |
@@ -3286,6 +3291,7 @@ check_bom(FILE *f) | ||
3286 | 3291 | } |
3287 | 3292 | if (iconv == w_iconv16) { |
3288 | 3293 | input_endian = ENDIAN_LITTLE; |
3294 | + input_bom_f = TRUE; | |
3289 | 3295 | return; |
3290 | 3296 | } |
3291 | 3297 | (*i_ungetc)(0xFE,f); |
@@ -4190,12 +4196,13 @@ print_guessed_code(char *filename) | ||
4190 | 4196 | if (guess_f == 1) { |
4191 | 4197 | printf("%s\n", input_codename); |
4192 | 4198 | } else { |
4193 | - printf("%s%s%s\n", | |
4199 | + printf("%s%s%s%s\n", | |
4194 | 4200 | input_codename, |
4195 | 4201 | iconv != w_iconv16 && iconv != w_iconv32 ? "" : |
4196 | 4202 | input_endian == ENDIAN_LITTLE ? " LE" : |
4197 | 4203 | input_endian == ENDIAN_BIG ? " BE" : |
4198 | 4204 | "[BUG]", |
4205 | + input_bom_f ? " (BOM)" : "", | |
4199 | 4206 | input_eol == CR ? " (CR)" : |
4200 | 4207 | input_eol == LF ? " (LF)" : |
4201 | 4208 | input_eol == CRLF ? " (CRLF)" : |