From 4a8ca6d134a70ffeaa508037992376a361e5eb02 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@zdoom.fake>
Date: Tue, 16 May 2006 10:06:23 +0000
Subject: [PATCH] Changed TAG_MORE parameter to a struct containing a va_list
 to ensure that no matter how va_list is defined the address can be taken.

SVN r119 (trunk)
---
 src/v_draw.cpp |  6 +++---
 src/v_text.cpp | 18 +++++++++---------
 src/v_video.h  |  5 +++++
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/v_draw.cpp b/src/v_draw.cpp
index 17796e3fe..e3851ae2f 100644
--- a/src/v_draw.cpp
+++ b/src/v_draw.cpp
@@ -103,7 +103,7 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, int x0, int y0, DWORD tags_
 
 	while (tag != TAG_DONE)
 	{
-		va_list *more_p;
+		TagMoreData *more_p;
 		DWORD data;
 
 		switch (tag)
@@ -114,9 +114,9 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, int x0, int y0, DWORD tags_
 			break;
 
 		case TAG_MORE:
-			more_p = va_arg (tags, va_list*);
+			more_p = va_arg (tags, TagMoreData*);
 			va_end (tags);
-			tags = *more_p;
+			tags = more_p->tagdata;
 			break;
 
 		case DTA_DestWidth:
diff --git a/src/v_text.cpp b/src/v_text.cpp
index bde25b81d..fd932e6cc 100644
--- a/src/v_text.cpp
+++ b/src/v_text.cpp
@@ -71,10 +71,10 @@ void STACK_ARGS DCanvas::DrawChar (int normalcolor, int x, int y, byte character
 	if (NULL != (pic = Font->GetChar (character, &dummy)))
 	{
 		const BYTE *range = Font->GetColorTranslation ((EColorRange)normalcolor);
-		va_list taglist;
-		va_start (taglist, character);
+		TagMoreData taglist;
+		va_start (taglist.tagdata, character);
 		DrawTexture (pic, x, y, DTA_Translation, range, TAG_MORE, &taglist);
-		va_end (taglist);
+		va_end (taglist.tagdata);
 	}
 }
 
@@ -125,7 +125,7 @@ void STACK_ARGS DCanvas::DrawText (int normalcolor, int x, int y, const char *st
 
 	while (tag != TAG_DONE)
 	{
-		va_list *more_p;
+		TagMoreData * more_p;
 		DWORD data;
 		void *ptrval;
 
@@ -137,9 +137,9 @@ void STACK_ARGS DCanvas::DrawText (int normalcolor, int x, int y, const char *st
 			break;
 
 		case TAG_MORE:
-			more_p = va_arg (tags, va_list*);
+			more_p = va_arg (tags, TagMoreData*);
 			va_end (tags);
-			tags = *more_p;
+			tags = more_p->tagdata;
 			break;
 
 		case DTA_DestWidth:
@@ -226,10 +226,10 @@ void STACK_ARGS DCanvas::DrawText (int normalcolor, int x, int y, const char *st
 
 		if (NULL != (pic = Font->GetChar (c, &w)))
 		{
-			va_list taglist;
-			va_start (taglist, string);
+			TagMoreData taglist;
+			va_start (taglist.tagdata, string);
 			DrawTexture (pic, cx, cy, DTA_Translation, range, TAG_MORE, &taglist);
-			va_end (taglist);
+			va_end (taglist.tagdata);
 		}
 		cx += (w + kerning) * scalex;
 	}
diff --git a/src/v_video.h b/src/v_video.h
index d4e3264e5..6de44d866 100644
--- a/src/v_video.h
+++ b/src/v_video.h
@@ -66,6 +66,11 @@ class FTexture;
 #define TAG_IGNORE	(1L) /* Ignore this Tag							*/
 #define TAG_MORE	(2L) /* Ends this list and continues with the	*/
 						 /* list pointed to in ti_Data 				*/
+struct TagMoreData
+{
+	va_list tagdata;
+};
+
 //#define TAG_SKIP	(3L) /* Skip this and the next ti_Data Tags		*/
 
 #define TAG_USER	((DWORD)(1L<<31))