=?UTF-8?Q?Andr=C3=A9=20Hentschel=20?=: wrc: Remove duplicate code ( PVS-Studio).

Alexandre Julliard julliard at wine.codeweavers.com
Tue Oct 28 02:24:35 CDT 2014


Module: wine
Branch: master
Commit: 9b810cd6e884facde7152a79a6474c3637b260ee
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9b810cd6e884facde7152a79a6474c3637b260ee

Author: André Hentschel <nerv at dawncrow.de>
Date:   Tue Oct 28 00:02:09 2014 +0100

wrc: Remove duplicate code (PVS-Studio).

---

 tools/wrc/genres.c | 178 ++++++++++++++++++-----------------------------------
 1 file changed, 61 insertions(+), 117 deletions(-)

diff --git a/tools/wrc/genres.c b/tools/wrc/genres.c
index 9cea432..8993a87 100644
--- a/tools/wrc/genres.c
+++ b/tools/wrc/genres.c
@@ -960,86 +960,48 @@ static res_t *cursorgroup2res(name_id_t *name, cursor_group_t *curg)
 
 	res = new_res();
 	restag = put_res_header(res, WRC_RT_GROUP_CURSOR, NULL, name, curg->memopt, &(curg->lvc));
-	if(win32)
-	{
-		put_word(res, 0);	/* Reserved */
-		/* FIXME: The ResType in the NEWHEADER structure should
-		 * contain 14 according to the MS win32 doc. This is
-		 * not the case with the BRC compiler and I really doubt
-		 * the latter. Putting one here is compliant to win16 spec,
-		 * but who knows the true value?
-		 */
-		put_word(res, 2);	/* ResType */
-		put_word(res, curg->ncursor);
-#if 0
-		for(cur = curg->cursorlist; cur; cur = cur->next)
-#else
-		cur = curg->cursorlist;
-		while(cur->next)
-			cur = cur->next;
-		for(; cur; cur = cur->prev)
-#endif
-		{
-			put_word(res, cur->width);
-			/* FIXME: The height of a cursor is half the size of
-			 * the bitmap's height. BRC puts the height from the
-			 * BITMAPINFOHEADER here instead of the cursorfile's
-			 * height. MS doesn't seem to care...
-			 */
-			put_word(res, cur->height);
-			/* FIXME: The next two are reversed in BRC and I don't
-			 * know why. Probably a bug. But, we can safely ignore
-			 * it because win16 does not support color cursors.
-			 * A warning should have been generated by the parser.
-			 */
-			put_word(res, cur->planes);
-			put_word(res, cur->bits);
-			/* FIXME: The +4 is the hotspot in the cursor resource.
-			 * However, I could not find this in the documentation.
-			 * The hotspot bytes must either be included or MS
-			 * doesn't care.
-			 */
-			put_dword(res, cur->data->size +4);
-			put_word(res, cur->id);
-		}
-	}
-	else /* win16 */
-	{
-		put_word(res, 0);	/* Reserved */
-		put_word(res, 2);	/* ResType */
-		put_word(res, curg->ncursor);
+
+    put_word(res, 0);	/* Reserved */
+    /* FIXME: The ResType in the NEWHEADER structure should
+     * contain 14 according to the MS win32 doc. This is
+     * not the case with the BRC compiler and I really doubt
+     * the latter. Putting one here is compliant to win16 spec,
+     * but who knows the true value?
+     */
+    put_word(res, 2);	/* ResType */
+    put_word(res, curg->ncursor);
 #if 0
-		for(cur = curg->cursorlist; cur; cur = cur->next)
+    for(cur = curg->cursorlist; cur; cur = cur->next)
 #else
-		cur = curg->cursorlist;
-		while(cur->next)
-			cur = cur->next;
-		for(; cur; cur = cur->prev)
+    cur = curg->cursorlist;
+    while(cur->next)
+        cur = cur->next;
+    for(; cur; cur = cur->prev)
 #endif
-		{
-			put_word(res, cur->width);
-			/* FIXME: The height of a cursor is half the size of
-			 * the bitmap's height. BRC puts the height from the
-			 * BITMAPINFOHEADER here instead of the cursorfile's
-			 * height. MS doesn't seem to care...
-			 */
-			put_word(res, cur->height);
-			/* FIXME: The next two are reversed in BRC and I don't
-			 * know why. Probably a bug. But, we can safely ignore
-			 * it because win16 does not support color cursors.
-			 * A warning should have been generated by the parser.
-			 */
-			put_word(res, cur->planes);
-			put_word(res, cur->bits);
-			/* FIXME: The +4 is the hotspot in the cursor resource.
-			 * However, I could not find this in the documentation.
-			 * The hotspot bytes must either be included or MS
-			 * doesn't care.
-			 */
-			put_dword(res, cur->data->size +4);
-			put_word(res, cur->id);
-		}
-	}
+    {
+        put_word(res, cur->width);
+        /* FIXME: The height of a cursor is half the size of
+         * the bitmap's height. BRC puts the height from the
+         * BITMAPINFOHEADER here instead of the cursorfile's
+         * height. MS doesn't seem to care...
+         */
+        put_word(res, cur->height);
+        /* FIXME: The next two are reversed in BRC and I don't
+         * know why. Probably a bug. But, we can safely ignore
+         * it because win16 does not support color cursors.
+         * A warning should have been generated by the parser.
+         */
+        put_word(res, cur->planes);
+        put_word(res, cur->bits);
+        /* FIXME: The +4 is the hotspot in the cursor resource.
+         * However, I could not find this in the documentation.
+         * The hotspot bytes must either be included or MS
+         * doesn't care.
+         */
+        put_dword(res, cur->data->size +4);
+        put_word(res, cur->id);
+    }
+
 	SetResSize(res, restag);	/* Set ResourceSize */
 	if(win32)
 		put_pad(res);
