summaryrefslogtreecommitdiff
path: root/src/font.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/font.c')
-rw-r--r--src/font.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/src/font.c b/src/font.c
index 39ec1b3562a..ab00402b40b 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3856,13 +3856,10 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit,
while (pos < *limit)
{
- Lisp_Object category;
-
- if (NILP (string))
- FETCH_CHAR_ADVANCE_NO_CHECK (c, pos, pos_byte);
- else
- FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, string, pos, pos_byte);
- category = CHAR_TABLE_REF (Vunicode_category_table, c);
+ c = (NILP (string)
+ ? fetch_char_advance_no_check (&pos, &pos_byte)
+ : fetch_string_char_advance_no_check (string, &pos, &pos_byte));
+ Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c);
if (FIXNUMP (category)
&& (XFIXNUM (category) == UNICODE_CATEGORY_Cf
|| CHAR_VARIATION_SELECTOR_P (c)))
@@ -4606,10 +4603,10 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
Lisp_Object window;
struct window *w;
- CHECK_FIXNUM_COERCE_MARKER (position);
- if (! (BEGV <= XFIXNUM (position) && XFIXNUM (position) < ZV))
+ EMACS_INT fixed_pos = fix_position (position);
+ if (! (BEGV <= fixed_pos && fixed_pos < ZV))
args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV));
- pos = XFIXNUM (position);
+ pos = fixed_pos;
pos_byte = CHAR_TO_BYTE (pos);
if (NILP (ch))
c = FETCH_CHAR (pos_byte);
@@ -4891,7 +4888,7 @@ the corresponding element is nil. */)
Lisp_Object object)
{
struct font *font = CHECK_FONT_GET_OBJECT (font_object);
- ptrdiff_t i, len;
+ ptrdiff_t len;
Lisp_Object *chars, vec;
USE_SAFE_ALLOCA;
@@ -4906,10 +4903,9 @@ the corresponding element is nil. */)
SAFE_ALLOCA_LISP (chars, len);
charpos = XFIXNAT (from);
bytepos = CHAR_TO_BYTE (charpos);
- for (i = 0; charpos < XFIXNAT (to); i++)
+ for (ptrdiff_t i = 0; charpos < XFIXNAT (to); i++)
{
- int c;
- FETCH_CHAR_ADVANCE (c, charpos, bytepos);
+ int c = fetch_char_advance (&charpos, &bytepos);
chars[i] = make_fixnum (c);
}
}
@@ -4929,18 +4925,18 @@ the corresponding element is nil. */)
int c;
/* Skip IFROM characters from the beginning. */
- for (i = 0; i < ifrom; i++)
- c = STRING_CHAR_ADVANCE (p);
+ for (ptrdiff_t i = 0; i < ifrom; i++)
+ p += BYTES_BY_CHAR_HEAD (*p);
/* Now fetch an interesting characters. */
- for (i = 0; i < len; i++)
- {
- c = STRING_CHAR_ADVANCE (p);
- chars[i] = make_fixnum (c);
- }
+ for (ptrdiff_t i = 0; i < len; i++)
+ {
+ c = string_char_advance (&p);
+ chars[i] = make_fixnum (c);
+ }
}
else
- for (i = 0; i < len; i++)
+ for (ptrdiff_t i = 0; i < len; i++)
chars[i] = make_fixnum (p[ifrom + i]);
}
else if (VECTORP (object))
@@ -4951,7 +4947,7 @@ the corresponding element is nil. */)
if (ifrom == ito)
return Qnil;
len = ito - ifrom;
- for (i = 0; i < len; i++)
+ for (ptrdiff_t i = 0; i < len; i++)
{
Lisp_Object elt = AREF (object, ifrom + i);
CHECK_CHARACTER (elt);
@@ -4962,7 +4958,7 @@ the corresponding element is nil. */)
wrong_type_argument (Qarrayp, object);
vec = make_uninit_vector (len);
- for (i = 0; i < len; i++)
+ for (ptrdiff_t i = 0; i < len; i++)
{
Lisp_Object g;
int c = XFIXNAT (chars[i]);
@@ -5013,24 +5009,26 @@ character at index specified by POSITION. */)
(Lisp_Object position, Lisp_Object window, Lisp_Object string)
{
struct window *w = decode_live_window (window);
+ EMACS_INT pos;
if (NILP (string))
{
if (XBUFFER (w->contents) != current_buffer)
error ("Specified window is not displaying the current buffer");
- CHECK_FIXNUM_COERCE_MARKER (position);
- if (! (BEGV <= XFIXNUM (position) && XFIXNUM (position) < ZV))
+ pos = fix_position (position);
+ if (! (BEGV <= pos && pos < ZV))
args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV));
}
else
{
CHECK_FIXNUM (position);
CHECK_STRING (string);
- if (! (0 <= XFIXNUM (position) && XFIXNUM (position) < SCHARS (string)))
+ pos = XFIXNUM (position);
+ if (! (0 <= pos && pos < SCHARS (string)))
args_out_of_range (string, position);
}
- return font_at (-1, XFIXNUM (position), NULL, w, string);
+ return font_at (-1, pos, NULL, w, string);
}
#if 0
@@ -5543,7 +5541,6 @@ cause Xft crashes. Only has an effect in Xft builds. */);
#ifdef USE_CAIRO
syms_of_ftcrfont ();
#else
- syms_of_ftxfont ();
#ifdef HAVE_XFT
syms_of_xftfont ();
#endif /* HAVE_XFT */