mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-05 22:20:24 -08:00
Port to glibc 2.43+ with GCC 15+
Port to planned glibc 2.43 (scheduled for February 2026), which will support qualifier-generic standard functions; see: https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690 For example, strchr (P, C) will return pointer to const if P is pointer to const. The idea is to catch dumb programming errors when a program mistakenly uses strchr to convert a pointer to const to an unrestricted pointer. This feature is required by C23, and will be enabled by default in GCC 15. * src/callint.c (Fcall_interactively): Respect constness of pointer when calling memchr. * src/gtkutil.c (xg_get_font): 2nd arg is char *, not const char *. * src/xfaces.c (parse_float_color_comp): Return bool, not double. New arg DST. All callers changed. This makes it easier for callers to use char const *. (parse_color_spec): Respect constness of pointer when calling strchr.
This commit is contained in:
parent
8cdc8a51ef
commit
4e7e340ee5
4 changed files with 30 additions and 26 deletions
|
|
@ -450,7 +450,7 @@ invoke it (via an `interactive' spec that contains, for instance, an
|
|||
char const *tem = string;
|
||||
for (ptrdiff_t i = 2; tem < string_end; i++)
|
||||
{
|
||||
char *pnl = memchr (tem + 1, '\n', string_len - (tem + 1 - string));
|
||||
char const *pnl = memchr (tem + 1, '\n', string_len - (tem + 1 - string));
|
||||
ptrdiff_t sz = pnl ? pnl - (tem + 1) : string_end - (tem + 1);
|
||||
|
||||
visargs[1] = make_string (tem + 1, sz);
|
||||
|
|
|
|||
|
|
@ -2894,10 +2894,11 @@ xg_font_filter (const PangoFontFamily *family,
|
|||
`FAMILY [VALUE1 VALUE2] SIZE'
|
||||
|
||||
This can be parsed using font_parse_fcname in font.c.
|
||||
DEFAULT_NAME, if non-zero, is the default font name. */
|
||||
DEFAULT_NAME, if non-null, is the default font name;
|
||||
it might be updated in place. */
|
||||
|
||||
Lisp_Object
|
||||
xg_get_font (struct frame *f, const char *default_name)
|
||||
xg_get_font (struct frame *f, char *default_name)
|
||||
{
|
||||
GtkWidget *w;
|
||||
int done = 0;
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ extern char *xg_get_file_name (struct frame *f,
|
|||
bool mustmatch_p,
|
||||
bool only_dir_p);
|
||||
|
||||
extern Lisp_Object xg_get_font (struct frame *f, const char *);
|
||||
extern Lisp_Object xg_get_font (struct frame *f, char *);
|
||||
|
||||
extern GtkWidget *xg_create_widget (const char *type,
|
||||
const char *name,
|
||||
|
|
|
|||
47
src/xfaces.c
47
src/xfaces.c
|
|
@ -950,19 +950,25 @@ parse_hex_color_comp (const char *s, const char *e, unsigned short *dst)
|
|||
}
|
||||
|
||||
/* Parse floating-point color component specification that starts at S
|
||||
and ends right before E. Return the parsed number if in the range
|
||||
[0,1]; otherwise return -1. */
|
||||
static double
|
||||
parse_float_color_comp (const char *s, const char *e)
|
||||
and ends right before E. Put the integer near-equivalent of that
|
||||
into *DST. Return true if successful, false otherwise. */
|
||||
static bool
|
||||
parse_float_color_comp (const char *s, const char *e, unsigned short *dst)
|
||||
{
|
||||
/* Only allow decimal float literals without whitespace. */
|
||||
for (const char *p = s; p < e; p++)
|
||||
if (!((*p >= '0' && *p <= '9')
|
||||
|| *p == '.' || *p == '+' || *p == '-' || *p == 'e' || *p == 'E'))
|
||||
return -1;
|
||||
return false;
|
||||
char *end;
|
||||
double x = strtod (s, &end);
|
||||
return (end == e && x >= 0 && x <= 1) ? x : -1;
|
||||
if (end == e && 0 <= x && x <= 1)
|
||||
{
|
||||
*dst = lrint (x * 65535);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Parse SPEC as a numeric color specification and set *R, *G and *B.
|
||||
|
|
@ -997,28 +1003,25 @@ parse_color_spec (const char *spec,
|
|||
}
|
||||
else if (strncmp (spec, "rgb:", 4) == 0)
|
||||
{
|
||||
char *sep1, *sep2;
|
||||
return ((sep1 = strchr (spec + 4, '/')) != NULL
|
||||
&& (sep2 = strchr (sep1 + 1, '/')) != NULL
|
||||
char const *sep1 = strchr (spec + 4, '/');
|
||||
if (!sep1)
|
||||
return false;
|
||||
char const *sep2 = strchr (sep1 + 1, '/');
|
||||
return (sep2
|
||||
&& parse_hex_color_comp (spec + 4, sep1, r)
|
||||
&& parse_hex_color_comp (sep1 + 1, sep2, g)
|
||||
&& parse_hex_color_comp (sep2 + 1, spec + len, b));
|
||||
}
|
||||
else if (strncmp (spec, "rgbi:", 5) == 0)
|
||||
{
|
||||
char *sep1, *sep2;
|
||||
double red, green, blue;
|
||||
if ((sep1 = strchr (spec + 5, '/')) != NULL
|
||||
&& (sep2 = strchr (sep1 + 1, '/')) != NULL
|
||||
&& (red = parse_float_color_comp (spec + 5, sep1)) >= 0
|
||||
&& (green = parse_float_color_comp (sep1 + 1, sep2)) >= 0
|
||||
&& (blue = parse_float_color_comp (sep2 + 1, spec + len)) >= 0)
|
||||
{
|
||||
*r = lrint (red * 65535);
|
||||
*g = lrint (green * 65535);
|
||||
*b = lrint (blue * 65535);
|
||||
return true;
|
||||
}
|
||||
char const *sep1 = strchr (spec + 5, '/');
|
||||
if (!sep1)
|
||||
return false;
|
||||
char const *sep2 = strchr (sep1 + 1, '/');
|
||||
return (sep2
|
||||
&& parse_float_color_comp (spec + 5, sep1, r)
|
||||
&& parse_float_color_comp (sep1 + 1, sep2, g)
|
||||
&& parse_float_color_comp (sep2 + 1, spec + len, b));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue