Skip to content
GitLab
Explore
Sign in
Commits on Source (2)
Fixes a segv and other wrong behaviours from changing to use AUTOFREE_BUFFERs
· 08e6e5e0
Dom Rushbrook
authored
Oct 29, 2015
08e6e5e0
Merge branch 'master' of projects.sucs.org:arthur/mw
· b7561512
Dom Rushbrook
authored
Oct 29, 2015
b7561512
Hide whitespace changes
Inline
Side-by-side
src/client/script_inst.c
View file @
b7561512
...
...
@@ -174,7 +174,7 @@ void scr_time( struct code *pc, int fargc, char **fargv )
}
/* set default idle time to zero */
s
np
rin
tf
(
value
,
MAXTEXTLENGTH
-
1
,
"0"
);
s
t
rin
g_add
(
&
value
,
"0"
);
size_t
wi
;
json_t
*
entry
;
...
...
@@ -184,7 +184,7 @@ void scr_time( struct code *pc, int fargc, char **fargv )
if
(
!
strcasecmp
(
name
,
uname
))
{
s
np
rin
tf
(
value
,
MAXTEXTLENGTH
-
1
,
"%ld"
,
now
-
idletime
);
s
t
rin
g_add
(
&
value
,
"%ld"
,
now
-
idletime
);
if
(
script_debug
)
printf
(
"- %s: Idletime is %ld
\n
"
,
pc
->
inst
->
name
,
now
-
idletime
);
}
}
...
...
@@ -193,9 +193,10 @@ void scr_time( struct code *pc, int fargc, char **fargv )
else
if
(
!
strcasecmp
(
pc
->
inst
->
name
,
"whenami"
))
{
struct
tm
*
tt
;
tt
=
localtime
(
&
now
);
strftime
(
value
,
MAXTEXTLENGTH
-
1
,
"%H:%M"
,
tt
);
value
=
malloc
(
10
);
strftime
(
value
,
9
,
"%H:%M"
,
tt
);
}
else
if
(
!
strcasecmp
(
pc
->
inst
->
name
,
"date"
))
{
...
...
@@ -963,16 +964,16 @@ void scr_split( struct code *pc, int fargc, char **fargv )
char
*
bbp
;
if
((
bbp
=
strchr
(
ccp
,
' '
))
==
NULL
)
{
VAR_STR_UPDATE
(
&
var1
,
cc
);
VAR_STR_UPDATE
(
&
var1
,
cc
p
);
VAR_STR_UPDATE
(
&
var2
,
""
);
}
else
{
bbp
=
bb
;
bbp
++
;
VAR_STR_UPDATE
(
&
var2
,
bbp
);
*
bb
=
0
;
VAR_STR_UPDATE
(
&
var1
,
cc
);
char
*
dd
=
bb
p
;
dd
++
;
VAR_STR_UPDATE
(
&
var2
,
dd
);
*
bb
p
=
0
;
VAR_STR_UPDATE
(
&
var1
,
cc
p
);
}
}
...
...