mirror of
https://github.com/NanashiTheNameless/FixTheGulf.git
synced 2025-07-06 06:30:39 -04:00
fix: replace spaces with tabs
This commit is contained in:
parent
1ff479fad6
commit
31f6f5e731
1 changed files with 25 additions and 25 deletions
50
gulf.js
50
gulf.js
|
@ -138,8 +138,8 @@
|
||||||
// Constants for special cases
|
// Constants for special cases
|
||||||
const CHAR_CODE_SPACE = " ".charCodeAt(0)
|
const CHAR_CODE_SPACE = " ".charCodeAt(0)
|
||||||
const CHAR_CODE_CAPITAL_A = "A".charCodeAt(0)
|
const CHAR_CODE_CAPITAL_A = "A".charCodeAt(0)
|
||||||
const CHAR_CODE_PARENTH = '('.charCodeAt(0)
|
const CHAR_CODE_PARENTH = '('.charCodeAt(0)
|
||||||
const CHAR_CODE_CAPITAL_G = 'G'.charCodeAt(0)
|
const CHAR_CODE_CAPITAL_G = 'G'.charCodeAt(0)
|
||||||
const REPLACEMENT_BYTES = [..."Mexico\0"].map(char => char.charCodeAt(0))
|
const REPLACEMENT_BYTES = [..."Mexico\0"].map(char => char.charCodeAt(0))
|
||||||
|
|
||||||
// For every possible starting character in our `labelBytes` blob...
|
// 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
|
// (we can't just add a fixed value because we don't know how long the
|
||||||
// match even is, thanks to variable space matching)
|
// match even is, thanks to variable space matching)
|
||||||
const americaStartIndex = labelBytes.indexOf(CHAR_CODE_CAPITAL_A, labelByteStartingIndex)
|
const americaStartIndex = labelBytes.indexOf(CHAR_CODE_CAPITAL_A, labelByteStartingIndex)
|
||||||
let parenthStartIndex = -1;
|
let parenthStartIndex = -1;
|
||||||
// Check if the label is `Gulf of Mexico (Gulf of America)`
|
// Check if the label is `Gulf of Mexico (Gulf of America)`
|
||||||
for (let i = 0; i < labelBytes.length; i++) {
|
for (let i = 0; i < labelBytes.length; i++) {
|
||||||
if (labelBytes[i] == CHAR_CODE_PARENTH && labelBytes[i + 1] == CHAR_CODE_CAPITAL_G) {
|
if (labelBytes[i] == CHAR_CODE_PARENTH && labelBytes[i + 1] == CHAR_CODE_CAPITAL_G) {
|
||||||
parenthStartIndex = i
|
parenthStartIndex = i
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (parenthStartIndex > -1) {
|
if (parenthStartIndex > -1) {
|
||||||
// Replace "(Gulf of" with null bytes
|
// Replace "(Gulf of" with null bytes
|
||||||
for (let i = 0; i < 8; i++) {
|
for (let i = 0; i < 8; i++) {
|
||||||
labelBytes[parenthStartIndex + i] = '\0'.charCodeAt(0)
|
labelBytes[parenthStartIndex + i] = '\0'.charCodeAt(0)
|
||||||
}
|
}
|
||||||
// Replace "America)" with null bytes
|
// Replace "America)" with null bytes
|
||||||
for (let i = 0; i < 8; i++) {
|
for (let i = 0; i < 8; i++) {
|
||||||
labelBytes[americaStartIndex + i] = '\0'.charCodeAt(0)
|
labelBytes[americaStartIndex + i] = '\0'.charCodeAt(0)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Replace "America" with "Mexico\0"
|
// Replace "America" with "Mexico\0"
|
||||||
for (let i = 0; i < REPLACEMENT_BYTES.length; i++) {
|
for (let i = 0; i < REPLACEMENT_BYTES.length; i++) {
|
||||||
labelBytes[americaStartIndex + i] = REPLACEMENT_BYTES[i]
|
labelBytes[americaStartIndex + i] = REPLACEMENT_BYTES[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue