Igalia / pflua

Packet filtering in Lua
Other
313 stars 39 forks source link

Allow octal literals as arguments #237

Closed mpeterv closed 9 years ago

mpeterv commented 9 years ago

Use same function for parsing numerical literals in arithmetic expressions and as arguments of primitives, e.g. 'port'. Add some error reporting to this function; previously lexer had to fallback to address parsing on incorrect number literals.

This improves tcpdump compatibility.

kbara commented 9 years ago

Would you explain/give an example of how it improves tcpdump compatibility?

mpeterv commented 9 years ago

@kbara it's just that, octal arguments. E.g. port 010 is supported in tcpdump. Of course that's very minor, the main benefit is improvement of error messages.

kbara commented 9 years ago

Thanks for the clarification. LGTM, and the extra parse tests look like a sufficient regression test. WDYT, @andywingo ?

wingo commented 9 years ago

LGTM with the nit, please let me know if the nit is correct and if so when you have a fix. Cheers :)

mpeterv commented 9 years ago

@andywingo assertion has to be moved out completely because a number with a valid terminator still can be start of a hostname, e.g. 0xffffffffff-oo.com.

I've pushed a simple fix which duplicates the assertion. We could also add optional max_pos parameter to lex_number and check number size only when it's not used or is equal to position of last digit. If you don't mind the current fix I could do that later along with some refactoring.

wingo commented 9 years ago

LGTM. Thank you @mpeterv :)