com php-src: Remove dead code from mbfilter_cp850.c (and do general code cleanup): ext/mbstring/ libmbfl/filters/mbfilter_cp850.c ext/mbstring/libmb
fl/mbfl/mbfl_consts.h

From: Date: Mon, 02 Nov 2020 19:31:06 +0000
Subject: com php-src: Remove dead code from mbfilter_cp850.c (and do general code cleanup): ext/mbstring/ libmbfl/filters/mbfilter_cp850.c ext/mbstring/libmb
fl/mbfl/mbfl_consts.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-114025@lists.php.net to get a copy of this message
Commit: b6e75265d00d68214c22eb02604e0ad24cc4465d Author: Alex Dowad <alexinbeijing@gmail.com> Sun, 18 Oct 2020 16:35:20 +0200 Parents: 8926252ee88dd38b12f5622014d843f2e176faa7 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b6e75265d00d68214c22eb02604e0ad24cc4465d Log: Remove dead code from mbfilter_cp850.c (and do general code cleanup) Since there are no invalid bytes in CP850, these if conditions will never be true. Changed paths: M ext/mbstring/libmbfl/filters/mbfilter_cp850.c M ext/mbstring/libmbfl/mbfl/mbfl_consts.h Diff: diff --git a/ext/mbstring/libmbfl/filters/mbfilter_cp850.c b/ext/mbstring/libmbfl/filters/mbfilter_cp850.c index 906f4c3e601..50390c179f0 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_cp850.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_cp850.c @@ -68,62 +68,31 @@ const struct mbfl_convert_vtbl vtbl_cp850_wchar = { #define CK(statement) do { if ((statement) < 0) return (-1); } while (0) -/* - * cp850 => wchar - */ -int -mbfl_filt_conv_cp850_wchar(int c, mbfl_convert_filter *filter) +int mbfl_filt_conv_cp850_wchar(int c, mbfl_convert_filter *filter) { int s; - if (c >= 0 && c < cp850_ucs_table_min) { + if (c < cp850_ucs_table_min) { s = c; - } else if (c >= cp850_ucs_table_min && c < 0x100) { - s = cp850_ucs_table[c - cp850_ucs_table_min]; - if (s <= 0) { - s = c; - s &= MBFL_WCSPLANE_MASK; - s |= MBFL_WCSPLANE_CP850; - } } else { - s = c; - s &= MBFL_WCSGROUP_MASK; - s |= MBFL_WCSGROUP_THROUGH; + s = cp850_ucs_table[c - cp850_ucs_table_min]; } CK((*filter->output_function)(s, filter->data)); - return c; } -/* - * wchar => cp850 - */ -int -mbfl_filt_conv_wchar_cp850(int c, mbfl_convert_filter *filter) +int mbfl_filt_conv_wchar_cp850(int c, mbfl_convert_filter *filter) { - int s, n; - if (c < 0x80) { - s = c; + CK((*filter->output_function)(c, filter->data)); } else { - s = -1; - n = cp850_ucs_table_len-1; - while (n >= 0) { + for (int n = 0; n < cp850_ucs_table_len; n++) { if (c == cp850_ucs_table[n]) { - s = cp850_ucs_table_min + n; - break; + CK((*filter->output_function)(cp850_ucs_table_min + n, filter->data)); + return c; } - n--; - } - if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_CP850) { - s = c & MBFL_WCSPLANE_MASK; } - } - - if (s >= 0) { - CK((*filter->output_function)(s, filter->data)); - } else { CK(mbfl_filt_conv_illegal_output(c, filter)); } diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_consts.h b/ext/mbstring/libmbfl/mbfl/mbfl_consts.h index 6a895883062..fb309358de3 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfl_consts.h +++ b/ext/mbstring/libmbfl/mbfl/mbfl_consts.h @@ -74,7 +74,6 @@ #define MBFL_WCSPLANE_8859_16 0x70fa0000 /* 00h - FFh */ #define MBFL_WCSPLANE_ARMSCII8 0x70fb0000 #define MBFL_WCSPLANE_KOI8U 0x70fc0000 -#define MBFL_WCSPLANE_CP850 0x70fe0000 /* 00h - FFh */ #define MBFL_WCSPLANE_GB18030 0x70ff0000 /* a1a1h-e3329a35h */ #define MBFL_WCSGROUP_MASK 0xffffff #define MBFL_WCSGROUP_UCS4MAX 0x70000000

« previous php.cvs (#114025) next »