Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Aayush
purr-data
Commits
00448223
Commit
00448223
authored
Jun 19, 2017
by
Jonathan Wilkes
Browse files
don't use functions that expect null-terminated strings with non-null-terminated
strings
parent
2e5e6c1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
pd/src/g_rtext.c
View file @
00448223
...
...
@@ -557,6 +557,7 @@ void rtext_activate(t_rtext *x, int state)
{
//fprintf(stderr,"rtext_activate state=%d\n", state);
int
w
=
0
,
h
=
0
,
widthspec
,
heightspec
,
indx
,
isgop
;
char
*
tmpbuf
;
t_glist
*
glist
=
x
->
x_glist
;
t_canvas
*
canvas
=
glist_getcanvas
(
glist
);
//if (state && x->x_active) printf("duplicate rtext_activate\n");
...
...
@@ -610,6 +611,13 @@ void rtext_activate(t_rtext *x, int state)
/* we need to get scroll to make sure we've got the
correct bbox for the svg */
canvas_getscroll
(
glist_getcanvas
(
canvas
));
/* ugly hack to get around the fact that x_buf is not
null terminated. If this becomes a problem we can revisit
it later */
tmpbuf
=
t_getbytes
(
x
->
x_bufsize
+
1
);
sprintf
(
tmpbuf
,
"%.*s"
,
x
->
x_bufsize
,
x
->
x_buf
);
/* in case x_bufsize is 0... */
tmpbuf
[
x
->
x_bufsize
]
=
'\0'
;
gui_vmess
(
"gui_textarea"
,
"xssiiiisiii"
,
canvas
,
x
->
x_tag
,
...
...
@@ -618,10 +626,11 @@ void rtext_activate(t_rtext *x, int state)
x
->
x_text
->
te_ypix
,
widthspec
,
heightspec
,
x
->
x_
buf
,
tmp
buf
,
sys_hostfontsize
(
glist_getfont
(
glist
)),
isgop
,
state
);
freebytes
(
tmpbuf
,
x
->
x_bufsize
+
1
);
}
// outputs 1 if found one of the special chars
...
...
pd/src/g_text.c
View file @
00448223
...
...
@@ -3009,7 +3009,9 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos)
//any point of recreating the object
binbuf_gettext
(
x
->
te_binbuf
,
&
c1
,
&
i1
);
binbuf_gettext
(
b
,
&
c2
,
&
i2
);
if
(
strcmp
(
c1
,
c2
))
/* must remember that binbuf_gettext does *not*
null-terminate, so we have to be careful here... */
if
(
i1
!=
i2
||
strncmp
(
c1
,
c2
,
i1
))
{
//fprintf(stderr,"string differs\n");
canvas_undo_add
(
glist_getcanvas
(
glist
),
10
,
"recreate"
,
...
...
@@ -3063,7 +3065,7 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos)
more than just a series of nearly-incomprehensible
side-effects, perhaps the issue may be revisited.
*/
if
(
strcmp
(
c1
,
c2
))
if
(
i1
!=
i2
||
str
n
cmp
(
c1
,
c2
,
i1
))
{
//fprintf(stderr,"text_setto calls canvas_undo_add recreate\n");
canvas_undo_add
(
glist_getcanvas
(
glist
),
10
,
"recreate"
,
...
...
@@ -3130,7 +3132,7 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos)
t_binbuf
*
b
=
binbuf_new
();
binbuf_text
(
b
,
buf
,
bufsize
);
binbuf_gettext
(
b
,
&
c2
,
&
i2
);
if
(
!
c1
||
strcmp
(
c1
,
c2
))
if
(
!
c1
||
i1
!=
i2
||
str
n
cmp
(
c1
,
c2
,
i1
))
{
canvas_undo_add
(
glist_getcanvas
(
glist
),
10
,
"typing"
,
(
void
*
)
canvas_undo_set_recreate
(
glist_getcanvas
(
glist
),
...
...
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