iryont/lua-struct

Improve to handle `struct.pack('c', ...)

EnTerr opened this issue · 0 comments

Minor improvement, so 'c' format can be handled for single characters w/o n appended (i.e. 'c', not only 'c1'):

      local n = format:sub(i + 1):match('^%d+') or ''
      local length = tonumber(n) or 1

It's a cheap fix. Also because of no '^' in pattern before, it would jump ahead to find a number and then i = i + n:len() would mess up progress in the pattern.