* [PATCH] manual: Result of mbrtowc is a single wide character
@ 2018-04-04 13:57 Florian Weimer
2018-04-04 14:21 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2018-04-04 13:57 UTC (permalink / raw)
To: libc-alpha
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.
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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] manual: Result of mbrtowc is a single wide character
2018-04-04 13:57 [PATCH] manual: Result of mbrtowc is a single wide character Florian Weimer
@ 2018-04-04 14:21 ` Andreas Schwab
2018-04-05 9:51 ` Florian Weimer
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2018-04-04 14:21 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
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.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] manual: Result of mbrtowc is a single wide character
2018-04-04 14:21 ` Andreas Schwab
@ 2018-04-05 9:51 ` Florian Weimer
0 siblings, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2018-04-05 9:51 UTC (permalink / raw)
To: Andreas Schwab; +Cc: libc-alpha
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-05 9:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04 13:57 [PATCH] manual: Result of mbrtowc is a single wide character Florian Weimer
2018-04-04 14:21 ` Andreas Schwab
2018-04-05 9:51 ` Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).