diff options
Diffstat (limited to 'src/font.c')
| -rw-r--r-- | src/font.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/font.c b/src/font.c index ecb61ab6a53..14390335f3c 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -232,22 +232,35 @@ static int num_font_drivers; | |||
| 232 | STR. */ | 232 | STR. */ |
| 233 | 233 | ||
| 234 | Lisp_Object | 234 | Lisp_Object |
| 235 | font_intern_prop (const char *str, int len, int force_symbol) | 235 | font_intern_prop (const char *str, ptrdiff_t len, int force_symbol) |
| 236 | { | 236 | { |
| 237 | int i; | 237 | ptrdiff_t i; |
| 238 | Lisp_Object tem; | 238 | Lisp_Object tem; |
| 239 | Lisp_Object obarray; | 239 | Lisp_Object obarray; |
| 240 | EMACS_INT nbytes, nchars; | 240 | EMACS_INT nbytes, nchars; |
| 241 | 241 | ||
| 242 | if (len == 1 && *str == '*') | 242 | if (len == 1 && *str == '*') |
| 243 | return Qnil; | 243 | return Qnil; |
| 244 | if (!force_symbol && len >=1 && isdigit (*str)) | 244 | if (!force_symbol && 0 < len && '0' <= *str && *str <= '9') |
| 245 | { | 245 | { |
| 246 | for (i = 1; i < len; i++) | 246 | for (i = 1; i < len; i++) |
| 247 | if (! isdigit (str[i])) | 247 | if (! ('0' <= str[i] && str[i] <= '9')) |
| 248 | break; | 248 | break; |
| 249 | if (i == len) | 249 | if (i == len) |
| 250 | return make_number (atoi (str)); | 250 | { |
| 251 | EMACS_INT n; | ||
| 252 | |||
| 253 | i = 0; | ||
| 254 | for (n = 0; (n += str[i++] - '0') <= MOST_POSITIVE_FIXNUM; n *= 10) | ||
| 255 | { | ||
| 256 | if (i == len) | ||
| 257 | return make_number (n); | ||
| 258 | if (MOST_POSITIVE_FIXNUM / 10 < n) | ||
| 259 | break; | ||
| 260 | } | ||
| 261 | |||
| 262 | xsignal1 (Qoverflow_error, make_string (str, len)); | ||
| 263 | } | ||
| 251 | } | 264 | } |
| 252 | 265 | ||
| 253 | /* The following code is copied from the function intern (in | 266 | /* The following code is copied from the function intern (in |
| @@ -982,7 +995,7 @@ font_expand_wildcards (Lisp_Object *field, int n) | |||
| 982 | int | 995 | int |
| 983 | font_parse_xlfd (char *name, Lisp_Object font) | 996 | font_parse_xlfd (char *name, Lisp_Object font) |
| 984 | { | 997 | { |
| 985 | int len = strlen (name); | 998 | ptrdiff_t len = strlen (name); |
| 986 | int i, j, n; | 999 | int i, j, n; |
| 987 | char *f[XLFD_LAST_INDEX + 1]; | 1000 | char *f[XLFD_LAST_INDEX + 1]; |
| 988 | Lisp_Object val; | 1001 | Lisp_Object val; |
| @@ -1310,7 +1323,7 @@ font_parse_fcname (char *name, Lisp_Object font) | |||
| 1310 | char *p, *q; | 1323 | char *p, *q; |
| 1311 | char *size_beg = NULL, *size_end = NULL; | 1324 | char *size_beg = NULL, *size_end = NULL; |
| 1312 | char *props_beg = NULL, *family_end = NULL; | 1325 | char *props_beg = NULL, *family_end = NULL; |
| 1313 | int len = strlen (name); | 1326 | ptrdiff_t len = strlen (name); |
| 1314 | 1327 | ||
| 1315 | if (len == 0) | 1328 | if (len == 0) |
| 1316 | return -1; | 1329 | return -1; |
| @@ -1376,7 +1389,7 @@ font_parse_fcname (char *name, Lisp_Object font) | |||
| 1376 | if (*q != '=') | 1389 | if (*q != '=') |
| 1377 | { | 1390 | { |
| 1378 | /* Must be an enumerated value. */ | 1391 | /* Must be an enumerated value. */ |
| 1379 | int word_len; | 1392 | ptrdiff_t word_len; |
| 1380 | p = p + 1; | 1393 | p = p + 1; |
| 1381 | word_len = q - p; | 1394 | word_len = q - p; |
| 1382 | val = font_intern_prop (p, q - p, 1); | 1395 | val = font_intern_prop (p, q - p, 1); |
| @@ -1452,7 +1465,7 @@ font_parse_fcname (char *name, Lisp_Object font) | |||
| 1452 | Lisp_Object weight = Qnil, slant = Qnil; | 1465 | Lisp_Object weight = Qnil, slant = Qnil; |
| 1453 | Lisp_Object width = Qnil, size = Qnil; | 1466 | Lisp_Object width = Qnil, size = Qnil; |
| 1454 | char *word_start; | 1467 | char *word_start; |
| 1455 | int word_len; | 1468 | ptrdiff_t word_len; |
| 1456 | 1469 | ||
| 1457 | /* Scan backwards from the end, looking for a size. */ | 1470 | /* Scan backwards from the end, looking for a size. */ |
| 1458 | for (p = name + len - 1; p >= name; p--) | 1471 | for (p = name + len - 1; p >= name; p--) |
| @@ -1542,7 +1555,8 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes) | |||
| 1542 | Lisp_Object family, foundry; | 1555 | Lisp_Object family, foundry; |
| 1543 | Lisp_Object tail, val; | 1556 | Lisp_Object tail, val; |
| 1544 | int point_size; | 1557 | int point_size; |
| 1545 | int i, len = 1; | 1558 | int i; |
| 1559 | ptrdiff_t len = 1; | ||
| 1546 | char *p; | 1560 | char *p; |
| 1547 | Lisp_Object styles[3]; | 1561 | Lisp_Object styles[3]; |
| 1548 | const char *style_names[3] = { "weight", "slant", "width" }; | 1562 | const char *style_names[3] = { "weight", "slant", "width" }; |
| @@ -2093,8 +2107,8 @@ font_score (Lisp_Object entity, Lisp_Object *spec_prop) | |||
| 2093 | { | 2107 | { |
| 2094 | /* We use the higher 6-bit for the actual size difference. The | 2108 | /* We use the higher 6-bit for the actual size difference. The |
| 2095 | lowest bit is set if the DPI is different. */ | 2109 | lowest bit is set if the DPI is different. */ |
| 2096 | int diff; | 2110 | EMACS_INT diff; |
| 2097 | int pixel_size = XINT (spec_prop[FONT_SIZE_INDEX]); | 2111 | EMACS_INT pixel_size = XINT (spec_prop[FONT_SIZE_INDEX]); |
| 2098 | 2112 | ||
| 2099 | if (CONSP (Vface_font_rescale_alist)) | 2113 | if (CONSP (Vface_font_rescale_alist)) |
| 2100 | pixel_size *= font_rescale_ratio (entity); | 2114 | pixel_size *= font_rescale_ratio (entity); |
| @@ -4294,7 +4308,7 @@ created glyph-string. Otherwise, the value is nil. */) | |||
| 4294 | { | 4308 | { |
| 4295 | struct font *font; | 4309 | struct font *font; |
| 4296 | Lisp_Object font_object, n, glyph; | 4310 | Lisp_Object font_object, n, glyph; |
| 4297 | int i, j, from, to; | 4311 | EMACS_INT i, j, from, to; |
| 4298 | 4312 | ||
| 4299 | if (! composition_gstring_p (gstring)) | 4313 | if (! composition_gstring_p (gstring)) |
| 4300 | signal_error ("Invalid glyph-string: ", gstring); | 4314 | signal_error ("Invalid glyph-string: ", gstring); |