Commit 91e52d416aedfdfcf5b4331c2156a3866898738e

Werner Lemberg 2000-06-02T14:30:38

Finishing first formatting/documenting etc. of the `base' dir. Some modules are still badly documented, though...

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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index e3f2ef3..beaa845 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -126,13 +126,6 @@
   /*    All callers of FT_Realloc() _must_ provide the current block size  */
   /*    as well as the new one.                                            */
   /*                                                                       */
-  /*    If the memory object's flag FT_SYSTEM_FLAG_NO_REALLOC is set, this */
-  /*    function will try to emulate a reallocation using FT_Alloc() and   */
-  /*    FT_Free().  Otherwise, it will call the system-specific `realloc'  */
-  /*    implementation.                                                    */
-  /*                                                                       */
-  /*    (Some embedded systems do not have a working realloc function).    */
-  /*                                                                       */
   BASE_FUNC( FT_Error )  FT_Realloc( FT_Memory  memory,
                                      FT_Long    current,
                                      FT_Long    size,
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index 6c3cc6d..e8d5b06 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftstream.c                                                             */
+/*                                                                         */
+/*    I/O stream support (body).                                           */
+/*                                                                         */
+/*  Copyright 2000 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used        */
+/*  modified and distributed under the terms of the FreeType project       */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include <freetype/internal/ftstream.h>
 #include <freetype/internal/ftdebug.h>
 
@@ -5,10 +23,10 @@
 #define FT_COMPONENT  trace_stream
 
 
-  BASE_FUNC(void)  FT_New_Memory_Stream( FT_Library     library,
-                                         void*          base,
-                                         unsigned long  size,
-                                         FT_Stream      stream )
+  BASE_FUNC( void )  FT_New_Memory_Stream( FT_Library     library,
+                                           void*          base,
+                                           unsigned long  size,
+                                           FT_Stream      stream )
   {
     stream->memory = library->memory;
     stream->base   = (char*)base;
@@ -20,34 +38,35 @@
   }
 
 
-  BASE_FUNC(FT_Error)  FT_Seek_Stream( FT_Stream  stream,
-                                       FT_ULong   pos )
+  BASE_FUNC( FT_Error )  FT_Seek_Stream( FT_Stream  stream,
+                                         FT_ULong   pos )
   {
     FT_Error  error;
 
+
     stream->pos = pos;
 
-    if (stream->read)
+    if ( stream->read )
     {
-      if (stream->read( stream, pos, 0, 0 ))
+      if ( stream->read( stream, pos, 0, 0 ) )
       {
-        error = FT_Err_Invalid_Stream_Operation;
-
         FT_ERROR(( "FT_Seek_Stream:" ));
-        FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx\n",
+        FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
                    pos, stream->size ));
+
+        error = FT_Err_Invalid_Stream_Operation;
       }
       else
         error = FT_Err_Ok;
     }
     /* note that seeking to the first position after the file is valid */
-    else if (pos > stream->size)
+    else if ( pos > stream->size )
     {
-      error = FT_Err_Invalid_Stream_Operation;
-
       FT_ERROR(( "FT_Seek_Stream:" ));
-      FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx\n",
+      FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
                  pos, stream->size ));
+
+      error = FT_Err_Invalid_Stream_Operation;
     }
 
     else
@@ -57,51 +76,51 @@
   }
 
 
-  BASE_FUNC(FT_Error)  FT_Skip_Stream( FT_Stream  stream,
-                                       FT_Long    distance )
+  BASE_FUNC( FT_Error )  FT_Skip_Stream( FT_Stream  stream,
+                                         FT_Long    distance )
   {
-    return FT_Seek_Stream( stream, (FT_ULong)(stream->pos + distance) );
+    return FT_Seek_Stream( stream, (FT_ULong)( stream->pos + distance ) );
   }
 
 
-
-  BASE_FUNC(FT_Long)   FT_Stream_Pos( FT_Stream  stream )
+  BASE_FUNC( FT_Long )  FT_Stream_Pos( FT_Stream  stream )
   {
     return stream->pos;
   }
 
 
-  BASE_FUNC(FT_Error)  FT_Read_Stream( FT_Stream  stream,
-                                       void*      buffer,
-                                       FT_ULong   count )
+  BASE_FUNC( FT_Error )  FT_Read_Stream( FT_Stream  stream,
+                                         void*      buffer,
+                                         FT_ULong   count )
   {
     return FT_Read_Stream_At( stream, stream->pos, buffer, count );
   }
 
 
