Deleted Added
full compact
vfwscanf.c (128002) vfwscanf.c (128822)
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 25 unchanged lines hidden (view full) ---

34 * SUCH DAMAGE.
35 */
36
37#include <sys/cdefs.h>
38#if 0
39#if defined(LIBC_SCCS) && !defined(lint)
40static char sccsid[] = "@(#)vfscanf.c 8.1 (Berkeley) 6/4/93";
41#endif /* LIBC_SCCS and not lint */
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 25 unchanged lines hidden (view full) ---

34 * SUCH DAMAGE.
35 */
36
37#include <sys/cdefs.h>
38#if 0
39#if defined(LIBC_SCCS) && !defined(lint)
40static char sccsid[] = "@(#)vfscanf.c 8.1 (Berkeley) 6/4/93";
41#endif /* LIBC_SCCS and not lint */
42__FBSDID("FreeBSD: src/lib/libc/stdio/vfscanf.c,v 1.35 2004/01/31 23:16:09 das Exp ");
42__FBSDID("FreeBSD: src/lib/libc/stdio/vfscanf.c,v 1.37 2004/05/02 10:55:05 das
43Exp");
43#endif
44#endif
44__FBSDID("$FreeBSD: head/lib/libc/stdio/vfwscanf.c 128002 2004-04-07 09:55:05Z tjr $");
45__FBSDID("$FreeBSD: head/lib/libc/stdio/vfwscanf.c 128822 2004-05-02 10:56:26Z das $");
45
46#include "namespace.h"
47#include <ctype.h>
48#include <inttypes.h>
49#include <stdio.h>
50#include <stdlib.h>
51#include <stddef.h>
52#include <stdarg.h>
53#include <string.h>
54#include <wchar.h>
55#include <wctype.h>
56#include "un-namespace.h"
57
58#include "libc_private.h"
59#include "local.h"
60
46
47#include "namespace.h"
48#include <ctype.h>
49#include <inttypes.h>
50#include <stdio.h>
51#include <stdlib.h>
52#include <stddef.h>
53#include <stdarg.h>
54#include <string.h>
55#include <wchar.h>
56#include <wctype.h>
57#include "un-namespace.h"
58
59#include "libc_private.h"
60#include "local.h"
61
61#define FLOATING_POINT
62
63#ifdef FLOATING_POINT
62#ifndef NO_FLOATING_POINT
64#include <locale.h>
65#endif
66
67#define BUF 513 /* Maximum length of numeric string. */
68
69/*
70 * Flags used during conversion.
71 */

--- 186 unchanged lines hidden (view full) ---

258 case 'X':
259 case 'x':
260 flags |= PFXOK; /* enable 0x prefixing */
261 c = CT_INT;
262 flags |= UNSIGNED;
263 base = 16;
264 break;
265
63#include <locale.h>
64#endif
65
66#define BUF 513 /* Maximum length of numeric string. */
67
68/*
69 * Flags used during conversion.
70 */

--- 186 unchanged lines hidden (view full) ---

257 case 'X':
258 case 'x':
259 flags |= PFXOK; /* enable 0x prefixing */
260 c = CT_INT;
261 flags |= UNSIGNED;
262 base = 16;
263 break;
264
266#ifdef FLOATING_POINT
265#ifndef NO_FLOATING_POINT
267 case 'A': case 'E': case 'F': case 'G':
268 case 'a': case 'e': case 'f': case 'g':
269 c = CT_FLOAT;
270 break;
271#endif
272
273 case 'S':
274 flags |= LONG;

--- 410 unchanged lines hidden (view full) ---

685 else
686 *va_arg(ap, int *) = res;
687 nassigned++;
688 }
689 nread += p - buf;
690 nconversions++;
691 break;
692
266 case 'A': case 'E': case 'F': case 'G':
267 case 'a': case 'e': case 'f': case 'g':
268 c = CT_FLOAT;
269 break;
270#endif
271
272 case 'S':
273 flags |= LONG;

--- 410 unchanged lines hidden (view full) ---

684 else
685 *va_arg(ap, int *) = res;
686 nassigned++;
687 }
688 nread += p - buf;
689 nconversions++;
690 break;
691
693#ifdef FLOATING_POINT
692#ifndef NO_FLOATING_POINT
694 case CT_FLOAT:
695 /* scan a floating point number as if by strtod */
696 if (width == 0 || width > sizeof(buf) /
697 sizeof(*buf) - 1)
698 width = sizeof(buf) / sizeof(*buf) - 1;
699 if ((width = parsefloat(fp, buf, buf + width)) == 0)
700 goto match_failure;
701 if ((flags & SUPPRESS) == 0) {

--- 9 unchanged lines hidden (view full) ---

711 }
712 if (__scanfdebug && p - buf != width)
713 abort();
714 nassigned++;
715 }
716 nread += width;
717 nconversions++;
718 break;
693 case CT_FLOAT:
694 /* scan a floating point number as if by strtod */
695 if (width == 0 || width > sizeof(buf) /
696 sizeof(*buf) - 1)
697 width = sizeof(buf) / sizeof(*buf) - 1;
698 if ((width = parsefloat(fp, buf, buf + width)) == 0)
699 goto match_failure;
700 if ((flags & SUPPRESS) == 0) {

--- 9 unchanged lines hidden (view full) ---

710 }
711 if (__scanfdebug && p - buf != width)
712 abort();
713 nassigned++;
714 }
715 nread += width;
716 nconversions++;
717 break;
719#endif /* FLOATING_POINT */
718#endif /* !NO_FLOATING_POINT */
720 }
721 }
722input_failure:
723 return (nconversions != 0 ? nassigned : EOF);
724match_failure:
725 return (nassigned);
726}
727
719 }
720 }
721input_failure:
722 return (nconversions != 0 ? nassigned : EOF);
723match_failure:
724 return (nassigned);
725}
726
728#ifdef FLOATING_POINT
727#ifndef NO_FLOATING_POINT
729static int
730parsefloat(FILE *fp, wchar_t *buf, wchar_t *end)
731{
732 wchar_t *commit, *p;
733 int infnanpos = 0;
734 enum {
735 S_START, S_GOTSIGN, S_INF, S_NAN, S_MAYBEHEX,
736 S_DIGITS, S_FRAC, S_EXP, S_EXPDIGITS

--- 144 unchanged lines hidden ---
728static int
729parsefloat(FILE *fp, wchar_t *buf, wchar_t *end)
730{
731 wchar_t *commit, *p;
732 int infnanpos = 0;
733 enum {
734 S_START, S_GOTSIGN, S_INF, S_NAN, S_MAYBEHEX,
735 S_DIGITS, S_FRAC, S_EXP, S_EXPDIGITS

--- 144 unchanged lines hidden ---