From: <ped...@us...> - 2007-06-24 21:30:38
|
Revision: 993 http://svn.sourceforge.net/cegcc/?rev=993&view=rev Author: pedroalves Date: 2007-06-24 14:30:34 -0700 (Sun, 24 Jun 2007) Log Message: ----------- * mingwex/dirname.c (dirname) [__COREDLL__]: Don't handle drive names. * mingwex/basename.c (basename) [__COREDLL__]: Likewise. * mingwex/wdirent.c (UNICODE_DIRENT): New define. * mingwex/dirent.c [__COREDLL__]: Don't include errno.h or direct.h. (__set_errno): New. (ENOTDIR, EFAULT, EINVAL): Define. (_TDIR, _TCHAR, _T, _topendir, _treaddir, _tclosedir, _trewinddir, _ttelldir, tseekdir, _tfindfirst, _tfindnext, _tcscat, _tcsncpy, _tcslen, _tcscpy, _tcsrchr, _tdirent) [!UNICODE_DIRENT]: Redefine to the non-wide counterparts. (_tGetFileAttributes) [__COREDLL__]: Reimplement for Windows CE. (_topendir): Use __set_errno. Avoid _tfullpath. (_treaddir, _closedir, _trewinddir, _ttelldir, _tseekdir): Use __set_errno. * mingwex/wcstold.c: Don't compile on WinCE. * mingwex/getopt.c [__COREDLL__]: Don't include errno.h. (IS_POSIXLY_CORRECT) [__MINGW32CE__]: Hardcode to 0. * mingwex/gettimeofday.c (gettimeofday) [__COREDLL__]: Replace the GetSystemTimeAsFileTime call with GetSystemTime and SystemTimeToFileTime. Modified Paths: -------------- trunk/cegcc/src/mingw/ChangeLog.mingw32ce trunk/cegcc/src/mingw/mingwex/basename.c trunk/cegcc/src/mingw/mingwex/dirent.c trunk/cegcc/src/mingw/mingwex/dirname.c trunk/cegcc/src/mingw/mingwex/getopt.c trunk/cegcc/src/mingw/mingwex/gettimeofday.c trunk/cegcc/src/mingw/mingwex/wcstold.c trunk/cegcc/src/mingw/mingwex/wdirent.c Modified: trunk/cegcc/src/mingw/ChangeLog.mingw32ce =================================================================== --- trunk/cegcc/src/mingw/ChangeLog.mingw32ce 2007-06-24 19:42:31 UTC (rev 992) +++ trunk/cegcc/src/mingw/ChangeLog.mingw32ce 2007-06-24 21:30:34 UTC (rev 993) @@ -1,5 +1,28 @@ 2007-06-24 Pedro Alves <ped...@po...> + * mingwex/dirname.c (dirname) [__COREDLL__]: Don't handle drive names. + * mingwex/basename.c (basename) [__COREDLL__]: Likewise. + * mingwex/wdirent.c (UNICODE_DIRENT): New define. + * mingwex/dirent.c [__COREDLL__]: Don't include errno.h or direct.h. + (__set_errno): New. + (ENOTDIR, EFAULT, EINVAL): Define. + (_TDIR, _TCHAR, _T, _topendir, _treaddir, _tclosedir, _trewinddir, + _ttelldir, tseekdir, _tfindfirst, _tfindnext, _tcscat, _tcsncpy, + _tcslen, _tcscpy, _tcsrchr, _tdirent) [!UNICODE_DIRENT]: Redefine to + the non-wide counterparts. + (_tGetFileAttributes) [__COREDLL__]: Reimplement for Windows CE. + (_topendir): Use __set_errno. Avoid _tfullpath. + (_treaddir, _closedir, _trewinddir, _ttelldir, _tseekdir): Use + __set_errno. + * mingwex/wcstold.c: Don't compile on WinCE. + * mingwex/getopt.c [__COREDLL__]: Don't include errno.h. + (IS_POSIXLY_CORRECT) [__MINGW32CE__]: Hardcode to 0. + * mingwex/gettimeofday.c (gettimeofday) [__COREDLL__]: Replace + the GetSystemTimeAsFileTime call with GetSystemTime and + SystemTimeToFileTime. + +2007-06-24 Pedro Alves <ped...@po...> + * mingwex/wince/findfile.c: New file. * mingwex/wince/chsize.c: New file. * mingwex/wince/access.c: New file. Modified: trunk/cegcc/src/mingw/mingwex/basename.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/basename.c 2007-06-24 19:42:31 UTC (rev 992) +++ trunk/cegcc/src/mingw/mingwex/basename.c 2007-06-24 21:30:34 UTC (rev 993) @@ -37,9 +37,10 @@ /* step over the drive designator, if present ... * (FIXME: maybe should confirm *path is a valid drive designator). */ - +#ifndef __COREDLL__ if( path[1] == ':' ) path += 2; +#endif /* check again, just to ensure we still have a non-empty path name ... */ Modified: trunk/cegcc/src/mingw/mingwex/dirent.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/dirent.c 2007-06-24 19:42:31 UTC (rev 992) +++ trunk/cegcc/src/mingw/mingwex/dirent.c 2007-06-24 21:30:34 UTC (rev 993) @@ -4,35 +4,106 @@ * This file is a part of the mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER within the package. * - * Derived from DIRLIB.C by Matt J. Weinstein + * Derived from DIRLIB.C by Matt J. Weinstein * This note appears in the DIRLIB.H * DIRLIB.H by M. J. Weinstein Released to public domain 1-Jan-89 * * Updated by Jeremy Bettis <je...@hk...> * Significantly revised and rewinddir, seekdir and telldir added by Colin * Peters <co...@fu...> - * + * */ #include <stdlib.h> +#ifndef __COREDLL__ #include <errno.h> +#endif #include <string.h> #include <io.h> +#ifndef __COREDLL__ #include <direct.h> +#endif #include <dirent.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> /* for GetFileAttributes */ #include <tchar.h> + #define SUFFIX _T("*") #define SLASH _T("\\") +#ifdef __COREDLL__ +/* Pretty safe in this file, since we are only setting errno, and never + reading it. */ +#define __set_errno(ERR) SetLastError (ERR) + +#define ENOTDIR ERROR_DIRECTORY +#define EFAULT ERROR_INVALID_ADDRESS +#define EINVAL ERROR_INVALID_PARAMETER + +#ifndef UNICODE_DIRENT + +/* Windows CE is always UNICODE - work around it. */ +#undef _TDIR +#undef _TCHAR + +#undef _T + +#undef _topendir +#undef _treaddir +#undef _tclosedir +#undef _trewinddir +#undef _ttelldir +#undef _tseekdir + +#undef _tfindfirst +#undef _tfindnext + +#undef _tcscat +#undef _tcsncpy +#undef _tcslen +#undef _tcscpy +#undef _tcsrchr + +#undef _tdirent + +#define _TDIR DIR +#define _TCHAR CHAR + +#define _T(S) S + +#define _topendir opendir +#define _treaddir readdir +#define _tclosedir closedir +#define _trewinddir rewinddir +#define _ttelldir telldir +#define _tseekdir seekdir + +#define _tfindfirst _findfirst +#define _tfindnext _findnext + +#define _tcscat strcat +#define _tcsncpy strncpy +#define _tcslen strlen +#define _tcscpy strcpy +#define _tcsrchr strrchr + +#define _tdirent dirent + +#endif + +#else +#define __set_errno(ERR) do { errno = (ERR); } while (0) +#endif + +#if !defined (__COREDLL__) + /* Helper for opendir(). */ static inline unsigned _tGetFileAttributes (const _TCHAR * tPath) { -#ifdef _UNICODE +#ifdef (_UNICODE) /* GetFileAttributesW does not work on W9x, so convert to ANSI */ if (_osver & 0x8000) { @@ -42,35 +113,51 @@ return GetFileAttributesA (aPath); } return GetFileAttributesW (tPath); -#else +#else /* _UNICODE */ return GetFileAttributesA (tPath); #endif } +#else /* __COREDLL__ */ + +/* Helper for opendir(). */ +static inline unsigned _tGetFileAttributes (const _TCHAR * tPath) +{ +#ifdef UNICODE_DIRENT + return GetFileAttributesW (tPath); +#else + WCHAR wpath[MAX_PATH]; + mbstowcs (wpath, tPath, MAX_PATH); + return GetFileAttributesW (wpath); +#endif +} + +#endif + /* * opendir * * Returns a pointer to a DIR structure appropriately filled in to begin * searching a directory. */ -_TDIR * +_TDIR * _topendir (const _TCHAR *szPath) { _TDIR *nd; unsigned int rc; _TCHAR szFullPath[MAX_PATH]; - - errno = 0; + __set_errno (0); + if (!szPath) { - errno = EFAULT; + __set_errno (EFAULT); return (_TDIR *) 0; } if (szPath[0] == _T('\0')) { - errno = ENOTDIR; + __set_errno (ENOTDIR); return (_TDIR *) 0; } @@ -79,18 +166,31 @@ if (rc == (unsigned int)-1) { /* call GetLastError for more error info */ +#ifdef __COREDLL__ + /* GetFileAttributes already sets LastError. */ +#else errno = ENOENT; +#endif return (_TDIR *) 0; } if (!(rc & FILE_ATTRIBUTE_DIRECTORY)) { /* Error, entry exists but not a directory. */ +#ifdef __COREDLL__ + /* GetFileAttributes already sets LastError. */ +#else errno = ENOTDIR; +#endif return (_TDIR *) 0; } +#ifdef __COREDLL__ + /* On Windows CE paths must always be absolute. */ + _tcsncpy (szFullPath, szPath, MAX_PATH); +#else /* Make an absolute pathname. */ _tfullpath (szFullPath, szPath, MAX_PATH); +#endif /* Allocate enough space to store DIR structure and the complete * directory path given. */ @@ -102,7 +202,9 @@ if (!nd) { /* Error, out of memory. */ +#ifndef __COREDLL__ errno = ENOMEM; +#endif return (_TDIR *) 0; } @@ -150,12 +252,12 @@ struct _tdirent * _treaddir (_TDIR * dirp) { - errno = 0; + __set_errno (0); /* Check for valid DIR struct. */ if (!dirp) { - errno = EFAULT; + __set_errno (EFAULT); return (struct _tdirent *) 0; } @@ -187,12 +289,12 @@ /* Get the next search entry. */ if (_tfindnext (dirp->dd_handle, &(dirp->dd_dta))) { - /* We are off the end or otherwise error. + /* We are off the end or otherwise error. _findnext sets errno to ENOENT if no more file - Undo this. */ + Undo this. */ DWORD winerr = GetLastError (); if (winerr == ERROR_NO_MORE_FILES) - errno = 0; + __set_errno (0); _findclose (dirp->dd_handle); dirp->dd_handle = -1; dirp->dd_stat = -1; @@ -229,12 +331,12 @@ { int rc; - errno = 0; + __set_errno (0); rc = 0; if (!dirp) { - errno = EFAULT; + __set_errno (EFAULT); return -1; } @@ -258,11 +360,11 @@ void _trewinddir (_TDIR * dirp) { - errno = 0; + __set_errno (0); if (!dirp) { - errno = EFAULT; + __set_errno (EFAULT); return; } @@ -284,11 +386,11 @@ long _ttelldir (_TDIR * dirp) { - errno = 0; + __set_errno (0); if (!dirp) { - errno = EFAULT; + __set_errno (EFAULT); return -1; } return dirp->dd_stat; @@ -306,18 +408,18 @@ void _tseekdir (_TDIR * dirp, long lPos) { - errno = 0; + __set_errno (0); if (!dirp) { - errno = EFAULT; + __set_errno (EFAULT); return; } if (lPos < -1) { /* Seeking to an invalid position. */ - errno = EINVAL; + __set_errno (EINVAL); return; } else if (lPos == -1) Modified: trunk/cegcc/src/mingw/mingwex/dirname.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/dirname.c 2007-06-24 19:42:31 UTC (rev 992) +++ trunk/cegcc/src/mingw/mingwex/dirname.c 2007-06-24 21:30:34 UTC (rev 993) @@ -49,7 +49,7 @@ if( (path[1] == *retname) && (path[2] == '\0') ) return retname; } - +#ifndef __COREDLL__ /* For all other cases ... * step over the drive designator, if present, copying it to retfail ... * (FIXME: maybe should confirm *path is a valid drive designator). @@ -60,6 +60,7 @@ *copyptr++ = *path++; *copyptr++ = *path++; } +#endif if( *path ) { Modified: trunk/cegcc/src/mingw/mingwex/getopt.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/getopt.c 2007-06-24 19:42:31 UTC (rev 992) +++ trunk/cegcc/src/mingw/mingwex/getopt.c 2007-06-24 21:30:34 UTC (rev 993) @@ -37,7 +37,9 @@ */ #include <assert.h> +#ifndef __COREDLL__ #include <errno.h> +#endif #include <stdlib.h> #include <string.h> #include <getopt.h> @@ -69,6 +71,10 @@ extern char __declspec(dllimport) *__progname; #endif +#ifdef __MINGW32CE__ +#define IS_POSIXLY_CORRECT 0 +#endif + #define IGNORE_FIRST (*options == '-' || *options == '+') #define PRINT_ERROR ((opterr) && ((*options != ':') \ || (IGNORE_FIRST && options[1] != ':'))) Modified: trunk/cegcc/src/mingw/mingwex/gettimeofday.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/gettimeofday.c 2007-06-24 19:42:31 UTC (rev 992) +++ trunk/cegcc/src/mingw/mingwex/gettimeofday.c 2007-06-24 21:30:34 UTC (rev 993) @@ -38,7 +38,13 @@ if(tp) { +#ifndef __COREDLL__ GetSystemTimeAsFileTime (&_now.ft); +#else + SYSTEMTIME st; + GetSystemTime (&st); + SystemTimeToFileTime (&st, &_now.ft); +#endif tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL ); tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); } Modified: trunk/cegcc/src/mingw/mingwex/wcstold.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/wcstold.c 2007-06-24 19:42:31 UTC (rev 992) +++ trunk/cegcc/src/mingw/mingwex/wcstold.c 2007-06-24 21:30:34 UTC (rev 993) @@ -8,11 +8,13 @@ /* This routine has been placed in the public domain.*/ +#ifdef __COREDLL__ +/* coredll.dll doesn't export strtold. */ +#else + #define WIN32_LEAN_AND_MEAN #include <windows.h> -#ifndef __COREDLL__ #include <locale.h> -#endif #include <wchar.h> #include <stdlib.h> #include <string.h> @@ -51,15 +53,15 @@ char * cse; unsigned int i; long double ret; - const unsigned int cp = get_codepage (); - + const unsigned int cp = get_codepage (); + /* Allocate enough room for (possibly) mb chars */ cs = (char *) malloc ((wcslen(wcs)+1) * MB_CUR_MAX); if (cp == 0) /* C locale */ { for (i = 0; (wcs[i] != 0) && wcs[i] <= 255; i++) - cs[i] = (char) wcs[i]; + cs[i] = (char) wcs[i]; cs[i] = '\0'; } else @@ -90,3 +92,5 @@ return ret; } + +#endif /* __COREDLL__ */ Modified: trunk/cegcc/src/mingw/mingwex/wdirent.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/wdirent.c 2007-06-24 19:42:31 UTC (rev 992) +++ trunk/cegcc/src/mingw/mingwex/wdirent.c 2007-06-24 21:30:34 UTC (rev 993) @@ -1,5 +1,7 @@ #define _UNICODE 1 #define UNICODE 1 +#define UNICODE_DIRENT 1 + #include <wchar.h> #include "dirent.c" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |