From 4aa3feb8991e4d1ecf1c4915d25ab88863e84ef6 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Sun, 2 Mar 2003 07:00:48 +0000 Subject: 2003-03-02 Danny Smith * include/stdio.h (vscanf): Add prototype. (vfscanf): Ditto. (vsscanf): Ditto. (vwscanf): Ditto. (vfwscanf): Ditto. (vswscanf): Ditto. * include/wchar.h (vwscanf): Add prototype. (vfwscanf): Ditto. (vswscanf): Ditto. * mingwex/snprintf.c: Move to mingwex/stdio. * mingwex/vsnprintf.c: Ditto. * mingwex/snwprintf.c: Ditto. * mingwex/vsnwprintf.c: Ditto. * mingwex/Makefile.in (VPATH): Add $(srcdir)/stdio (STDIO_DISTFILES): Add. (DISTFILES): Adjust. (STDIO_STUB_OBJS): Rename to STDIO_OBJS and add v*scanf objects. (LIB_OBJS): Adjust. (dist): Adjust. 2003-03-02 Aaron W LaFramboise * mingwex/stdio: New directory * mingwex/stdio/vfscanf.c: New file. * mingwex/stdio/vfwscanf.c: New file. * mingwex/stdio/vscanf.c: New file. * mingwex/stdio/vsscanf.c: New file. * mingwex/stdio/vswscanf.c: New file. * mingwex/stdio/vwscanf.c: New file. --- winsup/mingw/mingwex/Makefile.in | 28 ++++++++++++++------- winsup/mingw/mingwex/snprintf.c | 13 ---------- winsup/mingw/mingwex/snwprintf.c | 13 ---------- winsup/mingw/mingwex/stdio/snprintf.c | 13 ++++++++++ winsup/mingw/mingwex/stdio/snwprintf.c | 13 ++++++++++ winsup/mingw/mingwex/stdio/vfscanf.c | 40 ++++++++++++++++++++++++++++++ winsup/mingw/mingwex/stdio/vfwscanf.c | 42 ++++++++++++++++++++++++++++++++ winsup/mingw/mingwex/stdio/vscanf.c | 9 +++++++ winsup/mingw/mingwex/stdio/vsnprintf.c | 5 ++++ winsup/mingw/mingwex/stdio/vsnwprintf.c | 5 ++++ winsup/mingw/mingwex/stdio/vsscanf.c | 41 +++++++++++++++++++++++++++++++ winsup/mingw/mingwex/stdio/vswscanf.c | 43 +++++++++++++++++++++++++++++++++ winsup/mingw/mingwex/stdio/vwscanf.c | 9 +++++++ winsup/mingw/mingwex/vsnprintf.c | 5 ---- winsup/mingw/mingwex/vsnwprintf.c | 5 ---- 15 files changed, 239 insertions(+), 45 deletions(-) delete mode 100644 winsup/mingw/mingwex/snprintf.c delete mode 100644 winsup/mingw/mingwex/snwprintf.c create mode 100644 winsup/mingw/mingwex/stdio/snprintf.c create mode 100644 winsup/mingw/mingwex/stdio/snwprintf.c create mode 100644 winsup/mingw/mingwex/stdio/vfscanf.c create mode 100644 winsup/mingw/mingwex/stdio/vfwscanf.c create mode 100644 winsup/mingw/mingwex/stdio/vscanf.c create mode 100644 winsup/mingw/mingwex/stdio/vsnprintf.c create mode 100644 winsup/mingw/mingwex/stdio/vsnwprintf.c create mode 100644 winsup/mingw/mingwex/stdio/vsscanf.c create mode 100644 winsup/mingw/mingwex/stdio/vswscanf.c create mode 100644 winsup/mingw/mingwex/stdio/vwscanf.c delete mode 100644 winsup/mingw/mingwex/vsnprintf.c delete mode 100644 winsup/mingw/mingwex/vsnwprintf.c (limited to 'winsup/mingw/mingwex') diff --git a/winsup/mingw/mingwex/Makefile.in b/winsup/mingw/mingwex/Makefile.in index bb96cac71..07fca1e36 100644 --- a/winsup/mingw/mingwex/Makefile.in +++ b/winsup/mingw/mingwex/Makefile.in @@ -4,7 +4,7 @@ # This makefile requires GNU make. srcdir = @srcdir@ -VPATH = $(srcdir):$(srcdir)/math +VPATH = $(srcdir):$(srcdir)/math:$(srcdir)/stdio objdir = . target_alias = @target_alias@ @@ -30,11 +30,12 @@ DISTFILES = Makefile.in configure configure.in \ fegetexceptflag.c fegetround.c feholdexcept.c feraiseexcept.c \ fesetenv.c fesetexceptflag.c fesetround.c fetestexcept.c \ feupdateenv.c fwide.c imaxabs.c imaxdiv.c ldtoa.c lltoa.c lltow.c \ - mbsinit.c mingw-fseek.c sitest.c snprintf.c snwprintf.c \ + mbsinit.c mingw-fseek.c sitest.c \ strtof.c strtoimax.c strtold.c strtoumax.c testwmem.c \ - ulltoa.c ulltow.c vsnprintf.c vsnwprintf.c wcstof.c \ + ulltoa.c ulltow.c wcstof.c \ wcstoimax.c wcstold.c wcstoumax.c wdirent.c wmemchr.c \ wmemcmp.c wmemcpy.c wmemmove.c wmemset.c wtoll.c + MATH_DISTFILES = \ acosf.c acosl.c asinf.c asinl.c atan2f.c atan2l.c \ atanf.c atanl.c cbrt.c cbrtf.c cbrtl.c ceilf.S ceill.S \ @@ -61,6 +62,10 @@ MATH_DISTFILES = \ sqrtf.c sqrtl.c tanf.S tanhf.c tanhl.c tanl.S tgamma.c \ tgammaf.c tgammal.c trunc.c truncf.c truncl.c +STDIO_DISTFILES = \ + snprintf.c snwprintf.c vsnprintf.c vsnwprintf.c \ + vfscanf.c vfwscanf.c vscanf.c vsscanf.c vswscanf.c vwscanf.c + CC = @CC@ # FIXME: Which is it, CC or CC_FOR_TARGET? CC_FOR_TARGET = $(CC) @@ -104,8 +109,9 @@ STDLIB_STUB_OBJS = \ atoll.o wtoll.o \ strtof.o wcstof.o \ _Exit.o -STDIO_STUB_OBJS = \ - snprintf.o vsnprintf.o snwprintf.o vsnwprintf.o +STDIO_OBJS = \ + snprintf.o vsnprintf.o snwprintf.o vsnwprintf.o \ + vfscanf.o vfwscanf.o vscanf.o vsscanf.o vswscanf.o vwscanf.o MATH_OBJS = \ acosf.o acosl.o asinf.o asinl.o atan2f.o atan2l.o \ atanf.o atanl.o cbrt.o cbrtf.o cbrtl.o ceilf.o ceill.o \ @@ -141,8 +147,8 @@ REPLACE_OBJS = \ mingw-fseek.o LIB_OBJS = $(Q8_OBJS) $(STDLIB_OBJS) $(STDLIB_STUB_OBJS) \ - $(STDIO_STUB_OBJS) $(MATH_OBJS) $(FENV_OBJS) $(POSIX_OBJS) \ - $(REPLACE_OBJS) + $(STDIO_OBJS) $(MATH_OBJS) $(FENV_OBJS) \ + $(POSIX_OBJS) $(REPLACE_OBJS) LIBS = $(LIBMINGWEX_A) DLLS = @@ -203,8 +209,12 @@ dist: cp -p $(srcdir)/$$i $(distdir)/mingwex/$$i ; \ done mkdir $(distdir)/mingwex/math - chmod 755 $(distdir)//mingwex/math + chmod 755 $(distdir)/mingwex/math @for i in $(MATH_DISTFILES); do\ cp -p $(srcdir)/math/$$i $(distdir)/mingwex/math/$$i ; \ done - + mkdir $(distdir)/mingwex/stdio + chmod 755 $(distdir)/mingwex/stdio + @for i in $(STDIO_DISTFILES); do\ + cp -p $(srcdir)/stdio/$$i $(distdir)/mingwex/stdio/$$i ; \ + done diff --git a/winsup/mingw/mingwex/snprintf.c b/winsup/mingw/mingwex/snprintf.c deleted file mode 100644 index c8d2a7b20..000000000 --- a/winsup/mingw/mingwex/snprintf.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -int snprintf(char* buffer, size_t n, const char* format, ...) -{ - int retval; - va_list argptr; - - va_start( argptr, format ); - retval = _vsnprintf( buffer, n, format, argptr ); - va_end( argptr ); - return retval; -} diff --git a/winsup/mingw/mingwex/snwprintf.c b/winsup/mingw/mingwex/snwprintf.c deleted file mode 100644 index 42b05b292..000000000 --- a/winsup/mingw/mingwex/snwprintf.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -int snwprintf(wchar_t* buffer, size_t n, const wchar_t* format, ...) -{ - int retval; - va_list argptr; - - va_start( argptr, format ); - retval = _vsnwprintf( buffer, n, format, argptr ); - va_end( argptr ); - return retval; -} diff --git a/winsup/mingw/mingwex/stdio/snprintf.c b/winsup/mingw/mingwex/stdio/snprintf.c new file mode 100644 index 000000000..c8d2a7b20 --- /dev/null +++ b/winsup/mingw/mingwex/stdio/snprintf.c @@ -0,0 +1,13 @@ +#include +#include + +int snprintf(char* buffer, size_t n, const char* format, ...) +{ + int retval; + va_list argptr; + + va_start( argptr, format ); + retval = _vsnprintf( buffer, n, format, argptr ); + va_end( argptr ); + return retval; +} diff --git a/winsup/mingw/mingwex/stdio/snwprintf.c b/winsup/mingw/mingwex/stdio/snwprintf.c new file mode 100644 index 000000000..42b05b292 --- /dev/null +++ b/winsup/mingw/mingwex/stdio/snwprintf.c @@ -0,0 +1,13 @@ +#include +#include + +int snwprintf(wchar_t* buffer, size_t n, const wchar_t* format, ...) +{ + int retval; + va_list argptr; + + va_start( argptr, format ); + retval = _vsnwprintf( buffer, n, format, argptr ); + va_end( argptr ); + return retval; +} diff --git a/winsup/mingw/mingwex/stdio/vfscanf.c b/winsup/mingw/mingwex/stdio/vfscanf.c new file mode 100644 index 000000000..41549f9e4 --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vfscanf.c @@ -0,0 +1,40 @@ +// By aaronwl 2003-01-28 for mingw-msvcrt +// Public domain: all copyrights disclaimed, absolutely no warranties */ + +#include +#include + +int vfscanf(FILE * __restrict__ stream, const char * __restrict__ format, va_list arg) { + int ret; + + __asm__( + + /* allocate stack (esp += frame - arg3 - (8[arg1,2] + 12)) */ + "movl %%esp, %%ebx\n\t" + "lea 0xFFFFFFEC(%%esp, %6), %%esp\n\t" + "subl %5, %%esp\n\t" + + // set up stack + "movl %1, 0xC(%%esp)\n\t" // stream + "movl %2, 0x10(%%esp)\n\t" // format + "lea 0x14(%%esp), %%edi\n\t" + "movl %%edi, (%%esp)\n\t" // memcpy dest + "movl %5, 0x4(%%esp)\n\t" // memcpy src + "movl %5, 0x8(%%esp)\n\t" + "subl %6, 0x8(%%esp)\n\t" // memcpy len + "call _memcpy\n\t" + "addl $12, %%esp\n\t" + + // call fscanf + "call _fscanf\n\t" + + // restore stack + "movl %%ebx, %%esp\n\t" + + : "=a"(ret), "=c"(stream), "=d"(format) + : "1"(stream), "2"(format), "S"(arg), + "a"(&ret) + : "ebx"); + + return ret; +} diff --git a/winsup/mingw/mingwex/stdio/vfwscanf.c b/winsup/mingw/mingwex/stdio/vfwscanf.c new file mode 100644 index 000000000..8fa33376e --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vfwscanf.c @@ -0,0 +1,42 @@ +// By aaronwl 2003-01-28 for mingw-msvcrt. +// Public domain: all copyrights disclaimed, absolutely no warranties. + +#include +#include + +int vfwscanf(FILE * __restrict__ stream, const wchar_t * __restrict__ format, + va_list arg) { + + int ret; + + __asm__( + + // allocate stack (esp += frame - arg3 - (8[arg1,2] + 12)) + "movl %%esp, %%ebx\n\t" + "lea 0xFFFFFFEC(%%esp, %6), %%esp\n\t" + "subl %5, %%esp\n\t" + + // set up stack + "movl %1, 0xC(%%esp)\n\t" // stream + "movl %2, 0x10(%%esp)\n\t" // format + "lea 0x14(%%esp), %%edi\n\t" + "movl %%edi, (%%esp)\n\t" // memcpy dest + "movl %5, 0x4(%%esp)\n\t" // memcpy src + "movl %5, 0x8(%%esp)\n\t" + "subl %6, 0x8(%%esp)\n\t" // memcpy len + "call _memcpy\n\t" + "addl $12, %%esp\n\t" + + // call fscanf + "call _fwscanf\n\t" + + // restore stack + "movl %%ebx, %%esp\n\t" + + : "=a"(ret), "=c"(stream), "=d"(format) + : "1"(stream), "2"(format), "S"(arg), + "a"(&ret) + : "ebx"); + + return ret; +} diff --git a/winsup/mingw/mingwex/stdio/vscanf.c b/winsup/mingw/mingwex/stdio/vscanf.c new file mode 100644 index 000000000..53f543442 --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vscanf.c @@ -0,0 +1,9 @@ +// By aaronwl 2003-01-28 for mingw-msvcrt +// Public domain: all copyrights disclaimed, absolutely no warranties + +#include +#include + +int vscanf(const char * __restrict__ format, va_list arg) { + return vfscanf(stdin, format, arg); +} diff --git a/winsup/mingw/mingwex/stdio/vsnprintf.c b/winsup/mingw/mingwex/stdio/vsnprintf.c new file mode 100644 index 000000000..f3dce5b67 --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vsnprintf.c @@ -0,0 +1,5 @@ +#include +#include + +int vsnprintf (char* s, size_t n, const char* format, va_list arg) + { return _vsnprintf ( s, n, format, arg); } diff --git a/winsup/mingw/mingwex/stdio/vsnwprintf.c b/winsup/mingw/mingwex/stdio/vsnwprintf.c new file mode 100644 index 000000000..1b59a078b --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vsnwprintf.c @@ -0,0 +1,5 @@ +#include +#include + +int vsnwprintf(wchar_t *buffer, size_t n, const wchar_t * format, va_list argptr) + { return _vsnwprintf( buffer, n, format, argptr );} diff --git a/winsup/mingw/mingwex/stdio/vsscanf.c b/winsup/mingw/mingwex/stdio/vsscanf.c new file mode 100644 index 000000000..33fd333ae --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vsscanf.c @@ -0,0 +1,41 @@ +// By aaronwl 2003-01-28 for mingw-msvcrt. +// Public domain: all copyrights disclaimed, absolutely no warranties. + +#include +#include + + +int vsscanf(const char * __restrict__ s, const char * __restrict__ format, va_list arg) { + int ret; + + __asm__( + + // allocate stack (esp += frame - arg3 - (8[arg1,2] + 12)) + "movl %%esp, %%ebx\n\t" + "lea 0xFFFFFFEC(%%esp, %6), %%esp\n\t" + "subl %5, %%esp\n\t" + + // set up stack + "movl %1, 0xC(%%esp)\n\t" // s + "movl %2, 0x10(%%esp)\n\t" // format + "lea 0x14(%%esp), %%edi\n\t" + "movl %%edi, (%%esp)\n\t" // memcpy dest + "movl %5, 0x4(%%esp)\n\t" // memcpy src + "movl %5, 0x8(%%esp)\n\t" + "subl %6, 0x8(%%esp)\n\t" // memcpy len + "call _memcpy\n\t" + "addl $12, %%esp\n\t" + + // call sscanf + "call _sscanf\n\t" + + // restore stack + "movl %%ebx, %%esp\n\t" + + : "=a"(ret), "=c"(s), "=d"(format) + : "1"(s), "2"(format), "S"(arg), + "a"(&ret) + : "ebx"); + + return ret; +} diff --git a/winsup/mingw/mingwex/stdio/vswscanf.c b/winsup/mingw/mingwex/stdio/vswscanf.c new file mode 100644 index 000000000..20a0f85f5 --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vswscanf.c @@ -0,0 +1,43 @@ +// By aaronwl 2003-01-28 for mingw-msvcrt +// Public domain: all copyrights disclaimed, absolutely no warranties */ + +#include +#include + + +int vswscanf(const wchar_t * __restrict__ s, const wchar_t * __restrict__ format, + va_list arg) { + + int ret; + + __asm__( + + // allocate stack (esp += frame - arg3 - (8[arg1,2] + 12)) + "movl %%esp, %%ebx\n\t" + "lea 0xFFFFFFEC(%%esp, %6), %%esp\n\t" + "subl %5, %%esp\n\t" + + // set up stack + "movl %1, 0xC(%%esp)\n\t" // s + "movl %2, 0x10(%%esp)\n\t" // format + "lea 0x14(%%esp), %%edi\n\t" + "movl %%edi, (%%esp)\n\t" // memcpy dest + "movl %5, 0x4(%%esp)\n\t" // memcpy src + "movl %5, 0x8(%%esp)\n\t" + "subl %6, 0x8(%%esp)\n\t" // memcpy len + "call _memcpy\n\t" + "addl $12, %%esp\n\t" + + // call sscanf + "call _swscanf\n\t" + + // restore stack + "movl %%ebx, %%esp\n\t" + + : "=a"(ret), "=c"(s), "=d"(format) + : "1"(s), "2"(format), "S"(arg), + "a"(&ret) + : "ebx"); + + return ret; +} diff --git a/winsup/mingw/mingwex/stdio/vwscanf.c b/winsup/mingw/mingwex/stdio/vwscanf.c new file mode 100644 index 000000000..c8f53eef2 --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vwscanf.c @@ -0,0 +1,9 @@ +// By aaronwl 2003-01-28 for mingw-msvcrt. +// Public domain: all copyrights disclaimed, absolutely no warranties. + +#include +#include + +int vwscanf(const wchar_t * __restrict__ format, va_list arg) { + return vfwscanf(stdin, format, arg); +} diff --git a/winsup/mingw/mingwex/vsnprintf.c b/winsup/mingw/mingwex/vsnprintf.c deleted file mode 100644 index f3dce5b67..000000000 --- a/winsup/mingw/mingwex/vsnprintf.c +++ /dev/null @@ -1,5 +0,0 @@ -#include -#include - -int vsnprintf (char* s, size_t n, const char* format, va_list arg) - { return _vsnprintf ( s, n, format, arg); } diff --git a/winsup/mingw/mingwex/vsnwprintf.c b/winsup/mingw/mingwex/vsnwprintf.c deleted file mode 100644 index 1b59a078b..000000000 --- a/winsup/mingw/mingwex/vsnwprintf.c +++ /dev/null @@ -1,5 +0,0 @@ -#include -#include - -int vsnwprintf(wchar_t *buffer, size_t n, const wchar_t * format, va_list argptr) - { return _vsnwprintf( buffer, n, format, argptr );} -- cgit v1.2.3