[Commits] SDL: Fixed compiling IME test program with HAVE_SDL_TTF on C89 c...

libsdl.org revision control commits-owner at libsdl.org
Thu Mar 10 12:05:58 PST 2016


details:   https://hg.libsdl.org/SDL/rev/c14536d0deff
changeset: 10111:c14536d0deff
user:      Philipp Wiesemann <philipp.wiesemann at arcor.de>
date:      Thu Mar 10 21:00:27 2016 +0100
description:
Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.

diffstat:

 test/testime.c |  22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diffs (55 lines):

diff -r 3dd0469150ce -r c14536d0deff test/testime.c
--- a/test/testime.c	Thu Mar 10 21:00:13 2016 +0100
+++ b/test/testime.c	Thu Mar 10 21:00:27 2016 +0100
@@ -110,7 +110,6 @@
 #endif
 }
 
-
 void _Redraw(SDL_Renderer * renderer) {
     int w = 0, h = textRect.h;
     SDL_Rect cursorRect, underlineRect;
@@ -122,9 +121,14 @@
     if (*text)
     {
         SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, text, textColor);
-        SDL_Rect dest = {textRect.x, textRect.y, textSur->w, textSur->h };
+        SDL_Rect dest;
+        SDL_Texture *texture;
+        dest.x = textRect.x;
+        dest.y = textRect.y;
+        dest.w = textSur->w;
+        dest.h = textSur->h;
 
-        SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer,textSur);
+        texture = SDL_CreateTextureFromSurface(renderer,textSur);
         SDL_FreeSurface(textSur);
 
         SDL_RenderCopy(renderer,texture,NULL,&dest);
@@ -156,6 +160,9 @@
     if (markedText[0])
     {
 #ifdef HAVE_SDL_TTF
+        SDL_Surface *textSur;
+        SDL_Rect dest;
+        SDL_Texture *texture;
         if (cursor)
         {
             char *p = utf8_advance(markedText, cursor);
@@ -169,10 +176,13 @@
             cursorRect.x += w;
             *p = c;
         }
-        SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, markedText, textColor);
-        SDL_Rect dest = {markedRect.x, markedRect.y, textSur->w, textSur->h };
+        textSur = TTF_RenderUTF8_Blended(font, markedText, textColor);
+        dest.x = markedRect.x;
+        dest.y = markedRect.y;
+        dest.w = textSur->w;
+        dest.h = textSur->h;
         TTF_SizeUTF8(font, markedText, &w, &h);
-        SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer,textSur);
+        texture = SDL_CreateTextureFromSurface(renderer,textSur);
         SDL_FreeSurface(textSur);
 
         SDL_RenderCopy(renderer,texture,NULL,&dest);


More information about the commits mailing list