diff options
| author | Dmitry Antipov | 2012-07-11 10:14:19 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-11 10:14:19 +0400 |
| commit | d923b542aa2d115bb87e72e156be837cea752536 (patch) | |
| tree | e2a0c475d8d1aee4c790e77765554b6926871ab6 | |
| parent | 57054ddd444bd1702f2bcc08321d3ed3a644448e (diff) | |
| download | emacs-d923b542aa2d115bb87e72e156be837cea752536.tar.gz emacs-d923b542aa2d115bb87e72e156be837cea752536.zip | |
Avoid call to strlen in fast_c_string_match_ignore_case.
* search.c (fast_c_string_match_ignore_case): Change to use
length argument. Adjust users accordingly.
* lisp.h (fast_c_string_match_ignore_case): Adjust prototype.
| -rw-r--r-- | src/ChangeLog | 17 | ||||
| -rw-r--r-- | src/font.c | 9 | ||||
| -rw-r--r-- | src/font.h | 4 | ||||
| -rw-r--r-- | src/ftfont.c | 4 | ||||
| -rw-r--r-- | src/lisp.h | 3 | ||||
| -rw-r--r-- | src/lread.c | 2 | ||||
| -rw-r--r-- | src/search.c | 4 | ||||
| -rw-r--r-- | src/xfont.c | 3 |
8 files changed, 31 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 7b47636969e..8a6dc8644b8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-07-11 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Avoid call to strlen in fast_c_string_match_ignore_case. | ||
| 4 | * search.c (fast_c_string_match_ignore_case): Change to use | ||
| 5 | length argument. Adjust users accordingly. | ||
| 6 | * lisp.h (fast_c_string_match_ignore_case): Adjust prototype. | ||
| 7 | |||
| 1 | 2012-07-11 Paul Eggert <eggert@cs.ucla.edu> | 8 | 2012-07-11 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 9 | ||
| 3 | Assume rename. | 10 | Assume rename. |
| @@ -15,10 +22,12 @@ | |||
| 15 | 22 | ||
| 16 | Avoid calls to strlen in font processing functions. | 23 | Avoid calls to strlen in font processing functions. |
| 17 | * font.c (font_parse_name, font_parse_xlfd, font_parse_fcname) | 24 | * font.c (font_parse_name, font_parse_xlfd, font_parse_fcname) |
| 18 | (font_open_by_name): Changed to use length argument. Adjust | 25 | (font_open_by_name): Change to use length argument. Adjust |
| 19 | users accordingly. | 26 | users accordingly. |
| 20 | * font.h (font_open_by_name, font_parse_xlfd): Adjust prototypes. | 27 | * font.h (font_open_by_name, font_parse_xlfd, font_unparse_xlfd): |
| 21 | * xfont.c (xfont_decode_coding_xlfd): Changed to return ptrdiff_t. | 28 | Adjust prototypes. |
| 29 | * xfont.c (xfont_decode_coding_xlfd, font_unparse_xlfd): | ||
| 30 | Change to return ptrdiff_t. | ||
| 22 | (xfont_list_pattern, xfont_match): Use length returned by | 31 | (xfont_list_pattern, xfont_match): Use length returned by |
| 23 | xfont_decode_coding_xlfd. | 32 | xfont_decode_coding_xlfd. |
| 24 | * xfns.c (x_default_font_parameter): Omit useless xstrdup. | 33 | * xfns.c (x_default_font_parameter): Omit useless xstrdup. |
| @@ -107,7 +116,7 @@ | |||
| 107 | Use XCAR and XCDR instead of Fcar and Fcdr where possible. | 116 | Use XCAR and XCDR instead of Fcar and Fcdr where possible. |
| 108 | * callint.c, coding.c, doc.c, editfns.c, eval.c, font.c, fontset.c, | 117 | * callint.c, coding.c, doc.c, editfns.c, eval.c, font.c, fontset.c, |
| 109 | * frame.c, gnutls.c, minibuf.c, msdos.c, textprop.c, w32fns.c, | 118 | * frame.c, gnutls.c, minibuf.c, msdos.c, textprop.c, w32fns.c, |
| 110 | * w32menu.c, window.c, xmenu.c: Changed to use XCAR and XCDR | 119 | * w32menu.c, window.c, xmenu.c: Change to use XCAR and XCDR |
| 111 | where argument type is known to be a Lisp_Cons. | 120 | where argument type is known to be a Lisp_Cons. |
| 112 | 121 | ||
| 113 | 2012-07-10 Tom Tromey <tromey@redhat.com> | 122 | 2012-07-10 Tom Tromey <tromey@redhat.com> |
diff --git a/src/font.c b/src/font.c index 27abbe25786..bbfda984a4d 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -1199,7 +1199,7 @@ font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font) | |||
| 1199 | length), and return the name length. If FONT_SIZE_INDEX of FONT is | 1199 | length), and return the name length. If FONT_SIZE_INDEX of FONT is |
| 1200 | 0, use PIXEL_SIZE instead. */ | 1200 | 0, use PIXEL_SIZE instead. */ |
| 1201 | 1201 | ||
| 1202 | int | 1202 | ptrdiff_t |
| 1203 | font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes) | 1203 | font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes) |
| 1204 | { | 1204 | { |
| 1205 | char *p; | 1205 | char *p; |
| @@ -2642,15 +2642,18 @@ font_delete_unmatched (Lisp_Object vec, Lisp_Object spec, int size) | |||
| 2642 | if (! NILP (Vface_ignored_fonts)) | 2642 | if (! NILP (Vface_ignored_fonts)) |
| 2643 | { | 2643 | { |
| 2644 | char name[256]; | 2644 | char name[256]; |
| 2645 | ptrdiff_t namelen; | ||
| 2645 | Lisp_Object tail, regexp; | 2646 | Lisp_Object tail, regexp; |
| 2646 | 2647 | ||
| 2647 | if (font_unparse_xlfd (entity, 0, name, 256) >= 0) | 2648 | namelen = font_unparse_xlfd (entity, 0, name, 256); |
| 2649 | if (namelen >= 0) | ||
| 2648 | { | 2650 | { |
| 2649 | for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) | 2651 | for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) |
| 2650 | { | 2652 | { |
| 2651 | regexp = XCAR (tail); | 2653 | regexp = XCAR (tail); |
| 2652 | if (STRINGP (regexp) | 2654 | if (STRINGP (regexp) |
| 2653 | && fast_c_string_match_ignore_case (regexp, name) >= 0) | 2655 | && fast_c_string_match_ignore_case (regexp, name, |
| 2656 | namelen) >= 0) | ||
| 2654 | break; | 2657 | break; |
| 2655 | } | 2658 | } |
| 2656 | if (CONSP (tail)) | 2659 | if (CONSP (tail)) |
diff --git a/src/font.h b/src/font.h index 11329daa6e7..b4e994397de 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -782,8 +782,8 @@ extern void font_parse_family_registry (Lisp_Object family, | |||
| 782 | Lisp_Object spec); | 782 | Lisp_Object spec); |
| 783 | 783 | ||
| 784 | extern int font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font); | 784 | extern int font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font); |
| 785 | extern int font_unparse_xlfd (Lisp_Object font, int pixel_size, | 785 | extern ptrdiff_t font_unparse_xlfd (Lisp_Object font, int pixel_size, |
| 786 | char *name, int bytes); | 786 | char *name, int bytes); |
| 787 | extern int font_unparse_fcname (Lisp_Object font, int pixel_size, | 787 | extern int font_unparse_fcname (Lisp_Object font, int pixel_size, |
| 788 | char *name, int bytes); | 788 | char *name, int bytes); |
| 789 | extern void register_font_driver (struct font_driver *driver, FRAME_PTR f); | 789 | extern void register_font_driver (struct font_driver *driver, FRAME_PTR f); |
diff --git a/src/ftfont.c b/src/ftfont.c index 8e322369868..131a27f76e0 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -598,7 +598,9 @@ ftfont_get_charset (Lisp_Object registry) | |||
| 598 | re[j] = '\0'; | 598 | re[j] = '\0'; |
| 599 | regexp = make_unibyte_string (re, j); | 599 | regexp = make_unibyte_string (re, j); |
| 600 | for (i = 0; fc_charset_table[i].name; i++) | 600 | for (i = 0; fc_charset_table[i].name; i++) |
| 601 | if (fast_c_string_match_ignore_case (regexp, fc_charset_table[i].name) >= 0) | 601 | if (fast_c_string_match_ignore_case |
| 602 | (regexp, fc_charset_table[i].name, | ||
| 603 | strlen (fc_charset_table[i].name)) >= 0) | ||
| 602 | break; | 604 | break; |
| 603 | if (! fc_charset_table[i].name) | 605 | if (! fc_charset_table[i].name) |
| 604 | return -1; | 606 | return -1; |
diff --git a/src/lisp.h b/src/lisp.h index b4499b0eaaa..5077713451e 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2896,7 +2896,8 @@ extern struct re_pattern_buffer *compile_pattern (Lisp_Object, | |||
| 2896 | struct re_registers *, | 2896 | struct re_registers *, |
| 2897 | Lisp_Object, int, int); | 2897 | Lisp_Object, int, int); |
| 2898 | extern ptrdiff_t fast_string_match (Lisp_Object, Lisp_Object); | 2898 | extern ptrdiff_t fast_string_match (Lisp_Object, Lisp_Object); |
| 2899 | extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *); | 2899 | extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *, |
| 2900 | ptrdiff_t); | ||
| 2900 | extern ptrdiff_t fast_string_match_ignore_case (Lisp_Object, Lisp_Object); | 2901 | extern ptrdiff_t fast_string_match_ignore_case (Lisp_Object, Lisp_Object); |
| 2901 | extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t, | 2902 | extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t, |
| 2902 | ptrdiff_t, ptrdiff_t, Lisp_Object); | 2903 | ptrdiff_t, ptrdiff_t, Lisp_Object); |
diff --git a/src/lread.c b/src/lread.c index c0e4a173eeb..f74d44d12a8 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -906,7 +906,7 @@ safe_to_load_p (int fd) | |||
| 906 | 906 | ||
| 907 | if (i >= nbytes | 907 | if (i >= nbytes |
| 908 | || fast_c_string_match_ignore_case (Vbytecomp_version_regexp, | 908 | || fast_c_string_match_ignore_case (Vbytecomp_version_regexp, |
| 909 | buf + i) < 0) | 909 | buf + i, nbytes - i) < 0) |
| 910 | safe_p = 0; | 910 | safe_p = 0; |
| 911 | } | 911 | } |
| 912 | if (safe_p) | 912 | if (safe_p) |
diff --git a/src/search.c b/src/search.c index de95f5a30f4..118cec4af48 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -490,11 +490,11 @@ fast_string_match (Lisp_Object regexp, Lisp_Object string) | |||
| 490 | We assume that STRING contains single-byte characters. */ | 490 | We assume that STRING contains single-byte characters. */ |
| 491 | 491 | ||
| 492 | ptrdiff_t | 492 | ptrdiff_t |
| 493 | fast_c_string_match_ignore_case (Lisp_Object regexp, const char *string) | 493 | fast_c_string_match_ignore_case (Lisp_Object regexp, |
| 494 | const char *string, ptrdiff_t len) | ||
| 494 | { | 495 | { |
| 495 | ptrdiff_t val; | 496 | ptrdiff_t val; |
| 496 | struct re_pattern_buffer *bufp; | 497 | struct re_pattern_buffer *bufp; |
| 497 | size_t len = strlen (string); | ||
| 498 | 498 | ||
| 499 | regexp = string_make_unibyte (regexp); | 499 | regexp = string_make_unibyte (regexp); |
| 500 | re_match_object = Qt; | 500 | re_match_object = Qt; |
diff --git a/src/xfont.c b/src/xfont.c index 2ba7941c9cb..0443b49de8f 100644 --- a/src/xfont.c +++ b/src/xfont.c | |||
| @@ -434,7 +434,8 @@ xfont_list_pattern (Display *display, const char *pattern, | |||
| 434 | { | 434 | { |
| 435 | elt = XCAR (tail); | 435 | elt = XCAR (tail); |
| 436 | if (STRINGP (elt) | 436 | if (STRINGP (elt) |
| 437 | && fast_c_string_match_ignore_case (elt, indices[i]) >= 0) | 437 | && fast_c_string_match_ignore_case (elt, indices[i], |
| 438 | len) >= 0) | ||
| 438 | break; | 439 | break; |
| 439 | } | 440 | } |
| 440 | if (! CONSP (tail)) | 441 | if (! CONSP (tail)) |