{"thread":{"id":"59543","subject":"diff -w when removing nested braces (thus unindenting)","startedAt":"2023-04-04T20:26:41Z","lastAt":"2023-04-04T20:26:41Z","messageCount":1,"participants":["Alejandro Colomar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"474808","messageId":"27551992-99d0-e0e4-a9c6-bebca729d78e@gmail.com","threadId":"59543","inReplyTo":null,"subject":"diff -w when removing nested braces (thus unindenting)","fromName":"Alejandro Colomar","fromEmail":"alx.manpages@gmail.com","sentAt":"2023-04-04T20:26:27Z","receivedAt":"2023-04-04T20:26:41Z","isPatch":false,"sender":{"key":"alx.manpages@gmail.com","avatar":null},"body":"Hi,\n\nWhen removing nested braces, it would be nice if the diff algorithm\ncould try to remove the brace in a way that it fits semantically.\nConsidering the following diff:\n\n> diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c\n> index 9f3233c8..0e8de7c5 100644\n> --- a/src/nxt_http_parse.c\n> +++ b/src/nxt_http_parse.c\n> @@ -351,29 +351,30 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,\n>  \n>          } while (*p == ' ');\n>  \n> -        if (memcmp(p, \"HTTP/\", nxt_min(end - p, 5)) == 0) {\n> +        if (memcmp(p, \"HTTP/\", nxt_min(end - p, 5)) != 0) {\n> +            return NXT_HTTP_PARSE_INVALID;\n> +        }\n>  \n>          switch (end - p) {\n>          case 8:\n>              if (p[7] < '0' || p[7] > '9') {\n> -                    break;\n> +                return NXT_HTTP_PARSE_INVALID;\n>              }\n>              /* Fall through. */\n>          case 7:\n>              if (p[6] != '.') {\n> -                    break;\n> +                return NXT_HTTP_PARSE_INVALID;\n>              }\n>              /* Fall through. */\n>          case 6:\n>              if (p[5] < '0' || p[5] > '9') {\n> -                    break;\n> +                return NXT_HTTP_PARSE_INVALID;\n>              }\n>              /* Fall through. */\n>          default:\n>              return NXT_AGAIN;\n>          }\n>      }\n> -    }\n\nThis brace removal looks like it would be an unmatching brace.\nIt would be nicer if the diff showed this:\n\n\n          }\n -    }\n      }\n\nAlthough I'm conscious that this might be a wild wish impossible\nto implement; so I'd just like you to know this little itch of\nmine in case you consider it doable.\n\nCheers,\n\nAlex\n\n>  \n>      /* \" HTTP/1.1\\r\\n\" or \" HTTP/1.1\\n\" */\n>  \n\n\n\n-- \n<http://www.alejandro-colomar.es/>\nGPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5\n"}]}