emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c


From: Mattias Engdegård
Subject: Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c
Date: Wed, 24 Jul 2024 11:09:13 +0200

23 juli 2024 kl. 22.42 skrev Stefan Kangas <stefankangas@gmail.com>:

>> We avoid that when they are converted from a sexp (see
>> treesit_query_string_string).
>> 
>> Perhaps we should do the same when we get a string?

Tree-sitter is something of which I know very little, but if you mean taking 
care of NULs when we create a Lisp string from what we get from tree-sitter, 
then it doesn't seem to be too broken at a quick glance:

`ts_query_capture_name_for_id` and `ts_query_string_value_for_id` return 
byte-counted strings and we do a somewhat reasonable job converting them.
(intern_c_string_1 is a bit questionable but so is the entire interning system; 
I may do something about that in Emacs 31 later on.)

Most other strings returned from TS appear to be NUL-terminated and we don't 
get any explicit length anyway.

For example, `ts_node_string` returns NUL-terminated string but it's a (TS) 
S-expression so it may contain strings in TS syntax with escaped NULs.

(We have too many string constructors in general and several of them don't do 
precisely what the caller thought they would but that's a different problem, to 
be dealt with another day.)

Also, TS string literals are almost but not quite parsable by the Lisp reader 
(why?) but I don't think we use the reader for them anywhere. `ts-node-string` 
seems to be used for testing only.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]