[PATCH] manual: Result of mbrtowc is a single wide character
Florian Weimer
fweimer@redhat.com
Wed Apr 4 13:57:00 GMT 2018
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;
}
More information about the Libc-alpha
mailing list