[tlbuild] luaharfbuzz breaks tostring

Simon Dales simon at getthingsfixed.co.uk
Fri Mar 6 10:48:45 CET 2020


If I iterate over luaharfbuzz in texlua it dies with a broken tostring()

There is a hack fix: run tostring() within pcall(). It works but not
ideal.

////////////////////
function show_var(K,V)
	io.write('//' .. K .. '\n')
	for k,v in pairs(V) do
		io.write(':://' .. k .. ':')
		io.write(type(v) .. ':')
 		io.write(tostring(v))
		io.write('\n')
	end
end

--main
show_var('luaharfbuzz',luaharfbuzz)
--eof
/////////////////

This dies.

But replace tostring() with p_tostring(), and it works
///
local l_p_string_keys = {}
local l_p_string_keys_num = 0
--[[!
	@brief pcalled tostring
	
	Uses regular tostring() if happy,
		else makes one up
	]]
local function p_tostring(V)
	local _fn = function()
		return tostring(V)
	end
	local didIt,val = pcall(_fn)
	if (didIt) then
		return val
	else -- can't say as string
		local key = l_p_string_keys[V]
		if (key==nil) then --  make a new one
			l_p_string_keys_num = l_p_string_keys_num + 1
			key = '*undef:' .. l_p_string_keys_num .. '*'
			l_p_string_keys[V] = key
		end
		return key
	end
end
///
///////////////

Simon Dales



More information about the tlbuild mailing list.