On Mon, Feb 27, 2023 at 11:09:29AM +0100, Peter J. Philipp wrote: > Please give this some scrutiny and commit it to util if you like it. Until > then I view this bug report as AWAITING RESPONSE :-).
OK, 2 seconds after I sent this I found 3 things wrong with it, so here it is again and it even compiles! I'd like to thank Claudio Jeker for helping me along with tcpdump and committing fixes for earlier bug reports. Please again, give this function some scrutiny if you decide to commit it, otherwise I sent patches using fn_printn() I believe earlier in this thread. There is inherently nothing wrong with that either. -----------> #include <stdio.h> #include <stdlib.h> #include <vis.h> char cp[1501]; char *snapend = &cp[1500]; /* returns -1 on error, 0 on success */ int fn_print_vis(char *bp, int bplen) { char *name, *cp; int i; if (bplen <= 0) return (-1); if (&bp[bplen] > snapend) return (-1); name = calloc(bplen, 5); if (name == NULL) return (-1); cp = name; for (i = 0; i < bplen && bp[i] != '\0'; i++) { cp = vis(cp, bp[i], VIS_WHITE, 0); } printf("%s", name); free(name); return (0); } int main(void) { fn_print_vis(cp, 20); } <----------- Best Regards, -peter