From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#56469: 29.0.50; Unibyte dir in directory_files_internal Date: Sun, 10 Jul 2022 10:58:30 -0400 Message-ID: References: <83y1x2177x.fsf@gnu.org> <83bktx11ji.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11795"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 56469@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 10 16:59:10 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1oAYOs-0002qq-5w for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Jul 2022 16:59:10 +0200 Original-Received: from localhost ([::1]:47328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oAYOq-0005hc-Gv for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Jul 2022 10:59:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oAYOk-0005hU-QH for bug-gnu-emacs@gnu.org; Sun, 10 Jul 2022 10:59:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43802) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oAYOk-0002aD-Hz for bug-gnu-emacs@gnu.org; Sun, 10 Jul 2022 10:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oAYOk-0004Za-CP for bug-gnu-emacs@gnu.org; Sun, 10 Jul 2022 10:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Jul 2022 14:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56469 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 56469-submit@debbugs.gnu.org id=B56469.165746512417547 (code B ref 56469); Sun, 10 Jul 2022 14:59:02 +0000 Original-Received: (at 56469) by debbugs.gnu.org; 10 Jul 2022 14:58:44 +0000 Original-Received: from localhost ([127.0.0.1]:37699 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oAYOS-0004Yw-9a for submit@debbugs.gnu.org; Sun, 10 Jul 2022 10:58:44 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:41502) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oAYOR-0004Yj-Cr for 56469@debbugs.gnu.org; Sun, 10 Jul 2022 10:58:43 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id EC6B6440980; Sun, 10 Jul 2022 10:58:37 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B602C4408F1; Sun, 10 Jul 2022 10:58:36 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1657465116; bh=5aHDkmUuDuuOVAV8Vm/V8Xzt3No1WGASWl0GY6m1MW0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=KkkpWiq+L6GCpyTibV99lK+5H8MdDbfyS+StZoY3JcW1OfN7tK5xL7X96upSjvSqy EeLKfX1V4loA6dXgBZ6u8apOc6eQlxNmQreW9xCKifBIjJty2hSDNcDiRybF9f4xmE qKsyNCHnqVosnc5JM+b8m4+QS80nYZX0rxoJyrbMHBnu+LRGnTZ7mlPqwvx7nOfDx6 czCzDs15fFXlyY1pCDx9xIZLWmVENlVcKhffdsnsnBCYkBGoWRpM69aE5eMERIj8rQ yyZfId9qWbOjzQ+yDUisiazKNFQJc3QQWETvJLcCKmvr/oiHkNELi65d2VFkZxxHcl M2mlEoGdELeLg== Original-Received: from pastel (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 84483120415; Sun, 10 Jul 2022 10:58:36 -0400 (EDT) In-Reply-To: <83bktx11ji.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 10 Jul 2022 17:32:17 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:236582 Archived-At: Eli Zaretskii [2022-07-10 17:32:17] wrote: >> From: Stefan Monnier >> Cc: 56469@debbugs.gnu.org >> Date: Sun, 10 Jul 2022 10:23:28 -0400 >> >> W.r.t to the comment, it's indeed unrelated to the patch (other than >> the fact that it touches the same code). The question is when we do: >> >> finalname = (nchars == nbytes) >> ? make_uninit_string (nbytes) >> : make_uninit_multibyte_string (nchars, nbytes); >> >> the actual bytes are "decoded" (i.e. in our internal UTF-8 encoding), so >> (nchars == nbytes) checks whether its "pure ASCII" or not and if it's >> pure ASCII we return a unibyte string. > > I don't think this is true, because early during startup we don't yet > have the coding-systems set up, and so the file names are unibyte and > undecoded. So that place in dired.c doesn't only handle ASCII when it > sees that ncahrs == nbytes. Hmm... the early startup is actually not a worry here (according to my tests `directory_files_internal` is first called when we get to native-compile the macroexp/bytecomp, at which point all our coding systems have been setup). But indeed, if the file name coding system is something like `binary`, DECODE_FILE will always return a unibyte string, so we may have non-ASCII bytes when (nchars == nbytes). Thanks, I'll update the comment accordingly. Stefan