mirror of
https://github.com/mamedev/mame.git
synced 2024-11-18 10:06:19 +01:00
plugin/data: handle multiple blocks in dat
This commit is contained in:
parent
fc87679998
commit
f16565a556
2 changed files with 12 additions and 7 deletions
|
@ -7,7 +7,7 @@ do
|
|||
if not buttonchar then buttonchar = require("data/button_char") end
|
||||
return buttonchar(str)
|
||||
end
|
||||
datread, ver = datread.open("command.dat", "# Version:", convert)
|
||||
datread, ver = datread.open("command.dat", "#[^V]*Ver[^.:]*[.:]", convert)
|
||||
end
|
||||
|
||||
function dat.check(set, softlist)
|
||||
|
@ -19,7 +19,6 @@ function dat.check(set, softlist)
|
|||
if not status or not info then
|
||||
return nil
|
||||
end
|
||||
info = "#jf\n" .. info
|
||||
return _("Command")
|
||||
end
|
||||
|
||||
|
|
|
@ -106,21 +106,21 @@ function datfile.open(file, vertag, fixupcb)
|
|||
local tags, data
|
||||
while not data do
|
||||
local npos
|
||||
local spos, epos = buffer:find("[\n\r]$[^=]*=[^\n\r]*", pos)
|
||||
local spos, epos = buffer:find("[\n\r]$[^=\n\r]*=[^\n\r]*", pos)
|
||||
if not spos then
|
||||
return nil
|
||||
end
|
||||
npos, epos = buffer:find("[\n\r]$%w*[\n\r]+", epos)
|
||||
npos, epos = buffer:find("[\n\r]$%w+%s*[\n\r]+", epos)
|
||||
if not npos then
|
||||
return nil
|
||||
end
|
||||
tags = buffer:sub(spos, epos)
|
||||
spos, npos = buffer:find("[\n\r]$end[\n\r]", epos)
|
||||
spos, npos = buffer:find("[\n\r]$[^=\n\r]*=[^\n\r]*", epos)
|
||||
if not spos then
|
||||
return nil
|
||||
end
|
||||
data = buffer:sub(epos, spos)
|
||||
pos = npos
|
||||
pos = spos
|
||||
end
|
||||
return tags, data
|
||||
end
|
||||
|
@ -129,6 +129,8 @@ function datfile.open(file, vertag, fixupcb)
|
|||
for info, data in gmatchpos() do
|
||||
local tags = {}
|
||||
local infotype
|
||||
info = info:gsub(utf8.char(0xfeff), "") --remove boms
|
||||
data = data:gsub(utf8.char(0xfeff), "")
|
||||
for s in info:gmatch("[\n\r]$([^\n\r]*)") do
|
||||
if s:find("=", 1, true) then
|
||||
local m1, m2 = s:match("([^=]*)=(.*)")
|
||||
|
@ -142,7 +144,11 @@ function datfile.open(file, vertag, fixupcb)
|
|||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
data = data:gsub("[\n\r]$end%s*[\n\r]$%w+%s*[\n\r]", "\n")
|
||||
data = data:gsub("[\n\r]$end%s*[\n\r].-[\n\r]$%w+%s*[\n\r]", "\n")
|
||||
data = data:gsub("[\n\r]$end%s*[\n\r].*", "")
|
||||
|
||||
if #tags > 0 and infotype then
|
||||
data = data:gsub("\r", "") -- strip crs
|
||||
if fixupcb then
|
||||
|
|
Loading…
Reference in a new issue