fsck: detect gitmodules files
[gitweb.git] / line-range.c
index ede0c6c98f7b6fc1f4e85a3956f7824a81dff743..323399d16cfa828adce913c9ff994e860ce2e7a5 100644 (file)
@@ -54,8 +54,11 @@ static const char *parse_loc(const char *spec, nth_line_fn_t nth_line,
        }
        num = strtol(spec, &term, 10);
        if (term != spec) {
-               if (ret)
+               if (ret) {
+                       if (num <= 0)
+                               die("-L invalid line number: %ld", num);
                        *ret = num;
+               }
                return term;
        }
 
@@ -266,8 +269,7 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,
                return -1;
 
        if (*begin && *end && *end < *begin) {
-               long tmp;
-               tmp = *end; *end = *begin; *begin = tmp;
+               SWAP(*end, *begin);
        }
 
        return 0;