# HG changeset patch # User dewyatt # Date 1280018930 14400 # Node ID b99b1024607a5c84db405b015b77e5b6f719b448 # Parent 436183eb30c849151429ddc22ae0c4aa28fb144e Changed markedText to have its own storage to resolve multiple bugs. Changed an odd strcpy to a more appropriate strcat. diff -r 436183eb30c8 -r b99b1024607a test/testime.c --- a/test/testime.c Sun Jul 18 13:48:23 2010 -0400 +++ b/test/testime.c Sat Jul 24 20:48:50 2010 -0400 @@ -25,7 +25,7 @@ SDL_Rect textRect, markedRect; Uint32 lineColor, backColor; SDL_Color textColor = { 0, 0, 0 }; -char text[MAX_TEXT_LENGTH], *markedText; +char text[MAX_TEXT_LENGTH], markedText[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; void usage() { @@ -124,7 +124,7 @@ text[0] = 0; markedRect = textRect; - markedText = NULL; + markedText[0] = 0; SDL_StartTextInput(); } @@ -178,7 +178,7 @@ cursorRect.h = h; SDL_FillRect(screen, &markedRect, backColor); - if (markedText) + if (markedText[0]) { #ifdef HAVE_SDL_TTF RenderText(screen, font, markedText, markedRect.x, markedRect.y, textColor); @@ -293,13 +293,13 @@ fprintf(stderr, "Keyboard: text input \"%s\"\n", event.text.text); if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text)) - strcpy(text + SDL_strlen(text), event.text.text); + strcat(text, event.text.text); fprintf(stderr, "text inputed: %s\n", text); // After text inputed, we can clear up markedText because it // is committed - markedText = NULL; + markedText[0] = 0; Redraw(); break; @@ -307,7 +307,7 @@ fprintf(stderr, "text editing \"%s\", selected range (%d, %d)\n", event.edit.text, event.edit.start, event.edit.length); - markedText = event.edit.text; + strcpy(markedText, event.edit.text); Redraw(); break;