Deleted Added
full compact
vswscanf.c (122105) vswscanf.c (128002)
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 * Donn Seeley at UUNET Technologies, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

36
37#include <sys/cdefs.h>
38#if 0
39#if defined(LIBC_SCCS) && !defined(lint)
40static char sccsid[] = "@(#)vsscanf.c 8.1 (Berkeley) 6/4/93";
41#endif /* LIBC_SCCS and not lint */
42__FBSDID("FreeBSD: src/lib/libc/stdio/vsscanf.c,v 1.11 2002/08/21 16:19:57 mike Exp ");
43#endif
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 * Donn Seeley at UUNET Technologies, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

36
37#include <sys/cdefs.h>
38#if 0
39#if defined(LIBC_SCCS) && !defined(lint)
40static char sccsid[] = "@(#)vsscanf.c 8.1 (Berkeley) 6/4/93";
41#endif /* LIBC_SCCS and not lint */
42__FBSDID("FreeBSD: src/lib/libc/stdio/vsscanf.c,v 1.11 2002/08/21 16:19:57 mike Exp ");
43#endif
44__FBSDID("$FreeBSD: head/lib/libc/stdio/vswscanf.c 122105 2003-11-05 08:20:45Z tjr $");
44__FBSDID("$FreeBSD: head/lib/libc/stdio/vswscanf.c 128002 2004-04-07 09:55:05Z tjr $");
45
46#include <limits.h>
47#include <stdarg.h>
48#include <stdio.h>
49#include <stdlib.h>
50#include <string.h>
51#include <wchar.h>
52#include "local.h"

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

59
60 return (0);
61}
62
63int
64vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt,
65 va_list ap)
66{
45
46#include <limits.h>
47#include <stdarg.h>
48#include <stdio.h>
49#include <stdlib.h>
50#include <string.h>
51#include <wchar.h>
52#include "local.h"

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

59
60 return (0);
61}
62
63int
64vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt,
65 va_list ap)
66{
67 static const mbstate_t initial;
68 mbstate_t mbs;
67 FILE f;
68 struct __sFILEX ext;
69 char *mbstr;
70 size_t mlen;
71 int r;
72
73 /*
74 * XXX Convert the wide character string to multibyte, which
75 * __vfwscanf() will convert back to wide characters.
76 */
77 if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX + 1)) == NULL)
78 return (EOF);
69 FILE f;
70 struct __sFILEX ext;
71 char *mbstr;
72 size_t mlen;
73 int r;
74
75 /*
76 * XXX Convert the wide character string to multibyte, which
77 * __vfwscanf() will convert back to wide characters.
78 */
79 if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX + 1)) == NULL)
80 return (EOF);
79 if ((mlen = wcsrtombs(mbstr, &str, SIZE_T_MAX, NULL)) == (size_t)-1) {
81 mbs = initial;
82 if ((mlen = wcsrtombs(mbstr, &str, SIZE_T_MAX, &mbs)) == (size_t)-1) {
80 free(mbstr);
81 return (EOF);
82 }
83 f._file = -1;
84 f._flags = __SRD;
85 f._bf._base = f._p = (unsigned char *)mbstr;
86 f._bf._size = f._r = mlen;
87 f._read = eofread;
88 f._ub._base = NULL;
89 f._lb._base = NULL;
90 f._extra = &ext;
91 INITEXTRA(&f);
92 r = __vfwscanf(&f, fmt, ap);
93 free(mbstr);
94
95 return (r);
96}
83 free(mbstr);
84 return (EOF);
85 }
86 f._file = -1;
87 f._flags = __SRD;
88 f._bf._base = f._p = (unsigned char *)mbstr;
89 f._bf._size = f._r = mlen;
90 f._read = eofread;
91 f._ub._base = NULL;
92 f._lb._base = NULL;
93 f._extra = &ext;
94 INITEXTRA(&f);
95 r = __vfwscanf(&f, fmt, ap);
96 free(mbstr);
97
98 return (r);
99}