mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Replace String.prototype.substr()
occurrences with String.prototype.substring()
As outlined in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr, which refers to the ECMA-262 specification, using the `substr` function is advised against. Hence this PR, which replaces all remaining `substr` occurrences with `substring` instead. Please refer to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr#Syntax respectively https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring#Syntax for the differences between the two functions. Note that in most cases in the code-base there's only one argument passed to `substr`, and those require no other changes except replacing "substr" with "substring". For the other cases, the `substr(start, length)` calls are changed to `substring(start, start + length)` instead.
This commit is contained in:
parent
54d6c2436c
commit
842e9206c0
15 changed files with 24 additions and 23 deletions
|
@ -1366,7 +1366,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
|||
nibbles += (nibbles.length & 1) ? 'f' : 'ff';
|
||||
var out = [30];
|
||||
for (i = 0, ii = nibbles.length; i < ii; i += 2) {
|
||||
out.push(parseInt(nibbles.substr(i, 2), 16));
|
||||
out.push(parseInt(nibbles.substring(i, i + 2), 16));
|
||||
}
|
||||
return out;
|
||||
},
|
||||
|
|
|
@ -228,7 +228,7 @@ class CMap {
|
|||
while (low <= high) {
|
||||
this._map[low++] = dstLow;
|
||||
// Only the last byte has to be incremented.
|
||||
dstLow = dstLow.substr(0, lastByte) +
|
||||
dstLow = dstLow.substring(0, lastByte) +
|
||||
String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2002,18 +2002,18 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
switch (glyphName[0]) {
|
||||
case 'G': // Gxx glyph
|
||||
if (glyphName.length === 3) {
|
||||
code = parseInt(glyphName.substr(1), 16);
|
||||
code = parseInt(glyphName.substring(1), 16);
|
||||
}
|
||||
break;
|
||||
case 'g': // g00xx glyph
|
||||
if (glyphName.length === 5) {
|
||||
code = parseInt(glyphName.substr(1), 16);
|
||||
code = parseInt(glyphName.substring(1), 16);
|
||||
}
|
||||
break;
|
||||
case 'C': // Cddd glyph
|
||||
case 'c': // cddd glyph
|
||||
if (glyphName.length >= 3) {
|
||||
code = +glyphName.substr(1);
|
||||
code = +glyphName.substring(1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -70,9 +70,9 @@ function getUnicodeForGlyph(name, glyphsUnicodeMap) {
|
|||
var nameLen = name.length, hexStr;
|
||||
|
||||
if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') { // 'uniXXXX'
|
||||
hexStr = name.substr(3);
|
||||
hexStr = name.substring(3);
|
||||
} else if (nameLen >= 5 && nameLen <= 7) { // 'uXXXX{XX}'
|
||||
hexStr = name.substr(1);
|
||||
hexStr = name.substring(1);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -195,8 +195,8 @@ if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
|
|||
}
|
||||
|
||||
function spliceString(s, offset, remove, insert) {
|
||||
var chunk1 = s.substr(0, offset);
|
||||
var chunk2 = s.substr(offset + remove);
|
||||
var chunk1 = s.substring(0, offset);
|
||||
var chunk2 = s.substring(offset + remove);
|
||||
return chunk1 + insert + chunk2;
|
||||
}
|
||||
|
||||
|
|
|
@ -373,7 +373,7 @@ SVGGraphics = (function SVGGraphicsClosure() {
|
|||
do {
|
||||
i--;
|
||||
} while (s[i] === '0');
|
||||
return s.substr(0, s[i] === '.' ? i : i + 1);
|
||||
return s.substring(0, s[i] === '.' ? i : i + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue