Commit 9b71edb0deb16b68a7944f95f7ef9c9c599e8f02

Werner Lemberg 2005-08-31T16:29:51

* src/gxvalid/gxvbsln.c: Fix compiler warnings. * src/gxvalid/gxvcommn.c: Fix compiler warnings. (gxv_XEntryTable_validate, gxv_compare_ranges): Remove unused parameter. Update all callers. Improve tracing messages. Some formatting.

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
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
diff --git a/ChangeLog b/ChangeLog
index 54ef5eb..d9d565d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
 2005-08-30  Werner Lemberg  <wl@gnu.org>
 
 	* src/gxvalid/README: Revised.
+	* src/gxvalid/gxvbsln.c: Fix compiler warnings.
+	* src/gxvalid/gxvcommn.c: Fix compiler warnings.
+	(gxv_XEntryTable_validate, gxv_compare_ranges): Remove unused
+	parameter.  Update all callers.
+	Improve tracing messages.
+	Some formatting.
 
 2005-08-29  Werner Lemberg  <wl@gnu.org>
 
diff --git a/src/gxvalid/Jamfile b/src/gxvalid/Jamfile
index aab71d2..88049a6 100644
--- a/src/gxvalid/Jamfile
+++ b/src/gxvalid/Jamfile
@@ -1,14 +1,26 @@
-# FreeType 2 src/gxvalid Jamfile (c) 2005 suzuki toshiya, Masatake YAMATO and Red Hat K.K.
+# FreeType 2 src/gxvalid Jamfile
 #
+# Copyright 2005 by
+# suzuki toshiya, Masatake YAMATO and Red Hat K.K.
+#
+# 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.
 
 SubDir  FT2_TOP $(FT2_SRC_DIR) gxvalid ;
 
+
 {
   local  _sources ;
 
   if $(FT2_MULTI)
   {
-    _sources = gxvcommn gxvfeat gxvbsln gxvtrak gxvopbd gxvprop gxvjust gxvmort gxvmort0 gxvmort1 gxvmort2 gxvmort4 gxvmort5 gxvmorx gxvmorx0 gxvmorx1 gxvmorx2 gxvmorx4 gxvmorx5 gxvlcar gxvkern gxvmod ;
+    _sources = gxvcommn gxvfeat  gxvbsln  gxvtrak  gxvopbd  gxvprop
+               gxvmort  gxvmort0 gxvmort1 gxvmort2 gxvmort4 gxvmort5
+               gxvmorx  gxvmorx0 gxvmorx1 gxvmorx2 gxvmorx4 gxvmorx5
+               gxvlcar  gxvkern  gxvmod   gxvjust  ;
   }
   else
   {
diff --git a/src/gxvalid/gxvalid.h b/src/gxvalid/gxvalid.h
index d05259c..27be9ec 100644
--- a/src/gxvalid/gxvalid.h
+++ b/src/gxvalid/gxvalid.h
@@ -16,9 +16,11 @@
 /***************************************************************************/
 
 /***************************************************************************/
+/*                                                                         */
 /* gxvalid is derived from both gxlayout module and otvalid module.        */
-/* Development of gxlayout was support of Information-technology Promotion */
-/* Agency(IPA), Japan.                                                     */
+/* Development of gxlayout is supported by the Information-technology      */
+/* Promotion Agency(IPA), Japan.                                           */
+/*                                                                         */
 /***************************************************************************/
 
 
@@ -75,11 +77,10 @@ FT_BEGIN_HEADER
                      FT_Validator  valid );
 
   FT_LOCAL( void )
-  gxv_kern_validate_classic
-                   ( FT_Bytes      table,
-                     FT_Face       face,
-                     FT_Int        dialect_flags,
-                     FT_Validator  valid );
+  gxv_kern_validate_classic( FT_Bytes      table,
+                             FT_Face       face,
+                             FT_Int        dialect_flags,
+                             FT_Validator  valid );
 
   FT_LOCAL( void )
   gxv_opbd_validate( FT_Bytes      table,
diff --git a/src/gxvalid/gxvbsln.c b/src/gxvalid/gxvbsln.c
index 678fedc..ab29c7f 100644
--- a/src/gxvalid/gxvbsln.c
+++ b/src/gxvalid/gxvbsln.c
@@ -16,9 +16,11 @@
 /***************************************************************************/
 
 /***************************************************************************/
+/*                                                                         */
 /* gxvalid is derived from both gxlayout module and otvalid module.        */
-/* Development of gxlayout was support of Information-technology Promotion */
-/* Agency(IPA), Japan.                                                     */
+/* Development of gxlayout is supported by the Information-technology      */
+/* Promotion Agency(IPA), Japan.                                           */
+/*                                                                         */
 /***************************************************************************/
 
 
@@ -26,7 +28,6 @@
 #include "gxvcommn.h"
 
 
-
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -45,8 +46,9 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define GXV_BSLN_VALUE_COUNT 32
-#define GXV_BSLN_VALUE_EMPTY 0xFFFF
+#define GXV_BSLN_VALUE_COUNT  32
+#define GXV_BSLN_VALUE_EMPTY  0xFFFF
+
 
   typedef struct  GXV_bsln_DataRec_
   {
@@ -54,7 +56,8 @@
     FT_UShort  defaultBaseline;
 
   } GXV_bsln_DataRec, *GXV_bsln_Data;
-#define GXV_BSLN_DATA(field)  GXV_TABLE_DATA( bsln, field )
+
+#define GXV_BSLN_DATA( field )  GXV_TABLE_DATA( bsln, field )
 
 
   /*************************************************************************/
@@ -70,16 +73,17 @@
                                  GXV_LookupValueDesc  value,
                                  GXV_Validator        valid )
   {
-    FT_UShort   v  = value.u;
+    FT_UShort   v = value.u;
     FT_UShort*  ctlPoints;
 
+    FT_UNUSED( glyph );
+
 
     GXV_NAME_ENTER( " lookup value" );
 
     if ( v >= GXV_BSLN_VALUE_COUNT )
       FT_INVALID_DATA;
 
-
     ctlPoints = (FT_UShort*)GXV_BSLN_DATA( ctlPoints_p );
     if ( ctlPoints && ctlPoints[v] == GXV_BSLN_VALUE_EMPTY )
       FT_INVALID_DATA;
@@ -126,6 +130,7 @@
     FT_UShort            offset;
     GXV_LookupValueDesc  value;
 
+
     offset = base_value.u + ( relative_gindex * sizeof ( FT_UShort ) );
 
     p     = valid->lookuptbl_head + offset;
@@ -137,6 +142,7 @@
     return value;
   }
 
+
   static void
   gxv_bsln_parts_fmt0_validate( FT_Bytes       tables,
                                 FT_Bytes       limit,
@@ -163,6 +169,7 @@
   {
     FT_Bytes  p = tables;
 
+
     GXV_NAME_ENTER( " parts format 1" );
 
     /* deltas */
@@ -185,13 +192,13 @@
                                 FT_Bytes       limit,
                                 GXV_Validator  valid )
   {
-    FT_Bytes      p = tables;
+    FT_Bytes   p = tables;
 
-    FT_UShort     stdGlyph;
-    FT_UShort     ctlPoint;
-    FT_Int        i;
+    FT_UShort  stdGlyph;
+    FT_UShort  ctlPoint;
+    FT_Int     i;
 
-    FT_UShort     defaultBaseline = GXV_BSLN_DATA( defaultBaseline );
+    FT_UShort  defaultBaseline = GXV_BSLN_DATA( defaultBaseline );
 
 
     GXV_NAME_ENTER( "parts format 2" );
@@ -205,7 +212,7 @@
     gxv_glyphid_validate( stdGlyph, valid );
 
     /* Record the position of ctlPoints */
-    GXV_BSLN_DATA( ctlPoints_p) = p;
+    GXV_BSLN_DATA( ctlPoints_p ) = p;
 
     /* ctlPoints */
     for ( i = 0; i < GXV_BSLN_VALUE_COUNT; i++ )
@@ -217,9 +224,7 @@
           FT_INVALID_DATA;
       }
       else
-      {
         gxv_ctlPoint_validate( stdGlyph, (FT_Short)ctlPoint, valid );
-      }
     }
 
     GXV_EXIT;
@@ -264,13 +269,13 @@
                      FT_Face       face,
                      FT_Validator  ftvalid )
   {
-    GXV_ValidatorRec   validrec;
-    GXV_Validator      valid = &validrec;
+    GXV_ValidatorRec  validrec;
+    GXV_Validator     valid = &validrec;
 
-    GXV_bsln_DataRec   bslnrec;
-    GXV_bsln_Data      bsln = &bslnrec;
+    GXV_bsln_DataRec  bslnrec;
+    GXV_bsln_Data     bsln = &bslnrec;
 
-    FT_Bytes  p = table;
+    FT_Bytes  p     = table;
     FT_Bytes  limit = 0;
 
     FT_ULong   version;
@@ -299,11 +304,11 @@
     format          = FT_NEXT_USHORT( p );
     defaultBaseline = FT_NEXT_USHORT( p );
 
-    /* version 1.0 is only defined (1996) */
+    /* only version 1.0 is defined (1996) */
     if ( version != 0x00010000UL )
       FT_INVALID_FORMAT;
 
-    /* format 1, 2, 3 are only defined (1996) */
+    /* only format 1, 2, 3 are defined (1996) */
     GXV_TRACE(( " (format = %d)\n", format ));
     if ( format > 3 )
       FT_INVALID_FORMAT;
@@ -311,7 +316,6 @@
     if ( defaultBaseline > 31 )
       FT_INVALID_FORMAT;
 
-
     bsln->defaultBaseline = defaultBaseline;
 
     fmt_funcs_table[format]( p, limit, valid );
@@ -319,6 +323,7 @@
     FT_TRACE4(( "\n" ));
   }
 
