From: Paul Eggert Date: Sat, 3 Aug 2024 06:32:42 +0000 (-0700) Subject: Minor utf8.c improvements X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c26c2ea2e9747101b4c63640bbdf8225f184e13d;p=thirdparty%2Ftar.git Minor utf8.c improvements * src/utf8.c: Minor rephrases for -1. --- diff --git a/src/utf8.c b/src/utf8.c index 6dde8814..2e499a9c 100644 --- a/src/utf8.c +++ b/src/utf8.c @@ -35,7 +35,8 @@ # define iconv_open(tocode, fromcode) ((iconv_t) -1) # undef iconv -# define iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft) (errno = ENOSYS, (size_t) -1) +# define iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft) \ + (errno = ENOSYS, SIZE_MAX) # undef iconv_close # define iconv_close(cd) 0 @@ -77,7 +78,7 @@ utf8_convert (bool to_utf, char const *input, char **output) *output = xstrdup (input); return true; } - else if (cd == (iconv_t)-1) + else if (cd == (iconv_t) -1) return false; inlen = strlen (input) + 1; @@ -93,7 +94,7 @@ utf8_convert (bool to_utf, char const *input, char **output) implementation-defined conversion on this character." It will "update the variables pointed to by the arguments to reflect the extent of the conversion and return the number of non-identical conversions performed". - On error, it returns -1. + On error, it returns SIZE_MAX. In other words, non-zero return always indicates failure, either because the input was not fully converted, or because it was converted in a non-reversible way.