git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [GSOC][PATCH] userdiff: add support for Scheme

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 28, 2021, 18:06 UTC
Message-ID
<xmqqft0fm9uu.fsf@gitster.g>
In-Reply-To
<EBC020E6-BE8B-4332-8225-A988CB7CFA69@gmail.com>
Atharva Raykar <raykar.ath@gmail.com> writes:
Show 14 quoted lines
>>> +         "(\\.|[^][)(\\}\\{ ])+"),
>> 
>> One or more "dot or anything other than SP or parentheses"?  But
>> a dot "." is neither a space or any {bra-ce} letter, so would the
>> above be equivalent to
>> 
>> 	"[^][()\\{\\} \t]+"
>> 
>> I wonder...
>
> A backslash is allowed in scheme identifiers, and I erroneously thought that
> the first part handles the case for identifiers such as `component\new` or 
> `\"id-with-quotes\"`. (I tested it with a regex engine that behaves differently
> than the one git is using, my bad.)

Ah, perhaps you didn't have enough backslashes. A half of the doubled one before the dot is eaten by the C compiler, so the regexp engine is seeing only a single backslash before the dot, which means "literally a single dot". If you meant "literally a single backslash, followed by any single char", you probably would write 4 backslashes and a dot---half of the backslashes would be eaten by the compiler, so you'd be passing two backslashes and a dot, which is probably what you meant.

Having said that, two further points.
 - the "anything but whitespaces and various forms of parentheses"
   set would include backslash, so 'component\new' would be taken as
   a single word with "[^][()\\{\\} \t]+", wouldn't it?
 - how common is the use of backslashes in identifiers?  I am trying
   to see if the additional complexity needed to support them is
   worth the benefit.
Show 6 quoted lines
> But somehow, the regexp you suggested, ie:
>
> 	"[^][()\\{\\} \t]+"
>
> does not handle the case of make\foo -> make\bar (it will only diff on foo).
> I am not too sure why it treats backslashes as delimiters.

Perhaps because you have included two backslashes inside [] to say "backslash is not a word character" in the original, and I blindly copied that? IOW, do you need to quote {} inside []?

> Yes, this is exactly what I was trying to express. All words should be
> delimited by either whitespace or a parenthesis, and all other special
> characters should be accepted as part of the word.

That sentence after "All words should be..." would be a good comment to replace what you wrote in the original, then ;-).

Previous: Atharva RaykarNext: Atharva Raykar
Message 13 of 35 in “userdiff: add support for Scheme”
  1. Atharva RaykarMar 27, 2021
  2. Junio C HamanoMar 27, 2021
  3. Junio C HamanoMar 27, 2021
  4. Ævar Arnfjörð BjarmasonMar 28, 2021
  5. Junio C HamanoMar 28, 2021
  6. Atharva RaykarMar 28, 2021
  7. Phillip WoodMar 29, 2021
  8. Atharva RaykarMar 30, 2021
  9. Ævar Arnfjörð BjarmasonMar 30, 2021
  10. Atharva RaykarMar 30, 2021
  11. Atharva RaykarMar 28, 2021
  12. Atharva RaykarMar 28, 2021
  13. Junio C HamanoMar 28, 2021
  14. Atharva RaykarMar 29, 2021
  15. Junio C HamanoMar 29, 2021
  16. Phillip WoodMar 29, 2021
  17. Johannes SixtMar 27, 2021
  18. Atharva RaykarMar 28, 2021
  19. Phillip WoodMar 29, 2021
  20. Johannes SixtMar 29, 2021
  21. Ævar Arnfjörð BjarmasonMar 29, 2021
  22. Phillip WoodMar 29, 2021
  23. Atharva RaykarMar 30, 2021
  24. Atharva RaykarMar 30, 2021
  25. Phillip WoodApr 5, 2021
  26. Johannes SixtApr 5, 2021
  27. Atharva RaykarApr 6, 2021
  28. Phillip WoodApr 6, 2021
  29. [GSoC][PATCH v2 0/1] userdiff: add support for schemeAtharva Raykar, Apr 3, 2021
  30. [GSoC][PATCH v2 1/1] userdiff: add support for schemeAtharva Raykar, Apr 3, 2021
  31. Phillip WoodApr 5, 2021
  32. Atharva RaykarApr 6, 2021
  33. [GSoC][PATCH v3 0/1] userdiff: add support for schemeAtharva Raykar, Apr 8, 2021
  34. [GSoC][PATCH v3 1/1] userdiff: add support for SchemeAtharva Raykar, Apr 8, 2021
  35. Junio C HamanoApr 12, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.