diff --git a/reactos/lib/crtdll/crtdll.rc b/reactos/lib/crtdll/crtdll.rc index 31300128ff1..b960fbb4ed9 100644 --- a/reactos/lib/crtdll/crtdll.rc +++ b/reactos/lib/crtdll/crtdll.rc @@ -1,4 +1,4 @@ -#include +#include "../../include/defines.h" #include "../../include/reactos/resource.h" LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US diff --git a/reactos/lib/crtdll/io/commit.c b/reactos/lib/crtdll/io/commit.c index 5a16ad6f599..8c9d787a146 100644 --- a/reactos/lib/crtdll/io/commit.c +++ b/reactos/lib/crtdll/io/commit.c @@ -3,7 +3,6 @@ #include #include -//fixme change this constant to _OCOMMIT int _commode_dll = _IOCOMMIT; int _commit(int _fd) diff --git a/reactos/lib/crtdll/makefile b/reactos/lib/crtdll/makefile index 1cb766e79ce..2deac2a7fc7 100644 --- a/reactos/lib/crtdll/makefile +++ b/reactos/lib/crtdll/makefile @@ -119,7 +119,7 @@ OLD_OBJECTS = $(MISC_OBJECTS) stdlib/malloc.o stdlib/abort.o \ stdlib/errno.o stdio/printf.o stdio/vprintf.o\ $(QUAD_OBJECTS) -RESOURCE_OBJECT = crtdll.coff +#RESOURCE_OBJECT = crtdll.coff OBJECTS = $(MISC_OBJECTS) $(STDLIB_OBJECTS) $(IO_OBJECTS) \ $(FLOAT_OBJECTS) $(ASSERT_OBJECTS) $(PROCESS_OBJECTS) \ diff --git a/reactos/lib/crtdll/mbstring/hanzen.c b/reactos/lib/crtdll/mbstring/hanzen.c index 0ab798f4b03..78a8e2550d1 100644 --- a/reactos/lib/crtdll/mbstring/hanzen.c +++ b/reactos/lib/crtdll/mbstring/hanzen.c @@ -1,3 +1,13 @@ +#include + +/* + * japanese code system utilities < jutil.h > + * + * 日本語のコード体系に関するユーティリティ + * + * Copyright (c) 1992-94 Tokyo Denki University, Taiji Yamada + * Copyright (c) 1997 AIHARA Electrical Engineering Co.,Ltd., Taiji Yamada + */ static unsigned short han_to_zen_ascii_table[0x5f] = { 0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166, @@ -84,15 +94,6 @@ static unsigned short _mbctombb(unsigned short c) } return c; } -#endif -unsigned int _mbctohira( unsigned int c ) -{ - return c; -} -unsigned int _mbctokata( unsigned int c ) -{ - return c; -} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbslwr.c b/reactos/lib/crtdll/mbstring/mbslwr.c index c5cf9f9c8eb..eb418b10119 100644 --- a/reactos/lib/crtdll/mbstring/mbslwr.c +++ b/reactos/lib/crtdll/mbstring/mbslwr.c @@ -1,3 +1,5 @@ +#include + unsigned int _mbctolower(unsigned int c) { if (!_ismbblead(c) ) diff --git a/reactos/lib/crtdll/mbstring/mbsupr.c b/reactos/lib/crtdll/mbstring/mbsupr.c index baf762b3fee..7b5762f8dd2 100644 --- a/reactos/lib/crtdll/mbstring/mbsupr.c +++ b/reactos/lib/crtdll/mbstring/mbsupr.c @@ -1,3 +1,5 @@ +#include + unsigned int _mbctoupper(unsigned int c) { if (!_ismbblead(c) ) diff --git a/reactos/lib/crtdll/stdio/fflush.c b/reactos/lib/crtdll/stdio/fflush.c index 47d8aad7be5..ad9f56ead24 100644 --- a/reactos/lib/crtdll/stdio/fflush.c +++ b/reactos/lib/crtdll/stdio/fflush.c @@ -73,6 +73,9 @@ int fflush(FILE *f) // how can write return less than rn without being on error ??? +// possibly commit the flushed data +// better open the file in write through mode + do { n = _write(fileno(f), base, rn); if (n <= 0) { diff --git a/reactos/lib/crtdll/stdio/filbuf.c b/reactos/lib/crtdll/stdio/filbuf.c index 1ff790888e6..2bab0044ae0 100644 --- a/reactos/lib/crtdll/stdio/filbuf.c +++ b/reactos/lib/crtdll/stdio/filbuf.c @@ -59,7 +59,7 @@ _filbuf(FILE *f) } // if we have a dirty stream we flush it - if ( f->_flag &_IODIRTY == _IODIRTY ) + if ( (f->_flag &_IODIRTY) == _IODIRTY ) fflush(f); diff --git a/reactos/lib/crtdll/stdio/flsbuf.c b/reactos/lib/crtdll/stdio/flsbuf.c index 5f3268144b7..574525a7c02 100644 --- a/reactos/lib/crtdll/stdio/flsbuf.c +++ b/reactos/lib/crtdll/stdio/flsbuf.c @@ -28,6 +28,12 @@ _flsbuf(int c, FILE *f) return EOF; } +// no file associated with buffer +// this is a memory stream + + if ( fileno(f) == -1 ) + return c; + /* if the buffer is not yet allocated, allocate it */ if ((base = f->_base) == NULL && (f->_flag & _IONBF) == 0) { diff --git a/reactos/lib/crtdll/stdio/getc.c b/reactos/lib/crtdll/stdio/getc.c index d3087a60359..fe87af39952 100644 --- a/reactos/lib/crtdll/stdio/getc.c +++ b/reactos/lib/crtdll/stdio/getc.c @@ -9,7 +9,7 @@ int getc(FILE *fp) { - + int c = -1; // check for invalid stream if ( !__validfp (fp) ) { @@ -25,12 +25,12 @@ int getc(FILE *fp) if(fp->_cnt > 0) { fp->_cnt--; - return (int)*fp->_ptr++; + c = (int)*fp->_ptr++; } else { - return _filbuf(fp); + c = _filbuf(fp); } - return -1; + return c; } // not exported diff --git a/reactos/lib/crtdll/stdio/putw.c b/reactos/lib/crtdll/stdio/putw.c index 10aab3fa835..51a69163bd4 100644 --- a/reactos/lib/crtdll/stdio/putw.c +++ b/reactos/lib/crtdll/stdio/putw.c @@ -1,15 +1,31 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + + #include -#include + +/* Write the word (int) W to STREAM. */ int -putw(int w, FILE *f) +putw(int w,FILE *stream) { - char *p; - int i; - - p = (char *)&w; - for (i=sizeof(int); --i>=0;) - putc(*p++, f); - return ferror(f); + /* Is there a better way? */ + if (fwrite( &w, sizeof(w), 1, stream) < 1) + return(EOF); + return(0); } diff --git a/reactos/lib/crtdll/stdio/setlineb.c b/reactos/lib/crtdll/stdio/setlineb.c index c51097a1245..e8dcb040d4d 100644 --- a/reactos/lib/crtdll/stdio/setlineb.c +++ b/reactos/lib/crtdll/stdio/setlineb.c @@ -1,6 +1,8 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include +// not exported + void setlinebuf(FILE *f) { setvbuf(f, 0, _IOLBF, BUFSIZ); diff --git a/reactos/lib/crtdll/stdio/sprintf.c b/reactos/lib/crtdll/stdio/sprintf.c index e3bf4ba9cad..12a660929e2 100644 --- a/reactos/lib/crtdll/stdio/sprintf.c +++ b/reactos/lib/crtdll/stdio/sprintf.c @@ -1,4 +1,25 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + +/* Copyright (C) 1991, 1995 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include #include #include #include @@ -7,15 +28,30 @@ int sprintf(char *str, const char *fmt, ...) { - FILE _strbuf; - int len; - va_list a = 0; - va_start( a, fmt ); + va_list arg; + int done; - _strbuf._flag = _IOWRT|_IOSTRG; - _strbuf._ptr = str; - _strbuf._cnt = INT_MAX; - len = vfprintf(&_strbuf, fmt, a); - *_strbuf._ptr = 0; - return len; + va_start (arg, fmt); + done = vsprintf (str, fmt, arg); + //va_end (arg); + return done; } + + + +/* Write formatted output into S, according to the format + string FORMAT, writing no more than MAXLEN characters. */ +/* VARARGS3 */ +int +snprintf (char *s, size_t maxlen,const char *format, ...) +{ + va_list arg; + int done; + + va_start (arg, format); + done = vsnprintf (s, maxlen, format, arg); + //va_end (arg); + + return done; +} + diff --git a/reactos/lib/crtdll/stdio/ungetc.c b/reactos/lib/crtdll/stdio/ungetc.c index e39ff4712a0..848622dc3d8 100644 --- a/reactos/lib/crtdll/stdio/ungetc.c +++ b/reactos/lib/crtdll/stdio/ungetc.c @@ -37,7 +37,6 @@ ungetc(int c, FILE *f) f->_flag |= _IOUNGETC; *f->_ptr = c; } - return c; } diff --git a/reactos/lib/crtdll/stdio/vfscanf.c b/reactos/lib/crtdll/stdio/vfscanf.c index 6b200e9361b..a42088595b9 100644 --- a/reactos/lib/crtdll/stdio/vfscanf.c +++ b/reactos/lib/crtdll/stdio/vfscanf.c @@ -99,6 +99,28 @@ unsigned long int __strtoul_internal (const char *__nptr, char **__endptr, int # define flockfile(S) /* nothing */ # define funlockfile(S) /* nothing */ + char *wp = NULL; /* Workspace. */ + size_t wpmax = 0; /* Maximal size of workspace. */ + size_t wpsize = 0; /* Currently used bytes in workspace. */ + + +void ADDW(int Ch) \ +{ + if (wpsize == wpmax) + { + char *old = wp; + wpmax = UCHAR_MAX > 2 * wpmax ? UCHAR_MAX : 2 * wpmax; + wp = (char *) malloc (wpmax); + if (old != NULL) { + memcpy (wp, old, wpsize); + free(old); + } + } + wp[wpsize++] = (Ch); + +} + + int __vfscanf (FILE *s, const char *format, va_list argptr) { va_list arg; @@ -141,23 +163,6 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) int skip_space = 0; /* Workspace. */ char *tw; /* Temporary pointer. */ - char *wp = NULL; /* Workspace. */ - size_t wpmax = 0; /* Maximal size of workspace. */ - size_t wpsize; /* Currently used bytes in workspace. */ -#define ADDW(Ch) \ - do \ - { \ - if (wpsize == wpmax) \ - { \ - char *old = wp; \ - wpmax = UCHAR_MAX > 2 * wpmax ? UCHAR_MAX : 2 * wpmax; \ - wp = (char *) alloca (wpmax); \ - if (old != NULL) \ - memcpy (wp, old, wpsize); \ - } \ - wp[wpsize++] = (Ch); \ - } \ - while (0) #ifdef __va_copy __va_copy (arg, argptr); @@ -165,7 +170,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) arg = (va_list) argptr; #endif - + /* Run through the format string. */ while (*f != '\0') diff --git a/reactos/lib/crtdll/stdio/vsprintf.c b/reactos/lib/crtdll/stdio/vsprintf.c index 7c7e59186f9..75112b0c4f7 100644 --- a/reactos/lib/crtdll/stdio/vsprintf.c +++ b/reactos/lib/crtdll/stdio/vsprintf.c @@ -13,7 +13,24 @@ vsprintf(char *str, const char *fmt, va_list ap) f._flag = _IOWRT|_IOSTRG; f._ptr = str; f._cnt = INT_MAX; + f._file = -1; len = vfprintf(&f,fmt, ap); *f._ptr = 0; return len; } + +int +vsnprintf(char *str, size_t maxlen, const char *fmt, va_list ap) +{ + FILE f; + int len; + f._flag = _IOWRT|_IOSTRG; + f._ptr = str; + f._cnt = maxlen; + f._file = -1; + len = vfprintf(&f,fmt, ap); + // what if the buffer is full ?? + *f._ptr = 0; + return len; +} + diff --git a/reactos/lib/crtdll/time/clock.c b/reactos/lib/crtdll/time/clock.c index 404aadff133..4fcda91b6d7 100644 --- a/reactos/lib/crtdll/time/clock.c +++ b/reactos/lib/crtdll/time/clock.c @@ -16,19 +16,16 @@ VOID STDCALL GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime ); clock_t clock ( void ) { - FILETIME CreationTime; - FILETIME ExitTime; - FILETIME KernelTime; - FILETIME UserTime; - - FILETIME SystemTime; - DWORD Remainder; + FILETIME CreationTime; + FILETIME ExitTime; + FILETIME KernelTime; + FILETIME UserTime; + + DWORD Remainder; - if ( !GetProcessTimes(GetCurrentProcess(),&CreationTime,&ExitTime,&KernelTime,&UserTime ) ) - return -1; + if ( !GetProcessTimes(GetCurrentProcess(),&CreationTime,&ExitTime,&KernelTime,&UserTime ) ) + return -1; + - GetSystemTimeAsFileTime(&SystemTime); - - - return FileTimeToUnixTime( &SystemTime,&Remainder ) - FileTimeToUnixTime( &CreationTime,&Remainder ); -} \ No newline at end of file + return FileTimeToUnixTime( &KernelTime,&Remainder ) + FileTimeToUnixTime( &UserTime,&Remainder ); +}