From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c Date: Wed, 24 Jul 2024 11:09:13 +0200 Message-ID: References: <172164369582.30827.14373383262408294645@vcs2.savannah.gnu.org> <20240722102136.6C9D6C3534A@vcs2.savannah.gnu.org> <87o76pyb5h.fsf@yahoo.com> <8634o1br4c.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22788"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Yuan Fu , luangruo@yahoo.com, emacs-devel@gnu.org To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 24 11:10:19 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sWY0p-0005qn-G5 for ged-emacs-devel@m.gmane-mx.org; Wed, 24 Jul 2024 11:10:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWY06-0006dD-6e; Wed, 24 Jul 2024 05:09:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sWXzu-0006ax-H6 for emacs-devel@gnu.org; Wed, 24 Jul 2024 05:09:24 -0400 Original-Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWXzs-0008BB-RI; Wed, 24 Jul 2024 05:09:22 -0400 Original-Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-52ed741fe46so7553666e87.0; Wed, 24 Jul 2024 02:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721812155; x=1722416955; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=/uQfWyGOVzaLwROKUFeOdrFTzctm+pGtxg7r2L2sd+o=; b=irMpsifeQEx1mHilqWmaALa1juvcqxrirc88It6u4W2P3+NPgTUzTbY4PS+WeTy4i9 OAdhtJgUCtmqoO6jRNzeq18sB6rSvCW7P87If95P4PP5G/ua5SuZO2L8vbai0xF1ehcH MQiteQWVFdUZ57aqiUr+nkTLSE106n3FJs+LOm5kysdBSCAH9GFqaodQu4A+ItsIBZuG dpQLf5FcFH9mUxMeD0CVo7zX7+WItueeRbmUeute1BqpW0Jj7txxEKbbzVZd5rx8b9na G1mTvRv6zpCJYfe0hWmPEZZocwvEtdj/Z6vmGZmd2C9Eh0nL47q61UTLENddpQOvmJXa 7pjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721812155; x=1722416955; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/uQfWyGOVzaLwROKUFeOdrFTzctm+pGtxg7r2L2sd+o=; b=oi73wXfMTsj7f9GvLPp04H92KKb293m+uXZae5JMgJWp/WWQGy2ltx+1XhQXC7/7EV OnJQICn92JKnPAij00oXNJPhC78ehMjvCTGIbPju34XBB+FGp+u66+aeOR8OndsPv4R9 2X0AeNJoyetFMMpVzqushwSldg0pcm1uvS+Ue0o47gVhsMYPh5KCInKA+kG5Jk/82c+e vpdSuGkWvTjhQ2Wd6bLVGfG6Gwr1wY6+IyKjRo6Kr/VLw1Z1MFbyKoHK6UF2IiauHhzS UpgO1rzWeCTsA75ZaqVPsoCTnv1xoCK1xakR4hoXe3eIQFrBdWfFMgdcYSyo6rT9WqvP h0FA== X-Forwarded-Encrypted: i=1; AJvYcCUXahS5DFWkgvjDMyzlmmwiKhlXtu1Uaz28giQFQo8oliYNq2ZhuzAE/oVWpPiKdOKpRJxWzL3DAFc+FiNVdHKotusB X-Gm-Message-State: AOJu0YyiWmDRCDEI097NPxK64Hu+54/xXhmMeuPIo9lR5uNryqYYZ3kg b+QmXKd3SpDezJL5iaoh6puzxAjV9Fq4/DrjPv8DGBYflxycqGJqfdDT2Q== X-Google-Smtp-Source: AGHT+IHwR4h2h8Te3ECHYLxv/+5NguV4dZI+xfFyol5JZetrWIicqzQhPVYcQAzk11iSK63RWJWRQg== X-Received: by 2002:a05:6512:ac8:b0:52e:7f16:96b6 with SMTP id 2adb3069b0e04-52efb837fcfmr8329440e87.37.1721812154961; Wed, 24 Jul 2024 02:09:14 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-191-82.bredband.tele2.se. [188.150.191.82]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52efa29b249sm1553828e87.79.2024.07.24.02.09.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2024 02:09:14 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=mattias.engdegard@gmail.com; helo=mail-lf1-x130.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:322031 Archived-At: 23 juli 2024 kl. 22.42 skrev Stefan Kangas : >> We avoid that when they are converted from a sexp (see >> treesit_query_string_string). >>=20 >> 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.