all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefankangas@gmail.com>
To: "Mattias Engdegård" <mattias.engdegard@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, Yuan Fu <casouri@gmail.com>,
	luangruo@yahoo.com, emacs-devel@gnu.org
Subject: Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c
Date: Wed, 24 Jul 2024 04:33:32 -0700	[thread overview]
Message-ID: <CADwFkmnQGBHmavjf74tuFiagVBkfh6fh4HFw2R2+uY-LMh4M8w@mail.gmail.com> (raw)
In-Reply-To: <B3638644-2F20-431A-B4FA-96440A1C810B@gmail.com>

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.



  reply	other threads:[~2024-07-24 11:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <172164369582.30827.14373383262408294645@vcs2.savannah.gnu.org>
     [not found] ` <20240722102136.6C9D6C3534A@vcs2.savannah.gnu.org>
2024-07-22 10:27   ` master d995429e7bc: Use SBYTES instead of strlen in treesit.c Po Lu
2024-07-22 11:06     ` Stefan Kangas
2024-07-22 11:30       ` Eli Zaretskii
2024-07-22 11:55         ` Stefan Kangas
2024-07-22 12:22           ` Eli Zaretskii
2024-07-23 20:42           ` Stefan Kangas
2024-07-24  9:09             ` Mattias Engdegård
2024-07-24 11:33               ` Stefan Kangas [this message]
2024-07-24 12:02                 ` Mattias Engdegård
2024-07-23 17:09         ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADwFkmnQGBHmavjf74tuFiagVBkfh6fh4HFw2R2+uY-LMh4M8w@mail.gmail.com \
    --to=stefankangas@gmail.com \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=mattias.engdegard@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.