diff -w when removing nested braces (thus unindenting)
- From
- Alejandro Colomar <alx.manpages@gmail.com>
- Date
- Apr 4, 2023, 20:26 UTC
- Message-ID
- <27551992-99d0-e0e4-a9c6-bebca729d78e@gmail.com>
Hi,
When removing nested braces, it would be nice if the diff algorithm could try to remove the brace in a way that it fits semantically. Considering the following diff:
Show 37 quoted lines
> diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
> index 9f3233c8..0e8de7c5 100644
> --- a/src/nxt_http_parse.c
> +++ b/src/nxt_http_parse.c
> @@ -351,29 +351,30 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
>
> } while (*p == ' ');
>
> - if (memcmp(p, "HTTP/", nxt_min(end - p, 5)) == 0) {
> + if (memcmp(p, "HTTP/", nxt_min(end - p, 5)) != 0) {
> + return NXT_HTTP_PARSE_INVALID;
> + }
>
> switch (end - p) {
> case 8:
> if (p[7] < '0' || p[7] > '9') {
> - break;
> + return NXT_HTTP_PARSE_INVALID;
> }
> /* Fall through. */
> case 7:
> if (p[6] != '.') {
> - break;
> + return NXT_HTTP_PARSE_INVALID;
> }
> /* Fall through. */
> case 6:
> if (p[5] < '0' || p[5] > '9') {
> - break;
> + return NXT_HTTP_PARSE_INVALID;
> }
> /* Fall through. */
> default:
> return NXT_AGAIN;
> }
> }
> - }This brace removal looks like it would be an unmatching brace. It would be nicer if the diff showed this:
}
- }
}Although I'm conscious that this might be a wild wish impossible to implement; so I'd just like you to know this little itch of mine in case you consider it doable.
Cheers,
Alex
> > /* " HTTP/1.1\r\n" or " HTTP/1.1\n" */ >
-- <http://www.alejandro-colomar.es/> GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5