From: Junio C Hamano <gitster@pobox.com>
To: William Duclot <william.duclot@ensimag.grenoble-inp.fr>
Cc: git@vger.kernel.org, simon.rabourg@ensimag.grenoble-inp.fr,
francois.beutin@ensimag.grenoble-inp.fr,
antoine.queru@ensimag.grenoble-inp.fr,
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Subject: Re: [PATCH] userdiff: add built-in pattern for CSS
Date: Fri, 20 May 2016 15:37:26 -0700 [thread overview]
Message-ID: <xmqqshxcbbkp.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160520132829.7937-1-william.duclot@ensimag.grenoble-inp.fr> (William Duclot's message of "Fri, 20 May 2016 15:28:29 +0200")
William Duclot <william.duclot@ensimag.grenoble-inp.fr> writes:
> CSS is widely used, motivating it being included as a built-in pattern.
>
> It must be noted that the word_regex for CSS (i.e. the regex defining
> what is a word in the language) does not consider '.' and '#' characters
> (in CSS selectors) to be part of the word. This behavior is documented
> by the test t/t4018/css-rule.
> The logic behind this behavior is the following: identifiers in CSS
> selectors are identifiers in a HTML/XML document. Therefore, the '.'/'#'
> character are not part of the identifier, but an indicator of the nature
> of the identifier in HTML/XML (class or id). Diffing ".class1" and
> ".class2" must show that the class name is changed, but we still are
> selecting a class.
In other words, if "div#foo" changed to "span#bar", word-diff would
say that "div changed to span, # didn't change and foo changed to
bar".
Which makes sense to me.
The above is not a request to change anything; just me thinking
aloud to see if I agree with the reasoning.
> diff --git a/userdiff.c b/userdiff.c
> index 6bf2505..0f9cfbe 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -148,6 +148,14 @@ PATTERNS("csharp",
> "[a-zA-Z_][a-zA-Z0-9_]*"
> "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
> "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"),
> +PATTERNS("css",
> + "^([^,{}]+)((,[^}]*\\{)|([ \t]*\\{))$",
> + /* -- */
> + /* This regex comes from W3C CSS specs. Should theoretically also allow ISO 10646 characters U+00A0 and higher,
> + * this not handled in this regex. */
> + "-?[_a-zA-F][-_a-zA-F0-9]*" /* identifiers */
> + "|-?[0-9]+|\\#[0-9a-fA-F]+" /* numbers */
> +),
Style:
/*
* This regex comes from ...
* ...
* but they are not handled with this regex.
*/
I wonder if IPATTERN() may make it easier to express the above.
Also, a-zA-F (twice seen in "identifiers" section) looks somewhat
suspicious. a-fA-F or a-zA-Z I would understand, and I suspect this
is a misspelled form of the latter.
next prev parent reply other threads:[~2016-05-20 22:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-20 13:28 [PATCH] userdiff: add built-in pattern for CSS William Duclot
2016-05-20 22:37 ` Junio C Hamano [this message]
2016-05-24 14:25 ` William Duclot
2016-05-24 19:06 ` Junio C Hamano
2016-05-24 22:12 ` William Duclot
2016-05-24 22:18 ` Junio C Hamano
2016-05-26 21:11 ` Johannes Sixt
2016-05-27 7:48 ` William Duclot
2016-06-02 22:48 ` William Duclot
2016-06-02 23:07 ` Junio C Hamano
2016-06-03 5:52 ` Johannes Sixt
2016-06-03 6:41 ` Matthieu Moy
2016-06-03 6:56 ` Johannes Sixt
2016-06-03 9:45 ` William Duclot
2016-06-03 15:50 ` Junio C Hamano
2016-06-06 7:28 ` William Duclot
2016-06-06 18:00 ` Junio C Hamano
2016-06-06 20:45 ` William Duclot
2016-06-06 20:55 ` Junio C Hamano
2016-06-03 12:32 ` William Duclot
2016-06-03 21:31 ` Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqshxcbbkp.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=antoine.queru@ensimag.grenoble-inp.fr \
--cc=francois.beutin@ensimag.grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=matthieu.moy@grenoble-inp.fr \
--cc=simon.rabourg@ensimag.grenoble-inp.fr \
--cc=william.duclot@ensimag.grenoble-inp.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.