Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
9b8ec5c6
Commit
9b8ec5c6
authored
Aug 22, 2010
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't need to use strlen() to determine if there's text.
Use the SDL safe strcpy() function
parent
43cd4e54
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
testime.c
test/testime.c
+3
-3
No files found.
test/testime.c
View file @
9b8ec5c6
...
@@ -136,7 +136,7 @@ static void RenderText(SDL_Surface *sur,
...
@@ -136,7 +136,7 @@ static void RenderText(SDL_Surface *sur,
int
x
,
int
y
,
int
x
,
int
y
,
SDL_Color
color
)
SDL_Color
color
)
{
{
if
(
text
&&
strlen
(
text
)
)
{
if
(
text
&&
*
text
)
{
SDL_Surface
*
textSur
=
TTF_RenderUTF8_Blended
(
font
,
text
,
color
);
SDL_Surface
*
textSur
=
TTF_RenderUTF8_Blended
(
font
,
text
,
color
);
SDL_Rect
dest
=
{
x
,
y
,
textSur
->
w
,
textSur
->
h
};
SDL_Rect
dest
=
{
x
,
y
,
textSur
->
w
,
textSur
->
h
};
...
@@ -154,7 +154,7 @@ void Redraw()
...
@@ -154,7 +154,7 @@ void Redraw()
SDL_FillRect
(
screen
,
&
textRect
,
backColor
);
SDL_FillRect
(
screen
,
&
textRect
,
backColor
);
#ifdef HAVE_SDL_TTF
#ifdef HAVE_SDL_TTF
if
(
strlen
(
text
)
)
if
(
*
text
)
{
{
RenderText
(
screen
,
font
,
text
,
textRect
.
x
,
textRect
.
y
,
textColor
);
RenderText
(
screen
,
font
,
text
,
textRect
.
x
,
textRect
.
y
,
textColor
);
TTF_SizeUTF8
(
font
,
text
,
&
w
,
&
h
);
TTF_SizeUTF8
(
font
,
text
,
&
w
,
&
h
);
...
@@ -295,7 +295,7 @@ int main(int argc, char *argv[])
...
@@ -295,7 +295,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"Keyboard: text input
\"
%s
\"\n
"
,
event
.
text
.
text
);
fprintf
(
stderr
,
"Keyboard: text input
\"
%s
\"\n
"
,
event
.
text
.
text
);
if
(
SDL_strlen
(
text
)
+
SDL_strlen
(
event
.
text
.
text
)
<
sizeof
(
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
);
fprintf
(
stderr
,
"text inputed: %s
\n
"
,
text
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment