OSDN Git Service

Correct malformations and missed definitions to finish _USE_32BIT_TIME_T coding.
authorEarnie Boyd <earnie@users.sourceforge.net>
Sun, 16 Jun 2013 18:23:18 +0000 (14:23 -0400)
committerEarnie Boyd <earnie@users.sourceforge.net>
Sun, 16 Jun 2013 18:23:18 +0000 (14:23 -0400)
ChangeLog
include/_mingw.h
include/string.h
include/sys/stat.h
include/sys/utime.h
include/wchar.h

index 96e0515..91c6818 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2013-06-16  Earnie Boyd  <earnie@users.sourceforge.net>
+
+       * include/_mingw.h (GCC system_header): Add a __CRT_TESTING__ filter.
+       * include/string.h (GCC system_header): Ditto.
+       * include/sys/stat.h (GCC system_header): Ditto.
+       (string.h): Move the include toward the top of the file.
+       (extern "C" {): Move above the filters so that it is not incorrectly
+       conditional.
+       Correct some comments and move the opening brace to the function
+       definition line throughout.
+       * include/sys/utime.h (utime): Move declaration to after the declaration
+       of _utime64().  Create a _CRTALIAS when _USE_32BIT_TIME_T is undefined.
+       Add datatype specifiers within the _CRTALIAS definitions throughout.
+       * include/wchar.h (GCC system_header): Add a __CRT_TESTING__ filter.
+       (FILENAME_MAX): Define macro if not already defined.
+       Correct comments throughout.
+       Correct #if...#endif misaligned pair.
+       (wcsicmp): Use _CRTALIAS instead of __CRT_INLINE since it is a one line
+       function definition.
+       (*wfinddata*): Use FILENAME_MAX throughout.
+       (_wstat32): Make a _CRTALIAS rather than a _CRTIMP.
+       (_wstat64i32): Use __CRT_MAYBE_INLINE instead of __CRT_INLINE.
+       (_wstat32i64): Define.
+       (_wstat, _wstati64): Remove the MSVCRT_VERSION >= 800 filter.
+
 2013-06-07  Earnie Boyd  <earnie@users.sourceforge.net>
 
        * include/_mingw.h (_CRTALIAS): Add comments explaining its purpose.
index f038fdf..eb7c41f 100644 (file)
@@ -29,7 +29,9 @@
  */
 #ifndef __MINGW_H
 #define __MINGW_H
+#ifndef __CRT_TESTING__
 #pragma GCC system_header
+#endif
 #include <sdkddkver.h>
 
 #define __MINGW_VERSION             4.0
index 11f6601..65ba493 100644 (file)
@@ -8,11 +8,11 @@
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * and/or sell copies of the Software, and to permit persons to whom the
  * Software is furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the next
  * paragraph) shall be included in all copies or substantial portions of the
  * Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,7 +23,9 @@
  */
 #ifndef _STRING_H
 #define        _STRING_H
+#ifndef __CRT_TESTING__
 #pragma GCC system_header
+#endif
 #include <_mingw.h>
 
 /*
index 36198f0..43047ba 100644 (file)
@@ -23,7 +23,9 @@
  */
 #ifndef _STAT_H_
 #define _STAT_H_
+#ifndef __CRT_TESTING__
 #pragma GCC system_header
+#endif
 #include <_mingw.h>
 
 #define __need_size_t
@@ -33,6 +35,7 @@
 #endif /* Not RC_INVOKED */
 
 #include <sys/types.h>
