array of bytes sawzall bounds checking

36 views
Skip to first unread message

Jakob Praher

unread,
Nov 5, 2010, 5:19:37 AM11/5/10
to szl-users
Hi all,

I compiled sawzall and tried the quick example on the project page.
There splitcsvline is used like this:

fields: array of bytes = splitcsvline(input);

now when I want to lookup a value by using subscript (as in the
example) I get an out-of-bounds error, since szl deduces that fields
as length 0:

fields[0] (index out of bounds (index = 0, array length = 0)))

What am I doing wrong?

Cheers,
Jakob



David Hilley

unread,
Nov 5, 2010, 12:33:02 PM11/5/10
to szl-...@googlegroups.com

Is input the empty string when you're calling splitcsvline? What are
you providing as an input source? (If you don't provide a file source
at all for input you'll just get the empty string.)

echo -en '1,2\n4,3\n' | szl -e 'fields: array of bytes =
splitcsvline(input); emit stdout <- string(fields[0]);' /dev/stdin
1
4

szl -e 'fields: array of bytes = splitcsvline(B""); emit stdout <-
string(fields[0]);'
(index out of bounds error)

szl -e 'emit stdout <- format("%b", input == B"");'
true

--
D. Hilley (d...@google.com)

Jakob Praher

unread,
Nov 5, 2010, 4:04:13 PM11/5/10
to szl-users
Dear David,

thanks for your reply.

I did

../src/szl quick.szl < input.data

instead of

../src/szl quick.szl input.data

or
../src/szl quick.szl /dev/stdin < input.data

Changing that worked for me.
IMHO the usage could be a bit more clear on that.

Best,
-- Jakob
Reply all
Reply to author
Forward
0 new messages