From 54d65fdd5643f61a816c1d028b53039290ed1d92 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Tue, 13 Dec 2022 19:31:21 -0600 Subject: [PATCH] diff: restyle loop a bit This is a bit more readable, and this loop is probably unlikely to gain any `continue` or `break`s. Suggested by: pstef Differential Revision: https://reviews.freebsd.org/D37676 --- usr.bin/diff/diffreg.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 1247317951d3..971f640fa05f 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1246,9 +1246,9 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags) else if (diff_format != D_UNIFIED) printf(" "); } - col = 0; - for (j = 0, lastc = '\0'; j < nc && (hw == 0 || col < hw); - j++, lastc = c) { + col = j = 0; + lastc = '\0'; + while (j < nc && (hw == 0 || col < hw)) { c = getc(lb); if (flags & D_STRIPCR && c == '\r') { if ((c = getc(lb)) == '\n') @@ -1313,6 +1313,9 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags) col++; } } + + j++; + lastc = c; } } if (color && diff_format == D_SIDEBYSIDE)