Skip to content

Commit 6f10283

Browse files
authored
Merge pull request #5 from wlupton/feature/improve-light-userdata-handling
Remove leading 'userdata: ' when reporting light userdata
2 parents c00501f + 58a164b commit 6f10283

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

logging.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ local function dump_(prefix, value, maxlen, level, add)
9292
-- light userdata is just a pointer (can't iterate over it)
9393
-- XXX is there a better way of checking for light userdata?
9494
if type(value) == 'userdata' and not pcall(pairs(value)) then
95-
value = '<pointer>'
95+
value = tostring(value):gsub('userdata:%s*', '')
9696

9797
-- modify the value heuristically
9898
elseif ({table=1, userdata=1})[type(value)] then
@@ -131,9 +131,10 @@ local function dump_(prefix, value, maxlen, level, add)
131131
add(string.format('%s%s%s%s%s%s%s%s', indent, prefix, presep, typ,
132132
typsep, quo, value, quo))
133133
-- light userdata is just a pointer (can't iterate over it)
134-
-- XXX is there a better way of checking for light userdataXS?
134+
-- XXX is there a better way of checking for light userdata?
135135
elseif valtyp == 'userdata' and not pcall(pairs(value)) then
136-
add(string.format('%s%s%s%s <pointer>', indent, prefix, presep, typ))
136+
add(string.format('%s%s%s%s %s', indent, prefix, presep, typ,
137+
tostring(value):gsub('userdata:%s*', '')))
137138
elseif ({table=1, userdata=1})[valtyp] then
138139
add(string.format('%s%s%s%s%s{', indent, prefix, presep, typ, typsep))
139140
-- Attr and Attr.attributes have both numeric and string keys, so

0 commit comments

Comments
 (0)