From: Chris S. <ir0...@us...> - 2005-08-12 22:04:31
|
Update of /cvsroot/mingw/runtime/mingwex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17105/mingwex Modified Files: Makefile.in dirent.c mingw-fseek.c strtold.c Added Files: btowc.c mb_wc_common.h mbrtowc.c wcrtomb.c wctob.c wctrans.c wctype.c Removed Files: fopen64.c fseeko64.c ftello64.c lseek64.c Log Message: Merge Cygwin changes --- fopen64.c DELETED --- Index: dirent.c =================================================================== RCS file: /cvsroot/mingw/runtime/mingwex/dirent.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dirent.c 20 Apr 2004 23:26:34 -0000 1.5 --- dirent.c 12 Aug 2005 22:04:23 -0000 1.6 *************** *** 76,81 **** /* Allocate enough space to store DIR structure and the complete * directory path given. */ ! nd = (_TDIR *) malloc (sizeof (_TDIR) + (_tcslen(szFullPath) + _tcslen (SLASH) + ! _tcslen(SUFFIX) + 1) * sizeof(_TCHAR)); if (!nd) --- 76,83 ---- /* Allocate enough space to store DIR structure and the complete * directory path given. */ ! nd = (_TDIR *) malloc (sizeof (_TDIR) + (_tcslen (szFullPath) ! + _tcslen (SLASH) ! + _tcslen (SUFFIX) + 1) ! * sizeof (_TCHAR)); if (!nd) *************** *** 90,96 **** /* Add on a slash if the path does not end with one. */ ! if (nd->dd_name[0] != _T('\0') && ! nd->dd_name[_tcslen (nd->dd_name) - 1] != _T('/') && ! nd->dd_name[_tcslen (nd->dd_name) - 1] != _T('\\')) { _tcscat (nd->dd_name, SLASH); --- 92,100 ---- /* Add on a slash if the path does not end with one. */ ! if (nd->dd_name[0] != _T('\0') ! && _tcsrchr (nd->dd_name, _T('/')) != nd->dd_name ! + _tcslen (nd->dd_name) - 1 ! && _tcsrchr (nd->dd_name, _T('\\')) != nd->dd_name ! + _tcslen (nd->dd_name) - 1) { _tcscat (nd->dd_name, SLASH); *************** *** 149,153 **** dirp->dd_handle = _tfindfirst (dirp->dd_name, &(dirp->dd_dta)); ! if (dirp->dd_handle == -1) { /* Whoops! Seems there are no files in that --- 153,157 ---- dirp->dd_handle = _tfindfirst (dirp->dd_name, &(dirp->dd_dta)); ! if (dirp->dd_handle == -1) { /* Whoops! Seems there are no files in that *************** *** 168,172 **** _findnext sets errno to ENOENT if no more file Undo this. */ ! DWORD winerr = GetLastError(); if (winerr == ERROR_NO_MORE_FILES) errno = 0; --- 172,176 ---- _findnext sets errno to ENOENT if no more file Undo this. */ ! DWORD winerr = GetLastError (); if (winerr == ERROR_NO_MORE_FILES) errno = 0; --- NEW FILE: mb_wc_common.h --- #include <locale.h> #include <string.h> #include <stdlib.h> static inline unsigned int get_cp_from_locale (void) { char* cp_string; /* locale :: "lang[_country[.code_page]]" | ".code_page" */ if ((cp_string = strchr(setlocale(LC_CTYPE, NULL), '.'))) return ((unsigned) atoi (cp_string + 1)); return 0; } Index: Makefile.in =================================================================== RCS file: /cvsroot/mingw/runtime/mingwex/Makefile.in,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Makefile.in 13 Jan 2005 19:52:19 -0000 1.15 --- Makefile.in 12 Aug 2005 22:04:23 -0000 1.16 *************** *** 34,40 **** mingw-fseek.c sitest.c strtof.c strtoimax.c strtold.c strtoumax.c \ testwmem.c tst-aligned-malloc.c ulltoa.c ulltow.c wcstof.c \ ! wcstoimax.c wcstold.c wcstoumax.c wdirent.c wmemchr.c wmemcmp.c \ ! wmemcpy.c wmemmove.c wmemset.c wtoll.c ! MATH_DISTFILES = \ acosf.c acosl.c asinf.c asinl.c atan2f.c atan2l.c \ --- 34,40 ---- mingw-fseek.c sitest.c strtof.c strtoimax.c strtold.c strtoumax.c \ testwmem.c tst-aligned-malloc.c ulltoa.c ulltow.c wcstof.c \ ! wcstoimax.c wcstold.c wcstoumax.c wctrans.c wctype.c \ ! wdirent.c wmemchr.c wmemcmp.c wmemcpy.c wmemmove.c wmemset.c wtoll.c \ ! wcrtomb.c wctob.c mbrtowc.c btowc.c mb_wc_common.h MATH_DISTFILES = \ acosf.c acosl.c asinf.c asinl.c atan2f.c atan2l.c \ *************** *** 42,46 **** cephes_emath.h cephes_emath.c cephes_mconf.h \ copysign.S copysignf.S copysignl.S cosf.S coshf.c coshl.c cosl.S \ ! exp2.S exp2f.S exp2l.S expf.c expl.c fabs.c fabsf.c fabsl.c \ fdim.c fdimf.c fdiml.c floorf.S floorl.S fma.S fmaf.S fmal.c \ fmax.c fmaxf.c fmaxl.c fmin.c fminf.c fminl.c fmodf.c \ --- 42,47 ---- cephes_emath.h cephes_emath.c cephes_mconf.h \ copysign.S copysignf.S copysignl.S cosf.S coshf.c coshl.c cosl.S \ ! erfl.c exp2.S exp2f.S exp2l.S expf.c expl.c expm1.c expm1l.c expm1f.c \ ! fabs.c fabsf.c fabsl.c \ fdim.c fdimf.c fdiml.c floorf.S floorl.S fma.S fmaf.S fmal.c \ fmax.c fmaxf.c fmaxl.c fmin.c fminf.c fminl.c fmodf.c \ *************** *** 54,58 **** log2l.S logb.c logbf.c logbl.c logf.S logl.S lrint.c lrintf.c \ lrintl.c lround.c lroundf.c lroundl.c modff.c modfl.c \ ! nearbyint.S nearbyintf.S nearbyintl.S nextafterf.c \ powf.c powi.c powif.c powil.c powl.c \ remainder.S remainderf.S remainderl.S remquo.S \ --- 55,60 ---- log2l.S logb.c logbf.c logbl.c logf.S logl.S lrint.c lrintf.c \ lrintl.c lround.c lroundf.c lroundl.c modff.c modfl.c \ ! nearbyint.S nearbyintf.S nearbyintl.S \ ! nextafterf.c nextafterl.c nexttowardf.c nexttoward.c \ powf.c powi.c powif.c powil.c powl.c \ remainder.S remainderf.S remainderl.S remquo.S \ *************** *** 114,118 **** fwide.o imaxabs.o imaxdiv.o mbsinit.o \ strtoimax.o strtoumax.o wcstoimax.o wcstoumax.o \ ! wmemchr.o wmemcmp.o wmemcpy.o wmemmove.o wmemset.o STDLIB_OBJS = \ strtold.o wcstold.o --- 116,121 ---- fwide.o imaxabs.o imaxdiv.o mbsinit.o \ strtoimax.o strtoumax.o wcstoimax.o wcstoumax.o \ ! wmemchr.o wmemcmp.o wmemcpy.o wmemmove.o wmemset.o \ ! wctrans.o wctype.o wcrtomb.o wctob.o mbrtowc.o btowc.o STDLIB_OBJS = \ strtold.o wcstold.o *************** *** 132,136 **** cephes_emath.o \ copysign.o copysignf.o copysignl.o cosf.o coshf.o coshl.o cosl.o \ ! exp2.o exp2f.o exp2l.o expf.o expl.o fabs.o fabsf.o fabsl.o \ fdim.o fdimf.o fdiml.o floorf.o floorl.o fma.o fmaf.o fmal.o \ fmax.o fmaxf.o fmaxl.o fmin.o fminf.o fminl.o fmodf.o \ --- 135,140 ---- cephes_emath.o \ copysign.o copysignf.o copysignl.o cosf.o coshf.o coshl.o cosl.o \ ! erfl.o exp2.o exp2f.o exp2l.o expf.o expl.o expm1.o expm1l.o expm1f.o \ ! fabs.o fabsf.o fabsl.o \ fdim.o fdimf.o fdiml.o floorf.o floorl.o fma.o fmaf.o fmal.o \ fmax.o fmaxf.o fmaxl.o fmin.o fminf.o fminl.o fmodf.o \ *************** *** 144,148 **** log2l.o logb.o logbf.o logbl.o logf.o logl.o lrint.o lrintf.o \ lrintl.o lround.o lroundf.o lroundl.o modff.o modfl.o \ ! nearbyint.o nearbyintf.o nearbyintl.o nextafterf.o \ powf.o powi.o powif.o powil.o powl.o \ remainder.o remainderf.o remainderl.o remquo.o \ --- 148,153 ---- log2l.o logb.o logbf.o logbl.o logf.o logl.o lrint.o lrintf.o \ lrintl.o lround.o lroundf.o lroundl.o modff.o modfl.o \ ! nearbyint.o nearbyintf.o nearbyintl.o \ ! nextafterf.o nextafterl.o nexttowardf.o nexttoward.o \ powf.o powi.o powif.o powil.o powl.o \ remainder.o remainderf.o remainderl.o remquo.o \ *************** *** 231,235 **** asinh.o asinhf.o asinhl.o \ atanh.o atanhf.o atanhl.o: fastmath.h ! dist: --- 236,240 ---- asinh.o asinhf.o asinhl.o \ atanh.o atanhf.o atanhl.o: fastmath.h ! mbrtowc.o wcrtomb.o: mb_wc_common.h dist: --- lseek64.c DELETED --- --- NEW FILE: wctob.c --- #include "mb_wc_common.h" #include <wchar.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> /* Return just the first byte after translating to multibyte. */ int wctob (wint_t wc ) { wchar_t w = wc; char c; int invalid_char = 0; if (!WideCharToMultiByte (get_cp_from_locale(), 0 /* Is this correct flag? */, &w, 1, &c, 1, NULL, &invalid_char) || invalid_char) return EOF; return (int) c; } --- ftello64.c DELETED --- Index: strtold.c =================================================================== RCS file: /cvsroot/mingw/runtime/mingwex/strtold.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** strtold.c 19 Apr 2004 17:22:41 -0000 1.2 --- strtold.c 12 Aug 2005 22:04:23 -0000 1.3 *************** *** 256,259 **** --- 256,261 ---- esign = 1; exp = 0; + /* Save position in case we need to fall back. */ + sp = s; ++s; /* check for + or - */ *************** *** 266,269 **** --- 268,278 ---- ++s; + /* Check for valid exponent. */ + if (!(*s >= '0' && *s <= '9')) + { + s = sp; + goto daldone; + } + while( (*s >= '0') && (*s <= '9') ) { --- NEW FILE: wctype.c --- /* wctype.c 7.25.2.2.2 The wctype function Contributed by: Danny Smith <dan...@us...> 2005-02-24 This source code is placed in the PUBLIC DOMAIN. It is modified from the Q8 package created by Doug Gwyn <gw...@ar...> The wctype function constructs a value with type wctype_t that describes a class of wide characters identified by the string argument property. In particular, we map the property strings so that: iswctype(wc, wctype("alnum")) == iswalnum(wc) iswctype(wc, wctype("alpha")) == iswalpha(wc) iswctype(wc, wctype("cntrl")) == iswcntrl(wc) iswctype(wc, wctype("digit")) == iswdigit(wc) iswctype(wc, wctype("graph")) == iswgraph(wc) iswctype(wc, wctype("lower")) == iswlower(wc) iswctype(wc, wctype("print")) == iswprint(wc) iswctype(wc, wctype("punct")) == iswpunct(wc) iswctype(wc, wctype("space")) == iswspace(wc) iswctype(wc, wctype("upper")) == iswupper(wc) iswctype(wc, wctype("xdigit")) == iswxdigit(wc) */ #include <string.h> #include <wctype.h> /* Using the bit-OR'd ctype character classification flags as return values achieves compatibility with MS iswctype(). */ static const struct { const char *name; wctype_t flags;} cmap[] = { {"alnum", _ALPHA|_DIGIT}, {"alpha", _ALPHA}, {"cntrl", _CONTROL}, {"digit", _DIGIT}, {"graph", _PUNCT|_ALPHA|_DIGIT}, {"lower", _LOWER}, {"print", _BLANK|_PUNCT|_ALPHA|_DIGIT}, {"punct", _PUNCT}, {"space", _SPACE}, {"upper", _UPPER}, {"xdigit", _HEX} }; #define NCMAP (sizeof cmap / sizeof cmap[0]) wctype_t wctype (const char *property) { int i; for (i = 0; i < NCMAP; ++i) if (strcmp (property, cmap[i].name) == 0) return cmap[i].flags; return 0; } --- fseeko64.c DELETED --- --- NEW FILE: mbrtowc.c --- #include "mb_wc_common.h" #include <wchar.h> #include <stdlib.h> #include <errno.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> static int __MINGW_ATTRIB_NONNULL(1) __MINGW_ATTRIB_NONNULL(4) __mbrtowc_cp (wchar_t * __restrict__ pwc, const char * __restrict__ s, size_t n, mbstate_t* __restrict__ ps, const unsigned int cp, const unsigned int mb_max) { union { mbstate_t val; char mbcs[4]; } shift_state; /* Do the prelim checks */ if (s == NULL) return 0; if (n == 0) /* The standard doesn't mention this case explicitly. Tell caller that the conversion from a non-null s is incomplete. */ return -2; /* Save the current shift state, in case we need it in DBCS case. */ shift_state.val = *ps; *ps = 0; if (!*s) { *pwc = 0; return 0; } if (mb_max > 1) { if (shift_state.mbcs[0] != 0) { /* Complete the mb char with the trailing byte. */ shift_state.mbcs[1] = *s; /* the second byte */ if (MultiByteToWideChar(cp, MB_ERR_INVALID_CHARS, shift_state.mbcs, 2, pwc, 1) == 0) { /* An invalid trailing byte */ errno = EILSEQ; return -1; } return 2; } else if (IsDBCSLeadByteEx (cp, *s)) { /* If told to translate one byte, just save the leadbyte in *ps. */ if (n < 2) { ((char*) ps)[0] = *s; return -2; } /* Else translate the first two bytes */ else if (MultiByteToWideChar (cp, MB_ERR_INVALID_CHARS, s, 2, pwc, 1) == 0) { errno = EILSEQ; return -1; } return 2; } } /* Fall through to single byte char */ if (cp == 0) *pwc = (wchar_t)(unsigned char)*s; else if (MultiByteToWideChar (cp, MB_ERR_INVALID_CHARS, s, 1, pwc, 1) == 0) { errno = EILSEQ; return -1; } return 1; } size_t mbrtowc (wchar_t * __restrict__ pwc, const char * __restrict__ s, size_t n, mbstate_t* __restrict__ ps) { static mbstate_t internal_mbstate = 0; wchar_t byte_bucket = 0; wchar_t* dst = pwc ? pwc : &byte_bucket; return (size_t) __mbrtowc_cp (dst, s, n, ps ? ps : &internal_mbstate, get_cp_from_locale(), MB_CUR_MAX); } size_t mbsrtowcs (wchar_t* __restrict__ dst, const char ** __restrict__ src, size_t len, mbstate_t* __restrict__ ps) { int ret =0 ; size_t n = 0; static mbstate_t internal_mbstate = 0; mbstate_t* internal_ps = ps ? ps : &internal_mbstate; const unsigned int cp = get_cp_from_locale();; const unsigned int mb_max = MB_CUR_MAX; if ( src == NULL || *src == NULL ) /* undefined behavior */ return 0; if (dst != NULL) { while (n < len && (ret = __mbrtowc_cp(dst, *src, len - n, internal_ps, cp, mb_max)) > 0) { ++dst; *src += ret; n += ret; } if (n < len && ret == 0) *src = (char *)NULL; } else { wchar_t byte_bucket = 0; while (n < len && (ret = __mbrtowc_cp (&byte_bucket, *src, mb_max, internal_ps, cp, mb_max)) > 0) { *src += ret; n += ret; } } return n; } size_t mbrlen (const char * __restrict__ s, size_t n, mbstate_t * __restrict__ ps) { static mbstate_t s_mbstate = 0; wchar_t byte_bucket = 0; return __mbrtowc_cp (&byte_bucket, s, n, (ps) ? ps : &s_mbstate, get_cp_from_locale(), MB_CUR_MAX); } --- NEW FILE: wcrtomb.c --- #include "mb_wc_common.h" #include <wchar.h> #include <stdlib.h> #include <errno.h> #include <limits.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> static int __MINGW_ATTRIB_NONNULL(1) __wcrtomb_cp (char *dst, wchar_t wc, const unsigned int cp, const unsigned int mb_max) { if (wc > 255) { errno = EILSEQ; return -1; } if (cp == 0) { *dst = (char) wc; return 1; } else { int invalid_char = 0; int size = WideCharToMultiByte(get_cp_from_locale(), 0 /* Is this correct flag? */, &wc, 1, dst, mb_max, NULL, &invalid_char); if (size == 0 || invalid_char) { errno = EILSEQ; return -1; } return size; } } size_t wcrtomb (char *dst, wchar_t wc, mbstate_t * __UNUSED_PARAM (ps)) { char byte_bucket [MB_LEN_MAX]; char* tmp_dst = dst ? dst : byte_bucket; return (size_t)__wcrtomb_cp (tmp_dst, wc, get_cp_from_locale (), MB_CUR_MAX); } size_t wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t * __UNUSED_PARAM (ps)) { int ret = 0; size_t n = 0; const unsigned int cp = get_cp_from_locale(); const unsigned int mb_max = MB_CUR_MAX; if (src == NULL || *src == NULL) /* undefined behavior */ return 0; if (dst != NULL) { const wchar_t ** saved_src = src; while (n < len) { if ((ret = __wcrtomb_cp (dst, **src, cp, mb_max)) <= 0) return (size_t) -1; n += ret; dst += ret; if (*(dst - 1) == '\0') { *saved_src = (wchar_t) NULL;; return (n - 1); } *src++; } } else { char byte_bucket [MB_LEN_MAX]; while (n < len) { if ((ret = __wcrtomb_cp (byte_bucket, **src, cp, mb_max)) <= 0) return (size_t) -1; n += ret; if (byte_bucket [ret - 1] == '\0') return (n - 1); *src++; } } return n; } Index: mingw-fseek.c =================================================================== RCS file: /cvsroot/mingw/runtime/mingwex/mingw-fseek.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mingw-fseek.c 13 Jul 2004 10:57:39 -0000 1.3 --- mingw-fseek.c 12 Aug 2005 22:04:23 -0000 1.4 *************** *** 38,42 **** } ! int __mingw_fwrite (const void *buffer, size_t size, size_t count, FILE *fp) { --- 38,42 ---- } ! size_t __mingw_fwrite (const void *buffer, size_t size, size_t count, FILE *fp) { --- NEW FILE: wctrans.c --- /* wctrans.c 7.25.3.2 Extensible wide-character case mapping functions Contributed by: Danny Smith <dan...@us...> 2005-02-24 This source code is placed in the PUBLIC DOMAIN. It is modified from the Q8 package created by Doug Gwyn <gw...@ar...> */ #include <string.h> #include <wctype.h> /* This differs from the MS implementation of wctrans which returns 0 for tolower and 1 for toupper. According to C99, a 0 return value indicates invalid input. These two function go in the same translation unit so that we can ensure that towctrans(wc, wctrans("tolower")) == towlower(wc) towctrans(wc, wctrans("toupper")) == towupper(wc) It also ensures that towctrans(wc, wctrans("")) == wc which is not required by standard. */ static const struct { const char *name; wctrans_t val; } tmap[] = { {"tolower", _LOWER}, {"toupper", _UPPER} }; #define NTMAP (sizeof tmap / sizeof tmap[0]) wctrans_t wctrans (const char* property) { int i; for ( i = 0; i < NTMAP; ++i ) if (strcmp (property, tmap[i].name) == 0) return tmap[i].val; return 0; } wint_t towctrans (wint_t wc, wctrans_t desc) { switch (desc) { case _LOWER: return towlower (wc); case _UPPER: return towupper (wc); default: return wc; } } --- NEW FILE: btowc.c --- #include "mb_wc_common.h" #include <wchar.h> #include <stdio.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> wint_t btowc (int c) { if (c == EOF) return (WEOF); else { unsigned char ch = c; wchar_t wc = WEOF; MultiByteToWideChar (get_cp_from_locale(), MB_ERR_INVALID_CHARS, (char*)&ch, 1, &wc, 1); return wc; } } |