freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] 2 commits: docs/DEBUG: Formatting.


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] 2 commits: docs/DEBUG: Formatting.
Date: Tue, 23 May 2023 11:19:03 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • 66cc4619
    by Werner Lemberg at 2023-05-23T12:54:48+02:00
    docs/DEBUG: Formatting.
    
  • 80a507a6
    by Werner Lemberg at 2023-05-23T13:18:01+02:00
    Replace `sprintf` with `snprintf`.
    
    Fixes #1233.
    
    * include/freetype/config/ftstdlib.h (ft_sprintf): Replace with...
    (ft_snprintf): This new macro.
    
    * src/autofit/afhints.c (af_print_idx): Add argument to pass the buffer
    size.
    (af_glyph_hints_dump_points, af_glyph_hints_dump_segments,
    af_glyph_hints_dump_edges): Updated.
    
    * src/bdf/bdflib.c (BUFSIZE): New macro.
    (bdf_parse_properties_, bdf_parse_start_): Use `ft_snprintf`.
    
    * src/tools/ftrandom/ftrandom.c (do_test): Use `snprintf`.
    

5 changed files:

Changes:

  • docs/DEBUG
    ... ... @@ -270,12 +270,12 @@ to access them.
    270 270
         `FT2_DEBUG' environment  variable.  Use this function  to override
    
    271 271
         the value with `level'.  Use value `NULL' to disable tracing.
    
    272 272
     
    
    273
    -  FT_Trace_Set_Default_Level():
    
    273
    +  FT_Trace_Set_Default_Level( void )
    
    274 274
     
    
    275 275
         Reset the tracing levels to the default value, i.e., the value of
    
    276 276
         the `FT2_DEBUG' environment variable or no tracing if not set.
    
    277 277
     
    
    278
    -  FT_Set_Log_Handler( ft_custom_log_handler  handler ):
    
    278
    +  FT_Set_Log_Handler( ft_custom_log_handler  handler )
    
    279 279
     
    
    280 280
         Use `handler' as a custom handler for formatting tracing and error
    
    281 281
         messages.  The  `ft_custom_log_handler' typedef has  the following
    
    ... ... @@ -290,7 +290,7 @@ to access them.
    290 290
        first argument  of `FT_TRACE' or  `FT_ERROR', and `args'  holds the
    
    291 291
        remaining arguments.
    
    292 292
     
    
    293
    -  FT_Set_Default_Log_Handler():
    
    293
    +  FT_Set_Default_Log_Handler( void )
    
    294 294
     
    
    295 295
         Reset the log handler to the default version.
    
    296 296
     
    

  • include/freetype/config/ftstdlib.h
    ... ... @@ -111,13 +111,13 @@
    111 111
     
    
    112 112
     #include <stdio.h>
    
    113 113
     
    
    114
    -#define FT_FILE     FILE
    
    115
    -#define ft_fclose   fclose
    
    116
    -#define ft_fopen    fopen
    
    117
    -#define ft_fread    fread
    
    118
    -#define ft_fseek    fseek
    
    119
    -#define ft_ftell    ftell
    
    120
    -#define ft_sprintf  sprintf
    
    114
    +#define FT_FILE      FILE
    
    115
    +#define ft_fclose    fclose
    
    116
    +#define ft_fopen     fopen
    
    117
    +#define ft_fread     fread
    
    118
    +#define ft_fseek     fseek
    
    119
    +#define ft_ftell     ftell
    
    120
    +#define ft_snprintf  snprintf
    
    121 121
     
    
    122 122
     
    
    123 123
       /**************************************************************************
    

  • src/autofit/afhints.c
    ... ... @@ -320,8 +320,9 @@
    320 320
     
    
    321 321
     
    
    322 322
       static char*
    
    323
    -  af_print_idx( char* p,
    
    324
    -                int   idx )
    
    323
    +  af_print_idx( char*   p,
    
    324
    +                size_t  n,
    
    325
    +                int     idx )
    
    325 326
       {
    
    326 327
         if ( idx == -1 )
    
    327 328
         {
    
    ... ... @@ -330,7 +331,7 @@
    330 331
           p[2] = '\0';
    
    331 332
         }
    
    332 333
         else
    
    333
    -      ft_sprintf( p, "%d", idx );
    
    334
    +      ft_snprintf( p, n, "%d", idx );
    
    334 335
     
    
    335 336
         return p;
    
    336 337
       }
    
    ... ... @@ -457,12 +458,12 @@
    457 458
                     " %5d %5d %7.2f %7.2f %7.2f %7.2f"
    
    458 459
                     " %5s %5s %5s %5s\n",
    
    459 460
                     point_idx,
    
    460
    -                af_print_idx( buf1,
    
    461
    +                af_print_idx( buf1, 16,
    
    461 462
                                   af_get_edge_index( hints, segment_idx_1, 1 ) ),
    
    462
    -                af_print_idx( buf2, segment_idx_1 ),
    
    463
    -                af_print_idx( buf3,
    
    463
    +                af_print_idx( buf2, 16, segment_idx_1 ),
    
    464
    +                af_print_idx( buf3, 16,
    
    464 465
                                   af_get_edge_index( hints, segment_idx_0, 0 ) ),
    
    465
    -                af_print_idx( buf4, segment_idx_0 ),
    
    466
    +                af_print_idx( buf4, 16, segment_idx_0 ),
    
    466 467
                     ( point->flags & AF_FLAG_NEAR )
    
    467 468
                       ? " near "
    
    468 469
                       : ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
    
    ... ... @@ -476,18 +477,22 @@
    476 477
                     (double)point->x / 64,
    
    477 478
                     (double)point->y / 64,
    
    478 479
     
    
    479
    -                af_print_idx( buf5, af_get_strong_edge_index( hints,
    
    480
    -                                                              point->before,
    
    481
    -                                                              1 ) ),
    
    482
    -                af_print_idx( buf6, af_get_strong_edge_index( hints,
    
    483
    -                                                              point->after,
    
    484
    -                                                              1 ) ),
    
    485
    -                af_print_idx( buf7, af_get_strong_edge_index( hints,
    
    486
    -                                                              point->before,
    
    487
    -                                                              0 ) ),
    
    488
    -                af_print_idx( buf8, af_get_strong_edge_index( hints,
    
    489
    -                                                              point->after,
    
    490
    -                                                              0 ) ) ));
    
    480
    +                af_print_idx( buf5, 16,
    
    481
    +                              af_get_strong_edge_index( hints,
    
    482
    +                                                        point->before,
    
    483
    +                                                        1 ) ),
    
    484
    +                af_print_idx( buf6, 16,
    
    485
    +                              af_get_strong_edge_index( hints,
    
    486
    +                                                        point->after,
    
    487
    +                                                        1 ) ),
    
    488
    +                af_print_idx( buf7, 16,
    
    489
    +                              af_get_strong_edge_index( hints,
    
    490
    +                                                        point->before,
    
    491
    +                                                        0 ) ),
    
    492
    +                af_print_idx( buf8, 16,
    
    493
    +                              af_get_strong_edge_index( hints,
    
    494
    +                                                        point->after,
    
    495
    +                                                        0 ) ) ));
    
    491 496
         }
    
    492 497
         AF_DUMP(( "\n" ));
    
    493 498
       }
    
    ... ... @@ -574,9 +579,12 @@
    574 579
                       AF_INDEX_NUM( seg->first, points ),
    
    575 580
                       AF_INDEX_NUM( seg->last, points ),
    
    576 581
     
    
    577
    -                  af_print_idx( buf1, AF_INDEX_NUM( seg->link, segments ) ),
    
    578
    -                  af_print_idx( buf2, AF_INDEX_NUM( seg->serif, segments ) ),
    
    579
    -                  af_print_idx( buf3, AF_INDEX_NUM( seg->edge, edges ) ),
    
    582
    +                  af_print_idx( buf1, 16,
    
    583
    +                                AF_INDEX_NUM( seg->link, segments ) ),
    
    584
    +                  af_print_idx( buf2, 16,
    
    585
    +                                AF_INDEX_NUM( seg->serif, segments ) ),
    
    586
    +                  af_print_idx( buf3, 16,
    
    587
    +                                AF_INDEX_NUM( seg->edge, edges ) ),
    
    580 588
     
    
    581 589
                       seg->height,
    
    582 590
                       seg->height - ( seg->max_coord - seg->min_coord ),
    
    ... ... @@ -716,8 +724,10 @@
    716 724
                       AF_INDEX_NUM( edge, edges ),
    
    717 725
                       (double)(int)edge->opos / 64,
    
    718 726
                       af_dir_str( (AF_Direction)edge->dir ),
    
    719
    -                  af_print_idx( buf1, AF_INDEX_NUM( edge->link, edges ) ),
    
    720
    -                  af_print_idx( buf2, AF_INDEX_NUM( edge->serif, edges ) ),
    
    727
    +                  af_print_idx( buf1, 16,
    
    728
    +                                AF_INDEX_NUM( edge->link, edges ) ),
    
    729
    +                  af_print_idx( buf2, 16,
    
    730
    +                                AF_INDEX_NUM( edge->serif, edges ) ),
    
    721 731
     
    
    722 732
                       edge->blue_edge ? 'y' : 'n',
    
    723 733
                       (double)edge->opos / 64,
    

  • src/bdf/bdflib.c
    ... ... @@ -51,6 +51,9 @@
    51 51
     #define FT_COMPONENT  bdflib
    
    52 52
     
    
    53 53
     
    
    54
    +#define BUFSIZE  128
    
    55
    +
    
    56
    +
    
    54 57
       /**************************************************************************
    
    55 58
        *
    
    56 59
        * Default BDF font options.
    
    ... ... @@ -1773,7 +1776,7 @@
    1773 1776
         bdf_parse_t_*      p;
    
    1774 1777
         char*              name;
    
    1775 1778
         char*              value;
    
    1776
    -    char               nbuf[128];
    
    1779
    +    char               nbuf[BUFSIZE];
    
    1777 1780
         FT_Error           error = FT_Err_Ok;
    
    1778 1781
     
    
    1779 1782
         FT_UNUSED( lineno );
    
    ... ... @@ -1794,7 +1797,7 @@
    1794 1797
           if ( bdf_get_font_property( p->font, "FONT_ASCENT" ) == 0 )
    
    1795 1798
           {
    
    1796 1799
             p->font->font_ascent = p->font->bbx.ascent;
    
    1797
    -        ft_sprintf( nbuf, "%hd", p->font->bbx.ascent );
    
    1800
    +        ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.ascent );
    
    1798 1801
             error = bdf_add_property_( p->font, "FONT_ASCENT",
    
    1799 1802
                                        nbuf, lineno );
    
    1800 1803
             if ( error )
    
    ... ... @@ -1806,7 +1809,7 @@
    1806 1809
           if ( bdf_get_font_property( p->font, "FONT_DESCENT" ) == 0 )
    
    1807 1810
           {
    
    1808 1811
             p->font->font_descent = p->font->bbx.descent;
    
    1809
    -        ft_sprintf( nbuf, "%hd", p->font->bbx.descent );
    
    1812
    +        ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.descent );
    
    1810 1813
             error = bdf_add_property_( p->font, "FONT_DESCENT",
    
    1811 1814
                                        nbuf, lineno );
    
    1812 1815
             if ( error )
    
    ... ... @@ -2114,7 +2117,7 @@
    2114 2117
         /* Check for the CHARS field -- font properties are optional */
    
    2115 2118
         if ( _bdf_strncmp( line, "CHARS", 5 ) == 0 )
    
    2116 2119
         {
    
    2117
    -      char  nbuf[128];
    
    2120
    +      char  nbuf[BUFSIZE];
    
    2118 2121
     
    
    2119 2122
     
    
    2120 2123
           if ( !( p->flags & BDF_FONT_BBX_ ) )
    
    ... ... @@ -2128,7 +2131,7 @@
    2128 2131
           /* Add the two standard X11 properties which are required */
    
    2129 2132
           /* for compiling fonts.                                   */
    
    2130 2133
           p->font->font_ascent = p->font->bbx.ascent;
    
    2131
    -      ft_sprintf( nbuf, "%hd", p->font->bbx.ascent );
    
    2134
    +      ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.ascent );
    
    2132 2135
           error = bdf_add_property_( p->font, "FONT_ASCENT",
    
    2133 2136
                                      nbuf, lineno );
    
    2134 2137
           if ( error )
    
    ... ... @@ -2136,7 +2139,7 @@
    2136 2139
           FT_TRACE2(( "bdf_parse_properties_: " ACMSG1, p->font->bbx.ascent ));
    
    2137 2140
     
    
    2138 2141
           p->font->font_descent = p->font->bbx.descent;
    
    2139
    -      ft_sprintf( nbuf, "%hd", p->font->bbx.descent );
    
    2142
    +      ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.descent );
    
    2140 2143
           error = bdf_add_property_( p->font, "FONT_DESCENT",
    
    2141 2144
                                      nbuf, lineno );
    
    2142 2145
           if ( error )
    

  • src/tools/ftrandom/ftrandom.c
    ... ... @@ -520,7 +520,7 @@
    520 520
         char        buffer[1024];
    
    521 521
     
    
    522 522
     
    
    523
    -    sprintf( buffer, "%s/test%d", results_dir, test_num++ );
    
    523
    +    snprintf( buffer, 1024, "%s/test%d", results_dir, test_num++ );
    
    524 524
     
    
    525 525
         if ( copyfont ( &fontlist[i], buffer ) )
    
    526 526
         {
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]