Added patch to fix return type of shlwapi.SHAddDataBlock.

Also fixes parsing of multiline From: headers in staging/patchutils.py.
This commit is contained in:
Sebastian Lackner 2017-01-19 06:54:01 +01:00
parent 80a4e6bdd7
commit 49ba202882
4 changed files with 162 additions and 9 deletions

View File

@ -334,6 +334,7 @@ patch_enable_all ()
enable_shell32_Toolbar_Bitmaps="$1"
enable_shell32_UnixFS="$1"
enable_shlwapi_AssocGetPerceivedType="$1"
enable_shlwapi_SHAddDataBlock="$1"
enable_shlwapi_SHMapHandle="$1"
enable_shlwapi_UrlCombine="$1"
enable_stdole32_idl_Typelib="$1"
@ -1213,6 +1214,9 @@ patch_enable ()
shlwapi-AssocGetPerceivedType)
enable_shlwapi_AssocGetPerceivedType="$2"
;;
shlwapi-SHAddDataBlock)
enable_shlwapi_SHAddDataBlock="$2"
;;
shlwapi-SHMapHandle)
enable_shlwapi_SHMapHandle="$2"
;;
@ -7167,6 +7171,18 @@ if test "$enable_shlwapi_AssocGetPerceivedType" -eq 1; then
) >> "$patchlist"
fi
# Patchset shlwapi-SHAddDataBlock
# |
# | Modified files:
# | * dlls/shlwapi/clist.c, dlls/shlwapi/tests/clist.c
# |
if test "$enable_shlwapi_SHAddDataBlock" -eq 1; then
patch_apply shlwapi-SHAddDataBlock/0001-shlwapi-Fix-the-return-value-of-SHAddDataBlock.patch
(
echo '+ { "Hermès BÉLUSCA-MAÏTO", "shlwapi: Fix the return value of SHAddDataBlock.", 1 },';
) >> "$patchlist"
fi
# Patchset shlwapi-SHMapHandle
# |
# | Modified files:

View File