-  BASE_FUNC(FT_Error)  FT_Read_Stream_At( FT_Stream  stream,
-                                          FT_ULong   pos,
-                                          void*      buffer,
-                                          FT_ULong   count )
+  BASE_FUNC( FT_Error )  FT_Read_Stream_At( FT_Stream  stream,
+                                            FT_ULong   pos,
+                                            void*      buffer,
+                                            FT_ULong   count )
   {
     FT_Error  error = FT_Err_Ok;
     FT_ULong  read_bytes;
 
-    if (pos >= stream->size)
+
+    if ( pos >= stream->size )
     {
       FT_ERROR(( "FT_Read_Stream_At:" ));
-      FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx\n",
+      FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
                  pos, stream->size ));
 
       return FT_Err_Invalid_Stream_Operation;
     }
 
-    if (stream->read)
+    if ( stream->read )
       read_bytes = stream->read( stream, pos, buffer, count );
     else
     {
       read_bytes = stream->size - pos;
-      if (read_bytes > count)
+      if ( read_bytes > count )
         read_bytes = count;
 
       MEM_Copy( buffer, stream->base + pos, read_bytes );
@@ -109,11 +128,12 @@
 
     stream->pos = pos + read_bytes;
 
-    if (read_bytes < count)
+    if ( read_bytes < count )
     {
       FT_ERROR(( "FT_Read_Stream_At:" ));
-      FT_ERROR(( " invalid read, expected %lu bytes, got %lu",
+      FT_ERROR(( " invalid read; expected %lu bytes, got %lu",
                  count, read_bytes ));
+
       error = FT_Err_Invalid_Stream_Operation;
     }
 
@@ -121,62 +141,67 @@
   }
 
 
-  BASE_FUNC(FT_Error)  FT_Extract_Frame( FT_Stream  stream,
-                                         FT_ULong   count,
-                                         FT_Byte*  *pbytes )
+  BASE_FUNC( FT_Error )  FT_Extract_Frame( FT_Stream  stream,
+                                           FT_ULong   count,
+                                           FT_Byte**  pbytes )
   {
     FT_Error  error;
+
     
     error = FT_Access_Frame( stream, count );
-    if (!error)
+    if ( !error )
     {
       *pbytes = (FT_Byte*)stream->cursor;
         
-      /* equivalent to FT_Forget_Frame, with no memory block release */
+      /* equivalent to FT_Forget_Frame(), with no memory block release */
       stream->cursor = 0;
       stream->limit  = 0;
     }
+
     return error;
   }                                         
 
 
-  BASE_FUNC(void)    FT_Release_Frame( FT_Stream  stream,
-                                       FT_Byte*  *pbytes )
+  BASE_FUNC( void )  FT_Release_Frame( FT_Stream  stream,
+                                       FT_Byte**  pbytes )
   {
-    if (stream->read)
+    if ( stream->read )
     {
       FT_Memory  memory = stream->memory;
+
+
       FREE( *pbytes );
     }
     *pbytes = 0;
   }
 
 
-
-  BASE_FUNC(FT_Error)  FT_Access_Frame( FT_Stream  stream,
-                                        FT_ULong   count )
+  BASE_FUNC( FT_Error )  FT_Access_Frame( FT_Stream  stream,
+                                          FT_ULong   count )
   {
     FT_Error  error = FT_Err_Ok;
     FT_ULong  read_bytes;
 
+
     /* check for nested frame access */
     FT_Assert( stream && stream->cursor == 0 );
 
-    if (stream->read)
+    if ( stream->read )
     {
       /* allocate the frame in memory */
       FT_Memory  memory = stream->memory;
 
+
       if ( ALLOC( stream->base, count ) )
         goto Exit;
 
       /* read it */
       read_bytes = stream->read( stream, stream->pos,
                                  stream->base, count );
-      if (read_bytes < count)
+      if ( read_bytes < count )
       {
         FT_ERROR(( "FT_Access_Frame:" ));
-        FT_ERROR(( " invalid read, expected %lu bytes, got %lu",
+        FT_ERROR(( " invalid read; expected %lu bytes, got %lu",
                    count, read_bytes ));
 
         FREE( stream->base );
@@ -189,10 +214,11 @@
     else
     {
       /* check current and new position */
-      if (stream->pos >= stream->size || stream->pos + count > stream->size)
+      if ( stream->pos >= stream->size        ||
+           stream->pos + count > stream->size )
       {
         FT_ERROR(( "FT_Access_Frame:" ));
-        FT_ERROR(( " invalid i/o, pos = 0x%lx, count = %lu, size = 0x%lx",
+        FT_ERROR(( " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx",
                    stream->pos, count, stream->size ));
 
         error = FT_Err_Invalid_Stream_Operation;
@@ -204,27 +230,30 @@
       stream->limit  = stream->cursor + count;
       stream->pos   += count;
     }
+
   Exit:
     return error;
   }
 
 
-  BASE_FUNC(void)  FT_Forget_Frame( FT_Stream  stream )
+  BASE_FUNC( void )  FT_Forget_Frame( FT_Stream  stream )
   {
     /* IMPORTANT: The assertion stream->cursor != 0 was removed, given    */
     /*            that it is possible to access a frame of length 0 in    */
     /*            some weird fonts (usually, when accessing an array of   */
-    /*            0 records, like in some strange kern tables)..          */
+    /*            0 records, like in some strange kern tables).           */
     /*                                                                    */
     /*  In this case, the loader code handles the 0-length table          */
-    /*  gracefully, however, stream.cursor is really set to 0 by the      */
-    /*  FT_Access_Frame call, and this is not an error..                  */
+    /*  gracefully; however, stream.cursor is really set to 0 by the      */
+    /*  FT_Access_Frame() call, and this is not an error.                 */
     /*                                                                    */
     FT_Assert( stream );
 
-    if (stream->read)
+    if ( stream->read )
     {
       FT_Memory  memory = stream->memory;
+
+
       FREE( stream->base );
     }
     stream->cursor = 0;
@@ -232,117 +261,126 @@
   }
 
 
-  BASE_FUNC(FT_Char)  FT_Get_Char( FT_Stream  stream )
+  BASE_FUNC( FT_Char )  FT_Get_Char( FT_Stream  stream )
   {
     FT_Char  result;
 
+
     FT_Assert( stream && stream->cursor );
 
     result = 0;
-    if (stream->cursor < stream->limit)
+    if ( stream->cursor < stream->limit )
       result = *stream->cursor++;
 
     return result;
   }
 
 
-  BASE_FUNC(FT_Short)  FT_Get_Short( FT_Stream  stream )
+  BASE_FUNC( FT_Short )  FT_Get_Short( FT_Stream  stream )
   {
     char*     p;
     FT_Short  result;
 
+
     FT_Assert( stream && stream->cursor );
 
     result         = 0;
     p              = stream->cursor;
-    if (p+1 < stream->limit)
-      result       = NEXT_Short(p);
+    if ( p + 1 < stream->limit )
+      result       = NEXT_Short( p );
     stream->cursor = p;
+
     return result;
   }
 
 
-  BASE_FUNC(FT_Long)  FT_Get_Offset( FT_Stream  stream )
+  BASE_FUNC( FT_Long )  FT_Get_Offset( FT_Stream  stream )
   {
     char*    p;
     FT_Long  result;
 
+
     FT_Assert( stream && stream->cursor );
 
     result         = 0;
     p              = stream->cursor;
-    if (p+2 < stream->limit)
-      result       = NEXT_Offset(p);
+    if ( p + 2 < stream->limit )
+      result       = NEXT_Offset( p );
     stream->cursor = p;
     return result;
   }
 
 
-  BASE_FUNC(FT_Long)  FT_Get_Long( FT_Stream  stream )
+  BASE_FUNC( FT_Long )  FT_Get_Long( FT_Stream  stream )
   {
     char*    p;
     FT_Long  result;
 
+
     FT_Assert( stream && stream->cursor );
 
     result         = 0;
     p              = stream->cursor;
-    if (p+3 < stream->limit)
-      result       = NEXT_Long(p);
+    if ( p + 3 < stream->limit )
+      result       = NEXT_Long( p );
     stream->cursor = p;
     return result;
   }
 
 
-  BASE_FUNC(FT_Char)  FT_Read_Char( FT_Stream  stream,
-                                    FT_Error*  error )
+  BASE_FUNC( FT_Char )  FT_Read_Char( FT_Stream  stream,
+                                      FT_Error*  error )
   {
     char  result = 0;
 
+
     FT_Assert( stream );
 
     *error = FT_Err_Ok;
 
-    if (stream->read)
+    if ( stream->read )
     {
       if ( stream->read( stream, stream->pos, &result, 1L ) != 1L )
         goto Fail;
     }
     else
     {
-      if (stream->pos < stream->size)
+      if ( stream->pos < stream->size )
         result = stream->base[stream->pos];
       else
         goto Fail;
     }
     stream->pos++;
+
     return result;
 
   Fail:
     *error = FT_Err_Invalid_Stream_Operation;
     FT_ERROR(( "FT_Read_Char:" ));
-    FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx",
+    FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx",
                stream->pos, stream->size ));
+
     return 0;
   }
 
 
-  BASE_FUNC(FT_Short)  FT_Read_Short( FT_Stream  stream,
-                                      FT_Error*  error )
+  BASE_FUNC( FT_Short )  FT_Read_Short( FT_Stream  stream,
+                                        FT_Error*  error )
   {
     char     reads[2];
     char*    p = 0;
     FT_Short result = 0;
 
+
     FT_Assert( stream );
 
     *error = FT_Err_Ok;
 
-    if (stream->pos+1 < stream->size)
+    if ( stream->pos + 1 < stream->size )
     {
-      if (stream->read)
+      if ( stream->read )
       {
-        if (stream->read( stream, stream->pos, reads, 2L ) != 2L )
+        if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
           goto Fail;
 
         p = reads;
@@ -352,37 +390,41 @@
         p = stream->base + stream->pos;
       }
 
-      if (p)
-        result = NEXT_Short(p);
+      if ( p )
+        result = NEXT_Short( p );
     }
-    else goto Fail;
+    else
+      goto Fail;
 
     stream->pos += 2;
+
     return result;
 
   Fail:
     *error = FT_Err_Invalid_Stream_Operation;
     FT_ERROR(( "FT_Read_Short:" ));
-    FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx",
+    FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx",
                stream->pos, stream->size ));
+
     return 0;
   }
 
 
-  BASE_FUNC(FT_Long)  FT_Read_Offset( FT_Stream  stream,
-                                      FT_Error*  error )
+  BASE_FUNC( FT_Long )  FT_Read_Offset( FT_Stream  stream,
+                                        FT_Error*  error )
   {
     char     reads[3];
     char*    p = 0;
     FT_Long  result = 0;
 
+
     FT_Assert( stream );
 
     *error = FT_Err_Ok;
 
-    if (stream->pos+2 < stream->size)
+    if ( stream->pos + 2 < stream->size )
     {
-      if (stream->read)
+      if ( stream->read )
       {
         if (stream->read( stream, stream->pos, reads, 3L ) != 3L )
           goto Fail;
@@ -394,39 +436,43 @@
         p = stream->base + stream->pos;
       }
 
-      if (p)
-        result = NEXT_Offset(p);
+      if ( p )
+        result = NEXT_Offset( p );
     }
-    else goto Fail;
+    else
+      goto Fail;
 
     stream->pos += 3;
+
     return result;
 
   Fail:
     *error = FT_Err_Invalid_Stream_Operation;
     FT_ERROR(( "FT_Read_Offset:" ));
-    FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx",
+    FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx",
                stream->pos, stream->size ));
+
     return 0;
   }
 
 
-  BASE_FUNC(FT_Long)  FT_Read_Long( FT_Stream  stream,
-                                    FT_Error*  error )
+  BASE_FUNC( FT_Long )  FT_Read_Long( FT_Stream  stream,
+                                      FT_Error*  error )
   {
     char     reads[4];
     char*    p = 0;
     FT_Long  result = 0;
 
+
     FT_Assert( stream );
 
     *error = FT_Err_Ok;
 
-    if (stream->pos+3 < stream->size)
+    if ( stream->pos + 3 < stream->size )
     {
-      if (stream->read)
+      if ( stream->read )
       {
-        if (stream->read( stream, stream->pos, reads, 4L ) != 4L )
+        if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
           goto Fail;
 
         p = reads;
@@ -436,30 +482,35 @@
         p = stream->base + stream->pos;
       }
 
-      if (p)
-        result = NEXT_Long(p);
+      if ( p )
+        result = NEXT_Long( p );
     }
-    else goto Fail;
+    else
+      goto Fail;
 
     stream->pos += 4;
+
     return result;
 
   Fail:
-    *error = FT_Err_Invalid_Stream_Operation;
     FT_ERROR(( "FT_Read_Long:" ));
-    FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx",
+    FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx",
                stream->pos, stream->size ));
+    *error = FT_Err_Invalid_Stream_Operation;
+
     return 0;
   }
 
-  BASE_FUNC(FT_Error) FT_Read_Fields( FT_Stream              stream,
-                                      const FT_Frame_Field*  fields,
-                                      void*                  structure )
+
+  BASE_FUNC( FT_Error ) FT_Read_Fields( FT_Stream              stream,
+                                        const FT_Frame_Field*  fields,
+                                        void*                  structure )
   {
     FT_Error  error;
     FT_Bool   frame_accessed = 0;
 
-    if (!fields || !stream)
+
+    if ( !fields || !stream )
       return FT_Err_Invalid_Argument;
 
     error = FT_Err_Ok;
@@ -469,131 +520,149 @@
       FT_Int    sign_shift;
       FT_Byte*  p;
 
-      switch (fields->value)
-      {
-        case ft_frame_start:  /* access a new frame */
-          {
-            error = FT_Access_Frame( stream, fields->offset );
-            if (error) goto Exit;
 
-            frame_accessed = 1;
-            fields++;
-            continue;  /* loop ! */
-          }
-
-        case ft_frame_byte:
-        case ft_frame_schar:  /* read a single byte */
-          {
-            value = GET_Byte();
-            sign_shift = 24;
-            break;
-          }
-
-        case ft_frame_short_be:
-        case ft_frame_ushort_be:  /* read a 2-byte big-endian short */
-          {
-            value = GET_UShort();
-            sign_shift = 16;
-            break;
-          }
-
-        case ft_frame_short_le:
-        case ft_frame_ushort_le:  /* read a 2-byte little-endian short */
-          {
-            char* p;
-            value = 0;
-            p     = stream->cursor;
-            if (p+1 < stream->limit)
-            {
-              value = (FT_UShort)p[0] | ((FT_UShort)p[1] << 8);
-              stream->cursor += 2;
-            }
-            sign_shift = 16;
-            break;
-          }
-
-        case ft_frame_long_be:
-        case ft_frame_ulong_be:  /* read a 4-byte big-endian long */
-          {
-            value = GET_ULong();
-            sign_shift = 0;
-            break;
-          }
-
-        case ft_frame_long_le:
-        case ft_frame_ulong_le:  /* read a 4-byte little-endian long */
+      switch ( fields->value )
+      {
+      case ft_frame_start:  /* access a new frame */
+        {
+          error = FT_Access_Frame( stream, fields->offset );
+          if ( error )
+            goto Exit;
+
+          frame_accessed = 1;
+          fields++;
+          continue;  /* loop! */
+        }
+
+      case ft_frame_byte:
+      case ft_frame_schar:  /* read a single byte */
+        {
+          value = GET_Byte();
+          sign_shift = 24;
+          break;
+        }
+
+      case ft_frame_short_be:
+      case ft_frame_ushort_be:  /* read a 2-byte big-endian short */
+        {
+          value = GET_UShort();
+          sign_shift = 16;
+          break;
+        }
+
+      case ft_frame_short_le:
+      case ft_frame_ushort_le:  /* read a 2-byte little-endian short */
+        {
+          char* p;
+          value = 0;
+          p     = stream->cursor;
+          if ( p + 1 < stream->limit )
           {
-            char* p;
-            value = 0;
-            p     = stream->cursor;
-            if (p+3 < stream->limit)
-            {
-              value = (FT_ULong)p[0]        |
-                     ((FT_ULong)p[1] << 8)  |
-                     ((FT_ULong)p[2] << 16) |
-                     ((FT_ULong)p[3] << 24);
-              stream->cursor += 4;
-            }
-            sign_shift = 0;
-            break;
+            value = ( FT_UShort)p[0] | ((FT_UShort)p[1] << 8 );
+            stream->cursor += 2;
           }
-
-        case ft_frame_off3_be:
-        case ft_frame_uoff3_be:  /* read a 3-byte big-endian long */
+          sign_shift = 16;
+          break;
+        }
+
+      case ft_frame_long_be:
+      case ft_frame_ulong_be:  /* read a 4-byte big-endian long */
+        {
+          value = GET_ULong();
+          sign_shift = 0;
+          break;
+        }
+
+      case ft_frame_long_le:
+      case ft_frame_ulong_le:  /* read a 4-byte little-endian long */
+        {
+          char* p;
+
+
+          value = 0;
+          p     = stream->cursor;
+          if ( p + 3 < stream->limit )
           {
-            value = GET_UOffset();
-            sign_shift = 8;
-            break;
+            value =  (FT_ULong)p[0]         |
+                   ( (FT_ULong)p[1] << 8  ) |
+                   ( (FT_ULong)p[2] << 16 ) |
+                   ( (FT_ULong)p[3] << 24 );
+            stream->cursor += 4;
           }
-
-        case ft_frame_off3_le:
-        case ft_frame_uoff3_le:  /* read a 3-byte little-endian long */
+          sign_shift = 0;
+          break;
+        }
+
+      case ft_frame_off3_be:
+      case ft_frame_uoff3_be:  /* read a 3-byte big-endian long */
+        {
+          value = GET_UOffset();
+          sign_shift = 8;
+          break;
+        }
+
+      case ft_frame_off3_le:
+      case ft_frame_uoff3_le:  /* read a 3-byte little-endian long */
+        {
+          char* p;
+
+
+          value = 0;
+          p     = stream->cursor;
+          if ( p + 3 < stream->limit )
           {
-            char* p;
-            value = 0;
-            p     = stream->cursor;
-            if (p+3 < stream->limit)
-            {
-              value = (FT_ULong)p[0]        |
-                     ((FT_ULong)p[1] << 8)  |
-                     ((FT_ULong)p[2] << 16) |
-                     ((FT_ULong)p[3] << 24);
-              stream->cursor += 4;
-            }
-            sign_shift = 8;
-            break;
+            value =  (FT_ULong)p[0]         |
+                   ( (FT_ULong)p[1] << 8  ) |
+                   ( (FT_ULong)p[2] << 16 ) |
+                   ( (FT_ULong)p[3] << 24 );
+            stream->cursor += 4;
           }
+          sign_shift = 8;
+          break;
+        }
 
-        default:
-          /* otherwise, exit the loop */
-          goto Exit;
+      default:
+        /* otherwise, exit the loop */
+        goto Exit;
       }
 
       /* now, compute the signed value is necessary */
-      if (fields->value & FT_FRAME_OP_SIGNED)
-        value   = (FT_ULong)((FT_Long)(value << sign_shift) >> sign_shift);
+      if ( fields->value & FT_FRAME_OP_SIGNED )
+        value = (FT_ULong)( (FT_Long)( value << sign_shift ) >> sign_shift );
 
       /* finally, store the value in the object */
 
       p = (FT_Byte*)structure + fields->offset;
-      switch (fields->size)
+      switch ( fields->size )
       {
-        case 1: *(FT_Byte*)p   = (FT_Byte)  value; break;
-        case 2: *(FT_UShort*)p = (FT_UShort)value; break;
-        case 4: *(FT_ULong*)p  = (FT_ULong) value; break;
-        default:  ; /* ignore !! */
+      case 1:
+        *(FT_Byte*)p = (FT_Byte)value;
+        break;
+
+      case 2:
+        *(FT_UShort*)p = (FT_UShort)value;
+        break;
+
+      case 4:
+         *(FT_ULong*)p = (FT_ULong)value;
+         break;
+
+      default:
+         ;          /* ignore! */
       }
 
       /* go to next field */
       fields++;
     }
-    while (1);
+    while ( 1 );
 
   Exit:
     /* close the frame if it was opened by this read */
-    if (frame_accessed)
-      FT_Forget_Frame(stream);
+    if ( frame_accessed )
+      FT_Forget_Frame( stream );
 
     return error;
   }
 
+
+/* END */
diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c
index 25d5265..bf02b11 100644
--- a/src/base/ftsystem.c
+++ b/src/base/ftsystem.c
@@ -1,163 +1,183 @@
-/**************************************************************************
- *
- *  ftsystem.h                                                        1.0
- *
- *    ANSI-specific FreeType low-level system interface
- *
- *    This file contains the definition of interface used by FreeType
- *    to access low-level, i.e. memory management, i/o access as well
- *    as thread synchronisation.
- *
- *
- *  Copyright 1996-1999 by
- *  David Turner, Robert Wilhelm, and Werner Lemberg
- *
- *  This file is part of the FreeType project, and may only be used
- *  modified and distributed under the terms of the FreeType project
- *  license, LICENSE.TXT.  By continuing to use, modify, or distribute
- *  this file you indicate that you have read the license and
- *  understand and accept it fully.
- *
- **************************************************************************/
+/***************************************************************************/
+/*                                                                         */
+/*  ftsystem.h                                                             */
+/*                                                                         */
+/*    ANSI-specific FreeType low-level system interface (body).            */
+/*                                                                         */
+/*  Copyright 1996-2000 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used        */
+/*  modified and distributed under the terms of the FreeType project       */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file contains the default interface used by FreeType to access   */
+  /* low-level, i.e. memory management, i/o access as well as thread       */
+  /* synchronisation.  It can be replaced by user-specific routines if     */
+  /* necessary.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
 
 #include <freetype/config/ftconfig.h>
 #include <freetype/ftsystem.h>
 #include <freetype/fterrors.h>
+#include <freetype/fttypes.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-  /*********************************************************************/
-  /*                                                                   */
-  /*                       MEMORY MANAGEMENT INTERFACE                 */
-  /*                                                                   */
-
-/************************************************************************
- *
- * <FuncType>
- *    FT_Alloc_Func
- *
- * <Description>
- *    The memory allocator function type
- *
- * <Input>
- *    system    :: pointer to the system object
- *    size      :: requested size in bytes
- *
- * <Output>
- *    block     :: address of newly allocated block
- *
- * <Return>
- *    Error code. 0 means success.
- *
- * <Note>
- *    If your allocation routine ALWAYS zeroes the new block, you
- *    should set the flag FT_SYSTEM_FLAG_ALLOC_ZEROES in your system
- *    object 'flags' field.
- *
- *    If you have set the flag FT_SYSTEM_FLAG_REPORT_CURRENT_ALLOC in
- *    your system's "system_flags" field, this function should update
- *    the "current_alloc" field of the system object.
- *
- ************************************************************************/
 
+  /*************************************************************************/
+  /*                                                                       */
+  /*                       MEMORY MANAGEMENT INTERFACE                     */
+  /*                                                                       */
+  /*************************************************************************/
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* It is not necessary to do any error checking here.  This will be done */
+  /* by the higher level routines like FT_Alloc() or FT_Realloc().         */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    ft_alloc                                                           */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    The memory allocation function.                                    */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    memory :: A pointer to the memory object.                          */
+  /*    size   :: The requested size in bytes.                             */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    block  :: The address of newly allocated block.                    */
+  /*                                                                       */
   static
   void*  ft_alloc( FT_Memory  memory,
                    long       size )
   {
-    UNUSED(memory);
-    return malloc(size);
-  }
+    UNUSED( memory );
 
+    return malloc( size );
+  }
 
