add workarounds for mingw runtime version differences
gave directory routines a good cleanup (based on wine)
more tcharizing of routines
Modified: trunk/reactos/lib/crt/direct/chdir.c
Modified: trunk/reactos/lib/crt/direct/chdrive.c
Modified: trunk/reactos/lib/crt/direct/getcwd.c
Modified: trunk/reactos/lib/crt/direct/getdcwd.c
Modified: trunk/reactos/lib/crt/direct/getdrive.c
Modified: trunk/reactos/lib/crt/direct/mkdir.c
Modified: trunk/reactos/lib/crt/direct/rmdir.c
Modified: trunk/reactos/lib/crt/direct/wchdir.c
Modified: trunk/reactos/lib/crt/direct/wgetcwd.c
Modified: trunk/reactos/lib/crt/direct/wgetdcwd.c
Modified: trunk/reactos/lib/crt/direct/wmkdir.c
Modified: trunk/reactos/lib/crt/direct/wrmdir.c
Modified: trunk/reactos/lib/crt/float/fpclass.c
Added: trunk/reactos/lib/crt/include/internal/debug.h
Modified: trunk/reactos/lib/crt/include/internal/file.h
Deleted: trunk/reactos/lib/crt/include/internal/msvcrtdbg.h
Modified: trunk/reactos/lib/crt/io/access.c
Modified: trunk/reactos/lib/crt/io/chmod.c
Modified: trunk/reactos/lib/crt/io/chsize.c
Modified: trunk/reactos/lib/crt/io/close.c
Modified: trunk/reactos/lib/crt/io/create.c
Modified: trunk/reactos/lib/crt/io/find.c
Modified: trunk/reactos/lib/crt/io/isatty.c
Modified: trunk/reactos/lib/crt/io/mktemp.c
Modified: trunk/reactos/lib/crt/io/open.c
Modified: trunk/reactos/lib/crt/io/pipe.c
Modified: trunk/reactos/lib/crt/io/read.c
Modified: trunk/reactos/lib/crt/io/setmode.c
Modified: trunk/reactos/lib/crt/io/unlink.c
Modified: trunk/reactos/lib/crt/io/wcreate.c
Modified: trunk/reactos/lib/crt/io/wmktemp.c
Modified: trunk/reactos/lib/crt/io/wopen.c
Modified: trunk/reactos/lib/crt/io/write.c
Modified: trunk/reactos/lib/crt/io/wunlink.c
Modified: trunk/reactos/lib/crt/locale/locale.c
Modified: trunk/reactos/lib/crt/misc/crtmain.c
Modified: trunk/reactos/lib/crt/misc/environ.c
Modified: trunk/reactos/lib/crt/misc/lock.c
Modified: trunk/reactos/lib/crt/misc/stubs.c
Modified: trunk/reactos/lib/crt/process/process.c
Modified: trunk/reactos/lib/crt/signal/signal.c
Modified: trunk/reactos/lib/crt/stdio/fwrite.c
Modified: trunk/reactos/lib/crt/stdio/popen.c
Modified: trunk/reactos/lib/crt/stdio/remove.c
Modified: trunk/reactos/lib/crt/stdlib/getenv.c
Modified: trunk/reactos/lib/crt/stdlib/putenv.c
Modified: trunk/reactos/lib/crt/stdlib/senv.c
Modified: trunk/reactos/lib/crt/stdlib/wputenv.c
Modified: trunk/reactos/lib/crt/wine/scanf.c

Modified: trunk/reactos/lib/crt/direct/chdir.c
--- trunk/reactos/lib/crt/direct/chdir.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/chdir.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -2,14 +2,15 @@
 #include <ctype.h>
 #include <direct.h>
 #include <internal/file.h>
+#include <tchar.h>
 
 /*
  * @implemented
  */
