Fixed all lua check issues

master
Tobias Gaarenstroom 2022-01-11 19:29:48 +01:00
parent 8b52bce4fb
commit 87d4a1683a
1 changed files with 11 additions and 14 deletions

View File

@ -557,7 +557,7 @@ local function calculate_error_correction(data,num_ec_codewords)
local highest_exponent = len_message + num_ec_codewords - 1
local gp_alpha,tmp
local he
--local gp_int = {}
-- local gp_int = {}
local mp_int = {}
-- create message shifted to left (highest exponent)
for i=1,len_message do
@ -593,7 +593,7 @@ local function calculate_error_correction(data,num_ec_codewords)
gp_alpha[i] = 256
end
gp_int = convert_to_int(gp_alpha)
local gp_int = convert_to_int(gp_alpha)
mp_int = convert_to_int(mp_alpha)
@ -755,7 +755,7 @@ local function arrange_codewords_and_calculate_ec( version,ec_level,data )
local blocks = ecblocks[version][ec_level]
local size_datablock_bytes, size_ecblock_bytes
local datablocks = {}
local ecblocks = {}
local ecblock2 = {}
local count = 1
local pos = 0
local cpty_ec_bits = 0
@ -771,7 +771,7 @@ local function arrange_codewords_and_calculate_ec( version,ec_level,data )
for x=1,#tmp_tab do
tmp_str = tmp_str .. binary(tmp_tab[x],8)
end
ecblocks[#ecblocks + 1] = tmp_str
ecblock2[#ecblock2 + 1] = tmp_str
pos = pos + size_datablock_bytes
count = count + 1
end
@ -790,9 +790,9 @@ local function arrange_codewords_and_calculate_ec( version,ec_level,data )
local arranged_ec = ""
pos = 1
repeat
for i=1,#ecblocks do
if pos < #ecblocks[i] then
arranged_ec = arranged_ec .. string.sub(ecblocks[i],pos, pos + 7)
for i=1,#ecblock2 do
if pos < #ecblock2[i] then
arranged_ec = arranged_ec .. string.sub(ecblock2[i],pos, pos + 7)
end
end
pos = pos + 8
@ -1083,7 +1083,7 @@ local function get_pixel_with_mask( mask, x,y,value )
local invert = false
-- test purpose only:
if mask == -1 then
-- ignore, no masking applied
invert = false -- ignore, no masking applied
elseif mask == 0 then
if math.fmod(x + y,2) == 0 then invert = true end
elseif mask == 1 then
@ -1220,9 +1220,6 @@ local function calculate_penalty(matrix)
if matrix[x][y] > 0 then
-- small optimization: this is for penalty 4
number_of_dark_cells = number_of_dark_cells + 1
is_blank = false
else
is_blank = true
end
is_blank = matrix[x][y] < 0
if last_bit_blank == is_blank then
@ -1359,10 +1356,10 @@ end
--- 1. Return qrcode with least penalty
-- If ec_level or mode is given, use the ones for generating the qrcode. (mode is not implemented yet)
local function qrcode( str, ec_level, mode )
local arranged_data, version, data_raw, mode, len_bitstring
version, ec_level, data_raw, mode, len_bitstring = get_version_eclevel_mode_bistringlength(str,ec_level)
local arranged_data, version, data_raw, mode2, len_bitstring
version, ec_level, data_raw, mode2, len_bitstring = get_version_eclevel_mode_bistringlength(str,ec_level)
data_raw = data_raw .. len_bitstring
data_raw = data_raw .. encode_data(str,mode)
data_raw = data_raw .. encode_data(str,mode2)
data_raw = add_pad_data(version,ec_level,data_raw)
arranged_data = arrange_codewords_and_calculate_ec(version,ec_level,data_raw)
if math.fmod(#arranged_data,8) ~= 0 then