+
 /* arch-tag: ebe81143-fdaa-4c68-a4d1-b57227daa3bc
    (do not change this comment) */
 
diff --git a/src/gxvalid/gxvcommn.c b/src/gxvalid/gxvcommn.c
index 69978cd..0747603 100644
--- a/src/gxvalid/gxvcommn.c
+++ b/src/gxvalid/gxvcommn.c
@@ -16,9 +16,11 @@
 /***************************************************************************/
 
 /***************************************************************************/
+/*                                                                         */
 /* gxvalid is derived from both gxlayout module and otvalid module.        */
-/* Development of gxlayout was support of Information-technology Promotion */
-/* Agency(IPA), Japan.                                                     */
+/* Development of gxlayout is supported by the Information-technology      */
+/* Promotion Agency(IPA), Japan.                                           */
+/*                                                                         */
 /***************************************************************************/
 
 
@@ -64,7 +66,7 @@
                                    FT_UShort      limit,
                                    GXV_Validator  valid)
   {
-    FT_UInt    i;
+    FT_UInt  i;
 
 
     for ( i = 0; i < nmemb; i++ )
@@ -74,7 +76,7 @@
       buff[i] = offset[i];
     buff[nmemb] = limit;
 
-    ft_qsort( buff, ( nmemb + 1 ), sizeof(FT_UShort),
+    ft_qsort( buff, ( nmemb + 1 ), sizeof ( FT_UShort ),
               ( int(*)(const void*, const void*) )gxv_compare_ushort_offset );
 
     if ( buff[nmemb] > limit )
@@ -82,14 +84,14 @@
 
     for ( i = 0; i < nmemb; i++ )
     {
-      FT_UInt j;
+      FT_UInt  j;
 
 
       for ( j = 0; j < nmemb; j++ )
         if ( buff[j] == offset[i] )
           break;
 
-      if (j == nmemb)
+      if ( j == nmemb )
         FT_INVALID_OFFSET;
 
       *(length[i]) = buff[j + 1] - buff[j];
@@ -129,7 +131,7 @@
                                   FT_ULong       limit,
                                   GXV_Validator  valid)
   {
-    FT_UInt    i;
+    FT_UInt  i;
 
 
     for ( i = 0; i < nmemb; i++ )
@@ -139,7 +141,7 @@
       buff[i] = offset[i];
     buff[nmemb] = limit;
 
-    ft_qsort( buff, ( nmemb + 1 ), sizeof(FT_ULong),
+    ft_qsort( buff, ( nmemb + 1 ), sizeof ( FT_ULong ),
               ( int(*)(const void*, const void*) )gxv_compare_ulong_offset );
 
     if ( buff[nmemb] > limit )
@@ -147,14 +149,14 @@
 
     for ( i = 0; i < nmemb; i++ )
     {
-      FT_UInt j;
+      FT_UInt  j;
 
 
       for ( j = 0; j < nmemb; j++ )
         if ( buff[j] == offset[i] )
           break;
 
-      if (j == nmemb)
+      if ( j == nmemb )
         FT_INVALID_OFFSET;
 
       *(length[i]) = buff[j + 1] - buff[j];
@@ -191,6 +193,7 @@
     {
       FT_Byte  val;
 
+
       GXV_LIMIT_CHECK( 1 );
       val = FT_NEXT_BYTE( p );
 
@@ -198,7 +201,7 @@
       *max = FT_MAX( *max, val );
     }
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
   }
 
 
@@ -212,13 +215,14 @@
     FT_Bytes  p = table;
 
 
-    *min = 0xFFFF;
+    *min = 0xFFFFU;
     *max = 0x0000;
 
     while ( p < limit )
     {
       FT_UShort  val;
 
+
       GXV_LIMIT_CHECK( 2 );
       val = FT_NEXT_USHORT( p );
 
@@ -226,7 +230,7 @@
       *max = FT_MAX( *max, val );
     }
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
   }
 
 
@@ -238,13 +242,13 @@
   /*************************************************************************/
   /*************************************************************************/
 
-  typedef struct GXV_BinSrchHeader_
+  typedef struct  GXV_BinSrchHeader_
   {
-    FT_UShort unitSize;
-    FT_UShort nUnits;
-    FT_UShort searchRange;
-    FT_UShort entrySelector;
-    FT_UShort rangeShift;
+    FT_UShort  unitSize;
+    FT_UShort  nUnits;
+    FT_UShort  searchRange;
+    FT_UShort  entrySelector;
+    FT_UShort  rangeShift;
 
   } GXV_BinSrchHeader;
 
@@ -253,9 +257,9 @@
   gxv_BinSrchHeader_check_consistency( GXV_BinSrchHeader*  binSrchHeader,
                                        GXV_Validator       valid )
   {
-    FT_UShort searchRange;
-    FT_UShort entrySelector;
-    FT_UShort rangeShift;
+    FT_UShort  searchRange;
+    FT_UShort  entrySelector;
+    FT_UShort  rangeShift;
 
 
     if ( binSrchHeader->unitSize == 0 )
@@ -266,25 +270,21 @@
       if ( binSrchHeader->searchRange   == 0 &&
            binSrchHeader->entrySelector == 0 &&
            binSrchHeader->rangeShift    == 0 )
-      {
         return;
-      }
       else
-      {
         FT_INVALID_DATA;
-      }
     }
 
     for ( searchRange = 1, entrySelector = 1;
-          ( searchRange * 2 ) <= binSrchHeader->nUnits && searchRange < 0x8000;
+          ( searchRange * 2 ) <= binSrchHeader->nUnits &&
+            searchRange < 0x8000U;
           searchRange *= 2, entrySelector++ )
       ;
 
-    entrySelector --;
-    searchRange *= ( binSrchHeader->unitSize );
-    rangeShift   = ( binSrchHeader->nUnits ) * ( binSrchHeader->unitSize )
-                   - searchRange;
-
+    entrySelector--;
+    searchRange *= binSrchHeader->unitSize;
+    rangeShift   = binSrchHeader->nUnits * binSrchHeader->unitSize -
+                     searchRange;
 
     if ( searchRange   != binSrchHeader->searchRange   ||
          entrySelector != binSrchHeader->entrySelector ||
@@ -302,6 +302,7 @@
                   "rangeShift=%d\n",
                   binSrchHeader->unitSize, binSrchHeader->nUnits,
                   searchRange, entrySelector, rangeShift ));
+
       if ( valid->root->level >= FT_VALIDATE_PARANOID )
         FT_INVALID_DATA;
     }
@@ -314,7 +315,7 @@
    *
    * Essential parameters (unitSize, nUnits) are returned by
    * given pointer, others (searchRange, entrySelector, rangeShift)
-   * can be calculated essential parameters, so they are just
+   * can be calculated by essential parameters, so they are just
    * validated and discarded.
    *
    * However, wrong values in searchRange, entrySelector, rangeShift
@@ -323,7 +324,6 @@
    *   -- suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
    */
 
-
   FT_LOCAL_DEF( void )
   gxv_BinSrchHeader_validate( FT_Bytes       table,
                               FT_Bytes       limit,
@@ -331,7 +331,7 @@
                               FT_UShort*     nUnits_p,
                               GXV_Validator  valid )
   {
-    FT_Bytes  p = table;
+    FT_Bytes           p = table;
     GXV_BinSrchHeader  binSrchHeader;
 
 
@@ -345,7 +345,7 @@
     else
       binSrchHeader.unitSize = *unitSize_p;
 
-    if ( *nUnits_p == 0)
+    if ( *nUnits_p == 0 )
     {
       GXV_LIMIT_CHECK( 2 );
       binSrchHeader.nUnits = FT_NEXT_USHORT( p );
@@ -365,12 +365,13 @@
       *unitSize_p = binSrchHeader.unitSize;
 
     if ( *nUnits_p == 0 )
-      *nUnits_p   = binSrchHeader.nUnits;
+      *nUnits_p = binSrchHeader.nUnits;
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
     GXV_EXIT;
   }
 
+
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -379,14 +380,14 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define GXV_LOOKUP_VALUE_LOAD(P, SIGNSPEC) \
-  ( P += 2, gxv_lookup_value_load( P - 2, SIGNSPEC ) )
+#define GXV_LOOKUP_VALUE_LOAD( P, SIGNSPEC )                   \
+          ( P += 2, gxv_lookup_value_load( P - 2, SIGNSPEC ) )
 
   static GXV_LookupValueDesc
   gxv_lookup_value_load( FT_Bytes  p,
                          int       signspec )
   {
-    GXV_LookupValueDesc v;
+    GXV_LookupValueDesc  v;
 
 
     if ( signspec == GXV_LOOKUPVALUE_UNSIGNED )
@@ -397,26 +398,27 @@
     return v;
   }
 
+
 #define GXV_UNITSIZE_VALIDATE( FORMAT, UNITSIZE, NUNITS, CORRECTSIZE ) \
-          FT_BEGIN_STMNT                                     \
-            if ( UNITSIZE != CORRECTSIZE )                   \
-            {                                                \
-              FT_ERROR(( "unitSize=%d differs from"          \
-                         "expected unitSize=%d"              \
-                         "in LookupTable %s",                \
-                          UNITSIZE, CORRECTSIZE, FORMAT ));  \
-              if ( UNITSIZE != 0 && NUNITS != 0 )            \
-              {                                              \
-                FT_ERROR(( " cannot validate anymore\n" ));  \
-                FT_INVALID_FORMAT;                           \
-              }                                              \
-              else                                           \
-                FT_ERROR(( " forcibly continues\n" ));       \
-            }                                                \
+          FT_BEGIN_STMNT                                               \
+            if ( UNITSIZE != CORRECTSIZE )                             \
+            {                                                          \
+              FT_ERROR(( "unitSize=%d differs from"                    \
+                         "expected unitSize=%d"                        \
+                         "in LookupTable %s",                          \
+                          UNITSIZE, CORRECTSIZE, FORMAT ));            \
+              if ( UNITSIZE != 0 && NUNITS != 0 )                      \
+              {                                                        \
+                FT_ERROR(( " cannot validate anymore\n" ));            \
+                FT_INVALID_FORMAT;                                     \
+              }                                                        \
+              else                                                     \
+                FT_ERROR(( " forcibly continues\n" ));                 \
+            }                                                          \
           FT_END_STMNT
 
 
-  /* ================= Simple Array Format 0 Lookup Table ================= */
+  /* ================= Simple Array Format 0 Lookup Table ================ */
   static void
   gxv_LookupTable_fmt0_validate( FT_Bytes       table,
                                  FT_Bytes       limit,
@@ -435,32 +437,38 @@
     for ( i = 0; i < valid->face->num_glyphs; i++ )
     {
       GXV_LIMIT_CHECK( 2 );
-      if ( p + 2 >= limit ) /* some fonts has too-short fmt0 array */
+      if ( p + 2 >= limit )     /* some fonts have too-short fmt0 array */
       {
-        GXV_TRACE(( "too-short, glyph %d - %d are missing\n",
-                     i, valid->face->num_glyphs ));
+        GXV_TRACE(( "too short, glyphs %d - %d are missing\n",
+                    i, valid->face->num_glyphs ));
         if ( valid->root->level >= FT_VALIDATE_PARANOID )
           FT_INVALID_GLYPH_ID;
         break;
       }
+
       value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
       valid->lookupval_func( i, value, valid );
     }
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
     GXV_EXIT;
   }
 
-  /* ================= Segment Single Format 2 Loolup Table =============== */
+
+  /* ================= Segment Single Format 2 Loolup Table ============== */
   /*
-   * Apple spec says: To guarantee that a binary search terminates,
-   *   you must include one or more special "end of search table" values
-   *   at the end of the data to be searched. The number of termination
-   *   values that need to be included is table-specific. The value
-   *   that indicates binary search termination is 0xFFFF.
-   * The problem is that nUnits does not include this end-marker.
-   * It's quite difficult to discriminate following 0xFFFF comes from
+   * Apple spec says:
+   *
+   *   To guarantee that a binary search terminates, you must include one or
+   *   more special `end of search table' values at the end of the data to
+   *   be searched.  The number of termination values that need to be
+   *   included is table-specific.  The value that indicates binary search
+   *   termination is 0xFFFF.
+   *
+   * The problem is that nUnits does not include this end-marker.  It's
+   * quite difficult to discriminate whether the following 0xFFFF comes from
    * the end-marker or some next data.
+   *
    *   -- suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
    */
   static void
@@ -475,15 +483,14 @@
     {
       if ( p[0] != 0xFF || p[1] != 0xFF || /* lastGlyph */
            p[2] != 0xFF || p[3] != 0xFF )  /* firstGlyph */
-      {
         break;
-      }
       p += unitSize;
     }
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
   }
 
+
   static void
   gxv_LookupTable_fmt2_validate( FT_Bytes       table,
                                  FT_Bytes       limit,
@@ -508,7 +515,6 @@
 
     GXV_UNITSIZE_VALIDATE( "format2", unitSize, nUnits, 6 );
 
-
     for ( unit = 0, gid = 0; unit < nUnits; unit++ )
     {
       GXV_LIMIT_CHECK( 2 + 2 + 2 );
@@ -519,35 +525,32 @@
       gxv_glyphid_validate( firstGlyph, valid );
       gxv_glyphid_validate( lastGlyph, valid );
 
-
       if ( lastGlyph < gid )
       {
         GXV_TRACE(( "reverse ordered segment specification:"
                     " lastGlyph[%d]=%d < lastGlyph[%d]=%d\n",
-                     unit, lastGlyph, unit - 1 , gid ));
+                    unit, lastGlyph, unit - 1 , gid ));
         if ( valid->root->level >= FT_VALIDATE_PARANOID )
           FT_INVALID_GLYPH_ID;
       }
 
-
       if ( lastGlyph < firstGlyph )
       {
         GXV_TRACE(( "reverse ordered range specification at unit %d:",
                     " lastGlyph %d < firstGlyph %d ",
-                      unit, lastGlyph, firstGlyph ));
+                    unit, lastGlyph, firstGlyph ));
         if ( valid->root->level >= FT_VALIDATE_PARANOID )
           FT_INVALID_GLYPH_ID;
 
         if ( valid->root->level == FT_VALIDATE_TIGHT )
