aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/callint.c2
-rw-r--r--src/gtkutil.c5
-rw-r--r--src/gtkutil.h2
-rw-r--r--src/xfaces.c47
4 files changed, 30 insertions, 26 deletions
diff --git a/src/callint.c b/src/callint.c
index e0246e5d594..ee06e6973f2 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -450,7 +450,7 @@ invoke it (via an `interactive' spec that contains, for instance, an
450 char const *tem = string; 450 char const *tem = string;
451 for (ptrdiff_t i = 2; tem < string_end; i++) 451 for (ptrdiff_t i = 2; tem < string_end; i++)
452 { 452 {
453 char *pnl = memchr (tem + 1, '\n', string_len - (tem + 1 - string)); 453 char const *pnl = memchr (tem + 1, '\n', string_len - (tem + 1 - string));
454 ptrdiff_t sz = pnl ? pnl - (tem + 1) : string_end - (tem + 1); 454 ptrdiff_t sz = pnl ? pnl - (tem + 1) : string_end - (tem + 1);
455 455
456 visargs[1] = make_string (tem + 1, sz); 456 visargs[1] = make_string (tem + 1, sz);
diff --git a/src/gtkutil.c b/src/gtkutil.c
index a8e65f7cb0f..7ad6c7ce8c4 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -2894,10 +2894,11 @@ xg_font_filter (const PangoFontFamily *family,
2894 `FAMILY [VALUE1 VALUE2] SIZE' 2894 `FAMILY [VALUE1 VALUE2] SIZE'
2895 2895
2896 This can be parsed using font_parse_fcname in font.c. 2896 This can be parsed using font_parse_fcname in font.c.
2897 DEFAULT_NAME, if non-zero, is the default font name. */ 2897 DEFAULT_NAME, if non-null, is the default font name;
2898 it might be updated in place. */
2898 2899
2899Lisp_Object 2900Lisp_Object
2900xg_get_font (struct frame *f, const char *default_name) 2901xg_get_font (struct frame *f, char *default_name)
2901{ 2902{
2902 GtkWidget *w; 2903 GtkWidget *w;
2903 int done = 0; 2904 int done = 0;
diff --git a/src/gtkutil.h b/src/gtkutil.h
index cabf88da73f..e6c1e19c765 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -91,7 +91,7 @@ extern char *xg_get_file_name (struct frame *f,
91 bool mustmatch_p, 91 bool mustmatch_p,
92 bool only_dir_p); 92 bool only_dir_p);
93 93
94extern Lisp_Object xg_get_font (struct frame *f, const char *); 94extern Lisp_Object xg_get_font (struct frame *f, char *);
95 95
96extern GtkWidget *xg_create_widget (const char *type, 96extern GtkWidget *xg_create_widget (const char *type,
97 const char *name, 97 const char *name,
diff --git a/src/xfaces.c b/src/xfaces.c
index 83d4c3f1f2c..b0052cdd455 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -950,19 +950,25 @@ parse_hex_color_comp (const char *s, const char *e, unsigned short *dst)
950} 950}
951 951
952/* Parse floating-point color component specification that starts at S 952/* Parse floating-point color component specification that starts at S
953 and ends right before E. Return the parsed number if in the range 953 and ends right before E. Put the integer near-equivalent of that
954 [0,1]; otherwise return -1. */ 954 into *DST. Return true if successful, false otherwise. */
955static double 955static bool
956parse_float_color_comp (const char *s, const char *e) 956parse_float_color_comp (const char *s, const char *e, unsigned short *dst)
957{ 957{
958 /* Only allow decimal float literals without whitespace. */ 958 /* Only allow decimal float literals without whitespace. */
959 for (const char *p = s; p < e; p++) 959 for (const char *p = s; p < e; p++)
960 if (!((*p >= '0' && *p <= '9') 960 if (!((*p >= '0' && *p <= '9')
961 || *p == '.' || *p == '+' || *p == '-' || *p == 'e' || *p == 'E')) 961 || *p == '.' || *p == '+' || *p == '-' || *p == 'e' || *p == 'E'))
962 return -1; 962 return false;
963 char *end; 963 char *end;
964 double x = strtod (s, &end); 964 double x = strtod (s, &end);
965 return (end == e && x >= 0 && x <= 1) ? x : -1; 965 if (end == e && 0 <= x && x <= 1)
966 {
967 *dst = lrint (x * 65535);
968 return true;
969 }
970 else
971 return false;
966} 972}
967 973
968/* Parse SPEC as a numeric color specification and set *R, *G and *B. 974/* Parse SPEC as a numeric color specification and set *R, *G and *B.
@@ -997,28 +1003,25 @@ parse_color_spec (const char *spec,
997 } 1003 }
998 else if (strncmp (spec, "rgb:", 4) == 0) 1004 else if (strncmp (spec, "rgb:", 4) == 0)
999 { 1005 {
1000 char *sep1, *sep2; 1006 char const *sep1 = strchr (spec + 4, '/');
1001 return ((sep1 = strchr (spec + 4, '/')) != NULL 1007 if (!sep1)
1002 && (sep2 = strchr (sep1 + 1, '/')) != NULL 1008 return false;
1009 char const *sep2 = strchr (sep1 + 1, '/');
1010 return (sep2
1003 && parse_hex_color_comp (spec + 4, sep1, r) 1011 && parse_hex_color_comp (spec + 4, sep1, r)
1004 && parse_hex_color_comp (sep1 + 1, sep2, g) 1012 && parse_hex_color_comp (sep1 + 1, sep2, g)
1005 && parse_hex_color_comp (sep2 + 1, spec + len, b)); 1013 && parse_hex_color_comp (sep2 + 1, spec + len, b));
1006 } 1014 }
1007 else if (strncmp (spec, "rgbi:", 5) == 0) 1015 else if (strncmp (spec, "rgbi:", 5) == 0)
1008 { 1016 {
1009 char *sep1, *sep2; 1017 char const *sep1 = strchr (spec + 5, '/');
1010 double red, green, blue; 1018 if (!sep1)
1011 if ((sep1 = strchr (spec + 5, '/')) != NULL 1019 return false;
1012 && (sep2 = strchr (sep1 + 1, '/')) != NULL 1020 char const *sep2 = strchr (sep1 + 1, '/');
1013 && (red = parse_float_color_comp (spec + 5, sep1)) >= 0 1021 return (sep2
1014 && (green = parse_float_color_comp (sep1 + 1, sep2)) >= 0 1022 && parse_float_color_comp (spec + 5, sep1, r)
1015 && (blue = parse_float_color_comp (sep2 + 1, spec + len)) >= 0) 1023 && parse_float_color_comp (sep1 + 1, sep2, g)
1016 { 1024 && parse_float_color_comp (sep2 + 1, spec + len, b));
1017 *r = lrint (red * 65535);
1018 *g = lrint (green * 65535);
1019 *b = lrint (blue * 65535);
1020 return true;
1021 }
1022 } 1025 }
1023 return false; 1026 return false;
1024} 1027}