glibc/manual/examples
Florian Weimer cf138b0c83 manual: Various fixes to the mbstouwcs example, and mbrtowc update
The example did not work because the null byte was not converted, and
mbrtowc was called with a zero-length input string.  This results in a
(size_t) -2 return value, so the function always returns NULL.

The size computation for the heap allocation of the result was
incorrect because it did not deal with integer overflow.

Error checking was missing, and the allocated memory was not freed on
error paths.  All error returns now set errno.  (Note that there is an
assumption that free does not clobber errno.)

The slightly unportable comparision against (size_t) -2 to catch both
(size_t) -1 and (size_t) -2 return values is gone as well.

A null wide character needs to be stored in the result explicitly, to
terminate it.

The description in the manual is updated to deal with these finer
points.  The (size_t) -2 behavior (consuming the input bytes) matches
what is specified in ISO C11.
2018-04-05 12:52:19 +02:00
..
add.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
argp-ex1.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
argp-ex2.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
argp-ex3.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
argp-ex4.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
atexit.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
db.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dir2.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
dir.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
execinfo.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
filecli.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
filesrv.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
fmtmsgexpl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
genpass.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
inetcli.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
inetsrv.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
isockad.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
longopt.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
mbstouwcs.c manual: Various fixes to the mbstouwcs example, and mbrtowc update 2018-04-05 12:52:19 +02:00
memopen.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
memstrm.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
mkdirent.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
mkfsock.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
mkisock.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
mygetpass.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
ofdlocks.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
pipe.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
popen.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
README BZ #13792: License manual example source files under GPL. 2012-03-02 16:52:01 -08:00
rprintf.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
search.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
select.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
setjmp.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigh1.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigusr.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
stpcpy.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
strdupa.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
strftim.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
subopt.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
swapcontext.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
termios.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
testopt.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
testpass.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
timeval_subtract.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00

These are source files for example code that appears in The GNU C
Library Reference Manual.

While the manual itself is licensed under the terms of the GNU Free
Documentation License, you can use these source files on their own
under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License, or (at your
option) any later version.