add comments explaining extended parsing.

This commit is contained in:
Christopher Jeffrey 2013-02-24 19:15:53 -06:00
parent a549b6e56f
commit 7a7bc00777
1 changed files with 21 additions and 17 deletions

View File

@ -213,24 +213,25 @@ Tput.prototype.parseTerminfo = function(data) {
// lastStrTableOffset: 680,
// total: 245 },
// For xterm, offsets:
// { header: '0 - 10',
// bools: '10 - 12',
// numbers: '12 - 14',
// For xterm, layout:
// { header: '0 - 10', // length: 10
// bools: '10 - 12', // length: 2
// numbers: '12 - 14', // length: 2
// strings: '14 - 128', // length: 114 (57 short)
// symstrings: '128 - 248', // length: 120 (60 short)
// stringData: '248 - 612',
// sym: '612 - 928' }
// symoffsets: '128 - 248', // length: 120 (60 short)
// stringtable: '248 - 612', // length: 364
// sym: '612 - 928' } // length: 316
//
// header size: 10
// bools size: 2
// numbers size: 4
// string-offset size: 114
// sym-offset size: 120
// string table size: 364
// sym size: 316
// 364 + 316 === 680 (lastStrTableOffset)
// data.length - h.lastStrTableOffset === 248 (sym-offset size)
// How lastStrTableOffset works:
// data.length - h.lastStrTableOffset === 248 (sym-offset end, string-table start)
// 364 + 316 === 680 (lastStrTableOffset)
// How strTableSize works:
// h.strCount + [symOffsetCount] === h.strTableSize
// 57 + 60 === 117 (strTableSize)
// symOffsetCount doesn't actually exist in the header. it's just implied.
// Getting the number of sym offsets:
// h.symOffsetCount = h.strTableSize - h.strCount;
// h.symOffsetSize = (h.strTableSize - h.strCount) * 2;
Tput.prototype.parseExtended = function(data) {
var info = {}
@ -247,6 +248,8 @@ Tput.prototype.parseExtended = function(data) {
lastStrTableOffset: (data[i + 9] << 8) | data[i + 8]
};
// h.symOffsetCount = h.strTableSize - h.strCount;
h.total = h.headerSize
+ h.boolCount
+ h.numCount * 2
@ -294,6 +297,7 @@ Tput.prototype.parseExtended = function(data) {
// Pass over the sym offsets and get to the string table.
i = data.length - h.lastStrTableOffset;
// i += h.symOffsetCount * 2;
// String Table
var high = 0;
@ -328,7 +332,7 @@ Tput.prototype.parseExtended = function(data) {
l = data.length;
var sym = []
, j = 0;
, j;
for (; i < l; i++) {
j = i;