-/************************************************************************
- *
- * <FuncType>
- *    FT_Realloc_Func
- *
- * <Description>
- *    The memory reallocator function type
- *
- * <Input>
- *    system   :: pointer to the system object
- *    new_size :: new requested size in bytes
- *
- * <InOut>
- *    block    :: address of block in memory
- *
- * <Return>
- *    Error code. 0 means success.
- *
- * <Note>
- *    This function is _never_ called when the system flag
- *    FT_SYSTEM_FLAG_NO_REALLOC is set. Instead, the engine will emulate
- *    realloc through "alloc" and "free".
- *
- *    Note that this is possible due to the fact that FreeType's
- *    "FT_Realloc" always requests the _current_ size of the reallocated
- *    block as a parameter, thus avoiding memory leaks.
- *
- *    If you have set the flag FT_SYSTEM_FLAG_REPORT_CURRENT_ALLOC in
- *    your system's "system_flags" field, this function should update
- *    the "current_alloc" field of the system object.
- *
- ************************************************************************/
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    ft_realloc                                                         */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    The memory reallocation function.                                  */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    memory   :: A pointer to the memory object.                        */
+  /*                                                                       */
+  /*    cur_size :: The current size of the allocated memory block.        */
+  /*                                                                       */
+  /*    new_size :: The newly requested size in bytes.                     */
+  /*                                                                       */
+  /*    block    :: The current address of the block in memory.            */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    The address of the reallocated memory block.                       */
+  /*                                                                       */
   static
   void*  ft_realloc( FT_Memory  memory,
                      long       cur_size,
                      long       new_size,
                      void*      block )
   {
-    UNUSED(memory);
-    UNUSED(cur_size);
+    UNUSED( memory );
+    UNUSED( cur_size );
 
     return realloc( block, new_size );
   }
 
 
