Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
fe130de5
Commit
fe130de5
authored
Jul 17, 2003
by
rswindell
Browse files
Bugfix in new read/compile block (was always reading script from stdin).
parent
4a1c0ca1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
src/sbbs3/jsexec.c
src/sbbs3/jsexec.c
+17
-4
No files found.
src/sbbs3/jsexec.c
View file @
fe130de5
...
...
@@ -498,6 +498,7 @@ long js_exec(const char *fname, char** args)
JSScript
*
js_script
=
NULL
;
JSString
*
arg
;
JSObject
*
argv
;
FILE
*
fp
=
stdin
;
jsval
val
;
jsval
rval
=
JSVAL_VOID
;
int32
result
=
0
;
...
...
@@ -514,6 +515,11 @@ long js_exec(const char *fname, char** args)
fprintf
(
errfp
,
"!Module file (%s) doesn't exist
\n
"
,
path
);
return
(
-
1
);
}
if
((
fp
=
fopen
(
path
,
"r"
))
==
NULL
)
{
fprintf
(
errfp
,
"!Error %d (%s) opening %s
\n
"
,
errno
,
STRERROR
(
errno
),
path
);
return
(
-
1
);
}
}
JS_ClearPendingException
(
js_cx
);
...
...
@@ -541,13 +547,14 @@ long js_exec(const char *fname, char** args)
JS_SetBranchCallback
(
js_cx
,
js_BranchCallback
);
if
(
f
name
==
NULL
)
/* Us
e
stdin for script source */
if
(
f
p
==
stdin
)
/* Us
ing
stdin for script source */
SAFECOPY
(
path
,
"stdin"
);
fprintf
(
statfp
,
"Reading script from %s
\n
"
,
path
);
line_no
=
0
;
js_buflen
=
0
;
while
(
!
feof
(
stdin
))
{
if
(
!
fgets
(
line
,
sizeof
(
line
),
stdin
))
while
(
!
feof
(
fp
))
{
if
(
!
fgets
(
line
,
sizeof
(
line
),
fp
))
break
;
line_no
++
;
#ifdef __unix__
/* Support Unix Shell Scripts that start with #!/path/to/jsexec */
...
...
@@ -563,7 +570,7 @@ long js_exec(const char *fname, char** args)
js_buflen
+=
strlen
(
line
);
}
if
((
js_script
=
JS_CompileScript
(
js_cx
,
js_scope
,
js_buf
,
js_buflen
,
fname
==
NULL
?
NULL
:
path
,
1
))
==
NULL
)
{
fprintf
(
errfp
,
"!Error compiling script from
stdin
\n
"
);
fprintf
(
errfp
,
"!Error compiling script from
%s
\n
"
,
path
);
return
(
-
1
);
}
JS_ExecuteScript
(
js_cx
,
js_scope
,
js_script
,
&
rval
);
...
...
@@ -581,6 +588,12 @@ long js_exec(const char *fname, char** args)
JS_GC
(
js_cx
);
if
(
fp
!=
NULL
&&
fp
!=
stdin
)
fclose
(
fp
);
if
(
js_buf
!=
NULL
)
free
(
js_buf
);
return
(
result
);
}
...
...
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