git: 54d65fdd5643 - main - diff: restyle loop a bit
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 14 Dec 2022 01:33:31 UTC
The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=54d65fdd5643f61a816c1d028b53039290ed1d92 commit 54d65fdd5643f61a816c1d028b53039290ed1d92 Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2022-12-14 01:31:21 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2022-12-14 01:31:21 +0000 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)