diff -w when removing nested braces (thus unindenting)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

> 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

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux