Commit 442bfb89137086811de13b9eae9cd6390ad5c204

Werner Lemberg 2007-02-12T21:44:10

Formatting, copyright years, s/memcpy/ft_memcpy/.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
diff --git a/ChangeLog b/ChangeLog
index 9372ffb..d83aed1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,21 +1,32 @@
 2007-02-12  David Turner  <david@freetype.org>
 
-	* src/autofit/afloader.c: improve spacing adjustments for the
-	non-light auto-hinted modes. Gets rid of "inter-letter spacing
-	is too wide"
+	* src/truetype/ttinterp.h, src/truetype/ttinterp.c: Simplify
+	projection and dual-projection code interface.
 
-	* src/truetype/ttinterp.h, src/truetype/ttinterp.c: simplify
-	projection and dual-projection code interface
+	* src/autofit/afloader.c: Improve spacing adjustments for the
+	non-light auto-hinted modes.  Gets rid of `inter-letter spacing is
+	too wide' problems.
 
-	* include/freetype/internal/ftmemory.h, src/base/ftutils.c,
-	src/bfd/bfddrivr.c, src/bdf/bdflib.c, src/pcf/pcfread.c,
-	src/cff/cffdrivr.c, src/cff/cffload.c, src/cff/cffobjs.c,
-	src/sfnt/sfdriver.c, src/type1/t1driver.c, src/type42/t42drivr.c:
-	introduce ft_mem_strdup, ft_mem_dup, ft_mem_strcpyn and the
-	corresponding macros, and modify code to use them. This is to
-	get rid of various uses of strcpy and other "evil" functions,
-	as well as simplify a few things
 
+	Introduce new string functions and the corresponding macros to get
+	rid of various uses of strcpy and other `evil' functions, as well as
+	to simplify a few things.
+
+	* include/freetype/internal/ftmemory.h (ft_mem_strdup, ft_mem_dup,
+	ft_mem_strcpyn): New declarations.
+	(FT_MEM_STRDUP, FT_STRDUP, FT_MEM_DUP, FT_DUP, FT_STRCPYN): New
+	macros.
+	* src/base/ftutil.c (ft_mem_dup, ft_mem_strdup, ft_mem_strcpyn): New
+	functions.
+
+	* src/bfd/bfddrivr.c (bdf_interpret_style, BDF_Face_Init),
+	src/bdf/bdflib.c (_bdf_add_property), src/pcf/pcfread.c
+	(pcf_get_properties, pcf_interpret_style, pcf_load_font),
+	src/cff/cffdrivr.c (cff_get_glyph_name), src/cff/cffload.c
+	(cff_index_get_sid_string), src/cff/cffobjs.c (cff_strcpy),
+	src/sfnt/sfdriver.c (sfnt_get_glyph_name), src/type1/t1driver.c
+	(t1_get_glyph_name), src/type42/t42drivr.c (t42_get_glyph_name,
+	t42_get_name_index): Use new functions and simplify code.
 
 2007-02-11  Werner Lemberg  <wl@gnu.org>
 
@@ -85,7 +96,6 @@
 	(gxv_mort_subtable_type1_substTable_validate): Fix debugging
 	message.
 
->>>>>>> 1.1514
 2007-01-31  Werner Lemberg  <wl@gnu.org>
 
 
diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h
index f52c9d8..c6ddc42 100644
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -333,26 +333,29 @@ FT_BEGIN_HEADER
               FT_ULong     size,
               FT_Error    *p_error );
 
-#define  FT_MEM_STRDUP(dst,str)    \
-    (dst) = ft_mem_strdup( memory, (const char*)(str), &error )
+#define FT_MEM_STRDUP( dst, str )                                     \
+          (dst) = ft_mem_strdup( memory, (const char*)(str), &error )
 
-#define  FT_STRDUP(dst,str)   \
-    FT_MEM_SET_ERROR( FT_MEM_STRDUP(dst,str) )
+#define FT_STRDUP( dst, str )                           \
+          FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) )
 
