use a constant for max diff context size
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/got/got.c b/got/got.c
index 9724740..7ea9071 100644
--- a/got/got.c
+++ b/got/got.c
@@ -460,7 +460,8 @@ cmd_log(int argc, char *argv[])
start_commit = optarg;
break;
case 'C':
- diff_context = strtonum(optarg, 1, INT_MAX, &errstr);
+ diff_context = strtonum(optarg, 0, GOT_DIFF_MAX_CONTEXT,
+ &errstr);
if (errstr != NULL)
err(1, "-C option %s", errstr);
break;
diff --git a/include/got_diff.h b/include/got_diff.h
index 2d8ae7f..a817a1e 100644
--- a/include/got_diff.h
+++ b/include/got_diff.h
@@ -63,3 +63,5 @@ const struct got_error *got_diff_objects_as_trees(struct got_object *,
*/
const struct got_error *got_diff_objects_as_commits(struct got_object *,
struct got_object *, int, struct got_repository *, FILE *);
+
+#define GOT_DIFF_MAX_CONTEXT 64
diff --git a/lib/diffreg.c b/lib/diffreg.c
index b2fe324..54ebb2f 100644
--- a/lib/diffreg.c
+++ b/lib/diffreg.c
@@ -280,7 +280,7 @@ got_diffreg(int *rval, FILE *f1, FILE *f2, int flags,
ds->lastline = 0;
ds->lastmatchline = 0;
ds->context_vec_ptr = ds->context_vec_start - 1;
- ds->max_context = 64;
+ ds->max_context = GOT_DIFF_MAX_CONTEXT;
if (flags & D_IGNORECASE)
ds->chrtran = cup2low;
else
diff --git a/tog/tog.c b/tog/tog.c
index 82f68df..2d26c2e 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1795,7 +1795,7 @@ input_diff_view(struct tog_view **new_view, struct tog_view **dead_view,
}
break;
case ']':
- if (s->diff_context < INT_MAX) {
+ if (s->diff_context < GOT_DIFF_MAX_CONTEXT) {
s->diff_context++;
err = create_diff(s);
}