diff options
| author | Dmitry Antipov | 2014-10-07 20:00:35 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-10-07 20:00:35 +0400 |
| commit | 5bdd495965548f6b754f204080f4f1e6bec622ed (patch) | |
| tree | 690b266b75525d09bb5ad52f2a061f4b829c2aea /src | |
| parent | 5571633133c6f600d4126a083819d3ae5804f1c0 (diff) | |
| download | emacs-5bdd495965548f6b754f204080f4f1e6bec622ed.tar.gz emacs-5bdd495965548f6b754f204080f4f1e6bec622ed.zip | |
* font.c (Ffont_get_glyphs): Use validate_subarray and fix
the case where an optional string is used. Adjust docstring.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/font.c | 54 |
2 files changed, 35 insertions, 24 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c03b6dad06f..b57c76d5e3f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-10-07 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * font.c (Ffont_get_glyphs): Use validate_subarray and fix | ||
| 4 | the case where an optional string is used. Adjust docstring. | ||
| 5 | |||
| 1 | 2014-10-06 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2014-10-06 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | * lisp.mk (lisp): Remove w32-common-fns.elc. | 8 | * lisp.mk (lisp): Remove w32-common-fns.elc. |
diff --git a/src/font.c b/src/font.c index 8405065a0d0..d73aed76d40 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -4687,9 +4687,10 @@ DEFUN ("font-get-glyphs", Ffont_get_glyphs, Sfont_get_glyphs, 3, 4, 0, | |||
| 4687 | doc: | 4687 | doc: |
| 4688 | /* Return a vector of FONT-OBJECT's glyphs for the specified characters. | 4688 | /* Return a vector of FONT-OBJECT's glyphs for the specified characters. |
| 4689 | FROM and TO are positions (integers or markers) specifying a region | 4689 | FROM and TO are positions (integers or markers) specifying a region |
| 4690 | of the current buffer. | 4690 | of the current buffer, and can be in either order. If the optional |
| 4691 | If the optional fourth arg OBJECT is not nil, it is a string or a | 4691 | fourth arg OBJECT is not nil, it is a string or a vector containing |
| 4692 | vector containing the target characters. | 4692 | the target characters between indices FROM and TO, which are treated |
| 4693 | as in `substring'. | ||
| 4693 | 4694 | ||
| 4694 | Each element is a vector containing information of a glyph in this format: | 4695 | Each element is a vector containing information of a glyph in this format: |
| 4695 | [FROM-IDX TO-IDX C CODE WIDTH LBEARING RBEARING ASCENT DESCENT ADJUSTMENT] | 4696 | [FROM-IDX TO-IDX C CODE WIDTH LBEARING RBEARING ASCENT DESCENT ADJUSTMENT] |
| @@ -4732,45 +4733,50 @@ the corresponding element is nil. */) | |||
| 4732 | else if (STRINGP (object)) | 4733 | else if (STRINGP (object)) |
| 4733 | { | 4734 | { |
| 4734 | const unsigned char *p; | 4735 | const unsigned char *p; |
| 4736 | ptrdiff_t ifrom, ito; | ||
| 4735 | 4737 | ||
| 4736 | CHECK_NUMBER (from); | 4738 | validate_subarray (object, from, to, SCHARS (object), &ifrom, &ito); |
| 4737 | CHECK_NUMBER (to); | 4739 | if (ifrom == ito) |
| 4738 | if (XINT (from) < 0 || XINT (from) > XINT (to) | ||
| 4739 | || XINT (to) > SCHARS (object)) | ||
| 4740 | args_out_of_range_3 (object, from, to); | ||
| 4741 | if (EQ (from, to)) | ||
| 4742 | return Qnil; | 4740 | return Qnil; |
| 4743 | len = XFASTINT (to) - XFASTINT (from); | 4741 | len = ito - ifrom; |
| 4744 | SAFE_ALLOCA_LISP (chars, len); | 4742 | SAFE_ALLOCA_LISP (chars, len); |
| 4745 | p = SDATA (object); | 4743 | p = SDATA (object); |
| 4746 | if (STRING_MULTIBYTE (object)) | 4744 | if (STRING_MULTIBYTE (object)) |
| 4747 | for (i = 0; i < len; i++) | 4745 | { |
| 4746 | int c; | ||
| 4747 | |||
| 4748 | /* Skip IFROM characters from the beginning. */ | ||
| 4749 | for (i = 0; i < ifrom; i++) | ||
| 4750 | c = STRING_CHAR_ADVANCE (p); | ||
| 4751 | |||
| 4752 | /* Now fetch an interesting characters. */ | ||
| 4753 | for (i = 0; i < len; i++) | ||
| 4748 | { | 4754 | { |
| 4749 | int c = STRING_CHAR_ADVANCE (p); | 4755 | c = STRING_CHAR_ADVANCE (p); |
| 4750 | chars[i] = make_number (c); | 4756 | chars[i] = make_number (c); |
| 4751 | } | 4757 | } |
| 4758 | } | ||
| 4752 | else | 4759 | else |
| 4753 | for (i = 0; i < len; i++) | 4760 | for (i = 0; i < len; i++) |
| 4754 | chars[i] = make_number (p[i]); | 4761 | chars[i] = make_number (p[ifrom + i]); |
| 4755 | } | 4762 | } |
| 4756 | else | 4763 | else if (VECTORP (object)) |
| 4757 | { | 4764 | { |
| 4758 | CHECK_VECTOR (object); | 4765 | ptrdiff_t ifrom, ito; |
| 4759 | CHECK_NUMBER (from); | 4766 | |
| 4760 | CHECK_NUMBER (to); | 4767 | validate_subarray (object, from, to, ASIZE (object), &ifrom, &ito); |
| 4761 | if (XINT (from) < 0 || XINT (from) > XINT (to) | 4768 | if (ifrom == ito) |
| 4762 | || XINT (to) > ASIZE (object)) | ||
| 4763 | args_out_of_range_3 (object, from, to); | ||
| 4764 | if (EQ (from, to)) | ||
| 4765 | return Qnil; | 4769 | return Qnil; |
| 4766 | len = XFASTINT (to) - XFASTINT (from); | 4770 | len = ito - ifrom; |
| 4767 | for (i = 0; i < len; i++) | 4771 | for (i = 0; i < len; i++) |
| 4768 | { | 4772 | { |
| 4769 | Lisp_Object elt = AREF (object, XFASTINT (from) + i); | 4773 | Lisp_Object elt = AREF (object, ifrom + i); |
| 4770 | CHECK_CHARACTER (elt); | 4774 | CHECK_CHARACTER (elt); |
| 4771 | } | 4775 | } |
| 4772 | chars = aref_addr (object, XFASTINT (from)); | 4776 | chars = aref_addr (object, ifrom); |
| 4773 | } | 4777 | } |
| 4778 | else | ||
| 4779 | wrong_type_argument (Qarrayp, object); | ||
| 4774 | 4780 | ||
| 4775 | vec = make_uninit_vector (len); | 4781 | vec = make_uninit_vector (len); |
| 4776 | for (i = 0; i < len; i++) | 4782 | for (i = 0; i < len; i++) |