-#define  FT_MEM_DUP(dst, address,size)   \
-    (dst) = ft_mem_dup( memory, (address), (FT_ULong)(size), &error )
+#define FT_MEM_DUP( dst, address, size )                                    \
+          (dst) = ft_mem_dup( memory, (address), (FT_ULong)(size), &error )
 
-#define  FT_DUP(dst,address,size)  \
-    FT_MEM_SET_ERROR( FT_MEM_DUP(dst,address,size) )
+#define FT_DUP( dst, address, size )                           \
+          FT_MEM_SET_ERROR( FT_MEM_DUP( dst, address, size ) )
 
-  /* returns 1 or more if a trunction occured, 0 if the source string fitted the buffer */
-  /* this is *not* the same than the normal strlcpy() call                              */
+
+  /* Return >= 1 if a truncation occurs.            */
+  /* Return 0 if the source string fits the buffer. */
+  /* This is *not* the same as strlcpy().           */
   FT_BASE( FT_Int )
   ft_mem_strcpyn( char*        dst,
                   const char*  src,
                   FT_ULong     size );
 
-#define  FT_STRCPYN(dst,src,size)   ft_mem_strcpyn( (char*)dst, (const char*)(src), (FT_ULong)(size) )
+#define FT_STRCPYN( dst, src, size )                                         \
+          ft_mem_strcpyn( (char*)dst, (const char*)(src), (FT_ULong)(size) )
 
  /* */
 
diff --git a/src/base/ftutil.c b/src/base/ftutil.c
index eb6f6b1..e14aea7 100644
--- a/src/base/ftutil.c
+++ b/src/base/ftutil.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType utility file for memory and list management (body).         */
 /*                                                                         */
-/*  Copyright 2002, 2004, 2005, 2006 by                                    */
+/*  Copyright 2002, 2004, 2005, 2006, 2007 by                              */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -181,7 +181,8 @@
     FT_Error    error;
     FT_Pointer  p = ft_mem_qalloc( memory, size, &error );
 
-    if (!error && address)
+
+    if ( !error && address )
       ft_memcpy( p, address, size );
 
     *p_error = error;
@@ -194,7 +195,9 @@
                  const char*  str,
                  FT_Error    *p_error )
   {
-    FT_ULong  len = str ? (FT_ULong)ft_strlen(str)+1 : 0;
+    FT_ULong  len = str ? (FT_ULong)ft_strlen( str ) + 1
+                        : 0;
+
 
     return ft_mem_dup( memory, str, len, p_error );
   }
@@ -210,7 +213,7 @@
 
     *dst = 0;  /* always zero-terminate */
 
-    return (*src != 0);
+    return *src != 0;
   }
 
 
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index beaa267..30580c5 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -2,7 +2,7 @@
 
     FreeType font driver for bdf files
 
-    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by
+    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 by
     Francesco Zappa Nardelli
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -198,6 +198,7 @@ THE SOFTWARE.
     char*  strings[4] = { NULL, NULL, NULL, NULL };
     int    lengths[4];
 
+
     face->style_flags = 0;
 
     prop = bdf_get_font_property( font, (char *)"SLANT" );
