declared variable confidence before use, to make it work in 'strict mode' environment.

This commit is contained in:
Spiky 2015-11-27 16:17:28 -05:00
parent 17aebe7b28
commit b0f828d8ad
1 changed files with 77 additions and 73 deletions

View File

@ -1,3 +1,4 @@
'use strict';
var util = require('util'),
Match = require ('../match');
@ -12,8 +13,10 @@ module.exports.UTF_16BE = function() {
this.match = function(det) {
var input = det.fRawInput;
if (input.length >= 2 && ((input[0] & 0xff) == 0xfe && (input[1] & 0xff) == 0xff))
return new Match(det, this, confidence = 100);
if (input.length >= 2 && ((input[0] & 0xff) == 0xfe && (input[1] & 0xff) == 0xff)) {
var confidence = 100;
return new Match(det, this, confidence);
}
// TODO: Do some statistics to check for unsigned UTF-16BE
return null;
@ -29,11 +32,12 @@ module.exports.UTF_16LE = function() {
if (input.length >= 2 && ((input[0] & 0xff) == 0xff && (input[1] & 0xff) == 0xfe)) {
// An LE BOM is present.
if (input.length >= 4 && input[2] == 0x00 && input[3] == 0x00)
if (input.length >= 4 && input[2] == 0x00 && input[3] == 0x00) {
// It is probably UTF-32 LE, not UTF-16
return null;
return new Match(det, this, confidence = 100);
}
var confidence = 100;
return new Match(det, this, confidence);
}
// TODO: Do some statistics to check for unsigned UTF-16LE