-          continue; /* ftxvalidator silently skips such entry */
+          continue;     /* ftxvalidator silently skips such an entry */
 
-        FT_TRACE4(( "continue with exchange\n" ));
+        FT_TRACE4(( "continuing with exchanged values\n" ));
         gid        = firstGlyph;
         firstGlyph = lastGlyph;
         lastGlyph  = gid;
       }
 
-
       for ( gid = firstGlyph; gid <= lastGlyph; gid++ )
         valid->lookupval_func( gid, value, valid );
     }
@@ -555,11 +558,12 @@
     gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, valid );
     p += valid->subtable_length;
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
     GXV_EXIT;
   }
 
-  /* ================= Segment Array Format 4 Lookup Table ================ */
+
+  /* ================= Segment Array Format 4 Lookup Table =============== */
   static void
   gxv_LookupTable_fmt4_validate( FT_Bytes       table,
                                  FT_Bytes       limit,
@@ -594,35 +598,32 @@
       gxv_glyphid_validate( firstGlyph, valid );
       gxv_glyphid_validate( lastGlyph, valid );
 
-
       if ( lastGlyph < gid )
       {
         GXV_TRACE(( "reverse ordered segment specification:"
                     " lastGlyph[%d]=%d < lastGlyph[%d]=%d\n",
-                     unit, lastGlyph, unit - 1 , gid ));
+                    unit, lastGlyph, unit - 1 , gid ));
         if ( valid->root->level >= FT_VALIDATE_PARANOID )
           FT_INVALID_GLYPH_ID;
       }
 
