From 4ec88040a1c1ff9a280d40cbcdc083b1121654de Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sun, 30 Jan 2011 01:35:35 +0100 Subject: [PATCH] * src/font.c (PROP_MATCH): Remove parameter N and use strlen instead. All uses changed. (PROP_SAVE): Likewise. --- src/ChangeLog | 6 ++++ src/font.c | 78 ++++++++++++++++++++++++++------------------------- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 0c562f87994..50a7a217245 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-01-30 Andreas Schwab + + * font.c (PROP_MATCH): Remove parameter N and use strlen instead. + All uses changed. + (PROP_SAVE): Likewise. + 2011-01-29 Chong Yidong * keyboard.c (make_lispy_position): Fix typo in last change diff --git a/src/font.c b/src/font.c index 449169dad1b..58d8dc90962 100644 --- a/src/font.c +++ b/src/font.c @@ -1380,25 +1380,26 @@ font_parse_fcname (char *name, Lisp_Object font) word_len = q - p; val = font_intern_prop (p, q - p, 1); -#define PROP_MATCH(STR,N) ((word_len == N) && memcmp (p, STR, N) == 0) - - if (PROP_MATCH ("light", 5) - || PROP_MATCH ("medium", 6) - || PROP_MATCH ("demibold", 8) - || PROP_MATCH ("bold", 4) - || PROP_MATCH ("black", 5)) +#define PROP_MATCH(STR) (word_len == strlen (STR) \ + && memcmp (p, STR, strlen (STR)) == 0) + + if (PROP_MATCH ("light") + || PROP_MATCH ("medium") + || PROP_MATCH ("demibold") + || PROP_MATCH ("bold") + || PROP_MATCH ("black")) FONT_SET_STYLE (font, FONT_WEIGHT_INDEX, val); - else if (PROP_MATCH ("roman", 5) - || PROP_MATCH ("italic", 6) - || PROP_MATCH ("oblique", 7)) + else if (PROP_MATCH ("roman") + || PROP_MATCH ("italic") + || PROP_MATCH ("oblique")) FONT_SET_STYLE (font, FONT_SLANT_INDEX, val); - else if (PROP_MATCH ("charcell", 8)) + else if (PROP_MATCH ("charcell")) ASET (font, FONT_SPACING_INDEX, make_number (FONT_SPACING_CHARCELL)); - else if (PROP_MATCH ("mono", 4)) + else if (PROP_MATCH ("mono")) ASET (font, FONT_SPACING_INDEX, make_number (FONT_SPACING_MONO)); - else if (PROP_MATCH ("proportional", 12)) + else if (PROP_MATCH ("proportional")) ASET (font, FONT_SPACING_INDEX, make_number (FONT_SPACING_PROPORTIONAL)); #undef PROP_MATCH @@ -1480,31 +1481,32 @@ font_parse_fcname (char *name, Lisp_Object font) word_start = q + 1; word_len = p - word_start; -#define PROP_MATCH(STR,N) \ - ((word_len == N) && memcmp (word_start, STR, N) == 0) -#define PROP_SAVE(VAR,STR,N) \ - (VAR = NILP (VAR) ? font_intern_prop (STR, N, 1) : VAR) - - if (PROP_MATCH ("Ultra-Light", 11)) - PROP_SAVE (weight, "ultra-light", 11); - else if (PROP_MATCH ("Light", 5)) - PROP_SAVE (weight, "light", 5); - else if (PROP_MATCH ("Book", 4)) - PROP_SAVE (weight, "book", 4); - else if (PROP_MATCH ("Medium", 6)) - PROP_SAVE (weight, "medium", 6); - else if (PROP_MATCH ("Semi-Bold", 9)) - PROP_SAVE (weight, "semi-bold", 9); - else if (PROP_MATCH ("Bold", 4)) - PROP_SAVE (weight, "bold", 4); - else if (PROP_MATCH ("Italic", 6)) - PROP_SAVE (slant, "italic", 6); - else if (PROP_MATCH ("Oblique", 7)) - PROP_SAVE (slant, "oblique", 7); - else if (PROP_MATCH ("Semi-Condensed", 14)) - PROP_SAVE (width, "semi-condensed", 14); - else if (PROP_MATCH ("Condensed", 9)) - PROP_SAVE (width, "condensed", 9); +#define PROP_MATCH(STR) \ + (word_len == strlen (STR) \ + && memcmp (word_start, STR, strlen (STR)) == 0) +#define PROP_SAVE(VAR, STR) \ + (VAR = NILP (VAR) ? font_intern_prop (STR, strlen (STR), 1) : VAR) + + if (PROP_MATCH ("Ultra-Light")) + PROP_SAVE (weight, "ultra-light"); + else if (PROP_MATCH ("Light")) + PROP_SAVE (weight, "light"); + else if (PROP_MATCH ("Book")) + PROP_SAVE (weight, "book"); + else if (PROP_MATCH ("Medium")) + PROP_SAVE (weight, "medium"); + else if (PROP_MATCH ("Semi-Bold")) + PROP_SAVE (weight, "semi-bold"); + else if (PROP_MATCH ("Bold")) + PROP_SAVE (weight, "bold"); + else if (PROP_MATCH ("Italic")) + PROP_SAVE (slant, "italic"); + else if (PROP_MATCH ("Oblique")) + PROP_SAVE (slant, "oblique"); + else if (PROP_MATCH ("Semi-Condensed")) + PROP_SAVE (width, "semi-condensed"); + else if (PROP_MATCH ("Condensed")) + PROP_SAVE (width, "condensed"); /* An unknown word must be part of the font name. */ else { -- 2.39.2