aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/diff
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2021-01-26 15:25:00 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2021-01-27 11:28:26 +0000
commite43239f5140e1b80de122458a2ac037172866058 (patch)
treec6b9d09cbd55e2b01576e45fb1fb70cadd40d6ad /usr.bin/diff
parente52546a3a75f6e4b327178f4d50a98dd99101c64 (diff)
downloadsrc-e43239f5140e1b80de122458a2ac037172866058.tar.gz
src-e43239f5140e1b80de122458a2ac037172866058.zip
Diffstat (limited to 'usr.bin/diff')
-rw-r--r--usr.bin/diff/diffreg.c77
1 files changed, 27 insertions, 50 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index f8c25f822147..564032751862 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1349,64 +1349,41 @@ readhash(FILE *f, int flags)
sum = 1;
space = 0;
- if ((flags & (D_FOLDBLANKS|D_IGNOREBLANKS)) == 0) {
- if (flags & D_IGNORECASE)
- for (i = 0; (t = getc(f)) != '\n'; i++) {
- if (flags & D_STRIPCR && t == '\r') {
- t = getc(f);
- if (t == '\n')
- break;
- ungetc(t, f);
- }
- if (t == EOF) {
- if (i == 0)
- return (0);
+ for (i = 0;;) {
+ switch (t = getc(f)) {
+ case '\r':
+ if (flags & D_STRIPCR) {
+ t = getc(f);
+ if (t == '\n')
break;
- }
- sum = sum * 127 + chrtran(t);
- }
- else
- for (i = 0; (t = getc(f)) != '\n'; i++) {
- if (flags & D_STRIPCR && t == '\r') {
- t = getc(f);
- if (t == '\n')
- break;
- ungetc(t, f);
- }
- if (t == EOF) {
- if (i == 0)
- return (0);
- break;
- }
- sum = sum * 127 + t;
+ ungetc(t, f);
}
- } else {
- for (i = 0;;) {
- switch (t = getc(f)) {
- case '\r':
- case '\t':
- case '\v':
- case '\f':
- case ' ':
+ /* FALLTHROUGH */
+ case '\t':
+ case '\v':
+ case '\f':
+ case ' ':
+ if ((flags & (D_FOLDBLANKS|D_IGNOREBLANKS)) != 0) {
space++;
continue;
- default:
- if (space && (flags & D_IGNOREBLANKS) == 0) {
- i++;
- space = 0;
- }
- sum = sum * 127 + chrtran(t);
+ }
+ /* FALLTHROUGH */
+ default:
+ if (space && (flags & D_IGNOREBLANKS) == 0) {
i++;
- continue;
- case EOF:
- if (i == 0)
- return (0);
- /* FALLTHROUGH */
- case '\n':
- break;
+ space = 0;
}
+ sum = sum * 127 + chrtran(t);
+ i++;
+ continue;
+ case EOF:
+ if (i == 0)
+ return (0);
+ /* FALLTHROUGH */
+ case '\n':
break;
}
+ break;
}
/*
* There is a remote possibility that we end up with a zero sum.