+2012-07-11 Dmitry Antipov <dmantipov@yandex.ru>
+
+ 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.
+
2012-07-11 Paul Eggert <eggert@cs.ucla.edu>
Assume rename.
Avoid calls to strlen in font processing functions.
* font.c (font_parse_name, font_parse_xlfd, font_parse_fcname)
- (font_open_by_name): Changed to use length argument. Adjust
+ (font_open_by_name): Change to use length argument. Adjust
users accordingly.
- * font.h (font_open_by_name, font_parse_xlfd): Adjust prototypes.
- * xfont.c (xfont_decode_coding_xlfd): Changed to return ptrdiff_t.
+ * font.h (font_open_by_name, font_parse_xlfd, font_unparse_xlfd):
+ Adjust prototypes.
+ * xfont.c (xfont_decode_coding_xlfd, font_unparse_xlfd):
+ Change to return ptrdiff_t.
(xfont_list_pattern, xfont_match): Use length returned by
xfont_decode_coding_xlfd.
* xfns.c (x_default_font_parameter): Omit useless xstrdup.
Use XCAR and XCDR instead of Fcar and Fcdr where possible.
* callint.c, coding.c, doc.c, editfns.c, eval.c, font.c, fontset.c,
* frame.c, gnutls.c, minibuf.c, msdos.c, textprop.c, w32fns.c,
- * w32menu.c, window.c, xmenu.c: Changed to use XCAR and XCDR
+ * w32menu.c, window.c, xmenu.c: Change to use XCAR and XCDR
where argument type is known to be a Lisp_Cons.
2012-07-10 Tom Tromey <tromey@redhat.com>
length), and return the name length. If FONT_SIZE_INDEX of FONT is
0, use PIXEL_SIZE instead. */
-int
+ptrdiff_t
font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
{
char *p;
if (! NILP (Vface_ignored_fonts))
{
char name[256];
+ ptrdiff_t namelen;
Lisp_Object tail, regexp;
- if (font_unparse_xlfd (entity, 0, name, 256) >= 0)
+ namelen = font_unparse_xlfd (entity, 0, name, 256);
+ if (namelen >= 0)
{
for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail))
{
regexp = XCAR (tail);
if (STRINGP (regexp)
- && fast_c_string_match_ignore_case (regexp, name) >= 0)
+ && fast_c_string_match_ignore_case (regexp, name,
+ namelen) >= 0)
break;
}
if (CONSP (tail))
Lisp_Object spec);
extern int font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font);
-extern int font_unparse_xlfd (Lisp_Object font, int pixel_size,
- char *name, int bytes);
+extern ptrdiff_t font_unparse_xlfd (Lisp_Object font, int pixel_size,
+ char *name, int bytes);
extern int font_unparse_fcname (Lisp_Object font, int pixel_size,
char *name, int bytes);
extern void register_font_driver (struct font_driver *driver, FRAME_PTR f);
re[j] = '\0';
regexp = make_unibyte_string (re, j);
for (i = 0; fc_charset_table[i].name; i++)
- if (fast_c_string_match_ignore_case (regexp, fc_charset_table[i].name) >= 0)
+ if (fast_c_string_match_ignore_case
+ (regexp, fc_charset_table[i].name,
+ strlen (fc_charset_table[i].name)) >= 0)
break;
if (! fc_charset_table[i].name)
return -1;
struct re_registers *,
Lisp_Object, int, int);
extern ptrdiff_t fast_string_match (Lisp_Object, Lisp_Object);
-extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *);
+extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *,
+ ptrdiff_t);
extern ptrdiff_t fast_string_match_ignore_case (Lisp_Object, Lisp_Object);
extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t, Lisp_Object);
if (i >= nbytes
|| fast_c_string_match_ignore_case (Vbytecomp_version_regexp,
- buf + i) < 0)
+ buf + i, nbytes - i) < 0)
safe_p = 0;
}
if (safe_p)
We assume that STRING contains single-byte characters. */
ptrdiff_t
-fast_c_string_match_ignore_case (Lisp_Object regexp, const char *string)
+fast_c_string_match_ignore_case (Lisp_Object regexp,
+ const char *string, ptrdiff_t len)
{
ptrdiff_t val;
struct re_pattern_buffer *bufp;
- size_t len = strlen (string);
regexp = string_make_unibyte (regexp);
re_match_object = Qt;
{
elt = XCAR (tail);
if (STRINGP (elt)
- && fast_c_string_match_ignore_case (elt, indices[i]) >= 0)
+ && fast_c_string_match_ignore_case (elt, indices[i],
+ len) >= 0)
break;
}
if (! CONSP (tail))