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

Re: [PATCH v2 2/2] mailinfo: support Unicode scissors

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 3, 2019, 06:47 UTC
Message-ID
<xmqq8swrtwj0.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190402143615.GC10564@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 17 quoted lines
> In fact, I think you could then combine this with the previous
> conditional and get:
>
>   if (skip_prefix(c, ">8", &end) ||
>       skip_prefix(c, "8<", &end) ||
>       skip_prefix(c, ">%", &end) ||
>       skip_prefix(c, "%<", &end) ||
>       /* U-2702 in UTF-8 */
>       skip_prefix(c, "\xE2\x9C\x82", &end)) {
>           in_perforation = 1;
> 	  perforation += end - c;
> 	  scissors += end - c;
> 	  c = end - 1; /* minus one to account for loop increment */
>   }
>
> (Though I'm still on the fence regarding the whole idea, so do not take
> this as an endorsement ;) ).

I do not think we want to add more, but use of skip_prefix does sound sensible. I was very tempted to suggest

	static const char *scissors[] = {
		">8", "8<", ">%", "%<",
                NULL,
	};
        const char **s;
	for (s = scissors; *s; s++)
		if (skip_prefix, c, *s, &end) {
			in_perforation = 1;
			...
			break;
		}
	}
        if (!s)
		... we are not looking at any of the scissors[] ...

but that would encourage adding more random entries to the array, which we would want to avoid in order to help reduce the cognirive load of end-users.

In hindsight, addition of an undocumented '%' was already a mistake. I wonder how widely it is in use (yes, I am tempted to deprecate and remove these two to match the code to the docs).

Previous: Jeff KingNext: Jeff King
Message 10 of 16 in “mailinfo: support Unicode scissors”
  1. mailinfo: support Unicode scissorsAndrei Rybak, Mar 31, 2019
  2. SZEDER GáborMar 31, 2019
  3. Junio C HamanoApr 1, 2019
  4. Jeff KingApr 1, 2019
  5. Duy NguyenApr 1, 2019
  6. Andrei RybakApr 1, 2019
  7. 1/2 mailinfo: use starts_with() for clarityAndrei Rybak, Apr 1, 2019
  8. 2/2 mailinfo: support Unicode scissorsAndrei Rybak, Apr 1, 2019
  9. Jeff KingApr 2, 2019
  10. Junio C HamanoApr 3, 2019
  11. Jeff KingApr 2, 2019
  12. mailinfo: use starts_with() when checking scissorsAndrei Rybak, Jun 8, 2021
  13. Jeff KingJun 8, 2021
  14. Junio C HamanoJun 9, 2021
  15. Jeff KingJun 9, 2021
  16. Junio C HamanoJun 9, 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.