-/************************************************************************
- *
- * <FuncType>
- *    FT_Free_Func
- *
- * <Description>
- *    The memory release function type
- *
- * <Input>
- *    system  :: pointer to the system object
- *    block   :: address of block in memory
- *
- * <Note>
- *    If you have set the flag FT_SYSTEM_FLAG_REPORT_CURRENT_ALLOC in
- *    your system's "system_flags" field, this function should update
- *    the "current_alloc" field of the system object.
- *
- ************************************************************************/
-
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    ft_free                                                            */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    The memory release function.                                       */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    memory  :: A pointer to the memory object.                         */
+  /*                                                                       */
+  /*    block   :: The address of block in memory to be freed.             */
+  /*                                                                       */
   static
   void  ft_free( FT_Memory  memory,
                  void*      block )
   {
-    UNUSED(memory);
+    UNUSED( memory );
+
     free( block );
   }
 
-  /*********************************************************************/
-  /*                                                                   */
-  /*                     RESOURCE MANAGEMENT INTERFACE                 */
-  /*                                                                   */
 
+  /*************************************************************************/
+  /*                                                                       */
+  /*                     RESOURCE MANAGEMENT INTERFACE                     */
+  /*                                                                       */
+  /*************************************************************************/
 
-#define STREAM_FILE(stream)  ((FILE*)stream->descriptor.pointer)
 
