diff --git a/lib/tput.js b/lib/tput.js index 86cfc17..8224eb4 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -1030,7 +1030,7 @@ Tput.prototype.readTermcap = function(data) { || Tput.termcap; var terms = this.parseTermcap(data) - , term = terms[this.term]; + , root = terms[this.term]; if (this.debug) { this._termcap = terms; @@ -1038,32 +1038,32 @@ Tput.prototype.readTermcap = function(data) { (function tc(term) { if (term && term.strings.tc) { + root.inherits = root.inherits || []; + root.inherits.push(term.strings.tc); + if (self.debug && terms[term.strings.tc]) { - console.log(term.names.join('/') - + ' inherits from ' - + terms[term.strings.tc].names.join('/')); + console.log(term.names.join('/') + ' inherits from ' + + terms[term.strings.tc].names.join('/')); } - var t = terms[self.term]; - t.inherits = t.inherits || []; - t.inherits.push(term.strings.tc); + if (self.debug) { + var names = terms[term.strings.tc] + ? terms[term.strings.tc].names + : [term.strings.tc]; + console.log(term.names.join('/') + ' inherits from ' + names.join('/')); + } var inherit = tc(terms[term.strings.tc]); if (inherit) { - if (0 && self.debug) { - console.log(term.names.join('/') - + ' inherits from ' - + inherit.names.join('/')); - } ['bools', 'numbers', 'strings'].forEach(function(type) { merge(term[type], inherit[type]); }); } } return term; - })(term); + })(root); - return term; + return root; }; /**