Skip to content

Commit 46f0710

Browse files
committed
Fixed redundant and buggy check for "\\" in a quoted string.
1 parent 75bf264 commit 46f0710

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

util/SQUISH.LUA

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ local function Squish(fileName)
4040
pos = lineEnd
4141
end
4242

43-
-- Handle strings with double quotes
44-
elseif c == '"' then
43+
-- Handle quoted strings
44+
elseif c == '"' or c == "'" then
4545
local stringStart = pos
4646
pos = pos + 1
4747
while pos <= #data do
48-
if data:sub(pos, pos) == '"' and data:sub(pos - 1, pos - 1) ~= "\\" then
48+
if data:sub(pos, pos) == c then
4949
break
5050
elseif data:sub(pos, pos) == "\\" and pos < #data then
5151
pos = pos + 2 -- Skip escaped character
@@ -61,28 +61,7 @@ local function Squish(fileName)
6161
table.insert(tokens, {type = "code", value = data:sub(stringStart, pos - 1)})
6262
end
6363

64-
-- Handle strings with single quotes
65-
elseif c == "'" then
66-
local stringStart = pos
67-
pos = pos + 1
68-
while pos <= #data do
69-
if data:sub(pos, pos) == "'" and data:sub(pos - 1, pos - 1) ~= "\\" then
70-
break
71-
elseif data:sub(pos, pos) == "\\" and pos < #data then
72-
pos = pos + 2 -- Skip escaped character
73-
else
74-
pos = pos + 1
75-
end
76-
end
77-
if pos <= #data then
78-
table.insert(tokens, {type = "string", value = data:sub(stringStart, pos)})
79-
pos = pos + 1
80-
else
81-
-- Unclosed string, treat as code (this is an error in Lua)
82-
table.insert(tokens, {type = "code", value = data:sub(stringStart, pos - 1)})
83-
end
84-
85-
-- Handle long bracket strings
64+
-- Handle bracket strings
8665
elseif c == "[" and data:sub(pos, pos + 1):match("%[=*%[") then
8766
local stringStart = pos
8867
local openBracket = data:match("%[=*%[", pos)

0 commit comments

Comments
 (0)