logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 62f01936f78c90e7c5f04dced6b5ece2eb5f6ca1
parent 89e42f7426d269a44971e383f23e7954530f1e42
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 30 Jan 2022 02:19:55 +0100

bin/strings: Accept end at non-printable character

Diffstat:

Mbin/strings.c17++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/bin/strings.c b/bin/strings.c @@ -32,7 +32,16 @@ concat(int fd, const char *fdname) for(s = 0; s < c; offset++, s++, b = read_buf[s]) { - if(b == '\n' || b == 0) + if(isprint(b) && write_pos < 4096) + { + write_buf[write_pos++] = b; + } +#define END_NONPRINT +#ifdef END_NONPRINT + else +#else + else if(b == '\n' || b == 0) +#endif { if(write_pos >= opt_min_strlen) { @@ -48,15 +57,13 @@ concat(int fd, const char *fdname) write_pos = 0; memset(write_buf, 0, sizeof(write_buf)); } - else if(isprint(b) && write_pos < 4096) - { - write_buf[write_pos++] = b; - } +#ifndef END_NONPRINT else { write_pos = 0; memset(write_buf, 0, sizeof(write_buf)); } +#endif } }