From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61258 invoked by alias); 4 Apr 2018 13:57:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 61140 invoked by uid 89); 4 Apr 2018 13:57:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Date: Wed, 04 Apr 2018 13:57:00 -0000 To: libc-alpha@sourceware.org Subject: [PATCH] manual: Result of mbrtowc is a single wide character User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20180404135733.3097D406F5A23@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) X-SW-Source: 2018-04/txt/msg00114.txt.bz2 2018-04-04 Florian Weimer * manual/charset.texi (Converting a Character): Result of mbrtowc is not a string, but a single wide character. * manual/examples/mbstouwcs.c (mbstouwcs): Adjust. diff --git a/manual/charset.texi b/manual/charset.texi index 6831ebec27..b37fac4df1 100644 --- a/manual/charset.texi +++ b/manual/charset.texi @@ -643,8 +643,8 @@ and they also do not require it to be in the initial state. @cindex stateful The @code{mbrtowc} function (``multibyte restartable to wide character'') converts the next multibyte character in the string pointed -to by @var{s} into a wide character and stores it in the wide character -string pointed to by @var{pwc}. The conversion is performed according +to by @var{s} into a wide character and stores it in the location +pointed to by @var{pwc}. The conversion is performed according to the locale currently selected for the @code{LC_CTYPE} category. If the conversion for the character set used in the locale requires a state, the multibyte string is interpreted in the state represented by the @@ -690,7 +690,7 @@ checking, and sometimes leaks memory): @end smallexample The use of @code{mbrtowc} should be clear. A single wide character is -stored in @code{@var{tmp}[0]}, and the number of consumed bytes is stored +stored in @code{*@var{tmp}}, and the number of consumed bytes is stored in the variable @var{nbytes}. If the conversion is successful, the uppercase variant of the wide character is stored in the @var{result} array and the pointer to the input string and the number of available diff --git a/manual/examples/mbstouwcs.c b/manual/examples/mbstouwcs.c index 5d223da2ae..3a8b9a65f9 100644 --- a/manual/examples/mbstouwcs.c +++ b/manual/examples/mbstouwcs.c @@ -20,7 +20,7 @@ mbstouwcs (const char *s) if (nbytes >= (size_t) -2) /* Invalid input string. */ return NULL; - *wcp++ = towupper (tmp[0]); + *wcp++ = towupper (*tmp); len -= nbytes; s += nbytes; }