cleanup
This commit is contained in:
parent
c477f71dd2
commit
6dad574249
48
lib/tput.js
48
lib/tput.js
|
@ -837,54 +837,6 @@ Tput.prototype.parseTermCap = function(data) {
|
|||
return terms;
|
||||
};
|
||||
|
||||
Tput.prototype.parseTermCap_ = function(data) {
|
||||
var terms = {}
|
||||
, term;
|
||||
|
||||
// remove escaped newlines
|
||||
data = data.replace(/\\\n\s*/g, '');
|
||||
|
||||
// remove comments
|
||||
data = data.replace(/^#[^\n]+/gm, '');
|
||||
|
||||
// could split by line instead
|
||||
data = data.replace(/\s+/g, '');
|
||||
|
||||
var fields = data.split(/:+/)
|
||||
, l = fields.length
|
||||
, i = 0
|
||||
, field
|
||||
, names;
|
||||
|
||||
for (; i < l; i++) {
|
||||
field = fields[i].trim();
|
||||
if (!field) continue;
|
||||
|
||||
names = field.split('|');
|
||||
if (names.length > 1) {
|
||||
term = terms[names[0]] = {};
|
||||
term.header = {
|
||||
desc: names.pop(),
|
||||
names: names
|
||||
};
|
||||
term.bools = {};
|
||||
term.numbers = {};
|
||||
term.strings = {};
|
||||
continue;
|
||||
}
|
||||
|
||||
if (~field.indexOf('=')) {
|
||||
parts = field.split('=');
|
||||
term.strings[parts[0]] = parts.slice(1).join('=');
|
||||
} else if (~field.indexOf('#')) {
|
||||
parts = field.split('#');
|
||||
term.numbers[parts[0]] = +parts.slice(1).join('#');
|
||||
} else {
|
||||
term.bools[field] = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Termcap Compiler
|
||||
* man termcap
|
||||
|
|
Loading…
Reference in New Issue