|
|
43e195 |
commit 2c4832d30939b45c05757f0a05128ce64c4cacc7
|
|
|
43e195 |
Author: Werner Lemberg <wl@gnu.org>
|
|
|
43e195 |
Date: Fri Nov 7 07:42:33 2014 +0100
|
|
|
43e195 |
|
|
|
43e195 |
Fix Savannah bug #43535.
|
|
|
43e195 |
|
|
|
43e195 |
* src/bdf/bdflib.c (_bdf_strncmp): New macro that checks one
|
|
|
43e195 |
character more than `strncmp'.
|
|
|
43e195 |
s/ft_strncmp/_bdf_strncmp/ everywhere.
|
|
|
43e195 |
|
|
|
43e195 |
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
|
|
|
43e195 |
index 2eda11c..c128526 100644
|
|
|
43e195 |
--- a/src/bdf/bdflib.c
|
|
|
43e195 |
+++ b/src/bdf/bdflib.c
|
|
|
43e195 |
@@ -169,6 +169,18 @@
|
|
|
43e195 |
sizeof ( _bdf_properties[0] );
|
|
|
43e195 |
|
|
|
43e195 |
|
|
|
43e195 |
+ /* An auxiliary macro to parse properties, to be used in conditionals. */
|
|
|
43e195 |
+ /* It behaves like `strncmp' but also tests the following character */
|
|
|
43e195 |
+ /* whether it is a whitespace or NULL. */
|
|
|
43e195 |
+ /* `property' is a constant string of length `n' to compare with. */
|
|
|
43e195 |
+#define _bdf_strncmp( name, property, n ) \
|
|
|
43e195 |
+ ( ft_strncmp( name, property, n ) || \
|
|
|
43e195 |
+ !( name[n] == ' ' || \
|
|
|
43e195 |
+ name[n] == '\0' || \
|
|
|
43e195 |
+ name[n] == '\n' || \
|
|
|
43e195 |
+ name[n] == '\r' || \
|
|
|
43e195 |
+ name[n] == '\t' ) )
|
|
|
43e195 |
+
|
|
|
43e195 |
/* Auto correction messages. */
|
|
|
43e195 |
#define ACMSG1 "FONT_ASCENT property missing. " \
|
|
|
43e195 |
"Added `FONT_ASCENT %hd'.\n"
|
|
|
43e195 |
@@ -1402,7 +1414,7 @@
|
|
|
43e195 |
|
|
|
43e195 |
/* If the property happens to be a comment, then it doesn't need */
|
|
|
43e195 |
/* to be added to the internal hash table. */
|
|
|
43e195 |
- if ( ft_strncmp( name, "COMMENT", 7 ) != 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( name, "COMMENT", 7 ) != 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
/* Add the property to the font property table. */
|
|
|
43e195 |
error = hash_insert( fp->name,
|
|
|
43e195 |
@@ -1420,13 +1432,13 @@
|
|
|
43e195 |
/* FONT_ASCENT and FONT_DESCENT need to be assigned if they are */
|
|
|
43e195 |
/* present, and the SPACING property should override the default */
|
|
|
43e195 |
/* spacing. */
|
|
|
43e195 |
- if ( ft_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 )
|
|
|
43e195 |
font->default_char = fp->value.l;
|
|
|
43e195 |
- else if ( ft_strncmp( name, "FONT_ASCENT", 11 ) == 0 )
|
|
|
43e195 |
+ else if ( _bdf_strncmp( name, "FONT_ASCENT", 11 ) == 0 )
|
|
|
43e195 |
font->font_ascent = fp->value.l;
|
|
|
43e195 |
- else if ( ft_strncmp( name, "FONT_DESCENT", 12 ) == 0 )
|
|
|
43e195 |
+ else if ( _bdf_strncmp( name, "FONT_DESCENT", 12 ) == 0 )
|
|
|
43e195 |
font->font_descent = fp->value.l;
|
|
|
43e195 |
- else if ( ft_strncmp( name, "SPACING", 7 ) == 0 )
|
|
|
43e195 |
+ else if ( _bdf_strncmp( name, "SPACING", 7 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
if ( !fp->value.atom )
|
|
|
43e195 |
{
|
|
|
43e195 |
@@ -1484,7 +1496,7 @@
|
|
|
43e195 |
memory = font->memory;
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for a comment. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "COMMENT", 7 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
linelen -= 7;
|
|
|
43e195 |
|
|
|
43e195 |
@@ -1501,7 +1513,7 @@
|
|
|
43e195 |
/* The very first thing expected is the number of glyphs. */
|
|
|
43e195 |
if ( !( p->flags & _BDF_GLYPHS ) )
|
|
|
43e195 |
{
|
|
|
43e195 |
- if ( ft_strncmp( line, "CHARS", 5 ) != 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "CHARS", 5 ) != 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "CHARS" ));
|
|
|
43e195 |
error = BDF_Err_Missing_Chars_Field;
|
|
|
43e195 |
@@ -1535,7 +1547,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for the ENDFONT field. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "ENDFONT", 7 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "ENDFONT", 7 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
/* Sort the glyphs by encoding. */
|
|
|
43e195 |
ft_qsort( (char *)font->glyphs,
|
|
|
43e195 |
@@ -1549,7 +1561,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for the ENDCHAR field. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "ENDCHAR", 7 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "ENDCHAR", 7 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
p->glyph_enc = 0;
|
|
|
43e195 |
p->flags &= ~_BDF_GLYPH_BITS;
|
|
|
43e195 |
@@ -1565,7 +1577,7 @@
|
|
|
43e195 |
goto Exit;
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for the STARTCHAR field. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "STARTCHAR", 9 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "STARTCHAR", 9 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
/* Set the character name in the parse info first until the */
|
|
|
43e195 |
/* encoding can be checked for an unencoded character. */
|
|
|
43e195 |
@@ -1599,7 +1611,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for the ENCODING field. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "ENCODING", 8 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "ENCODING", 8 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
if ( !( p->flags & _BDF_GLYPH ) )
|
|
|
43e195 |
{
|
|
|
43e195 |
@@ -1785,7 +1797,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Expect the SWIDTH (scalable width) field next. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "SWIDTH", 6 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "SWIDTH", 6 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
if ( !( p->flags & _BDF_ENCODING ) )
|
|
|
43e195 |
goto Missing_Encoding;
|
|
|
43e195 |
@@ -1801,7 +1813,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Expect the DWIDTH (scalable width) field next. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "DWIDTH", 6 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "DWIDTH", 6 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
if ( !( p->flags & _BDF_ENCODING ) )
|
|
|
43e195 |
goto Missing_Encoding;
|
|
|
43e195 |
@@ -1829,7 +1841,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Expect the BBX field next. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "BBX", 3 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "BBX", 3 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
if ( !( p->flags & _BDF_ENCODING ) )
|
|
|
43e195 |
goto Missing_Encoding;
|
|
|
43e195 |
@@ -1897,7 +1909,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* And finally, gather up the bitmap. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "BITMAP", 6 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "BITMAP", 6 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
unsigned long bitmap_size;
|
|
|
43e195 |
|
|
|
43e195 |
@@ -1972,7 +1984,7 @@
|
|
|
43e195 |
p = (_bdf_parse_t *) client_data;
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for the end of the properties. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "ENDPROPERTIES", 13 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "ENDPROPERTIES", 13 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
/* If the FONT_ASCENT or FONT_DESCENT properties have not been */
|
|
|
43e195 |
/* encountered yet, then make sure they are added as properties and */
|
|
|
43e195 |
@@ -2013,12 +2025,12 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Ignore the _XFREE86_GLYPH_RANGES properties. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "_XFREE86_GLYPH_RANGES", 21 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "_XFREE86_GLYPH_RANGES", 21 ) == 0 )
|
|
|
43e195 |
goto Exit;
|
|
|
43e195 |
|
|
|
43e195 |
/* Handle COMMENT fields and properties in a special way to preserve */
|
|
|
43e195 |
/* the spacing. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "COMMENT", 7 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
name = value = line;
|
|
|
43e195 |
value += 7;
|
|
|
43e195 |
@@ -2082,7 +2094,7 @@
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for a comment. This is done to handle those fonts that have */
|
|
|
43e195 |
/* comments before the STARTFONT line for some reason. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "COMMENT", 7 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
if ( p->opts->keep_comments != 0 && p->font != 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
@@ -2108,7 +2120,7 @@
|
|
|
43e195 |
{
|
|
|
43e195 |
memory = p->memory;
|
|
|
43e195 |
|
|
|
43e195 |
- if ( ft_strncmp( line, "STARTFONT", 9 ) != 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "STARTFONT", 9 ) != 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
/* we don't emit an error message since this code gets */
|
|
|
43e195 |
/* explicitly caught one level higher */
|
|
|
43e195 |
@@ -2156,7 +2168,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for the start of the properties. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "STARTPROPERTIES", 15 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "STARTPROPERTIES", 15 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
if ( !( p->flags & _BDF_FONT_BBX ) )
|
|
|
43e195 |
{
|
|
|
43e195 |
@@ -2185,7 +2197,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for the FONTBOUNDINGBOX field. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "FONTBOUNDINGBOX", 15 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "FONTBOUNDINGBOX", 15 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
if ( !( p->flags & _BDF_SIZE ) )
|
|
|
43e195 |
{
|
|
|
43e195 |
@@ -2216,7 +2228,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* The next thing to check for is the FONT field. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "FONT", 4 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "FONT", 4 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
|
|
|
43e195 |
if ( error )
|
|
|
43e195 |
@@ -2251,7 +2263,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for the SIZE field. */
|
|
|
43e195 |
- if ( ft_strncmp( line, "SIZE", 4 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "SIZE", 4 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
if ( !( p->flags & _BDF_FONT_NAME ) )
|
|
|
43e195 |
{
|
|
|
43e195 |
@@ -2305,7 +2317,7 @@
|
|
|
43e195 |
}
|
|
|
43e195 |
|
|
|
43e195 |
/* Check for the CHARS field -- font properties are optional */
|
|
|
43e195 |
- if ( ft_strncmp( line, "CHARS", 5 ) == 0 )
|
|
|
43e195 |
+ if ( _bdf_strncmp( line, "CHARS", 5 ) == 0 )
|
|
|
43e195 |
{
|
|
|
43e195 |
char nbuf[128];
|
|
|
43e195 |
|