emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A possible small tiny bug in win32 FULL_DEBUG build and some questio


From: Eli Zaretskii
Subject: Re: A possible small tiny bug in win32 FULL_DEBUG build and some questions
Date: Fri, 03 Jan 2025 10:32:40 +0200

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]