Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
fe130de5
Commit
fe130de5
authored
21 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix in new read/compile block (was always reading script from stdin).
parent
4a1c0ca1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/jsexec.c
+17
-4
17 additions, 4 deletions
src/sbbs3/jsexec.c
with
17 additions
and
4 deletions
src/sbbs3/jsexec.c
+
17
−
4
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
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment