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

Re: [PATCH v2] utf8: add display_mode_esc_sequence_len_counted()

From
Andy Koppe <andy.koppe@gmail.com>
Date
Nov 18, 2026, 19:12 UTC
Message-ID
<CAHWeT-ZjZHFE1BhRSwv6cvK4=rk0ZXNak8uG1y75Pgy+vNVQdQ@mail.gmail.com>
In-Reply-To
<ghik1uassi.fsf@gouders.net>
Dirk Gouders wrote:
>
> On Wed, Nov 18 2026, Andy Koppe wrote:
Show 15 quoted lines
> >> And as far as I know, we would need an FSM to identify valid sequences
> >> if we are going to allow colons.
>
> > No. The parameter field can be any mix of digits, colons and
> > semicolons.  Semicolons separate parameters, colons separate
> > subparameters, and individual (sub)parameters can be empty, which is
> > equivalent to zero. If the field consists of nothing but colons,
> > that's one parameter with multiple empty subparameters.
>
> My statement was a bit misleading, because
> display_mode_esc_sequence_len() already is an FSM
> accepting the language "\033\[[0-9;]+m".  My concern was that I doubt
> that simply adding ":" to the alphabet and as valid input to the state
> "parameter"  (without introducing one or more new states) would still
> let it accept only valid SGR sequences.

"\033\[[0-9:;]*m" is the complete regex for SGRs. (Of course, it's not that simple if you wanted to actually collect the (sub)parameter values, but git doesn't need to.)

> It seems I can learn something: is "\033[:;m" a valid SGR sequence?

Yep. That's two parameters, with the first one consisting of two empty subparameters, and the second one an empty parameter.

> But, such a discussion is difficult without defining what language you
> want to accept.  I guess the two links were meant as a definition and I
> have to confess I didn't yet read them.

To be fair, ECMA-48 isn't the most readable, but once you realise that 3/0 stands for 0x30 (aka '0') and 3/11 for 0x3B (aka ';'), it's not too bad.

Andy
Previous: Dirk GoudersNext: Dirk Gouders
Message 14 of 15 in “utf8: make display_mode_esc_sequence_len() take a length”
  1. utf8: make display_mode_esc_sequence_len() take a lengthJunio C Hamano, Nov 17, 2026
  2. utf8: add display_mode_esc_sequence_len_counted()Junio C Hamano, Nov 17, 2026
  3. Dirk GoudersNov 17, 2026
  4. Junio C HamanoNov 17, 2026
  5. Dirk GoudersNov 17, 2026
  6. Junio C HamanoNov 18, 2026
  7. Dirk GoudersNov 18, 2026
  8. Andy KoppeNov 17, 2026
  9. Junio C HamanoNov 17, 2026
  10. Andy KoppeNov 18, 2026
  11. Dirk GoudersNov 18, 2026
  12. Andy KoppeNov 18, 2026
  13. Dirk GoudersNov 18, 2026
  14. Andy KoppeNov 18, 2026
  15. Dirk GoudersNov 18, 2026

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.