After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 400072 - Handling of ; in control sequences
Handling of ; in control sequences
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
: 305507 306320 332630 334942 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-01-24 04:03 UTC by Mariano Suárez-Alvarez
Modified: 2007-02-23 18:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add ';' to the numeric class (3.14 KB, patch)
2007-01-24 10:40 UTC, Chris Wilson
none Details | Review
Create a numeric_list matcher (5.67 KB, patch)
2007-01-24 14:26 UTC, Chris Wilson
none Details | Review
Rebase the numeric_list matcher to HEAD (8.66 KB, patch)
2007-01-24 23:14 UTC, Chris Wilson
none Details | Review

Description Mariano Suárez-Alvarez 2007-01-24 04:03:34 UTC
Chris committed <http://svn.gnome.org/viewcvs/vte/trunk/src/table.c?rev=1512&r1=1453&r2=1512>:

2007-01-24  Chris Wilson <chris@chris-wilson.co.uk>

	<mariano> hm, vte is not matching «ESC [ ; 7 m» :/

	* src/table.c: (_vte_table_addi), (_vte_table_matchi),
	(_vte_table_match):
		s/GList/GSList/
		g_slist_append -> g_slist_reverse(g_slist_prepend)
		And finally add the subtable to handle the leading ';'
		in the variable length parameters.

That patch makes vte ignore a leading ; for a %m parameter (in vte-parlance; that is, a sequence of numbers).

Actually, the parameter bytes sequence of a control sequence is to be separated in sub-sequences by ‘;’ charaters, and each sub-sequence that turns out to be empty after doing this (including the initial sub-sequence and the final one) represents a default value, depending on the control sequence. This is ECMA-48 5.4.2.

For example, «ESC [ ; 7 m» should be treated as «ESC [ 0 ; 7 m» because 0 is the default parameter for the «ESC [ Ps m» control sequence. Likewise «ESC [ m» stands for «ESC [ 0 m».

These control sequence variations do arise in practice: they are (part of) what is wrong with bug 398401.


As for the GList->SList optimization, I think that in practice control sequences with many parameters are extremely rare (one could get actual usage data here...), so that a simpler optimization would be to allocate a GPtrArray with, say, g_ptr_array_sized_new (10) and put there the arginfo thingies.
Comment 1 Mariano Suárez-Alvarez 2007-01-24 04:45:27 UTC
By the way, to see the effect of the patch, say:

  echo -e 'AAA\e[4mBBB\e[;1mCCC\e[mDDD'

both in xterm and in src/vte. It prints 3 A's, starts underlining, then prints three B's, then goes to normal mode and starts using bold, and prints 3 C's, and then goes into normal mode again and prints 3 D's.

In vte, the implicit 0 in the '\e[;1m' part is not taken into account.
Comment 2 Chris Wilson 2007-01-24 10:40:52 UTC
Created attachment 81052 [details] [review]
Add ';' to the numeric class

Sorry Mariano, I wanted to ping a patch to you last night, but I needed sleep more.

This patch takes a simpler approach and extends '%d' to match '([0-9;]+)*' which is what _vte_table_extract_numbers() was designed to parse.
Comment 3 Chris Wilson 2007-01-24 11:14:01 UTC
Hmm, perhaps '([0-9]+;)*' is the closer regexp. PBC.
Comment 4 6ywcdrm9fz7qp53 2007-01-24 11:55:54 UTC
([0-9]*;?)*

I think
Comment 5 Chris Wilson 2007-01-24 12:42:53 UTC
Hah, this breaks '\e[1;1H' and I guess others.
* bangs head against brick wall.
Comment 6 Chris Wilson 2007-01-24 14:26:27 UTC
Created attachment 81078 [details] [review]
Create a numeric_list matcher

So introduce a numeric_list class (for '%m') search for a match on that subtable before a '%d'. If we fail to find a match, continue on to an exact number match.
Comment 7 Chris Wilson 2007-01-24 23:13:03 UTC
Reverted r1512, r1524: 2007-01-24  Chris Wilson <chris@chris-wilson.co.uk>

	cf Bug 400072 – Handling of ; in control sequences

	Morale of the story: wait until the morning.
	Revert r1512, the mistaken attempt at parsing '\e[;30m'.

	* src/table.c: (_vte_table_addi), (_vte_table_matchi),
	(_vte_table_match):

Comment 8 Chris Wilson 2007-01-24 23:14:36 UTC
Created attachment 81133 [details] [review]
Rebase the numeric_list matcher to HEAD
Comment 9 Chris Wilson 2007-01-25 01:53:25 UTC
*** Bug 305507 has been marked as a duplicate of this bug. ***
Comment 10 Chris Wilson 2007-01-25 01:54:50 UTC
Just found a previous thread, bug 305507, with an almost identical broken patch.
Comment 11 Chris Wilson 2007-01-31 22:54:39 UTC
*** Bug 306320 has been marked as a duplicate of this bug. ***
Comment 12 Chris Wilson 2007-01-31 23:40:12 UTC
*** Bug 334942 has been marked as a duplicate of this bug. ***
Comment 13 Chris Wilson 2007-01-31 23:40:25 UTC
*** Bug 332630 has been marked as a duplicate of this bug. ***
Comment 14 Chris Wilson 2007-02-23 16:58:34 UTC
I accidentally commited this patch a while ago and nobody has complained so far - it even fixed a couple of other bugs in the process.
Comment 15 Mariano Suárez-Alvarez 2007-02-23 18:51:31 UTC
FWIW, the patch has the issue that it does not take into account the fact that the values of default arguments depend on the control sequence (it's always 0 or 1, I guess). Some of this issues are catered for by hand in the source (that's why we have «CSI A» and «CSI %d A», for example).