-
       if ( lastGlyph < firstGlyph )
       {
         GXV_TRACE(( "reverse ordered range specification at unit %d:",
                     " lastGlyph %d < firstGlyph %d ",
-                      unit, lastGlyph, firstGlyph ));
+                    unit, lastGlyph, firstGlyph ));
         if ( valid->root->level >= FT_VALIDATE_PARANOID )
           FT_INVALID_GLYPH_ID;
 
         if ( valid->root->level == FT_VALIDATE_TIGHT )
-          continue; /* ftxvalidator silently skips such entry */
+          continue; /* ftxvalidator silently skips such an entry */
 
-        FT_TRACE4(( "continue with exchange\n" ));
+        FT_TRACE4(( "continuing with exchanged values\n" ));
         gid        = firstGlyph;
         firstGlyph = lastGlyph;
         lastGlyph  = gid;
       }
 
-
       GXV_LIMIT_CHECK( 2 );
       base_value = GXV_LOOKUP_VALUE_LOAD( p, GXV_LOOKUPVALUE_UNSIGNED );
 
@@ -637,11 +638,12 @@
     gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, valid );
     p += valid->subtable_length;
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
     GXV_EXIT;
   }
 
-  /* ================= Segment Table Format 6 Lookup Table ================ */
+
+  /* ================= Segment Table Format 6 Lookup Table =============== */
   static void
   gxv_LookupTable_fmt6_skip_endmarkers( FT_Bytes       table,
                                         FT_UShort      unitSize,
@@ -657,9 +659,10 @@
       p += unitSize;
     }
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
   }
 
+
   static void
   gxv_LookupTable_fmt6_validate( FT_Bytes       table,
                                  FT_Bytes       limit,
@@ -689,7 +692,6 @@
       glyph = FT_NEXT_USHORT( p );
       value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
 
-
       if ( gxv_glyphid_validate( glyph, valid ) )
         GXV_TRACE(( " endmarker found within defined range"
                     " (entry %d < nUnits=%d)\n",
@@ -698,24 +700,24 @@
       if ( prev_glyph > glyph )
       {
         GXV_TRACE(( "current gid 0x%04x < previous gid 0x%04x\n",
-                     glyph, prev_glyph ));
+                    glyph, prev_glyph ));
         if ( valid->root->level >= FT_VALIDATE_PARANOID )
           FT_INVALID_GLYPH_ID;
       }
       prev_glyph = glyph;
 
-
       valid->lookupval_func( glyph, value, valid );
     }
 
     gxv_LookupTable_fmt6_skip_endmarkers( p, unitSize, valid );
     p += valid->subtable_length;
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
     GXV_EXIT;
   }
 
-  /* ================= Trimmed Array Format 8 Lookup Table ================ */
+
+  /* ================= Trimmed Array Format 8 Lookup Table =============== */
   static void
   gxv_LookupTable_fmt8_validate( FT_Bytes       table,
                                  FT_Bytes       limit,
@@ -747,7 +749,7 @@
       valid->lookupval_func( firstGlyph + i, value, valid );
     }
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
     GXV_EXIT;
   }
 
@@ -757,10 +759,10 @@
                             FT_Bytes       limit,
                             GXV_Validator  valid )
   {
-    FT_Bytes  p = table;
-    FT_UShort format;
+    FT_Bytes   p = table;
+    FT_UShort  format;
 
-    GXV_Validate_Func fmt_funcs_table [] =
+    GXV_Validate_Func  fmt_funcs_table[] =
     {
       gxv_LookupTable_fmt0_validate, /* 0 */
       NULL,                          /* 1 */
@@ -772,7 +774,8 @@
       NULL,                          /* 7 */
       gxv_LookupTable_fmt8_validate, /* 8 */
     };
-    GXV_Validate_Func func;
+
+    GXV_Validate_Func  func;
 
 
     GXV_NAME_ENTER(" LookupTable" );
@@ -795,7 +798,7 @@
     func( p, limit, valid );
     p += valid->subtable_length;
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
 
     GXV_EXIT;
   }
