]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
tuklib_mbstr_width: Update a comment about shift states
authorLasse Collin <lasse.collin@tukaani.org>
Mon, 16 Dec 2024 18:08:27 +0000 (20:08 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Wed, 18 Dec 2024 15:09:30 +0000 (17:09 +0200)
src/common/tuklib_mbstr_width.c

index e7052235d49ce96cc4caca30783280105db94806..f003aed11a3b594398918d1ccdd6b7ff45c03330 100644 (file)
@@ -62,9 +62,14 @@ tuklib_mbstr_width(const char *str, size_t *bytes)
 #endif
        }
 
-       // Require that the string ends in the initial shift state.
-       // This way the caller can be combine the string with other
-       // strings without needing to worry about the shift states.
+       // It's good to check that the string ended in the initial state.
+       // However, in practice this is redundant:
+       //
+       //   - No one will use this code with character sets that have
+       //     locking shift states.
+       //
+       //   - We already checked that mbrtowc() didn't return (size_t)-2
+       //     which would indicate a partial multibyte character.
        if (!mbsinit(&state))
                return (size_t)-1;