@ -0,0 +1,132 @@
From 0cf3e133b7ab01d7d1facf955263bd9b8a0ed28e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herm=C3=A8s=20B=C3=89LUSCA-MA=C3=8FTO?=
<hermes.belusca@sfr.fr>
Date: Tue, 17 Jan 2017 23:46:31 +0100
Subject: shlwapi: Fix the return value of SHAddDataBlock
This patch fixes the return type and value of SHAddDataBlock.
The corresponding test (shlwapi's clist) is adjusted to reflect
those changes. Tested on Windows 2003 and 7.
In addition I set, in SHRemoveDataBlock, the lpList pointer
to NULL, to respect the fact it's a pointer, not just a number.
Signed-off-by: Hermes Belusca-Maito <hermes.belusca@sfr.fr>
---
dlls/shlwapi/clist.c | 14 +++++++-------
dlls/shlwapi/tests/clist.c | 21 +++++++++------------
2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/dlls/shlwapi/clist.c b/dlls/shlwapi/clist.c
index 52bee37c9e4..77917b35469 100644
--- a/dlls/shlwapi/clist.c
+++ b/dlls/shlwapi/clist.c
@@ -65,19 +65,19 @@ static inline LPDATABLOCK_HEADER NextItem(LPDBLIST lpList)
* the call returns S_OK but does not actually add the element.
* See SHWriteDataBlockList.
*/
-HRESULT WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewItem)
+BOOL WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewItem)
{
LPDATABLOCK_HEADER lpInsertAt = NULL;
ULONG ulSize;
TRACE("(%p,%p)\n", lppList, lpNewItem);
- if(!lppList || !lpNewItem )
- return E_INVALIDARG;
+ if(!lppList || !lpNewItem)
+ return FALSE;
if (lpNewItem->cbSize < sizeof(DATABLOCK_HEADER) ||
lpNewItem->dwSignature == CLIST_ID_CONTAINER)
- return S_OK;
+ return FALSE;
ulSize = lpNewItem->cbSize;
@@ -134,9 +134,9 @@ HRESULT WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewIt
lpInsertAt = NextItem(lpInsertAt);
lpInsertAt->cbSize = 0;
- return lpNewItem->cbSize;
+ return TRUE;
}
- return S_OK;
+ return FALSE;
}
/*************************************************************************
@@ -354,7 +354,7 @@ VOID WINAPI SHFreeDataBlockList(LPDBLIST lpList)
*/
BOOL WINAPI SHRemoveDataBlock(LPDBLIST* lppList, DWORD dwSignature)
{
- LPDATABLOCK_HEADER lpList = 0;
+ LPDATABLOCK_HEADER lpList = NULL;
LPDATABLOCK_HEADER lpItem = NULL;
LPDATABLOCK_HEADER lpNext;
ULONG ulNewSize;
diff --git a/dlls/shlwapi/tests/clist.c b/dlls/shlwapi/tests/clist.c
index b930470806e..309b3335ec1 100644
--- a/dlls/shlwapi/tests/clist.c
+++ b/dlls/shlwapi/tests/clist.c
@@ -218,7 +218,7 @@ static IStreamVtbl iclvt =
static HMODULE SHLWAPI_hshlwapi = 0;
static VOID (WINAPI *pSHLWAPI_19)(LPSHLWAPI_CLIST);
-static HRESULT (WINAPI *pSHLWAPI_20)(LPSHLWAPI_CLIST*,LPCSHLWAPI_CLIST);
+static BOOL (WINAPI *pSHLWAPI_20)(LPSHLWAPI_CLIST*,LPCSHLWAPI_CLIST);
static BOOL (WINAPI *pSHLWAPI_21)(LPSHLWAPI_CLIST*,ULONG);
static LPSHLWAPI_CLIST (WINAPI *pSHLWAPI_22)(LPSHLWAPI_CLIST,ULONG);
static HRESULT (WINAPI *pSHLWAPI_17)(IStream*, SHLWAPI_CLIST*);
@@ -292,6 +292,7 @@ static void test_CList(void)
struct dummystream streamobj;
LPSHLWAPI_CLIST list = NULL;
LPCSHLWAPI_CLIST item = SHLWAPI_CLIST_items;
+ BOOL bRet;
HRESULT hRet;
LPSHLWAPI_CLIST inserted;
BYTE buff[64];
@@ -312,10 +313,10 @@ static void test_CList(void)
buff[sizeof(SHLWAPI_CLIST)+i] = i*2;
/* Add it */
- hRet = pSHLWAPI_20(&list, inserted);
- ok(hRet > S_OK, "failed list add\n");
+ bRet = pSHLWAPI_20(&list, inserted);
+ ok(bRet == TRUE, "failed list add\n");
- if (hRet > S_OK)
+ if (bRet == TRUE)
{
ok(list && list->ulSize, "item not added\n");
@@ -390,11 +391,8 @@ static void test_CList(void)
inserted = (LPSHLWAPI_CLIST)buff;
inserted->ulSize = sizeof(SHLWAPI_CLIST) -1;
inserted->ulId = 33;
-
- /* The call succeeds but the item is not inserted, except on some early
- * versions which return failure. Wine behaves like later versions.
- */
- pSHLWAPI_20(&list, inserted);
+ bRet = pSHLWAPI_20(&list, inserted);
+ ok(bRet == FALSE, "Expected failure\n");
inserted = pSHLWAPI_22(list, 33);
ok(inserted == NULL, "inserted bad element size\n");
@@ -402,9 +400,8 @@ static void test_CList(void)
inserted = (LPSHLWAPI_CLIST)buff;
inserted->ulSize = 44;
inserted->ulId = ~0U;
-
- /* See comment above, some early versions fail this call */
- pSHLWAPI_20(&list, inserted);
+ bRet = pSHLWAPI_20(&list, inserted);
+ ok(bRet == FALSE, "Expected failure\n");
item = SHLWAPI_CLIST_items;
--
2.11.0

View File

@ -0,0 +1 @@
Fixes: Fix return type of shlwapi.SHAddDataBlock

View File

@ -135,6 +135,16 @@ class _PatchReader(object):
tmp, self.peeked = self.peeked, None
return tmp[1]
def read_multiline(self):
"""Read multiline data from a patch file."""
line = self.read().rstrip("\r\n")
while True:
tmp = self.peek()
if not tmp.startswith(" "): break
line += tmp.rstrip("\r\n")
self.read()
return line
def read_hunk(self):
"""Read one hunk from a patch file."""
line = self.peek()
@ -341,18 +351,12 @@ def read_patch(filename, fp=None):
break
elif line.startswith("From: "):
header['author'], header['email'] = _parse_author(line[6:])
author = fp.read_multiline()[6:]
header['author'], header['email'] = _parse_author(author)
header.pop('signedoffby', None)
fp.read()
elif line.startswith("Subject: "):
subject = line[9:].rstrip("\r\n")
fp.read()
while True:
line = fp.peek()
if not line.startswith(" "): break
subject += line.rstrip("\r\n")
fp.read()
subject = fp.read_multiline()[9:]
subject, revision = _parse_subject(subject)
if not subject.endswith("."): subject += "."
subject = re.sub('^([^:]*: *)([a-z])', lambda x: "%s%s" %