summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/local.h
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2012-04-29 16:28:39 +0000
committerdas <das@FreeBSD.org>2012-04-29 16:28:39 +0000
commit99428404bed28d421872e61f367292954ab61dc2 (patch)
tree90305c02b6140f111de9eb5ca26f308a7e9ed0d9 /lib/libc/stdio/local.h
parentbfedf1ea421f9d5cf143cd7304bbcc03525462db (diff)
downloadFreeBSD-src-99428404bed28d421872e61f367292954ab61dc2.zip
FreeBSD-src-99428404bed28d421872e61f367292954ab61dc2.tar.gz
Previously, vfscanf()'s wide character processing functions were
reading wide characters manually. With this change, they now use fgetwc(). To make this work, we use an internal version of fgetwc() with a few extensions: it takes an mbstate * because non-wide streams don't have a built-in mbstate, and it indicates the number of bytes read. vfscanf() now resembles vfwscanf() more closely. Minor functional improvements include working xlocale support in vfscanf(), setting the stream error indicator on encoding errors, and proper handling of shift-based encodings. (Actually, making shift-based encodings work with non-wide streams is hopeless, but the implementation now matches the broken specification.)
Diffstat (limited to 'lib/libc/stdio/local.h')
-rw-r--r--lib/libc/stdio/local.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/libc/stdio/local.h b/lib/libc/stdio/local.h
index 8b37f0d..7168f62 100644
--- a/lib/libc/stdio/local.h
+++ b/lib/libc/stdio/local.h
@@ -56,7 +56,7 @@ extern int _ftello(FILE *, fpos_t *);
extern int _fseeko(FILE *, off_t, int, int);
extern int __fflush(FILE *fp);
extern void __fcloseall(void);
-extern wint_t __fgetwc(FILE *, locale_t);
+extern wint_t __fgetwc_mbs(FILE *, mbstate_t *, int *, locale_t);
extern wint_t __fputwc(wchar_t, FILE *, locale_t);
extern int __sflush(FILE *);
extern FILE *__sfp(void);
@@ -85,6 +85,13 @@ extern size_t __fread(void * __restrict buf, size_t size, size_t count,
FILE * __restrict fp);
extern int __sdidinit;
+static inline wint_t
+__fgetwc(FILE *fp, locale_t locale)
+{
+ int nread;
+
+ return (__fgetwc_mbs(fp, &fp->_mbstate, &nread, locale));
+}
/*
* Prepare the given FILE for writing, and return 0 iff it
OpenPOWER on IntegriCloud