Skip to content

Commit

Permalink
jis04cmap_exp/*.lua: cleanup trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aminophen committed Nov 3, 2022
1 parent d14154d commit 23d6d35
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 55 deletions.
42 changes: 21 additions & 21 deletions jis04cmap_exp/cmapdec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ local function load_cid_char()
local cid, ucs, ucsa
line = fh:read("*l")
while line do
if string.find(line, "end...?char") then
line = fh:read("*l"); return
if string.find(line, "end...?char") then
line = fh:read("*l"); return
else -- WMA l is in the form "<%x+>%s%d+"
ucs, cid = string.match(line, "<(%x+)>%s+<?(%x+)>?")
cid = tonumber(cid); ucs = tonumber(ucs, 16);
tt[ucs] = cid
ucs, cid = string.match(line, "<(%x+)>%s+<?(%x+)>?")
cid = tonumber(cid); ucs = tonumber(ucs, 16);
tt[ucs] = cid
end
line = fh:read("*l")
end
Expand All @@ -20,17 +20,17 @@ local function load_cid_range()
local bucs, eucs, cid
line = fh:read("*l")
while line do
if string.find(line, "end...?range") then
line = fh:read("*l"); return
else -- WMA l is in the form "<%x+>%s+<%x+>"
bucs, eucs, cid = string.match(line, "<(%x+)>%s+<(%x+)>%s+<?(%x+)>?")
cid = tonumber(cid);
bucs = tonumber(bucs, 16); eucs = tonumber(eucs, 16)
for ucs = bucs, eucs do
tt[ucs], cid = cid, cid + 1
end
end
line = fh:read("*l")
if string.find(line, "end...?range") then
line = fh:read("*l"); return
else -- WMA l is in the form "<%x+>%s+<%x+>"
bucs, eucs, cid = string.match(line, "<(%x+)>%s+<(%x+)>%s+<?(%x+)>?")
cid = tonumber(cid);
bucs = tonumber(bucs, 16); eucs = tonumber(eucs, 16)
for ucs = bucs, eucs do
tt[ucs], cid = cid, cid + 1
end
end
line = fh:read("*l")
end
end

Expand All @@ -40,15 +40,15 @@ local function open_cmap_file(cmap_name, out_table)
line = fh:read("*l")
while line do
if string.find(line, "%x+%s+begin...?char") then
load_cid_char()
load_cid_char()
elseif string.find(line, "%x+%s+begin...?range") then
load_cid_range()
load_cid_range()
else
line = fh:read("*l")
line = fh:read("*l")
end
end
fh:close();
fh:close();
return tt
end

return { open_cmap_file = open_cmap_file };
return { open_cmap_file = open_cmap_file };
68 changes: 34 additions & 34 deletions jis04cmap_exp/mk_jis_to_aj16_cid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,21 @@ local function mk_jis_cid_table(jis_uni, uni_cid)
for jis, uni in pairs(jis_uni) do
local c = uni_cid[uni]
if c then
if ((jis>=0x2900) and (jis<=0x2B7E)) then
res[#res+1] = { jis, nonuni_cid[jis] or c}
else
-- それ以外の場合は全角化する
res[#res+1] = { jis, nonuni_cid[jis] or (prop_to_full[c] or c)}
end
if ((jis>=0x2900) and (jis<=0x2B7E)) then
res[#res+1] = { jis, nonuni_cid[jis] or c}
else
-- それ以外の場合は全角化する
res[#res+1] = { jis, nonuni_cid[jis] or (prop_to_full[c] or c)}
end
end
end
table.sort(res, function (a,b) return a[1]<b[1] end)
return res
end

--
--
local function change_repr(t)
local res = {}
local res = {}
for i,v in pairs(t) do
res[#res+1] = {i,v}
end
Expand All @@ -276,7 +276,7 @@ end
-- 出力処理
do
local buf, bufline, fh

local function flush()
fh:write(tonumber(bufline) .. " begincidrange\n" .. buf .. "endcidrange\n")
buf, bufline = "", 0
Expand All @@ -294,15 +294,15 @@ do
]])
if wmode == 1 then
local s = string.gsub('%%DocumentNeededResources: CMap ($NAME)\n', '$NAME', hname)
fh:write(s)
fh:write(s)
end

fh:write([[
%%IncludeResource: ProcSet (CIDInit)
]])
if wmode == 1 then
local s = string.gsub('%%IncludeResource: CMap ($NAME)\n', '$NAME', hname)
fh:write(s)
fh:write(s)
end

local s = string.gsub([[
Expand All @@ -329,9 +329,9 @@ begincmap
fh:write(s)
if wmode == 1 then
s=string.gsub(
string.gsub('\n/$NAME usecmap\n\n', '$NAME', fname),
'-V', '-H')
fh:write(s)
string.gsub('\n/$NAME usecmap\n\n', '$NAME', fname),
'-V', '-H')
fh:write(s)
end
s = string.gsub([[
/CIDSystemInfo 3 dict dup begin
Expand All @@ -348,7 +348,7 @@ end def

fh:write('\n/WMode ' .. wmode .. ' def\n\n')
if wmode ==0 then
fh:write(crange .. '\n')
fh:write(crange .. '\n')
end
end

Expand All @@ -371,23 +371,23 @@ end
local fstr = "<%x> <%x> %" .. col_num .. "d"
local i, outbi, outbc = 1, jis_cid[1][1], jis_cid[1][2]
while i < #jis_cid do
if jis_cid[i+1][2] == jis_cid[i][2] + 1
and jis_cid[i+1][1] == jis_cid[i][1] + 1 then
oute = jis_cid[i+1][1]
else
out(string.format(fstr, outbi, oute, outbc))
outbi, oute, outbc = jis_cid[i+1][1], jis_cid[i+1][1], jis_cid[i+1][2]
end
i = i + 1
if jis_cid[i+1][2] == jis_cid[i][2] + 1
and jis_cid[i+1][1] == jis_cid[i][1] + 1 then
oute = jis_cid[i+1][1]
else
out(string.format(fstr, outbi, oute, outbc))
outbi, oute, outbc = jis_cid[i+1][1], jis_cid[i+1][1], jis_cid[i+1][2]
end
i = i + 1
end
out(string.format(fstr, outbi, jis_cid[#jis_cid][1], outbc))
flush();
out_footer();
flush();
out_footer();
fh:close()
end
end

--
--
local function cleanup(new, old)
table.sort(new, function (a,b) return a[1]<b[1] end)
-- We can assume new and old are sorted.
Expand All @@ -396,8 +396,8 @@ local function cleanup(new, old)
for _,v in ipairs(new) do
for i = oi, ol do
local w = old[i]
if v[1] == w[1] and v[2] ~= w[2] then
res [#res+1] = v;
if v[1] == w[1] and v[2] ~= w[2] then
res [#res+1] = v;
oi = i + 1; break
elseif v[1]<w[1] then
-- We don't need further search.
Expand Down Expand Up @@ -451,8 +451,8 @@ for lx in f:lines() do
-- 全角幅優先
uni = string.match(lx, 'Fullwidth: U%+(%x*)') or uni
if jis and uni then
uni = tonumber(uni,16)
jis04_uni[jis] = uni
uni = tonumber(uni,16)
jis04_uni[jis] = uni
end
end
end
Expand Down Expand Up @@ -480,7 +480,7 @@ replace(jis_cid_h04, 0x2926, 8059) -- COPYRIGHT SIGN
replace(jis_cid_h04, 0x292A, 8060) -- REGISTERED SIGN
replace(jis_cid_h04, 0x2933, 8185) -- VULGAR FRACTION ONE QUARTER
replace(jis_cid_h04, 0x2934, 8184) -- VULGAR FRACTION ONE HALF
replace(jis_cid_h04, 0x2935, 9783) -- VULGAR FRACTION THREE QUARTERS
replace(jis_cid_h04, 0x2935, 9783) -- VULGAR FRACTION THREE QUARTERS

out_cmap('2004-H', '', jis_cid_h04, '', code_range_04, 0)

Expand Down Expand Up @@ -515,7 +515,7 @@ replace(jis_cid_v04, 0x2926, 8059) -- COPYRIGHT SIGN
replace(jis_cid_v04, 0x292A, 8060) -- REGISTERED SIGN
replace(jis_cid_v04, 0x2933, 8185) -- VULGAR FRACTION ONE QUARTER
replace(jis_cid_v04, 0x2934, 8184) -- VULGAR FRACTION ONE HALF
replace(jis_cid_v04, 0x2935, 9783) -- VULGAR FRACTION THREE QUARTERS
replace(jis_cid_v04, 0x2935, 9783) -- VULGAR FRACTION THREE QUARTERS


out_cmap('2004-V', '2004-H', cleanup(jis_cid_v04, jis_cid_h04), '', code_range_04, 1)
Expand All @@ -534,8 +534,8 @@ end
-- local uni = string.match(l, "^0x%x*%s*0x%x*%s*0x(%x*)")
-- -- 全角幅優先
-- if jis and uni then
-- uni = tonumber(uni,16)
-- jis90_uni[jis] = uni
-- uni = tonumber(uni,16)
-- jis90_uni[jis] = uni
-- end
-- end
-- end
Expand Down

0 comments on commit 23d6d35

Please sign in to comment.