+#include <string.h> /* Need memset declaration */
 
 /*
  * Constants for the stat st_mode member.
 
 #ifndef RC_INVOKED
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef _STAT_DEFINED
 /*
  * The structure manipulated and returned by stat and fstat.
@@ -170,10 +177,6 @@ struct _stat64i32 {
        __time64_t      st_ctime;
 };
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* _stat32 does not exist in MSVCRT.DLL */
 _CRTIMP int __cdecl __MINGW_NOTHROW _stat (const char*, struct _stat32*);
 _CRTALIAS int __cdecl __MINGW_NOTHROW _stat32 (const char* _v1, struct _stat32* _v2) {
@@ -193,7 +196,7 @@ _CRTALIAS int __cdecl __MINGW_NOTHROW _fstat32 (int _v1, struct _stat32* _v2) {
 _CRTIMP int __cdecl __MINGW_NOTHROW _fstat64 (int, struct _stat64*);
 int __cdecl __MINGW_NOTHROW _fstat32i64 (int, struct _stat32i64*);
 int __cdecl __MINGW_NOTHROW _fstat64i32 (int, struct _stat64i32*);
-#include <string.h> /* Need memset declaration */
+
 __CRT_MAYBE_INLINE int __cdecl _fstat64i32(int desc, struct _stat64i32 *_stat) {
   struct _stat64 st;
   int ret = _fstat64(desc, &st);
@@ -214,8 +217,7 @@ __CRT_MAYBE_INLINE int __cdecl _fstat64i32(int desc, struct _stat64i32 *_stat) {
   _stat->st_ctime = st.st_ctime;
   return ret;
 }
-__CRT_MAYBE_INLINE int __cdecl _fstat32i64(int desc, struct _stat32i64 *_stat)
-{
+__CRT_MAYBE_INLINE int __cdecl _fstat32i64(int desc, struct _stat32i64 *_stat) {
   struct _stat32 st;
   int ret = _fstat32(desc, &st);
   if (ret == -1) {
@@ -235,8 +237,7 @@ __CRT_MAYBE_INLINE int __cdecl _fstat32i64(int desc, struct _stat32i64 *_stat)
   _stat->st_ctime = st.st_ctime;
   return ret;
 }
-__CRT_MAYBE_INLINE int __cdecl _stat64i32(const char *fname, struct _stat64i32 *_stat)
-{
+__CRT_MAYBE_INLINE int __cdecl _stat64i32(const char *fname, struct _stat64i32 *_stat) {
   struct _stat64 st;
   int ret = _stat64(fname, &st);
   if (ret == -1) {
@@ -256,8 +257,7 @@ __CRT_MAYBE_INLINE int __cdecl _stat64i32(const char *fname, struct _stat64i32 *
   _stat->st_ctime = st.st_ctime;
   return ret;
 }
-__CRT_MAYBE_INLINE int __cdecl _stat32i64(const char *fname, struct _stat32i64 *_stat)
-{
+__CRT_MAYBE_INLINE int __cdecl _stat32i64(const char *fname, struct _stat32i64 *_stat) {
   struct _stat32 st;
   int ret = _stat32(fname, &st);
   if (ret == -1) {
@@ -303,17 +303,15 @@ __CRT_MAYBE_INLINE int __cdecl _stat32i64(const char *fname, struct _stat32i64 *
 
 #if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
 /* _wstat32 does not exist in MSVCRT.DLL */
+_CRTIMP int __cdecl __MINGW_NOTHROW _wstat (const wchar_t*, struct _stat32*);
 _CRTALIAS int __cdecl __MINGW_NOTHROW _wstat32 (const wchar_t* _v1, struct _stat32* _v2) {
-    _CRTIMP int __cdecl __MINGW_NOTHROW _wstat (const wchar_t*, struct _stat32*);
     return _wstat(_v1, _v2);
 }
 
 _CRTIMP int __cdecl __MINGW_NOTHROW _wstat64 (const wchar_t*, struct _stat64*);
 _CRTIMP int __cdecl __MINGW_NOTHROW _wstat32i64 (const wchar_t*, struct _stat32i64*);
 int __cdecl __MINGW_NOTHROW _wstat64i32 (const wchar_t*, struct _stat64i32*);
-#include <string.h> /* Need memset declaration */
-__CRT_MAYBE_INLINE int __cdecl _wstat64i32(const wchar_t *fname, struct _stat64i32 *_stat)
-{
+__CRT_MAYBE_INLINE int __cdecl _wstat64i32(const wchar_t *fname, struct _stat64i32 *_stat) {
   struct _stat64 st;
   int ret = _wstat64(fname, &st);
   if (ret == -1) {
@@ -333,8 +331,7 @@ __CRT_MAYBE_INLINE int __cdecl _wstat64i32(const wchar_t *fname, struct _stat64i
   _stat->st_ctime = st.st_ctime;
   return ret;
 }
-__CRT_MAYBE_INLINE int __cdecl _wstat32i64(const wchar_t *fname, struct _stat32i64 *_stat)
-{
+__CRT_MAYBE_INLINE int __cdecl _wstat32i64(const wchar_t *fname, struct _stat32i64 *_stat) {
   struct _stat32 st;
   int ret = _wstat32(fname, &st);
   if (ret == -1) {
@@ -359,14 +356,15 @@ __CRT_MAYBE_INLINE int __cdecl _wstat32i64(const wchar_t *fname, struct _stat32i
 #define _wstat      _wstat32
 #define _wstati64   _wstat32i64
 
-#else /* !_USE_32BIT_TIME_T */
+#else /* ! _USE_32BIT_TIME_T */
 #define _wstat      _wstat64i32
 #define _wstati64   _wstat64
 
 #endif /* _USE_32BIT_TIME_T */
 
 #define _WSTAT_DEFINED
-#endif /* _WSTAT_DEFIND */
+#endif /* ! _WSTAT_DEFIND */
+
 
 #ifdef __cplusplus
 }
index 9d5db74..afcb7e3 100644 (file)
@@ -74,14 +74,6 @@ struct utimbuf32
 extern "C" {
 #endif
 
-#ifndef        _NO_OLDNAMES
-#ifdef _USE_32BIT_TIME_T
-_CRTIMP int __cdecl __MINGW_NOTHROW    utime (const char*, struct utimbuf*);
-#else
-#define utime _utime
-#endif
-#endif /* Not _NO_OLDNAMES */
-
 _CRTIMP int __cdecl __MINGW_NOTHROW    _utime64 (const char*, struct __utimbuf64*);
 _CRTIMP int __cdecl __MINGW_NOTHROW    _futime64 (int, struct __utimbuf64*);
 
@@ -92,16 +84,27 @@ _CRTIMP int __cdecl __MINGW_NOTHROW _futime32 (int, struct __utimbuf32*);
 #else
 _CRTIMP int __cdecl __MINGW_NOTHROW    _utime (const char*, struct _utimbuf*);
 _CRTALIAS int __cdecl __MINGW_NOTHROW _utime32 (const char* _v1, struct __utimbuf32* _v2) {
-    return _utime(_v1, _v2);
+    return _utime(_v1, (struct _utimbuf*)_v2);
 }
 
 _CRTIMP int __cdecl __MINGW_NOTHROW    _futime (int, struct _utimbuf*);
 _CRTALIAS int __cdecl __MINGW_NOTHROW _futime32 (int _v1, struct __utimbuf32* _v2) {
-    return _futime(_v1, _v2);
+    return _futime(_v1, (struct _utimbuf*)_v2);
 }
 
 #endif
 
+#ifndef        _NO_OLDNAMES
+#ifdef _USE_32BIT_TIME_T
+_CRTIMP int __cdecl __MINGW_NOTHROW    utime (const char*, struct utimbuf*);
+#else
+int __cdecl __MINGW_NOTHROW utime (const char*, struct utimbuf*);
+_CRTALIAS int __cdecl __MINGW_NOTHROW  utime (const char* _v1, struct utimbuf* _v2) {
+  return _utime64(_v1, (struct __utimbuf64*)_v2);
+}
+#endif
+#endif /* Not _NO_OLDNAMES */
+
 #ifndef _USE_32BIT_TIME_T
 _CRTALIAS int __cdecl __MINGW_NOTHROW  _utime (const char* _v1, struct _utimbuf* _v2) {
     return(_utime64  (_v1,(struct __utimbuf64*)_v2));
@@ -130,7 +133,7 @@ _CRTIMP int __cdecl __MINGW_NOTHROW _wutime32 (const wchar_t*, struct __utimbuf3
 #else /* MSVCRT_VERSION < 800 */
 _CRTIMP int __cdecl __MINGW_NOTHROW    _wutime (const wchar_t*, struct _utimbuf*);
 _CRTALIAS int __cdecl __MINGW_NOTHROW _wutime32 (const wchar_t* _v1, struct __utimbuf32* _v2) {
-    return _wutime(_v1, _v2);
+    return _wutime(_v1, (struct _utimbuf*)_v2);
 }
 
 #endif /* MSVCRT_VERSION >= 800 */
index 7066839..0efaedc 100644 (file)
@@ -23,7 +23,9 @@
  */
 #ifndef        _WCHAR_H_
 #define        _WCHAR_H_
+#ifndef __CRT_TESTING__
 #pragma GCC system_header
+#endif
 #include <_mingw.h>
 
 #ifndef RC_INVOKED
@@ -38,7 +40,7 @@
 #define __need___va_list
 #include <stdarg.h>
 #define __VALIST __builtin_va_list
-#endif
+#endif /* ndef __VALIST */
 
 #endif /* Not RC_INVOKED */
 
 #define        WEOF    (wchar_t)(0xFFFF)
 #endif
 
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 260
+#endif
+
 #ifndef RC_INVOKED
 
 #ifdef __cplusplus
@@ -243,13 +249,12 @@ _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW  _wctime32 (const __time32_t* _v1) {
 #endif /* MSVCRT_VERSION >= 800 */
 
 #if MSVCRT_VERSION >= 800
-#if defined(_USE_32BIT_TIME_T)
+#ifdef _USE_32BIT_TIME_T
 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW     _wctime (const time_t* _v)      { return(_wctime32 (_v)); }
 
-#else /* MSVCRT_VERSION < 800 */
+#else /* ! _USE_32BIT_TIME_T */
 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW     _wctime (const time_t* _v)      { return(_wctime64 (_v)); }
-#endif /* defined(_USE_32BIT_TIME_T) */
-#endif /* MSVCRT_VERSION >= 800 */
+#endif /* _USE_32BIT_TIME_T */
 
 #else /* MSVCRT_VERSION < 800 */
 #ifdef _USE_32BIT_TIME_T
@@ -272,7 +277,7 @@ _CRTIMP int __cdecl __MINGW_NOTHROW _wutime32 (const wchar_t*, struct __utimbuf3
 #else /* MSVCRT_VERSION < 800 */
 _CRTIMP int __cdecl __MINGW_NOTHROW    _wutime (const wchar_t*, struct _utimbuf*);
 _CRTALIAS int __cdecl __MINGW_NOTHROW _wutime32 (const wchar_t* _v1, struct __utimbuf32* _v2) {
-    return _wutime(_v1, _v2);
+    return _wutime(_v1, (struct _utimbuf *)_v2);
 }
 
 #endif /* MSVCRT_VERSION >= 800 */
@@ -341,11 +346,9 @@ _CRTIMP  wchar_t* __cdecl __MINGW_NOTHROW __wcserror(const wchar_t*);
 #ifndef        _NO_OLDNAMES
 /* NOTE: There is no _wcscmpi, but this is for compatibility. */
 int __cdecl __MINGW_NOTHROW wcscmpi (const wchar_t *, const wchar_t *);
-#ifndef __NO_INLINE__
-__CRT_INLINE int __cdecl __MINGW_NOTHROW
+_CRTALIAS int __cdecl __MINGW_NOTHROW
 wcscmpi (const wchar_t * __ws1, const wchar_t * __ws2)
   {return _wcsicmp (__ws1, __ws2);}
-#endif
 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsdup (const wchar_t*);
 _CRTIMP int __cdecl __MINGW_NOTHROW    wcsicmp (const wchar_t*, const wchar_t*);
 _CRTIMP int __cdecl __MINGW_NOTHROW    wcsicoll (const wchar_t*, const wchar_t*);
@@ -427,7 +430,7 @@ struct _wfinddata_t {
        time_t          time_access;    /* -1 for FAT file systems */
        time_t          time_write;
        _fsize_t        size;
-       wchar_t         name[260];      /* may include spaces. */
+       wchar_t         name[FILENAME_MAX];     /* may include spaces. */
 };
 struct _wfinddatai64_t {
        unsigned    attrib;
@@ -435,7 +438,7 @@ struct _wfinddatai64_t {
        time_t      time_access;
        time_t      time_write;
        __int64     size;
-       wchar_t     name[260];
+       wchar_t     name[FILENAME_MAX];
 };
 struct _wfinddata64_t {
         unsigned    attrib;
@@ -444,9 +447,8 @@ struct _wfinddata64_t {
         __time64_t  time_write;
 /* 8 bytes are returned so it can't be _fsize_t */
         __int64    size;
-        wchar_t     name[260];
+        wchar_t     name[FILENAME_MAX];
 };
-#include <stdio.h>
 struct _wfinddata32_t {
        unsigned        attrib;
        __time32_t      time_create;
@@ -514,7 +516,7 @@ _CRTALIAS int  __cdecl __MINGW_NOTHROW      _wfindnext32 (intptr_t _v1, struct _wfind
 #define _wfindfirsti64 _wfindfirst32i64
 #define _wfindnexti64 _wfindnext32i64
 
-#else /* !defined(_USE_32BIT_TIME_T)
+#else /* !defined(_USE_32BIT_TIME_T) */
 #define _wfinddata_t _wfinddata64i32_t
 #define _wfinddatai64_t _wfinddata64_t
 #define _wfindfirst _wfindfirst64i32
@@ -621,28 +623,32 @@ struct _stat64i32 {
 };
 
 #define __stat64 _stat64
-#if defined(_USE_32BIT_TIME_T) && MSVCRT_VERSION >= 800
+#if defined(_USE_32BIT_TIME_T)
 #define _fstat      _fstat32
 #define _fstati64   _fstat32i64
 #define _stat       _stat32
 #define _stati64    _stat32i64
-#else  /* !_USE_32BIT_TIME_T */
+#else  /* ! _USE_32BIT_TIME_T */
 #define _fstat      _fstat64i32
 #define _fstati64   _fstat64
 #define _stat       _stat64i32
 #define _stati64    _stat64
 #endif /* _USE_32BIT_TIME_T */
 #define _STAT_DEFINED
-#endif /* _STAT_DEFINED */
+#endif /* _STAT_DEFINED */
 
 #if !defined ( _WSTAT_DEFINED) /* also declared in sys/stat.h */
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstat32 (const wchar_t*, struct _stat32*);
+/* _wstat32 does not exist in MSVCRT.DLL */
+_CRTIMP int __cdecl __MINGW_NOTHROW _wstat (const wchar_t*, struct _stat32*);
+_CRTALIAS int __cdecl __MINGW_NOTHROW _wstat32 (const wchar_t* _v1, struct _stat32* _v2) {
+    return _wstat(_v1, _v2);
+}
+
 _CRTIMP int __cdecl __MINGW_NOTHROW _wstat64 (const wchar_t*, struct _stat64*);
 _CRTIMP int __cdecl __MINGW_NOTHROW _wstat32i64 (const wchar_t*, struct _stat32i64*);
 int __cdecl __MINGW_NOTHROW _wstat64i32 (const wchar_t*, struct _stat64i32*);
-#ifndef __NO_INLINE__
 #include <string.h> /* Need memset declaration. */
-  __CRT_INLINE int __cdecl _wstat64i32(const wchar_t *fname, struct _stat64i32 *_stat)
+__CRT_MAYBE_INLINE int __cdecl _wstat64i32(const wchar_t *fname, struct _stat64i32 *_stat)
   {
     struct _stat64 st;
     int ret = _wstat64(fname, &st);
@@ -662,16 +668,33 @@ int __cdecl __MINGW_NOTHROW _wstat64i32 (const wchar_t*, struct _stat64i32*);
     _stat->st_mtime = st.st_mtime;
     _stat->st_ctime = st.st_ctime;
     return ret;
+}
+__CRT_MAYBE_INLINE int __cdecl _wstat32i64(const wchar_t *fname, struct _stat32i64 *_stat) {
+  struct _stat32 st;
+  int ret = _wstat32(fname, &st);
+  if (ret == -1) {
+    memset(_stat, 0, sizeof(struct _stat32i64));
+    return -1;
   }
-#else
-#define _wstat64i32 _wstat64
-#endif
+  _stat->st_dev = st.st_dev;
+  _stat->st_ino = st.st_ino;
+  _stat->st_mode = st.st_mode;
+  _stat->st_nlink = st.st_nlink;
+  _stat->st_uid = st.st_uid;
+  _stat->st_gid = st.st_gid;
+  _stat->st_rdev = st.st_rdev;
+  _stat->st_size = (_off_t) st.st_size;
+  _stat->st_atime = st.st_atime;
+  _stat->st_mtime = st.st_mtime;
+  _stat->st_ctime = st.st_ctime;
+  return ret;
+}
 
-#if defined(_USE_32BIT_TIME_T) && MSVCRT_VERSION >= 800
+#if defined(_USE_32BIT_TIME_T)
 #define _wstat      _wstat32
 #define _wstati64   _wstat32i64
-#else
 
+#else /* ! _USE_32BIT_TIME_T */
 #define _wstat      _wstat64i32
 #define _wstati64   _wstat64
 #endif /* _USE_32BIT_TIME_T */