/* [MS-OSHARED] 2.3.3.1.4 Lpstr
118
function parse_lpstr(blob, type, pad) {
	var start = blob.l;
	var str = blob.read_shift(0, 'lpstr-cp');
	if(pad) while((blob.l - start) & 3) ++blob.l;
	return str;
}
956898
function parse_PtgName(blob, length, opts) {
	var type = (blob.read_shift(1) >>> 5) & 0x03;
	var w = (!opts || (opts.biff >= 8)) ? 4 : 2;
	var nameindex = blob.read_shift(w);
	switch(opts.biff) {
		case 2: blob.l += 5; break;
		case 3: case 4: blob.l += 8; break;
		case 5: blob.l += 12; break;
	}
	return [type, 0, nameindex];
}
1245419
function deepSplitString (input, separators) {
  if (input === null || typeof input === 'undefined') {
    return input
  }
  if (separators.length === 0) {
    return input
  }

  const sep = separators.shift()
  let output = input

  if (typeof input === 'string') {
    output = splitString(input, sep)
  } else if (Array.isArray(input)) {
    output = input.map(i => splitString(i, sep))
  } else if (typeof input === 'object') {
    output = {}
    Object.keys(input).forEach(key => {
      output[key] = splitString(input[key], sep)
    })
  }

  if (separators.length > 0) {
    return deepSplitString(output, separators)
  } else {
    return output
  }
}
1068580
function(formatString, value) {

                var fieldDelimiterIndex;
                var fieldDelimiter = '{';
                var endPlaceholder = false;
                var formattedStringArray = [];

                while ((fieldDelimiterIndex = formatString.indexOf(fieldDelimiter)) !== -1) {

                    var pieceFormatedString, formatSpec, fieldName;

                    pieceFormatedString = formatString.slice(0, fieldDelimiterIndex);

                    if (endPlaceholder) {
                        formatSpec = pieceFormatedString.split(':');
                        fieldName = formatSpec.shift().split('.');
                        pieceFormatedString = value;

                        for (var i = 0; i < fieldName.length; i++)
                            pieceFormatedString = pieceFormatedString[fieldName[i]];

                        if (formatSpec.length)
                            pieceFormatedString = this.number(formatSpec, pieceFormatedString);
                    }

                    formattedStringArray.push(pieceFormatedString);

                    formatString = formatString.slice(fieldDelimiterIndex + 1);
                    endPlaceholder = !endPlaceholder;
                    fieldDelimiter = (endPlaceholder) ? '}' : '{';
                }
                formattedStringArray.push(formatString);

                return formattedStringArray.join('');
            }
1247920
def _pstorestr(ins):
    
    output = []
    temporal = False

    # 2nd operand first, because must go into the stack
    value = ins.quad[2]

    if value[0] == '*':
        value = value[1:]
        indirect = True
    else:
        indirect = False

    if value[0] == '_':
        output.append('ld de, (%s)' % value)

        if indirect:
            output.append('call __LOAD_DE_DE')
            REQUIRES.add('lddede.asm')

    elif value[0] == '#':
        output.append('ld de, %s' % value[1:])
    else:
        output.append('pop de')
        temporal = value[0] != '$'
        if indirect:
            output.append('call __LOAD_DE_DE')
            REQUIRES.add('lddede.asm')

    # Now 1st operand
    value = ins.quad[1]
    if value[0] == '*':
        value = value[1:]
        indirect = True
    else:
        indirect = False

    I = int(value)
    if I >= 0:
        I += 4  # Return Address + "push IX"

    output.append('ld bc, %i' % I)

    if not temporal:
        if indirect:
            output.append('call __PISTORE_STR')
            REQUIRES.add('storestr.asm')
        else:
            output.append('call __PSTORE_STR')
            REQUIRES.add('pstorestr.asm')
    else:
        if indirect:
            output.append('call __PISTORE_STR2')
            REQUIRES.add('storestr2.asm')
        else:
            output.append('call __PSTORE_STR2')
            REQUIRES.add('pstorestr2.asm')

    return output
675427
function handlePolyphone(array, splitter, joinChar)
{
    splitter = splitter || '';
    var result = [''], temp = [];
    for(var i=0; i<array.length; i++)
    {
        temp = [];
        var t = array[i].split(splitter);
        for(var j=0; j<t.length; j++)
        {
            for(var k=0; k<result.length; k++)
                temp.push(result[k] + (result[k]?joinChar:'') + t[j]);
        }
        result = temp;
    }
    return simpleUnique(result);
}
154397
function parseDirectory(dataStr) {
		let currChar = '';
		let directory = '';
		let pos = 24;

		while (currChar !== '\x1E') {
			currChar = dataStr.charAt(pos);
			if (currChar !== 'x1E') {
				directory += currChar;
			}

			pos++;

			if (pos > dataStr.length) {
				throw new Error('Invalid record');
			}
		}

		return directory;
	}
169795
function
  tlid__xtro(str) {
  var r = new Object();
  r.tlid = "-1";
  r.src = str;
  r.txt = "";
  // r.deco = "";

  if (tlid__has(str)) {
    r.tlid = tlid__xtr(str);
    r.txt = str.replace(r.tlid + " ", "") // try to clear out the double space
      .replace(r.tlid, "") // if ending the string, well we remove it
      .replace("@tlid ", ""); //remove the decorator

  }

  return r;
}
495144
function ends_withp(str, substr) {
        return slice(str, str.length - substr.length) == substr
    }
1102711
function parse_PtgAttrSemi(blob, length, opts) {
	var bitSemi = (blob[blob.l+1] & 0xFF) ? 1 : 0;
	blob.l += opts && opts.biff == 2 ? 3 : 4;
	return [bitSemi];
}
260042
function(str) {
    var startsWith = !_.isNull(str.match(rOpsHeadRe))
    return startsWith & cons.isLegalSentence(str)
  }
1313997
private int readCustomLine(Text str, int maxLineLength, int maxBytesToConsume)
    throws IOException {
    str.clear();
    int txtLength = 0; // tracks str.getLength(), as an optimization
    long bytesConsumed = 0;
    int delPosn = 0;
    do {
      int startPosn = bufferPosn; // starting from where we left off the last
      // time
      if (bufferPosn >= bufferLength) {
        startPosn = bufferPosn = 0;
        bufferLength = in.read(buffer);
        if (bufferLength <= 0)
          break; // EOF
      }
      for (; bufferPosn < bufferLength; ++bufferPosn) {
        if (buffer[bufferPosn] == recordDelimiterBytes[delPosn]) {
          delPosn++;
          if (delPosn >= recordDelimiterBytes.length) {
            bufferPosn++;
            break;
          }
        } else {
          delPosn = 0;
        }
      }
      int readLength = bufferPosn - startPosn;
      bytesConsumed += readLength;
      int appendLength = readLength - delPosn;
      if (appendLength > maxLineLength - txtLength) {
        appendLength = maxLineLength - txtLength;
      }
      if (appendLength > 0) {
        str.append(buffer, startPosn, appendLength);
        txtLength += appendLength;
      }
    } while (delPosn < recordDelimiterBytes.length
      && bytesConsumed < maxBytesToConsume);
    if (bytesConsumed > (long) Integer.MAX_VALUE)
      throw new IOException("Too many bytes before delimiter: " + bytesConsumed);
    return (int) bytesConsumed;
  }
143684
function(str) {
    var startsWith = !_.isNull(str.match(wOpsHeadRe))
    return startsWith & cons.isLegalSentence(str)
  }
73075
function parse_PtgAttrIf(blob, length, opts) {
	var bitIf = (blob[blob.l+1] & 0xFF) ? 1 : 0;
	blob.l += 2;
	return [bitIf, blob.read_shift(opts && opts.biff == 2 ? 1 : 2)];
}
869645
function(str, len, padChar) {
    str = stringIt(str);
    if (str.length >= len) {
      return str;
    }
    var padStr = getPadding(padChar, len);
    return str + padStr.substr(str.length - len);
  }
1163918
function parse( str , limit ) {
	var v , runtime = {
		i: 0
		, depth: 0	//# noDepthTracking!
		, depthLimit: limit || depthLimit   //# noDepthLimit!
		, ancestors: []	//# noRefNotation!
	} ;

	if ( typeof str !== 'string' ) {
		if ( str && typeof str === 'object' ) { str = str.toString() ; }
		else { throw new TypeError( "Argument #0 should be a string or an object with a .toString() method" ) ; }
	}

	parseIdle( str , runtime ) ;

	if ( runtime.i >= str.length ) { throw new SyntaxError( "Empty" ) ; }

	v = parseValue( str , runtime ) ;
	parseIdle( str , runtime ) ;

	if ( runtime.i < str.length ) { throw new SyntaxError( "Unexpected " + str[ runtime.i ] ) ; }

	return v ;
}
196109
private static long SBOG_LPSti64(Int512 t, int i) {
        return (StreebogTables.sbob_sl64[0][t.getByte(i) & 0xFF] ^
                StreebogTables.sbob_sl64[1][t.getByte(i + 8) & 0xFF] ^
                StreebogTables.sbob_sl64[2][t.getByte(i + 16) & 0xFF] ^
                StreebogTables.sbob_sl64[3][t.getByte(i + 24) & 0xFF] ^
                StreebogTables.sbob_sl64[4][t.getByte(i + 32) & 0xFF] ^
                StreebogTables.sbob_sl64[5][t.getByte(i + 40) & 0xFF] ^
                StreebogTables.sbob_sl64[6][t.getByte(i + 48) & 0xFF] ^
                StreebogTables.sbob_sl64[7][t.getByte(i + 56) & 0xFF]);
    }