diff --git a/builtin-pickaxe.c b/builtin-pickaxe.c index 673185f96de4430a363b961bc9ab8912444808a1..64999f3577294eb2bfe030be386dacd7b3787bbf 100644 --- a/builtin-pickaxe.c +++ b/builtin-pickaxe.c @@ -1545,6 +1545,25 @@ static const char *parse_loc(const char *spec, regex_t regexp; regmatch_t match[1]; + /* Allow "-L ,+20" to mean starting at + * for 20 lines, or "-L ,-5" for 5 lines ending at + * . + */ + if (1 < begin && (spec[0] == '+' || spec[0] == '-')) { + num = strtol(spec + 1, &term, 10); + if (term != spec + 1) { + if (spec[0] == '-') + num = 0 - num; + if (0 < num) + *ret = begin + num - 2; + else if (!num) + *ret = begin; + else + *ret = begin + num; + return term; + } + return spec; + } num = strtol(spec, &term, 10); if (term != spec) { *ret = num;