@@ -1103,46 +1065,28 @@ static res_t *icongroup2res(name_id_t *name, icon_group_t *icog)
 
 	res = new_res();
 	restag = put_res_header(res, WRC_RT_GROUP_ICON, NULL, name, icog->memopt, &(icog->lvc));
-	if(win32)
-	{
-		put_word(res, 0);	/* Reserved */
-		/* FIXME: The ResType in the NEWHEADER structure should
-		 * contain 14 according to the MS win32 doc. This is
-		 * not the case with the BRC compiler and I really doubt
-		 * the latter. Putting one here is compliant to win16 spec,
-		 * but who knows the true value?
-		 */
-		put_word(res, 1);	/* ResType */
-		put_word(res, icog->nicon);
-		for(ico = icog->iconlist; ico; ico = ico->next)
-		{
-			put_byte(res, ico->width);
-			put_byte(res, ico->height);
-			put_byte(res, ico->nclr);
-			put_byte(res, 0);	/* Reserved */
-			put_word(res, ico->planes);
-			put_word(res, ico->bits);
-			put_dword(res, ico->data->size);
-			put_word(res, ico->id);
-		}
-	}
-	else /* win16 */
-	{
-		put_word(res, 0);	/* Reserved */
-		put_word(res, 1);	/* ResType */
-		put_word(res, icog->nicon);
-		for(ico = icog->iconlist; ico; ico = ico->next)
-		{
-			put_byte(res, ico->width);
-			put_byte(res, ico->height);
-			put_byte(res, ico->nclr);
-			put_byte(res, 0);	/* Reserved */
-			put_word(res, ico->planes);
-			put_word(res, ico->bits);
-			put_dword(res, ico->data->size);
-			put_word(res, ico->id);
-		}
-	}
+
+    put_word(res, 0);	/* Reserved */
+    /* FIXME: The ResType in the NEWHEADER structure should
+     * contain 14 according to the MS win32 doc. This is
+     * not the case with the BRC compiler and I really doubt
+     * the latter. Putting one here is compliant to win16 spec,
+     * but who knows the true value?
+     */
+    put_word(res, 1);	/* ResType */
+    put_word(res, icog->nicon);
+    for(ico = icog->iconlist; ico; ico = ico->next)
+    {
+        put_byte(res, ico->width);
+        put_byte(res, ico->height);
+        put_byte(res, ico->nclr);
+        put_byte(res, 0);	/* Reserved */
+        put_word(res, ico->planes);
+        put_word(res, ico->bits);
+        put_dword(res, ico->data->size);
+        put_word(res, ico->id);
+    }
+
 	SetResSize(res, restag);	/* Set ResourceSize */
 	if(win32)
 		put_pad(res);




More information about the wine-cvs mailing list