@@ -813,10 +816,10 @@
   gxv_glyphid_validate( FT_UShort      gid,
                         GXV_Validator  valid )
   {
-    FT_Face       face;
+    FT_Face  face;
 
 
-    if ( gid == 0xFFFF )
+    if ( gid == 0xFFFFU )
     {
       GXV_EXIT;
       return 1;
@@ -826,7 +829,7 @@
     if ( face->num_glyphs < gid )
     {
       GXV_TRACE(( " gxv_glyphid_check() gid overflow: num_glyphs %d < %d\n",
-                   face->num_glyphs, gid ));
+                  face->num_glyphs, gid ));
       if ( valid->root->level >= FT_VALIDATE_PARANOID )
         FT_INVALID_GLYPH_ID;
     }
@@ -860,7 +863,7 @@
 
     error = FT_Load_Glyph( face,
                            gid,
-                           FT_LOAD_NO_BITMAP|FT_LOAD_IGNORE_TRANSFORM );
+                           FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM );
     if ( error )
       FT_INVALID_GLYPH_ID;
 
@@ -889,7 +892,7 @@
                          GXV_Validator  valid )
   {
     FT_SfntName  name;
-    FT_Int       i;
+    FT_UInt      i;
     FT_UInt      nnames;
 
 
@@ -898,7 +901,7 @@
     if ( name_index < min_index || max_index < name_index )
       FT_INVALID_FORMAT;
 
-    nnames = FT_Get_Sfnt_Name_Count (valid->face);
+    nnames = FT_Get_Sfnt_Name_Count( valid->face );
     for ( i = 0; i < nnames; i++ )
     {
       if ( FT_Get_Sfnt_Name( valid->face, i, &name ) != FT_Err_Ok )
@@ -931,10 +934,10 @@
   /* -------------------------- Class Table --------------------------- */
 
   /*
-   * highestClass is used to notice how many class are defined in this
-   * Class Subtable. Apple spec does not mention about whether undefined
-   * hole in the class (e.g.: 0-3 are predefined, 4 is unused, 5 is used)
-   * is permitted. At present, hole in defined class is not checked.
+   * highestClass specifies how many classes are defined in this
+   * Class Subtable.  Apple spec does not mention whether undefined
+   * holes in the class (e.g.: 0-3 are predefined, 4 is unused, 5 is used)
+   * are permitted.  At present, holes in a defined class are not checked.
    *   -- suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
    */
 
@@ -945,15 +948,15 @@
                            FT_Byte*       maxClassID_p,
                            GXV_Validator  valid )
   {
-    FT_Bytes  p     = table;
-    FT_Bytes  limit = table + *length_p;
-    FT_UShort firstGlyph;
-    FT_UShort nGlyphs;
+    FT_Bytes   p     = table;
+    FT_Bytes   limit = table + *length_p;
+    FT_UShort  firstGlyph;
+    FT_UShort  nGlyphs;
 
 
     GXV_NAME_ENTER( "ClassTable" );
 
-    *maxClassID_p = 3;  /* Class 0,2,3 are predefined */
+    *maxClassID_p = 3;  /* Classes 0, 2, and 3 are predefined */
 
     GXV_LIMIT_CHECK( 2 + 2 );
     firstGlyph = FT_NEXT_USHORT( p );
@@ -981,35 +984,37 @@
         classID = FT_NEXT_BYTE( p );
         switch ( classID )
         {
-          /* following class should not be appear in class array */
-          case 0:  /* end of text */
-          case 2:  /* out of bounds */
-          case 3:  /* end of line */
-            FT_INVALID_DATA;
-            break;
-
-          case 1:  /* out of bounds */
-          default: /* user-defined: 4 - ( stateSize - 1 ) */
-            if ( classID >= stateSize )
-              FT_INVALID_DATA;   /* assign glyph to undefined state */
-            nGlyphInClass[classID]++;
-            break;
+          /* following classes should not appear in class array */
+        case 0:             /* end of text */
+        case 2:             /* out of bounds */
+        case 3:             /* end of line */
+          FT_INVALID_DATA;
+          break;
+
+        case 1:             /* out of bounds */
+        default:            /* user-defined: 4 - ( stateSize - 1 ) */
+          if ( classID >= stateSize )
+            FT_INVALID_DATA;   /* assign glyph to undefined state */
+
+          nGlyphInClass[classID]++;
+          break;
         }
       }
-      *length_p = ( p - table );
-
+      *length_p = p - table;
 
       /* scan max ClassID in use */
       for ( i = 0; i < stateSize; i++ )
-        if ((3 < i) && (nGlyphInClass[i] > 0))
+        if ( ( 3 < i ) && ( nGlyphInClass[i] > 0 ) )
           *maxClassID_p = i;
     }
 
-Out:
-    GXV_TRACE(( "Declared stateSize=0x%02x, Used maxClassID=0x%02x\n", stateSize, *maxClassID_p ));
+  Out:
+    GXV_TRACE(( "Declared stateSize=0x%02x, Used maxClassID=0x%02x\n",
+                stateSize, *maxClassID_p ));
     GXV_EXIT;
   }
 
+
   /* --------------------------- State Array ----------------------------- */
 
   static void
@@ -1030,10 +1035,10 @@ Out:
     GXV_NAME_ENTER( "StateArray" );
 
     GXV_TRACE(( "parse %d bytes by stateSize=%d maxClassID=%d\n",
-                       (int)(*length_p), stateSize, (int)(maxClassID) ));
+                (int)(*length_p), stateSize, (int)(maxClassID) ));
 
     /*
-     * 2 states are predefined and must be described in StateArray
+     * 2 states are predefined and must be described in StateArray:
      * state 0 (start of text), 1 (start of line)
      */
     GXV_LIMIT_CHECK( ( 1 + maxClassID ) * 2 );
@@ -1044,7 +1049,7 @@ Out:
     /* read if enough to read another state */
     while ( p + ( 1 + maxClassID ) <= limit )
     {
-      (*maxState_p) ++;
+      (*maxState_p)++;
       for ( class = 0; class <= maxClassID; class++ )
       {
         entry = FT_NEXT_BYTE( p );
@@ -1052,13 +1057,14 @@ Out:
       }
     }
     GXV_TRACE(( "parsed: maxState=%d, maxEntry=%d\n",
-                         *maxState_p, *maxEntry_p ));
+                *maxState_p, *maxEntry_p ));
 
-    *length_p = ( p - table );
+    *length_p = p - table;
 
     GXV_EXIT;
   }
 
+
   /* --------------------------- Entry Table ----------------------------- */
 
   static void
@@ -1072,11 +1078,12 @@ Out:
                            FT_Bytes       statetable_limit,
                            GXV_Validator  valid )
   {
-    FT_Bytes  p = table;
+    FT_Bytes  p     = table;
     FT_Bytes  limit = table + *length_p;
     FT_Byte   entry;
     FT_Byte   state;
     FT_Int    entrySize = 2 + 2 + GXV_GLYPHOFFSET_SIZE( statetable );
+
     GXV_XStateTable_GlyphOffsetDesc  glyphOffset;
 
 
@@ -1089,13 +1096,12 @@ Out:
       if ( valid->root->level >= FT_VALIDATE_PARANOID )
         FT_INVALID_TOO_SHORT;
 
-      /* ftxvalidator, FontValidator warns and continues */
-      maxEntry = ( *length_p / entrySize ) - 1;
-      GXV_TRACE(( "too large maxEntry, shrink to %d fit EntryTable length\n",
-                   maxEntry ));
+      /* ftxvalidator and FontValidator both warn and continue */
+      maxEntry = *length_p / entrySize - 1;
+      GXV_TRACE(( "too large maxEntry, shrinking to %d fit EntryTable length\n",
+                  maxEntry ));
     }
 
