summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2023-06-24 23:23:54 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2023-06-24 23:23:54 +0000
commit3fed8e215415fdfc865acc39c39dbc4666b60e74 (patch)
tree7a05a1eafbe52abc3eea6b1d594ef5a797e5346a /Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c
parent26b39aa87a9ac83dab1e9b770125dc3defd9a405 (diff)
freetype 2.13.1
git-svn-id: svn://tug.org/texlive/trunk@67463 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c')
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c67
1 files changed, 34 insertions, 33 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c b/Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c
index 2224698fc00..0fa7e0a8c5f 100644
--- a/Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c
+++ b/Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c
@@ -51,6 +51,9 @@
#define FT_COMPONENT bdflib
+#define BUFSIZE 128
+
+
/**************************************************************************
*
* Default BDF font options.
@@ -378,7 +381,7 @@
*alen = 0;
if ( list == NULL || list->used == 0 )
- return 0;
+ return NULL;
dp = list->field[0];
for ( i = j = 0; i < list->used; i++ )
@@ -887,18 +890,18 @@
}
- FT_LOCAL_DEF( bdf_property_t* )
- bdf_get_property( char* name,
+ static bdf_property_t*
+ bdf_get_property( const char* name,
bdf_font_t* font )
{
size_t* propid;
if ( name == NULL || *name == 0 )
- return 0;
+ return NULL;
if ( ( propid = ft_hash_str_lookup( name, &(font->proptbl) ) ) == NULL )
- return 0;
+ return NULL;
if ( *propid >= num_bdf_properties_ )
return font->user_props + ( *propid - num_bdf_properties_ );
@@ -944,7 +947,7 @@
static FT_Error
bdf_add_comment_( bdf_font_t* font,
- char* comment,
+ const char* comment,
unsigned long len )
{
char* cp;
@@ -1053,27 +1056,24 @@
bdf_property_t* p;
- *name = sp = ep = line;
+ sp = ep = line;
while ( *ep && *ep != ' ' && *ep != '\t' )
ep++;
- hold = -1;
- if ( *ep )
- {
- hold = *ep;
- *ep = 0;
- }
+ hold = *ep;
+ *ep = '\0';
p = bdf_get_property( sp, font );
- /* Restore the character that was saved before any return can happen. */
- if ( hold != -1 )
- *ep = (char)hold;
-
/* If the property exists and is not an atom, just return here. */
if ( p && p->format != BDF_ATOM )
+ {
+ *ep = (char)hold; /* Undo NUL-termination. */
return 0;
+ }
+
+ *name = sp;
/* The property is an atom. Trim all leading and trailing whitespace */
/* and double quotes for the atom value. */
@@ -1081,25 +1081,26 @@
ep = line + linelen;
/* Trim the leading whitespace if it exists. */
- if ( *sp )
- *sp++ = 0;
- while ( *sp &&
- ( *sp == ' ' || *sp == '\t' ) )
- sp++;
+ if ( sp < ep )
+ do
+ sp++;
+ while ( *sp == ' ' || *sp == '\t' );
/* Trim the leading double quote if it exists. */
if ( *sp == '"' )
sp++;
+
*value = sp;
/* Trim the trailing whitespace if it exists. */
- while ( ep > sp &&
- ( *( ep - 1 ) == ' ' || *( ep - 1 ) == '\t' ) )
- *--ep = 0;
+ if ( sp < ep )
+ do
+ *ep-- = '\0';
+ while ( *ep == ' ' || *ep == '\t' );
/* Trim the trailing double quote if it exists. */
- if ( ep > sp && *( ep - 1 ) == '"' )
- *--ep = 0;
+ if ( *ep == '"' )
+ *ep = '\0';
return 1;
}
@@ -1775,7 +1776,7 @@
bdf_parse_t_* p;
char* name;
char* value;
- char nbuf[128];
+ char nbuf[BUFSIZE];
FT_Error error = FT_Err_Ok;
FT_UNUSED( lineno );
@@ -1796,7 +1797,7 @@
if ( bdf_get_font_property( p->font, "FONT_ASCENT" ) == 0 )
{
p->font->font_ascent = p->font->bbx.ascent;
- ft_sprintf( nbuf, "%hd", p->font->bbx.ascent );
+ ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.ascent );
error = bdf_add_property_( p->font, "FONT_ASCENT",
nbuf, lineno );
if ( error )
@@ -1808,7 +1809,7 @@
if ( bdf_get_font_property( p->font, "FONT_DESCENT" ) == 0 )
{
p->font->font_descent = p->font->bbx.descent;
- ft_sprintf( nbuf, "%hd", p->font->bbx.descent );
+ ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.descent );
error = bdf_add_property_( p->font, "FONT_DESCENT",
nbuf, lineno );
if ( error )
@@ -2116,7 +2117,7 @@
/* Check for the CHARS field -- font properties are optional */
if ( _bdf_strncmp( line, "CHARS", 5 ) == 0 )
{
- char nbuf[128];
+ char nbuf[BUFSIZE];
if ( !( p->flags & BDF_FONT_BBX_ ) )
@@ -2130,7 +2131,7 @@
/* Add the two standard X11 properties which are required */
/* for compiling fonts. */
p->font->font_ascent = p->font->bbx.ascent;
- ft_sprintf( nbuf, "%hd", p->font->bbx.ascent );
+ ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.ascent );
error = bdf_add_property_( p->font, "FONT_ASCENT",
nbuf, lineno );
if ( error )
@@ -2138,7 +2139,7 @@
FT_TRACE2(( "bdf_parse_properties_: " ACMSG1, p->font->bbx.ascent ));
p->font->font_descent = p->font->bbx.descent;
- ft_sprintf( nbuf, "%hd", p->font->bbx.descent );
+ ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.descent );
error = bdf_add_property_( p->font, "FONT_DESCENT",
nbuf, lineno );
if ( error )