diff options
author | Sam Lantinga <slouken@libsdl.org> | 2010-08-22 11:56:07 -0700 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2010-08-22 11:56:07 -0700 |
commit | 9b8ec5c66ad236b72013cc04066e178604fb5903 (patch) | |
tree | 46281f97cceff4e3dba824a97d3f0da8b4d7e2af | |
parent | 43cd4e54ac5885a002d58f6d2570cf515e319d32 (diff) |
Don't need to use strlen() to determine if there's text.
Use the SDL safe strcpy() function
-rw-r--r-- | test/testime.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/testime.c b/test/testime.c index c2b5b045..bae74000 100644 --- a/test/testime.c +++ b/test/testime.c @@ -136,7 +136,7 @@ static void RenderText(SDL_Surface *sur, 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 @@ void Redraw() 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 @@ int main(int argc, char *argv[]) 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); |