From a38f0cad21ab983e317ef6105676b34c329496c5 Mon Sep 17 00:00:00 2001 From: Robert Dickenson Date: Mon, 25 Nov 2002 17:41:40 +0000 Subject: [PATCH] cleaned up some warnings. svn path=/trunk/; revision=3791 --- reactos/lib/msvcrt/Makefile | 3 +- reactos/lib/msvcrt/io/lseeki64.c | 50 ++++++--------- reactos/lib/msvcrt/misc/crtmain.c | 92 ++++++++++++---------------- reactos/lib/msvcrt/process/_system.c | 3 +- reactos/lib/msvcrt/stdio/fflush.c | 2 +- reactos/lib/msvcrt/stdio/vfscanf.c | 14 ++--- reactos/lib/msvcrt/stdlib/putenv.c | 56 ++++++----------- reactos/lib/msvcrt/stdlib/wputenv.c | 31 ++++++++++ reactos/lib/msvcrt/wstring/wcsupr.c | 5 +- 9 files changed, 122 insertions(+), 134 deletions(-) create mode 100644 reactos/lib/msvcrt/stdlib/wputenv.c diff --git a/reactos/lib/msvcrt/Makefile b/reactos/lib/msvcrt/Makefile index c2300ba70ab..98c0fae1153 100644 --- a/reactos/lib/msvcrt/Makefile +++ b/reactos/lib/msvcrt/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.26 2002/11/24 18:42:20 robd Exp $ +# $Id: Makefile,v 1.27 2002/11/25 17:41:39 robd Exp $ PATH_TO_TOP = ../.. @@ -391,6 +391,7 @@ STDLIB_OBJECTS = \ stdlib/wfulpath.o \ stdlib/witoa.o \ stdlib/witow.o \ + stdlib/wputenv.o \ stdlib/wsenv.o \ stdlib/wsplitp.o \ stdlib/wmakpath.o \ diff --git a/reactos/lib/msvcrt/io/lseeki64.c b/reactos/lib/msvcrt/io/lseeki64.c index 1279c0d95bb..71b8e768059 100644 --- a/reactos/lib/msvcrt/io/lseeki64.c +++ b/reactos/lib/msvcrt/io/lseeki64.c @@ -3,18 +3,14 @@ #include -BOOL STDCALL SetFilePointerEx( - HANDLE hFile, // handle to file - LARGE_INTEGER liDistanceToMove, // bytes to move pointer - PLARGE_INTEGER lpNewFilePointer, // new file pointer - DWORD dwMoveMethod // starting point -); +//#define SETFILEPOINTEREX_AVAILABLE __int64 _lseeki64(int _fildes, __int64 _offset, int _whence) { -#if 0 - __int64 new_pos; - LARGE_INTEGER offset = _offset; +#ifdef SETFILEPOINTEREX_AVAILABLE + LARGE_INTEGER new_pos; + LARGE_INTEGER offset; + offset.QuadPart = _offset; // if (invalid_filehnd(_fildes)) { // errno = EBADF; @@ -25,29 +21,19 @@ __int64 _lseeki64(int _fildes, __int64 _offset, int _whence) //errno = EINVAL; return -1L; } - return new_pos; + return new_pos.QuadPart; #else - ULONG lo_pos, hi_pos; - //DWORD lo_pos; + //ULONG lo_pos; + //DWORD hi_pos = 0; // must equal 0 or -1 if supplied, -1 for negative 32 seek value + //lo_pos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, &hi_pos, _whence); + //return((((__int64)hi_pos) << 32) + lo_pos); - lo_pos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, &hi_pos, _whence); - return((((__int64)hi_pos) << 32) + lo_pos); -#endif -} -/* -long _lseek ( int handle, long offset, int origin ); -__int64 _lseeki64( int handle, __int64 offset, int origin ); + LARGE_INTEGER offset; + offset.QuadPart = _offset; + + offset.u.LowPart = SetFilePointer((HANDLE)filehnd(_fildes), + offset.u.LowPart, &offset.u.HighPart, _whence); + return ((((__int64)offset.u.HighPart) << 32) + offset.u.LowPart); -BOOL SetFilePointerEx( - HANDLE hFile, // handle to file - LARGE_INTEGER liDistanceToMove, // bytes to move pointer - PLARGE_INTEGER lpNewFilePointer, // new file pointer - DWORD dwMoveMethod // starting point -); -DWORD SetFilePointer( - HANDLE hFile, // handle to file - LONG lDistanceToMove, // bytes to move pointer - PLONG lpDistanceToMoveHigh, // bytes to move pointer - DWORD dwMoveMethod // starting point -); - */ +#endif /*SETFILEPOINTEREX_AVAILABLE*/ +} diff --git a/reactos/lib/msvcrt/misc/crtmain.c b/reactos/lib/msvcrt/misc/crtmain.c index b91862e7f56..27ed7a90f6f 100644 --- a/reactos/lib/msvcrt/misc/crtmain.c +++ b/reactos/lib/msvcrt/misc/crtmain.c @@ -1,4 +1,4 @@ -/* $Id: crtmain.c,v 1.1 2002/11/24 18:42:23 robd Exp $ +/* $Id: crtmain.c,v 1.2 2002/11/25 17:41:39 robd Exp $ * * ReactOS MSVCRT.DLL Compatibility Library */ @@ -13,101 +13,89 @@ /* GLOBAL VARIABLES *******************************************************/ int _fltused; -//int _allmul; -/* FUNCTIONS **************************************************************/ +/* FUNCTIONS **************************************************************/ -int __cdecl _allmul(void) +/* + */ +int +STDCALL +_except_handler3(void) { return 0; } -int __cdecl _allshl(void) +int +STDCALL +_local_unwind2(void) { return 0; } -#if 1 - -void __cdecl _chkesp(int value1, int value2) -{ -} - -#else - -int __cdecl _chkesp(int value) +int +STDCALL +_spawnlp(int a, const char* b, const char* args, ...) { - return value; + return 0; } -#endif +#else /*__GNUC__*/ -int __cdecl _alloca_probe(void) +int +_spawnlp(int a, const char* b, const char* args, ...) { return 0; } -/* -BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved); - -int STDCALL _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) -{ - BOOL result; - //__fileno_init(); - //result = DllMain(hInst, ul_reason_for_call, lpReserved); +#endif /*__GNUC__*/ - result = DllMain(hInst, DLL_PROCESS_ATTACH, lpReserved); - - return (result ? 1 : 0); -} - */ /* -int -STDCALL -_abnormal_termination(void) +int __cdecl _allmul(void) { return 0; } -int -STDCALL -_setjmp(void) +int __cdecl _allshl(void) { return 0; } - */ -int -STDCALL -_except_handler3(void) + +void __cdecl _chkesp(int value1, int value2) { - return 0; } -int -STDCALL -_local_unwind2(void) +int __cdecl _alloca_probe(void) { return 0; } -int -STDCALL -_spawnlp(int a, const char* b, const char* args, ...) +int STDCALL _abnormal_termination(void) { return 0; } -#else /*__GNUC__*/ - -int -_spawnlp(int a, const char* b, const char* args, ...) +int STDCALL _setjmp(void) { return 0; } +*/ +/* +BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved); -#endif /*__GNUC__*/ +int STDCALL _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) +{ + BOOL result; + //__fileno_init(); + //result = DllMain(hInst, ul_reason_for_call, lpReserved); + + result = DllMain(hInst, DLL_PROCESS_ATTACH, lpReserved); + + + return (result ? 1 : 0); +} + */ /* EOF */ diff --git a/reactos/lib/msvcrt/process/_system.c b/reactos/lib/msvcrt/process/_system.c index edd09400be5..9c6fd2f879e 100644 --- a/reactos/lib/msvcrt/process/_system.c +++ b/reactos/lib/msvcrt/process/_system.c @@ -1,4 +1,4 @@ -/* $Id: _system.c,v 1.5 2002/11/24 18:42:23 robd Exp $ +/* $Id: _system.c,v 1.6 2002/11/25 17:41:39 robd Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -13,6 +13,7 @@ #include #include #include +#include int system(const char *command) { diff --git a/reactos/lib/msvcrt/stdio/fflush.c b/reactos/lib/msvcrt/stdio/fflush.c index c80cbddbafd..7d34c0f1394 100644 --- a/reactos/lib/msvcrt/stdio/fflush.c +++ b/reactos/lib/msvcrt/stdio/fflush.c @@ -33,7 +33,7 @@ int fflush(FILE *f) __set_errno(0); _fwalk((void (*)(FILE *))fflush); - if (_errno) + if (errno) return EOF; __set_errno(e); return 0; diff --git a/reactos/lib/msvcrt/stdio/vfscanf.c b/reactos/lib/msvcrt/stdio/vfscanf.c index 7ad51057eee..0b6d53da1ae 100644 --- a/reactos/lib/msvcrt/stdio/vfscanf.c +++ b/reactos/lib/msvcrt/stdio/vfscanf.c @@ -150,8 +150,8 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) /* Integral holding variables. */ union { - LONGLONG int q; - ULONGLONG int uq; + LONGLONG q; + ULONGLONG uq; long int l; unsigned long int ul; } num; @@ -782,19 +782,19 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) if (! number_signed) { if (flags & LONGDBL) { - *ARG (ULONGLONG int *) = num.uq; + *ARG (ULONGLONG*) = num.uq; } else if (flags & LONG) - *ARG (unsigned long int *) = num.ul; + *ARG (unsigned long int*) = num.ul; else if (flags & SHORT) - *ARG (unsigned short int *) = (unsigned short int) num.ul; + *ARG (unsigned short int*) = (unsigned short int) num.ul; else - *ARG (unsigned int *) = (unsigned int) num.ul; + *ARG (unsigned int*) = (unsigned int) num.ul; } else { if (flags & LONGDBL) { - *ARG (LONGLONG int *) = num.q; + *ARG (LONGLONG *) = num.q; } else if (flags & LONG) *ARG (long int *) = num.l; diff --git a/reactos/lib/msvcrt/stdlib/putenv.c b/reactos/lib/msvcrt/stdlib/putenv.c index ce68245ba87..3f5c3de00d8 100644 --- a/reactos/lib/msvcrt/stdlib/putenv.c +++ b/reactos/lib/msvcrt/stdlib/putenv.c @@ -8,44 +8,24 @@ extern int BlockEnvToEnviron(); // defined in misc/dllmain.c -int _putenv(const char *val) +int _putenv(const char* val) { - char *buffer; - char *epos; - int res; + char* buffer; + char* epos; + int res; - DPRINT("_putenv('%s')\n", val); - epos = strchr(val, '='); - if ( epos == NULL ) - return -1; - buffer = (char*)malloc(epos - val + 1); - if (buffer == NULL) - return -1; - strncpy(buffer, val, epos - val); - buffer[epos - val] = 0; - res = SetEnvironmentVariableA(buffer,epos+1); - free(buffer); - if (BlockEnvToEnviron()) return 0; - return res; -} - -int _wputenv(const wchar_t *val) -{ - wchar_t *buffer; - wchar_t *epos; - int res; - - DPRINT("_wputenv('%S')\n", val); - epos = wcsrchr(val, L'='); - if ( epos == NULL ) - return -1; - buffer = (char*)malloc((epos - val + 1) * sizeof (wchar_t)); - if (buffer == NULL) - return -1; - wcsncpy(buffer, val, epos - val); - buffer[epos - val] = 0; - res = SetEnvironmentVariableW(buffer,epos+1); - free(buffer); - if (BlockEnvToEnviron() ) return 0; - return res; + DPRINT("_putenv('%s')\n", val); + epos = strchr(val, '='); + if ( epos == NULL ) + return -1; + buffer = (char*)malloc(epos - val + 1); + if (buffer == NULL) + return -1; + strncpy(buffer, val, epos - val); + buffer[epos - val] = 0; + res = SetEnvironmentVariableA(buffer, epos+1); + free(buffer); + if (BlockEnvToEnviron()) + return 0; + return res; } diff --git a/reactos/lib/msvcrt/stdlib/wputenv.c b/reactos/lib/msvcrt/stdlib/wputenv.c new file mode 100644 index 00000000000..08bfff5bea8 --- /dev/null +++ b/reactos/lib/msvcrt/stdlib/wputenv.c @@ -0,0 +1,31 @@ +#include +#include +#include + +#define NDEBUG +#include + + +extern int BlockEnvToEnviron(); // defined in misc/dllmain.c + +int _wputenv(const wchar_t* val) +{ + wchar_t* buffer; + wchar_t* epos; + int res; + + DPRINT("_wputenv('%S')\n", val); + epos = wcsrchr(val, L'='); + if (epos == NULL) + return -1; + buffer = (char*)malloc((epos - val + 1) * sizeof(wchar_t)); + if (buffer == NULL) + return -1; + wcsncpy(buffer, val, epos - val); + buffer[epos - val] = 0; + res = SetEnvironmentVariableW(buffer, epos+1); + free(buffer); + if (BlockEnvToEnviron()) + return 0; + return res; +} diff --git a/reactos/lib/msvcrt/wstring/wcsupr.c b/reactos/lib/msvcrt/wstring/wcsupr.c index 27db416ba42..1eeef91ec70 100644 --- a/reactos/lib/msvcrt/wstring/wcsupr.c +++ b/reactos/lib/msvcrt/wstring/wcsupr.c @@ -1,11 +1,12 @@ +#include #include wchar_t *_wcsupr(wchar_t *x) { - wchar_t *y=x; + wchar_t *y = x; while (*y) { - *y=towupper(*y); + *y = towupper(*y); y++; } return x; -- 2.17.1