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
* 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 <stdarg.h>
/*
* 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
* 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

View file

@ -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 */

View file

@ -10,12 +10,14 @@
#include <windows.h>
#include <crtdll/conio.h>
#include <crtdll/string.h>
#include <crtdll/stdio.h>
#include <crtdll/internal/file.h>
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;
}

View file

@ -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;

View file

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

View file

@ -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;

View file

@ -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;
}

View file

@ -1,27 +1,18 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/stdio.h>
#include <windows.h>
#include <crtdll/internal/file.h>
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;
}

View file

@ -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;
}

View file

@ -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

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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;