Currently mingw_vfwscanf.c files provides 3 functions:
mingw_swformat(), mingw_vfwscanf() and mingw_vswscanf().

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_vfwscanf.c => mingw_swformat.c}    |   46 +-
 mingw-w64-crt/stdio/mingw_swformat.h          |   63 +
 mingw-w64-crt/stdio/mingw_vfwscanf.c          | 1645 +----------------
 mingw-w64-crt/stdio/mingw_vswscanf.c          |   15 +
 5 files changed, 102 insertions(+), 1671 deletions(-)
 copy mingw-w64-crt/stdio/{mingw_vfwscanf.c => mingw_swformat.c} (97%)
 create mode 100644 mingw-w64-crt/stdio/mingw_swformat.h
 rewrite mingw-w64-crt/stdio/mingw_vfwscanf.c (99%)
 create mode 100644 mingw-w64-crt/stdio/mingw_vswscanf.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index e364d761b85d..c207b3bcabac 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    mingw_sformat.h           \
+  stdio/mingw_pformat.h    mingw_sformat.h           mingw_swformat.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_sformat.c     stdio/mingw_vsscanf.c    \
+  stdio/mingw_vfwscanf.c   stdio/mingw_vswscanf.c    stdio/mingw_vsscanf.c    
stdio/mingw_sformat.c     stdio/mingw_swformat.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_vfwscanf.c 
b/mingw-w64-crt/stdio/mingw_swformat.c
similarity index 97%
copy from mingw-w64-crt/stdio/mingw_vfwscanf.c
copy to mingw-w64-crt/stdio/mingw_swformat.c
index 81cb46b661e9..5f4b2c08f395 100644
--- a/mingw-w64-crt/stdio/mingw_vfwscanf.c
+++ b/mingw-w64-crt/stdio/mingw_swformat.c
@@ -57,6 +57,8 @@
 #include <locale.h>
 #include <errno.h>
 
+#include "mingw_swformat.h"
+
 #ifndef CP_UTF8
 #define CP_UTF8 65001
 #endif
@@ -80,19 +82,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 wchar_t *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)
 {
@@ -123,7 +112,7 @@ optimize_alloc (char **p, char *end, size_t alloc_sz)
 }
 
 static void
-back_ch (int c, _IFP *s, size_t *rin, int not_eof)
+back_ch (int c, _IFPW *s, size_t *rin, int not_eof)
 {
   if (!not_eof && c == WEOF)
     return;
@@ -140,7 +129,7 @@ back_ch (int c, _IFP *s, size_t *rin, int not_eof)
 }
 
 static int
-in_ch (_IFP *s, size_t *rin)
+in_ch (_IFPW *s, size_t *rin)
 {
   int r;
   if (s->back_top)
@@ -179,7 +168,7 @@ in_ch (_IFP *s, size_t *rin)
 }
 
 static int
-match_string (_IFP *s, size_t *rin, wint_t *c, const wchar_t *str)
+match_string (_IFPW *s, size_t *rin, wint_t *c, const wchar_t *str)
 {
   int ch = *c;
 
@@ -308,8 +297,9 @@ resize_wbuf (size_t wpsz, size_t *wbuf_max_sz, wchar_t *old)
   return wbuf;
 }
 
-static int
-__mingw_swformat (_IFP *s, const wchar_t *format, va_list argp)
+int
+__cdecl
+__mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp)
 {
   const wchar_t *f = format;
   struct gcollect *gcollect = NULL;
@@ -1609,23 +1599,3 @@ __mingw_swformat (_IFP *s, const wchar_t *format, 
va_list argp)
 
   return cleanup_return (rval, &gcollect, pstr, &wbuf);
 }
-
-int
-__mingw_vfwscanf (FILE *s, const wchar_t *format, va_list argp)
-{
-  _IFP ifp;
-  memset (&ifp, 0, sizeof (_IFP));
-  ifp.fp = s;
-  return __mingw_swformat (&ifp, format, argp);
-}
-
-int
-__mingw_vswscanf (const wchar_t *s, const wchar_t *format, va_list argp)
-{
-  _IFP ifp;
-  memset (&ifp, 0, sizeof (_IFP));
-  ifp.str = s;
-  ifp.is_string = 1;
-  return __mingw_swformat (&ifp, format, argp);
-}
-
diff --git a/mingw-w64-crt/stdio/mingw_swformat.h 
b/mingw-w64-crt/stdio/mingw_swformat.h
new file mode 100644
index 000000000000..aea4c53fb6b0
--- /dev/null
+++ b/mingw-w64-crt/stdio/mingw_swformat.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 SWFORMAT_H
+#define SWFORMAT_H
+
+/* internal stream structure with back-buffer.  */
+typedef struct _IFPW
+{
+  __extension__ union {
+    void *fp;
+    const wchar_t *str;
+  };
+  int bch[1024];
+  unsigned int is_string : 1;
+  int back_top;
+  unsigned int seen_eof : 1;
+} _IFPW;
+
+int __cdecl __mingw_swformat(_IFPW *, const wchar_t *, va_list) 
__MINGW_NOTHROW;
+
+#endif /* !defined SWFORMAT_H */
diff --git a/mingw-w64-crt/stdio/mingw_vfwscanf.c 
b/mingw-w64-crt/stdio/mingw_vfwscanf.c
dissimilarity index 99%
index 81cb46b661e9..dfb156f6d059 100644
--- a/mingw-w64-crt/stdio/mingw_vfwscanf.c
+++ b/mingw-w64-crt/stdio/mingw_vfwscanf.c
@@ -?,? +1,14 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "mingw_swformat.h"
+
+int
+__mingw_vfwscanf (FILE *s, const wchar_t *format, va_list argp)
+{
+  _IFPW ifp;
+  memset (&ifp, 0, sizeof (_IFPW));
+  ifp.fp = s;
+  return __mingw_swformat (&ifp, format, argp);
+}
diff --git a/mingw-w64-crt/stdio/mingw_vswscanf.c 
b/mingw-w64-crt/stdio/mingw_vswscanf.c
new file mode 100644
index 000000000000..48767f229735
--- /dev/null
+++ b/mingw-w64-crt/stdio/mingw_vswscanf.c
@@ -0,0 +1,15 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "mingw_swformat.h"
+
+int
+__mingw_vswscanf (const wchar_t *s, const wchar_t *format, va_list argp)
+{
+  _IFPW ifp;
+  memset (&ifp, 0, sizeof (_IFPW));
+  ifp.str = s;
+  ifp.is_string = 1;
+  return __mingw_swformat (&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

Reply via email to