all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: arthur miller <arthur.miller@live.com>
Cc: emacs-devel@gnu.org
Subject: Re: A possible small tiny bug in win32 FULL_DEBUG build and some questions
Date: Fri, 03 Jan 2025 10:32:40 +0200	[thread overview]
Message-ID: <86zfk8guvr.fsf@gnu.org> (raw)
In-Reply-To: <AS8PR02MB101075C8F0899BBC64608AD7396152@AS8PR02MB10107.eurprd02.prod.outlook.com> (message from arthur miller on Fri, 3 Jan 2025 00:24:58 +0000)

> From: arthur miller <arthur.miller@live.com>
> CC: "emacs-devel@gnu.org" <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.



  reply	other threads:[~2025-01-03  8:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-02 15:59 A possible small tiny bug in win32 FULL_DEBUG build and some questions arthur miller
2025-01-02 17:19 ` Eli Zaretskii
2025-01-03  0:24   ` Sv: " arthur miller
2025-01-03  8:32     ` Eli Zaretskii [this message]
2025-01-03 16:19       ` arthur miller

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=86zfk8guvr.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    /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.