unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: arthur miller <arthur.miller@live.com>
To: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: A possible small tiny bug in win32 FULL_DEBUG build and some questions
Date: Thu, 2 Jan 2025 15:59:32 +0000	[thread overview]
Message-ID: <VI1PR02MB10098B3AF2D31EC2BA800DD7696142@VI1PR02MB10098.eurprd02.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2748 bytes --]

Tiny bug: line 2447 in w32proc.c should probably read: cp->child_procs; not
cp-child_procs.

Possible tiny opt/simplification: SetConsoleCP & SetConsoleOutputCP
already do check for validity themselves (as far as I have tested with invalid
codepages), so it is possible to simplify those two:

DEFUN ("w32-set-console-codepage", Fw32_set_console_codepage,
       Sw32_set_console_codepage, 1, 1, 0,
       doc: /* Make Windows codepage CP be the codepage for Emacs tty keyboard input.
This codepage setting affects keyboard input in tty mode.
If successful, the new CP is returned, otherwise nil.  */)
  (Lisp_Object cp)
{
  CHECK_FIXNUM (cp);

  if (SetConsoleCP (XFIXNUM (cp)) != 0)
    return make_fixnum (GetConsoleCP ());
  return Qnil;
}

DEFUN ("w32-set-console-output-codepage", Fw32_set_console_output_codepage,
       Sw32_set_console_output_codepage, 1, 1, 0,
       doc: /* Make Windows codepage CP be the codepage for Emacs console output.
This codepage setting affects display in tty mode.
If successful, the new CP is returned, otherwise nil.  */)
  (Lisp_Object cp)
{
  CHECK_FIXNUM (cp);

  if (SetConsoleOutputCP (XFIXNUM (cp)) != 0)
    return make_fixnum (GetConsoleOutputCP ());
  return Qnil;
}

Msdn (or whatever they call it now) docs says it returns 0 if it does not
succeed. I have tested with few invalid numbers for CPs and those functions seem
to work fine for me. I am not expert on win32, perhaps there is something I miss
there? Nothing important, but if you want I can give you a patch.

Some questions:

Does GC-protected variables, those delcared as "staticpro", works the way I
think they work: GC never collects them?

If I enum all codepages with w32-get-valid-codepages, than the list will forever
stay alive? Even if the result from the function is never assigned to a variable
int the user code? 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?

Another question: can list of valid codepages on the system change during the
runtime? Would it be OK to check if the list is alreay built, and just return
it, instead of setting the list to nil on each run and re-computing it? I guess
it is not something that changes often? I don't know really how it works on the
system level, so just a question.

Also, is it important that this list is in some particular order? Why reversing
it before returning it?

[-- Attachment #2: Type: text/html, Size: 9720 bytes --]

             reply	other threads:[~2025-01-02 15:59 UTC|newest]

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR02MB10098B3AF2D31EC2BA800DD7696142@VI1PR02MB10098.eurprd02.prod.outlook.com \
    --to=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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).