+#define STREAM_FILE( stream )  ( (FILE*)stream->descriptor.pointer )
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    ft_close_stream                                                    */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    The function to close a stream.                                    */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    stream :: A pointer to the stream object.                          */
+  /*                                                                       */
   static
   void  ft_close_stream( FT_Stream  stream )
   {
-    fclose( STREAM_FILE(stream) );
+    fclose( STREAM_FILE( stream ) );
   }
 
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    ft_io_stream                                                       */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    The function to open a stream.                                     */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    stream :: A pointer to the stream object.                          */
+  /*                                                                       */
+  /*    offset :: The position in the data stream to start reading.        */
+  /*                                                                       */
+  /*    buffer :: The address of buffer to store the read data.            */
+  /*                                                                       */
+  /*    count  :: The number of bytes to read from the stream.             */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    The number of bytes actually read.                                 */
+  /*                                                                       */
   static
   unsigned long  ft_io_stream( FT_Stream      stream,
                                unsigned long  offset,
@@ -166,24 +186,44 @@
   {
     FILE*  file;
 
-    file = STREAM_FILE(stream);
+
+    file = STREAM_FILE( stream );
 
     fseek( file, offset, SEEK_SET );
+
     return (unsigned long)fread( buffer, 1, count, file );
   }
 
 
-  FT_EXPORT_FUNC(int)  FT_New_Stream( const char*  filepathname,
-                                      FT_Stream    stream )
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_New_Stream                                                      */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Creates a new stream object.                                       */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    filepathname :: The name of the stream (usually a file) to be      */
+  /*                    opened.                                            */
+  /*                                                                       */
+  /*    stream       :: A pointer to the stream object.                    */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  FT_EXPORT_FUNC( FT_Error )  FT_New_Stream( const char*  filepathname,
+                                             FT_Stream    stream )
   {
     FILE*  file;
 
+
     file = fopen( filepathname, "rb" );
-    if (!file)
+    if ( !file )
       return FT_Err_Cannot_Open_Resource;
 
     fseek( file, 0, SEEK_END );
-    stream->size = ftell(file);
+    stream->size = ftell( file );
     fseek( file, 0, SEEK_SET );
 
     stream->descriptor.pointer = file;
@@ -192,22 +232,37 @@
     stream->read  = ft_io_stream;
     stream->close = ft_close_stream;
 
-    return 0;
+    return FT_Err_Ok;
   }
 
 
-  FT_EXPORT_FUNC(FT_Memory)  FT_New_Memory( void )
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_New_Memory                                                      */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Creates a new memory object.                                       */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    A pointer to the new memory object.  0 in case of error.           */
+  /*                                                                       */
+  FT_EXPORT_FUNC( FT_Memory )  FT_New_Memory( void )
   {
     FT_Memory  memory;
 
-    memory = (FT_Memory)malloc( sizeof(*memory) );
-    if (memory)
+
+    memory = (FT_Memory)malloc( sizeof ( *memory ) );
+    if ( memory )
     {
       memory->user    = 0;
       memory->alloc   = ft_alloc;
       memory->realloc = ft_realloc;
       memory->free    = ft_free;
     }
+
     return memory;
   }
 
+
+/* END */
diff --git a/src/base/rules.mk b/src/base/rules.mk
index 367f34b..e2617ac 100644
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -17,7 +17,7 @@
 # after the call:
 #
 #    BASE_H:       The list of base layer header files on which the rest
-#                  of the library (i.e., drivers) rely.
+#                  of the library (i.e. drivers) rely.
 #
 #    BASE_OBJ_S:   The single-object base layer.
 #    BASE_OBJ_M:   A list of all objects for a multiple-objects build.
@@ -36,7 +36,6 @@ BASE_SRC := $(BASE_)ftcalc.c    \
             $(BASE_)ftstream.c  \
             $(BASE_)ftoutln.c
 
-
 # Base layer headers
 #
 BASE_H := $(INTERNAL_)ftcalc.h    \
@@ -63,6 +62,10 @@ BASE_EXT_SRC := $(BASE_)ftraster.c \
 #
 BASE_EXT_H := $(BASE_EXT_SRC:%c=%h)
 
+# Default extensions objects
+#
+BASE_EXT_OBJ := $(BASE_EXT_SRC:$(BASE_)%.c=$(OBJ_)%.$O)
+
 
 # Base layer object(s)
 #
@@ -75,12 +78,6 @@ BASE_EXT_H := $(BASE_EXT_SRC:%c=%h)
 BASE_OBJ_M := $(BASE_SRC:$(BASE_)%.c=$(OBJ_)%.$O)
 BASE_OBJ_S := $(OBJ_)ftbase.$O
 
-
-# Default extensions objects
-#
-BASE_EXT_OBJ := $(BASE_EXT_SRC:$(BASE_)%.c=$(OBJ_)%.$O)
-
-
 # Base layer root source file(s)
 #
 BASE_SRC_M := $(BASE_SRC)