| Summary: | awk printf("%c", 0) doesn't print anything | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | alt.j2-4o4s2yon |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | busybox-cvs |
| Priority: | P5 | ||
| Version: | 1.33.x | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
| Attachments: | awk: allow printf('%c') to output NUL | ||
Created attachment 8736 [details]
awk: allow printf('%c') to output NUL
thanks ron for your patch. does it fix both printf and sprintf ? btw looks like this has been reported once before: https://bugs.busybox.net/show_bug.cgi?id=12506 The patch only fixes printf. As wolf+busybox says in the other bug, fixing sprintf is much harder. And you only asked for printf ;) |
testcase: echo -n "7F454C460201010000" | awk 'BEGIN{ht="123456789ABCDEF";}function h2i(h){return index(ht, substr(h,1,1))*16+index(ht,substr(h,2,1));} {for(i=1;i<=length($0);i+=2)printf("%c", h2i(substr($0,i,2)));}' | hexdump -ve '1/1 "%.2X"' prints 7F454C460201010000 on gawk and mawk, busybox swallows the 2 null bytes at the end.