# HG changeset patch # User Sam Lantinga # Date 1282503367 25200 # Node ID 08d22c54a21fd1a9079966a0403ab17337c49599 # Parent 8c229370ddbacaeced0e20a539ba606ea750edcb Don't need to use strlen() to determine if there's text. Use the SDL safe strcpy() function diff -r 8c229370ddba -r 08d22c54a21f test/testime.c --- a/test/testime.c Thu Aug 12 16:00:47 2010 +0200 +++ b/test/testime.c Sun Aug 22 11:56:07 2010 -0700 @@ -136,7 +136,7 @@ int x, int y, SDL_Color color) { - if (text && strlen(text)) { + if (text && *text) { SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, text, color); SDL_Rect dest = { x, y, textSur->w, textSur->h }; @@ -154,7 +154,7 @@ SDL_FillRect(screen, &textRect, backColor); #ifdef HAVE_SDL_TTF - if (strlen(text)) + if (*text) { RenderText(screen, font, text, textRect.x, textRect.y, textColor); TTF_SizeUTF8(font, text, &w, &h); @@ -295,7 +295,7 @@ 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); + SDL_strlcpy(text + SDL_strlen(text), event.text.text, sizeof(text)); fprintf(stderr, "text inputed: %s\n", text);