Skip to content

Commit

Permalink
Replace the depracated 'substr' with 'substring'
Browse files Browse the repository at this point in the history
  • Loading branch information
OfekShilon committed Mar 10, 2024
1 parent 10c6074 commit 8c51ed7
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion lib/base-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ export class BaseCompiler implements ICompiler {
const foundlibOptions: string[] = [];
_.each(libsAndOptions.options, option => {
if (option.indexOf(linkFlag) === 0) {
const libVersion = this.findAutodetectStaticLibLink(option.substr(linkFlag.length).trim());
const libVersion = this.findAutodetectStaticLibLink(option.substring(linkFlag.length).trim());
if (libVersion) {
foundlibOptions.push(option);
detectedLibs.push(libVersion);
Expand Down
2 changes: 1 addition & 1 deletion lib/buildenvsetup/ceconan-rust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class BuildEnvSetupCeConanRustDirect extends BuildEnvSetupCeConanDirect {
});

if (target) {
const triple = target.substr(target.indexOf('=') + 1);
const triple = target.substring(target.indexOf('=') + 1);
return this.getArchFromTriple(triple);
} else {
const idx = key.options.indexOf('--target');
Expand Down
6 changes: 3 additions & 3 deletions lib/compiler-arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class CompilerArguments implements ICompilerArguments {
if (documentedOption.includes('=')) {
const idx = documentedOption.indexOf('=');
if (givenOption.indexOf('=') === idx) {
if (documentedOption.substr(0, idx) === givenOption.substr(0, idx)) {
if (documentedOption.substring(0, idx) === givenOption.substring(0, idx)) {
return documentedOption;
}
}
Expand All @@ -173,15 +173,15 @@ export class CompilerArguments implements ICompilerArguments {
if (documentedOption.includes(':')) {
const idx = documentedOption.indexOf(':');
if (givenOption.indexOf(':') === idx) {
if (documentedOption.substr(0, idx) === givenOption.substr(0, idx)) {
if (documentedOption.substring(0, idx) === givenOption.substring(0, idx)) {
return documentedOption;
}
}
}

if (documentedOption.includes('[')) {
const idx = documentedOption.indexOf('[') - 1;
if (documentedOption.indexOf(givenOption.substr(0, idx)) === 0) {
if (documentedOption.indexOf(givenOption.substring(0, idx)) === 0) {
return documentedOption;
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/compilers/argument-parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,8 @@ export class VCParser extends BaseParser {
let col1;
let col2;
if (line.length > 39 && line[40] === '/') {
col1 = line.substr(0, 39);
col2 = line.substr(40);
col1 = line.substring(0, 39);
col2 = line.substring(40);
} else {
col1 = line;
col2 = '';
Expand Down Expand Up @@ -923,7 +923,7 @@ export class TableGenParser extends BaseParser {
}

actions.push({
name: action_match[1].substr(2) + ': ' + action_match[2],
name: action_match[1].substring(2) + ': ' + action_match[2],
value: action_match[1],
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/compilers/clang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class ClangCompiler extends BaseCompiler {
if (startOrEnd === '__START__') {
prevStart = match.index + full.length + 1;
} else {
devices[triple] = assembly.substr(prevStart, match.index - prevStart);
devices[triple] = assembly.substring(prevStart, match.index);
}
}
return devices;
Expand Down
2 changes: 1 addition & 1 deletion lib/compilers/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export class JavaCompiler extends BaseCompiler implements SimpleOutputFilenameCo
if (lastIndex !== -1) {
// Get "interesting" text after the LineNumbers table (header of next method/tail of file)
// trimRight() because of trailing \r on Windows
textsBeforeMethod.push(codeAndLineNumberTable.substr(lastIndex).trimEnd());
textsBeforeMethod.push(codeAndLineNumberTable.substring(lastIndex).trimEnd());
}

if (currentSourceLine !== -1) {
Expand Down
4 changes: 2 additions & 2 deletions lib/compilers/llvm-mos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class LLVMMOSCompiler extends ClangCompiler {
if (this.compiler.exe.includes('nes')) {
let nesFile = outputFilename;
if (outputFilename.endsWith('.elf')) {
nesFile = outputFilename.substr(0, outputFilename.length - 4);
nesFile = outputFilename.substring(0, outputFilename.length - 4);
}

if (await utils.fileExists(nesFile)) {
Expand All @@ -93,7 +93,7 @@ export class LLVMMOSCompiler extends ClangCompiler {
} else if (this.compiler.exe.includes('c64')) {
let prgFile = outputFilename;
if (outputFilename.endsWith('.elf')) {
prgFile = outputFilename.substr(0, outputFilename.length - 4);
prgFile = outputFilename.substring(0, outputFilename.length - 4);
}

if (await utils.fileExists(prgFile)) {
Expand Down
18 changes: 10 additions & 8 deletions lib/compilers/pascal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ export class FPCCompiler extends BaseCompiler {
if (relevantAsmStartsAt !== -1) {
const lastLinefeedBeforeStart = input.lastIndexOf('\n', relevantAsmStartsAt);
if (lastLinefeedBeforeStart === -1) {
input = input.substr(0, input.indexOf('00000000004')) + '\n' + input.substr(relevantAsmStartsAt);
input = input.substring(0, input.indexOf('00000000004')) + '\n' + input.substring(relevantAsmStartsAt);
} else {
input =
input.substr(0, input.indexOf('00000000004')) + '\n' + input.substr(lastLinefeedBeforeStart + 1);
input.substring(0, input.indexOf('00000000004')) +
'\n' +
input.substring(lastLinefeedBeforeStart + 1);
}
}
return input;
Expand Down Expand Up @@ -229,14 +231,14 @@ export class FPCCompiler extends BaseCompiler {
getExtraAsmHint(asm: string, currentFileId: number) {
if (asm.startsWith('# [')) {
const bracketEndPos = asm.indexOf(']', 3);
let valueInBrackets = asm.substr(3, bracketEndPos - 3);
let valueInBrackets = asm.substring(3, bracketEndPos);
const colonPos = valueInBrackets.indexOf(':');
if (colonPos !== -1) {
valueInBrackets = valueInBrackets.substr(0, colonPos - 1);
valueInBrackets = valueInBrackets.substring(0, colonPos - 1);
}

if (valueInBrackets.startsWith('/')) {
valueInBrackets = valueInBrackets.substr(1);
valueInBrackets = valueInBrackets.substring(1);
}

if (Number.isNaN(Number(valueInBrackets))) {
Expand All @@ -254,14 +256,14 @@ export class FPCCompiler extends BaseCompiler {
tryGetFilenumber(asm: string, files: Record<string, number>) {
if (asm.startsWith('# [')) {
const bracketEndPos = asm.indexOf(']', 3);
let valueInBrackets = asm.substr(3, bracketEndPos - 3);
let valueInBrackets = asm.substring(3, bracketEndPos);
const colonPos = valueInBrackets.indexOf(':');
if (colonPos !== -1) {
valueInBrackets = valueInBrackets.substr(0, colonPos - 1);
valueInBrackets = valueInBrackets.substring(0, colonPos - 1);
}

if (valueInBrackets.startsWith('/')) {
valueInBrackets = valueInBrackets.substr(1);
valueInBrackets = valueInBrackets.substring(1);
}

if (Number.isNaN(Number(valueInBrackets))) {
Expand Down
4 changes: 2 additions & 2 deletions lib/compilers/ptxas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class PtxAssembler extends BaseCompiler {
line = line.split(inputFilename).join('<source>');

if (inputFilename.indexOf('./') === 0) {
line = line.split('/home/ubuntu/' + inputFilename.substr(2)).join('<source>');
line = line.split('/home/ce/' + inputFilename.substr(2)).join('<source>');
line = line.split('/home/ubuntu/' + inputFilename.substring(2)).join('<source>');
line = line.split('/home/ce/' + inputFilename.substring(2)).join('<source>');
}
}
if (line !== null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/compilers/wine-vc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class WineVcCompiler extends BaseCompiler {

execOptions.customCwd = path.dirname(inputFilename);
if (inputFilename.startsWith('Z:')) {
execOptions.customCwd = execOptions.customCwd.substr(2);
execOptions.customCwd = execOptions.customCwd.substring(2);
}

return await super.runCompiler(compiler, options, inputFilename, execOptions);
Expand Down
20 changes: 10 additions & 10 deletions lib/demangler/pascal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class PascalDemangler extends BaseDemangler {
if (!text.endsWith(':')) return false;
if (this.shouldIgnoreSymbol(text)) return false;

text = text.substr(0, text.length - 1);
text = text.substring(0, text.length - 1);

for (const k in this.fixedsymbols) {
if (text === k) {
Expand All @@ -119,11 +119,11 @@ export class PascalDemangler extends BaseDemangler {
}

if (text.startsWith('U_$OUTPUT_$$_')) {
const unmangledGlobalVar = text.substr(13).toLowerCase();
const unmangledGlobalVar = text.substring(13).toLowerCase();
this.symbolStore.add(text, unmangledGlobalVar);
return unmangledGlobalVar;
} else if (text.startsWith('U_OUTPUT_')) {
const unmangledGlobalVar = text.substr(9).toLowerCase();
const unmangledGlobalVar = text.substring(9).toLowerCase();
this.symbolStore.add(text, unmangledGlobalVar);
return unmangledGlobalVar;
}
Expand All @@ -139,15 +139,15 @@ export class PascalDemangler extends BaseDemangler {

idx = text.indexOf('$_$');
if (idx !== -1) {
unitname = text.substr(0, idx - 1);
classname = text.substr(idx + 3, text.indexOf('_$_', idx + 2) - idx - 3);
unitname = text.substring(0, idx - 1);
classname = text.substring(idx + 3, text.indexOf('_$_', idx + 2));
}

let signature = '';
idx = text.indexOf('_$$_');
if (idx !== -1) {
if (unitname === '') unitname = text.substr(0, idx - 1);
signature = text.substr(idx + 3);
if (unitname === '') unitname = text.substring(0, idx - 1);
signature = text.substring(idx + 3);
}

if (unitname === '') {
Expand All @@ -157,10 +157,10 @@ export class PascalDemangler extends BaseDemangler {

idx = text.indexOf('_$__');
if (idx === -1) {
signature = text.substr(6);
signature = text.substring(6);
} else {
classname = text.substr(7, idx - 7);
signature = text.substr(idx + 3);
classname = text.substring(7, idx);
signature = text.substring(idx + 3);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/demangler/prefix-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class PrefixTree {
assert(character !== undefined, 'Undefined code point encountered in PrefixTree');
node = node[character];
if (!node) break;
if (node.result) match = [needle.substr(0, i + 1), node.result];
if (node.result) match = [needle.substring(0, i + 1), node.result];
}
return match;
}
Expand All @@ -93,7 +93,7 @@ export class PrefixTree {
// Use a binary search to find the replacements (allowing a prefix match). If we couldn't find a match, skip
// on, else use the replacement, and skip by that amount.
while (index < line.length) {
const lineBit = line.substr(index);
const lineBit = line.substring(index);
const [oldValue, newValue] = this.findLongestMatch(lineBit);
if (oldValue) {
// We found a replacement.
Expand Down
2 changes: 1 addition & 1 deletion lib/llvm-ir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class LlvmIrParser {
metaNode[key] = keyValuePair[2];
// Remove "" from string
if (metaNode[key][0] === '"') {
metaNode[key] = metaNode[key].substr(1, metaNode[key].length - 2);
metaNode[key] = metaNode[key].substring(1, metaNode[key].length - 1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/parsers/asm-parser-hexagon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class HexagonAsmParser extends AsmParser {
// Remove any leading label definition...
const match = line.match(this.labelDef);
if (match) {
line = line.substr(match[0].length);
line = line.substring(match[0].length);
}
// Strip any comments
line = line.split(this.commentRe, 1)[0];
Expand Down
2 changes: 1 addition & 1 deletion lib/parsers/asm-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class AsmParser extends AsmRegex implements IAsmParser {
// Remove any leading label definition...
const match = line.match(this.labelDef);
if (match) {
line = line.substr(match[0].length);
line = line.substring(match[0].length);
}
// Strip any comments
line = line.split(this.commentRe, 1)[0];
Expand Down
2 changes: 1 addition & 1 deletion lib/storage/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export abstract class StorageBase {
// Keep rehashing until a usable text is found
let configHash = StorageBase.getRawConfigHash(config);
let tries = 1;
while (!StorageBase.isCleanText(configHash.substr(0, USABLE_HASH_CHECK_LENGTH))) {
while (!StorageBase.isCleanText(configHash.substring(0, USABLE_HASH_CHECK_LENGTH))) {
// Shake up the hash a bit by adding, or incrementing a nonce value.
config.nonce = tries;
logger.info(`Unusable text found in full hash ${configHash} - Trying again (${tries})`);
Expand Down
6 changes: 3 additions & 3 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function expandTabs(line: string): string {
const total = offset + extraChars;
const spacesNeeded = (total + 8) & 7;
extraChars += spacesNeeded - 1;
return ' '.substr(spacesNeeded);
return ' '.substring(spacesNeeded);
});
}

Expand Down Expand Up @@ -266,7 +266,7 @@ export function padRight(name: string, len: number): string {
export function trimRight(name: string): string {
let l = name.length;
while (l > 0 && name[l - 1] === ' ') l -= 1;
return name.substr(0, l);
return name.substring(0, l);
}

/***
Expand Down Expand Up @@ -407,7 +407,7 @@ export function replaceAll(line: string, oldValue: string, newValue: string): st
for (;;) {
const index = line.indexOf(oldValue, startPoint);
if (index === -1) break;
line = line.substr(0, index) + newValue + line.substr(index + oldValue.length);
line = line.substring(0, index) + newValue + line.substring(index + oldValue.length);
startPoint = index + newValue.length;
}
return line;
Expand Down
8 changes: 4 additions & 4 deletions static/ansi-to-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ function generateOutput(stack: string[], token: string, data: string | number, o

function handleRgb(stack: string[], data: string, options: AnsiToHtmlOptions) {
data = data.substring(2).slice(0, -1);
const operation = +data.substr(0, 2);
const operation = +data.substring(0, 2);

const color = data.substring(5).split(';');
const rgb = color
.map(value => {
return ('0' + Number(value).toString(16)).substr(-2);
return ('0' + Number(value).toString(16)).slice(-2);
})
.join('');

Expand All @@ -152,8 +152,8 @@ function handleRgb(stack: string[], data: string, options: AnsiToHtmlOptions) {

function handleXterm256(stack: string[], data: string, options: AnsiToHtmlOptions): string {
data = data.substring(2).slice(0, -1);
const operation = +data.substr(0, 2);
const color = +data.substr(5);
const operation = +data.substring(0, 2);
const color = +data.substring(5);
if (operation === 38) {
return pushForegroundColor(stack, options.colors[color]);
} else {
Expand Down
2 changes: 1 addition & 1 deletion static/sharing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class Sharing {
const config = Sharing.filterComponentState(this.layout.toConfig());
this.ensureUrlIsNotOutdated(config);
if (options.embedded) {
const strippedToLast = window.location.pathname.substr(0, window.location.pathname.lastIndexOf('/') + 1);
const strippedToLast = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
$('a.link').prop('href', strippedToLast + '#' + url.serialiseState(config));
}
}
Expand Down

0 comments on commit 8c51ed7

Please sign in to comment.