Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Don't need to use strlen() to determine if there's text.
Browse files Browse the repository at this point in the history
Use the SDL safe strcpy() function
  • Loading branch information
slouken committed Aug 22, 2010
1 parent 1c48525 commit 8b6ea0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/testime.c
Expand Up @@ -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 };

Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 8b6ea0c

Please sign in to comment.