onetrueawk / awk

One true awk
Other
1.98k stars 159 forks source link

Inconsistent behavior of \x #164

Closed arnoldrobbins closed 1 year ago

arnoldrobbins commented 1 year ago

Hi. The codes that handle \x escape sequences are not consistent. In b.c:hexstr, it reads a maximum of two hex digits. This is the correct way to go, such that \x gives only byte values. This is also what gawk does.

In lex.c:string the code reads up to 100 hex digits and then scanf's a value. It would be better if that code simply used hexstr function from b.c.

Thanks!

arnoldrobbins commented 1 year ago

hex-patch.txt Here is a proposed patch. It seems to pass the test suite.

plan9 commented 1 year ago

thanks I had done it by adjusting the buffer to 3 chars, but I like yours better.

arnoldrobbins commented 1 year ago

Should I just push it to Git?

plan9 commented 1 year ago

no patch is fine.

arnoldrobbins commented 1 year ago

I have merged this patch and pushed to all the branches. Closing the issue.