ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
December 2008
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
31 participants
710 discussions
Start a n
N
ew thread
[dchapyshev] 38374: - Fix 11 tests for OpenFile
by dchapyshev@svn.reactos.org
Author: dchapyshev Date: Sat Dec 27 04:31:53 2008 New Revision: 38374 URL:
http://svn.reactos.org/svn/reactos?rev=38374&view=rev
Log: - Fix 11 tests for OpenFile Modified: trunk/reactos/dll/win32/kernel32/file/file.c Modified: trunk/reactos/dll/win32/kernel32/file/file.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/fi…
============================================================================== --- trunk/reactos/dll/win32/kernel32/file/file.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/file/file.c [iso-8859-1] Sat Dec 27 04:31:53 2008 @@ -236,8 +236,34 @@ if (lpReOpenBuff == NULL) { - return FALSE; + return HFILE_ERROR; } + + lpReOpenBuff->cBytes = sizeof(OFSTRUCT); + lpReOpenBuff->nErrCode = 0; + + if (uStyle & OF_REOPEN) lpFileName = lpReOpenBuff->szPathName; + + if (!lpFileName) + { + return HFILE_ERROR; + } + + if (!GetFullPathNameA(lpFileName, + sizeof(lpReOpenBuff->szPathName), + lpReOpenBuff->szPathName, + NULL)) + { + lpReOpenBuff->nErrCode = GetLastError(); + return HFILE_ERROR; + } + + if (uStyle & OF_PARSE) + { + lpReOpenBuff->fFixedDisk = (GetDriveTypeA(lpReOpenBuff->szPathName) != DRIVE_REMOVABLE); + TRACE("(%s): OF_PARSE, res = '%s'\n", lpFileName, lpReOpenBuff->szPathName); + return 0; + } if ((uStyle & OF_CREATE) == OF_CREATE) { @@ -280,8 +306,20 @@ if (Len == 0 || Len > OFS_MAXPATHNAME) { + lpReOpenBuff->nErrCode = GetLastError(); return (HFILE)INVALID_HANDLE_VALUE; } + + if (uStyle & OF_DELETE) + { + if (!DeleteFileW(PathNameW)) + { + lpReOpenBuff->nErrCode = GetLastError(); + return HFILE_ERROR; + } + TRACE("(%s): OF_DELETE return = OK\n", lpFileName); + return TRUE; + } FileName.Buffer = lpReOpenBuff->szPathName; FileName.Length = 0; @@ -306,14 +344,6 @@ // FILE_SHARE_READ // FILE_NO_INTERMEDIATE_BUFFERING - if ((uStyle & OF_PARSE) == OF_PARSE) - { - RtlFreeHeap(RtlGetProcessHeap(), - 0, - FileNameString.Buffer); - return (HFILE)NULL; - } - ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); ObjectAttributes.RootDirectory = NULL; ObjectAttributes.ObjectName = &FileNameString; @@ -328,16 +358,20 @@ FILE_SHARE_READ, FILE_NON_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT); - RtlFreeHeap(RtlGetProcessHeap(), - 0, - FileNameString.Buffer); - - lpReOpenBuff->nErrCode = (WORD)RtlNtStatusToDosError(errCode); + RtlFreeHeap(RtlGetProcessHeap(), 0, FileNameString.Buffer); + + lpReOpenBuff->nErrCode = RtlNtStatusToDosError(errCode); if (!NT_SUCCESS(errCode)) { SetLastErrorByStatus (errCode); return (HFILE)INVALID_HANDLE_VALUE; + } + + if (uStyle & OF_EXIST) + { + NtClose(FileHandle); + return TRUE; } return (HFILE)FileHandle;
15 years, 12 months
1
0
0
0
[cwittich] 38373: sync rsaenh to wine 1.1.11
by cwittich@svn.reactos.org
Author: cwittich Date: Sat Dec 27 04:11:34 2008 New Revision: 38373 URL:
http://svn.reactos.org/svn/reactos?rev=38373&view=rev
Log: sync rsaenh to wine 1.1.11 Modified: trunk/reactos/dll/win32/rsaenh/md2.c trunk/reactos/dll/win32/rsaenh/mpi.c trunk/reactos/dll/win32/rsaenh/rc2.c trunk/reactos/dll/win32/rsaenh/rsaenh.c trunk/reactos/dll/win32/rsaenh/tomcrypt.h Modified: trunk/reactos/dll/win32/rsaenh/md2.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/rsaenh/md2.c?rev…
============================================================================== --- trunk/reactos/dll/win32/rsaenh/md2.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/rsaenh/md2.c [iso-8859-1] Sat Dec 27 04:11:34 2008 @@ -77,7 +77,7 @@ md2->X[32+j] = md2->X[j] ^ md2->X[16+j]; } - t = (unsigned char)0; + t = 0; /* do 18 rounds */ for (j = 0; j < 18; j++) { Modified: trunk/reactos/dll/win32/rsaenh/mpi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/rsaenh/mpi.c?rev…
============================================================================== --- trunk/reactos/dll/win32/rsaenh/mpi.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/rsaenh/mpi.c [iso-8859-1] Sat Dec 27 04:11:34 2008 @@ -39,13 +39,26 @@ static const int KARATSUBA_MUL_CUTOFF = 88, /* Min. number of digits before Karatsuba multiplication is used. */ KARATSUBA_SQR_CUTOFF = 128; /* Min. number of digits before Karatsuba squaring is used. */ +static void bn_reverse(unsigned char *s, int len); +static int s_mp_add(mp_int *a, mp_int *b, mp_int *c); +static int s_mp_exptmod (const mp_int * G, const mp_int * X, mp_int * P, mp_int * Y); +#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1) +static int s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs); +static int s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs); +static int s_mp_sqr(const mp_int *a, mp_int *b); +static int s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c); +static int mp_exptmod_fast(const mp_int *G, const mp_int *X, mp_int *P, mp_int *Y, int mode); +static int mp_invmod_slow (const mp_int * a, mp_int * b, mp_int * c); +static int mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c); +static int mp_karatsuba_sqr(const mp_int *a, mp_int *b); + /* computes the modular inverse via binary extended euclidean algorithm, * that is c = 1/a mod b * * Based on slow invmod except this is optimized for the case where b is * odd as per HAC Note 14.64 on pp. 610 */ -int +static int fast_mp_invmod (const mp_int * a, mp_int * b, mp_int * c) { mp_int x, y, u, v, B, D; @@ -175,7 +188,7 @@ * * Based on Algorithm 14.32 on pp.601 of HAC. */ -int +static int fast_mp_montgomery_reduce (mp_int * x, const mp_int * n, mp_digit rho) { int ix, res, olduse; @@ -335,7 +348,7 @@ * Based on Algorithm 14.12 on pp.595 of HAC. * */ -int +static int fast_s_mp_mul_digs (const mp_int * a, const mp_int * b, mp_int * c, int digs) { int olduse, res, pa, ix, iz; @@ -414,7 +427,7 @@ * * Based on Algorithm 14.12 on pp.595 of HAC. */ -int +static int fast_s_mp_mul_high_digs (const mp_int * a, const mp_int * b, mp_int * c, int digs) { int olduse, res, pa, ix, iz; @@ -512,7 +525,7 @@ */ -int fast_s_mp_sqr (const mp_int * a, mp_int * b) +static int fast_s_mp_sqr (const mp_int * a, mp_int * b) { int olduse, res, pa, ix, iz; mp_digit W[MP_WARRAY], *tmpx; @@ -996,7 +1009,7 @@ /* take the last digit and count the bits in it */ q = a->dp[a->used - 1]; - while (q > ((mp_digit) 0)) { + while (q > 0) { ++r; q >>= ((mp_digit) 1); } @@ -3847,7 +3860,7 @@ } /* reverse an array, used for radix code */ -void +static void bn_reverse (unsigned char *s, int len) { int ix, iy; @@ -3865,7 +3878,7 @@ } /* low level addition, based on HAC pp.594, Algorithm 14.7 */ -int +static int s_mp_add (mp_int * a, mp_int * b, mp_int * c) { mp_int *x; @@ -3952,7 +3965,7 @@ return MP_OKAY; } -int s_mp_exptmod (const mp_int * G, const mp_int * X, mp_int * P, mp_int * Y) +static int s_mp_exptmod (const mp_int * G, const mp_int * X, mp_int * P, mp_int * Y) { mp_int M[256], res, mu; mp_digit buf; @@ -4163,7 +4176,7 @@ * HAC pp. 595, Algorithm 14.12 Modified so you can control how * many digits of output are created. */ -int +static int s_mp_mul_digs (const mp_int * a, const mp_int * b, mp_int * c, int digs) { mp_int t; @@ -4232,7 +4245,7 @@ /* multiplies |a| * |b| and does not compute the lower digs digits * [meant to get the higher part of the product] */ -int +static int s_mp_mul_high_digs (const mp_int * a, const mp_int * b, mp_int * c, int digs) { mp_int t; @@ -4288,7 +4301,7 @@ } /* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */ -int +static int s_mp_sqr (const mp_int * a, mp_int * b) { mp_int t; @@ -4338,7 +4351,7 @@ u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); } /* propagate upwards */ - while (u != ((mp_digit) 0)) { + while (u != 0) { r = ((mp_word) *tmpt) + ((mp_word) u); *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK)); u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); Modified: trunk/reactos/dll/win32/rsaenh/rc2.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/rsaenh/rc2.c?rev…
============================================================================== --- trunk/reactos/dll/win32/rsaenh/rc2.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/rsaenh/rc2.c [iso-8859-1] Sat Dec 27 04:11:34 2008 @@ -70,7 +70,7 @@ * key schedule. One which is normal, and anther which has a hook to * use a reduced key length. * BSAFE uses the 'retarded' version. What I previously shipped is - * the same as specifying 1024 for the 'bits' parameter. Bsafe uses + * the same as specifying 1024 for the 'bits' parameter. BSAFE uses * a version where the bits parameter is the same as len*8 */ /* Seems like MS uses the 'retarded' version, too. * Adjust effective keylen bits */ Modified: trunk/reactos/dll/win32/rsaenh/rsaenh.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/rsaenh/rsaenh.c?…
============================================================================== --- trunk/reactos/dll/win32/rsaenh/rsaenh.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/rsaenh/rsaenh.c [iso-8859-1] Sat Dec 27 04:11:34 2008 @@ -657,7 +657,7 @@ pbTemp = HeapAlloc(GetProcessHeap(), 0, dwDataLen); if (!pbTemp) return; memcpy(pbTemp, pbData, dwDataLen); - RSAENH_CPEncrypt(pCryptHash->hProv, pCryptHash->hKey, (HCRYPTHASH)NULL, FALSE, 0, + RSAENH_CPEncrypt(pCryptHash->hProv, pCryptHash->hKey, 0, FALSE, 0, pbTemp, &dwDataLen, dwDataLen); HeapFree(GetProcessHeap(), 0, pbTemp); break; @@ -701,7 +701,7 @@ case CALG_MAC: dwDataLen = 0; - RSAENH_CPEncrypt(pCryptHash->hProv, pCryptHash->hKey, (HCRYPTHASH)NULL, TRUE, 0, + RSAENH_CPEncrypt(pCryptHash->hProv, pCryptHash->hKey, 0, TRUE, 0, pCryptHash->abHashValue, &dwDataLen, pCryptHash->dwHashSize); break; @@ -1259,7 +1259,7 @@ 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 } }, { CALG_SHA, 15, { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 } }, - { 0, 0, {} } + { 0, 0, { 0 } } }; DWORD dwIdxOID, i, j; @@ -1677,7 +1677,7 @@ pCryptHash->hKey = hKey; pCryptHash->hProv = hProv; pCryptHash->dwState = RSAENH_HASHSTATE_HASHING; - pCryptHash->pHMACInfo = (PHMAC_INFO)NULL; + pCryptHash->pHMACInfo = NULL; pCryptHash->dwHashSize = peaAlgidInfo->dwDefaultLen >> 3; init_data_blob(&pCryptHash->tpPRFParams.blobLabel); init_data_blob(&pCryptHash->tpPRFParams.blobSeed); @@ -2826,10 +2826,10 @@ { CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)pbData; - /* salt length can't be greater than 128 bits = 16 bytes */ - if (blob->cbData > 16) + /* salt length can't be greater than 184 bits = 24 bytes */ + if (blob->cbData > 24) { - SetLastError(ERROR_INVALID_PARAMETER); + SetLastError(NTE_BAD_DATA); return FALSE; } memcpy(pCryptKey->abKeyValue + pCryptKey->dwKeyLen, blob->pbData, @@ -3557,7 +3557,7 @@ { CRYPTHASH *pCryptHash; CRYPTKEY *pCryptKey; - int i; + DWORD i; TRACE("(hProv=%08lx, hHash=%08lx, dwParam=%08x, pbData=%p, dwFlags=%08x)\n", hProv, hHash, dwParam, pbData, dwFlags); Modified: trunk/reactos/dll/win32/rsaenh/tomcrypt.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/rsaenh/tomcrypt.…
============================================================================== --- trunk/reactos/dll/win32/rsaenh/tomcrypt.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/rsaenh/tomcrypt.h [iso-8859-1] Sat Dec 27 04:11:34 2008 @@ -574,27 +574,6 @@ #define mp_todecimal(M, S) mp_toradix((M), (S), 10) #define mp_tohex(M, S) mp_toradix((M), (S), 16) -/* lowlevel functions, do not call! */ -int s_mp_add(mp_int *a, mp_int *b, mp_int *c); -int s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c); -#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1) -int fast_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs); -int s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs); -int fast_s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs); -int s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs); -int fast_s_mp_sqr(const mp_int *a, mp_int *b); -int s_mp_sqr(const mp_int *a, mp_int *b); -int mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c); -int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c); -int mp_karatsuba_sqr(const mp_int *a, mp_int *b); -int mp_toom_sqr(mp_int *a, mp_int *b); -int fast_mp_invmod(const mp_int *a, mp_int *b, mp_int *c); -int mp_invmod_slow (const mp_int * a, mp_int * b, mp_int * c); -int fast_mp_montgomery_reduce(mp_int *a, const mp_int *m, mp_digit mp); -int mp_exptmod_fast(const mp_int *G, const mp_int *X, mp_int *P, mp_int *Y, int mode); -int s_mp_exptmod (const mp_int * G, const mp_int * X, mp_int * P, mp_int * Y); -void bn_reverse(unsigned char *s, int len); - extern const char *mp_s_rmap; #define PK_PRIVATE 0 /* PK private keys */
15 years, 12 months
1
0
0
0
[cwittich] 38372: sync cabinet to wine 1.1.11
by cwittich@svn.reactos.org
Author: cwittich Date: Sat Dec 27 04:00:27 2008 New Revision: 38372 URL:
http://svn.reactos.org/svn/reactos?rev=38372&view=rev
Log: sync cabinet to wine 1.1.11 Modified: trunk/reactos/dll/win32/cabinet/fci.c trunk/reactos/dll/win32/cabinet/fdi.c Modified: trunk/reactos/dll/win32/cabinet/fci.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/cabinet/fci.c?re…
============================================================================== --- trunk/reactos/dll/win32/cabinet/fci.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/cabinet/fci.c [iso-8859-1] Sat Dec 27 04:00:27 2008 @@ -462,7 +462,7 @@ case 2: ul |= (((ULONG)(*pb++)) << 8); case 1: - ul |= *pb++; + ul |= *pb; default: break; } Modified: trunk/reactos/dll/win32/cabinet/fdi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/cabinet/fdi.c?re…
============================================================================== --- trunk/reactos/dll/win32/cabinet/fdi.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/cabinet/fdi.c [iso-8859-1] Sat Dec 27 04:00:27 2008 @@ -911,6 +911,7 @@ static int NONEfdi_decomp(int inlen, int outlen, fdi_decomp_state *decomp_state) { if (inlen != outlen) return DECR_ILLEGALDATA; + if (outlen > CAB_BLOCKMAX) return DECR_DATAFORMAT; memcpy(CAB(outbuf), CAB(inbuf), (size_t) inlen); return DECR_OK; } @@ -924,7 +925,7 @@ /* Go through linked list, freeing from the allocated (t[-1]) address. */ p = t; - while (p != (struct Ziphuft *)NULL) + while (p != NULL) { q = (--p)->v.t; PFDI_FREE(hfdi, p); @@ -969,7 +970,7 @@ } while (--i); if (ZIP(c)[0] == n) /* null input--all zero length codes */ { - *t = (struct Ziphuft *)NULL; + *t = NULL; *m = 0; return 0; } @@ -1017,8 +1018,8 @@ p = ZIP(v); /* grab values in bit order */ h = -1; /* no tables yet--level -1 */ w = l[-1] = 0; /* no bits decoded yet */ - ZIP(u)[0] = (struct Ziphuft *)NULL; /* just to keep compilers happy */ - q = (struct Ziphuft *)NULL; /* ditto */ + ZIP(u)[0] = NULL; /* just to keep compilers happy */ + q = NULL; /* ditto */ z = 0; /* ditto */ /* go through the bit lengths (k already is bits in shortest code) */ @@ -1060,7 +1061,7 @@ return 3; /* not enough memory */ } *t = q + 1; /* link to list for Ziphuft_free() */ - *(t = &(q->v.t)) = (struct Ziphuft *)NULL; + *(t = &(q->v.t)) = NULL; ZIP(u)[h] = ++q; /* table starts after link */ /* connect to last table, if there is one */ @@ -2258,6 +2259,56 @@ return DECR_OK; } +static void free_decompression_temps(HFDI hfdi, struct fdi_folder *fol, + fdi_decomp_state *decomp_state) +{ + switch (fol->comp_type & cffoldCOMPTYPE_MASK) { + case cffoldCOMPTYPE_LZX: + if (LZX(window)) { + PFDI_FREE(hfdi, LZX(window)); + LZX(window) = NULL; + } + break; + case cffoldCOMPTYPE_QUANTUM: + if (QTM(window)) { + PFDI_FREE(hfdi, QTM(window)); + QTM(window) = NULL; + } + break; + } +} + +static void free_decompression_mem(HFDI hfdi, struct fdi_folder *fol, + fdi_decomp_state *decomp_state, struct fdi_file *file) +{ + while (decomp_state) { + fdi_decomp_state *prev_fds; + + PFDI_CLOSE(hfdi, CAB(cabhf)); + + /* free the storage remembered by mii */ + if (CAB(mii).nextname) PFDI_FREE(hfdi, CAB(mii).nextname); + if (CAB(mii).nextinfo) PFDI_FREE(hfdi, CAB(mii).nextinfo); + if (CAB(mii).prevname) PFDI_FREE(hfdi, CAB(mii).prevname); + if (CAB(mii).previnfo) PFDI_FREE(hfdi, CAB(mii).previnfo); + + while (CAB(firstfol)) { + fol = CAB(firstfol); + CAB(firstfol) = CAB(firstfol)->next; + PFDI_FREE(hfdi, fol); + } + while (CAB(firstfile)) { + file = CAB(firstfile); + if (file->filename) PFDI_FREE(hfdi, (void *)file->filename); + CAB(firstfile) = CAB(firstfile)->next; + PFDI_FREE(hfdi, file); + } + prev_fds = decomp_state; + decomp_state = CAB(next); + PFDI_FREE(hfdi, prev_fds); + } +} + /*********************************************************************** * FDICopy (CABINET.22) * @@ -2442,8 +2493,7 @@ cab_UBYTE buf[64]; struct fdi_folder *fol = NULL, *linkfol = NULL; struct fdi_file *file = NULL, *linkfile = NULL; - fdi_decomp_state _decomp_state; - fdi_decomp_state *decomp_state = &_decomp_state; + fdi_decomp_state *decomp_state; TRACE("(hfdi == ^%p, pszCabinet == ^%p, pszCabPath == ^%p, flags == %0d, " "pfnfdin == ^%p, pfnfdid == ^%p, pvUser == ^%p)\n", @@ -2454,6 +2504,11 @@ return FALSE; } + if (!(decomp_state = PFDI_ALLOC(hfdi, sizeof(fdi_decomp_state)))) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } ZeroMemory(decomp_state, sizeof(fdi_decomp_state)); pathlen = (pszCabPath) ? strlen(pszCabPath) : 0; @@ -2777,7 +2832,7 @@ if (file->offset > CAB(offset)) { /* decode bytes and send them to /dev/null */ - switch ((err = fdi_decomp(file, 0, decomp_state, pszCabPath, pfnfdin, pvUser))) { + switch (fdi_decomp(file, 0, decomp_state, pszCabPath, pfnfdin, pvUser)) { case DECR_OK: break; case DECR_USERABORT: @@ -2839,99 +2894,18 @@ } } - /* free decompression temps */ - switch (fol->comp_type & cffoldCOMPTYPE_MASK) { - case cffoldCOMPTYPE_LZX: - if (LZX(window)) { - PFDI_FREE(hfdi, LZX(window)); - LZX(window) = NULL; - } - break; - case cffoldCOMPTYPE_QUANTUM: - if (QTM(window)) { - PFDI_FREE(hfdi, QTM(window)); - QTM(window) = NULL; - } - break; - } - - while (decomp_state) { - fdi_decomp_state *prev_fds; - - PFDI_CLOSE(hfdi, CAB(cabhf)); - - /* free the storage remembered by mii */ - if (CAB(mii).nextname) PFDI_FREE(hfdi, CAB(mii).nextname); - if (CAB(mii).nextinfo) PFDI_FREE(hfdi, CAB(mii).nextinfo); - if (CAB(mii).prevname) PFDI_FREE(hfdi, CAB(mii).prevname); - if (CAB(mii).previnfo) PFDI_FREE(hfdi, CAB(mii).previnfo); - - while (CAB(firstfol)) { - fol = CAB(firstfol); - CAB(firstfol) = CAB(firstfol)->next; - PFDI_FREE(hfdi, fol); - } - while (CAB(firstfile)) { - file = CAB(firstfile); - if (file->filename) PFDI_FREE(hfdi, (void *)file->filename); - CAB(firstfile) = CAB(firstfile)->next; - PFDI_FREE(hfdi, file); - } - prev_fds = decomp_state; - decomp_state = CAB(next); - if (prev_fds != &_decomp_state) - PFDI_FREE(hfdi, prev_fds); - } + free_decompression_temps(hfdi, fol, decomp_state); + free_decompression_mem(hfdi, fol, decomp_state, file); return TRUE; bail_and_fail: /* here we free ram before error returns */ - /* free decompression temps */ - switch (fol->comp_type & cffoldCOMPTYPE_MASK) { - case cffoldCOMPTYPE_LZX: - if (LZX(window)) { - PFDI_FREE(hfdi, LZX(window)); - LZX(window) = NULL; - } - break; - case cffoldCOMPTYPE_QUANTUM: - if (QTM(window)) { - PFDI_FREE(hfdi, QTM(window)); - QTM(window) = NULL; - } - break; - } + free_decompression_temps(hfdi, fol, decomp_state); if (filehf) PFDI_CLOSE(hfdi, filehf); - while (decomp_state) { - fdi_decomp_state *prev_fds; - - PFDI_CLOSE(hfdi, CAB(cabhf)); - - /* free the storage remembered by mii */ - if (CAB(mii).nextname) PFDI_FREE(hfdi, CAB(mii).nextname); - if (CAB(mii).nextinfo) PFDI_FREE(hfdi, CAB(mii).nextinfo); - if (CAB(mii).prevname) PFDI_FREE(hfdi, CAB(mii).prevname); - if (CAB(mii).previnfo) PFDI_FREE(hfdi, CAB(mii).previnfo); - - while (CAB(firstfol)) { - fol = CAB(firstfol); - CAB(firstfol) = CAB(firstfol)->next; - PFDI_FREE(hfdi, fol); - } - while (CAB(firstfile)) { - file = CAB(firstfile); - if (file->filename) PFDI_FREE(hfdi, (void *)file->filename); - CAB(firstfile) = CAB(firstfile)->next; - PFDI_FREE(hfdi, file); - } - prev_fds = decomp_state; - decomp_state = CAB(next); - if (prev_fds != &_decomp_state) - PFDI_FREE(hfdi, prev_fds); - } + free_decompression_mem(hfdi, fol, decomp_state, file); return FALSE; }
15 years, 12 months
1
0
0
0
[amunger] 38371: Remove the i8042prt entry from the static hive, it was correctly installed by PnP all all tested cases.
by amunger@svn.reactos.org
Author: amunger Date: Sat Dec 27 03:04:15 2008 New Revision: 38371 URL:
http://svn.reactos.org/svn/reactos?rev=38371&view=rev
Log: Remove the i8042prt entry from the static hive, it was correctly installed by PnP all all tested cases. Modified: trunk/reactos/boot/bootdata/hivesys_i386.inf Modified: trunk/reactos/boot/bootdata/hivesys_i386.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesys_i386…
============================================================================== --- trunk/reactos/boot/bootdata/hivesys_i386.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivesys_i386.inf [iso-8859-1] Sat Dec 27 03:04:15 2008 @@ -890,14 +890,6 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Fs_Rec","Start",0x00010001,0x00000001 HKLM,"SYSTEM\CurrentControlSet\Services\Fs_Rec","Type",0x00010001,0x00000008 -; i8042 port driver -HKLM,"SYSTEM\CurrentControlSet\Services\i8042prt","ErrorControl",0x00010001,0x00000000 -HKLM,"SYSTEM\CurrentControlSet\Services\i8042prt","Group",0x00000000,"Keyboard Port" -HKLM,"SYSTEM\CurrentControlSet\Services\i8042prt","ImagePath",0x00020000,"system32\drivers\i8042prt.sys" -HKLM,"SYSTEM\CurrentControlSet\Services\i8042prt","Start",0x00010001,0x00000001 -HKLM,"SYSTEM\CurrentControlSet\Services\i8042prt","Type",0x00010001,0x00000001 -HKLM,"SYSTEM\CurrentControlSet\Services\i8042prt\Parameters","BreakOnSysRq",0x00010001,0x00000001 - ; Kernel-Mode Tests ;HKLM,"SYSTEM\CurrentControlSet\Services\Kmtest","ErrorControl",0x00010001,0x00000000 ;HKLM,"SYSTEM\CurrentControlSet\Services\Kmtest","Group",0x00000000,"Base"
15 years, 12 months
1
0
0
0
[cwittich] 38370: sync riched20 with wine 1.1.11
by cwittich@svn.reactos.org
Author: cwittich Date: Sat Dec 27 02:49:35 2008 New Revision: 38370 URL:
http://svn.reactos.org/svn/reactos?rev=38370&view=rev
Log: sync riched20 with wine 1.1.11 Modified: trunk/reactos/dll/win32/riched20/caret.c trunk/reactos/dll/win32/riched20/clipboard.c trunk/reactos/dll/win32/riched20/editor.c trunk/reactos/dll/win32/riched20/editor.h trunk/reactos/dll/win32/riched20/editstr.h trunk/reactos/dll/win32/riched20/paint.c trunk/reactos/dll/win32/riched20/para.c trunk/reactos/dll/win32/riched20/reader.c trunk/reactos/dll/win32/riched20/rtf.h trunk/reactos/dll/win32/riched20/run.c trunk/reactos/dll/win32/riched20/string.c trunk/reactos/dll/win32/riched20/wrap.c trunk/reactos/dll/win32/riched20/writer.c Modified: trunk/reactos/dll/win32/riched20/caret.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/caret.c…
============================================================================== --- trunk/reactos/dll/win32/riched20/caret.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/caret.c [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -214,8 +214,9 @@ } *height = pSizeRun->member.run.nAscent + pSizeRun->member.run.nDescent; - *x = run->member.run.pt.x + sz.cx; - *y = para->member.para.pt.y + row->member.row.nBaseline + run->member.run.pt.y - pSizeRun->member.run.nAscent - ME_GetYScrollPos(editor); + *x = c.rcView.left + run->member.run.pt.x + sz.cx; + *y = c.rcView.top + para->member.para.pt.y + row->member.row.nBaseline + + run->member.run.pt.y - pSizeRun->member.run.nAscent - ME_GetYScrollPos(editor); ME_DestroyContext(&c, editor->hWnd); return; } @@ -236,10 +237,7 @@ ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height); if(editor->bHaveFocus && !ME_IsSelection(editor)) { - RECT rect; - - GetClientRect(editor->hWnd, &rect); - x = min(x, rect.right-2); + x = min(x, editor->rcFormat.right-1); CreateCaret(editor->hWnd, NULL, 0, height); SetCaretPos(x, y); } @@ -922,6 +920,9 @@ int rx = 0; BOOL isExact = TRUE; + x -= editor->rcFormat.left; + y -= editor->rcFormat.top; + if (is_eol) *is_eol = 0; @@ -1109,13 +1110,13 @@ ME_FindPixelPos(editor, x, y, &editor->pCursors[0], &editor->bCaretAtEnd); - if (x >= editor->selofs || is_shift) + if (x >= editor->rcFormat.left || is_shift) { if (clickNum > 1) { editor->pCursors[1] = editor->pCursors[0]; if (is_shift) { - if (x >= editor->selofs) + if (x >= editor->rcFormat.left) ME_SelectByType(editor, stWord); else ME_SelectByType(editor, stParagraph); @@ -1177,16 +1178,10 @@ memcmp(&editor->pCursors[1], &editor->pCursors[3], sizeof(ME_Cursor))) { /* The scroll the cursor towards the other end, since it was the one - * extended by ME_ExtendAnchorSelection - */ - ME_Cursor tmpCursor = editor->pCursors[0]; - editor->pCursors[0] = editor->pCursors[1]; - editor->pCursors[1] = tmpCursor; - SendMessageW(editor->hWnd, EM_SCROLLCARET, 0, 0); - editor->pCursors[1] = editor->pCursors[0]; - editor->pCursors[0] = tmpCursor; + * extended by ME_ExtendAnchorSelection */ + ME_EnsureVisible(editor, editor->pCursors[1].pRun); } else { - SendMessageW(editor->hWnd, EM_SCROLLCARET, 0, 0); + ME_EnsureVisible(editor, editor->pCursors[0].pRun); } ME_InvalidateSelection(editor); @@ -1571,11 +1566,9 @@ if (!(editor->nEventMask & ENM_SELCHANGE)) return; - - sc.nmhdr.hwndFrom = editor->hWnd; - sc.nmhdr.idFrom = GetWindowLongW(editor->hWnd, GWLP_ID); + sc.nmhdr.code = EN_SELCHANGE; - SendMessageW(editor->hWnd, EM_EXGETSEL, 0, (LPARAM)&sc.chrg); + ME_GetSelection(editor, &sc.chrg.cpMin, &sc.chrg.cpMax); sc.seltyp = SEL_EMPTY; if (sc.chrg.cpMin != sc.chrg.cpMax) sc.seltyp |= SEL_TEXT; Modified: trunk/reactos/dll/win32/riched20/clipboard.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/clipboa…
============================================================================== --- trunk/reactos/dll/win32/riched20/clipboard.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/clipboard.c [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -334,7 +334,7 @@ pars = ME_CountParagraphsBetween(editor, lpchrg->cpMin, lpchrg->cpMax); len = lpchrg->cpMax-lpchrg->cpMin; ret = GlobalAlloc(GMEM_MOVEABLE, sizeof(WCHAR)*(len+pars+1)); - data = (WCHAR *)GlobalLock(ret); + data = GlobalLock(ret); len = ME_GetTextW(editor, data, lpchrg->cpMin, len, TRUE); data[len] = 0; GlobalUnlock(ret); @@ -359,7 +359,7 @@ int nNewSize = (((nMaxSize+cb+1)|0x1FFFF)+1) & 0xFFFE0000; pData->hData = GlobalReAlloc(pData->hData, nNewSize, 0); } - pDest = (BYTE *)GlobalLock(pData->hData); + pDest = GlobalLock(pData->hData); memcpy(pDest + pData->nLength, lpBuff, cb); pData->nLength += cb; pDest[pData->nLength] = '\0'; Modified: trunk/reactos/dll/win32/riched20/editor.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/editor.…
============================================================================== --- trunk/reactos/dll/win32/riched20/editor.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/editor.c [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -99,6 +99,7 @@ - EM_SETFONTSIZE - EM_SETIMECOLOR 1.0asian - EM_SETIMEOPTIONS 1.0asian + - EM_SETIMESTATUS - EM_SETLANGOPTIONS 2.0 - EM_SETLIMITTEXT - EM_SETMARGINS @@ -1425,7 +1426,7 @@ ME_DisplayItem *para_item; style = editor->pBuffer->pDefaultStyle; ME_AddRefStyle(style); - SendMessageA(editor->hWnd, EM_SETSEL, 0, 0); + ME_SetSelection(editor, 0, 0); ME_InternalDeleteText(editor, 0, ME_GetTextLength(editor), FALSE); from = to = 0; ME_ClearTempStyle(editor); @@ -1469,7 +1470,6 @@ memset(&parser, 0, sizeof parser); RTFSetEditStream(&parser, &inStream); parser.rtfFormat = format&(SF_TEXT|SF_RTF); - parser.hwndEdit = editor->hWnd; parser.editor = editor; parser.style = style; WriterInit(&parser); @@ -1559,7 +1559,7 @@ ME_GetSelection(editor, &to, &to2); /* put the cursor at the top */ if (!(format & SFF_SELECTION)) - SendMessageA(editor->hWnd, EM_SETSEL, 0, 0); + ME_SetSelection(editor, 0, 0); } /* Restore saved undo mode */ @@ -1938,6 +1938,73 @@ return -1; } +static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) +{ + int nStart, nCount; /* in chars */ + + if (ex->flags & ~(GT_SELECTION | GT_USECRLF)) + FIXME("GETTEXTEX flags 0x%08x not supported\n", ex->flags & ~(GT_SELECTION | GT_USECRLF)); + + if (ex->flags & GT_SELECTION) + { + ME_GetSelection(editor, &nStart, &nCount); + nCount -= nStart; + } + else + { + nStart = 0; + nCount = 0x7fffffff; + } + if (ex->codepage == 1200) + { + nCount = min(nCount, ex->cb / sizeof(WCHAR) - 1); + return ME_GetTextW(editor, (LPWSTR)pText, nStart, nCount, ex->flags & GT_USECRLF); + } + else + { + /* potentially each char may be a CR, why calculate the exact value with O(N) when + we can just take a bigger buffer? :) + The above assumption still holds with CR/LF counters, since CR->CRLF expansion + occurs only in richedit 2.0 mode, in which line breaks have only one CR + */ + int crlfmul = (ex->flags & GT_USECRLF) ? 2 : 1; + LPWSTR buffer; + DWORD buflen = ex->cb; + LRESULT rc; + DWORD flags = 0; + + nCount = min(nCount, ex->cb - 1); + buffer = heap_alloc((crlfmul*nCount + 1) * sizeof(WCHAR)); + + buflen = ME_GetTextW(editor, buffer, nStart, nCount, ex->flags & GT_USECRLF); + rc = WideCharToMultiByte(ex->codepage, flags, buffer, buflen+1, + (LPSTR)pText, ex->cb, ex->lpDefaultChar, ex->lpUsedDefChar); + if (rc) rc--; /* do not count 0 terminator */ + + heap_free(buffer); + return rc; + } +} + +static int ME_GetTextRange(ME_TextEditor *editor, TEXTRANGEW *rng, BOOL unicode) +{ + if (unicode) + return ME_GetTextW(editor, rng->lpstrText, rng->chrg.cpMin, + rng->chrg.cpMax-rng->chrg.cpMin, 0); + else + { + int nLen = rng->chrg.cpMax-rng->chrg.cpMin; + WCHAR *p = ALLOC_N_OBJ(WCHAR, nLen+1); + int nChars = ME_GetTextW(editor, p, rng->chrg.cpMin, nLen, 0); + /* FIXME this is a potential security hole (buffer overrun) + if you know more about wchar->mbyte conversion please explain + */ + WideCharToMultiByte(CP_ACP, 0, p, nChars+1, (char *)rng->lpstrText, nLen+1, NULL, NULL); + FREE_OBJ(p); + return nChars; + } +} + typedef struct tagME_GlobalDestStruct { HGLOBAL hData; @@ -1952,7 +2019,7 @@ cb = cb >> 1; pDest = (WORD *)lpBuff; - pSrc = (WORD *)GlobalLock(pData->hData); + pSrc = GlobalLock(pData->hData); for (i = 0; i<cb && pSrc[pData->nLength+i]; i++) { pDest[i] = pSrc[pData->nLength+i]; } @@ -1969,7 +2036,7 @@ BYTE *pSrc, *pDest; pDest = lpBuff; - pSrc = (BYTE *)GlobalLock(pData->hData); + pSrc = GlobalLock(pData->hData); for (i = 0; i<cb && pSrc[pData->nLength+i]; i++) { pDest[i] = pSrc[pData->nLength+i]; } @@ -2178,10 +2245,176 @@ return FALSE; } +static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode, + LPARAM flags, BOOL unicode) +{ + WCHAR wstr; + + if (unicode) + wstr = (WCHAR)charCode; + else + { + CHAR charA = charCode; + MultiByteToWideChar(CP_ACP, 0, &charA, 1, &wstr, 1); + } + + if (GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_READONLY) { + MessageBeep(MB_ICONERROR); + return 0; /* FIXME really 0 ? */ + } + + if (((unsigned)wstr)>=' ' + || (wstr=='\r' && (GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_MULTILINE)) + || wstr=='\t') { + ME_Cursor cursor = editor->pCursors[0]; + ME_DisplayItem *para = ME_GetParagraph(cursor.pRun); + int from, to; + BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000; + ME_GetSelection(editor, &from, &to); + if (wstr=='\t' + /* v4.1 allows tabs to be inserted with ctrl key down */ + && !(ctrl_is_down && !editor->bEmulateVersion10) + ) + { + ME_DisplayItem *para; + BOOL bSelectedRow = FALSE; + + para = ME_GetParagraph(cursor.pRun); + if (ME_IsSelection(editor) && + cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 && + to == ME_GetCursorOfs(editor, 0) && + para->member.para.prev_para->type == diParagraph) + { + para = para->member.para.prev_para; + bSelectedRow = TRUE; + } + if (ME_IsInTable(para)) + { + ME_TabPressedInTable(editor, bSelectedRow); + ME_CommitUndo(editor); + return 0; + } + } else if (!editor->bEmulateVersion10) { /* v4.1 */ + if (para->member.para.nFlags & MEPF_ROWEND) { + if (wstr=='\r') { + /* Add a new table row after this row. */ + para = ME_AppendTableRow(editor, para); + para = para->member.para.next_para; + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[0].nOffset = 0; + editor->pCursors[1] = editor->pCursors[0]; + ME_CommitUndo(editor); + ME_CheckTablesForCorruption(editor); + ME_UpdateRepaint(editor); + return 0; + } else if (from == to) { + para = para->member.para.next_para; + if (para->member.para.nFlags & MEPF_ROWSTART) + para = para->member.para.next_para; + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[0].nOffset = 0; + editor->pCursors[1] = editor->pCursors[0]; + } + } + else if (para == ME_GetParagraph(editor->pCursors[1].pRun) && + cursor.nOffset + cursor.pRun->member.run.nCharOfs == 0 && + para->member.para.prev_para->member.para.nFlags & MEPF_ROWSTART && + !para->member.para.prev_para->member.para.nCharOfs) + { + /* Insert a newline before the table. */ + WCHAR endl = '\r'; + para = para->member.para.prev_para; + para->member.para.nFlags &= ~MEPF_ROWSTART; + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[1] = editor->pCursors[0]; + ME_InsertTextFromCursor(editor, 0, &endl, 1, + editor->pCursors[0].pRun->member.run.style); + para = editor->pBuffer->pFirst->member.para.next_para; + ME_SetDefaultParaFormat(para->member.para.pFmt); + para->member.para.nFlags = MEPF_REWRAP; + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[1] = editor->pCursors[0]; + para->member.para.next_para->member.para.nFlags |= MEPF_ROWSTART; + ME_CommitCoalescingUndo(editor); + ME_CheckTablesForCorruption(editor); + ME_UpdateRepaint(editor); + return 0; + } + } else { /* v1.0 - 3.0 */ + ME_DisplayItem *para = ME_GetParagraph(cursor.pRun); + if (ME_IsInTable(cursor.pRun)) + { + if (cursor.pRun->member.run.nFlags & MERF_ENDPARA) + { + if (from == to) { + if (wstr=='\r') { + ME_ContinueCoalescingTransaction(editor); + para = ME_AppendTableRow(editor, para); + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[0].nOffset = 0; + editor->pCursors[1] = editor->pCursors[0]; + ME_CommitCoalescingUndo(editor); + ME_UpdateRepaint(editor); + } else { + /* Text should not be inserted at the end of the table. */ + MessageBeep(-1); + } + return 0; + } + } else if (wstr == '\r') { + ME_ContinueCoalescingTransaction(editor); + if (cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 && + !ME_IsInTable(para->member.para.prev_para)) + { + /* Insert newline before table */ + WCHAR endl = '\r'; + cursor.pRun = ME_FindItemBack(para, diRun); + if (cursor.pRun) + editor->pCursors[0].pRun = cursor.pRun; + editor->pCursors[0].nOffset = 0; + editor->pCursors[1] = editor->pCursors[0]; + ME_InsertTextFromCursor(editor, 0, &endl, 1, + editor->pCursors[0].pRun->member.run.style); + } else { + editor->pCursors[1] = editor->pCursors[0]; + para = ME_AppendTableRow(editor, para); + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[0].nOffset = 0; + editor->pCursors[1] = editor->pCursors[0]; + } + ME_CommitCoalescingUndo(editor); + ME_UpdateRepaint(editor); + return 0; + } + } + } + /* FIXME maybe it would make sense to call EM_REPLACESEL instead ? */ + /* WM_CHAR is restricted to nTextLimit */ + if(editor->nTextLimit > ME_GetTextLength(editor) - (to-from)) + { + ME_Style *style = ME_GetInsertStyle(editor, 0); + ME_SaveTempStyle(editor); + ME_ContinueCoalescingTransaction(editor); + if (wstr == '\r' && (GetKeyState(VK_SHIFT) & 0x8000)) + ME_InsertEndRowFromCursor(editor, 0); + else + ME_InsertTextFromCursor(editor, 0, &wstr, 1, style); + ME_ReleaseStyle(style); + ME_CommitCoalescingUndo(editor); + SetCursor(NULL); + } + + if (editor->AutoURLDetect_bEnable) ME_UpdateSelectionLinkAttribute(editor); + + ME_UpdateRepaint(editor); + } + return 0; +} + /* Process the message and calculate the new click count. * * returns: The click count if it is mouse down event, else returns 0. */ -static int ME_CalculateClickCount(HWND hWnd, UINT msg, WPARAM wParam, +static int ME_CalculateClickCount(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam) { static int clickNum = 0; @@ -2203,7 +2436,9 @@ { static MSG prevClickMsg; MSG clickMsg; - clickMsg.hwnd = hWnd; + /* Compare the editor instead of the hwnd so that the this + * can still be done for windowless richedit controls. */ + clickMsg.hwnd = (HWND)editor; clickMsg.message = msg; clickMsg.wParam = wParam; clickMsg.lParam = lParam; @@ -2257,9 +2492,26 @@ } ScreenToClient(editor->hWnd, &pt); - if ((GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_SELECTIONBAR) && - (pt.x < editor->selofs || - (editor->nSelectionType == stLine && GetCapture() == editor->hWnd))) + if (editor->nSelectionType == stLine && GetCapture() == editor->hWnd) { + SetCursor(hLeft); + return TRUE; + } + if (!editor->bEmulateVersion10 /* v4.1 */ && + pt.y < editor->rcFormat.top && + pt.x < editor->rcFormat.left) + { + SetCursor(hLeft); + return TRUE; + } + if (pt.y < editor->rcFormat.top || pt.y > editor->rcFormat.bottom) + { + if (editor->bEmulateVersion10) /* v1.0 - 3.0 */ + SetCursor(LoadCursorW(NULL, (WCHAR*)IDC_ARROW)); + else /* v4.1 */ + SetCursor(LoadCursorW(NULL, (WCHAR*)IDC_IBEAM)); + return TRUE; + } + if (pt.x < editor->rcFormat.left) { SetCursor(hLeft); return TRUE; @@ -2293,6 +2545,16 @@ } SetCursor(LoadCursorW(NULL, (WCHAR*)IDC_IBEAM)); return TRUE; +} + +static void ME_SetDefaultFormatRect(ME_TextEditor *editor) +{ + DWORD exstyle = GetWindowLongW(editor->hWnd, GWL_EXSTYLE); + + GetClientRect(editor->hWnd, &editor->rcFormat); + editor->rcFormat.top += (exstyle & WS_EX_CLIENTEDGE ? 1 : 0); + editor->rcFormat.left += 1 + editor->selofs; + editor->rcFormat.right -= 1; } static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y) @@ -2343,7 +2605,6 @@ ed->pCursors[2] = ed->pCursors[0]; ed->pCursors[3] = ed->pCursors[1]; ed->nLastTotalLength = ed->nTotalLength = 0; - ed->nHeight = 0; ed->nUDArrowX = -1; ed->nSequence = 0; ed->rgbBackColor = -1; @@ -2379,6 +2640,7 @@ ed->selofs = SELECTIONBAR_WIDTH; else ed->selofs = 0; + ed->bDefaultFormatRect = TRUE; ed->nSelectionType = stPosition; if (GetWindowLongW(hWnd, GWL_STYLE) & ES_PASSWORD) @@ -2461,11 +2723,6 @@ return TRUE; } - -#define UNSUPPORTED_MSG(e) \ - case e: \ - FIXME(#e ": stub\n"); \ - return DefWindowProcW(hWnd, msg, wParam, lParam); static const char * const edit_messages[] = { "EM_GETSEL", @@ -2507,7 +2764,9 @@ "EM_GETMARGINS", "EM_GETLIMITTEXT", "EM_POSFROMCHAR", - "EM_CHARFROMPOS" + "EM_CHARFROMPOS", + "EM_SETIMESTATUS", + "EM_GETIMESTATUS" }; static const char * const richedit_messages[] = { @@ -2604,18 +2863,60 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode) { - ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(hWnd, 0); - - TRACE("hwnd %p msg %04x (%s) %lx %lx, unicode %d\n", + ME_TextEditor *editor; + HRESULT hresult; + LRESULT lresult; + + TRACE("enter hwnd %p msg %04x (%s) %lx %lx, unicode %d\n", hWnd, msg, get_msg_name(msg), wParam, lParam, unicode); - - if (!editor && msg != WM_NCCREATE && msg != WM_NCDESTROY) { - ERR("called with invalid hWnd %p - application bug?\n", hWnd); - return 0; - } + + editor = (ME_TextEditor *)GetWindowLongPtrW(hWnd, 0); + if (!editor) + { + if (msg == WM_NCCREATE) + { + CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam; + TRACE("WM_NCCREATE: style 0x%08x\n", pcs->style); + editor = ME_MakeEditor(hWnd); + SetWindowLongPtrW(hWnd, 0, (LONG_PTR)editor); + return TRUE; + } + else if (msg != WM_NCDESTROY) + { + ERR("called with invalid hWnd %p - application bug?\n", hWnd); + return 0; + } + } + + lresult = ME_HandleMessage(editor, msg, wParam, lParam, unicode, &hresult); + + if (hresult == S_FALSE) + lresult = DefWindowProcW(hWnd, msg, wParam, lParam); + + TRACE("exit hwnd %p msg %04x (%s) %lx %lx, unicode %d -> %lu\n", + hWnd, msg, get_msg_name(msg), wParam, lParam, unicode, lresult); + + return lresult; +} + +#define UNSUPPORTED_MSG(e) \ + case e: \ + FIXME(#e ": stub\n"); \ + *phresult = S_FALSE; \ + return 0; + +/* Handle messages for windowless and windoweded richedit controls. + * + * The LRESULT that is returned is a return value for window procs, + * and the phresult parameter is the COM return code needed by the + * text services interface. */ +LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, + LPARAM lParam, BOOL unicode, HRESULT* phresult) +{ + *phresult = S_OK; switch(msg) { - + UNSUPPORTED_MSG(EM_DISPLAYBAND) UNSUPPORTED_MSG(EM_FINDWORDBREAK) UNSUPPORTED_MSG(EM_FMTLINES) @@ -2623,7 +2924,8 @@ UNSUPPORTED_MSG(EM_GETBIDIOPTIONS) UNSUPPORTED_MSG(EM_GETEDITSTYLE) UNSUPPORTED_MSG(EM_GETIMECOMPMODE) - /* UNSUPPORTED_MSG(EM_GETIMESTATUS) missing in Wine headers */ + UNSUPPORTED_MSG(EM_GETIMESTATUS) + UNSUPPORTED_MSG(EM_SETIMESTATUS) UNSUPPORTED_MSG(EM_GETLANGOPTIONS) /* UNSUPPORTED_MSG(EM_GETOLEINTERFACE) separate stub */ UNSUPPORTED_MSG(EM_GETREDONAME) @@ -2658,7 +2960,7 @@ { int vk = (int)((LPMSG)lParam)->wParam; /* if style says we want return key */ - if((vk == VK_RETURN) && (GetWindowLongW(hWnd, GWL_STYLE) & ES_WANTRETURN)) + if((vk == VK_RETURN) && (GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_WANTRETURN)) { code |= DLGC_WANTMESSAGE; } @@ -2669,14 +2971,6 @@ } } return code; - } - case WM_NCCREATE: - { - CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam; - TRACE("WM_NCCREATE: style 0x%08x\n", pcs->style); - editor = ME_MakeEditor(hWnd); - SetWindowLongPtrW(hWnd, 0, (LONG_PTR)editor); - return TRUE; } case EM_EMPTYUNDOBUFFER: ME_EmptyUndoStack(editor); @@ -2723,8 +3017,8 @@ { /* these flags are equivalent to the ES_* counterparts */ DWORD mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL | - ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN; - DWORD settings = GetWindowLongW(hWnd, GWL_STYLE) & mask; + ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN | ECO_SELECTIONBAR; + DWORD settings = GetWindowLongW(editor->hWnd, GWL_STYLE) & mask; return settings; } @@ -2736,8 +3030,10 @@ */ DWORD mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL | ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN | ECO_SELECTIONBAR; - DWORD raw = GetWindowLongW(hWnd, GWL_STYLE); + DWORD raw = GetWindowLongW(editor->hWnd, GWL_STYLE); DWORD settings = mask & raw; + DWORD oldSettings = settings; + DWORD changedSettings; switch(wParam) { @@ -2753,15 +3049,23 @@ case ECOOP_XOR: settings ^= lParam; } - SetWindowLongW(hWnd, GWL_STYLE, (raw & ~mask) | (settings & mask)); + SetWindowLongW(editor->hWnd, GWL_STYLE, (raw & ~mask) | (settings & mask)); + + changedSettings = oldSettings ^ settings; if (settings & ECO_AUTOWORDSELECTION) FIXME("ECO_AUTOWORDSELECTION not implemented yet!\n"); - if (settings & ECO_SELECTIONBAR) + + if (oldSettings ^ settings) { + if (settings & ECO_SELECTIONBAR) { editor->selofs = SELECTIONBAR_WIDTH; - else + editor->rcFormat.left += SELECTIONBAR_WIDTH; + } else { editor->selofs = 0; - ME_WrapMarkedParagraphs(editor); + editor->rcFormat.left -= SELECTIONBAR_WIDTH; + } + ME_WrapMarkedParagraphs(editor); + } if (settings & ECO_VERTICAL) FIXME("ECO_VERTICAL not implemented yet!\n"); @@ -2895,8 +3199,8 @@ editor->rgbBackColor = lParam; editor->hbrBackground = CreateSolidBrush(editor->rgbBackColor); } - InvalidateRect(hWnd, NULL, TRUE); - UpdateWindow(hWnd); + InvalidateRect(editor->hWnd, NULL, TRUE); + UpdateWindow(editor->hWnd); return lColor; } case EM_GETMODIFY: @@ -2912,12 +3216,12 @@ } case EM_SETREADONLY: { - long nStyle = GetWindowLongW(hWnd, GWL_STYLE); + long nStyle = GetWindowLongW(editor->hWnd, GWL_STYLE); if (wParam) nStyle |= ES_READONLY; else nStyle &= ~ES_READONLY; - SetWindowLongW(hWnd, GWL_STYLE, nStyle); + SetWindowLongW(editor->hWnd, GWL_STYLE, nStyle); return 0; } case EM_SETEVENTMASK: @@ -3060,23 +3364,8 @@ return len; } case EM_SCROLLCARET: - { - int top, bottom; /* row's edges relative to document top */ - int nPos; - ME_DisplayItem *para, *row; - - nPos = ME_GetYScrollPos(editor); - row = ME_RowStart(editor->pCursors[0].pRun); - para = ME_GetParagraph(row); - top = para->member.para.pt.y + row->member.row.pt.y; - bottom = top + row->member.row.nHeight; - - if (top < nPos) /* caret above window */ - ME_ScrollAbs(editor, top); - else if (nPos + editor->sizeWindow.cy < bottom) /*below*/ - ME_ScrollAbs(editor, bottom - editor->sizeWindow.cy); + ME_EnsureVisible(editor, editor->pCursors[0].pRun); return 0; - } case WM_SETFONT: { LOGFONTW lf; @@ -3087,9 +3376,9 @@ if (!wParam) wParam = (WPARAM)GetStockObject(SYSTEM_FONT); GetObjectW((HGDIOBJ)wParam, sizeof(LOGFONTW), &lf); - hDC = GetDC(hWnd); + hDC = GetDC(editor->hWnd); ME_CharFormatFromLogFont(hDC, &lf, &fmt); - ReleaseDC(hWnd, hDC); + ReleaseDC(editor->hWnd, hDC); ME_SetCharFormat(editor, 0, ME_GetTextLength(editor), &fmt); ME_SetDefaultCharFormat(editor, &fmt); @@ -3118,7 +3407,7 @@ int len = -1; /* uses default style! */ - if (!(GetWindowLongW(hWnd, GWL_STYLE) & ES_MULTILINE)) + if (!(GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_MULTILINE)) { WCHAR * p; @@ -3198,12 +3487,13 @@ ex.codepage = unicode ? 1200 : CP_ACP; ex.lpDefaultChar = NULL; ex.lpUsedDefChar = NULL; - rc = RichEditWndProc_common(hWnd, EM_GETTEXTEX, (WPARAM)&ex, unicode ? (LPARAM)bufferW : (LPARAM)bufferA, unicode); + + rc = ME_GetTextEx(editor, &ex, unicode ? (LPARAM)bufferW : (LPARAM)bufferA); if (unicode) { memcpy((LPWSTR)lParam, bufferW, wParam * sizeof(WCHAR)); - if (lstrlenW(bufferW) >= wParam) rc = 0; + if (strlenW(bufferW) >= wParam) rc = 0; } else { @@ -3215,52 +3505,7 @@ return rc; } case EM_GETTEXTEX: - { - GETTEXTEX *ex = (GETTEXTEX*)wParam; - int nStart, nCount; /* in chars */ - - if (ex->flags & ~(GT_SELECTION | GT_USECRLF)) - FIXME("GETTEXTEX flags 0x%08x not supported\n", ex->flags & ~(GT_SELECTION | GT_USECRLF)); - - if (ex->flags & GT_SELECTION) - { - ME_GetSelection(editor, &nStart, &nCount); - nCount -= nStart; - } - else - { - nStart = 0; - nCount = 0x7fffffff; - } - if (ex->codepage == 1200) - { - nCount = min(nCount, ex->cb / sizeof(WCHAR) - 1); - return ME_GetTextW(editor, (LPWSTR)lParam, nStart, nCount, ex->flags & GT_USECRLF); - } - else - { - /* potentially each char may be a CR, why calculate the exact value with O(N) when - we can just take a bigger buffer? :) - The above assumption still holds with CR/LF counters, since CR->CRLF expansion - occurs only in richedit 2.0 mode, in which line breaks have only one CR - */ - int crlfmul = (ex->flags & GT_USECRLF) ? 2 : 1; - LPWSTR buffer; - DWORD buflen = ex->cb; - LRESULT rc; - DWORD flags = 0; - - nCount = min(nCount, ex->cb - 1); - buffer = heap_alloc((crlfmul*nCount + 1) * sizeof(WCHAR)); - - buflen = ME_GetTextW(editor, buffer, nStart, nCount, ex->flags & GT_USECRLF); - rc = WideCharToMultiByte(ex->codepage, flags, buffer, buflen+1, (LPSTR)lParam, ex->cb, ex->lpDefaultChar, ex->lpUsedDefChar); - if (rc) rc--; /* do not count 0 terminator */ - - heap_free(buffer); - return rc; - } - } + return ME_GetTextEx(editor, (GETTEXTEX*)wParam, lParam); case EM_GETSELTEXT: { int from, to; @@ -3269,7 +3514,7 @@ tr.chrg.cpMin = from; tr.chrg.cpMax = to; tr.lpstrText = (WCHAR *)lParam; - return RichEditWndProc_common(hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr, unicode); + return ME_GetTextRange(editor, &tr, unicode); } case EM_GETSCROLLPOS: { @@ -3284,20 +3529,7 @@ TRACE("EM_GETTEXTRANGE min=%d max=%d unicode=%d emul1.0=%d length=%d\n", rng->chrg.cpMin, rng->chrg.cpMax, unicode, editor->bEmulateVersion10, ME_GetTextLength(editor)); - if (unicode) - return ME_GetTextW(editor, rng->lpstrText, rng->chrg.cpMin, rng->chrg.cpMax-rng->chrg.cpMin, 0); - else - { - int nLen = rng->chrg.cpMax-rng->chrg.cpMin; - WCHAR *p = ALLOC_N_OBJ(WCHAR, nLen+1); - int nChars = ME_GetTextW(editor, p, rng->chrg.cpMin, nLen, 0); - /* FIXME this is a potential security hole (buffer overrun) - if you know more about wchar->mbyte conversion please explain - */ - WideCharToMultiByte(CP_ACP, 0, p, nChars+1, (char *)rng->lpstrText, nLen+1, NULL, NULL); - FREE_OBJ(p); - return nChars; - } + return ME_GetTextRange(editor, rng, unicode); } case EM_GETLINE: { @@ -3338,7 +3570,7 @@ { if (run && (run->member.run.nFlags & MERF_ENDPARA)) { - unsigned int i; + int i; /* Write as many \r as encoded in end-of-paragraph, space allowing */ for (i = 0; i < run->member.run.nCR && nCharsLeft > 0; i++, nCharsLeft--) { @@ -3544,18 +3776,16 @@ nCharOfs = lParam; nLength = ME_GetTextLength(editor); nCharOfs = min(nCharOfs, nLength); + nCharOfs = max(nCharOfs, 0); ME_RunOfsFromCharOfs(editor, nCharOfs, &pRun, &nOffset); assert(pRun->type == diRun); pt.y = pRun->member.run.pt.y; pt.x = pRun->member.run.pt.x + ME_PointFromChar(editor, &pRun->member.run, nOffset); - pt.y += ME_GetParagraph(pRun)->member.para.pt.y; - pt.x += editor->selofs; - pt.x++; /* for some reason native offsets x by one */ - - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - if (GetScrollInfo(editor->hWnd, SB_VERT, &si)) pt.y -= si.nPos; + pt.y += ME_GetParagraph(pRun)->member.para.pt.y + editor->rcFormat.top; + pt.x += editor->rcFormat.left; + + pt.y -= editor->vert_si.nPos; si.cbSize = sizeof(si); si.fMask = SIF_POS; if (GetScrollInfo(editor->hWnd, SB_HORZ, &si)) pt.x -= si.nPos; @@ -3569,20 +3799,20 @@ { SCROLLINFO si; - GetClientRect(hWnd, &editor->rcFormat); - if (GetWindowLongW(hWnd, GWL_STYLE) & WS_HSCROLL) + ME_SetDefaultFormatRect(editor); + if (GetWindowLongW(editor->hWnd, GWL_STYLE) & WS_HSCROLL) { /* Squelch the default horizontal scrollbar it would make */ ShowScrollBar(editor->hWnd, SB_HORZ, FALSE); } si.cbSize = sizeof(si); si.fMask = SIF_PAGE | SIF_RANGE; - if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL) + if (GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_DISABLENOSCROLL) si.fMask |= SIF_DISABLENOSCROLL; si.nMax = (si.fMask & SIF_DISABLENOSCROLL) ? 1 : 0; si.nMin = 0; si.nPage = 0; - SetScrollInfo(hWnd, SB_VERT, &si, TRUE); + SetScrollInfo(editor->hWnd, SB_VERT, &si, TRUE); ME_CommitUndo(editor); ME_WrapMarkedParagraphs(editor); @@ -3591,7 +3821,7 @@ } case WM_DESTROY: ME_DestroyEditor(editor); - SetWindowLongPtrW(hWnd, 0, 0); + SetWindowLongPtrW(editor->hWnd, 0, 0); return 0; case WM_SETCURSOR: { @@ -3604,10 +3834,10 @@ if ((editor->nEventMask & ENM_MOUSEEVENTS) && !ME_FilterEvent(editor, msg, &wParam, &lParam)) return 0; - SetFocus(hWnd); + SetFocus(editor->hWnd); ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam), - ME_CalculateClickCount(hWnd, msg, wParam, lParam)); - SetCapture(hWnd); + ME_CalculateClickCount(editor, msg, wParam, lParam)); + SetCapture(editor->hWnd); ME_LinkNotify(editor,msg,wParam,lParam); if (!ME_SetCursor(editor)) goto do_default; break; @@ -3616,15 +3846,15 @@ if ((editor->nEventMask & ENM_MOUSEEVENTS) && !ME_FilterEvent(editor, msg, &wParam, &lParam)) return 0; - if (GetCapture() == hWnd) + if (GetCapture() == editor->hWnd) ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)); ME_LinkNotify(editor,msg,wParam,lParam); /* Set cursor if mouse is captured, since WM_SETCURSOR won't be received. */ - if (GetCapture() == hWnd) + if (GetCapture() == editor->hWnd) ME_SetCursor(editor); break; case WM_LBUTTONUP: - if (GetCapture() == hWnd) + if (GetCapture() == editor->hWnd) ReleaseCapture(); if (editor->nSelectionType == stDocument) editor->nSelectionType = stPosition; @@ -3651,11 +3881,39 @@ case WM_PAINT: { HDC hDC; + RECT rc; PAINTSTRUCT ps; - hDC = BeginPaint(hWnd, &ps); + hDC = BeginPaint(editor->hWnd, &ps); + /* Erase area outside of the formatting rectangle */ + if (ps.rcPaint.top < editor->rcFormat.top) + { + rc = ps.rcPaint; + rc.bottom = editor->rcFormat.top; + FillRect(hDC, &rc, editor->hbrBackground); + ps.rcPaint.top = editor->rcFormat.top; + } + if (ps.rcPaint.bottom > editor->rcFormat.bottom) { + rc = ps.rcPaint; + rc.top = editor->rcFormat.bottom; + FillRect(hDC, &rc, editor->hbrBackground); + ps.rcPaint.bottom = editor->rcFormat.bottom; + } + if (ps.rcPaint.left < editor->rcFormat.left) { + rc = ps.rcPaint; + rc.right = editor->rcFormat.left; + FillRect(hDC, &rc, editor->hbrBackground); + ps.rcPaint.left = editor->rcFormat.left; + } + if (ps.rcPaint.right > editor->rcFormat.right) { + rc = ps.rcPaint; + rc.left = editor->rcFormat.right; + FillRect(hDC, &rc, editor->hbrBackground); + ps.rcPaint.right = editor->rcFormat.right; + } + ME_PaintContent(editor, hDC, FALSE, &ps.rcPaint); - EndPaint(hWnd, &ps); + EndPaint(editor->hWnd, &ps); } break; case WM_SETFOCUS: @@ -3673,7 +3931,7 @@ { HDC hDC = (HDC)wParam; RECT rc; - if (GetUpdateRect(hWnd,&rc,TRUE)) + if (GetUpdateRect(editor->hWnd,&rc,TRUE)) { FillRect(hDC, &rc, editor->hbrBackground); } @@ -3694,170 +3952,8 @@ if (ME_KeyDown(editor, LOWORD(wParam))) return 0; goto do_default; - case WM_CHAR: - { - WCHAR wstr; - - if (unicode) - wstr = (WCHAR)wParam; - else - { - CHAR charA = wParam; - MultiByteToWideChar(CP_ACP, 0, &charA, 1, &wstr, 1); - } - - if (GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_READONLY) { - MessageBeep(MB_ICONERROR); - return 0; /* FIXME really 0 ? */ - } - - if (((unsigned)wstr)>=' ' - || (wstr=='\r' && (GetWindowLongW(hWnd, GWL_STYLE) & ES_MULTILINE)) - || wstr=='\t') { - ME_Cursor cursor = editor->pCursors[0]; - ME_DisplayItem *para = ME_GetParagraph(cursor.pRun); - int from, to; - BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000; - ME_GetSelection(editor, &from, &to); - if (wstr=='\t' - /* v4.1 allows tabs to be inserted with ctrl key down */ - && !(ctrl_is_down && !editor->bEmulateVersion10) - ) - { - ME_DisplayItem *para; - BOOL bSelectedRow = FALSE; - - para = ME_GetParagraph(cursor.pRun); - if (ME_IsSelection(editor) && - cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 && - to == ME_GetCursorOfs(editor, 0) && - para->member.para.prev_para->type == diParagraph) - { - para = para->member.para.prev_para; - bSelectedRow = TRUE; - } - if (ME_IsInTable(para)) - { - ME_TabPressedInTable(editor, bSelectedRow); - ME_CommitUndo(editor); - return 0; - } - } else if (!editor->bEmulateVersion10) { /* v4.1 */ - if (para->member.para.nFlags & MEPF_ROWEND) { - if (wstr=='\r') { - /* Add a new table row after this row. */ - para = ME_AppendTableRow(editor, para); - para = para->member.para.next_para; - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[0].nOffset = 0; - editor->pCursors[1] = editor->pCursors[0]; - ME_CommitUndo(editor); - ME_CheckTablesForCorruption(editor); - ME_UpdateRepaint(editor); - return 0; - } else if (from == to) { - para = para->member.para.next_para; - if (para->member.para.nFlags & MEPF_ROWSTART) - para = para->member.para.next_para; - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[0].nOffset = 0; - editor->pCursors[1] = editor->pCursors[0]; - } - } - else if (para == ME_GetParagraph(editor->pCursors[1].pRun) && - cursor.nOffset + cursor.pRun->member.run.nCharOfs == 0 && - para->member.para.prev_para->member.para.nFlags & MEPF_ROWSTART && - !para->member.para.prev_para->member.para.nCharOfs) - { - /* Insert a newline before the table. */ - WCHAR endl = '\r'; - para = para->member.para.prev_para; - para->member.para.nFlags &= ~MEPF_ROWSTART; - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[1] = editor->pCursors[0]; - ME_InsertTextFromCursor(editor, 0, &endl, 1, - editor->pCursors[0].pRun->member.run.style); - para = editor->pBuffer->pFirst->member.para.next_para; - ME_SetDefaultParaFormat(para->member.para.pFmt); - para->member.para.nFlags = MEPF_REWRAP; - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[1] = editor->pCursors[0]; - para->member.para.next_para->member.para.nFlags |= MEPF_ROWSTART; - ME_CommitCoalescingUndo(editor); - ME_CheckTablesForCorruption(editor); - ME_UpdateRepaint(editor); - return 0; - } - } else { /* v1.0 - 3.0 */ - ME_DisplayItem *para = ME_GetParagraph(cursor.pRun); - if (ME_IsInTable(cursor.pRun)) - { - if (cursor.pRun->member.run.nFlags & MERF_ENDPARA) - { - if (from == to) { - if (wstr=='\r') { - ME_ContinueCoalescingTransaction(editor); - para = ME_AppendTableRow(editor, para); - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[0].nOffset = 0; - editor->pCursors[1] = editor->pCursors[0]; - ME_CommitCoalescingUndo(editor); - ME_UpdateRepaint(editor); - } else { - /* Text should not be inserted at the end of the table. */ - MessageBeep(-1); - } - return 0; - } - } else if (wstr == '\r') { - ME_ContinueCoalescingTransaction(editor); - if (cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 && - !ME_IsInTable(para->member.para.prev_para)) - { - /* Insert newline before table */ - WCHAR endl = '\r'; - cursor.pRun = ME_FindItemBack(para, diRun); - if (cursor.pRun) - editor->pCursors[0].pRun = cursor.pRun; - editor->pCursors[0].nOffset = 0; - editor->pCursors[1] = editor->pCursors[0]; - ME_InsertTextFromCursor(editor, 0, &endl, 1, - editor->pCursors[0].pRun->member.run.style); - } else { - editor->pCursors[1] = editor->pCursors[0]; - para = ME_AppendTableRow(editor, para); - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[0].nOffset = 0; - editor->pCursors[1] = editor->pCursors[0]; - } - ME_CommitCoalescingUndo(editor); - ME_UpdateRepaint(editor); - return 0; - } - } - } - /* FIXME maybe it would make sense to call EM_REPLACESEL instead ? */ - /* WM_CHAR is restricted to nTextLimit */ - if(editor->nTextLimit > ME_GetTextLength(editor) - (to-from)) - { - ME_Style *style = ME_GetInsertStyle(editor, 0); - ME_SaveTempStyle(editor); - ME_ContinueCoalescingTransaction(editor); - if (wstr == '\r' && (GetKeyState(VK_SHIFT) & 0x8000)) - ME_InsertEndRowFromCursor(editor, 0); - else - ME_InsertTextFromCursor(editor, 0, &wstr, 1, style); - ME_ReleaseStyle(style); - ME_CommitCoalescingUndo(editor); - SetCursor(NULL); - } - - if (editor->AutoURLDetect_bEnable) ME_UpdateSelectionLinkAttribute(editor); - - ME_UpdateRepaint(editor); - } - return 0; - } + case WM_CHAR: + return ME_Char(editor, wParam, lParam, unicode); case WM_UNICHAR: if (unicode) { @@ -3867,10 +3963,11 @@ if(wParam > 0xffff) /* convert to surrogates */ { wParam -= 0x10000; - SendMessageW(editor->hWnd, WM_CHAR, (wParam >> 10) + 0xd800, 0); - SendMessageW(editor->hWnd, WM_CHAR, (wParam & 0x03ff) + 0xdc00, 0); + ME_Char(editor, (wParam >> 10) + 0xd800, 0, TRUE); + ME_Char(editor, (wParam & 0x03ff) + 0xdc00, 0, TRUE); + } else { + ME_Char(editor, wParam, 0, TRUE); } - else SendMessageW(editor->hWnd, WM_CHAR, wParam, 0); } return 0; } @@ -3936,6 +4033,8 @@ case EM_GETRECT: { *((RECT *)lParam) = editor->rcFormat; + if (editor->bDefaultFormatRect) + ((RECT *)lParam)->left -= editor->selofs; return 0; } case EM_SETRECT: @@ -3943,23 +4042,36 @@ { if (lParam) { + DWORD exstyle = GetWindowLongW(editor->hWnd, GWL_EXSTYLE); + int border = (exstyle & WS_EX_CLIENTEDGE) ? 1 : 0; + RECT clientRect; RECT *rc = (RECT *)lParam; - - if (wParam) + + GetClientRect(editor->hWnd, &clientRect); + if (wParam == 0) { - editor->rcFormat.left += rc->left; - editor->rcFormat.top += rc->top; - editor->rcFormat.right += rc->right; - editor->rcFormat.bottom += rc->bottom; - } - else - { - editor->rcFormat = *rc; - } + editor->rcFormat.top = max(0, rc->top - border); + editor->rcFormat.left = max(0, rc->left - border); + editor->rcFormat.bottom = min(clientRect.bottom, rc->bottom); + editor->rcFormat.right = min(clientRect.right, rc->right + border); + } else if (wParam == 1) { + /* MSDN incorrectly says a wParam value of 1 causes the + * lParam rect to be used as a relative offset, + * however, the tests show it just prevents min/max bound + * checking. */ + editor->rcFormat.top = rc->top - border; + editor->rcFormat.left = rc->left - border; + editor->rcFormat.bottom = rc->bottom; + editor->rcFormat.right = rc->right + border; + } else { + return 0; + } + editor->bDefaultFormatRect = FALSE; } else { - GetClientRect(hWnd, &editor->rcFormat); + ME_SetDefaultFormatRect(editor); + editor->bDefaultFormatRect = TRUE; } if (msg != EM_SETRECTNP) ME_RewrapRepaint(editor); @@ -3969,12 +4081,21 @@ ME_SendRequestResize(editor, TRUE); return 0; case WM_SETREDRAW: - return DefWindowProcW(hWnd, msg, wParam, lParam); + goto do_default; case WM_SIZE: { - GetClientRect(hWnd, &editor->rcFormat); + RECT clientRect; + + GetClientRect(editor->hWnd, &clientRect); + if (editor->bDefaultFormatRect) { + ME_SetDefaultFormatRect(editor); + } else { + editor->rcFormat.right += clientRect.right - editor->prevClientRect.right; + editor->rcFormat.bottom += clientRect.bottom - editor->prevClientRect.bottom; + } + editor->prevClientRect = clientRect; ME_RewrapRepaint(editor); - return DefWindowProcW(hWnd, msg, wParam, lParam); + goto do_default; } /* IME messages to make richedit controls IME aware */ case WM_IME_SETCONTEXT: @@ -3995,7 +4116,7 @@ HIMC hIMC; ME_Style *style = ME_GetInsertStyle(editor, 0); - hIMC = ImmGetContext(hWnd); + hIMC = ImmGetContext(editor->hWnd); ME_DeleteSelection(editor); ME_CommitUndo(editor); ME_SaveTempStyle(editor); @@ -4064,7 +4185,12 @@ LRESULT ret; int mask = 0; int changes = 0; - ret = RichEditWndProc_common(hWnd, WM_GETTEXTLENGTH, 0, 0, unicode); + GETTEXTLENGTHEX how; + + /* CR/LF conversion required in 2.0 mode, verbatim in 1.0 mode */ + how.flags = GTL_CLOSE | (editor->bEmulateVersion10 ? 0 : GTL_USECRLF) | GTL_NUMCHARS; + how.codepage = unicode ? 1200 : CP_ACP; + ret = ME_GetTextLengthEx(editor, &how); if (!ret) { /*Check for valid wParam*/ @@ -4106,7 +4232,8 @@ break; default: do_default: - return DefWindowProcW(hWnd, msg, wParam, lParam); + *phresult = S_FALSE; + break; } return 0L; } @@ -4148,7 +4275,9 @@ { ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(hWnd, 0); + TRACE("Emulating version 1.0 (hWnd=%p)\n", hWnd); editor->bEmulateVersion10 = TRUE; + editor->bWordWrap = (GetWindowLongW(hWnd, GWL_STYLE) & ES_AUTOHSCROLL) ? FALSE : TRUE; editor->pBuffer->pLast->member.para.nCharOfs = 2; assert(editor->pBuffer->pLast->prev->type == diRun); assert(editor->pBuffer->pLast->prev->member.run.nFlags & MERF_ENDPARA); @@ -4329,7 +4458,7 @@ wcW.hInstance = NULL; /* hInstance would register DLL-local class */ wcW.hIcon = NULL; wcW.hCursor = LoadCursorW(NULL, MAKEINTRESOURCEW(IDC_IBEAM)); - wcW.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); + wcW.hbrBackground = GetStockObject(NULL_BRUSH); wcW.lpszMenuName = NULL; if (is_version_nt()) @@ -4355,7 +4484,7 @@ wcA.hInstance = NULL; /* hInstance would register DLL-local class */ wcA.hIcon = NULL; wcA.hCursor = LoadCursorW(NULL, MAKEINTRESOURCEW(IDC_IBEAM)); - wcA.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); + wcA.hbrBackground = GetStockObject(NULL_BRUSH); wcA.lpszMenuName = NULL; wcA.lpszClassName = "RichEdit20A"; if (!RegisterClassA(&wcA)) return FALSE; @@ -4424,95 +4553,6 @@ return result; } - -int ME_AutoURLDetect(ME_TextEditor *editor, WCHAR curChar) -{ - struct prefix_s { - const char *text; - int length; - } prefixes[12] = { - {"http:", 5}, - {"file:", 6}, - {"mailto:", 8}, - {"ftp:", 5}, - {"https:", 7}, - {"gopher:", 8}, - {"nntp:", 6}, - {"prospero:", 10}, - {"telnet:", 8}, - {"news:", 6}, - {"wais:", 6}, - {"www.", 5} - }; - CHARRANGE ins_pt; - int curf_ef, link_ef, def_ef; - int cur_prefx, prefx_cnt; - int sel_min, sel_max; - int car_pos = 0; - int text_pos=-1; - int URLmin, URLmax = 0; - FINDTEXTA ft; - CHARFORMAT2W cur_format; - CHARFORMAT2W default_format; - CHARFORMAT2W link; - RichEditANSIWndProc(editor->hWnd, EM_EXGETSEL, (WPARAM) 0, (LPARAM) &ins_pt); - sel_min = ins_pt.cpMin; - sel_max = ins_pt.cpMax; - if (sel_min==sel_max) - car_pos = sel_min; - if (sel_min!=sel_max) - car_pos = ME_GetTextLength(editor)+1; - cur_format.cbSize = sizeof(cur_format); - default_format.cbSize = sizeof(default_format); - RichEditANSIWndProc(editor->hWnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM) &cur_format); - RichEditANSIWndProc(editor->hWnd, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM) &default_format); - link.cbSize = sizeof(link); - link.dwMask = CFM_LINK; - link.dwEffects = CFE_LINK; - curf_ef = cur_format.dwEffects & link.dwEffects; - def_ef = default_format.dwEffects & link.dwEffects; - link_ef = link.dwEffects & link.dwEffects; - if (curf_ef == link_ef) - { - if( curChar == '\n' || curChar=='\r' || curChar==' ') - { - ME_SetSelection(editor, car_pos, car_pos); - RichEditANSIWndProc(editor->hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &default_format); - text_pos=-1; - return 0; - } - } - if (curf_ef == def_ef) - { - cur_prefx = 0; - prefx_cnt = (sizeof(prefixes)/sizeof(struct prefix_s))-1; - while (cur_prefx<=prefx_cnt) - { - if (text_pos == -1) - { - ft.lpstrText = prefixes[cur_prefx].text; - URLmin=max(0,(car_pos-prefixes[cur_prefx].length)); - URLmax=max(0, car_pos); - if ((car_pos == 0) && (ME_GetTextLength(editor) != 0)) - { - URLmax = ME_GetTextLength(editor)+1; - } - ft.chrg.cpMin = URLmin; - ft.chrg.cpMax = URLmax; - text_pos=RichEditANSIWndProc(editor->hWnd, EM_FINDTEXT, FR_DOWN, (LPARAM)&ft); - cur_prefx++; - } - if (text_pos != -1) - { - ME_SetCharFormat(editor, text_pos, (URLmax-text_pos), &link); - ME_RewrapRepaint(editor); - break; - } - } - } - return 0; -} - static BOOL isurlspecial(WCHAR c) { @@ -4647,7 +4687,7 @@ }; LPWSTR bufferW = NULL; WCHAR bufW[32]; - int i; + unsigned int i; if (sel_max == -1) sel_max = ME_GetTextLength(editor); assert(sel_min <= sel_max); @@ -4655,9 +4695,9 @@ { if (sel_max - sel_min < prefixes[i].length) continue; if (bufferW == NULL) { - bufferW = (LPWSTR)heap_alloc((sel_max - sel_min + 1) * sizeof(WCHAR)); - } - ME_GetTextW(editor, bufferW, sel_min, min(sel_max - sel_min, strlen(prefixes[i].text)), 0); + bufferW = heap_alloc((sel_max - sel_min + 1) * sizeof(WCHAR)); + } + ME_GetTextW(editor, bufferW, sel_min, min(sel_max - sel_min, lstrlenA(prefixes[i].text)), 0); MultiByteToWideChar(CP_ACP, 0, prefixes[i].text, -1, bufW, 32); if (!lstrcmpW(bufW, bufferW)) { Modified: trunk/reactos/dll/win32/riched20/editor.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/editor.…
============================================================================== --- trunk/reactos/dll/win32/riched20/editor.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/editor.h [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -268,11 +268,11 @@ void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src); void ME_DeleteReObject(REOBJECT* reo); -/* wintest.c */ - /* editor.c */ ME_TextEditor *ME_MakeEditor(HWND hWnd); void ME_DestroyEditor(ME_TextEditor *editor); +LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, + LPARAM lParam, BOOL unicode, HRESULT* phresult); void ME_SendOldNotify(ME_TextEditor *editor, int nCode); void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam); int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, BOOL bCRLF); @@ -282,7 +282,6 @@ void ME_RTFTblAttrHook(struct _RTF_Info *info); void ME_RTFSpecialCharHook(struct _RTF_Info *info); void ME_StreamInFill(ME_InStream *stream); -int ME_AutoURLDetect(ME_TextEditor *editor, WCHAR curChar); extern int me_debug; extern void DoWrap(ME_TextEditor *editor); extern BOOL ME_FindNextURLCandidate(ME_TextEditor *editor, int sel_min, int sel_max, Modified: trunk/reactos/dll/win32/riched20/editstr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/editstr…
============================================================================== --- trunk/reactos/dll/win32/riched20/editstr.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/editstr.h [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -90,7 +90,7 @@ diUndoPotentialEndTransaction, /* 20 - allows grouping typed chars for undo */ } ME_DIType; -#define SELECTIONBAR_WIDTH 9 +#define SELECTIONBAR_WIDTH 8 /******************************** run flags *************************/ #define MERF_STYLEFLAGS 0x0FFF @@ -333,7 +333,6 @@ int nCursors; SIZE sizeWindow; int nTotalLength, nLastTotalLength; - int nHeight; int nUDArrowX; int nSequence; COLORREF rgbBackColor; @@ -350,7 +349,9 @@ ME_DisplayItem *pLastSelStartPara, *pLastSelEndPara; ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE]; int nZoomNumerator, nZoomDenominator; + RECT prevClientRect; RECT rcFormat; + BOOL bDefaultFormatRect; BOOL bWordWrap; int nInvalidOfs; int nTextLimit; Modified: trunk/reactos/dll/win32/riched20/paint.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/paint.c…
============================================================================== --- trunk/reactos/dll/win32/riched20/paint.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/paint.c [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -23,10 +23,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit); -void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *rcUpdate) { +void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *rcUpdate) +{ ME_DisplayItem *item; ME_Context c; int yoffset; + int ys, ye; editor->nSequence++; yoffset = ME_GetYScrollPos(editor); @@ -34,105 +36,70 @@ SetBkMode(hDC, TRANSPARENT); ME_MoveCaret(editor); /* Calls ME_WrapMarkedParagraphs */ item = editor->pBuffer->pFirst->next; - c.pt.y -= yoffset; - while(item != editor->pBuffer->pLast) { - int yTextOffset = 0; - int ye; + /* This context point is an offset for the paragraph positions stored + * during wrapping. It shouldn't be modified during painting. */ + c.pt.x = c.rcView.left; + c.pt.y = c.rcView.top - yoffset; + while(item != editor->pBuffer->pLast) + { assert(item->type == diParagraph); + + ys = c.pt.y + item->member.para.pt.y; if (item->member.para.pCell != item->member.para.next_para->member.para.pCell) { ME_Cell *cell = NULL; cell = &ME_FindItemBack(item->member.para.next_para, diCell)->member.cell; - ye = cell->pt.y + cell->nHeight - yoffset; + ye = c.pt.y + cell->pt.y + cell->nHeight; } else { - ye = c.pt.y + item->member.para.nHeight; - } - if (!(item->member.para.nFlags & MEPF_ROWEND) && + ye = ys + item->member.para.nHeight; + } + if (item->member.para.pCell && !(item->member.para.nFlags & MEPF_ROWEND) && item->member.para.pCell != item->member.para.prev_para->member.para.pCell) { - ME_DisplayItem *cell; - if (item->member.para.prev_para->member.para.nFlags & MEPF_ROWSTART) - cell = item->member.para.pCell; - else - cell = item->member.para.prev_para->member.para.pCell; - assert(cell); /* the border shifts the text down */ - yTextOffset = cell->member.cell.yTextOffset; - ye += yTextOffset; - } + ys -= item->member.para.pCell->member.cell.yTextOffset; + } + if (!bOnlyNew || (item->member.para.nFlags & MEPF_REPAINT)) { + /* Draw the pargraph if any of the paragraph is in the update region. */ BOOL bPaint = (rcUpdate == NULL); if (rcUpdate) - bPaint = c.pt.y<rcUpdate->bottom && ye>rcUpdate->top; + bPaint = ys < rcUpdate->bottom && ye > rcUpdate->top; if (bPaint) { - c.pt.y += yTextOffset; ME_DrawParagraph(&c, item); - if (!rcUpdate || (rcUpdate->top<=c.pt.y-yTextOffset && rcUpdate->bottom>=ye)) + /* Clear the repaint flag if the whole paragraph is in the + * update region. */ + if (!rcUpdate || (rcUpdate->top <= ys && rcUpdate->bottom >= ye)) item->member.para.nFlags &= ~MEPF_REPAINT; } } - if (item->member.para.pCell) - { - ME_Cell *cell = &item->member.para.pCell->member.cell; - ME_DisplayItem *next_para = item->member.para.next_para; - c.pt.x = cell->pt.x + cell->nWidth; - if (item->member.para.pCell == next_para->member.para.pCell && - !(next_para->member.para.nFlags & (MEPF_ROWSTART|MEPF_ROWEND))) - { - c.pt.y = ye; - } else { - if (next_para->member.para.nFlags & MEPF_ROWSTART) - { - cell = &ME_FindItemFwd(next_para, diCell)->member.cell; - } - else if (next_para->member.para.nFlags & MEPF_ROWEND) - { - cell = &cell->next_cell->member.cell; - } - else - { - cell = &next_para->member.para.pCell->member.cell; - } - c.pt.y = cell->pt.y - yoffset; - } - } else if (!(item->member.para.nFlags & MEPF_ROWSTART)) { - c.pt.y = ye; - } item = item->member.para.next_para; } - if (c.pt.y<c.rcView.bottom) { + if (c.pt.y + editor->nTotalLength < c.rcView.bottom) + { + /* Fill space after the end of the text. */ RECT rc; - int xs = c.rcView.left, xe = c.rcView.right; - int ys = c.pt.y, ye = c.rcView.bottom; - + rc.top = c.pt.y + editor->nTotalLength; + rc.left = c.rcView.left; + rc.bottom = c.rcView.bottom; + rc.right = c.rcView.right; + if (bOnlyNew) { - int y1 = editor->nTotalLength-yoffset, y2 = editor->nLastTotalLength-yoffset; - if (y1<y2) - ys = y1, ye = y2+1; + /* Only erase region drawn from previous call to ME_PaintContent */ + if (editor->nTotalLength < editor->nLastTotalLength) + rc.bottom = c.pt.y + editor->nLastTotalLength; else - ys = ye; - } - - if (rcUpdate && ys!=ye) - { - xs = rcUpdate->left, xe = rcUpdate->right; - if (rcUpdate->top > ys) - ys = rcUpdate->top; - if (rcUpdate->bottom < ye) - ye = rcUpdate->bottom; - } - - if (ye>ys) { - rc.left = xs; - rc.top = ys; - rc.right = xe; - rc.bottom = ye; + SetRectEmpty(&rc); + } + + IntersectRect(&rc, &rc, rcUpdate); + + if (!IsRectEmpty(&rc)) FillRect(hDC, &rc, c.editor->hbrBackground); - } } if (editor->nTotalLength != editor->nLastTotalLength) ME_SendRequestResize(editor, FALSE); @@ -441,7 +408,7 @@ if (runofs >= nSelFrom && runofs < nSelTo) { ME_HighlightSpace(c, x, y, wszSpace, 1, run->style, 0, 0, 1, - c->pt.y + start->member.row.pt.y, + c->pt.y + para->pt.y + start->member.row.pt.y, start->member.row.nHeight); } return; @@ -452,8 +419,8 @@ /* wszSpace is used instead of the tab character because otherwise * an unwanted symbol can be inserted instead. */ ME_DrawTextWithStyle(c, x, y, wszSpace, 1, run->style, run->nWidth, - nSelFrom-runofs,nSelTo-runofs, - c->pt.y + start->member.row.pt.y, + nSelFrom-runofs, nSelTo-runofs, + c->pt.y + para->pt.y + start->member.row.pt.y, start->member.row.nHeight); return; } @@ -467,13 +434,17 @@ ME_String *szMasked = ME_MakeStringR(c->editor->cPasswordMask,ME_StrVLen(run->strText)); ME_DrawTextWithStyle(c, x, y, szMasked->szData, ME_StrVLen(szMasked), run->style, run->nWidth, - nSelFrom-runofs,nSelTo-runofs, c->pt.y+start->member.row.pt.y, start->member.row.nHeight); + nSelFrom-runofs,nSelTo-runofs, + c->pt.y + para->pt.y + start->member.row.pt.y, + start->member.row.nHeight); ME_DestroyString(szMasked); } else ME_DrawTextWithStyle(c, x, y, run->strText->szData, ME_StrVLen(run->strText), run->style, run->nWidth, - nSelFrom-runofs,nSelTo-runofs, c->pt.y+start->member.row.pt.y, start->member.row.nHeight); + nSelFrom-runofs,nSelTo-runofs, + c->pt.y + para->pt.y + start->member.row.pt.y, + start->member.row.nHeight); } } @@ -728,11 +699,11 @@ int width; BOOL atTop = (para->pCell != para->prev_para->member.para.pCell); BOOL atBottom = (para->pCell != para->next_para->member.para.pCell); - int top = (atTop ? cell->pt.y : para->pt.y) - ME_GetYScrollPos(c->editor); + int top = c->pt.y + (atTop ? cell->pt.y : para->pt.y); int bottom = (atBottom ? - cell->pt.y + cell->nHeight - ME_GetYScrollPos(c->editor): + c->pt.y + cell->pt.y + cell->nHeight : top + para->nHeight + (atTop ? cell->yTextOffset : 0)); - rc.left = cell->pt.x; + rc.left = c->pt.x + cell->pt.x; rc.right = rc.left + cell->nWidth; if (atTop) { /* Erase gap before text if not all borders are the same height. */ @@ -745,7 +716,7 @@ } } /* Draw cell borders. - * The borders borders are draw in is left, top, bottom, right in order + * The order borders are draw in is left, top, bottom, right in order * to be consistent with native richedit. This is noticeable from the * overlap of borders of different colours. */ if (!(para->nFlags & MEPF_ROWEND)) { @@ -798,10 +769,10 @@ ME_DisplayItem *nextEndCell; nextEndCell = ME_FindItemBack(ME_GetTableRowEnd(paraAfterRow), diCell); assert(nextEndCell && !nextEndCell->member.cell.next_cell); - rc.left = nextEndCell->member.cell.pt.x; + rc.left = c->pt.x + nextEndCell->member.cell.pt.x; /* FIXME: Native draws FROM the bottom of the table rather than * TO the bottom of the table in this case, but just doing so here - * will case the next row to erase the border. */ + * will cause the next row to erase the border. */ /* rc.top = bottom; rc.bottom = rc.top + width; @@ -860,12 +831,12 @@ oldpen = SelectObject(c->hDC, pen); /* Find the start relative to the text */ - firstX = ME_FindItemFwd(paragraph, diRun)->member.run.pt.x; + firstX = c->pt.x + ME_FindItemFwd(paragraph, diRun)->member.run.pt.x; /* Go back by the horizontal gap, which is stored in dxOffset */ firstX -= ME_twips2pointsX(c, para->pFmt->dxOffset); /* The left edge, stored in dxStartIndent affected just the first edge */ startX = firstX - ME_twips2pointsX(c, para->pFmt->dxStartIndent); - rowY = c->pt.y; + rowY = c->pt.y + para->pt.y; if (para->pFmt->dwMask & PFM_SPACEBEFORE) rowY += ME_twips2pointsY(c, para->pFmt->dySpaceBefore); nHeight = ME_FindItemFwd(paragraph, diStartRow)->member.row.nHeight; @@ -907,53 +878,54 @@ } } -void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) { +void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) +{ int align = SetTextAlign(c->hDC, TA_BASELINE); ME_DisplayItem *p; ME_Run *run; ME_Paragraph *para = NULL; RECT rc, bounds; - int y = c->pt.y; + int y; int height = 0, baseline = 0, no=0; BOOL visible = FALSE; - c->pt.x = c->rcView.left; - rc.left = c->rcView.left; + rc.left = c->pt.x; rc.right = c->rcView.right; - for (p = paragraph; p!=paragraph->member.para.next_para; p = p->next) { + + assert(paragraph); + para = ¶graph->member.para; + y = c->pt.y + para->pt.y; + if (para->pCell) + { + ME_Cell *cell = ¶->pCell->member.cell; + rc.left = c->pt.x + cell->pt.x; + rc.right = rc.left + cell->nWidth; + } + if (para->nFlags & MEPF_ROWSTART) { + ME_Cell *cell = ¶->next_para->member.para.pCell->member.cell; + rc.right = c->pt.x + cell->pt.x; + } else if (para->nFlags & MEPF_ROWEND) { + ME_Cell *cell = ¶->prev_para->member.para.pCell->member.cell; + rc.left = c->pt.x + cell->pt.x + cell->nWidth; + } + ME_DrawParaDecoration(c, para, y, &bounds); + y += bounds.top; + rc.left += bounds.left; + rc.right -= bounds.right; + + for (p = paragraph->next; p != para->next_para; p = p->next) + { switch(p->type) { case diParagraph: - para = &p->member.para; - assert(para); - if (para->pCell) - { - ME_Cell *cell = ¶->pCell->member.cell; - rc.left = cell->pt.x; - rc.right = rc.left + cell->nWidth; - } - if (para->nFlags & MEPF_ROWSTART) { - ME_Cell *cell = ¶->next_para->member.para.pCell->member.cell; - rc.right = cell->pt.x; - } else if (para->nFlags & MEPF_ROWEND) { - ME_Cell *cell = ¶->prev_para->member.para.pCell->member.cell; - rc.left = cell->pt.x + cell->nWidth; - } - ME_DrawParaDecoration(c, para, y, &bounds); - y += bounds.top; + assert(FALSE); break; case diStartRow: - /* we should have seen a diParagraph before */ - assert(para); y += height; rc.top = y; - if (para->nFlags & MEPF_ROWSTART) { - ME_Cell *cell = ¶->next_para->member.para.pCell->member.cell; - rc.bottom = y + cell->nHeight; - } else if (para->nFlags & MEPF_ROWEND) { - ME_Cell *cell = ¶->prev_para->member.para.pCell->member.cell; - rc.bottom = y + cell->nHeight; + if (para->nFlags & (MEPF_ROWSTART|MEPF_ROWEND)) { + rc.bottom = y + para->nHeight; } else { - rc.bottom = y+p->member.row.nHeight; + rc.bottom = y + p->member.row.nHeight; } visible = RectVisible(c->hDC, &rc); if (visible) { @@ -976,10 +948,11 @@ assert(para); run = &p->member.run; if (visible && me_debug) { - rc.left = c->rcView.left+run->pt.x; - rc.right = c->rcView.left+run->pt.x+run->nWidth; - rc.top = c->pt.y+run->pt.y; - rc.bottom = c->pt.y+run->pt.y+height; + RECT rc; + rc.left = c->pt.x + run->pt.x; + rc.right = rc.left + run->nWidth; + rc.top = c->pt.y + para->pt.y + run->pt.y; + rc.bottom = rc.bottom + height; TRACE("rc = (%d, %d, %d, %d)\n", rc.left, rc.top, rc.right, rc.bottom); if (run->nFlags & MERF_SKIPPED) DrawFocusRect(c->hDC, &rc); @@ -987,28 +960,27 @@ FrameRect(c->hDC, &rc, GetSysColorBrush(COLOR_GRAYTEXT)); } if (visible) - ME_DrawRun(c, run->pt.x, c->pt.y+run->pt.y+baseline, p, ¶graph->member.para); + ME_DrawRun(c, c->pt.x + run->pt.x, + c->pt.y + para->pt.y + run->pt.y + baseline, p, para); if (me_debug) { /* I'm using %ls, hope wsprintfW is not going to use wrong (4-byte) WCHAR version */ const WCHAR wszRunDebug[] = {'[','%','d',':','%','x',']',' ','%','l','s',0}; WCHAR buf[2560]; POINT pt; - pt.x = run->pt.x; - pt.y = c->pt.y + run->pt.y; + pt.x = c->pt.x + run->pt.x; + pt.y = c->pt.y + para->pt.y + run->pt.y; wsprintfW(buf, wszRunDebug, no, p->member.run.nFlags, p->member.run.strText->szData); ME_DebugWrite(c->hDC, &pt, buf); } - /* c->pt.x += p->member.run.nWidth; */ break; case diCell: /* Clear any space at the bottom of the cell after the text. */ - if (para->nFlags & MEPF_ROWSTART) + if (para->nFlags & (MEPF_ROWSTART|MEPF_ROWEND)) break; y += height; - rc.top = y; - rc.bottom = p->member.cell.pt.y + p->member.cell.nHeight - - ME_GetYScrollPos(c->editor); + rc.top = c->pt.y + para->pt.y + para->nHeight; + rc.bottom = c->pt.y + p->member.cell.pt.y + p->member.cell.nHeight; if (RectVisible(c->hDC, &rc)) { FillRect(c->hDC, &rc, c->editor->hbrBackground); @@ -1084,7 +1056,7 @@ hWnd = editor->hWnd; winStyle = GetWindowLongW(hWnd, GWL_STYLE); bScrollBarIsVisible = (winStyle & WS_VSCROLL) != 0; - bScrollBarWillBeVisible = (editor->nHeight > editor->sizeWindow.cy) + bScrollBarWillBeVisible = (editor->nTotalLength > editor->sizeWindow.cy) || (winStyle & ES_DISABLENOSCROLL); if (bScrollBarIsVisible != bScrollBarWillBeVisible) { @@ -1110,7 +1082,7 @@ hWnd = editor->hWnd; si.cbSize = sizeof(si); bScrollBarWasVisible = ME_GetYScrollVisible(editor); - bScrollBarWillBeVisible = editor->nHeight > editor->sizeWindow.cy; + bScrollBarWillBeVisible = editor->nTotalLength > editor->sizeWindow.cy; si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL) Modified: trunk/reactos/dll/win32/riched20/para.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/para.c?…
============================================================================== --- trunk/reactos/dll/win32/riched20/para.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/para.c [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -38,7 +38,7 @@ ME_InitContext(&c, editor, GetDC(editor->hWnd)); - hf = (HFONT)GetStockObject(SYSTEM_FONT); + hf = GetStockObject(SYSTEM_FONT); assert(hf); GetObjectW(hf, sizeof(LOGFONTW), &lf); ZeroMemory(&cf, sizeof(cf)); Modified: trunk/reactos/dll/win32/riched20/reader.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/reader.…
============================================================================== --- trunk/reactos/dll/win32/riched20/reader.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/reader.c [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -673,7 +673,7 @@ } /* escaped char */ - /*if (index (":{}\\", c) != (char *) NULL)*/ /* escaped char */ + /*if (index (":{}\\", c) != NULL)*/ /* escaped char */ if (c == ':' || c == '{' || c == '}' || c == '\\') { info->rtfClass = rtfText; @@ -2289,7 +2289,7 @@ { rtfVersion, -1, "rtf", 0 }, { rtfDefFont, -1, "deff", 0 }, - { 0, -1, (char *) NULL, 0 } + { 0, -1, NULL, 0 } }; #define RTF_KEY_COUNT (sizeof(rtfKey) / sizeof(RTFKey)) @@ -2326,7 +2326,7 @@ void LookupCleanup(void) { - int i; + unsigned int i; for (i=0; i<RTF_KEY_COUNT*2; i++) { Modified: trunk/reactos/dll/win32/riched20/rtf.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/rtf.h?r…
============================================================================== --- trunk/reactos/dll/win32/riched20/rtf.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/rtf.h [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -1157,9 +1157,6 @@ ME_InStream *stream; - /* edit window to output to */ - HWND hwndEdit; - ME_TextEditor *editor; ME_Style *style; Modified: trunk/reactos/dll/win32/riched20/run.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/run.c?r…
============================================================================== --- trunk/reactos/dll/win32/riched20/run.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/run.c [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -692,7 +692,7 @@ { pos += lDefaultTab - (pos % lDefaultTab); } - ppos = ME_twips2pointsX(c, pos) + c->editor->selofs; + ppos = ME_twips2pointsX(c, pos); if (ppos > startx + run->pt.x) { size.cx = ppos - startx - run->pt.x; break; @@ -813,7 +813,7 @@ undo->nStart = tmp.pRun->member.run.nCharOfs+para->member.para.nCharOfs; undo->nLen = tmp.pRun->member.run.strText->nLen; undo->di.member.ustyle = tmp.pRun->member.run.style; - /* we'd have to addref undo..ustyle and release tmp...style + /* we'd have to addref undo...ustyle and release tmp...style but they'd cancel each other out so we can do nothing instead */ } else @@ -872,8 +872,6 @@ */ void ME_GetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) { - int nFrom, nTo; - ME_GetSelection(editor, &nFrom, &nTo); ME_CopyCharFormat(pFmt, &editor->pBuffer->pDefaultStyle->fmt); } Modified: trunk/reactos/dll/win32/riched20/string.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/string.…
============================================================================== --- trunk/reactos/dll/win32/riched20/string.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/string.c [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -342,7 +342,7 @@ int result; int buffer_size = WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen, NULL, 0, NULL, NULL); - char *buffer = (char*)heap_alloc(buffer_size); + char *buffer = heap_alloc(buffer_size); WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen, buffer, buffer_size, NULL, NULL); result = editor->pfnWordBreak(str->szData, start, str->nLen, code); Modified: trunk/reactos/dll/win32/riched20/wrap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/wrap.c?…
============================================================================== --- trunk/reactos/dll/win32/riched20/wrap.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/wrap.c [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -78,8 +78,7 @@ wc->bWordWrap = TRUE; } else { wc->nAvailWidth = wc->context->rcView.right - wc->context->rcView.left - - (wc->nRow ? wc->nLeftMargin : wc->nFirstMargin) - wc->nRightMargin - - wc->context->editor->selofs; + - (wc->nRow ? wc->nLeftMargin : wc->nFirstMargin) - wc->nRightMargin; } wc->pt.x = wc->context->pt.x; if (wc->context->editor->bEmulateVersion10 && /* v1.0 - 3.0 */ @@ -458,7 +457,7 @@ static void ME_PrepareParagraphForWrapping(ME_Context *c, ME_DisplayItem *tp); -static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD beginofs) { +static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) { ME_DisplayItem *p; ME_WrapContext wc; int border = 0; @@ -573,28 +572,26 @@ } } -BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) { +BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) +{ ME_DisplayItem *item; ME_Context c; BOOL bModified = FALSE; int yStart = -1; - int yLastPos = 0; ME_InitContext(&c, editor, GetDC(editor->hWnd)); - c.pt.x = editor->selofs; - editor->nHeight = 0; + c.pt.x = 0; item = editor->pBuffer->pFirst->next; while(item != editor->pBuffer->pLast) { BOOL bRedraw = FALSE; assert(item->type == diParagraph); - editor->nHeight = max(editor->nHeight, item->member.para.pt.y); if ((item->member.para.nFlags & MEPF_REWRAP) || (item->member.para.pt.y != c.pt.y)) bRedraw = TRUE; item->member.para.pt = c.pt; - ME_WrapTextParagraph(&c, item, editor->selofs); + ME_WrapTextParagraph(&c, item); if (bRedraw) { @@ -604,8 +601,6 @@ } bModified = bModified | bRedraw; - - yLastPos = max(yLastPos, c.pt.y); if (item->member.para.nFlags & MEPF_ROWSTART) { @@ -698,7 +693,8 @@ c.pt.x = cell->pt.x + cell->nWidth; c.pt.y = cell->pt.y; cell->next_cell->member.cell.pt = c.pt; - c.pt.y += cell->yTextOffset; + if (!(item->member.para.next_para->member.para.nFlags & MEPF_ROWEND)) + c.pt.y += cell->yTextOffset; } else { @@ -707,7 +703,7 @@ c.pt.x = item->member.para.pCell->member.cell.pt.x; } else { /* Normal paragraph */ - c.pt.x = editor->selofs; + c.pt.x = 0; } c.pt.y += item->member.para.nHeight; } @@ -718,17 +714,9 @@ editor->nTotalLength = c.pt.y; editor->pBuffer->pLast->member.para.pt.x = 0; - editor->pBuffer->pLast->member.para.pt.y = yLastPos; + editor->pBuffer->pLast->member.para.pt.y = c.pt.y; ME_DestroyContext(&c, editor->hWnd); - - /* Each paragraph may contain multiple rows, which should be scrollable, even - if the containing paragraph has pt.y == 0 */ - item = editor->pBuffer->pFirst; - while ((item = ME_FindItemFwd(item, diStartRow)) != NULL) { - assert(item->type == diStartRow); - editor->nHeight = max(editor->nHeight, item->member.row.pt.y); - } if (bModified || editor->nTotalLength < editor->nLastTotalLength) ME_InvalidateMarkedParagraphs(editor); @@ -749,16 +737,18 @@ item = editor->pBuffer->pFirst; while(item != editor->pBuffer->pLast) { if (item->member.para.nFlags & MEPF_REPAINT) { - rc.top = item->member.para.pt.y - ofs; - rc.bottom = item->member.para.pt.y + item->member.para.nHeight - ofs; + rc.top = c.rcView.top + item->member.para.pt.y - ofs; + rc.bottom = max(c.rcView.top + item->member.para.pt.y + + item->member.para.nHeight - ofs, + c.rcView.bottom); InvalidateRect(editor->hWnd, &rc, TRUE); } item = item->member.para.next_para; } if (editor->nTotalLength < editor->nLastTotalLength) { - rc.top = editor->nTotalLength - ofs; - rc.bottom = editor->nLastTotalLength - ofs; + rc.top = c.rcView.top + editor->nTotalLength - ofs; + rc.bottom = c.rcView.top + editor->nLastTotalLength - ofs; InvalidateRect(editor->hWnd, &rc, TRUE); } ME_DestroyContext(&c, editor->hWnd); Modified: trunk/reactos/dll/win32/riched20/writer.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/writer.…
============================================================================== --- trunk/reactos/dll/win32/riched20/writer.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/riched20/writer.c [iso-8859-1] Sat Dec 27 02:49:35 2008 @@ -201,7 +201,7 @@ { ME_DisplayItem *item = pFirstRun; ME_FontTableItem *table = pStream->fonttbl; - int i; + unsigned int i; ME_DisplayItem *pLastPara = ME_GetParagraph(pLastRun); ME_DisplayItem *pCell = NULL; @@ -264,7 +264,7 @@ { if (borders[i]->width > 0) { - int j; + unsigned int j; COLORREF crColor = borders[i]->colorRef; for (j = 1; j < pStream->nColorTblLen; j++) if (pStream->colortbl[j] == crColor) @@ -348,7 +348,7 @@ { if (borders[i]->width) { - int j; + unsigned int j; COLORREF crColor = borders[i]->colorRef; sprintf(props + strlen(props), "\\clbrdr%c", sideChar[i]); sprintf(props + strlen(props), "\\brdrs"); @@ -380,7 +380,7 @@ { if (borders[i]->width) { - int j; + unsigned int j; COLORREF crColor = borders[i]->colorRef; sprintf(props + strlen(props), "\\trbrdr%c", sideChar[i]); sprintf(props + strlen(props), "\\brdrs"); @@ -555,7 +555,7 @@ ME_StreamOutRTFCharProps(ME_OutStream *pStream, CHARFORMAT2W *fmt) { char props[STREAMOUT_BUFFER_SIZE] = ""; - int i; + unsigned int i; if (fmt->dwMask & CFM_ALLCAPS && fmt->dwEffects & CFE_ALLCAPS) strcat(props, "\\caps");
15 years, 12 months
1
0
0
0
[cwittich] 38369: add EM_GETIMESTATUS and EM_SETIMESTATUS
by cwittich@svn.reactos.org
Author: cwittich Date: Sat Dec 27 02:38:03 2008 New Revision: 38369 URL:
http://svn.reactos.org/svn/reactos?rev=38369&view=rev
Log: add EM_GETIMESTATUS and EM_SETIMESTATUS Modified: trunk/reactos/include/psdk/winuser.h Modified: trunk/reactos/include/psdk/winuser.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winuser.h?rev…
============================================================================== --- trunk/reactos/include/psdk/winuser.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/winuser.h [iso-8859-1] Sat Dec 27 02:38:03 2008 @@ -1849,6 +1849,7 @@ #define EM_CHARFROMPOS 215 #define EM_EMPTYUNDOBUFFER 205 #define EM_FMTLINES 200 +#define EM_GETIMESTATUS 217 #define EM_GETFIRSTVISIBLELINE 206 #define EM_GETHANDLE 189 #define EM_GETLIMITTEXT 213 @@ -1871,6 +1872,7 @@ #define EM_SCROLL 181 #define EM_SCROLLCARET 183 #define EM_SETHANDLE 188 +#define EM_SETIMESTATUS 216 #define EM_SETLIMITTEXT 197 #define EM_SETMARGINS 211 #define EM_SETMODIFY 185
15 years, 12 months
1
0
0
0
[dchapyshev] 38368: - Partial sync with Wine. It fixes 37 tests ("kernel32_winetest profile")
by dchapyshev@svn.reactos.org
Author: dchapyshev Date: Sat Dec 27 02:34:30 2008 New Revision: 38368 URL:
http://svn.reactos.org/svn/reactos?rev=38368&view=rev
Log: - Partial sync with Wine. It fixes 37 tests ("kernel32_winetest profile") Modified: trunk/reactos/dll/win32/kernel32/misc/profile.c Modified: trunk/reactos/dll/win32/kernel32/misc/profile.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/pr…
============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/profile.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/profile.c [iso-8859-1] Sat Dec 27 02:34:30 2008 @@ -88,17 +88,18 @@ const WCHAR *end; for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) - return (WCHAR *)ptr; + return (WCHAR *)(ULONG_PTR)ptr; return NULL; } static __inline WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n ) { - const WCHAR *end, *ret = NULL; + const WCHAR *end; + WCHAR *ret = NULL; for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) - ret = ptr; - return (WCHAR *)ret; + ret = (WCHAR *)(ULONG_PTR)ptr; + return ret; } /*********************************************************************** @@ -139,7 +140,7 @@ static __inline void PROFILE_WriteMarker(HANDLE hFile, ENCODING encoding) { DWORD dwBytesWritten; - DWORD bom; + WCHAR bom; switch (encoding) { case ENCODING_ANSI: @@ -283,12 +284,8 @@ /* returns 1 if a character white space else 0 */ static __inline int PROFILE_isspaceW(WCHAR c) { - if (iswspace(c)) - return 1; - if (c=='\r' || c==0x1a) - return 1; - /* CR and ^Z (DOS EOF) are spaces too (found on CD-ROMs) */ - return 0; + /* ^Z (DOS EOF) is a space too (found on CD-ROMs) */ + return isspace(c) || c == 0x1a; } @@ -325,7 +322,7 @@ */ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) { - void *pBuffer; + void *buffer_base, *pBuffer; WCHAR * szFile; const WCHAR *szLineStart, *szLineEnd; const WCHAR *szValueStart, *szEnd, *next_line; @@ -341,22 +338,22 @@ if (dwFileSize == INVALID_FILE_SIZE) return NULL; - pBuffer = HeapAlloc(GetProcessHeap(), 0 , dwFileSize); - if (!pBuffer) + buffer_base = HeapAlloc(GetProcessHeap(), 0 , dwFileSize); + if (!buffer_base) return NULL; - if (!ReadFile(hFile, pBuffer, dwFileSize, &dwFileSize, NULL)) - { - HeapFree(GetProcessHeap(), 0, pBuffer); + if (!ReadFile(hFile, buffer_base, dwFileSize, &dwFileSize, NULL)) + { + HeapFree(GetProcessHeap(), 0, buffer_base); DPRINT("Error %ld reading file\n", GetLastError()); return NULL; } len = dwFileSize; - *pEncoding = PROFILE_DetectTextEncoding(pBuffer, &len); + *pEncoding = PROFILE_DetectTextEncoding(buffer_base, &len); /* len is set to the number of bytes in the character marker. * we want to skip these bytes */ - pBuffer = (char *)pBuffer + len; + pBuffer = (char *)buffer_base + len; dwFileSize -= len; switch (*pEncoding) { @@ -367,7 +364,7 @@ szFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!szFile) { - HeapFree(GetProcessHeap(), 0, pBuffer); + HeapFree(GetProcessHeap(), 0, buffer_base); return NULL; } MultiByteToWideChar(CP_ACP, 0, (char *)pBuffer, dwFileSize, szFile, len); @@ -381,7 +378,7 @@ szFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!szFile) { - HeapFree(GetProcessHeap(), 0, pBuffer); + HeapFree(GetProcessHeap(), 0, buffer_base); return NULL; } MultiByteToWideChar(CP_UTF8, 0, (char *)pBuffer, dwFileSize, szFile, len); @@ -390,20 +387,20 @@ case ENCODING_UTF16LE: DPRINT("UTF16 Little Endian encoding\n"); - szFile = (WCHAR *)pBuffer + 1; + szFile = (WCHAR *)pBuffer;// + 1; szEnd = (WCHAR *)((char *)pBuffer + dwFileSize); break; case ENCODING_UTF16BE: DPRINT("UTF16 Big Endian encoding\n"); - szFile = (WCHAR *)pBuffer + 1; + szFile = (WCHAR *)pBuffer;// + 1; szEnd = (WCHAR *)((char *)pBuffer + dwFileSize); PROFILE_ByteSwapShortBuffer(szFile, dwFileSize / sizeof(WCHAR)); break; default: DPRINT("encoding type %d not implemented\n", *pEncoding); - HeapFree(GetProcessHeap(), 0, pBuffer); + HeapFree(GetProcessHeap(), 0, buffer_base); return NULL; } @@ -412,7 +409,7 @@ { if (szFile != pBuffer) HeapFree(GetProcessHeap(), 0, szFile); - HeapFree(GetProcessHeap(), 0, pBuffer); + HeapFree(GetProcessHeap(), 0, buffer_base); return NULL; } first_section->name[0] = 0; @@ -427,6 +424,7 @@ { szLineStart = next_line; next_line = memchrW(szLineStart, '\n', szEnd - szLineStart); + if (!next_line) next_line = memchrW(szLineStart, '\r', szEnd - szLineStart); if (!next_line) next_line = szEnd; else next_line++; szLineEnd = next_line; @@ -435,7 +433,7 @@ /* get rid of white space */ while (szLineStart < szLineEnd && PROFILE_isspaceW(*szLineStart)) szLineStart++; - while ((szLineEnd > szLineStart) && ((szLineEnd[-1] == '\n') || (PROFILE_isspaceW(szLineEnd[-1]) && szLineEnd[-1] != ' '))) szLineEnd--; + while ((szLineEnd > szLineStart) && PROFILE_isspaceW(szLineEnd[-1])) szLineEnd--; if (szLineStart >= szLineEnd) continue; @@ -510,7 +508,7 @@ } if (szFile != pBuffer) HeapFree(GetProcessHeap(), 0, szFile); - HeapFree(GetProcessHeap(), 0, pBuffer); + HeapFree(GetProcessHeap(), 0, buffer_base); return first_section; } @@ -688,7 +686,8 @@ if (!CurProfile->changed) return TRUE; - hFile = CreateFileW(CurProfile->filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileW(CurProfile->filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { @@ -725,11 +724,32 @@ /*********************************************************************** + * + * Compares a file time with the current time. If the file time is + * at least 2.1 seconds in the past, return true. + * + * Intended as cache safety measure: The time resolution on FAT is + * two seconds, so files that are not at least two seconds old might + * keep their time even on modification, so don't cache them. + */ +static BOOL is_not_current(FILETIME * ft) +{ + FILETIME Now; + LONGLONG ftll, nowll; + GetSystemTimeAsFileTime(&Now); + ftll = ((LONGLONG)ft->dwHighDateTime << 32) + ft->dwLowDateTime; + nowll = ((LONGLONG)Now.dwHighDateTime << 32) + Now.dwLowDateTime; + DPRINT("%08x;%08x\n",(unsigned)ftll+21000000,(unsigned)nowll); + return ftll + 21000000 < nowll; +} + + +/*********************************************************************** * PROFILE_Open * * Open a profile file, checking the cached file first. */ -static BOOL PROFILE_Open( LPCWSTR filename ) +static BOOL PROFILE_Open( LPCWSTR filename, BOOL write_access ) { WCHAR windirW[MAX_PATH]; WCHAR buffer[MAX_PATH]; @@ -775,7 +795,9 @@ DPRINT("path: %S\n", buffer); - hFile = CreateFileW(buffer, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileW(buffer, GENERIC_READ | (write_access ? GENERIC_WRITE : 0), + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if ((hFile == INVALID_HANDLE_VALUE) && (GetLastError() != ERROR_FILE_NOT_FOUND)) { @@ -797,21 +819,21 @@ CurProfile=tempProfile; } if (hFile != INVALID_HANDLE_VALUE) + { GetFileTime(hFile, NULL, NULL, &LastWriteTime); - else - LastWriteTime.dwHighDateTime = LastWriteTime.dwLowDateTime = 0; - if (memcmp(&CurProfile->LastWriteTime, &LastWriteTime, sizeof(FILETIME))) - { - DPRINT("(%S): already opened (mru = %d)\n", - buffer, i ); - } - else - { - DPRINT("(%S): already opened, needs refreshing (mru = %d)\n", - buffer, i ); - } - if (hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); + if (!memcmp( &CurProfile->LastWriteTime, &LastWriteTime, sizeof(FILETIME) ) && + is_not_current(&LastWriteTime)) + DPRINT("(%S): already opened (mru=%d)\n", buffer, i); + else + { + DPRINT("(%S): already opened, needs refreshing (mru=%d)\n", buffer, i); + CurProfile->section = PROFILE_Load(hFile, &CurProfile->encoding); + CurProfile->LastWriteTime = LastWriteTime; + } + CloseHandle(hFile); + } + else DPRINT("(%S): already opened (mru = %d)\n", buffer, i ); + return TRUE; } } @@ -984,15 +1006,15 @@ PROFILEKEY *key = NULL; static const WCHAR empty_strW[] = { 0 }; - if (!buffer) return 0; + if (!buffer || !len) return 0; if (!def_val) def_val = empty_strW; if (key_name) { if (!key_name[0]) { - /* Win95 returns 0 on keyname "". Tested with Likse32 bon 000227 */ - return 0; + PROFILE_CopyEntry(buffer, def_val, len, TRUE); + return wcslen(buffer); } key = PROFILE_Find( &CurProfile->section, section, key_name, FALSE, FALSE); PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val, @@ -1112,7 +1134,7 @@ BOOL win32 ) { int ret; - LPCWSTR pDefVal = NULL; + LPWSTR defval_tmp = NULL; DPRINT("%S, %S, %S, %p, %u, %S\n", section, entry, @@ -1121,52 +1143,40 @@ /* strip any trailing ' ' of def_val. */ if (def_val) { - LPCWSTR p = &def_val[wcslen(def_val)]; /* even "" works ! */ - - while (p > def_val) - { + LPCWSTR p = def_val + wcslen(def_val) - 1; + + while (p > def_val && *p == ' ') p--; - if ((*p) != ' ') - break; - } - - if (*p == ' ') /* ouch, contained trailing ' ' */ - { - int len = (int)(p - def_val); - LPWSTR p; - - p = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); - if(p == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - memcpy(p, def_val, len * sizeof(WCHAR)); - p[len] = '\0'; - pDefVal = p; - } - } - - if (!pDefVal) - pDefVal = (LPCWSTR)def_val; + + if (p >= def_val) + { + int len = (int)(p - def_val) + 1; + + defval_tmp = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + memcpy(defval_tmp, def_val, len * sizeof(WCHAR)); + defval_tmp[len] = '\0'; + def_val = defval_tmp; + } + } RtlEnterCriticalSection( &PROFILE_CritSect ); - if (PROFILE_Open( filename )) { + if (PROFILE_Open( filename, FALSE )) { if (win32 && (section == NULL)) ret = PROFILE_GetSectionNames(buffer, len); else /* PROFILE_GetString can handle the 'entry == NULL' case */ - ret = PROFILE_GetString( section, entry, pDefVal, buffer, len, win32 ); - } else { - lstrcpynW( buffer, pDefVal, len ); + ret = PROFILE_GetString( section, entry, def_val, buffer, len, win32 ); + } else if (buffer && def_val) { + lstrcpynW( buffer, def_val, len ); ret = wcslen( buffer ); } + else + ret = 0; RtlLeaveCriticalSection( &PROFILE_CritSect ); - if (pDefVal != def_val) /* allocated */ - HeapFree(GetProcessHeap(), 0, (void*)pDefVal); + HeapFree(GetProcessHeap(), 0, defval_tmp); DPRINT("returning %S, %d\n", buffer, ret); @@ -1302,7 +1312,7 @@ return (UINT)def_val; RtlInitUnicodeString( &bufferW, buffer ); - RtlUnicodeStringToInteger( &bufferW, 10, &result); + RtlUnicodeStringToInteger( &bufferW, 0, &result); // 10 return result; } @@ -1350,7 +1360,7 @@ RtlEnterCriticalSection( &PROFILE_CritSect ); - if (PROFILE_Open( filename )) + if (PROFILE_Open( filename, FALSE )) ret = PROFILE_GetSection(CurProfile->section, section, buffer, len, TRUE, FALSE); RtlLeaveCriticalSection( &PROFILE_CritSect ); @@ -1434,12 +1444,12 @@ if (!section && !entry && !string) /* documented "file flush" case */ { - if (!filename || PROFILE_Open( filename )) + if (!filename || PROFILE_Open( filename, TRUE )) { if (CurProfile) PROFILE_ReleaseFile(); /* always return FALSE in this case */ } } - else if (PROFILE_Open( filename )) + else if (PROFILE_Open( filename, TRUE )) { if (!section) { DPRINT1("(NULL?, %S, %S, %S)?\n", @@ -1494,12 +1504,12 @@ if (!section && !string) { - if (!filename || PROFILE_Open( filename )) + if (!filename || PROFILE_Open( filename, TRUE )) { if (CurProfile) PROFILE_ReleaseFile(); /* always return FALSE in this case */ } } - else if (PROFILE_Open( filename )) { + else if (PROFILE_Open( filename, TRUE )) { if (!string) {/* delete the named section*/ ret = PROFILE_SetString(section,NULL,NULL, FALSE); PROFILE_FlushFile(); @@ -1628,7 +1638,7 @@ RtlEnterCriticalSection( &PROFILE_CritSect ); - if (PROFILE_Open( filename )) + if (PROFILE_Open( filename, FALSE )) ret = PROFILE_GetSectionNames(buffer, size); RtlLeaveCriticalSection( &PROFILE_CritSect ); @@ -1685,7 +1695,7 @@ RtlEnterCriticalSection( &PROFILE_CritSect ); - if (PROFILE_Open( filename )) + if (PROFILE_Open( filename, FALSE )) { PROFILEKEY *k = PROFILE_Find ( &CurProfile->section, section, key, FALSE, FALSE); if (k) @@ -1814,7 +1824,7 @@ RtlEnterCriticalSection( &PROFILE_CritSect ); - if (PROFILE_Open( filename )) + if (PROFILE_Open( filename, TRUE )) { ret = PROFILE_SetString( section, key, outstring, FALSE); PROFILE_FlushFile();
15 years, 12 months
1
0
0
0
[dchapyshev] 38367: - Formatting fix
by dchapyshev@svn.reactos.org
Author: dchapyshev Date: Fri Dec 26 23:45:51 2008 New Revision: 38367 URL:
http://svn.reactos.org/svn/reactos?rev=38367&view=rev
Log: - Formatting fix Modified: trunk/reactos/dll/win32/kernel32/misc/time.c Modified: trunk/reactos/dll/win32/kernel32/misc/time.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/ti…
============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/time.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/time.c [iso-8859-1] Fri Dec 26 23:45:51 2008 @@ -21,19 +21,19 @@ typedef struct __DOSTIME { - WORD Second:5; - WORD Minute:6; - WORD Hour:5; + WORD Second:5; + WORD Minute:6; + WORD Hour:5; } DOSTIME, *PDOSTIME; typedef struct __DOSDATE { - WORD Day:5; - WORD Month:4; - WORD Year:5; + WORD Day:5; + WORD Month:4; + WORD Year:5; } DOSDATE, *PDOSDATE; -#define TICKSPERMIN 600000000 +#define TICKSPERMIN 600000000 #define LL2FILETIME( ll, pft )\ (pft)->dwLowDateTime = (UINT)(ll); \ @@ -43,15 +43,15 @@ static const int MonthLengths[2][12] = { - { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } + { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, + { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; /* STATIC FUNTIONS **********************************************************/ static inline int IsLeapYear(int Year) { - return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 1 : 0; + return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 1 : 0; } /*********************************************************************** @@ -70,8 +70,8 @@ * 1 if date > compareDate * -2 if an error occurs */ -static int TIME_DayLightCompareDate( const SYSTEMTIME *date, - const SYSTEMTIME *compareDate ) +static int +TIME_DayLightCompareDate(const SYSTEMTIME *date, const SYSTEMTIME *compareDate) { int limit_day, dayinsecs; @@ -131,8 +131,9 @@ * TIME_ZONE_ID_STANDARD Current time is standard time * TIME_ZONE_ID_DAYLIGHT Current time is daylight savings time */ -static DWORD TIME_CompTimeZoneID ( const TIME_ZONE_INFORMATION *pTZinfo, - FILETIME *lpFileTime, BOOL islocal ) +static +DWORD +TIME_CompTimeZoneID( const TIME_ZONE_INFORMATION *pTZinfo, FILETIME *lpFileTime, BOOL islocal ) { int ret; BOOL beforeStandardDate, afterDaylightDate; @@ -216,11 +217,11 @@ * RETURNS * TRUE when the time zone bias was calculated. */ -static BOOL TIME_GetTimezoneBias( const TIME_ZONE_INFORMATION *pTZinfo, - FILETIME *lpFileTime, BOOL islocal, LONG *pBias ) +static BOOL +TIME_GetTimezoneBias(const TIME_ZONE_INFORMATION *pTZinfo, FILETIME *lpFileTime, BOOL islocal, LONG *pBias) { LONG bias = pTZinfo->Bias; - DWORD tzid = TIME_CompTimeZoneID( pTZinfo, lpFileTime, islocal); + DWORD tzid = TIME_CompTimeZoneID(pTZinfo, lpFileTime, islocal); if( tzid == TIME_ZONE_ID_INVALID) return FALSE; @@ -240,72 +241,65 @@ */ BOOL WINAPI -FileTimeToDosDateTime( - CONST FILETIME *lpFileTime, - LPWORD lpFatDate, - LPWORD lpFatTime - ) -{ - PDOSTIME pdtime=(PDOSTIME) lpFatTime; - PDOSDATE pddate=(PDOSDATE) lpFatDate; - SYSTEMTIME SystemTime = { 0, 0, 0, 0, 0, 0, 0, 0 }; - - if ( lpFileTime == NULL ) - return FALSE; - - if ( lpFatDate == NULL ) - return FALSE; - - if ( lpFatTime == NULL ) - return FALSE; - - FileTimeToSystemTime( - lpFileTime, - &SystemTime - ); - - pdtime->Second = SystemTime.wSecond / 2; - pdtime->Minute = SystemTime.wMinute; - pdtime->Hour = SystemTime.wHour; - - pddate->Day = SystemTime.wDay; - pddate->Month = SystemTime.wMonth; - pddate->Year = SystemTime.wYear - 1980; - - return TRUE; -} - - -/* - * @implemented - */ -BOOL -WINAPI -DosDateTimeToFileTime( - WORD wFatDate, - WORD wFatTime, - LPFILETIME lpFileTime - ) -{ - PDOSTIME pdtime = (PDOSTIME) &wFatTime; - PDOSDATE pddate = (PDOSDATE) &wFatDate; - SYSTEMTIME SystemTime; - - if ( lpFileTime == NULL ) - return FALSE; - - SystemTime.wMilliseconds = 0; - SystemTime.wSecond = pdtime->Second * 2; - SystemTime.wMinute = pdtime->Minute; - SystemTime.wHour = pdtime->Hour; - - SystemTime.wDay = pddate->Day; - SystemTime.wMonth = pddate->Month; - SystemTime.wYear = 1980 + pddate->Year; - - SystemTimeToFileTime(&SystemTime,lpFileTime); - - return TRUE; +FileTimeToDosDateTime(CONST FILETIME *lpFileTime, + LPWORD lpFatDate, + LPWORD lpFatTime) +{ + PDOSTIME pdtime=(PDOSTIME) lpFatTime; + PDOSDATE pddate=(PDOSDATE) lpFatDate; + SYSTEMTIME SystemTime = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + if (lpFileTime == NULL) + return FALSE; + + if (lpFatDate == NULL) + return FALSE; + + if (lpFatTime == NULL) + return FALSE; + + FileTimeToSystemTime(lpFileTime, &SystemTime); + + pdtime->Second = SystemTime.wSecond / 2; + pdtime->Minute = SystemTime.wMinute; + pdtime->Hour = SystemTime.wHour; + + pddate->Day = SystemTime.wDay; + pddate->Month = SystemTime.wMonth; + pddate->Year = SystemTime.wYear - 1980; + + return TRUE; +} + + +/* + * @implemented + */ +BOOL +WINAPI +DosDateTimeToFileTime(WORD wFatDate, + WORD wFatTime, + LPFILETIME lpFileTime) +{ + PDOSTIME pdtime = (PDOSTIME) &wFatTime; + PDOSDATE pddate = (PDOSDATE) &wFatDate; + SYSTEMTIME SystemTime; + + if (lpFileTime == NULL) + return FALSE; + + SystemTime.wMilliseconds = 0; + SystemTime.wSecond = pdtime->Second * 2; + SystemTime.wMinute = pdtime->Minute; + SystemTime.wHour = pdtime->Hour; + + SystemTime.wDay = pddate->Day; + SystemTime.wMonth = pddate->Month; + SystemTime.wYear = 1980 + pddate->Year; + + SystemTimeToFileTime(&SystemTime,lpFileTime); + + return TRUE; } @@ -314,294 +308,285 @@ */ LONG WINAPI -CompareFileTime( - CONST FILETIME *lpFileTime1, - CONST FILETIME *lpFileTime2 - ) -{ - if ( lpFileTime1 == NULL ) - return 0; - if ( lpFileTime2 == NULL ) - return 0; - - if (*((PLONGLONG)lpFileTime1) > *((PLONGLONG)lpFileTime2)) - return 1; - else if (*((PLONGLONG)lpFileTime1) < *((PLONGLONG)lpFileTime2)) - return -1; - - return 0; -} - - -/* - * @implemented - */ -VOID WINAPI -GetSystemTimeAsFileTime (PFILETIME lpFileTime) -{ - do - { - lpFileTime->dwHighDateTime = SharedUserData->SystemTime.High1Time; - lpFileTime->dwLowDateTime = SharedUserData->SystemTime.LowPart; - } - while (lpFileTime->dwHighDateTime != (DWORD)SharedUserData->SystemTime.High2Time); -} - - -/* - * @implemented - */ -BOOL -WINAPI -SystemTimeToFileTime( - CONST SYSTEMTIME * lpSystemTime, - LPFILETIME lpFileTime - ) - -{ - TIME_FIELDS TimeFields; - LARGE_INTEGER liTime; - - TimeFields.Year = lpSystemTime->wYear; - TimeFields.Month = lpSystemTime->wMonth; - TimeFields.Day = lpSystemTime->wDay; - TimeFields.Hour = lpSystemTime->wHour; - TimeFields.Minute = lpSystemTime->wMinute; - TimeFields.Second = lpSystemTime->wSecond; - TimeFields.Milliseconds = lpSystemTime->wMilliseconds; - - if (RtlTimeFieldsToTime (&TimeFields, &liTime)) - { - lpFileTime->dwLowDateTime = liTime.u.LowPart; - lpFileTime->dwHighDateTime = liTime.u.HighPart; - return TRUE; - } - - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; -} - - -/* - * @implemented - */ -BOOL -WINAPI -FileTimeToSystemTime( - CONST FILETIME *lpFileTime, - LPSYSTEMTIME lpSystemTime - ) -{ - TIME_FIELDS TimeFields; - LARGE_INTEGER liTime; - - if(lpFileTime->dwHighDateTime & 0x80000000) - return FALSE; - - liTime.u.LowPart = lpFileTime->dwLowDateTime; - liTime.u.HighPart = lpFileTime->dwHighDateTime; - - RtlTimeToTimeFields(&liTime, &TimeFields); - - lpSystemTime->wYear = TimeFields.Year; - lpSystemTime->wMonth = TimeFields.Month; - lpSystemTime->wDay = TimeFields.Day; - lpSystemTime->wHour = TimeFields.Hour; - lpSystemTime->wMinute = TimeFields.Minute; - lpSystemTime->wSecond = TimeFields.Second; - lpSystemTime->wMilliseconds = TimeFields.Milliseconds; - lpSystemTime->wDayOfWeek = TimeFields.Weekday; - - return TRUE; -} - - -/* - * @implemented - */ -BOOL -WINAPI -FileTimeToLocalFileTime( - CONST FILETIME *lpFileTime, - LPFILETIME lpLocalFileTime - ) -{ - LARGE_INTEGER TimeZoneBias; - - do - { - TimeZoneBias.HighPart = SharedUserData->TimeZoneBias.High1Time; - TimeZoneBias.LowPart = SharedUserData->TimeZoneBias.LowPart; - } - while (TimeZoneBias.HighPart != SharedUserData->TimeZoneBias.High2Time); - - *((PLONGLONG)lpLocalFileTime) = - *((PLONGLONG)lpFileTime) - TimeZoneBias.QuadPart; - - return TRUE; -} - - -/* - * @implemented - */ -BOOL -WINAPI -LocalFileTimeToFileTime( - CONST FILETIME *lpLocalFileTime, - LPFILETIME lpFileTime - ) -{ - LARGE_INTEGER TimeZoneBias; - - do - { - TimeZoneBias.HighPart = SharedUserData->TimeZoneBias.High1Time; - TimeZoneBias.LowPart = SharedUserData->TimeZoneBias.LowPart; - } - while (TimeZoneBias.HighPart != SharedUserData->TimeZoneBias.High2Time); - - *((PLONGLONG)lpFileTime) = - *((PLONGLONG)lpLocalFileTime) + TimeZoneBias.QuadPart; - - return TRUE; -} - - -/* - * @implemented - */ -VOID WINAPI +CompareFileTime(CONST FILETIME *lpFileTime1, CONST FILETIME *lpFileTime2) +{ + if (lpFileTime1 == NULL) + return 0; + if (lpFileTime2 == NULL) + return 0; + + if (*((PLONGLONG)lpFileTime1) > *((PLONGLONG)lpFileTime2)) + return 1; + else if (*((PLONGLONG)lpFileTime1) < *((PLONGLONG)lpFileTime2)) + return -1; + + return 0; +} + + +/* + * @implemented + */ +VOID +WINAPI +GetSystemTimeAsFileTime(PFILETIME lpFileTime) +{ + do + { + lpFileTime->dwHighDateTime = SharedUserData->SystemTime.High1Time; + lpFileTime->dwLowDateTime = SharedUserData->SystemTime.LowPart; + } + while (lpFileTime->dwHighDateTime != (DWORD)SharedUserData->SystemTime.High2Time); +} + + +/* + * @implemented + */ +BOOL +WINAPI +SystemTimeToFileTime(CONST SYSTEMTIME *lpSystemTime, LPFILETIME lpFileTime) +{ + TIME_FIELDS TimeFields; + LARGE_INTEGER liTime; + + TimeFields.Year = lpSystemTime->wYear; + TimeFields.Month = lpSystemTime->wMonth; + TimeFields.Day = lpSystemTime->wDay; + TimeFields.Hour = lpSystemTime->wHour; + TimeFields.Minute = lpSystemTime->wMinute; + TimeFields.Second = lpSystemTime->wSecond; + TimeFields.Milliseconds = lpSystemTime->wMilliseconds; + + if (RtlTimeFieldsToTime (&TimeFields, &liTime)) + { + lpFileTime->dwLowDateTime = liTime.u.LowPart; + lpFileTime->dwHighDateTime = liTime.u.HighPart; + return TRUE; + } + + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; +} + + +/* + * @implemented + */ +BOOL +WINAPI +FileTimeToSystemTime(CONST FILETIME *lpFileTime, LPSYSTEMTIME lpSystemTime) +{ + TIME_FIELDS TimeFields; + LARGE_INTEGER liTime; + + if (lpFileTime->dwHighDateTime & 0x80000000) + return FALSE; + + liTime.u.LowPart = lpFileTime->dwLowDateTime; + liTime.u.HighPart = lpFileTime->dwHighDateTime; + + RtlTimeToTimeFields(&liTime, &TimeFields); + + lpSystemTime->wYear = TimeFields.Year; + lpSystemTime->wMonth = TimeFields.Month; + lpSystemTime->wDay = TimeFields.Day; + lpSystemTime->wHour = TimeFields.Hour; + lpSystemTime->wMinute = TimeFields.Minute; + lpSystemTime->wSecond = TimeFields.Second; + lpSystemTime->wMilliseconds = TimeFields.Milliseconds; + lpSystemTime->wDayOfWeek = TimeFields.Weekday; + + return TRUE; +} + + +/* + * @implemented + */ +BOOL +WINAPI +FileTimeToLocalFileTime(CONST FILETIME *lpFileTime, LPFILETIME lpLocalFileTime) +{ + LARGE_INTEGER TimeZoneBias; + + do + { + TimeZoneBias.HighPart = SharedUserData->TimeZoneBias.High1Time; + TimeZoneBias.LowPart = SharedUserData->TimeZoneBias.LowPart; + } + while (TimeZoneBias.HighPart != SharedUserData->TimeZoneBias.High2Time); + + *((PLONGLONG)lpLocalFileTime) = *((PLONGLONG)lpFileTime) - TimeZoneBias.QuadPart; + + return TRUE; +} + + +/* + * @implemented + */ +BOOL +WINAPI +LocalFileTimeToFileTime(CONST FILETIME *lpLocalFileTime, LPFILETIME lpFileTime) +{ + LARGE_INTEGER TimeZoneBias; + + do + { + TimeZoneBias.HighPart = SharedUserData->TimeZoneBias.High1Time; + TimeZoneBias.LowPart = SharedUserData->TimeZoneBias.LowPart; + } + while (TimeZoneBias.HighPart != SharedUserData->TimeZoneBias.High2Time); + + *((PLONGLONG)lpFileTime) = *((PLONGLONG)lpLocalFileTime) + TimeZoneBias.QuadPart; + + return TRUE; +} + + +/* + * @implemented + */ +VOID +WINAPI GetLocalTime(LPSYSTEMTIME lpSystemTime) { - FILETIME FileTime; - FILETIME LocalFileTime; - - GetSystemTimeAsFileTime(&FileTime); - FileTimeToLocalFileTime(&FileTime, &LocalFileTime); - FileTimeToSystemTime(&LocalFileTime, lpSystemTime); -} - - -/* - * @implemented - */ -VOID WINAPI + FILETIME FileTime; + FILETIME LocalFileTime; + + GetSystemTimeAsFileTime(&FileTime); + FileTimeToLocalFileTime(&FileTime, &LocalFileTime); + FileTimeToSystemTime(&LocalFileTime, lpSystemTime); +} + + +/* + * @implemented + */ +VOID +WINAPI GetSystemTime(LPSYSTEMTIME lpSystemTime) { - FILETIME FileTime; - - GetSystemTimeAsFileTime(&FileTime); - FileTimeToSystemTime(&FileTime, lpSystemTime); -} - - -/* - * @implemented - */ -BOOL WINAPI + FILETIME FileTime; + + GetSystemTimeAsFileTime(&FileTime); + FileTimeToSystemTime(&FileTime, lpSystemTime); +} + + +/* + * @implemented + */ +BOOL +WINAPI SetLocalTime(CONST SYSTEMTIME *lpSystemTime) { - FILETIME LocalFileTime; - LARGE_INTEGER FileTime; - NTSTATUS Status; - - SystemTimeToFileTime(lpSystemTime, &LocalFileTime); - LocalFileTimeToFileTime(&LocalFileTime, (FILETIME *)&FileTime); - Status = NtSetSystemTime(&FileTime, &FileTime); - if (!NT_SUCCESS(Status)) - return FALSE; - return TRUE; -} - - -/* - * @implemented - */ -BOOL WINAPI + FILETIME LocalFileTime; + LARGE_INTEGER FileTime; + NTSTATUS Status; + + SystemTimeToFileTime(lpSystemTime, &LocalFileTime); + LocalFileTimeToFileTime(&LocalFileTime, (FILETIME *)&FileTime); + Status = NtSetSystemTime(&FileTime, &FileTime); + if (!NT_SUCCESS(Status)) + return FALSE; + return TRUE; +} + + +/* + * @implemented + */ +BOOL +WINAPI SetSystemTime(CONST SYSTEMTIME *lpSystemTime) { - LARGE_INTEGER NewSystemTime; - NTSTATUS Status; - - SystemTimeToFileTime(lpSystemTime, (PFILETIME)&NewSystemTime); - Status = NtSetSystemTime(&NewSystemTime, &NewSystemTime); - if (!NT_SUCCESS(Status)) - return FALSE; - return TRUE; -} - - -/* - * @implemented - */ -DWORD WINAPI + LARGE_INTEGER NewSystemTime; + NTSTATUS Status; + + SystemTimeToFileTime(lpSystemTime, (PFILETIME)&NewSystemTime); + Status = NtSetSystemTime(&NewSystemTime, &NewSystemTime); + if (!NT_SUCCESS(Status)) + return FALSE; + return TRUE; +} + + +/* + * @implemented + */ +DWORD +WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation) { - NTSTATUS Status; - - DPRINT("GetTimeZoneInformation()\n"); - - Status = NtQuerySystemInformation(SystemCurrentTimeZoneInformation, - lpTimeZoneInformation, - sizeof(TIME_ZONE_INFORMATION), - NULL); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return TIME_ZONE_ID_INVALID; - } - - return(SharedUserData->TimeZoneId); -} - - -/* - * @implemented - */ -BOOL WINAPI + NTSTATUS Status; + + DPRINT("GetTimeZoneInformation()\n"); + + Status = NtQuerySystemInformation(SystemCurrentTimeZoneInformation, + lpTimeZoneInformation, + sizeof(TIME_ZONE_INFORMATION), + NULL); + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + return TIME_ZONE_ID_INVALID; + } + + return(SharedUserData->TimeZoneId); +} + + +/* + * @implemented + */ +BOOL +WINAPI SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation) { - NTSTATUS Status; - - DPRINT("SetTimeZoneInformation()\n"); - - Status = RtlSetTimeZoneInformation((LPTIME_ZONE_INFORMATION)lpTimeZoneInformation); - if (!NT_SUCCESS(Status)) - { - DPRINT1("RtlSetTimeZoneInformation() failed (Status %lx)\n", Status); - SetLastErrorByStatus(Status); - return FALSE; - } - - Status = NtSetSystemInformation(SystemCurrentTimeZoneInformation, - (PVOID)lpTimeZoneInformation, - sizeof(TIME_ZONE_INFORMATION)); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtSetSystemInformation() failed (Status %lx)\n", Status); - SetLastErrorByStatus(Status); - return FALSE; - } - - return TRUE; -} - - -/* - * @implemented - */ -DWORD WINAPI + NTSTATUS Status; + + DPRINT("SetTimeZoneInformation()\n"); + + Status = RtlSetTimeZoneInformation((LPTIME_ZONE_INFORMATION)lpTimeZoneInformation); + if (!NT_SUCCESS(Status)) + { + DPRINT1("RtlSetTimeZoneInformation() failed (Status %lx)\n", Status); + SetLastErrorByStatus(Status); + return FALSE; + } + + Status = NtSetSystemInformation(SystemCurrentTimeZoneInformation, + (PVOID)lpTimeZoneInformation, + sizeof(TIME_ZONE_INFORMATION)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtSetSystemInformation() failed (Status %lx)\n", Status); + SetLastErrorByStatus(Status); + return FALSE; + } + + return TRUE; +} + + +/* + * @implemented + */ +DWORD +WINAPI GetTickCount(VOID) { - return (DWORD)((ULONGLONG)SharedUserData->TickCountLowDeprecated * SharedUserData->TickCountMultiplier / 16777216); -} - - -/* - * @implemented - */ -ULONGLONG WINAPI + return (DWORD)((ULONGLONG)SharedUserData->TickCountLowDeprecated * SharedUserData->TickCountMultiplier / 16777216); +} + + +/* + * @implemented + */ +ULONGLONG +WINAPI GetTickCount64(VOID) { return (ULONGLONG)SharedUserData->TickCountLowDeprecated * (ULONGLONG)SharedUserData->TickCountMultiplier / 16777216; @@ -611,35 +596,34 @@ /* * @implemented */ -BOOL WINAPI -SystemTimeToTzSpecificLocalTime( - CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, +BOOL +WINAPI +SystemTimeToTzSpecificLocalTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, CONST SYSTEMTIME *lpUniversalTime, - LPSYSTEMTIME lpLocalTime - ) -{ - TIME_ZONE_INFORMATION TzInfo; - FILETIME FileTime; - LONGLONG llTime; - LONG lBias; - - if (lpTimeZoneInformation != NULL) - { - TzInfo = *lpTimeZoneInformation; - } - else - { - if (GetTimeZoneInformation(&TzInfo) == TIME_ZONE_ID_INVALID) - return FALSE; - } - - if (!lpUniversalTime || !lpLocalTime) - return FALSE; - - if (!SystemTimeToFileTime(lpUniversalTime, &FileTime)) - return FALSE; - - FILETIME2LL(&FileTime, llTime) + LPSYSTEMTIME lpLocalTime) +{ + TIME_ZONE_INFORMATION TzInfo; + FILETIME FileTime; + LONGLONG llTime; + LONG lBias; + + if (lpTimeZoneInformation != NULL) + { + TzInfo = *lpTimeZoneInformation; + } + else + { + if (GetTimeZoneInformation(&TzInfo) == TIME_ZONE_ID_INVALID) + return FALSE; + } + + if (!lpUniversalTime || !lpLocalTime) + return FALSE; + + if (!SystemTimeToFileTime(lpUniversalTime, &FileTime)) + return FALSE; + + FILETIME2LL(&FileTime, llTime) if (!TIME_GetTimezoneBias(&TzInfo, &FileTime, FALSE, &lBias)) return FALSE; @@ -649,7 +633,7 @@ LL2FILETIME( llTime, &FileTime) - return FileTimeToSystemTime(&FileTime, lpLocalTime); + return FileTimeToSystemTime(&FileTime, lpLocalTime); } @@ -658,11 +642,9 @@ */ BOOL WINAPI -TzSpecificLocalTimeToSystemTime( - CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, - CONST SYSTEMTIME *lpLocalTime, - LPSYSTEMTIME lpUniversalTime - ) +TzSpecificLocalTimeToSystemTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, + CONST SYSTEMTIME *lpLocalTime, + LPSYSTEMTIME lpUniversalTime) { FILETIME ft; LONG lBias; @@ -694,96 +676,96 @@ /* * @implemented */ -BOOL WINAPI +BOOL +WINAPI GetSystemTimeAdjustment(PDWORD lpTimeAdjustment, - PDWORD lpTimeIncrement, - PBOOL lpTimeAdjustmentDisabled) -{ - SYSTEM_QUERY_TIME_ADJUST_INFORMATION Buffer; - NTSTATUS Status; - - Status = NtQuerySystemInformation(SystemTimeAdjustmentInformation, - &Buffer, - sizeof(SYSTEM_QUERY_TIME_ADJUST_INFORMATION), - NULL); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return FALSE; - } - - *lpTimeAdjustment = (DWORD)Buffer.TimeAdjustment; - *lpTimeIncrement = (DWORD)Buffer.TimeIncrement; - *lpTimeAdjustmentDisabled = (BOOL)Buffer.Enable; - - return TRUE; -} - - -/* - * @implemented - */ -BOOL WINAPI + PDWORD lpTimeIncrement, + PBOOL lpTimeAdjustmentDisabled) +{ + SYSTEM_QUERY_TIME_ADJUST_INFORMATION Buffer; + NTSTATUS Status; + + Status = NtQuerySystemInformation(SystemTimeAdjustmentInformation, + &Buffer, + sizeof(SYSTEM_QUERY_TIME_ADJUST_INFORMATION), + NULL); + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + return FALSE; + } + + *lpTimeAdjustment = (DWORD)Buffer.TimeAdjustment; + *lpTimeIncrement = (DWORD)Buffer.TimeIncrement; + *lpTimeAdjustmentDisabled = (BOOL)Buffer.Enable; + + return TRUE; +} + + +/* + * @implemented + */ +BOOL +WINAPI SetSystemTimeAdjustment(DWORD dwTimeAdjustment, - BOOL bTimeAdjustmentDisabled) -{ - NTSTATUS Status; - SYSTEM_SET_TIME_ADJUST_INFORMATION Buffer; - - Buffer.TimeAdjustment = (ULONG)dwTimeAdjustment; - Buffer.Enable = (BOOLEAN)bTimeAdjustmentDisabled; - - Status = NtSetSystemInformation(SystemTimeAdjustmentInformation, - &Buffer, - sizeof(SYSTEM_SET_TIME_ADJUST_INFORMATION)); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return FALSE; - } - - return TRUE; -} - - -/* - * @implemented - */ -BOOL -WINAPI -GetSystemTimes( - LPFILETIME lpIdleTime, - LPFILETIME lpKernelTime, - LPFILETIME lpUserTime - ) -{ - SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SysProcPerfInfo; - NTSTATUS Status; - - Status = ZwQuerySystemInformation(SystemProcessorPerformanceInformation, - &SysProcPerfInfo, - sizeof(SysProcPerfInfo), - NULL); - - if (!NT_SUCCESS(Status)) - { + BOOL bTimeAdjustmentDisabled) +{ + NTSTATUS Status; + SYSTEM_SET_TIME_ADJUST_INFORMATION Buffer; + + Buffer.TimeAdjustment = (ULONG)dwTimeAdjustment; + Buffer.Enable = (BOOLEAN)bTimeAdjustmentDisabled; + + Status = NtSetSystemInformation(SystemTimeAdjustmentInformation, + &Buffer, + sizeof(SYSTEM_SET_TIME_ADJUST_INFORMATION)); + if (!NT_SUCCESS(Status)) + { SetLastErrorByStatus(Status); return FALSE; - } -/* - Good only for one processor system. - */ - - lpIdleTime->dwLowDateTime = SysProcPerfInfo.IdleTime.LowPart; - lpIdleTime->dwHighDateTime = SysProcPerfInfo.IdleTime.HighPart; - - lpKernelTime->dwLowDateTime = SysProcPerfInfo.KernelTime.LowPart; - lpKernelTime->dwHighDateTime = SysProcPerfInfo.KernelTime.HighPart; - - lpUserTime->dwLowDateTime = SysProcPerfInfo.UserTime.LowPart; - lpUserTime->dwHighDateTime = SysProcPerfInfo.UserTime.HighPart; - - return TRUE; + } + + return TRUE; +} + + +/* + * @implemented + */ +BOOL +WINAPI +GetSystemTimes(LPFILETIME lpIdleTime, + LPFILETIME lpKernelTime, + LPFILETIME lpUserTime) +{ + SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SysProcPerfInfo; + NTSTATUS Status; + + Status = ZwQuerySystemInformation(SystemProcessorPerformanceInformation, + &SysProcPerfInfo, + sizeof(SysProcPerfInfo), + NULL); + + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + return FALSE; + } +/* + Good only for one processor system. + */ + + lpIdleTime->dwLowDateTime = SysProcPerfInfo.IdleTime.LowPart; + lpIdleTime->dwHighDateTime = SysProcPerfInfo.IdleTime.HighPart; + + lpKernelTime->dwLowDateTime = SysProcPerfInfo.KernelTime.LowPart; + lpKernelTime->dwHighDateTime = SysProcPerfInfo.KernelTime.HighPart; + + lpUserTime->dwLowDateTime = SysProcPerfInfo.UserTime.LowPart; + lpUserTime->dwHighDateTime = SysProcPerfInfo.UserTime.HighPart; + + return TRUE; } /* EOF */
16 years
1
0
0
0
[dchapyshev] 38366: - Fix SystemTimeToTzSpecificLocalTime. +378 passed tests
by dchapyshev@svn.reactos.org
Author: dchapyshev Date: Fri Dec 26 23:31:06 2008 New Revision: 38366 URL:
http://svn.reactos.org/svn/reactos?rev=38366&view=rev
Log: - Fix SystemTimeToTzSpecificLocalTime. +378 passed tests Modified: trunk/reactos/dll/win32/kernel32/misc/time.c Modified: trunk/reactos/dll/win32/kernel32/misc/time.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/ti…
============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/time.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/time.c [iso-8859-1] Fri Dec 26 23:31:06 2008 @@ -141,8 +141,6 @@ SYSTEMTIME SysTime; FILETIME ftTemp; - ZeroMemory (&SysTime, sizeof (SysTime)); - if (pTZinfo->DaylightDate.wMonth != 0) { /* if year is 0 then date is in day-of-week format, otherwise @@ -162,7 +160,7 @@ if (!islocal) { FILETIME2LL( lpFileTime, llTime ); llTime -= ( pTZinfo->Bias + pTZinfo->DaylightBias ) - * (LONGLONG) TICKSPERMIN; + * (LONGLONG)TICKSPERMIN; LL2FILETIME( llTime, &ftTemp) lpFileTime = &ftTemp; } @@ -178,7 +176,7 @@ if (!islocal) { llTime -= ( pTZinfo->StandardBias - pTZinfo->DaylightBias ) - * (LONGLONG) TICKSPERMIN; + * (LONGLONG)TICKSPERMIN; LL2FILETIME( llTime, &ftTemp) FileTimeToSystemTime(lpFileTime, &SysTime); } @@ -620,29 +618,38 @@ LPSYSTEMTIME lpLocalTime ) { - TIME_ZONE_INFORMATION TimeZoneInformation; - LPTIME_ZONE_INFORMATION lpTzInfo; - LARGE_INTEGER FileTime; - - if (!lpTimeZoneInformation) + TIME_ZONE_INFORMATION TzInfo; + FILETIME FileTime; + LONGLONG llTime; + LONG lBias; + + if (lpTimeZoneInformation != NULL) { - GetTimeZoneInformation(&TimeZoneInformation); - lpTzInfo = &TimeZoneInformation; + TzInfo = *lpTimeZoneInformation; } else - lpTzInfo = (LPTIME_ZONE_INFORMATION)lpTimeZoneInformation; - - if (!lpUniversalTime) + { + if (GetTimeZoneInformation(&TzInfo) == TIME_ZONE_ID_INVALID) + return FALSE; + } + + if (!lpUniversalTime || !lpLocalTime) return FALSE; - if (!lpLocalTime) - return FALSE; - - SystemTimeToFileTime(lpUniversalTime, (PFILETIME)&FileTime); - FileTime.QuadPart -= (lpTzInfo->Bias * TICKSPERMIN); - FileTimeToSystemTime((PFILETIME)&FileTime, lpLocalTime); - - return TRUE; + if (!SystemTimeToFileTime(lpUniversalTime, &FileTime)) + return FALSE; + + FILETIME2LL(&FileTime, llTime) + + if (!TIME_GetTimezoneBias(&TzInfo, &FileTime, FALSE, &lBias)) + return FALSE; + + /* convert minutes to 100-nanoseconds-ticks */ + llTime -= (LONGLONG)lBias * TICKSPERMIN; + + LL2FILETIME( llTime, &FileTime) + + return FileTimeToSystemTime(&FileTime, lpLocalTime); }
16 years
1
0
0
0
[mjmartin] 38365: - Fix VideoPortInt10 implementation. The previous implementation was passing a significantly smaller KV86M_REGISTERS struct vice CONTEXT struct to Ke386CallBios, resulting in memory corruption. - Part 2 of ? fixes for bug 2286.
by mjmartin@svn.reactos.org
Author: mjmartin Date: Fri Dec 26 22:01:26 2008 New Revision: 38365 URL:
http://svn.reactos.org/svn/reactos?rev=38365&view=rev
Log: - Fix VideoPortInt10 implementation. The previous implementation was passing a significantly smaller KV86M_REGISTERS struct vice CONTEXT struct to Ke386CallBios, resulting in memory corruption. - Part 2 of ? fixes for bug 2286. Modified: trunk/reactos/drivers/video/videoprt/int10.c Modified: trunk/reactos/drivers/video/videoprt/int10.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/int…
============================================================================== --- trunk/reactos/drivers/video/videoprt/int10.c [iso-8859-1] (original) +++ trunk/reactos/drivers/video/videoprt/int10.c [iso-8859-1] Fri Dec 26 22:01:26 2008 @@ -199,48 +199,48 @@ VP_STATUS NTAPI VideoPortInt10( - IN PVOID HwDeviceExtension, - IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments) -{ - KV86M_REGISTERS Regs; - NTSTATUS Status; - PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); - KAPC_STATE ApcState; - - TRACE_(VIDEOPRT, "VideoPortInt10\n"); - - if (!CsrssInitialized) - { - return ERROR_INVALID_PARAMETER; - } - - IntAttachToCSRSS(&CallingProcess, &ApcState); - - memset(&Regs, 0, sizeof(Regs)); - INFO_(VIDEOPRT, "- Input register Eax: %x\n", BiosArguments->Eax); - Regs.Eax = BiosArguments->Eax; - INFO_(VIDEOPRT, "- Input register Ebx: %x\n", BiosArguments->Ebx); - Regs.Ebx = BiosArguments->Ebx; - INFO_(VIDEOPRT, "- Input register Ecx: %x\n", BiosArguments->Ecx); - Regs.Ecx = BiosArguments->Ecx; - INFO_(VIDEOPRT, "- Input register Edx: %x\n", BiosArguments->Edx); - Regs.Edx = BiosArguments->Edx; - INFO_(VIDEOPRT, "- Input register Esi: %x\n", BiosArguments->Esi); - Regs.Esi = BiosArguments->Esi; - INFO_(VIDEOPRT, "- Input register Edi: %x\n", BiosArguments->Edi); - Regs.Edi = BiosArguments->Edi; - INFO_(VIDEOPRT, "- Input register Ebp: %x\n", BiosArguments->Ebp); - Regs.Ebp = BiosArguments->Ebp; - Status = Ke386CallBios(0x10, (PCONTEXT)&Regs); - BiosArguments->Eax = Regs.Eax; - BiosArguments->Ebx = Regs.Ebx; - BiosArguments->Ecx = Regs.Ecx; - BiosArguments->Edx = Regs.Edx; - BiosArguments->Esi = Regs.Esi; - BiosArguments->Edi = Regs.Edi; - BiosArguments->Ebp = Regs.Ebp; - - IntDetachFromCSRSS(&CallingProcess, &ApcState); - - return Status; -} + IN PVOID HwDeviceExtension, + IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments) +{ + CONTEXT BiosContext; + NTSTATUS Status; + PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); + KAPC_STATE ApcState; + + if (!CsrssInitialized) + { + return ERROR_INVALID_PARAMETER; + } + + /* Attach to CSRSS */ + IntAttachToCSRSS(&CallingProcess, &ApcState); + + /* Clear the context */ + RtlZeroMemory(&BiosContext, sizeof(CONTEXT)); + + /* Fill out the bios arguments */ + BiosContext.Eax = BiosArguments->Eax; + BiosContext.Ebx = BiosArguments->Ebx; + BiosContext.Ecx = BiosArguments->Ecx; + BiosContext.Edx = BiosArguments->Edx; + BiosContext.Esi = BiosArguments->Esi; + BiosContext.Edi = BiosArguments->Edi; + BiosContext.Ebp = BiosArguments->Ebp; + + /* Do the ROM BIOS call */ + Status = Ke386CallBios(0x10, &BiosContext); + + /* Return the arguments */ + BiosArguments->Eax = BiosContext.Eax; + BiosArguments->Ebx = BiosContext.Ebx; + BiosArguments->Ecx = BiosContext.Ecx; + BiosArguments->Edx = BiosContext.Edx; + BiosArguments->Esi = BiosContext.Esi; + BiosArguments->Edi = BiosContext.Edi; + BiosArguments->Ebp = BiosContext.Ebp; + + /* Detach from CSRSS */ + IntDetachFromCSRSS(&CallingProcess, &ApcState); + + return Status; +}
16 years
1
0
0
0
← Newer
1
...
10
11
12
13
14
15
16
...
71
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Results per page:
10
25
50
100
200