diff mbox series

manual: Result of mbrtowc is a single wide character

Message ID 20180404135733.3097D406F5A23@oldenburg.str.redhat.com
State New
Headers show
Series manual: Result of mbrtowc is a single wide character | expand

Commit Message

Florian Weimer April 4, 2018, 1:57 p.m. UTC
2018-04-04  Florian Weimer  <fweimer@redhat.com>

	* manual/charset.texi (Converting a Character): Result of mbrtowc
	is not a string, but a single wide character.
	* manual/examples/mbstouwcs.c (mbstouwcs): Adjust.

Comments

Andreas Schwab April 4, 2018, 2:21 p.m. UTC | #1
On Apr 04 2018, fweimer@redhat.com (Florian Weimer) wrote:

> 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);

tmp is declared as an array, so tmp[0] is more natural.

Andreas.
Florian Weimer April 5, 2018, 9:51 a.m. UTC | #2
On 04/04/2018 04:21 PM, Andreas Schwab wrote:
> On Apr 04 2018, fweimer@redhat.com (Florian Weimer) wrote:
> 
>> 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);
> 
> tmp is declared as an array, so tmp[0] is more natural.

Thanks.  I'm going to fold this change into the other patch.

Florian
diff mbox series

Patch

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;
     }