mirror of
https://github.com/holub/mame
synced 2025-07-01 16:19:38 +03:00
plugin/data: handle multiple blocks in dat
This commit is contained in:
parent
5198603ea8
commit
e7f3ce58a9
@ -7,7 +7,7 @@ do
|
|||||||
if not buttonchar then buttonchar = require("data/button_char") end
|
if not buttonchar then buttonchar = require("data/button_char") end
|
||||||
return buttonchar(str)
|
return buttonchar(str)
|
||||||
end
|
end
|
||||||
datread, ver = datread.open("command.dat", "# Version:", convert)
|
datread, ver = datread.open("command.dat", "#[^V]*Ver[^.:]*[.:]", convert)
|
||||||
end
|
end
|
||||||
|
|
||||||
function dat.check(set, softlist)
|
function dat.check(set, softlist)
|
||||||
@ -19,7 +19,6 @@ function dat.check(set, softlist)
|
|||||||
if not status or not info then
|
if not status or not info then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
info = "#jf\n" .. info
|
|
||||||
return _("Command")
|
return _("Command")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -106,21 +106,21 @@ function datfile.open(file, vertag, fixupcb)
|
|||||||
local tags, data
|
local tags, data
|
||||||
while not data do
|
while not data do
|
||||||
local npos
|
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
|
if not spos then
|
||||||
return nil
|
return nil
|
||||||
end
|
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
|
if not npos then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
tags = buffer:sub(spos, epos)
|
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
|
if not spos then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
data = buffer:sub(epos, spos)
|
data = buffer:sub(epos, spos)
|
||||||
pos = npos
|
pos = spos
|
||||||
end
|
end
|
||||||
return tags, data
|
return tags, data
|
||||||
end
|
end
|
||||||
@ -129,6 +129,8 @@ function datfile.open(file, vertag, fixupcb)
|
|||||||
for info, data in gmatchpos() do
|
for info, data in gmatchpos() do
|
||||||
local tags = {}
|
local tags = {}
|
||||||
local infotype
|
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
|
for s in info:gmatch("[\n\r]$([^\n\r]*)") do
|
||||||
if s:find("=", 1, true) then
|
if s:find("=", 1, true) then
|
||||||
local m1, m2 = s:match("([^=]*)=(.*)")
|
local m1, m2 = s:match("([^=]*)=(.*)")
|
||||||
@ -143,6 +145,10 @@ function datfile.open(file, vertag, fixupcb)
|
|||||||
end
|
end
|
||||||
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
|
if #tags > 0 and infotype then
|
||||||
data = data:gsub("\r", "") -- strip crs
|
data = data:gsub("\r", "") -- strip crs
|
||||||
if fixupcb then
|
if fixupcb then
|
||||||
|
Loading…
Reference in New Issue
Block a user