-
     for ( entry = 0; entry <= maxEntry; entry++ )
     {
       FT_UShort  newState;
@@ -1107,60 +1113,59 @@ Out:
       flags    = FT_NEXT_USHORT( p );
 
 
-      if ( newState < stateArray || stateArray + stateArray_length < newState )
+      if ( newState < stateArray                     ||
+           stateArray + stateArray_length < newState )
       {
-        GXV_TRACE(( " newState offset 0x%04x is out of stateArray\n", newState ));
+        GXV_TRACE(( " newState offset 0x%04x is out of stateArray\n",
+                    newState ));
         if ( valid->root->level >= FT_VALIDATE_PARANOID )
           FT_INVALID_OFFSET;
         continue;
       }
 
-
-      if ( 0 != (( newState - stateArray ) % ( 1 + maxClassID )) )
+      if ( 0 != ( ( newState - stateArray ) % ( 1 + maxClassID ) ) )
       {
         GXV_TRACE(( " newState offset 0x%04x is not aligned to %d-classes\n",
-                                      newState,  1 + maxClassID ));
+                    newState,  1 + maxClassID ));
         if ( valid->root->level >= FT_VALIDATE_PARANOID )
           FT_INVALID_OFFSET;
         continue;
       }
 
-
       state =  ( newState - stateArray ) / ( 1 + maxClassID );
 
-
       switch ( GXV_GLYPHOFFSET_FMT( statetable ) )
       {
-        case GXV_GLYPHOFFSET_NONE:
-          break;
+      case GXV_GLYPHOFFSET_NONE:
+        break;
 
-        case GXV_GLYPHOFFSET_UCHAR:
-          glyphOffset.uc = FT_NEXT_BYTE( p );
-          break;
+      case GXV_GLYPHOFFSET_UCHAR:
+        glyphOffset.uc = FT_NEXT_BYTE( p );
+        break;
 
-        case GXV_GLYPHOFFSET_CHAR:
-          glyphOffset.c = FT_NEXT_CHAR( p );
-          break;
+      case GXV_GLYPHOFFSET_CHAR:
+        glyphOffset.c = FT_NEXT_CHAR( p );
+        break;
 
-        case GXV_GLYPHOFFSET_USHORT:
-          glyphOffset.u = FT_NEXT_USHORT( p );
-          break;
+      case GXV_GLYPHOFFSET_USHORT:
+        glyphOffset.u = FT_NEXT_USHORT( p );
+        break;
 
-        case GXV_GLYPHOFFSET_SHORT:
-          glyphOffset.s = FT_NEXT_SHORT( p );
-          break;
+      case GXV_GLYPHOFFSET_SHORT:
+        glyphOffset.s = FT_NEXT_SHORT( p );
+        break;
 
-        case GXV_GLYPHOFFSET_ULONG:
-          glyphOffset.ul = FT_NEXT_ULONG( p );
-          break;
+      case GXV_GLYPHOFFSET_ULONG:
+        glyphOffset.ul = FT_NEXT_ULONG( p );
+        break;
 
-        case GXV_GLYPHOFFSET_LONG:
-          glyphOffset.l = FT_NEXT_LONG( p );
-          break;
+      case GXV_GLYPHOFFSET_LONG:
+        glyphOffset.l = FT_NEXT_LONG( p );
+        break;
 
-        default:
-          if ( valid->root->level >= FT_VALIDATE_PARANOID )
-            FT_INVALID_FORMAT;
+      default:
+        if ( valid->root->level >= FT_VALIDATE_PARANOID )
+          FT_INVALID_FORMAT;
       }
 
       if ( NULL != valid->statetable.entry_validate_func )
@@ -1171,11 +1176,12 @@ Out:
                                                statetable_limit,
                                                valid );
     }
-    *length_p = ( p - table );
+    *length_p = p - table;
 
     GXV_EXIT;
   }
 
+
   /* =========================== State Table ============================= */
 
   FT_LOCAL_DEF( void )
@@ -1192,6 +1198,7 @@ Out:
     FT_UShort*  l[3];
     FT_UShort   buff[4];
 
+
     o[0] = classTable;
     o[1] = stateArray;
     o[2] = entryTable;
@@ -1202,17 +1209,20 @@ Out:
     gxv_set_length_by_ushort_offset( o, l, buff, 3, table_size, valid );
   }
 
+
   FT_LOCAL_DEF( void )
   gxv_StateTable_validate( FT_Bytes       table,
                            FT_Bytes       limit,
                            GXV_Validator  valid )
   {
     FT_UShort   stateSize;
-    FT_UShort   classTable;  /* offset to Class(Sub)Table */
-    FT_UShort   stateArray;  /* offset to StateArray */
-    FT_UShort   entryTable;  /* offset to EntryTable */
-#define GXV_STATETABLE_HEADER_SIZE ( 2 + 2 + 2 + 2 )
-#define GXV_STATEHEADER_SIZE GXV_STATETABLE_HEADER_SIZE
+    FT_UShort   classTable;     /* offset to Class(Sub)Table */
+    FT_UShort   stateArray;     /* offset to StateArray */
+    FT_UShort   entryTable;     /* offset to EntryTable */
+
+#define GXV_STATETABLE_HEADER_SIZE  ( 2 + 2 + 2 + 2 )
+#define GXV_STATEHEADER_SIZE        GXV_STATETABLE_HEADER_SIZE
+
     FT_UShort   classTable_length;
     FT_UShort   stateArray_length;
     FT_UShort   entryTable_length;
@@ -1240,13 +1250,12 @@ Out:
     GXV_TRACE(( "offset to stateArray=0x%04x\n", stateArray ));
     GXV_TRACE(( "offset to entryTable=0x%04x\n", entryTable ));
 
-    if (stateSize > 0xFF)
+    if ( stateSize > 0xFF )
       FT_INVALID_DATA;
 
     if ( valid->statetable.optdata_load_func != NULL )
       valid->statetable.optdata_load_func( p, limit, valid );
 
-
     if ( valid->statetable.subtable_setup_func != NULL)
       setup_func = valid->statetable.subtable_setup_func;
     else
@@ -1261,10 +1270,9 @@ Out:
                 &entryTable_length,
                 valid );
 
-
     GXV_TRACE(( "StateTable Subtables\n" ));
 
