[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c
From: |
Stefan Kangas |
Subject: |
Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c |
Date: |
Wed, 24 Jul 2024 04:33:32 -0700 |
Mattias Engdegård <mattias.engdegard@gmail.com> writes:
> 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:
It's not about what we get from tree-sitter, but what we pass to it.
I recently changed calls to ts_node_child_by_field_name and
treesit_query from using strlen for the length argument to using SBYTES.
But that meant that we now pass a length of 7 instead of 3 for Lisp
strings like "abc\^@def". The question is if tree-sitter will accept
that.
If it doesn't, I proposed that we might want to escape the NULs using
treesit_query_string_string. I'm struggling to find anything clear in
the tree-sitter documentation about this, but I see your recent change.
The other options are either warning about such Lisp strings when we get
them, or (my least favorite option) just revert back to using strlen.
> (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.)
Cleaning that up would be welcome in my book, FWIW.
- Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c, Po Lu, 2024/07/22
- Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c, Stefan Kangas, 2024/07/22
- Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c, Eli Zaretskii, 2024/07/22
- Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c, Stefan Kangas, 2024/07/22
- Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c, Eli Zaretskii, 2024/07/22
- Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c, Stefan Kangas, 2024/07/23
- Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c, Mattias Engdegård, 2024/07/24
- Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c,
Stefan Kangas <=
- Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c, Mattias Engdegård, 2024/07/24
- Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c, Yuan Fu, 2024/07/23