From 31f6f5e731ef3568484e162dab1707c83c85c011 Mon Sep 17 00:00:00 2001 From: Matvey Ryabchikov <35634442+ronanru@users.noreply.github.com> Date: Sun, 16 Feb 2025 17:37:43 +0300 Subject: [PATCH] fix: replace spaces with tabs --- gulf.js | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/gulf.js b/gulf.js index afb37cf..667b886 100644 --- a/gulf.js +++ b/gulf.js @@ -138,8 +138,8 @@ // Constants for special cases const CHAR_CODE_SPACE = " ".charCodeAt(0) const CHAR_CODE_CAPITAL_A = "A".charCodeAt(0) - const CHAR_CODE_PARENTH = '('.charCodeAt(0) - const CHAR_CODE_CAPITAL_G = 'G'.charCodeAt(0) + const CHAR_CODE_PARENTH = '('.charCodeAt(0) + const CHAR_CODE_CAPITAL_G = 'G'.charCodeAt(0) const REPLACEMENT_BYTES = [..."Mexico\0"].map(char => char.charCodeAt(0)) // For every possible starting character in our `labelBytes` blob... @@ -198,29 +198,29 @@ // (we can't just add a fixed value because we don't know how long the // match even is, thanks to variable space matching) const americaStartIndex = labelBytes.indexOf(CHAR_CODE_CAPITAL_A, labelByteStartingIndex) - let parenthStartIndex = -1; - // Check if the label is `Gulf of Mexico (Gulf of America)` - for (let i = 0; i < labelBytes.length; i++) { - if (labelBytes[i] == CHAR_CODE_PARENTH && labelBytes[i + 1] == CHAR_CODE_CAPITAL_G) { - parenthStartIndex = i - break - } - } - if (parenthStartIndex > -1) { - // Replace "(Gulf of" with null bytes - for (let i = 0; i < 8; i++) { - labelBytes[parenthStartIndex + i] = '\0'.charCodeAt(0) - } - // Replace "America)" with null bytes - for (let i = 0; i < 8; i++) { - labelBytes[americaStartIndex + i] = '\0'.charCodeAt(0) - } - } else { - // Replace "America" with "Mexico\0" - for (let i = 0; i < REPLACEMENT_BYTES.length; i++) { - labelBytes[americaStartIndex + i] = REPLACEMENT_BYTES[i] - } - } + let parenthStartIndex = -1; + // Check if the label is `Gulf of Mexico (Gulf of America)` + for (let i = 0; i < labelBytes.length; i++) { + if (labelBytes[i] == CHAR_CODE_PARENTH && labelBytes[i + 1] == CHAR_CODE_CAPITAL_G) { + parenthStartIndex = i + break + } + } + if (parenthStartIndex > -1) { + // Replace "(Gulf of" with null bytes + for (let i = 0; i < 8; i++) { + labelBytes[parenthStartIndex + i] = '\0'.charCodeAt(0) + } + // Replace "America)" with null bytes + for (let i = 0; i < 8; i++) { + labelBytes[americaStartIndex + i] = '\0'.charCodeAt(0) + } + } else { + // Replace "America" with "Mexico\0" + for (let i = 0; i < REPLACEMENT_BYTES.length; i++) { + labelBytes[americaStartIndex + i] = REPLACEMENT_BYTES[i] + } + } } }