[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: About the new frame title
From: |
Andrea Corallo |
Subject: |
Re: About the new frame title |
Date: |
Fri, 13 Nov 2020 23:51:54 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Stefan Kangas <stefankangas@gmail.com> writes:
[...]
Hi Stefan,
> From b373d79630bc6b419c46d782f13c4c4bfb625f0c Mon Sep 17 00:00:00 2001
> From: Stefan Kangas <stefan@marxist.se>
> Date: Sat, 19 Sep 2020 14:13:52 +0200
> Subject: [PATCH] Make initial frame match frame-title-format
>
> * src/xterm.c (x_term_init):
> * src/w32term.c (w32_initialize_display_info): Sync initial frame
> title with new value of Vframe_title_format.
> Problem reported by Angelo Graziosi <angelo.g0@libero.it>.
> ---
> src/w32term.c | 13 ++++++++-----
> src/xterm.c | 24 ++++++++++++++----------
> 2 files changed, 22 insertions(+), 15 deletions(-)
>
> diff --git a/src/w32term.c b/src/w32term.c
> index e0618e4f52..89fa26ed9f 100644
> --- a/src/w32term.c
> +++ b/src/w32term.c
> @@ -7167,13 +7167,16 @@ w32_initialize_display_info (Lisp_Object display_name)
> dpyinfo->name_list_element = Fcons (display_name, Qnil);
> if (STRINGP (Vsystem_name))
> {
> - dpyinfo->w32_id_name = xmalloc (SCHARS (Vinvocation_name)
> - + SCHARS (Vsystem_name) + 2);
> - sprintf (dpyinfo->w32_id_name, "%s@%s",
> - SDATA (Vinvocation_name), SDATA (Vsystem_name));
> + static char const title[] = "GNU Emacs at ";
> + dpyinfo->w32_id_name = xmalloc (sizeof title + SCHARS (Vsystem_name));
I believe `sizeof (title)` is more conventional nowdays as safer.
> + sprintf (dpyinfo->w32_id_name, "%s%s", title, SDATA (Vsystem_name));
> }
> else
> - dpyinfo->w32_id_name = xlispstrdup (Vinvocation_name);
> + {
> + static char const title[] = "GNU Emacs";
> + dpyinfo->w32_id_name = xmalloc (sizeof title);
Same
> + sprintf (dpyinfo->w32_id_name, "%s", title);
I think a strcpy here would be sufficent as the format string is only "%s".
> + }
>
> /* Default Console mode values - overridden when running in GUI mode
> with values obtained from system metrics. */
> diff --git a/src/xterm.c b/src/xterm.c
> index 98bb0ea891..c65588cfda 100644
> --- a/src/xterm.c
> +++ b/src/xterm.c
> @@ -12928,19 +12928,23 @@ #define NUM_ARGV 10
> #endif
>
> Lisp_Object system_name = Fsystem_name ();
> -
> - ptrdiff_t nbytes = SBYTES (Vinvocation_name) + 1;
> - if (STRINGP (system_name)
> - && INT_ADD_WRAPV (nbytes, SBYTES (system_name) + 1, &nbytes))
> - memory_full (SIZE_MAX);
> - dpyinfo->x_id = ++x_display_id;
> - dpyinfo->x_id_name = xmalloc (nbytes);
> - char *nametail = lispstpcpy (dpyinfo->x_id_name, Vinvocation_name);
> if (STRINGP (system_name))
> {
> - *nametail++ = '@';
> - lispstpcpy (nametail, system_name);
> + static char const title[] = "GNU Emacs at ";
> + ptrdiff_t nbytes = sizeof title;
Same
> + if (INT_ADD_WRAPV (nbytes, SBYTES (system_name), &nbytes))
> + memory_full (SIZE_MAX);
> + dpyinfo->x_id_name = xmalloc (nbytes);
> + sprintf (dpyinfo->x_id_name, "%s%s", title, SDATA (system_name));
> }
> + else
> + {
> + static char const title[] = "GNU Emacs";
> + dpyinfo->x_id_name = xmalloc (sizeof title);
> + sprintf (dpyinfo->x_id_name, "%s", title);
Same
> + }
> +
> + dpyinfo->x_id = ++x_display_id;
>
> /* Figure out which modifier bits mean what. */
> x_find_modifier_meanings (dpyinfo);
Hope it helps
Andrea