From f15d2a01f75304bc2d9dac109d9a5a47d1ce28e0 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 12 Jan 2022 11:34:23 +0100 Subject: [PATCH] lcUTF8: remove two unneeded ifs and two elses that are never reached When there is a break at the end of the while loop, it means that the loop will finish the first time that _XlcGetCharSetWithSide() returns a non-NULL result, which means that the first '(last_charset == NULL)' will always be true and the else part is redundant. Fixes issue #46. Reported-by: Bhavi Dhingra Signed-off-by: Benno Schulenberg --- src/xlibi18n/lcUTF8.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/xlibi18n/lcUTF8.c b/src/xlibi18n/lcUTF8.c index b18f77e1..8169608a 100644 --- a/src/xlibi18n/lcUTF8.c +++ b/src/xlibi18n/lcUTF8.c @@ -742,20 +742,14 @@ utf8tocs1( continue; } + last_charset = _XlcGetCharSetWithSide(chosen_charset->name, chosen_side); + if (last_charset == NULL) { - last_charset = - _XlcGetCharSetWithSide(chosen_charset->name, chosen_side); - if (last_charset == NULL) { - src += consumed; - unconv_num++; - continue; - } - } else { - if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name - && (last_charset->side == XlcGLGR - || last_charset->side == chosen_side))) - break; + src += consumed; + unconv_num++; + continue; } + src += consumed; dst += count; break; @@ -1615,20 +1609,14 @@ wcstocs1( continue; } + last_charset = _XlcGetCharSetWithSide(chosen_charset->name, chosen_side); + if (last_charset == NULL) { - last_charset = - _XlcGetCharSetWithSide(chosen_charset->name, chosen_side); - if (last_charset == NULL) { - src++; - unconv_num++; - continue; - } - } else { - if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name - && (last_charset->side == XlcGLGR - || last_charset->side == chosen_side))) - break; + src++; + unconv_num++; + continue; } + src++; dst += count; break;