@@ -225,35 +226,31 @@ THE SOFTWARE.
     if ( prop && prop->format == BDF_ATOM                              &&
          prop->value.atom && *(prop->value.atom)                       &&
          !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
-    {
       strings[3] = (char *)(prop->value.atom);
-    }
 
     prop = bdf_get_font_property( font, (char *)"ADD_STYLE_NAME" );
     if ( prop && prop->format == BDF_ATOM                              &&
          prop->value.atom && *(prop->value.atom)                       &&
          !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
-    {
       strings[0] = (char *)(prop->value.atom);
-    }
 
-    len   = 0;
+    len = 0;
 
-    for (len = 0, nn = 0; nn < 4; nn++)
+    for ( len = 0, nn = 0; nn < 4; nn++ )
     {
       lengths[nn] = 0;
-      if (strings[nn]) 
+      if ( strings[nn] )
       {
-        lengths[nn] = ft_strlen(strings[nn]);
-        len        += lengths[nn]+1;
+        lengths[nn] = ft_strlen( strings[nn] );
+        len        += lengths[nn] + 1;
       }
     }
 
     if ( len == 0 )
     {
       strings[0] = "Regular";
-      lengths[0] = ft_strlen(strings[0]);
-      len        = lengths[0]+1;
+      lengths[0] = ft_strlen( strings[0] );
+      len        = lengths[0] + 1;
     }
 
     {
@@ -265,27 +262,30 @@ THE SOFTWARE.
 
       s = face->style_name;
 
-      for (nn = 0; nn < 4; nn++)
+      for ( nn = 0; nn < 4; nn++ )
       {
         char*  src = strings[nn];
         int    len = lengths[nn];
 
+
         if ( src == NULL )
           continue;
 
         /* separate elements with a space */
-        if (s != face->style_name)
+        if ( s != face->style_name )
           *s++ = ' ';
 
-        memcpy( s, src, len );
+        ft_memcpy( s, src, len );
 
-        /* need to convert spaces to dashes for add_style_name and setwidth_name */
-        if (nn == 0 || nn == 3) 
+        /* need to convert spaces to dashes for */
+        /* add_style_name and setwidth_name     */
+        if ( nn == 0 || nn == 3 )
         {
           int  mm;
 
-          for (mm = 0; mm < len; mm++)
-            if (s[mm] == ' ')
+
+          for ( mm = 0; mm < len; mm++ )
+            if ( s[mm] == ' ' )
               s[mm] = '-';
         }
 
@@ -495,12 +495,14 @@ THE SOFTWARE.
             const char*  s;
 
 
-            if ( FT_STRDUP( face->charset_encoding, charset_encoding->value.atom ) ||
-                 FT_STRDUP( face->charset_registry, charset_registry->value.atom ) )
+            if ( FT_STRDUP( face->charset_encoding,
+                            charset_encoding->value.atom ) ||
+                 FT_STRDUP( face->charset_registry,
+                            charset_registry->value.atom ) )
               goto Exit;
 
-            /* Uh, oh, compare first letters manually to avoid dependency
-               on locales. */
+            /* Uh, oh, compare first letters manually to avoid dependency */
+            /* on locales.                                                */
             s = face->charset_registry;
             if ( ( s[0] == 'i' || s[0] == 'I' ) &&
                  ( s[1] == 's' || s[1] == 'S' ) &&
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 7737e54..6c931ad 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -1,6 +1,7 @@
 /*
  * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001, 2002, 2003, 2004, 2005, 2006 Francesco Zappa Nardelli
+ * Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ *   Francesco Zappa Nardelli
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 6e6f839..c02cf33 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -287,7 +287,8 @@
     FT_Error    error;
     FT_String*  result;
 
-    result = ft_mem_strdup(memory, source, &error);
+
+    result = ft_mem_strdup( memory, source, &error );
 
     return result;
   }
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 1a2064f..2a142fc 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -1002,9 +1002,9 @@ THE SOFTWARE.
            *(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) )
     {
       face->style_flags |= FT_STYLE_FLAG_ITALIC;
-      strings[2] = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' )
-          ? (char *)"Oblique"
-        : (char *)"Italic";
+      strings[2] = ( *(prop->value.atom) == 'O' ||
+                     *(prop->value.atom) == 'o' ) ? (char *)"Oblique"
+                                                  : (char *)"Italic";
     }
 
     prop = pcf_find_property( pcf, "WEIGHT_NAME" );
@@ -1019,33 +1019,29 @@ THE SOFTWARE.
     if ( prop && prop->isString                                        &&
          *(prop->value.atom)                                           &&
          !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
-    {
       strings[3] = (char *)(prop->value.atom);
-    }
 
     prop = pcf_find_property( pcf, "ADD_STYLE_NAME" );
     if ( prop && prop->isString                                        &&
          *(prop->value.atom)                                           &&
          !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
-    {
       strings[0] = (char *)(prop->value.atom);
-    }
 
-    for (len = 0, nn = 0; nn < 4; nn++)
+    for ( len = 0, nn = 0; nn < 4; nn++ )
     {
       lengths[nn] = 0;
-      if (strings[nn]) 
+      if ( strings[nn] )
       {
-        lengths[nn] = ft_strlen(strings[nn]);
-        len        += lengths[nn]+1;
+        lengths[nn] = ft_strlen( strings[nn] );
+        len        += lengths[nn] + 1;
       }
     }
 
     if ( len == 0 )
     {
       strings[0] = "Regular";
-      lengths[0] = ft_strlen(strings[0]);
-      len        = lengths[0]+1;
+      lengths[0] = ft_strlen( strings[0] );
+      len        = lengths[0] + 1;
     }
 
     {
@@ -1057,26 +1053,29 @@ THE SOFTWARE.
 
       s = face->style_name;
 
-      for (nn = 0; nn < 4; nn++)
+      for ( nn = 0; nn < 4; nn++ )
       {
         char*  src = strings[nn];
         int    len = lengths[nn];
 
+
         if ( src == NULL )
           continue;
 
         /* separate elements with a space */
-        if (s != face->style_name)
+        if ( s != face->style_name )
           *s++ = ' ';
 
-        memcpy( s, src, len );
+        ft_memcpy( s, src, len );
 
-        /* need to convert spaces to dashes for add_style_name and setwidth_name */
-        if (nn == 0 || nn == 3) 
+        /* need to convert spaces to dashes for */
+        /* add_style_name and setwidth_name     */
+        if ( nn == 0 || nn == 3 )
         {
           int  mm;
 
-          for (mm = 0; mm < len; mm++)
+
+          for ( mm = 0; mm < len; mm++ )
             if (s[mm] == ' ')
               s[mm] = '-';
         }
@@ -1243,8 +1242,10 @@ THE SOFTWARE.
         if ( charset_registry && charset_registry->isString &&
              charset_encoding && charset_encoding->isString )
         {
-          if ( FT_STRDUP( face->charset_encoding, charset_encoding->value.atom ) ||
-               FT_STRDUP( face->charset_registry, charset_registry->value.atom ) )
+          if ( FT_STRDUP( face->charset_encoding,
+                          charset_encoding->value.atom ) ||
+               FT_STRDUP( face->charset_registry,
+                          charset_registry->value.atom ) )
             goto Exit;
         }
       }
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index 103e224..5ba22a6 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    High-level SFNT driver interface (body).                             */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by                   */
+/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by             */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index 56545da..3ca21dc 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Type 1 driver interface (body).                                      */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2006 by                         */
+/*  Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007 by                   */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -60,6 +60,7 @@
                      FT_UInt     buffer_max )
   {
     FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
+
     return T1_Err_Ok;
   }
 
diff --git a/src/type42/t42drivr.c b/src/type42/t42drivr.c
index 4bba8f7..a6e4cf4 100644
--- a/src/type42/t42drivr.c
+++ b/src/type42/t42drivr.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    High-level Type 42 driver interface (body).                          */
 /*                                                                         */
-/*  Copyright 2002, 2003, 2004, 2006 by Roberto Alameda.                   */
+/*  Copyright 2002, 2003, 2004, 2006, 2007 by Roberto Alameda.             */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
 /*  modified, and distributed under the terms of the FreeType project      */
@@ -62,6 +62,7 @@
                       FT_UInt     buffer_max )
   {
     FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
+
     return T42_Err_Ok;
   }