From 0b1a369faf70bd6834540d2dd5b8eff473e84455 Mon Sep 17 00:00:00 2001 From: Royce Mitchell III Date: Wed, 16 Jul 2003 13:29:01 +0000 Subject: [PATCH] integrated Art Yerkes' _ftime implementation at lib/msvcrt/time/ftime.c fixed ungetc warning in lib/msvcrt/stdio/vfscanf.c (also renamed ungetc macro to UNGETC for clarity) svn path=/trunk/; revision=5139 --- reactos/ChangeLog | 7 ++++++ reactos/lib/msvcrt/Makefile | 3 ++- reactos/lib/msvcrt/msvcrt.def | 4 ++-- reactos/lib/msvcrt/stdio/vfscanf.c | 26 +++++++++++------------ reactos/lib/msvcrt/time/ftime.c | 34 ++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 reactos/lib/msvcrt/time/ftime.c diff --git a/reactos/ChangeLog b/reactos/ChangeLog index a73d428f5e0..e0393f9bae3 100644 --- a/reactos/ChangeLog +++ b/reactos/ChangeLog @@ -1,3 +1,10 @@ +2003-07-16 Royce Mitchell III + + * integrated Art Yerkes' _ftime implementation at + lib/msvcrt/time/ftime.c + * fixed ungetc warning in lib/msvcrt/stdio/vfscanf.c (also + renamed ungetc macro to UNGETC for clarity) + 2003-07-15 Royce Mitchell III * fixed references to errno in MSVCRT to use __set_errno() and diff --git a/reactos/lib/msvcrt/Makefile b/reactos/lib/msvcrt/Makefile index b68b2a34b6f..7c5cbbba827 100644 --- a/reactos/lib/msvcrt/Makefile +++ b/reactos/lib/msvcrt/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.36 2003/06/09 20:23:06 hbirr Exp $ +# $Id: Makefile,v 1.37 2003/07/16 13:29:01 royce Exp $ PATH_TO_TOP = ../.. @@ -427,6 +427,7 @@ TIME_OBJECTS = \ time/clock.o \ time/ctime.o \ time/difftime.o \ + time/ftime.o \ time/strdate.o \ time/strftime.o \ time/strtime.o \ diff --git a/reactos/lib/msvcrt/msvcrt.def b/reactos/lib/msvcrt/msvcrt.def index 39f1654d00f..103d707f326 100644 --- a/reactos/lib/msvcrt/msvcrt.def +++ b/reactos/lib/msvcrt/msvcrt.def @@ -1,4 +1,4 @@ -; $Id: msvcrt.def,v 1.21 2003/04/30 22:07:29 gvg Exp $ +; $Id: msvcrt.def,v 1.22 2003/07/16 13:29:01 royce Exp $ ; ; ReactOS MSVCRT Compatibility Library ; @@ -252,7 +252,7 @@ _fputwchar _fsopen _fstat _fstati64 -; _ftime +_ftime _ftol=NTDLL._ftol _fullpath _futime diff --git a/reactos/lib/msvcrt/stdio/vfscanf.c b/reactos/lib/msvcrt/stdio/vfscanf.c index b0ddad64c54..8f9f13c245d 100644 --- a/reactos/lib/msvcrt/stdio/vfscanf.c +++ b/reactos/lib/msvcrt/stdio/vfscanf.c @@ -64,7 +64,7 @@ unsigned long int __strtoul_internal (const char *__nptr, char **__endptr, int # define TYPEMOD (LONG|LONGDBL|SHORT) -# define ungetc(c, s) ((void) (c != EOF && --read_in), ungetc (c, s)) +# define UNGETC(c, s) ((void) (((wint_t)c) != ((wint_t)EOF) && --read_in), ungetc (c, s)) # define inchar() ((c = getc (s)), (void) (c != EOF && ++read_in), c) # define encode_error() do { \ funlockfile (s); \ @@ -198,7 +198,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) input_error (); else if (c != *f++) { - ungetc (c, s); + UNGETC (c, s); conv_error (); } } @@ -236,7 +236,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) if (c != fc) { - ungetc (c, s); + UNGETC (c, s); conv_error (); } @@ -356,7 +356,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) if (inchar () == EOF && *_errno() == EINTR) input_error (); while (isspace (c)); - ungetc (c, s); + UNGETC (c, s); skip_space = 0; } @@ -366,7 +366,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) c = inchar (); if (c != fc) { - ungetc (c, s); + UNGETC (c, s); conv_error (); } break; @@ -583,7 +583,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) { if (isspace (c)) { - ungetc (c, s); + UNGETC (c, s); break; } #define STRING_ADD_CHAR(Str, c, Type) \ @@ -653,7 +653,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) not make a difference for white space characters we can simply push back a simple which is guaranteed to be in the [:space:] class. */ - ungetc (' ', s); + UNGETC (' ', s); break; } @@ -751,7 +751,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) } /* The just read character is not part of the number anymore. */ - ungetc (c, s); + UNGETC (c, s); if (wpsize == 0 || (wpsize == 1 && (wp[0] == '+' || wp[0] == '-'))) @@ -853,7 +853,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) { /* The last read character is not part of the number anymore. */ - ungetc (c, s); + UNGETC (c, s); break; } if (width > 0) @@ -951,7 +951,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) if (fc == '\0') { if (!(flags & LONG)) - ungetc (c, s); + UNGETC (c, s); conv_error(); } @@ -973,7 +973,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) input we push it back only in case it is representable within one byte. */ if (val < 0x80) - ungetc (val, s); + UNGETC (val, s); break; } STRING_ADD_CHAR (wstr, val, wchar_t); @@ -999,7 +999,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) { if (wp[c] == not_in) { - ungetc (c, s); + UNGETC (c, s); break; } STRING_ADD_CHAR (str, c, char); @@ -1036,7 +1036,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) do c = inchar (); while (isspace (c)); - ungetc (c, s); + UNGETC (c, s); } diff --git a/reactos/lib/msvcrt/time/ftime.c b/reactos/lib/msvcrt/time/ftime.c new file mode 100644 index 00000000000..d0a2a3cfa82 --- /dev/null +++ b/reactos/lib/msvcrt/time/ftime.c @@ -0,0 +1,34 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/msvcrt/time/ftime.c + * PURPOSE: Deprecated BSD library call + * PROGRAMER: Art Yerkes + * UPDATE HISTORY: + * 07/15/03 -- Created + */ + +#include +#include +#include + +/* ftime (3) -- Obsolete BSD library function included in the SUS for copat. + * Also present in msvcrt.dll as _ftime + * See: http://www.opengroup.org/onlinepubs/007904957/functions/ftime.html */ +/* + * @implemented + */ +void _ftime( struct timeb *tm ) +{ + int ret = 0; + SYSTEMTIME syst; + + GetSystemTime( &syst ); + + if( ret == 0 ) { + time( &tm->time ); + tm->millitm = syst.wMilliseconds; + tm->_timezone = 0; /* According to the open group, timezone and dstflag */ + tm->dstflag = 0; /* exist for compatibility, but are unspecified. */ + } +}