-    if (classTable != 0)
+    if ( classTable != 0 )
       gxv_ClassTable_validate( table + classTable,
                                &classTable_length,
                                stateSize,
@@ -1273,7 +1281,7 @@ Out:
     else
       maxClassID = stateSize - 1;
 
-    if (stateArray != 0)
+    if ( stateArray != 0 )
       gxv_StateArray_validate( table + stateArray,
                                &stateArray_length,
                                maxClassID,
@@ -1283,14 +1291,14 @@ Out:
                                valid );
     else
     {
-      maxState = 1; /* 0:start of text, 1:start of line are predefined */
+      maxState = 1;     /* 0:start of text, 1:start of line are predefined */
       maxEntry = 0;
     }
 
-    if (maxEntry > 0 && entryTable == 0)
+    if ( maxEntry > 0 && entryTable == 0 )
       FT_INVALID_OFFSET;
 
-    if (entryTable != 0)
+    if ( entryTable != 0 )
       gxv_EntryTable_validate( table + entryTable,
                                &entryTable_length,
                                maxEntry,
@@ -1304,7 +1312,8 @@ Out:
     GXV_EXIT;
   }
 
-  /* ================ eXtended State Table (for morx) =================== */
+
+  /* ================= eXtended State Table (for morx) =================== */
 
   FT_LOCAL_DEF( void )
   gxv_XStateTable_subtable_setup( FT_ULong       table_size,
@@ -1320,6 +1329,7 @@ Out:
     FT_ULong*  l[3];
     FT_ULong   buff[4];
 
+
     o[0] = classTable;
     o[1] = stateArray;
     o[2] = entryTable;
@@ -1336,6 +1346,8 @@ Out:
                                       GXV_LookupValueDesc  value,
                                       GXV_Validator        valid )
   {
+    FT_UNUSED( glyph );
+
     if ( value.u >= valid->xstatetable.nClasses )
       FT_INVALID_DATA;
     if ( value.u > valid->xstatetable.maxClassID )
@@ -1380,7 +1392,8 @@ Out:
     FT_UShort            offset;
     GXV_LookupValueDesc  value;
 
-    offset = base_value.u + ( relative_gindex * sizeof ( FT_UShort ) );
+
+    offset = base_value.u + relative_gindex * sizeof ( FT_UShort );
 
     p     = valid->lookuptbl_head + offset;
     limit = lookuptbl_limit;
@@ -1410,10 +1423,10 @@ Out:
     GXV_NAME_ENTER( "XStateArray" );
 
     GXV_TRACE(( "parse % 3d bytes by stateSize=% 3d maxClassID=% 3d\n",
-                       (int)(*length_p), stateSize, (int)(maxClassID) ));
+                (int)(*length_p), stateSize, (int)(maxClassID) ));
 
     /*
-     * 2 states are predefined and must be described
+     * 2 states are predefined and must be described:
      * state 0 (start of text), 1 (start of line)
      */
     GXV_LIMIT_CHECK( ( 1 + maxClassID ) * 2 * 2 );
@@ -1424,7 +1437,7 @@ Out:
     /* read if enough to read another state */
     while ( p + ( ( 1 + maxClassID ) * 2 ) <= limit )
     {
-      (*maxState_p) ++;
+      (*maxState_p)++;
       for ( class = 0; class <= maxClassID; class++ )
       {
         entry = FT_NEXT_USHORT( p );
@@ -1432,9 +1445,9 @@ Out:
       }
     }
     GXV_TRACE(( "parsed: maxState=%d, maxEntry=%d\n",
-                         *maxState_p, *maxEntry_p ));
+                *maxState_p, *maxEntry_p ));
 
-    *length_p = ( p - table );
+    *length_p = p - table;
 
     GXV_EXIT;
   }
@@ -1444,7 +1457,6 @@ Out:
   gxv_XEntryTable_validate( FT_Bytes       table,
                             FT_ULong*      length_p,
                             FT_UShort      maxEntry,
-                            FT_ULong       stateArray,
                             FT_ULong       stateArray_length,
                             FT_UShort      maxClassID,
                             FT_Bytes       xstatetable_table,
@@ -1466,8 +1478,8 @@ Out:
 
     for (entry = 0; entry <= maxEntry ; entry++ )
     {
-      FT_UShort  newState_idx;
-      FT_UShort  flags;
+      FT_UShort                        newState_idx;
+      FT_UShort                        flags;
       GXV_XStateTable_GlyphOffsetDesc  glyphOffset;
 
 
@@ -1475,55 +1487,56 @@ Out:
       newState_idx = FT_NEXT_USHORT( p );
       flags        = FT_NEXT_USHORT( p );
 
-      if ( stateArray_length < ( newState_idx * 2 ) )
+      if ( stateArray_length < (FT_ULong)( newState_idx * 2 ) )
       {
-        GXV_TRACE(( "  newState index 0x%04x points out of stateArray\n", newState_idx ));
+        GXV_TRACE(( "  newState index 0x%04x points out of stateArray\n",
+                    newState_idx ));
         if ( valid->root->level >= FT_VALIDATE_PARANOID )
           FT_INVALID_OFFSET;
       }
 
-      state =  newState_idx / ( 1 + maxClassID );
+      state = newState_idx / ( 1 + maxClassID );
       if ( 0 != ( newState_idx % ( 1 + maxClassID ) ) )
       {
-        FT_TRACE4(( "-> new state = %d (supposed) but newState index 0x%04x is not aligned to %d-classes\n",
-                                      state, newState_idx,  1 + maxClassID ));
+        FT_TRACE4(( "-> new state = %d (supposed)\n"
+                    "but newState index 0x%04x is not aligned to %d-classes\n",
+                    state, newState_idx,  1 + maxClassID ));
         if ( valid->root->level >= FT_VALIDATE_PARANOID )
           FT_INVALID_OFFSET;
       }
 
-
       switch ( GXV_GLYPHOFFSET_FMT( xstatetable ) )
       {
-        case GXV_GLYPHOFFSET_NONE:
-          break;
+      case GXV_GLYPHOFFSET_NONE:
+        break;
 
-        case GXV_GLYPHOFFSET_UCHAR:
-          glyphOffset.uc = FT_NEXT_BYTE( p );
-          break;
+      case GXV_GLYPHOFFSET_UCHAR:
+        glyphOffset.uc = FT_NEXT_BYTE( p );
+        break;
 
-        case GXV_GLYPHOFFSET_CHAR:
-          glyphOffset.c = FT_NEXT_CHAR( p );
-          break;
+      case GXV_GLYPHOFFSET_CHAR:
+        glyphOffset.c = FT_NEXT_CHAR( p );
+        break;
 
-        case GXV_GLYPHOFFSET_USHORT:
-          glyphOffset.u = FT_NEXT_USHORT( p );
-          break;
+      case GXV_GLYPHOFFSET_USHORT:
+        glyphOffset.u = FT_NEXT_USHORT( p );
+        break;
 
-        case GXV_GLYPHOFFSET_SHORT:
-          glyphOffset.s = FT_NEXT_SHORT( p );
-          break;
+      case GXV_GLYPHOFFSET_SHORT:
+        glyphOffset.s = FT_NEXT_SHORT( p );
+        break;
 
-        case GXV_GLYPHOFFSET_ULONG:
-          glyphOffset.ul = FT_NEXT_ULONG( p );
-          break;
+      case GXV_GLYPHOFFSET_ULONG:
+        glyphOffset.ul = FT_NEXT_ULONG( p );
+        break;
 
-        case GXV_GLYPHOFFSET_LONG:
-          glyphOffset.l = FT_NEXT_LONG( p );
-          break;
+      case GXV_GLYPHOFFSET_LONG:
+        glyphOffset.l = FT_NEXT_LONG( p );
+        break;
 
-        default:
-          if ( valid->root->level >= FT_VALIDATE_PARANOID )
-            FT_INVALID_FORMAT;
+      default:
+        if ( valid->root->level >= FT_VALIDATE_PARANOID )
+          FT_INVALID_FORMAT;
       }
 
       if ( NULL != valid->xstatetable.entry_validate_func )
@@ -1535,38 +1548,42 @@ Out:
                                                 valid );
     }
 
-    *length_p = ( p - table );
+    *length_p = p - table;
 
     GXV_EXIT;
   }
 
