diff options
Diffstat (limited to 'StdLib/LibC/Stdio')
-rw-r--r-- | StdLib/LibC/Stdio/Stdio.inf | 1 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/freopen.c | 4 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/fseeko.c | 5 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/gettemp.c | 2 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/local.h | 10 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/mkstemp.c | 2 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/setbuffer.c | 23 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/vfwprintf.c | 35 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/vfwscanf.c | 11 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/vprintf.c | 2 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/vsnprintf.c | 2 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/vsnprintf_ss.c | 2 | ||||
-rw-r--r-- | StdLib/LibC/Stdio/vsprintf.c | 2 |
13 files changed, 52 insertions, 49 deletions
diff --git a/StdLib/LibC/Stdio/Stdio.inf b/StdLib/LibC/Stdio/Stdio.inf index 9d2adef1f6..6edc8867e8 100644 --- a/StdLib/LibC/Stdio/Stdio.inf +++ b/StdLib/LibC/Stdio/Stdio.inf @@ -72,6 +72,7 @@ snprintf.c
vsnprintf.c
+ fparseln.c
# Wide character functions
fgetwc.c #
diff --git a/StdLib/LibC/Stdio/freopen.c b/StdLib/LibC/Stdio/freopen.c index 4d34497317..75a086b84b 100644 --- a/StdLib/LibC/Stdio/freopen.c +++ b/StdLib/LibC/Stdio/freopen.c @@ -104,7 +104,7 @@ freopen(const char *file, const char *mode, FILE *fp) (void) __sflush(fp);
/* if close is NULL, closing is a no-op, hence pointless */
isopen = fp->_close != NULL;
- if ((wantfd = fp->_file) < 0 && isopen) {
+ if (((wantfd = fp->_file) >= 0) && isopen) {
(void) (*fp->_close)(fp->_cookie);
isopen = 0;
}
@@ -127,7 +127,7 @@ freopen(const char *file, const char *mode, FILE *fp) * keep fp->_base: it may be the wrong size. This loses the effect
* of any setbuffer calls, but stdio has always done this before.
*/
- if (isopen && f != wantfd)
+ if (isopen && (f != wantfd))
(void) (*fp->_close)(fp->_cookie);
if (fp->_flags & __SMBF)
free((char *)fp->_bf._base);
diff --git a/StdLib/LibC/Stdio/fseeko.c b/StdLib/LibC/Stdio/fseeko.c index 7fc7e42661..662d25f91a 100644 --- a/StdLib/LibC/Stdio/fseeko.c +++ b/StdLib/LibC/Stdio/fseeko.c @@ -238,6 +238,7 @@ fseeko(FILE *fp, off_t offset, int whence) fp->_r = (int)(n - o);
if (HASUB(fp))
FREEUB(fp);
+ WCIO_FREE(fp); /* Should this really be unconditional??? */
fp->_flags &= ~__SEOF;
FUNLOCKFILE(fp);
return (0);
@@ -261,6 +262,7 @@ fseeko(FILE *fp, off_t offset, int whence) fp->_p = fp->_bf._base;
if (HASUB(fp))
FREEUB(fp);
+ WCIO_FREE(fp); /* Should this really be unconditional??? */
fp->_flags &= ~__SEOF;
n = (int)(target - curoff);
if (n) {
@@ -290,9 +292,10 @@ dumb: /* success: clear EOF indicator and discard ungetc() data */
if (HASUB(fp))
FREEUB(fp);
+ WCIO_FREE(fp); /* Should this really be unconditional??? */
fp->_p = fp->_bf._base;
fp->_r = 0;
- /* fp->_w = 0; */ /* unnecessary (I think...) */
+ fp->_w = 0;
fp->_flags &= ~__SEOF;
FUNLOCKFILE(fp);
//Print(L"%a: %d\n", __func__, __LINE__);
diff --git a/StdLib/LibC/Stdio/gettemp.c b/StdLib/LibC/Stdio/gettemp.c index 1bd7dd3924..7b1c564c9a 100644 --- a/StdLib/LibC/Stdio/gettemp.c +++ b/StdLib/LibC/Stdio/gettemp.c @@ -45,7 +45,7 @@ #include "nbtool_config.h"
#endif
-#if !HAVE_NBTOOL_CONFIG_H || !HAVE_MKSTEMP || !HAVE_MKDTEMP
+#if !defined(HAVE_NBTOOL_CONFIG_H) || !defined(HAVE_MKSTEMP) || !defined(HAVE_MKDTEMP)
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
diff --git a/StdLib/LibC/Stdio/local.h b/StdLib/LibC/Stdio/local.h index f9eaba9989..262deb3611 100644 --- a/StdLib/LibC/Stdio/local.h +++ b/StdLib/LibC/Stdio/local.h @@ -64,11 +64,11 @@ extern int _fwalk(int (*)(FILE *)); extern char *_mktemp(char *);
extern int __swsetup(FILE *);
extern int __sflags(const char *, int *);
-extern int __svfscanf(FILE * __restrict, const char * __restrict, _BSD_VA_LIST_)
+extern int __svfscanf(FILE * __restrict, const char * __restrict, va_list)
__attribute__((__format__(__scanf__, 2, 0)));
-extern int __svfscanf_unlocked(FILE * __restrict, const char * __restrict, _BSD_VA_LIST_)
+extern int __svfscanf_unlocked(FILE * __restrict, const char * __restrict, va_list)
__attribute__((__format__(__scanf__, 2, 0)));
-extern int __vfprintf_unlocked(FILE * __restrict, const char * __restrict, _BSD_VA_LIST_);
+extern int __vfprintf_unlocked(FILE * __restrict, const char * __restrict, va_list);
extern int __sdidinit;
@@ -80,8 +80,8 @@ extern wint_t __fputwc_unlock(wchar_t, FILE *); extern char *__fgetstr(FILE * __restrict, size_t * __restrict, int);
extern int __slbexpand(FILE *, size_t);
-extern int __vfwprintf_unlocked(FILE *, const wchar_t *, _BSD_VA_LIST_);
-extern int __vfwscanf_unlocked(FILE * __restrict, const wchar_t * __restrict, _BSD_VA_LIST_);
+extern int __vfwprintf_unlocked(FILE *, const wchar_t *, va_list);
+extern int __vfwscanf_unlocked(FILE * __restrict, const wchar_t * __restrict, va_list);
/*
* Return true iff the given FILE cannot be written now.
diff --git a/StdLib/LibC/Stdio/mkstemp.c b/StdLib/LibC/Stdio/mkstemp.c index 7ea578ce4a..d2962214dd 100644 --- a/StdLib/LibC/Stdio/mkstemp.c +++ b/StdLib/LibC/Stdio/mkstemp.c @@ -34,7 +34,7 @@ #include "nbtool_config.h"
#endif
-#if !HAVE_NBTOOL_CONFIG_H || !HAVE_MKSTEMP
+#if !defined(HAVE_NBTOOL_CONFIG_H) || !defined(HAVE_MKSTEMP)
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
diff --git a/StdLib/LibC/Stdio/setbuffer.c b/StdLib/LibC/Stdio/setbuffer.c index 9527a4b3f6..761f67f88c 100644 --- a/StdLib/LibC/Stdio/setbuffer.c +++ b/StdLib/LibC/Stdio/setbuffer.c @@ -1,6 +1,13 @@ -/* $NetBSD: setbuffer.c,v 1.10 2003/08/07 16:43:31 agc Exp $ */
+/*
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License that accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,16 +37,12 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- */
+
+ NetBSD: setbuffer.c,v 1.10 2003/08/07 16:43:31 agc Exp
+ setbuffer.c 8.1 (Berkeley) 6/4/93
+*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)setbuffer.c 8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: setbuffer.c,v 1.10 2003/08/07 16:43:31 agc Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
diff --git a/StdLib/LibC/Stdio/vfwprintf.c b/StdLib/LibC/Stdio/vfwprintf.c index 3c5332ac4a..0554edb645 100644 --- a/StdLib/LibC/Stdio/vfwprintf.c +++ b/StdLib/LibC/Stdio/vfwprintf.c @@ -1056,8 +1056,6 @@ reswitch: switch (ch) { xdigs = xdigs_upper;
expchar = 'P';
}
- if (prec >= 0)
- prec++;
if (flags & LONGDBL) {
fparg.ldbl = GETARG(long double);
dtoaresult =
@@ -1092,10 +1090,8 @@ reswitch: switch (ch) { case 'e':
case 'E':
expchar = ch;
- if (prec < 0) /* account for digit before decpt */
- prec = DEFPREC + 1;
- else
- prec++;
+ if (prec < 0)
+ prec = DEFPREC;
goto fp_begin;
case 'f':
case 'F':
@@ -1165,10 +1161,8 @@ fp_common: case 'e':
case 'E':
expchar = ch;
- if (prec < 0) /* account for digit before decpt */
- prec = DEFPREC /* + 1*/ ;
- else
- prec++;
+ if (prec < 0)
+ prec = DEFPREC;
goto fp_begin;
case 'f':
case 'F':
@@ -1242,16 +1236,21 @@ fp_begin: /*
* Make %[gG] smell like %[eE], but
* trim trailing zeroes if no # flag.
+ *
+ * Note: The precision field used with [gG] is the number significant
+ * digits to print. When converting to [eE] the digit before the
+ * decimal must not be included in the precision value.
*/
if (!(flags & ALT))
- prec = ndig;
+ prec = ndig - 1;
}
}
if (expchar) {
+ dprec = prec; /* In some cases dprec will not be set. Make sure it is set now */
expsize = exponent(expstr, expt - 1, expchar);
- size = expsize + prec;
- if (prec > 1 || flags & ALT)
- ++size;
+ size = expsize + prec + 1; /* Leading digit + exponent string + precision */
+ if (prec >= 1 || flags & ALT)
+ ++size; /* Decimal point is added to character count */
} else {
/* space for digits before decimal point */
if (expt > 0)
@@ -1322,7 +1321,7 @@ fp_begin: * defined manner.''
* -- ANSI X3J11
*/
- ujval = (uintmax_t)GETARG(void *);
+ ujval = (uintmax_t) (UINTN) GETARG(void *);
base = 16;
xdigs = xdigs_lower;
flags = flags | INTMAXT;
@@ -1332,7 +1331,7 @@ fp_begin: flags |= LONGINT;
/*FALLTHROUGH*/
case 's':
- if ((flags & LONGINT) != MULTI) {
+ if (((flags & LONGINT) ? 1:0) != MULTI) {
if ((result = GETARG(CHAR_T *)) == NULL)
result = STRCONST("(null)");
} else {
@@ -1538,7 +1537,7 @@ number: if ((dprec = prec) >= 0) PRINTANDPAD(result, convbuf + ndig, prec,
zeroes);
} else { /* %[eE] or sufficiently long %[gG] */
- if (prec > 1 || flags & ALT) {
+ if (prec >= 1 || flags & ALT) {
buf[0] = *result++;
buf[1] = *decimal_point;
PRINT(buf, 2);
@@ -2003,8 +2002,6 @@ cvt(double value, int ndigits, int flags, char *sign, int *decpt, int ch, *decpt = -ndigits + 1;
bp += *decpt;
}
- if (value == 0) /* kludge for __dtoa irregularity */
- rve = bp;
while (rve < bp)
*rve++ = '0';
}
diff --git a/StdLib/LibC/Stdio/vfwscanf.c b/StdLib/LibC/Stdio/vfwscanf.c index 3d7404171b..7bf3f66690 100644 --- a/StdLib/LibC/Stdio/vfwscanf.c +++ b/StdLib/LibC/Stdio/vfwscanf.c @@ -198,7 +198,7 @@ literal: goto input_failure;
if (wi != c) {
ungetwc(wi, fp);
- goto input_failure;
+ goto match_failure;
}
nread++;
continue;
@@ -721,20 +721,19 @@ literal: if ((width = parsefloat(fp, buf, buf + width)) == 0)
goto match_failure;
if ((flags & SUPPRESS) == 0) {
-#ifdef notyet
+#ifdef REAL_LONG_DOUBLE_SUPPORT
if (flags & LONGDBL) {
long double res = wcstold(buf, &p);
*va_arg(ap, long double *) = res;
} else
#endif
- if (flags & LONG) {
+ if (flags & (LONG | LONGDBL)) {
double res = wcstod(buf, &p);
*va_arg(ap, double *) = res;
-#ifdef notyet
- } else {
+ }
+ else {
float res = wcstof(buf, &p);
*va_arg(ap, float *) = res;
-#endif
}
#ifdef DEBUG
if (p - buf != width)
diff --git a/StdLib/LibC/Stdio/vprintf.c b/StdLib/LibC/Stdio/vprintf.c index 96d43ee7a0..46ebf32970 100644 --- a/StdLib/LibC/Stdio/vprintf.c +++ b/StdLib/LibC/Stdio/vprintf.c @@ -50,7 +50,7 @@ #include <stdio.h>
int
-vprintf(char const *fmt, _BSD_VA_LIST_ ap)
+vprintf(char const *fmt, va_list ap)
{
_DIAGASSERT(fmt != NULL);
diff --git a/StdLib/LibC/Stdio/vsnprintf.c b/StdLib/LibC/Stdio/vsnprintf.c index 23385ba0d8..16e06667bc 100644 --- a/StdLib/LibC/Stdio/vsnprintf.c +++ b/StdLib/LibC/Stdio/vsnprintf.c @@ -54,7 +54,7 @@ __weak_alias(vsnprintf,_vsnprintf) #endif
int
-vsnprintf(char *str, size_t n, const char *fmt, _BSD_VA_LIST_ ap)
+vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
{
int ret;
FILE f;
diff --git a/StdLib/LibC/Stdio/vsnprintf_ss.c b/StdLib/LibC/Stdio/vsnprintf_ss.c index 77a2887ea6..a71dd6d3e5 100644 --- a/StdLib/LibC/Stdio/vsnprintf_ss.c +++ b/StdLib/LibC/Stdio/vsnprintf_ss.c @@ -117,7 +117,7 @@ __weak_alias(vsnprintf_ss,_vsnprintf_ss) } while (/*CONSTCOND*/0)
int
-vsnprintf_ss(char *sbuf, size_t slen, const char *fmt0, _BSD_VA_LIST_ ap)
+vsnprintf_ss(char *sbuf, size_t slen, const char *fmt0, va_list ap)
{
const char *fmt; /* format string */
int ch; /* character from fmt */
diff --git a/StdLib/LibC/Stdio/vsprintf.c b/StdLib/LibC/Stdio/vsprintf.c index 4fb8d28155..9534d95e1b 100644 --- a/StdLib/LibC/Stdio/vsprintf.c +++ b/StdLib/LibC/Stdio/vsprintf.c @@ -53,7 +53,7 @@ #include "local.h"
int
-vsprintf(char *str, const char *fmt, _BSD_VA_LIST_ ap)
+vsprintf(char *str, const char *fmt, va_list ap)
{
int ret;
FILE f;
|