From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: A possible small tiny bug in win32 FULL_DEBUG build and some questions Date: Fri, 03 Jan 2025 10:32:40 +0200 Message-ID: <86zfk8guvr.fsf@gnu.org> References: <86ed1ljfqc.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5911"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: arthur miller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 03 09:33:36 2025 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 1tTd7g-0001Nf-Ic for ged-emacs-devel@m.gmane-mx.org; Fri, 03 Jan 2025 09:33:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTd6w-0005G0-05; Fri, 03 Jan 2025 03:32:50 -0500 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 1tTd6r-0005FK-Ha for emacs-devel@gnu.org; Fri, 03 Jan 2025 03:32:45 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tTd6p-0003uI-ID; Fri, 03 Jan 2025 03:32:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=35/hL6wEJts/GTf8/J0Y2HJNfx9aCorK2QLLPzrgV4Y=; b=VFCHZPIL3/WOzlFnZ1NU BhXx/EyhVRpz3CuN2ParIM2Pkh3z0im6HxBbex1zE89cIaFYXOCbYLltVqg3nkPQVFSFPkplgME91 QjJUMZeZBWMQOIweu9JIgrQwt/zWDFfMLmItvHDWGoZrntHVBYucO5zGHSDztiaHxblnE+1efXC7B VQ4+ieJN+fpyFZKyLlzTobTcmXDOmghznlbWpU3ip6KOgmVhXXu2vGwZ9JGsKzUa10pDdr2jpAWuX ViVReHIYlq8/PhPPvC2TkDbo7t/QxPExJTrr7MzQS78myBQvMDgJ9CQxlC1Xn50S1aF6MNF2M87b6 LcrUyXphEczYhA==; In-Reply-To: (message from arthur miller on Fri, 3 Jan 2025 00:24:58 +0000) 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:327613 Archived-At: > From: arthur miller > CC: "emacs-devel@gnu.org" > Date: Fri, 3 Jan 2025 00:24:58 +0000 > > (let ((cp (w32-get-console-codepage)) > (cpo (w32-get-console-output-codepage))) > (dotimes (i 100000) > (w32-set-console-codepage i) > (w32-set-console-output-codepage i) > (w32-set-console-codepage (- i 10000)) > (w32-set-console-output-codepage (- i 10000))) > (w32-set-console-codepage cp) > (w32-set-console-output-codepage cpo)) > > Anyway, in the world of utf8 I guess nobody is using that code anyway, > so it does not really matter. Was just a little curiosa while I was > looking through the code for the reference. The codepages are still very much used in Emacs on Windows. The Windows UTF-8 support is rudimentary and marked "experimental" by MS. So we still need to consider the codepages when referencing external stuff. > >> I don't see any usage of this function, neither in C code nor > >> in Lisp (I grepped through); so I guess it is just eventually only called from > >> the external packages or just interactively by the user. Is it worth to copy > >> the returned list into a local list and return that so that the global list can > >> be freed so not to leak that list in the case the user does not want to save > >> that list anyway? > > > >I don't understand where did you see a leak, and what kind of a leak > >is that, please elaborate. > > I am assuming that this function can't be used very often. If the user > calls it for some reason (debugging, curiosity, checking if a codepage > is loaded?), the list will be constructed, but probably not used in a > single usage. But the space allocated for it will be allocated until > Emacs exists. If space is used but not needed than in a sense, it is a > memory leak. That's not a memory leak in my book, no. A value that is computed once and left to be used for the entire session is not a leak. > >I guess we want to return the list in the order the OS enumerates > > MS does not state any order of enumaration for this list, and the return > value does not seem to be sorted in some order, so any code that would > actually consult this list can't rely on any order and should probably > use functions like member or find; not elt or nth. > > >them, not in the reverse order. Again, why is this important? I > >don't think this function is likely to be called inside tight loops, > >is it? > > Of course not. Actually I don't think myself this function will be > called much at all. Codepages are more or less passé in the world of > utf8; so that is probably old cruft that is used on old systems, or is > that still needed? Not yet passé, see above.