SheetJS
5c7df1f3db
- reworked IIFE - avoid Buffer read helpers (see https://github.com/joyent/node/issues/7809) - avoid nested functions in parse - eliminate consecutive nulls in test files (libreoffice) - travis + coveralls support - jscs linting
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
/* [MS-CFB] 2.6.4 Red-Black Tree */
|
|
function build_full_paths(FI, FPD, FP, Paths) {
|
|
var i = 0, L = 0, R = 0, C = 0, j = 0, pl = Paths.length;
|
|
var dad = new Array(pl), q = new Array(pl);
|
|
|
|
for(; i < pl; ++i) { dad[i]=q[i]=i; FP[i]=Paths[i]; }
|
|
|
|
for(; j < q.length; ++j) {
|
|
i = q[j];
|
|
L = FI[i].L; R = FI[i].R; C = FI[i].C;
|
|
if(dad[i] === i) {
|
|
if(L !== -1 /*NOSTREAM*/ && dad[L] !== L) dad[i] = dad[L];
|
|
if(R !== -1 && dad[R] !== R) dad[i] = dad[R];
|
|
}
|
|
if(C !== -1 /*NOSTREAM*/) dad[C] = i;
|
|
if(L !== -1) { dad[L] = dad[i]; q.push(L); }
|
|
if(R !== -1) { dad[R] = dad[i]; q.push(R); }
|
|
}
|
|
for(i=1; i !== pl; ++i) if(dad[i] === i) {
|
|
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
|
|
else if(L !== -1 && dad[L] !== L) dad[i] = dad[L];
|
|
}
|
|
|
|
for(i=1; i < pl; ++i) {
|
|
if(FI[i].type === 0 /* unknown */) continue;
|
|
j = dad[i];
|
|
if(j === 0) FP[i] = FP[0] + "/" + FP[i];
|
|
else while(j !== 0) {
|
|
FP[i] = FP[j] + "/" + FP[i];
|
|
j = dad[j];
|
|
}
|
|
dad[i] = 0;
|
|
}
|
|
|
|
FP[0] += "/";
|
|
for(i=1; i < pl; ++i) {
|
|
if(FI[i].type !== 2 /* stream */) FP[i] += "/";
|
|
FPD[FP[i]] = FI[i];
|
|
}
|
|
}
|
|
|