Skip to content

Commit

Permalink
Более правильная работа с переопределением в global.
Browse files Browse the repository at this point in the history
  • Loading branch information
veged committed Nov 3, 2009
1 parent 3defd18 commit 214349e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tests.js
@@ -1,14 +1,14 @@
if (!load && include && system.getcwd)
var load = function(f) {
var oldLoad = load;
var load = global.load = function(f) {
var oldLoad = global.load;
if (f.indexOf('/') != -1)
global.load = function(ff){ return oldLoad(f.replace(/[^\/]+$/, '') + ff) };
var result = eval.call(global, new File(system.getcwd() + '/' + f).open("r").read());
global.load = oldLoad;
return result;
};
if (!print && system.stdout)
var print = function(d) { system.stdout(d + '\n'); return d; };
var print = global.print = function(d) { system.stdout(d + '\n'); return d; };

var tests = [
{
Expand Down
6 changes: 3 additions & 3 deletions translate.js
@@ -1,16 +1,16 @@
#!/usr/bin/env v8cgi

if (!load && include && system.getcwd)
var load = function(f) {
var oldLoad = load;
var load = global.load = function(f) {
var oldLoad = global.load;
if (f.indexOf('/') != -1)
global.load = function(ff){ return oldLoad(f.replace(/[^\/]+$/, '') + ff) };
var result = eval.call(global, new File(system.getcwd() + '/' + f).open("r").read());
global.load = oldLoad;
return result;
};
if (!print && system.stdout)
var print = function(d) { return system.stdout(d + '\n') };
var print = global.load = function(d) { return system.stdout(d + '\n') };


(function(){
Expand Down

0 comments on commit 214349e

Please sign in to comment.