+
   FT_LOCAL_DEF( void )
   gxv_XStateTable_validate( FT_Bytes       table,
                             FT_Bytes       limit,
                             GXV_Validator  valid )
   {
     /* StateHeader members */
-    FT_ULong    classTable;  /* offset to Class(Sub)Table */
-    FT_ULong    stateArray;  /* offset to StateArray */
-    FT_ULong    entryTable;  /* offset to EntryTable */
-#define GXV_XSTATETABLE_HEADER_SIZE ( 4 + 4 + 4 + 4 )
-#define GXV_XSTATEHEADER_SIZE GXV_XSTATETABLE_HEADER_SIZE
-    FT_ULong    classTable_length;
-    FT_ULong    stateArray_length;
-    FT_ULong    entryTable_length;
-    FT_UShort   maxState;
-    FT_UShort   maxEntry;
+    FT_ULong   classTable;      /* offset to Class(Sub)Table */
+    FT_ULong   stateArray;      /* offset to StateArray */
+    FT_ULong   entryTable;      /* offset to EntryTable */
+
+#define GXV_XSTATETABLE_HEADER_SIZE  ( 4 + 4 + 4 + 4 )
+#define GXV_XSTATEHEADER_SIZE        GXV_XSTATETABLE_HEADER_SIZE
+
+    FT_ULong   classTable_length;
+    FT_ULong   stateArray_length;
+    FT_ULong   entryTable_length;
+    FT_UShort  maxState;
+    FT_UShort  maxEntry;
 
     GXV_XStateTable_Subtable_Setup_Func  setup_func;
 
-    FT_Bytes    p = table;
+    FT_Bytes   p = table;
+
 
     GXV_NAME_ENTER( "XStateTable" );
 
     GXV_TRACE(( "XStateTable header\n" ));
 
     GXV_LIMIT_CHECK( 4 + 4 + 4 + 4 );
-    valid->xstatetable.nClasses  = FT_NEXT_ULONG( p );
+    valid->xstatetable.nClasses = FT_NEXT_ULONG( p );
     classTable = FT_NEXT_ULONG( p );
     stateArray = FT_NEXT_ULONG( p );
     entryTable = FT_NEXT_ULONG( p );
@@ -1576,7 +1593,7 @@ Out:
     GXV_TRACE(( "offset to stateArray=0x%08x\n", stateArray ));
     GXV_TRACE(( "offset to entryTable=0x%08x\n", entryTable ));
 
-    if ( valid->xstatetable.nClasses > 0xFFFF )
+    if ( valid->xstatetable.nClasses > 0xFFFFU )
       FT_INVALID_DATA;
 
     GXV_TRACE(( "StateTable Subtables\n" ));
@@ -1584,8 +1601,7 @@ Out:
     if ( valid->xstatetable.optdata_load_func != NULL )
       valid->xstatetable.optdata_load_func( p, limit, valid );
 
-
-    if ( valid->xstatetable.subtable_setup_func != NULL)
+    if ( valid->xstatetable.subtable_setup_func != NULL )
       setup_func = valid->xstatetable.subtable_setup_func;
     else
       setup_func = gxv_XStateTable_subtable_setup;
@@ -1599,13 +1615,12 @@ Out:
                 &entryTable_length,
                 valid );
 
-
-    if (classTable != 0)
+    if ( classTable != 0 )
     {
       valid->xstatetable.maxClassID = 0;
-      valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
-      valid->lookupval_func   = gxv_XClassTable_lookupval_validate;
-      valid->lookupfmt4_trans = gxv_XClassTable_lookupfmt4_transit;
+      valid->lookupval_sign         = GXV_LOOKUPVALUE_UNSIGNED;
+      valid->lookupval_func         = gxv_XClassTable_lookupval_validate;
+      valid->lookupfmt4_trans       = gxv_XClassTable_lookupfmt4_transit;
       gxv_LookupTable_validate( table + classTable,
                                 table + classTable + classTable_length,
                                 valid );
@@ -1615,9 +1630,7 @@ Out:
     else
       valid->xstatetable.maxClassID = valid->xstatetable.nClasses - 1;
 
-
-    if (stateArray != 0)
-    {
+    if ( stateArray != 0 )
       gxv_XStateArray_validate( table + stateArray,
                                 &stateArray_length,
                                 valid->xstatetable.maxClassID,
@@ -1625,28 +1638,24 @@ Out:
                                 &maxState,
                                 &maxEntry,
                                 valid );
-    }
     else
     {
       maxState = 1; /* 0:start of text, 1:start of line are predefined */
       maxEntry = 0;
     }
 
-    if (maxEntry > 0 && entryTable == 0)
+    if ( maxEntry > 0 && entryTable == 0 )
       FT_INVALID_OFFSET;
 
-    if (entryTable != 0)
-    {
+    if ( entryTable != 0 )
       gxv_XEntryTable_validate( table + entryTable,
                                 &entryTable_length,
                                 maxEntry,
-                                stateArray,
                                 stateArray_length,
                                 valid->xstatetable.maxClassID,
                                 table,
                                 limit,
                                 valid );
-    }
 
     GXV_EXIT;
   }
@@ -1661,11 +1670,10 @@ Out:
   /*************************************************************************/
 
   FT_LOCAL_DEF( int )
-  gxv_compare_ranges( FT_Bytes       table1_start,
-                      FT_ULong       table1_length,
-                      FT_Bytes       table2_start,
-                      FT_ULong       table2_length,
-                      GXV_Validator  valid )
+  gxv_compare_ranges( FT_Bytes  table1_start,
+                      FT_ULong  table1_length,
+                      FT_Bytes  table2_start,
+                      FT_ULong  table2_length )
   {
     if ( table1_start == table2_start )
     {
@@ -1698,9 +1706,10 @@ Out:
     odtect->range[ odtect->nRanges ].start  = start;
     odtect->range[ odtect->nRanges ].length = length;
     odtect->range[ odtect->nRanges ].name   = name;
-    odtect->nRanges ++;
+    odtect->nRanges++;
   }
 
+
   FT_LOCAL_DEF( void )
   gxv_odtect_validate( GXV_odtect_Range  odtect,
                        GXV_Validator     valid   )
@@ -1710,21 +1719,20 @@ Out:
 
     GXV_NAME_ENTER( "check overlap among multi ranges" );
 
-    for ( i = 0; i < odtect->nRanges; i ++ )
-      for ( j = 0; j < i; j ++ )
+    for ( i = 0; i < odtect->nRanges; i++ )
+      for ( j = 0; j < i; j++ )
         if ( 0 != gxv_compare_ranges( odtect->range[i].start,
                                       odtect->range[i].length,
                                       odtect->range[j].start,
-                                      odtect->range[j].length,
-                                      valid )                      )
+                                      odtect->range[j].length ) )
         {
           if ( odtect->range[i].name || odtect->range[j].name )
-            GXV_TRACE(( "found overlap between range-%d and range-%d\n",
-                         i, j ));
+            GXV_TRACE(( "found overlap between range %d and range %d\n",
+                        i, j ));
           else
-            GXV_TRACE(( "found overlap between \"%s\" and \"%s\"\n",
-                         odtect->range[i].name,
-                         odtect->range[j].name ));
+            GXV_TRACE(( "found overlap between `%s' and `%s\'\n",
+                        odtect->range[i].name,
+                        odtect->range[j].name ));
           FT_INVALID_OFFSET;
         }