Hi tech,
In diff & friends, use <sys/param.h> macros MIN() and MAX() instead of
defining these locally. Worth doing?
- Michael
Index: diff/diffreg.c
===================================================================
RCS file: /cvs/src/usr.bin/diff/diffreg.c,v
retrieving revision 1.90
diff -u -p -r1.90 diffreg.c
--- diff/diffreg.c 26 Oct 2015 12:52:27 -0000 1.90
+++ diff/diffreg.c 30 Dec 2015 02:28:03 -0000
@@ -64,6 +64,7 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
+#include <sys/param.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -83,9 +84,6 @@
#include "diff.h"
#include "xmalloc.h"
-#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
-#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
-
/*
* diff - compare two files.
*/
@@ -595,7 +593,7 @@ stone(int *a, int n, int *b, int *c, int
bound = UINT_MAX;
else {
sq = isqrt(n);
- bound = MAXIMUM(256, sq);
+ bound = MAX(256, sq);
}
k = 0;
@@ -1302,10 +1300,10 @@ dump_context_vec(FILE *f1, FILE *f2, int
return;
b = d = 0; /* gcc */
- lowa = MAXIMUM(1, cvp->a - diff_context);
- upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
- lowc = MAXIMUM(1, cvp->c - diff_context);
- upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAX(1, cvp->a - diff_context);
+ upb = MIN(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAX(1, cvp->c - diff_context);
+ upd = MIN(len[1], context_vec_ptr->d + diff_context);
diff_output("***************");
if ((flags & D_PROTOTYPE)) {
@@ -1405,10 +1403,10 @@ dump_unified_vec(FILE *f1, FILE *f2, int
return;
b = d = 0; /* gcc */
- lowa = MAXIMUM(1, cvp->a - diff_context);
- upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
- lowc = MAXIMUM(1, cvp->c - diff_context);
- upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAX(1, cvp->a - diff_context);
+ upb = MIN(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAX(1, cvp->c - diff_context);
+ upd = MIN(len[1], context_vec_ptr->d + diff_context);
diff_output("@@ -");
uni_range(lowa, upb);
Index: rcs/diff.c
===================================================================
RCS file: /cvs/src/usr.bin/rcs/diff.c,v
retrieving revision 1.38
diff -u -p -r1.38 diff.c
--- rcs/diff.c 13 Jun 2015 20:15:21 -0000 1.38
+++ rcs/diff.c 30 Dec 2015 02:28:04 -0000
@@ -64,6 +64,7 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
+#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -81,9 +82,6 @@
#include "diff.h"
#include "xmalloc.h"
-#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
-#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
-
/*
* diff - compare two files.
*/
@@ -532,7 +530,7 @@ stone(int *a, int n, int *b, int *c, int
bound = UINT_MAX;
else {
sq = isqrt(n);
- bound = MAXIMUM(256, sq);
+ bound = MAX(256, sq);
}
k = 0;
@@ -1205,10 +1203,10 @@ dump_context_vec(FILE *f1, FILE *f2, int
return;
b = d = 0; /* gcc */
- lowa = MAXIMUM(1, cvp->a - diff_context);
- upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
- lowc = MAXIMUM(1, cvp->c - diff_context);
- upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAX(1, cvp->a - diff_context);
+ upb = MIN(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAX(1, cvp->c - diff_context);
+ upd = MIN(len[1], context_vec_ptr->d + diff_context);
diff_output("***************");
if ((flags & D_PROTOTYPE)) {
@@ -1308,10 +1306,10 @@ dump_unified_vec(FILE *f1, FILE *f2, int
return;
d = 0; /* gcc */
- lowa = MAXIMUM(1, cvp->a - diff_context);
- upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
- lowc = MAXIMUM(1, cvp->c - diff_context);
- upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAX(1, cvp->a - diff_context);
+ upb = MIN(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAX(1, cvp->c - diff_context);
+ upd = MIN(len[1], context_vec_ptr->d + diff_context);
diff_output("@@ -");
uni_range(lowa, upb);
Index: cvs/diff_internals.c
===================================================================
RCS file: /cvs/src/usr.bin/cvs/diff_internals.c,v
retrieving revision 1.38
diff -u -p -r1.38 diff_internals.c
--- cvs/diff_internals.c 5 Nov 2015 09:48:21 -0000 1.38
+++ cvs/diff_internals.c 30 Dec 2015 02:28:04 -0000
@@ -64,6 +64,7 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -81,9 +82,6 @@
#include "cvs.h"
#include "diff.h"
-#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
-#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
-
/*
* diff - compare two files.
*/
@@ -550,7 +548,7 @@ stone(int *a, int n, int *b, int *c, int
bound = UINT_MAX;
else {
sq = isqrt(n);
- bound = MAXIMUM(256, sq);
+ bound = MAX(256, sq);
}
k = 0;
@@ -1278,10 +1276,10 @@ dump_context_vec(FILE *f1, FILE *f2, int
return;
b = d = 0; /* gcc */
- lowa = MAXIMUM(1, cvp->a - diff_context);
- upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
- lowc = MAXIMUM(1, cvp->c - diff_context);
- upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAX(1, cvp->a - diff_context);
+ upb = MIN(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAX(1, cvp->c - diff_context);
+ upd = MIN(len[1], context_vec_ptr->d + diff_context);
diff_output("***************");
if ((flags & D_PROTOTYPE)) {
@@ -1381,10 +1379,10 @@ dump_unified_vec(FILE *f1, FILE *f2, int
return;
b = d = 0; /* gcc */
- lowa = MAXIMUM(1, cvp->a - diff_context);
- upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
- lowc = MAXIMUM(1, cvp->c - diff_context);
- upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAX(1, cvp->a - diff_context);
+ upb = MIN(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAX(1, cvp->c - diff_context);
+ upd = MIN(len[1], context_vec_ptr->d + diff_context);
diff_output("@@ -");
uni_range(lowa, upb);