Currently mingw_vfscanf.c files provides 3 functions: mingw_sformat(), mingw_vfscanf() and mingw_vsscanf().
Split this file into 3 files, one for each function. Diff for this change from git is more human readable when showed by git options -B and -D. --- mingw-w64-crt/Makefile.am | 4 +- .../{mingw_vfscanf.c => mingw_sformat.c} | 38 +- mingw-w64-crt/stdio/mingw_sformat.h | 63 + mingw-w64-crt/stdio/mingw_vfscanf.c | 1646 +---------------- mingw-w64-crt/stdio/mingw_vsscanf.c | 15 + 5 files changed, 98 insertions(+), 1668 deletions(-) copy mingw-w64-crt/stdio/{mingw_vfscanf.c => mingw_sformat.c} (98%) create mode 100644 mingw-w64-crt/stdio/mingw_sformat.h rewrite mingw-w64-crt/stdio/mingw_vfscanf.c (99%) create mode 100644 mingw-w64-crt/stdio/mingw_vsscanf.c diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 22bb117a0faf..e364d761b85d 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -951,13 +951,13 @@ src_libmingwex=\ stdio/fopen64.c stdio/fseeko32.c stdio/fseeko64.c stdio/ftello.c \ stdio/ftello64.c stdio/ftruncate64.c stdio/lltoa.c stdio/lltow.c stdio/lseek64.c \ \ - stdio/mingw_pformat.h \ + stdio/mingw_pformat.h mingw_sformat.h \ stdio/mingw_fprintf.c stdio/mingw_fwprintf.c stdio/mingw_fscanf.c stdio/mingw_fwscanf.c stdio/mingw_pformat.c \ stdio/mingw_wpformat.c stdio/mingw_printf.c stdio/mingw_wprintf.c stdio/mingw_scanf.c stdio/mingw_snprintf.c \ stdio/mingw_swprintf.c stdio/mingw_snwprintf.c stdio/mingw_sprintf.c stdio/mingw_sscanf.c stdio/mingw_swscanf.c \ stdio/mingw_vfprintf.c stdio/mingw_vfwprintf.c stdio/mingw_vfscanf.c stdio/mingw_vprintf.c stdio/mingw_vwprintf.c \ stdio/mingw_vsnprintf.c stdio/mingw_vswprintf.c stdio/mingw_vsnwprintf.c stdio/mingw_vsprintf.c stdio/mingw_wscanf.c \ - stdio/mingw_vfwscanf.c \ + stdio/mingw_vfwscanf.c stdio/mingw_sformat.c stdio/mingw_vsscanf.c \ \ stdio/snprintf.c stdio/snwprintf.c stdio/truncate.c \ stdio/ulltoa.c stdio/ulltow.c stdio/vasprintf.c stdio/vfscanf.c stdio/vfwscanf.c \ diff --git a/mingw-w64-crt/stdio/mingw_vfscanf.c b/mingw-w64-crt/stdio/mingw_sformat.c similarity index 98% copy from mingw-w64-crt/stdio/mingw_vfscanf.c copy to mingw-w64-crt/stdio/mingw_sformat.c index 8ca81b54e117..040c2ae8874d 100644 --- a/mingw-w64-crt/stdio/mingw_vfscanf.c +++ b/mingw-w64-crt/stdio/mingw_sformat.c @@ -57,6 +57,8 @@ #include <locale.h> #include <errno.h> +#include "mingw_sformat.h" + /* Helper flags for conversion. */ #define IS_C 0x0001 #define IS_S 0x0002 @@ -72,19 +74,6 @@ #define IS_ALLOC_USED (USE_GNU_ALLOC | USE_POSIX_ALLOC) -/* internal stream structure with back-buffer. */ -typedef struct _IFP -{ - __extension__ union { - void *fp; - const char *str; - }; - int bch[1024]; - unsigned int is_string : 1; - int back_top; - unsigned int seen_eof : 1; -} _IFP; - static void * get_va_nth (va_list argp, unsigned int n) { @@ -299,7 +288,8 @@ resize_wbuf (size_t wpsz, size_t *wbuf_max_sz, char *old) return wbuf; } -static int +int +__cdecl __mingw_sformat (_IFP *s, const char *format, va_list argp) { const char *f = format; @@ -1610,23 +1600,3 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) return cleanup_return (rval, &gcollect, pstr, &wbuf); } - -int -__mingw_vfscanf (FILE *s, const char *format, va_list argp) -{ - _IFP ifp; - memset (&ifp, 0, sizeof (_IFP)); - ifp.fp = s; - return __mingw_sformat (&ifp, format, argp); -} - -int -__mingw_vsscanf (const char *s, const char *format, va_list argp) -{ - _IFP ifp; - memset (&ifp, 0, sizeof (_IFP)); - ifp.str = s; - ifp.is_string = 1; - return __mingw_sformat (&ifp, format, argp); -} - diff --git a/mingw-w64-crt/stdio/mingw_sformat.h b/mingw-w64-crt/stdio/mingw_sformat.h new file mode 100644 index 000000000000..7d133dd7f29b --- /dev/null +++ b/mingw-w64-crt/stdio/mingw_sformat.h @@ -0,0 +1,63 @@ +/* + This Software is provided under the Zope Public License (ZPL) Version 2.1. + + Copyright (c) 2011 by the mingw-w64 project + + See the AUTHORS file for the list of contributors to the mingw-w64 project. + + This license has been certified as open source. It has also been designated + as GPL compatible by the Free Software Foundation (FSF). + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions in source code must retain the accompanying copyright + notice, this list of conditions, and the following disclaimer. + 2. Redistributions in binary form must reproduce the accompanying + copyright notice, this list of conditions, and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + 3. Names of the copyright holders must not be used to endorse or promote + products derived from this software without prior written permission + from the copyright holders. + 4. The right to distribute this software or to use it for any purpose does + not give you the right to use Servicemarks (sm) or Trademarks (tm) of + the copyright holders. Use of them is covered by separate agreement + with the copyright holders. + 5. If any files are modified, you must cause the modified files to carry + prominent notices stating that you changed the files and the date of + any change. + + Disclaimer + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT 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. +*/ + +#ifndef SFORMAT_H +#define SFORMAT_H + +/* internal stream structure with back-buffer. */ +typedef struct _IFP +{ + __extension__ union { + void *fp; + const char *str; + }; + int bch[1024]; + unsigned int is_string : 1; + int back_top; + unsigned int seen_eof : 1; +} _IFP; + +int __cdecl __mingw_sformat(_IFP *, const char *, va_list) __MINGW_NOTHROW; + +#endif /* !defined SFORMAT_H */ diff --git a/mingw-w64-crt/stdio/mingw_vfscanf.c b/mingw-w64-crt/stdio/mingw_vfscanf.c dissimilarity index 99% index 8ca81b54e117..eadc9be321bc 100644 --- a/mingw-w64-crt/stdio/mingw_vfscanf.c +++ b/mingw-w64-crt/stdio/mingw_vfscanf.c @@ -?,? +1,14 @@ +#include <stdarg.h> +#include <stdio.h> +#include <string.h> + +#include "mingw_sformat.h" + +int +__mingw_vfscanf (FILE *s, const char *format, va_list argp) +{ + _IFP ifp; + memset (&ifp, 0, sizeof (_IFP)); + ifp.fp = s; + return __mingw_sformat (&ifp, format, argp); +} diff --git a/mingw-w64-crt/stdio/mingw_vsscanf.c b/mingw-w64-crt/stdio/mingw_vsscanf.c new file mode 100644 index 000000000000..52d72d9f0aa8 --- /dev/null +++ b/mingw-w64-crt/stdio/mingw_vsscanf.c @@ -0,0 +1,15 @@ +#include <stdarg.h> +#include <stdio.h> +#include <string.h> + +#include "mingw_sformat.h" + +int +__mingw_vsscanf (const char *s, const char *format, va_list argp) +{ + _IFP ifp; + memset (&ifp, 0, sizeof (_IFP)); + ifp.str = s; + ifp.is_string = 1; + return __mingw_sformat (&ifp, format, argp); +} -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public