Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit c49151c9 authored by Deucе's avatar Deucе 👌🏾

Deal with the three classes of variables...

1) ` vars which are always expanded.
2) & vars which are expanded "sometimes" (generally for display stuff).
3) "pure" vars which are only expanded when they are the entire string.

The main change here is in the & var handling... lw() no longer
expands these, so they can be displayed to the user... they are now
expanded in the following cases:

1) Anything that calculates the displayed length.  The assumption
   here is that the string will be passed to one of the following
   things.
2) Bar updates, either @quebar or @saybar
3) @do addlog
4) @do write
5) @moremap
6) @progname
7) @show
8) @writefile
parent 6f6a4ff2
......@@ -802,7 +802,7 @@ function broken_displen(str)
{
var i;
str = expand_ticks(replace_vars(str));
str = expand_ticks(replace_vars(replace_svars(str)));
return str.length;
}
......@@ -1304,7 +1304,6 @@ function replace_vars(str)
{
if (typeof str !== 'string')
return str;
str = str.replace(/([Ss]?&[A-Za-z]+)/g, function(m, r1) { return getvar(r1, true); });
str = str.replace(/(`[Vv][0-4][0-9])/g, function(m, r1) { return getvar(r1, true); });
str = str.replace(/(`[Ss][0-1][0-9])/g, function(m, r1) { return getvar(r1, true); });
str = str.replace(/(`[Pp][0-9][0-9])/g, function(m, r1) { return getvar(r1, true); });
......@@ -1316,6 +1315,14 @@ function replace_vars(str)
return str;
}
function replace_svars(str)
{
if (typeof str !== 'string')
return str;
str = str.replace(/([Ss]?&[A-Za-z]+)/g, function(m, r1) { return getvar(r1, true); });
return str;
}
function getoffset(x, y) {
return (x * 20 + y);
}
......
......@@ -79,7 +79,7 @@ function redraw_bar(updstatus)
function update_bar(str, msg, timeout)
{
str = replace_vars(str);
str = replace_vars(replace_svars(str));
var dl = displen(str);
var l;
......@@ -261,7 +261,7 @@ function run_ref(sec, fname)
return;
if (f.open('ab')) {
cl = files[fname].lines[line];
f.write(replace_vars(cl)+'\r\n');
f.write(replace_vars(replace_svars(cl))+'\r\n');
f.close();
}
},
......@@ -548,7 +548,7 @@ function run_ref(sec, fname)
if (line > files[fname].lines.length)
return;
cl = files[fname].lines[line];
lw(replace_vars(cl));
lw(replace_vars(replace_svars(cl)));
},
};
var handlers = {
......@@ -1242,7 +1242,7 @@ function run_ref(sec, fname)
if (line > files[fname].lines.length)
return;
cl = files[fname].lines[line];
morestr = replace_vars(cl);
morestr = replace_vars(replace_svars(cl));
},
'nocheck':function(args) {
// We don't really support this because there's no need for it.
......@@ -1269,7 +1269,7 @@ function run_ref(sec, fname)
if (line > files[fname].lines.length)
return;
cl = files[fname].lines[line];
progname = replace_vars(cl);
progname = replace_vars(replace_svars(cl));
},
'rank':function(args) {
// TODO: No real clue what the filename is for...
......@@ -1447,7 +1447,7 @@ rescan:
if (args.length === 0) {
l.forEach(function(l) {
lln(replace_vars(l));
lln(replace_vars(replace_svars(l)));
});
}
else if (args[0].toLowerCase() === 'scroll') {
......@@ -1543,7 +1543,7 @@ rescan:
if (!f.open('ab'))
throw new Error('Unable to open '+f.name+' at '+fname+':'+line);
getlines().forEach(function(l) {
f.write(replace_vars(l)+'\r\n');
f.write(replace_vars(replace_svars(l))+'\r\n');
});
f.close();
},
......
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