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
63be5587
Commit
63be5587
authored
18 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Move everything into a function named xjs_load() which can be called by xjs
files to convert another xjs file to ssjs and load() it.
parent
120bf828
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/xjs_handler.js
+69
-56
69 additions, 56 deletions
exec/xjs_handler.js
with
69 additions
and
56 deletions
exec/xjs_handler.js
+
69
−
56
View file @
63be5587
...
...
@@ -2,86 +2,99 @@
/* $Id$ */
var
filename
;
var
xjs_
filename
;
if
(
this
.
http_request
!=
undefined
)
/* Requested through web-server */
filename
=
http_request
.
real_path
;
xjs_
filename
=
http_request
.
real_path
;
else
filename
=
argv
[
0
];
xjs_
filename
=
argv
[
0
];
var
ssjs_filename
=
filename
+
"
.ssjs
"
;
var
last_cwd
=
''
;
// Probably a race condition on Win32
if
(
file_exists
(
ssjs_filename
))
{
if
(
file_date
(
ssjs_filename
)
<=
file_date
(
filename
))
{
file_remove
(
ssjs_filename
);
}
}
xjs_load
(
xjs_filename
);
function
xjs_load
(
filename
)
{
var
cwd
=
filename
;
cwd
=
cwd
.
replace
(
/
[^\\\/]
*$/
,
''
);
if
(
!
file_exists
(
ssjs_filename
))
{
var
file
=
new
File
(
filename
);
if
(
!
file
.
open
(
"
r
"
,
true
,
8192
))
{
writeln
(
"
!ERROR
"
+
file
.
error
+
"
opening
"
+
filename
);
exit
();
if
(
last_cwd
!=
''
)
filename
=
last_cwd
+
'
/
'
+
filename
;
var
ssjs_filename
=
filename
+
"
.ssjs
"
;
// Probably a race condition on Win32
if
(
file_exists
(
ssjs_filename
))
{
if
(
file_date
(
ssjs_filename
)
<=
file_date
(
filename
))
{
file_remove
(
ssjs_filename
);
}
}
var
text
=
file
.
readAll
(
8192
);
file
.
close
();
var
script
=
""
;
if
(
!
file_exists
(
ssjs_filename
))
{
var
file
=
new
File
(
filename
);
if
(
!
file
.
open
(
"
r
"
,
true
,
8192
))
{
writeln
(
"
!ERROR
"
+
file
.
error
+
"
opening
"
+
filename
);
exit
();
}
var
text
=
file
.
readAll
(
8192
);
file
.
close
();
var
script
=
""
;
var
in_xjs
=
false
;
for
(
line
in
text
)
{
var
str
=
text
[
line
];
while
(
str
!=
''
)
{
if
(
!
in_xjs
)
{
if
(
str
==
'
<?xjs
'
||
str
==
'
<?
'
)
{
in_xjs
=
true
;
str
=
''
;
var
in_xjs
=
false
;
for
(
line
in
text
)
{
var
str
=
text
[
line
];
while
(
str
!=
''
)
{
if
(
!
in_xjs
)
{
if
(
str
==
'
<?xjs
'
||
str
==
'
<?
'
)
{
in_xjs
=
true
;
str
=
''
;
}
else
{
if
(
str
.
search
(
/<
\?(
xjs
)?\s
+/
)
==-
1
)
{
script
+=
"
writeln(
"
+
escape_quotes
(
str
)
+
"
);
"
;
str
=
''
;
}
else
{
str
=
str
.
replace
(
/^
(
.*
?)
<
\?(
xjs
)?\s
+/
,
function
(
str
,
p1
,
p2
,
offset
,
s
)
{
if
(
p1
!=
''
)
script
+=
"
write(
"
+
escape_quotes
(
p1
)
+
"
);
"
;
in_xjs
=
true
;
return
''
;
}
);
}
}
}
else
{
if
(
str
.
search
(
/
<
\?
(
xjs
)?\s
+
/
)
==-
1
)
{
script
+=
"
writeln(
"
+
escape_quotes
(
str
)
+
"
);
"
;
if
(
str
.
search
(
/
\?
>
/
)
==-
1
)
{
script
+=
str
;
str
=
''
;
}
else
{
str
=
str
.
replace
(
/^
(
.*
?)
<
\?(
xjs
)?\s
+/
,
function
(
str
,
p1
,
p2
,
offset
,
s
)
{
if
(
p1
!=
''
)
script
+=
"
write(
"
+
escape_quotes
(
p1
)
+
"
);
"
;
in_xjs
=
true
;
str
=
str
.
replace
(
/^
(
.*
?)\?
>/
,
function
(
str
,
p1
,
offset
,
s
)
{
script
+=
p1
+
"
;
"
;
in_xjs
=
false
;
return
''
;
}
);
}
}
}
else
{
if
(
str
.
search
(
/
\?
>/
)
==-
1
)
{
script
+=
str
;
str
=
''
;
}
else
{
str
=
str
.
replace
(
/^
(
.*
?)\?
>/
,
function
(
str
,
p1
,
offset
,
s
)
{
script
+=
p1
+
"
;
"
;
in_xjs
=
false
;
return
''
;
}
);
}
}
script
+=
'
\n
'
;
}
script
+=
'
\n
'
;
}
var
f
=
new
File
(
ssjs_filename
);
if
(
f
.
open
(
"
w
"
,
false
))
{
f
.
write
(
script
);
f
.
close
();
var
f
=
new
File
(
ssjs_filename
);
if
(
f
.
open
(
"
w
"
,
false
))
{
f
.
write
(
script
);
f
.
close
();
}
}
}
load
(
ssjs_filename
);
last_cwd
=
cwd
;
load
(
ssjs_filename
);
}
function
escape_quotes
(
arg
)
{
return
(
"
'
"
+
arg
.
replace
(
/'/g
,
"
'+
"
+
'
"
'
+
"
'
"
+
'
"+
'
+
"
'
"
)
+
"
'
"
);
...
...
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