minor fixes

svn path=/trunk/; revision=366
This commit is contained in:
Boudewijn Dekker 1999-04-03 10:42:18 +00:00
parent e8cbdde2a7
commit 0c6333ed01
14 changed files with 63 additions and 79 deletions

View file

@ -22,9 +22,9 @@
* DISCLAMED. This includes but is not limited to warranties of * DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* $Author: ariadne $ * $Author: ariadne $
* $Date: 1999/04/02 21:42:06 $ * $Date: 1999/04/03 10:41:29 $
* *
*/ */
/* Appropriated for Reactos Crtdll by Ariadne */ /* 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 * 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. * using stdio.h and varargs.h in the same file, so I do the typedef myself.
*/ */
#ifndef _VA_LIST //#ifndef _VA_LIST
#define _VA_LIST //#define _VA_LIST
typedef char* va_list; //typedef char* va_list;
#endif //#endif
#include <stdarg.h>
/* /*
* FILE should be used as a pointer to an opaque data type. Do not rely on * FILE should be used as a pointer to an opaque data type. Do not rely on

View file

@ -18,9 +18,9 @@
* DISCLAMED. This includes but is not limited to warranties of * DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* $Author: ariadne $ * $Author: ariadne $
* $Date: 1999/04/02 21:42:06 $ * $Date: 1999/04/03 10:41:29 $
* *
*/ */
/* Appropriated for Reactos Crtdll by Ariadne */ /* 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 (int nError); /* NOTE: NOT an old name wrapper. */
char * _strerror(const char *s); char * _strerror(const char *s);
size_t strlen (const char* sz); 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); char* strncat (char* szAddTo, const char* szAdd, size_t sizeMaxAdd);
int strncmp (const char* sz1, const char* sz2, size_t sizeMaxCompare); int strncmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
char* strncpy (char* szCopyTo, const char* szSource, size_t sizeMaxCopy); char* strncpy (char* szCopyTo, const char* szSource, size_t sizeMaxCopy);
@ -189,7 +190,7 @@ wchar_t* wcsupr (wchar_t* wsToConvert);
#endif /* Not strict ANSI */ #endif /* Not strict ANSI */
#if 0
/* /*
* Include machine specific inline routines * Include machine specific inline routines
*/ */
@ -920,3 +921,4 @@ extern inline void * memscan(void * addr, int c, size_t size)
#endif #endif
#endif #endif
#endif

View file

@ -19,9 +19,9 @@
* DISCLAMED. This includes but is not limited to warranties of * DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* $Author: ariadne $ * $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 _chmod (const char* szPath, int nMode);
int _stat (const char* szPath, struct stat* pstat); int _stat (const char* szPath, struct stat* pstat);
#ifndef _NO_OLDNAMES #ifndef _NO_OLDNAMES
/* These functions live in liboldnames.a. */ #define fstat(nFileNo, pstat) _fstat(nFileNo, pstat)
int fstat (int nHandle, struct stat* pstat); #define chmod(szPath,nMode) _chmod(szPath,nMode)
int chmod (const char* szPath, int nMode); #define stat(szPath,pstat) _stat(szPath,pstat)
int stat (const char* szPath, struct stat* pstat);
#endif /* Not _NO_OLDNAMES */ #endif /* Not _NO_OLDNAMES */

View file

@ -10,12 +10,14 @@
#include <windows.h> #include <windows.h>
#include <crtdll/conio.h> #include <crtdll/conio.h>
#include <crtdll/string.h> #include <crtdll/string.h>
#include <crtdll/stdio.h>
#include <crtdll/internal/file.h>
int _cputs(const char *_str) int _cputs(const char *_str)
{ {
int len = strlen(_str); int len = strlen(_str);
int written = 0; 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 -1;
return 0; return 0;
} }

View file

@ -6,7 +6,7 @@ int _isatty( int fd )
{ {
struct stat buf; struct stat buf;
if (fstat (fd, &buf) < 0) if (_fstat (fd, &buf) < 0)
return 0; return 0;
if (S_ISCHR (buf.st_mode)) if (S_ISCHR (buf.st_mode))
return 1; return 1;

View file

@ -1,4 +1,4 @@
HOST=mingw32-windows
ifneq ($(HOST),mingw32-windows) ifneq ($(HOST),mingw32-windows)
ifneq ($(HOST),mingw32-linux) ifneq ($(HOST),mingw32-linux)
DLLTARGET=crtdll.a DLLTARGET=crtdll.a

View file

@ -273,7 +273,7 @@ int _doprnt(const char *fmt, va_list args, FILE *f)
base = 8; base = 8;
break; break;
case 'b': case 'b':
base = 2; base = 2;
break; break;
@ -282,7 +282,7 @@ int _doprnt(const char *fmt, va_list args, FILE *f)
case 'x': case 'x':
base = 16; base = 16;
break; break;
case 'f':
case 'd': case 'd':
case 'i': case 'i':
flags |= SIGN; flags |= SIGN;

View file

@ -20,7 +20,8 @@
int int
_filbuf(FILE *f) _filbuf(FILE *f)
{ {
int size, fillsize; int size =0;
//int fillsize = 0;
char c; char c;
if (f->_flag & _IORW) if (f->_flag & _IORW)
@ -33,8 +34,7 @@ _filbuf(FILE *f)
f->_flag &= ~_IOUNGETC; f->_flag &= ~_IOUNGETC;
if (f->_base==NULL && (f->_flag&_IONBF)==0) { 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) if ((f->_base = malloc(size)) == NULL)
{ {
f->_flag |= _IONBF; f->_flag |= _IONBF;
@ -44,7 +44,7 @@ _filbuf(FILE *f)
{ {
f->_flag |= _IOMYBUF; f->_flag |= _IOMYBUF;
f->_bufsiz = size; 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 aligns with file cluster boundaries; i.e. 512, then 2048
(512+1536), then 4096 (2048+2048) etc. */ (512+1536), then 4096 (2048+2048) etc. */
//fillsize = f->_fillsize; //fillsize = f->_fillsize;
fillsize = f->_bufsiz; //if (fillsize == 1024 && f->_bufsiz >= 1536)
if (fillsize == 1024 && f->_bufsiz >= 1536) // fillsize = 1536;
fillsize = 1536;
f->_cnt = _read(fileno(f), f->_base, 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 */ /* Read more next time, if we don't seek */
// if (f->_fillsize < f->_bufsiz) //if (f->_fillsize < f->_bufsiz)
// f->_fillsize *= 2; // f->_fillsize *= 2;
if(__is_text_file(f) && f->_cnt>0) if(__is_text_file(f) && f->_cnt>0)
{ {
@ -103,5 +102,3 @@ _filbuf(FILE *f)
} }
return *f->_ptr++ & 0377; return *f->_ptr++ & 0377;
} }

View file

@ -1,27 +1,18 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/stdio.h> #include <crtdll/stdio.h>
#include <windows.h> #include <windows.h>
#include <crtdll/internal/file.h> #include <crtdll/internal/file.h>
int getc(FILE *f)
int getc(FILE *fp)
{ {
int c; if(fp->_cnt > 0) {
DWORD NumberOfBytesRead =0; fp->_cnt--;
if (f->_cnt > 0) { return (int)*fp->_ptr++;
f->_cnt--;
f->_flag &= ~_IOUNGETC;
return *f->_ptr;
} }
else {
return _filbuf(fp);
if ( !ReadFile(_get_osfhandle(f->_file),&c, 1, &NumberOfBytesRead, NULL) ) }
return -1; return -1;
if ( NumberOfBytesRead == 0 )
return -1;
putchar(c&0xFF);
return c&0xFF;
} }

View file

@ -6,22 +6,14 @@
int putc(int c, FILE *fp) int putc(int c, FILE *fp)
{ {
int r; if (fp->_cnt > 0 ) {
fp->_cnt--;
// if(c =='\n' && __is_text_file(fp)) *(fp)->_ptr++ = (char)c;
// putc('\r',fp); return (int)c;
if ( ((fp->_flag) & _IOSTRG) == _IOSTRG) {
if(fp->_cnt>0)
{
fp->_cnt--;
return((unsigned char)(*(fp->_ptr++)=(unsigned char)c));
}
return(_flsbuf(c,fp));
} }
if ( !WriteFile(_get_osfhandle(fp->_file),&c,1,&r,NULL) ) else
return -1; return _flsbuf(c,fp);
return r;
return -1;
} }

View file

@ -19,9 +19,9 @@
* DISCLAMED. This includes but is not limited to warrenties of * DISCLAMED. This includes but is not limited to warrenties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* $Author: ariadne $ * $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 int
strncasecmp (const char* sz1, const char* sz2, size_t sizeMaxCompare) strncasecmp (const char* sz1, const char* sz2, size_t sizeMaxCompare)
{ {
return strnicmp (sz1, sz2, sizeMaxCompare); return _strnicmp (sz1, sz2, sizeMaxCompare);
} }
int int

View file

@ -18,5 +18,5 @@ _stricmp(const char *s1, const char *s2)
int int
_strcmpi(const char *s1, const char *s2) _strcmpi(const char *s1, const char *s2)
{ {
return stricmp(s1,s2); return _stricmp(s1,s2);
} }

View file

@ -7,7 +7,7 @@
int int
_fstat(int handle, struct stat *statbuf) _fstat(int fd, struct stat *statbuf)
{ {
BY_HANDLE_FILE_INFORMATION FileInformation; BY_HANDLE_FILE_INFORMATION FileInformation;
@ -18,13 +18,13 @@ _fstat(int handle, struct stat *statbuf)
return -1; return -1;
} }
if ( !GetFileInformationByHandle(_get_osfhandle(handle),&FileInformation) ) if ( !GetFileInformationByHandle(_get_osfhandle(fd),&FileInformation) )
return -1; return -1;
statbuf->st_ctime = FileTimeToUnixTime( &FileInformation.ftCreationTime,NULL); statbuf->st_ctime = FileTimeToUnixTime( &FileInformation.ftCreationTime,NULL);
statbuf->st_atime = FileTimeToUnixTime( &FileInformation.ftLastAccessTime,NULL); statbuf->st_atime = FileTimeToUnixTime( &FileInformation.ftLastAccessTime,NULL);
statbuf->st_mtime = FileTimeToUnixTime( &FileInformation.ftLastWriteTime,NULL); statbuf->st_mtime = FileTimeToUnixTime( &FileInformation.ftLastWriteTime,NULL);
statbuf->st_dev = handle; statbuf->st_dev = fd;
statbuf->st_size = FileInformation.nFileSizeLow; statbuf->st_size = FileInformation.nFileSizeLow;
return 0; return 0;
} }

View file

@ -6,11 +6,11 @@
int _stat( const char *path, struct stat *buffer ) int _stat( const char *path, struct stat *buffer )
{ {
int handle = _open(path,_O_RDONLY); int fd = _open(path,_O_RDONLY);
int ret; int ret;
ret = fstat(handle,buffer); ret = fstat(fd,buffer);
_close(handle); _close(fd);
return ret; return ret;