summaryrefslogtreecommitdiff
path: root/usr.bin/sdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-02-20 08:29:45 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-02-20 08:29:45 +0000
commitef58385553bf62fbb4fa96f657fe6926714dcf7f (patch)
tree058cfc51cada42a5e6a15e40ac97c41be3b061b9 /usr.bin/sdiff
parent8d6467382a7b3c449f1947a7dc11e3f3992ad0e1 (diff)
refactor processq() loop. From Rai Lay; ok jaredy@
Diffstat (limited to 'usr.bin/sdiff')
-rw-r--r--usr.bin/sdiff/sdiff.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/usr.bin/sdiff/sdiff.c b/usr.bin/sdiff/sdiff.c
index 69a87be93d1..105f1f53a3d 100644
--- a/usr.bin/sdiff/sdiff.c
+++ b/usr.bin/sdiff/sdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdiff.c,v 1.15 2006/02/15 15:27:38 otto Exp $ */
+/* $OpenBSD: sdiff.c,v 1.16 2006/02/20 08:29:44 otto Exp $ */
/*
* Written by Raymond Lai <ray@cyth.net>.
@@ -753,7 +753,9 @@ processq(void)
if (SIMPLEQ_EMPTY(&diffhead))
return;
- divc = '\0';
+ /* Remember the divider. */
+ divc = SIMPLEQ_FIRST(&diffhead)->div;
+
left = NULL;
right = NULL;
/*
@@ -762,19 +764,11 @@ processq(void)
*/
SIMPLEQ_FOREACH(diffp, &diffhead, diffentries) {
/*
- * Make sure that divc is consistent throughout set.
- * If divc is set, compare to next entry's divc. They
- * should be the same. If divc is not set, then store
- * this as this set's divc.
- */
- if (divc == '\0')
- divc = diffp->div;
-
- /*
* Print changed lines if -s was given,
* print all lines if -s was not given.
*/
- if (!sflag || divc == '|' || divc == '<' || divc == '>')
+ if (!sflag || diffp->div == '|' || diffp->div == '<' ||
+ diffp->div == '>')
println(diffp->left, diffp->div, diffp->right);
/* Append new lines to diff set. */