Commit fd627ea9 authored by deuce's avatar deuce
Browse files

Add support for /MAINT

Close TIME.DAT after opening it.
If the variable arg to @DO .. IS, @DO .. ADD, and @IF ... IS is a string,
do not expand bare numeric variables (like X and Y).
parent b44c6680
...@@ -741,8 +741,6 @@ function getvar(name) { ...@@ -741,8 +741,6 @@ function getvar(name) {
var ret; var ret;
if (vars[name.toLowerCase()] === undefined) { if (vars[name.toLowerCase()] === undefined) {
if (name.toLowerCase() === 'nil')
return '';
return replace_vars(name); return replace_vars(name);
} }
if (name.substr(0, 2) === 'S&') if (name.substr(0, 2) === 'S&')
...@@ -776,6 +774,16 @@ function getvar(name) { ...@@ -776,6 +774,16 @@ function getvar(name) {
return ret; return ret;
} }
function getsvar(name, vname)
{
var v = getvar(name);
var fv = getvar(vname);
if (typeof fv === 'string' && typeof v !== 'string')
return name;
return v;
}
function expand_ticks(str) function expand_ticks(str)
{ {
if (typeof str !== 'string') if (typeof str !== 'string')
...@@ -1676,7 +1684,7 @@ function run_ref(sec, fname) ...@@ -1676,7 +1684,7 @@ function run_ref(sec, fname)
setvar(args[0], tmp.deleted); setvar(args[0], tmp.deleted);
} }
else else
setvar(args[0], getvar(args[2])); setvar(args[0], getsvar(args[2], args[0]));
return; return;
} }
if (args.length > 2 && args[1] == '-') { if (args.length > 2 && args[1] == '-') {
...@@ -1688,7 +1696,7 @@ function run_ref(sec, fname) ...@@ -1688,7 +1696,7 @@ function run_ref(sec, fname)
return; return;
} }
if (args.length > 2 && args[1].toLowerCase() === 'add') { if (args.length > 2 && args[1].toLowerCase() === 'add') {
setvar(args[0], getvar(args[0]) + getvar(args[2]).toString()); setvar(args[0], getvar(args[0]) + getsvar(args[2], args[0]).toString());
return; return;
} }
if (args.length > 2 && args[1] == '/') { if (args.length > 2 && args[1] == '/') {
...@@ -1785,7 +1793,7 @@ function run_ref(sec, fname) ...@@ -1785,7 +1793,7 @@ function run_ref(sec, fname)
tmp = getvar(args[3]).length; tmp = getvar(args[3]).length;
} }
else else
tmp = getvar(args[2]); tmp = getsvar(args[2], args[0]);
if (getvar(args[0]).toString() === tmp.toString()) if (getvar(args[0]).toString() === tmp.toString())
handlers.do(args.slice(4)); handlers.do(args.slice(4));
else if (args[4].toLowerCase() === 'begin') else if (args[4].toLowerCase() === 'begin')
...@@ -3881,9 +3889,10 @@ function load_time() ...@@ -3881,9 +3889,10 @@ function load_time()
if (!f.open('r')) if (!f.open('r'))
throw('Unable to open '+f.name); throw('Unable to open '+f.name);
state.time = parseInt(f.readln(), 10); state.time = parseInt(f.readln(), 10);
f.close();
} }
if (newday) { if (newday || argv.indexOf('/MAINT') !== -1) {
f = new File(getfname('stime.dat')); f = new File(getfname('stime.dat'));
if (!f.open('r+b')) if (!f.open('r+b'))
throw('Unable to open '+f.name); throw('Unable to open '+f.name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment