Skip to content

Commit

Permalink
Fix: --"..." and --'...' are not delimited comments like --[[...]]
Browse files Browse the repository at this point in the history
Rather, these terminate at the end of the line.
  • Loading branch information
davidm committed Apr 19, 2013
1 parent 1e7ba26 commit 3e34fb1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,7 @@
0.1.2.20130418
Fix: `--"..."` and `--'...'` are not delimited comments
like `--[[...]]` but rather terminate at the end of the line.

0.1.1.20120323
Fix performance of LB.gsub on large strings.

Expand Down
10 changes: 6 additions & 4 deletions luabalanced.lua
Expand Up @@ -146,7 +146,7 @@ REFERENCES
--]==]---------------------------------------------------------------------
local M = {_TYPE='module', _NAME='luabalanaced', _VERSION='0.1.1.20120323'}
local M = {_TYPE='module', _NAME='luabalanaced', _VERSION='0.1.2.20130418'}
local assert = assert
Expand Down Expand Up @@ -234,9 +234,11 @@ local function match_comment(s, pos)
return nil, pos
end
pos = pos + 2
local partt, post = match_string(s, pos)
if partt then
return '--' .. partt, post
if s:sub(pos,pos) == '[' then
local partt, post = match_string(s, pos)
if partt then
return '--' .. partt, post
end
end
local part; part, pos = s:match('^([^\n]*\n?)()', pos)
return '--' .. part, pos
Expand Down
1 change: 1 addition & 0 deletions test/test.lua
Expand Up @@ -83,6 +83,7 @@ asserteq(me'a+ --[[]] b', tuple('a+ --[[]] b', 12))
asserteq(me'a --[[]] + b', tuple('a --[[]] + b', 13))
asserteq(me'a+ --[[]] --[=[]=] b', tuple('a+ --[[]] --[=[]=] b', 21))
asserteq(me'a+ -- b\n -- b\n b c', tuple('a+ -- b\n -- b\n b ', 18))
asserteq(me'a --""+\nb', tuple('a --""+\n', 9))

-- check for exceptions giving lots of possibly not syntactically
-- correct data.
Expand Down

0 comments on commit 3e34fb1

Please sign in to comment.