[hackers] [sbase] strings: Print strings that have the minimum length || Michael Forney

From: <git_AT_suckless.org>
Date: Fri, 15 Jan 2021 06:48:37 +0100 (CET)

commit 5377a9c3d16aefe4fc18025edb738676634c95f5
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Thu Jan 14 21:41:59 2021 -0800
Commit: Michael Forney <mforney_AT_mforney.org>
CommitDate: Thu Jan 14 21:46:26 2021 -0800

    strings: Print strings that have the minimum length
    
    Previously, there was an off-by-one error when determining whether
    to print a strings, so when the string was exactly the minimum
    length, it was not printed.
    
    This fixes a bug with an x264 configure test, which expects to find
    a string of length 4 (BIGE/EBIG) to detect system endianness.

diff --git a/strings.c b/strings.c
index 76b3316..a99642e 100644
--- a/strings.c
+++ b/strings.c
_AT_@ -23,23 +23,21 @@ strings(FILE *fp, const char *fname, size_t len)
                 if (r == Runeerror)
                         continue;
                 if (!isprintrune(r)) {
- if (i > len)
+ if (i == len)
                                 putchar('\n');
                         i = 0;
                         continue;
                 }
- if (i < len) {
- rbuf[i++] = r;
- continue;
- } else if (i > len) {
+ if (i == len) {
                         efputrune(&r, stdout, "<stdout>");
                         continue;
                 }
+ rbuf[i++] = r;
+ if (i < len)
+ continue;
                 printf(format, (long)off - i);
                 for (i = 0; i < len; i++)
                         efputrune(rbuf + i, stdout, "<stdout>");
- efputrune(&r, stdout, "<stdout>");
- i++;
         }
         free(rbuf);
 }
Received on Fri Jan 15 2021 - 06:48:37 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 15 2021 - 06:48:54 CET