cleanup _prefix and readTermcap.

This commit is contained in:
Christopher Jeffrey 2013-08-29 17:41:19 -05:00
parent a1c91ccb99
commit 97b6d6faee
1 changed files with 7 additions and 15 deletions

View File

@ -168,24 +168,19 @@ Tput.prototype._prefix = function(term) {
} }
var paths = Tput.ipaths.slice() var paths = Tput.ipaths.slice()
, file , file;
, i;
if (this.terminfoPrefix) { if (this.terminfoPrefix) {
paths.unshift(this.terminfoPrefix); paths.unshift(this.terminfoPrefix);
} }
// Try exact matches. // Try exact matches.
for (i = 0; i < paths.length; i++) { file = this._tprefix(paths, term);
file = this._tprefix(paths[i], term); if (file) return file;
if (file) return file;
}
// Try similar matches. // Try similar matches.
for (i = 0; i < paths.length; i++) { file = this._tprefix(paths, term, true);
file = this._tprefix(paths[i], term, true); if (file) return file;
if (file) return file;
}
// Not found. // Not found.
throw new Error('Terminfo directory not found.'); throw new Error('Terminfo directory not found.');
@ -205,7 +200,7 @@ Tput.prototype._tprefix = function(prefix, term, soft) {
if (Array.isArray(prefix)) { if (Array.isArray(prefix)) {
for (i = 0; i < prefix.length; i++) { for (i = 0; i < prefix.length; i++) {
file = this._tprefix(prefix[i], term); file = this._tprefix(prefix[i], term, soft);
if (file) return file; if (file) return file;
} }
return; return;
@ -1259,10 +1254,7 @@ Tput.prototype.readTermcap = function(term) {
paths.push(Tput.termcap); paths.push(Tput.termcap);
for (i = 0; i < paths.length; i++) { terms = this._tryCap(paths, term);
terms = this._tryCap(paths[i], term);
if (terms) break;
}
} }
if (!terms) { if (!terms) {