-int _chdir(const char* _path)
+int _tchdir(const _TCHAR* _path)
 {
-    if (!SetCurrentDirectoryA((char*)_path)) {
-    	_dosmaperr(GetLastError());
+    if (!SetCurrentDirectory(_path)) {
+      _dosmaperr(_path?GetLastError():0);
 		return -1;
 	}
     return 0;

Modified: trunk/reactos/lib/crt/direct/chdrive.c
--- trunk/reactos/lib/crt/direct/chdrive.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/chdrive.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -6,29 +6,36 @@
 #include <internal/file.h>
 
 
-int cur_drive = 0;
-
-
 /*
- * @implemented
+ * @implemented 
+ *
+ *    _chdrive (MSVCRT.@)
+ *
+ * Change the current drive.
+ *
+ * PARAMS
+ *  newdrive [I] Drive number to change to (1 = 'A', 2 = 'B', ...)
+ *
+ * RETURNS
+ *  Success: 0. The current drive is set to newdrive.
+ *  Failure: -1. errno indicates the error.
+ *
+ * NOTES
+ *  See SetCurrentDirectoryA.
  */
-int _chdrive(int drive)
+int _chdrive(int newdrive)
 {
-    char d[3];
+  WCHAR buffer[] = L"A:";
 
-    if (!( drive >= 1 && drive <= 26)) {
-    	__set_errno(EINVAL);
-        return -1;
-	}
-    if (cur_drive != drive) {
-        cur_drive = drive;
-        d[0] = toupper(cur_drive + '@');
-        d[1] = ':';
-        d[2] = 0;
-        if (!SetCurrentDirectoryA(d)) {
-	    	_dosmaperr(GetLastError());
-	    	return -1;
-	    }	
+  buffer[0] += newdrive - 1;
+  if (!SetCurrentDirectoryW( buffer ))
+  {
+    _dosmaperr(GetLastError());
+    if (newdrive <= 0)
+    {
+      __set_errno(EACCES);
     }
-    return 0;
+    return -1;
+  }
+  return 0;
 }

Modified: trunk/reactos/lib/crt/direct/getcwd.c
--- trunk/reactos/lib/crt/direct/getcwd.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/getcwd.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -3,29 +3,33 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <internal/file.h>
+#include <tchar.h>
 
-
 /*
  * @implemented
  */
-char *_getcwd(char* buffer, int maxlen)
+_TCHAR* _tgetcwd(_TCHAR* buf, int size)
 {
-    char *cwd;
-    int len;
+  _TCHAR dir[MAX_PATH];
+  DWORD dir_len = GetCurrentDirectory(MAX_PATH,dir);
 
-    if (buffer == NULL) {
-        if ( (cwd = malloc(MAX_PATH)) == NULL ) {
-        	__set_errno(ENOMEM);
-        	return NULL;
-        }
-        len = MAX_PATH;
-    } else {
-        cwd = buffer;
-        len = maxlen;
-    }
-    if (GetCurrentDirectoryA(len, cwd) == 0) {
-    	_dosmaperr(GetLastError());
-        return NULL;
-    }
-    return cwd;
+  if (dir_len == 0)
+  {
+    _dosmaperr(GetLastError());
+    return NULL; /* FIXME: Real return value untested */
+  }
+
+  if (!buf)
+  {
+    return _tcsdup(dir);
+  }
+  
+  if (dir_len >= size)
+  {
+    __set_errno(ERANGE);
+    return NULL; /* buf too small */
+  }
+  
+  _tcscpy(buf,dir);
+  return buf;
 }

Modified: trunk/reactos/lib/crt/direct/getdcwd.c
--- trunk/reactos/lib/crt/direct/getdcwd.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/getdcwd.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -1,27 +1,64 @@
 #include "precomp.h"
 #include <direct.h>
 #include <internal/file.h>
+#include <internal/debug.h>
+#include <tchar.h>
+#include <errno.h>
 
 /*
  * @implemented
+ *
+ *    _getdcwd (MSVCRT.@)
+ *
+ * Get the current working directory on a given disk.
+ * 
+ * PARAMS
+ *  drive [I] Drive letter to get the current working directory from.
+ *  buf   [O] Destination for the current working directory.
+ *  size  [I] Length of drive in characters.
+ *
+ * RETURNS
+ *  Success: If drive is NULL, returns an allocated string containing the path.
+ *           Otherwise populates drive with the path and returns it.
+ *  Failure: NULL. errno indicates the error.
  */
-char* _getdcwd(int nDrive, char* caBuffer, int nBufLen)
+_TCHAR* _tgetdcwd(int drive, _TCHAR * buf, int size)
 {
-    int i =0;
-    int dr = _getdrive();
+  static _TCHAR* dummy;
 
-    if (nDrive < 1 || nDrive > 26)
-        return NULL;
-    if (dr != nDrive) {
-        if ( _chdrive(nDrive) != 0 )
-        	return NULL;
-	}
-    i = GetCurrentDirectoryA(nBufLen, caBuffer);
-    if (i == nBufLen)
-        return NULL;
-    if (dr != nDrive) {
-        if ( _chdrive(dr) != 0 )
-        	return NULL;
-	}
-    return caBuffer;
+  TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);
+
+  if (!drive || drive == _getdrive())
+    return _tgetcwd(buf,size); /* current */
+  else
+  {
+    _TCHAR dir[MAX_PATH];
+    _TCHAR drivespec[] = _T("A:");
+    int dir_len;
+
+    drivespec[0] += drive - 1;
+    if (GetDriveType(drivespec) < DRIVE_REMOVABLE)
+    {
+      __set_errno(EACCES);
+      return NULL;
+    }
+
+    /* GetFullPathName for X: means "get working directory on drive X",
+     * just like passing X: to SetCurrentDirectory means "switch to working
+     * directory on drive X". -Gunnar */
+    dir_len = GetFullPathName(drivespec,MAX_PATH,dir,&dummy);
+    if (dir_len >= size || dir_len < 1)
+    {
+      __set_errno(ERANGE);
+      return NULL; /* buf too small */
+    }
+
+    TRACE(":returning '%s'\n", dir);
+    if (!buf)
+      return _tcsdup(dir); /* allocate */
+
+    _tcscpy(buf,dir);
+  }
+  return buf;
 }
+

Modified: trunk/reactos/lib/crt/direct/getdrive.c
--- trunk/reactos/lib/crt/direct/getdrive.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/getdrive.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -3,28 +3,33 @@
 #include <direct.h>
 
 
-extern int cur_drive;
-
 /*
  * @implemented
+ *
+ *    _getdrive (MSVCRT.@)
+ *
+ * Get the current drive number.
+ *
+ * PARAMS
+ *  None.
+ *
+ * RETURNS
+ *  Success: The drive letter number from 1 to 26 ("A:" to "Z:").
+ *  Failure: 0.
  */
 int _getdrive(void)
 {
-    char Buffer[MAX_PATH];
-
-    if (cur_drive == 0) {
-        GetCurrentDirectoryA(MAX_PATH, Buffer);
-        cur_drive = toupper(Buffer[0] - '@');
-    }
-    return cur_drive;
+    WCHAR buffer[MAX_PATH];
+    if (GetCurrentDirectoryW( MAX_PATH, buffer ) &&
+        buffer[0] >= 'A' && buffer[0] <= 'z' && buffer[1] == ':')
+        return towupper(buffer[0]) - 'A' + 1;
+    return 0;
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 unsigned long _getdrives(void)
 {
-    //fixme get logical drives
-    //return GetLogicalDrives();
-    return 5;  // drive A and C
+   return GetLogicalDrives();
 }

Modified: trunk/reactos/lib/crt/direct/mkdir.c
--- trunk/reactos/lib/crt/direct/mkdir.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/mkdir.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -1,14 +1,14 @@
 #include "precomp.h"
 #include <direct.h>
 #include <internal/file.h>
+#include <tchar.h>
 
-
 /*
  * @implemented
  */
-int _mkdir(const char* _path)
+int _tmkdir(const _TCHAR* _path)
 {
-    if (!CreateDirectoryA(_path, NULL)) {
+    if (!CreateDirectory(_path, NULL)) {
     	_dosmaperr(GetLastError());
         return -1;
 	}

Modified: trunk/reactos/lib/crt/direct/rmdir.c
--- trunk/reactos/lib/crt/direct/rmdir.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/rmdir.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -1,14 +1,14 @@
 #include "precomp.h"
 #include <direct.h>
 #include <internal/file.h>
+#include <tchar.h>
 
-
 /*
  * @implemented
  */
-int _rmdir(const char* _path)
+int _trmdir(const _TCHAR* _path)
 {
-    if (!RemoveDirectoryA(_path)) {
+    if (!RemoveDirectory(_path)) {
     	_dosmaperr(GetLastError());
         return -1;
     }

Modified: trunk/reactos/lib/crt/direct/wchdir.c
--- trunk/reactos/lib/crt/direct/wchdir.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/wchdir.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -1,16 +1,5 @@
-#include "precomp.h"
-#include <ctype.h>
-#include <direct.h>
-#include <internal/file.h>
+#define UNICODE
+#define _UNICODE
 
-/*
- * @implemented
- */
-int _wchdir (const wchar_t *_path)
-{
-    if (!SetCurrentDirectoryW((wchar_t *)_path)) {
-    	_dosmaperr(GetLastError());
-        return -1;
-	}
-    return 0;
-}
+#include "chdir.c"
+

Modified: trunk/reactos/lib/crt/direct/wgetcwd.c
--- trunk/reactos/lib/crt/direct/wgetcwd.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/wgetcwd.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -1,28 +1,5 @@
-#include "precomp.h"
-#include <direct.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <internal/file.h>
+#define UNICODE
+#define _UNICODE
 
+#include "getcwd.c"
 
-/*
- * @implemented
- */
-wchar_t* _wgetcwd(wchar_t* buffer, int maxlen)
-{
-    wchar_t *cwd;
-    int len;
-    if (buffer == NULL) {
-        if ( (cwd = malloc(MAX_PATH * sizeof(wchar_t))) == NULL ) {
-        	__set_errno(ENOMEM);
-        	return NULL;
-        }
-        len = MAX_PATH;
-    } else {
-        cwd = buffer;
-        len = maxlen;
-    }
-    if (GetCurrentDirectoryW(len, cwd) == 0)
-        return NULL;
-    return cwd;
-}

Modified: trunk/reactos/lib/crt/direct/wgetdcwd.c
--- trunk/reactos/lib/crt/direct/wgetdcwd.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/wgetdcwd.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -1,32 +1,5 @@
-#include "precomp.h"
-#include <direct.h>
-#include <internal/file.h>
+#define UNICODE
+#define _UNICODE
 
+#include "getdcwd.c"
 
-/*
- * @implemented
- */
-wchar_t* _wgetdcwd(int nDrive, wchar_t* caBuffer, int nBufLen)
-{
-    int i =0;
-    int dr = _getdrive();
-
-    if (nDrive < 1 || nDrive > 26)
-        return NULL;
-
-    if (dr != nDrive) {
-        if ( _chdrive(nDrive) != 0 )
-        	return NULL;
-	}
-
-    i = GetCurrentDirectoryW(nBufLen, caBuffer);
-    if (i == nBufLen)
-        return NULL;
-
-    if (dr != nDrive) {
-    	if ( _chdrive(dr) != 0 )
-			return NULL;
-	}
-
-    return caBuffer;
-}

Modified: trunk/reactos/lib/crt/direct/wmkdir.c
--- trunk/reactos/lib/crt/direct/wmkdir.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/wmkdir.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -1,16 +1,4 @@
-#include "precomp.h"
-#include <direct.h>
-#include <internal/file.h>
+#define UNICODE
+#define _UNICODE
 
-
-/*
- * @implemented
- */
-int _wmkdir(const wchar_t* _path)
-{
-    if (!CreateDirectoryW(_path, NULL)) {
-    	_dosmaperr(GetLastError());
-        return -1;
-	}
-    return 0;
-}
+#include "mkdir.c"

Modified: trunk/reactos/lib/crt/direct/wrmdir.c
--- trunk/reactos/lib/crt/direct/wrmdir.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/direct/wrmdir.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -1,16 +1,4 @@
-#include "precomp.h"
-#include <direct.h>
-#include <internal/file.h>
+#define UNICODE
+#define _UNICODE
 
-
-/*
- * @implemented
- */
-int _wrmdir(const wchar_t* _path)
-{
-    if (!RemoveDirectoryW(_path)) {
-    	_dosmaperr(GetLastError());
-        return -1;
-	}
-    return 0;
-}
+#include "rmdir.c"

Modified: trunk/reactos/lib/crt/float/fpclass.c
--- trunk/reactos/lib/crt/float/fpclass.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/float/fpclass.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -14,6 +14,9 @@
 #define _FPCLASS_PN	0x0100	/* positive normal */
 #define _FPCLASS_PINF	0x0200	/* positive infinity */
 
+
+#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3
+
 #define FP_SNAN       0x0001  //    signaling NaN
 #define	FP_QNAN       0x0002  //    quiet NaN
 #define	FP_NINF       0x0004  //    negative infinity
@@ -25,6 +28,8 @@
 #define FP_NNORM      0x0080  //    negative normalized non-zero
 #define FP_PNORM      0x0100  //    positive normalized non-zero
 
+#endif
+
 typedef int fpclass_t;
 
 /*

Copied: trunk/reactos/lib/crt/include/internal/debug.h (from rev 13607, trunk/reactos/lib/crt/include/internal/msvcrtdbg.h)

Modified: trunk/reactos/lib/crt/include/internal/file.h
--- trunk/reactos/lib/crt/include/internal/file.h	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/include/internal/file.h	2005-02-17 11:38:16 UTC (rev 13615)
@@ -185,6 +185,10 @@
 
 wint_t _filwbuf(FILE *f);
 
+#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 2
+   int __cdecl _filbuf (FILE*);
+   int __cdecl _flsbuf (int, FILE*);
+#endif
 
 
 #endif /* __dj_include_libc_file_h__ */

Deleted: trunk/reactos/lib/crt/include/internal/msvcrtdbg.h
--- trunk/reactos/lib/crt/include/internal/msvcrtdbg.h	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/include/internal/msvcrtdbg.h	2005-02-17 11:38:16 UTC (rev 13615)
@@ -1,90 +0,0 @@
-/*
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            include/msvcrt/msvcrtdbg.h
- * PURPOSE:         Useful debugging macros
- * PROGRAMMER:      
- * UPDATE HISTORY: 
- *                
- */
-
-/*
- * NOTE: Define NDEBUG before including this header to disable debugging
- * macros
- */
-
-#ifndef __MSVCRT_DEBUG
-#define __MSVCRT_DEBUG
-
-#include <roscfg.h>
-#include <windows.h>
-
-
-#define MK_STR(s) #s
-
-#ifdef _UNICODE
-   #define sT "S"
-#else   
-   #define sT "s"
-#endif
-   
- 
- 
-#define TRACE(...)
-
-
-#ifdef DBG
-   #define DPRINT1(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
-   #define CHECKPOINT1 do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0);
-#else
-   #ifdef __GNUC__
-      #define DPRINT1(args...)
-   #else
-      #define DPRINT DbgPrint
-   #endif
-   #define CHECKPOINT1
-#endif
-
-#if !defined(NDEBUG) && defined(DBG) 
-   #define DPRINT(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
-   #define CHECKPOINT do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0);
-#else
-   #ifdef __GNUC__
-      #define DPRINT(args...)
-   #else
-      #define DPRINT DbgPrint
-   #endif
-   #define CHECKPOINT
-#endif /* NDEBUG */
-
-
-#if 0
-
-   #define TRACE_RETURN(format_str, ret_type) \
-   ret_type __return_value__; \
-   static char* __return_format_str__ = "%s ret: "format_str"\n"
-
-   #define FUNCTION(func) \
-   static char* __func_name__ = #func
-
-   #define TRACE(a,b...) DPRINT1(a"\n", b)
-
-   #define RETURN(a) \
-   do{ __return_value__ = (a); DPRINT1(__return_format_str__ ,__func_name__,__return_value__); return __return_value__ ; }while(0)
-
-#endif
-
-
-/* ULONG CDECL DbgPrint(PCH Format, ...); */
-ULONG DbgPrint(PCH Format,...);
-/* unsigned long DbgPrint(const char* Format, ...); */
-
-
-
-/* #define TRACE 0 ? (void)0 : Trace */
-
-/* void Trace(TCHAR* lpszFormat, ...); */
-
-
-
-#endif /* __MSVCRT_DEBUG */

Modified: trunk/reactos/lib/crt/io/access.c
--- trunk/reactos/lib/crt/io/access.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/access.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -5,7 +5,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 #ifdef _UNICODE
  #define _TS S

Modified: trunk/reactos/lib/crt/io/chmod.c
--- trunk/reactos/lib/crt/io/chmod.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/chmod.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -6,7 +6,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 #define mode_t int

Modified: trunk/reactos/lib/crt/io/chsize.c
--- trunk/reactos/lib/crt/io/chsize.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/chsize.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -2,7 +2,7 @@
 #include <io.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/io/close.c
--- trunk/reactos/lib/crt/io/close.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/close.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -3,7 +3,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/io/create.c
--- trunk/reactos/lib/crt/io/create.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/create.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -2,7 +2,7 @@
 #include <fcntl.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/io/find.c
--- trunk/reactos/lib/crt/io/find.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/find.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -8,7 +8,7 @@
 /*
  * @implemented
  */
-#ifdef _UNICODE
+#if defined(_UNICODE) || !(__MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3)
 long
 #else
 int
@@ -60,7 +60,7 @@
  * @implemented
  */
 int _tfindnext(
-#ifdef _UNICODE
+#if defined(_UNICODE) || !(__MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3)
    long handle,
 #else
    int handle,
@@ -176,7 +176,13 @@
 /*
  * @implemented
  */
-int _findclose(int handle)
+int _findclose(
+#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3
+   int handle
+#else
+   long handle
+#endif
+   )
 {
     // check no wildcards or invalid handle
     if (handle == 0 || handle == -1)

Modified: trunk/reactos/lib/crt/io/isatty.c
--- trunk/reactos/lib/crt/io/isatty.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/isatty.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -2,7 +2,7 @@
 #include <sys/stat.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/io/mktemp.c
--- trunk/reactos/lib/crt/io/mktemp.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/mktemp.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -18,7 +18,7 @@
 #include <io.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/io/open.c
--- trunk/reactos/lib/crt/io/open.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/open.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -52,7 +52,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 

Modified: trunk/reactos/lib/crt/io/pipe.c
--- trunk/reactos/lib/crt/io/pipe.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/pipe.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -15,7 +15,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/io/read.c
--- trunk/reactos/lib/crt/io/read.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/read.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -17,7 +17,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/io/setmode.c
--- trunk/reactos/lib/crt/io/setmode.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/setmode.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -14,6 +14,6 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 

Modified: trunk/reactos/lib/crt/io/unlink.c
--- trunk/reactos/lib/crt/io/unlink.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/unlink.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -13,7 +13,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/io/wcreate.c
--- trunk/reactos/lib/crt/io/wcreate.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/wcreate.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -2,7 +2,7 @@
 #include <fcntl.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/io/wmktemp.c
--- trunk/reactos/lib/crt/io/wmktemp.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/wmktemp.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -18,7 +18,7 @@
 #include <io.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/io/wopen.c
--- trunk/reactos/lib/crt/io/wopen.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/wopen.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -26,7 +26,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/io/write.c
--- trunk/reactos/lib/crt/io/write.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/write.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -16,7 +16,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 #define BUFSIZE 4096
 /*

Modified: trunk/reactos/lib/crt/io/wunlink.c
--- trunk/reactos/lib/crt/io/wunlink.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/io/wunlink.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -13,7 +13,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/locale/locale.c
--- trunk/reactos/lib/crt/locale/locale.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/locale/locale.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 unsigned int __setlc_active;
 unsigned int __unguarded_readlc_active;

Modified: trunk/reactos/lib/crt/misc/crtmain.c
--- trunk/reactos/lib/crt/misc/crtmain.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/misc/crtmain.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -6,7 +6,7 @@
 #include "precomp.h"
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 #ifndef __GNUC__
 

Modified: trunk/reactos/lib/crt/misc/environ.c
--- trunk/reactos/lib/crt/misc/environ.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/misc/environ.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -12,7 +12,7 @@
 #include <internal/file.h>
   
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 unsigned int _osver = 0;

Modified: trunk/reactos/lib/crt/misc/lock.c
--- trunk/reactos/lib/crt/misc/lock.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/misc/lock.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -19,7 +19,7 @@
 #include "precomp.h"
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 #include <internal/mtdll.h>
 
 typedef struct

Modified: trunk/reactos/lib/crt/misc/stubs.c
--- trunk/reactos/lib/crt/misc/stubs.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/misc/stubs.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -1,7 +1,7 @@
 #include "precomp.h"
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 /*********************************************************************
  *		$I10_OUTPUT (MSVCRT.@)

Modified: trunk/reactos/lib/crt/process/process.c
--- trunk/reactos/lib/crt/process/process.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/process/process.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -7,7 +7,7 @@
 #include <tchar.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 #ifdef _UNICODE
    #define find_execT find_execW

Modified: trunk/reactos/lib/crt/signal/signal.c
--- trunk/reactos/lib/crt/signal/signal.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/signal/signal.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -89,7 +89,7 @@
 int
 raise(int sig)
 {
-   __p_sig_fn_t temp;// = SIG_DFL;
+   __p_sig_fn_t temp = 0;
    int i;
 
    switch (sig)

Modified: trunk/reactos/lib/crt/stdio/fwrite.c
--- trunk/reactos/lib/crt/stdio/fwrite.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/stdio/fwrite.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -6,7 +6,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/stdio/popen.c
--- trunk/reactos/lib/crt/stdio/popen.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/stdio/popen.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -8,7 +8,7 @@
 #include <internal/file.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/stdio/remove.c
--- trunk/reactos/lib/crt/stdio/remove.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/stdio/remove.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -4,7 +4,7 @@
 #include <tchar.h>
 
 #define NDEBUG
-#include <internal/msvcrtdbg.h>
+#include <internal/debug.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/stdlib/getenv.c
--- trunk/reactos/lib/crt/stdlib/getenv.c	2005-02-17 10:44:57 UTC (rev 13614)
+++ trunk/reactos/lib/crt/stdlib/getenv.c	2005-02-17 11:38:16 UTC (rev 13615)
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 
 #define NDEBUG
[truncated at 1000 lines; 63 more skipped]