Merge "Upgrade to current vfprintf."
This commit is contained in:
@@ -79,7 +79,6 @@ libc_common_src_files := \
|
||||
stdio/fvwrite.c \
|
||||
stdio/snprintf.c\
|
||||
stdio/sprintf.c \
|
||||
stdio/vfprintf.c \
|
||||
stdlib/atexit.c \
|
||||
stdlib/getenv.c \
|
||||
stdlib/putenv.c \
|
||||
@@ -395,6 +394,7 @@ libc_upstream_openbsd_src_files := \
|
||||
upstream-openbsd/lib/libc/stdio/tmpnam.c \
|
||||
upstream-openbsd/lib/libc/stdio/ungetc.c \
|
||||
upstream-openbsd/lib/libc/stdio/vasprintf.c \
|
||||
upstream-openbsd/lib/libc/stdio/vfprintf.c \
|
||||
upstream-openbsd/lib/libc/stdio/vfscanf.c \
|
||||
upstream-openbsd/lib/libc/stdio/vprintf.c \
|
||||
upstream-openbsd/lib/libc/stdio/vscanf.c \
|
||||
|
@@ -243,21 +243,42 @@ size_t wcsftime(wchar_t* wcs, size_t maxsize, const wchar_t* format, const stru
|
||||
return strftime(reinterpret_cast<char*>(wcs), maxsize, reinterpret_cast<const char*>(format), timptr);
|
||||
}
|
||||
|
||||
size_t wcsrtombs(char* dst, const wchar_t** src, size_t len, mbstate_t* /*ps*/) {
|
||||
const char* s = reinterpret_cast<const char*>(*src);
|
||||
const char* s2 = reinterpret_cast<const char*>(memchr(s, 0, len));
|
||||
if (s2 != NULL) {
|
||||
len = (s2 - s)+1;
|
||||
size_t wcsrtombs(char* dst, const wchar_t** src, size_t n, mbstate_t* /*ps*/) {
|
||||
size_t i = 0; // Number of input characters read.
|
||||
size_t o = 0; // Number of output bytes written.
|
||||
for (; (*src)[i] != 0; ++i) {
|
||||
// TODO: UTF-8 support.
|
||||
if ((*src)[i] > 0x7f) {
|
||||
errno = EILSEQ;
|
||||
return static_cast<size_t>(-1);
|
||||
}
|
||||
if (dst != NULL) {
|
||||
if (o + 1 > n) {
|
||||
break;
|
||||
}
|
||||
dst[o++] = static_cast<char>((*src)[i]);
|
||||
} else {
|
||||
++o;
|
||||
}
|
||||
}
|
||||
// If we consumed all the input, terminate the output.
|
||||
if (dst != NULL && o < n) {
|
||||
dst[o] = 0;
|
||||
}
|
||||
// If we were actually consuming input, record how far we got.
|
||||
if (dst != NULL) {
|
||||
memcpy( dst, s, len );
|
||||
if ((*src)[i] != 0) {
|
||||
*src = &(*src)[i]; // This is where the next call should pick up.
|
||||
} else {
|
||||
*src = NULL; // We consumed everything.
|
||||
}
|
||||
}
|
||||
*src = (wchar_t*)(s + len);
|
||||
return len;
|
||||
return o;
|
||||
}
|
||||
|
||||
size_t wcstombs(char* dst, const wchar_t* src, size_t len) {
|
||||
return wcsrtombs(dst, &src, len, NULL);
|
||||
const wchar_t* p = src;
|
||||
return wcsrtombs(dst, &p, len, NULL);
|
||||
}
|
||||
|
||||
double wcstod(const wchar_t* nptr, wchar_t** endptr) {
|
||||
|
@@ -95,6 +95,8 @@ extern int __sdidinit;
|
||||
#define FUNLOCKFILE(fp) funlockfile(fp)
|
||||
|
||||
#define FLOATING_POINT
|
||||
#define PRINTF_WIDE_CHAR
|
||||
#define SCANF_WIDE_CHAR
|
||||
|
||||
/* OpenBSD exposes these in <stdio.h>, but we only want them exposed to the implementation. */
|
||||
__BEGIN_DECLS
|
||||
|
3
libc/upstream-openbsd/lib/libc/include/langinfo.h
Normal file
3
libc/upstream-openbsd/lib/libc/include/langinfo.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* Hack to build "vfprintf.c". */
|
||||
#define RADIXCHAR 1
|
||||
#define nl_langinfo(i) ((i == RADIXCHAR) ? (char*) "." : NULL)
|
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: floatio.h,v 1.3 2003/06/02 20:18:37 millert Exp $ */
|
||||
/* $OpenBSD: floatio.h,v 1.4 2008/09/07 20:36:08 martynas Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -40,3 +40,19 @@
|
||||
#define MAXEXP 308
|
||||
/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
|
||||
#define MAXFRACT 39
|
||||
|
||||
/*
|
||||
* MAXEXPDIG is the maximum number of decimal digits needed to store a
|
||||
* floating point exponent in the largest supported format. It should
|
||||
* be ceil(log10(LDBL_MAX_10_EXP)) or, if hexadecimal floating point
|
||||
* conversions are supported, ceil(log10(LDBL_MAX_EXP)). But since it
|
||||
* is presently never greater than 5 in practice, we fudge it.
|
||||
*/
|
||||
#define MAXEXPDIG 6
|
||||
#if LDBL_MAX_EXP > 999999
|
||||
#error "floating point buffers too small"
|
||||
#endif
|
||||
|
||||
char *__hdtoa(double, const char *, int, int *, int *, char **);
|
||||
char *__hldtoa(long double, const char *, int, int *, int *, char **);
|
||||
char *__ldtoa(long double *, int, int, int *, int *, char **);
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user