From 0c6333ed01d3894ce4693f99c191dcf4f77887b4 Mon Sep 17 00:00:00 2001 From: Boudewijn Dekker Date: Sat, 3 Apr 1999 10:42:18 +0000 Subject: [PATCH] minor fixes svn path=/trunk/; revision=366 --- reactos/include/crtdll/stdio.h | 13 +++++++------ reactos/include/crtdll/string.h | 8 +++++--- reactos/include/crtdll/sys/stat.h | 13 ++++++------- reactos/lib/crtdll/conio/cputs.c | 4 +++- reactos/lib/crtdll/io/isatty.c | 2 +- reactos/lib/crtdll/makefile | 2 +- reactos/lib/crtdll/stdio/doprnt.c | 4 ++-- reactos/lib/crtdll/stdio/filbuf.c | 21 +++++++++------------ reactos/lib/crtdll/stdio/getc.c | 29 ++++++++++------------------- reactos/lib/crtdll/stdio/putc.c | 26 +++++++++----------------- reactos/lib/crtdll/string/str_old.c | 6 +++--- reactos/lib/crtdll/string/stricmp.c | 2 +- reactos/lib/crtdll/sys_stat/fstat.c | 6 +++--- reactos/lib/crtdll/sys_stat/stat.c | 6 +++--- 14 files changed, 63 insertions(+), 79 deletions(-) diff --git a/reactos/include/crtdll/stdio.h b/reactos/include/crtdll/stdio.h index 1f2bc692e2e..fb117a807a4 100644 --- a/reactos/include/crtdll/stdio.h +++ b/reactos/include/crtdll/stdio.h @@ -22,9 +22,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * $Author: ariadne $ - * $Date: 1999/04/02 21:42:06 $ + * $Date: 1999/04/03 10:41:29 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ @@ -65,10 +65,11 @@ extern "C" { * functions later on in the file which use va_list. That conflicts with * using stdio.h and varargs.h in the same file, so I do the typedef myself. */ -#ifndef _VA_LIST -#define _VA_LIST -typedef char* va_list; -#endif +//#ifndef _VA_LIST +//#define _VA_LIST +//typedef char* va_list; +//#endif +#include /* * FILE should be used as a pointer to an opaque data type. Do not rely on diff --git a/reactos/include/crtdll/string.h b/reactos/include/crtdll/string.h index 7244484d64e..d8be87efea5 100644 --- a/reactos/include/crtdll/string.h +++ b/reactos/include/crtdll/string.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Author: ariadne $ - * $Date: 1999/04/02 21:42:06 $ + * $Date: 1999/04/03 10:41:29 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ @@ -66,6 +66,7 @@ size_t strcspn (const char* szGetPrefix, const char* szNotIncluding); char* strerror (int nError); /* NOTE: NOT an old name wrapper. */ char * _strerror(const char *s); size_t strlen (const char* sz); +size_t strnlen (const char* sz, size_t count); // not exported char* strncat (char* szAddTo, const char* szAdd, size_t sizeMaxAdd); int strncmp (const char* sz1, const char* sz2, size_t sizeMaxCompare); char* strncpy (char* szCopyTo, const char* szSource, size_t sizeMaxCopy); @@ -189,7 +190,7 @@ wchar_t* wcsupr (wchar_t* wsToConvert); #endif /* Not strict ANSI */ - +#if 0 /* * Include machine specific inline routines */ @@ -920,3 +921,4 @@ extern inline void * memscan(void * addr, int c, size_t size) #endif #endif +#endif \ No newline at end of file diff --git a/reactos/include/crtdll/sys/stat.h b/reactos/include/crtdll/sys/stat.h index d27448c72a6..4d2e883acd2 100644 --- a/reactos/include/crtdll/sys/stat.h +++ b/reactos/include/crtdll/sys/stat.h @@ -19,9 +19,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * $Author: ariadne $ - * $Date: 1999/04/02 21:42:07 $ + * $Date: 1999/04/03 10:41:29 $ * */ @@ -90,17 +90,16 @@ struct stat }; -int _fstat (int nHandle, struct stat* pstat); +int _fstat (int nFileNo, struct stat* pstat); int _chmod (const char* szPath, int nMode); int _stat (const char* szPath, struct stat* pstat); #ifndef _NO_OLDNAMES -/* These functions live in liboldnames.a. */ -int fstat (int nHandle, struct stat* pstat); -int chmod (const char* szPath, int nMode); -int stat (const char* szPath, struct stat* pstat); +#define fstat(nFileNo, pstat) _fstat(nFileNo, pstat) +#define chmod(szPath,nMode) _chmod(szPath,nMode) +#define stat(szPath,pstat) _stat(szPath,pstat) #endif /* Not _NO_OLDNAMES */ diff --git a/reactos/lib/crtdll/conio/cputs.c b/reactos/lib/crtdll/conio/cputs.c index 91c97b3f845..d6f036f4f16 100644 --- a/reactos/lib/crtdll/conio/cputs.c +++ b/reactos/lib/crtdll/conio/cputs.c @@ -10,12 +10,14 @@ #include #include #include +#include +#include int _cputs(const char *_str) { int len = strlen(_str); int written = 0; - if ( !WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),_str,len,&written,NULL)) + if ( !WriteFile(filehnd(stdout->_file),_str,len,&written,NULL)) return -1; return 0; } diff --git a/reactos/lib/crtdll/io/isatty.c b/reactos/lib/crtdll/io/isatty.c index a7eb65b8907..a452414ba66 100644 --- a/reactos/lib/crtdll/io/isatty.c +++ b/reactos/lib/crtdll/io/isatty.c @@ -6,7 +6,7 @@ int _isatty( int fd ) { struct stat buf; - if (fstat (fd, &buf) < 0) + if (_fstat (fd, &buf) < 0) return 0; if (S_ISCHR (buf.st_mode)) return 1; diff --git a/reactos/lib/crtdll/makefile b/reactos/lib/crtdll/makefile index bf763276618..546d8decd0b 100644 --- a/reactos/lib/crtdll/makefile +++ b/reactos/lib/crtdll/makefile @@ -1,4 +1,4 @@ - +HOST=mingw32-windows ifneq ($(HOST),mingw32-windows) ifneq ($(HOST),mingw32-linux) DLLTARGET=crtdll.a diff --git a/reactos/lib/crtdll/stdio/doprnt.c b/reactos/lib/crtdll/stdio/doprnt.c index a359e1ab35a..8a25c20ec50 100644 --- a/reactos/lib/crtdll/stdio/doprnt.c +++ b/reactos/lib/crtdll/stdio/doprnt.c @@ -273,7 +273,7 @@ int _doprnt(const char *fmt, va_list args, FILE *f) base = 8; break; - case 'b': + case 'b': base = 2; break; @@ -282,7 +282,7 @@ int _doprnt(const char *fmt, va_list args, FILE *f) case 'x': base = 16; break; - + case 'f': case 'd': case 'i': flags |= SIGN; diff --git a/reactos/lib/crtdll/stdio/filbuf.c b/reactos/lib/crtdll/stdio/filbuf.c index 0060e258911..b551aa0987a 100644 --- a/reactos/lib/crtdll/stdio/filbuf.c +++ b/reactos/lib/crtdll/stdio/filbuf.c @@ -20,7 +20,8 @@ int _filbuf(FILE *f) { - int size, fillsize; + int size =0; + //int fillsize = 0; char c; if (f->_flag & _IORW) @@ -33,8 +34,7 @@ _filbuf(FILE *f) f->_flag &= ~_IOUNGETC; if (f->_base==NULL && (f->_flag&_IONBF)==0) { -// size = _go32_info_block.size_of_transfer_buffer; - size = 512; + size = 512; if ((f->_base = malloc(size)) == NULL) { f->_flag |= _IONBF; @@ -44,7 +44,7 @@ _filbuf(FILE *f) { f->_flag |= _IOMYBUF; f->_bufsiz = size; -// f->_fillsize = 512; + //f->_fillsize = 512; } } @@ -66,16 +66,15 @@ _filbuf(FILE *f) aligns with file cluster boundaries; i.e. 512, then 2048 (512+1536), then 4096 (2048+2048) etc. */ //fillsize = f->_fillsize; - fillsize = f->_bufsiz; - if (fillsize == 1024 && f->_bufsiz >= 1536) - fillsize = 1536; + //if (fillsize == 1024 && f->_bufsiz >= 1536) + // fillsize = 1536; f->_cnt = _read(fileno(f), f->_base, - f->_flag & _IONBF ? 1 : fillsize); + f->_flag & _IONBF ? 1 : size); /* Read more next time, if we don't seek */ -// if (f->_fillsize < f->_bufsiz) -// f->_fillsize *= 2; + //if (f->_fillsize < f->_bufsiz) + // f->_fillsize *= 2; if(__is_text_file(f) && f->_cnt>0) { @@ -103,5 +102,3 @@ _filbuf(FILE *f) } return *f->_ptr++ & 0377; } - - diff --git a/reactos/lib/crtdll/stdio/getc.c b/reactos/lib/crtdll/stdio/getc.c index 5fcae046820..28cfb259508 100644 --- a/reactos/lib/crtdll/stdio/getc.c +++ b/reactos/lib/crtdll/stdio/getc.c @@ -1,27 +1,18 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include #include #include -int getc(FILE *f) -{ - int c; - DWORD NumberOfBytesRead =0; - if (f->_cnt > 0) { - f->_cnt--; - f->_flag &= ~_IOUNGETC; - return *f->_ptr; - } - - - if ( !ReadFile(_get_osfhandle(f->_file),&c, 1, &NumberOfBytesRead, NULL) ) - return -1; - if ( NumberOfBytesRead == 0 ) - return -1; - putchar(c&0xFF); - return c&0xFF; - +int getc(FILE *fp) +{ + if(fp->_cnt > 0) { + fp->_cnt--; + return (int)*fp->_ptr++; + } + else { + return _filbuf(fp); + } + return -1; } diff --git a/reactos/lib/crtdll/stdio/putc.c b/reactos/lib/crtdll/stdio/putc.c index 6ed3e953d88..55f41df67d1 100644 --- a/reactos/lib/crtdll/stdio/putc.c +++ b/reactos/lib/crtdll/stdio/putc.c @@ -5,23 +5,15 @@ int putc(int c, FILE *fp) { - - int r; - -// if(c =='\n' && __is_text_file(fp)) -// putc('\r',fp); - - - if ( ((fp->_flag) & _IOSTRG) == _IOSTRG) { - if(fp->_cnt>0) - { - fp->_cnt--; - return((unsigned char)(*(fp->_ptr++)=(unsigned char)c)); - } - return(_flsbuf(c,fp)); + + if (fp->_cnt > 0 ) { + fp->_cnt--; + *(fp)->_ptr++ = (char)c; + return (int)c; } - if ( !WriteFile(_get_osfhandle(fp->_file),&c,1,&r,NULL) ) - return -1; - return r; + else + return _flsbuf(c,fp); + + return -1; } diff --git a/reactos/lib/crtdll/string/str_old.c b/reactos/lib/crtdll/string/str_old.c index a84ebb5728e..e047e3ef91a 100644 --- a/reactos/lib/crtdll/string/str_old.c +++ b/reactos/lib/crtdll/string/str_old.c @@ -19,9 +19,9 @@ * DISCLAMED. This includes but is not limited to warrenties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * $Author: ariadne $ - * $Date: 1999/04/02 21:44:05 $ + * $Date: 1999/04/03 10:42:18 $ * */ @@ -37,7 +37,7 @@ strcasecmp (const char* sz1, const char* sz2) int strncasecmp (const char* sz1, const char* sz2, size_t sizeMaxCompare) { - return strnicmp (sz1, sz2, sizeMaxCompare); + return _strnicmp (sz1, sz2, sizeMaxCompare); } int diff --git a/reactos/lib/crtdll/string/stricmp.c b/reactos/lib/crtdll/string/stricmp.c index 22b2eb44c3e..913ceef9eee 100644 --- a/reactos/lib/crtdll/string/stricmp.c +++ b/reactos/lib/crtdll/string/stricmp.c @@ -18,5 +18,5 @@ _stricmp(const char *s1, const char *s2) int _strcmpi(const char *s1, const char *s2) { - return stricmp(s1,s2); + return _stricmp(s1,s2); } diff --git a/reactos/lib/crtdll/sys_stat/fstat.c b/reactos/lib/crtdll/sys_stat/fstat.c index e75454f9d7b..af1a690d1f3 100644 --- a/reactos/lib/crtdll/sys_stat/fstat.c +++ b/reactos/lib/crtdll/sys_stat/fstat.c @@ -7,7 +7,7 @@ int -_fstat(int handle, struct stat *statbuf) +_fstat(int fd, struct stat *statbuf) { BY_HANDLE_FILE_INFORMATION FileInformation; @@ -18,13 +18,13 @@ _fstat(int handle, struct stat *statbuf) return -1; } - if ( !GetFileInformationByHandle(_get_osfhandle(handle),&FileInformation) ) + if ( !GetFileInformationByHandle(_get_osfhandle(fd),&FileInformation) ) return -1; statbuf->st_ctime = FileTimeToUnixTime( &FileInformation.ftCreationTime,NULL); statbuf->st_atime = FileTimeToUnixTime( &FileInformation.ftLastAccessTime,NULL); statbuf->st_mtime = FileTimeToUnixTime( &FileInformation.ftLastWriteTime,NULL); - statbuf->st_dev = handle; + statbuf->st_dev = fd; statbuf->st_size = FileInformation.nFileSizeLow; return 0; } diff --git a/reactos/lib/crtdll/sys_stat/stat.c b/reactos/lib/crtdll/sys_stat/stat.c index f8e409f1f4e..bb78ae90029 100644 --- a/reactos/lib/crtdll/sys_stat/stat.c +++ b/reactos/lib/crtdll/sys_stat/stat.c @@ -6,11 +6,11 @@ int _stat( const char *path, struct stat *buffer ) { - int handle = _open(path,_O_RDONLY); + int fd = _open(path,_O_RDONLY); int ret; - ret = fstat(handle,buffer); - _close(handle); + ret = fstat(fd,buffer); + _close(fd); return ret;