Commit 4a7f0b1c7a1ec912911187b8090d197a4b887726

Werner Lemberg 2005-09-01T07:33:03

* src/gxvalid/gxvbsln.c (GXV_BSLN_VALUE_EMPTY): Add `U'. * src/gxvalid/gxmort1.c (GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE), src/gxvalid/gxmort2.c (GXV_MORT_SUBTABLE_TYPE2_HEADER_SIZE): Fix typo. * src/gxvalid/gxvmorx0.c, src/gxvalid/gxvmorx1.c, src/gxvalid/gxvmorx2.c, src/gxvalid/gxvmorx4.c, src/gxvalid/gxvmorx5.c, src/gxvalid/gxvmort.c: Improve tracing messages. Decorate constants with `U' and `L' where appropriate. Fix compiler warnings. 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
diff --git a/ChangeLog b/ChangeLog
index da0e472..dee79ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2005-09-01  Werner Lemberg  <wl@gnu.org>
+
+	* src/gxvalid/gxvbsln.c (GXV_BSLN_VALUE_EMPTY): Add `U'.
+
+	* src/gxvalid/gxmort1.c (GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE),
+	src/gxvalid/gxmort2.c (GXV_MORT_SUBTABLE_TYPE2_HEADER_SIZE): Fix
+	typo.
+
+	* src/gxvalid/gxvmorx0.c, src/gxvalid/gxvmorx1.c,
+	src/gxvalid/gxvmorx2.c, src/gxvalid/gxvmorx4.c,
+	src/gxvalid/gxvmorx5.c, src/gxvalid/gxvmort.c: Improve tracing
+	messages.
+	Decorate constants with `U' and `L' where appropriate.
+	Fix compiler warnings.
+
 2005-08-31  Werner Lemberg  <wl@gnu.org>
 
 	* src/truetype/ttgload.c (load_truetype_glyph): Fix typo.
diff --git a/src/gxvalid/gxvbsln.c b/src/gxvalid/gxvbsln.c
index 4681250..5a6389f 100644
--- a/src/gxvalid/gxvbsln.c
+++ b/src/gxvalid/gxvbsln.c
@@ -47,7 +47,7 @@
   /*************************************************************************/
 
 #define GXV_BSLN_VALUE_COUNT  32
-#define GXV_BSLN_VALUE_EMPTY  0xFFFF
+#define GXV_BSLN_VALUE_EMPTY  0xFFFFU
 
 
   typedef struct  GXV_bsln_DataRec_
@@ -57,6 +57,7 @@
 
   } GXV_bsln_DataRec, *GXV_bsln_Data;
 
+
 #define GXV_BSLN_DATA( field )  GXV_TABLE_DATA( bsln, field )
 
 
diff --git a/src/gxvalid/gxvlcar.c b/src/gxvalid/gxvlcar.c
index 042457c..3888358 100644
--- a/src/gxvalid/gxvlcar.c
+++ b/src/gxvalid/gxvlcar.c
@@ -52,7 +52,8 @@
 
   } GXV_lcar_DataRec, *GXV_lcar_Data;
 
-#define GXV_LCAR_DATA(FIELD)  GXV_TABLE_DATA( lcar, FIELD )
+
+#define GXV_LCAR_DATA( FIELD )  GXV_TABLE_DATA( lcar, FIELD )
 
 
   /*************************************************************************/
diff --git a/src/gxvalid/gxvmort1.c b/src/gxvalid/gxvmort1.c
index 68e334c..5bdf2d3 100644
--- a/src/gxvalid/gxvmort1.c
+++ b/src/gxvalid/gxvmort1.c
@@ -46,7 +46,8 @@
   }  GXV_mort_subtable_type1_StateOptRec,
     *GXV_mort_subtable_type1_StateOptRecData;
 
-#define GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE  GXV_STATETABLE_HEADER_SIZE + 2
+#define GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE \
+          ( GXV_STATETABLE_HEADER_SIZE + 2 )
 
 
   static void
diff --git a/src/gxvalid/gxvmort2.c b/src/gxvalid/gxvmort2.c
index d63fd3d..2d1a838 100644
--- a/src/gxvalid/gxvmort2.c
+++ b/src/gxvalid/gxvmort2.c
@@ -51,7 +51,7 @@
     *GXV_mort_subtable_type2_StateOptRecData;
 
 #define GXV_MORT_SUBTABLE_TYPE2_HEADER_SIZE \
-          GXV_STATETABLE_HEADER_SIZE + 2 + 2 + 2
+          ( GXV_STATETABLE_HEADER_SIZE + 2 + 2 + 2 )
 
 
   static void
diff --git a/src/gxvalid/gxvmorx.c b/src/gxvalid/gxvmorx.c
index f9ace32..8a0ea1a 100644
--- a/src/gxvalid/gxvmorx.c
+++ b/src/gxvalid/gxvmorx.c
@@ -16,14 +16,17 @@
 /***************************************************************************/
 
 /***************************************************************************/
+/*                                                                         */
 /* 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.                                           */
+/*                                                                         */
 /***************************************************************************/
 
 
 #include "gxvmorx.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -40,8 +43,9 @@
                                FT_UShort      nSubtables,
                                GXV_Validator  valid )
   {
-    FT_Bytes   p = table;
-    GXV_Validate_Func fmt_funcs_table [] =
+    FT_Bytes  p = table;
+
+    GXV_Validate_Func fmt_funcs_table[] =
     {
       gxv_morx_subtable_type0_validate, /* 0 */
       gxv_morx_subtable_type1_validate, /* 1 */
@@ -51,11 +55,14 @@
       gxv_morx_subtable_type5_validate, /* 5 */
 
     };
-    GXV_Validate_Func func;
+
+    GXV_Validate_Func  func;
+
     FT_UShort  i;
 
 
-     GXV_NAME_ENTER(( "subtables in a chain" ));
+    GXV_NAME_ENTER( "subtables in a chain" );
+
     for ( i = 0; i < nSubtables; i++ )
     {
       FT_ULong  length;
@@ -71,7 +78,7 @@
       subFeatureFlags = FT_NEXT_ULONG( p );
 
       GXV_TRACE(( "validate chain subtable %d/%d (%d bytes)\n",
-                                  i + 1, nSubtables, length ));
+                  i + 1, nSubtables, length ));
 
       type = coverage & 0x0007;
       rest = length - ( 4 + 4 + 4 );
@@ -92,7 +99,8 @@
       p += rest;
     }
 
-    valid->subtable_length = ( p - table );
+    valid->subtable_length = p - table;
+
     GXV_EXIT;
   }
 
@@ -102,11 +110,11 @@
                            FT_Bytes       limit,
                            GXV_Validator  valid )
   {
-    FT_Bytes   p = table;
-    FT_ULong   defaultFlags;
-    FT_ULong   chainLength;
-    FT_ULong   nFeatureFlags;
-    FT_ULong   nSubtables;
+    FT_Bytes  p = table;
+    FT_ULong  defaultFlags;
+    FT_ULong  chainLength;
+    FT_ULong  nFeatureFlags;
+    FT_ULong  nSubtables;
 
 
     GXV_NAME_ENTER( "morx chain header" );
@@ -126,6 +134,7 @@
     GXV_EXIT;
   }
 
+
   FT_LOCAL_DEF( void )
   gxv_morx_validate( FT_Bytes      table,
                      FT_Face       face,
@@ -150,7 +159,7 @@
     version = FT_NEXT_ULONG( p );
     nChains = FT_NEXT_ULONG( p );
 
-    if (version != 0x00020000)
+    if ( version != 0x00020000UL )
       FT_INVALID_FORMAT;
 
     for ( i = 0; i < nChains; i++ )
diff --git a/src/gxvalid/gxvmorx.h b/src/gxvalid/gxvmorx.h
index 51d3126..a5f7bd3 100644
--- a/src/gxvalid/gxvmorx.h
+++ b/src/gxvalid/gxvmorx.h
@@ -16,11 +16,14 @@
 /***************************************************************************/
 
 /***************************************************************************/
+/*                                                                         */
 /* 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.                                           */
+/*                                                                         */
 /***************************************************************************/
 
+
 #ifndef __GXVMORX_H_
 #define __GXVMORX_H_
 
@@ -58,7 +61,7 @@
                                     GXV_Validator  valid );
 
 
-#endif  /* Not def: __GXVMORX_H__ */
+#endif /* __GXVMORX_H__ */
 
 
 /* END */
diff --git a/src/gxvalid/gxvmorx0.c b/src/gxvalid/gxvmorx0.c
index 1f50142..7ad78af 100644
--- a/src/gxvalid/gxvmorx0.c
+++ b/src/gxvalid/gxvmorx0.c
@@ -17,13 +17,17 @@
 /***************************************************************************/
 
 /***************************************************************************/
+/*                                                                         */
 /* 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.                                           */
+/*                                                                         */
 /***************************************************************************/
 
+
 #include "gxvmorx.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -35,22 +39,27 @@
 
 
   static void
-  gxv_morx_subtable_type0_entry_validate( FT_UShort      state,
-                                          FT_UShort      flags,
-                                          GXV_XStateTable_GlyphOffsetDesc
-                                                         glyphOffset,
-                                          FT_Bytes       table,
-                                          FT_Bytes       limit,
-                                          GXV_Validator  valid )
+  gxv_morx_subtable_type0_entry_validate(
+    FT_UShort                        state,
+    FT_UShort                        flags,
+    GXV_XStateTable_GlyphOffsetDesc  glyphOffset,
+    FT_Bytes                         table,
+    FT_Bytes                         limit,
+    GXV_Validator                    valid )
   {
-    FT_UShort markFirst;
-    FT_UShort dontAdvance;
-    FT_UShort markLast;
-    FT_UShort reserved;
-    FT_UShort verb;
+    FT_UShort  markFirst;
+    FT_UShort  dontAdvance;
+    FT_UShort  markLast;
+    FT_UShort  reserved;
+    FT_UShort  verb;
+
+    FT_UNUSED( state );
+    FT_UNUSED( glyphOffset );
+    FT_UNUSED( table );
+    FT_UNUSED( limit );
 
 
-    markFirst   =   flags / 0x8000;
+    markFirst   =   flags / 0x8000U;
     dontAdvance = ( flags & 0x4000 ) / 0x4000;
     markLast    = ( flags & 0x2000 ) / 0x2000;
     reserved    =   flags & 0x1FF0;
@@ -63,6 +72,7 @@
     }
   }
 
+
   static void
   gxv_morx_subtable_type0_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
@@ -70,7 +80,9 @@
   {
     FT_Bytes  p = table;
 
-    GXV_NAME_ENTER( "morx chain subtable type0 (Indic-Script Rearrangement)" );
+
+    GXV_NAME_ENTER(
+      "morx chain subtable type0 (Indic-Script Rearrangement)" );
 
     GXV_LIMIT_CHECK( GXV_STATETABLE_HEADER_SIZE );
 
@@ -78,8 +90,11 @@
     valid->xstatetable.optdata_load_func     = NULL;
     valid->xstatetable.subtable_setup_func   = NULL;
     valid->xstatetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
-    valid->xstatetable.entry_validate_func   = gxv_morx_subtable_type0_entry_validate;
+    valid->xstatetable.entry_validate_func =
+      gxv_morx_subtable_type0_entry_validate;
+
     gxv_XStateTable_validate( p, limit, valid );
+
     GXV_EXIT;
   }
 
diff --git a/src/gxvalid/gxvmorx1.c b/src/gxvalid/gxvmorx1.c
index e3240aa..5f6fe44 100644
--- a/src/gxvalid/gxvmorx1.c
+++ b/src/gxvalid/gxvmorx1.c
@@ -17,13 +17,17 @@
 /***************************************************************************/
 
 /***************************************************************************/
+/*                                                                         */
 /* 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.                                           */
+/*                                                                         */
 /***************************************************************************/
 
+
 #include "gxvmorx.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -43,15 +47,21 @@
   }  GXV_morx_subtable_type1_StateOptRec,
     *GXV_morx_subtable_type1_StateOptRecData;
 
-#define  GXV_MORX_SUBTABLE_TYPE1_HEADER_SIZE ( GXV_STATETABLE_HEADER_SIZE + 2 )
+
+#define GXV_MORX_SUBTABLE_TYPE1_HEADER_SIZE \
+          ( GXV_STATETABLE_HEADER_SIZE + 2 )
+
 
   static void
   gxv_morx_subtable_type1_substitutionTable_load( FT_Bytes       table,
                                                   FT_Bytes       limit,
                                                   GXV_Validator  valid )
   {
-    FT_Bytes                       p = table;
-    GXV_morx_subtable_type1_StateOptRecData  optdata = valid->xstatetable.optdata;
+    FT_Bytes  p = table;
+
+    GXV_morx_subtable_type1_StateOptRecData  optdata =
+                                               valid->xstatetable.optdata;
+
 
     GXV_LIMIT_CHECK( 2 );
     optdata->substitutionTable = FT_NEXT_USHORT( p );
@@ -71,7 +81,9 @@
     FT_ULong  o[4];
     FT_ULong  *l[4];
     FT_ULong  buff[5];
-    GXV_morx_subtable_type1_StateOptRecData  optdata = valid->xstatetable.optdata;
+
+    GXV_morx_subtable_type1_StateOptRecData  optdata =
+                                               valid->xstatetable.optdata;
 
 
     o[0] = classTable;
@@ -88,30 +100,37 @@
 
 
   static void
-  gxv_morx_subtable_type1_entry_validate( FT_UShort      state,
-                                          FT_UShort      flags,
-                                          GXV_StateTable_GlyphOffsetDesc
-                                                         glyphOffset,
-                                          FT_Bytes       table,
-                                          FT_Bytes       limit,
-                                          GXV_Validator  valid )
+  gxv_morx_subtable_type1_entry_validate(
+    FT_UShort                       state,
+    FT_UShort                       flags,
+    GXV_StateTable_GlyphOffsetDesc  glyphOffset,
+    FT_Bytes                        table,
+    FT_Bytes                        limit,
+    GXV_Validator                   valid )
   {
-    FT_UShort setMark;
-    FT_UShort dontAdvance;
-    FT_UShort reserved;
-    FT_Short  markIndex;
-    FT_Short  currentIndex;
-    GXV_morx_subtable_type1_StateOptRecData  optdata = valid->xstatetable.optdata;
+    FT_UShort  setMark;
+    FT_UShort  dontAdvance;
+    FT_UShort  reserved;
+    FT_Short   markIndex;
+    FT_Short   currentIndex;
+
+    GXV_morx_subtable_type1_StateOptRecData  optdata =
+                                               valid->xstatetable.optdata;
+
+    FT_UNUSED( state );
+    FT_UNUSED( table );
+    FT_UNUSED( limit );
 
 
-    setMark      =   flags / 0x8000;
+    setMark      =   flags / 0x8000U;
     dontAdvance  = ( flags & 0x4000 ) / 0x4000;
     reserved     =   flags & 0x3FFF;
-    markIndex    = GXV_USHORT_TO_SHORT( glyphOffset.ul / 0x00010000 );
-    currentIndex = GXV_USHORT_TO_SHORT( glyphOffset.ul & 0x0000FFFF );
+    markIndex    = GXV_USHORT_TO_SHORT( glyphOffset.ul / 0x00010000UL );
+    currentIndex = GXV_USHORT_TO_SHORT( glyphOffset.ul & 0x0000FFFFUL );
 
     GXV_TRACE(( " setMark=%01d dontAdvance=%01d\n",
-                  setMark, dontAdvance ));
+                setMark, dontAdvance ));
+
     if ( 0 < reserved )
     {
       GXV_TRACE(( " non-zero bits found in reserved range\n" ));
@@ -119,14 +138,14 @@
         FT_INVALID_DATA;
     }
 
-    GXV_TRACE(( "markIndex = %d, currentIndex = %d\n", markIndex, currentIndex ));
+    GXV_TRACE(( "markIndex = %d, currentIndex = %d\n",
+                markIndex, currentIndex ));
 
     if ( optdata->substitutionTable_num_lookupTables < markIndex + 1 )
       optdata->substitutionTable_num_lookupTables = markIndex + 1;
 
     if ( optdata->substitutionTable_num_lookupTables < currentIndex + 1 )
       optdata->substitutionTable_num_lookupTables = currentIndex + 1;
-
   }
 
 
@@ -142,10 +161,11 @@
 
 
   static GXV_LookupValueDesc
-  gxv_morx_subtable_type1_LookupFmt4_transit( FT_UShort            relative_gindex,
-                                              GXV_LookupValueDesc  base_value,
-                                              FT_Bytes             lookuptbl_limit,
-                                              GXV_Validator        valid )
+  gxv_morx_subtable_type1_LookupFmt4_transit(
+    FT_UShort            relative_gindex,
+    GXV_LookupValueDesc  base_value,
+    FT_Bytes             lookuptbl_limit,
+    GXV_Validator        valid )
   {
     FT_Bytes             p;
     FT_Bytes             limit;
@@ -153,7 +173,7 @@
     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;
@@ -173,10 +193,12 @@
                                                       FT_Bytes       limit,
                                                       GXV_Validator  valid )
   {
-    FT_Bytes   p          = table;
-    GXV_morx_subtable_type1_StateOptRecData  optdata = valid->xstatetable.optdata;
+    FT_Bytes   p = table;
     FT_UShort  i;
 
+    GXV_morx_subtable_type1_StateOptRecData  optdata =
+                                               valid->xstatetable.optdata;
+
 
     /* TODO: calculate offset/length for each lookupTables */
     valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
@@ -199,9 +221,9 @@
 
 
   /*
-   * subtable for Contextual glyph substition is modified StateTable.
-   * In addition classTable, stateArray, entryTable, "substitutionTable"
-   * is added.
+   * subtable for Contextual glyph substition is a modified StateTable.
+   * In addition to classTable, stateArray, entryTable, the field
+   * `substitutionTable' is added.
    */
   static void
   gxv_morx_subtable_type1_validate( FT_Bytes       table,
@@ -209,6 +231,7 @@
                                     GXV_Validator  valid )
   {
     FT_Bytes  p = table;
+
     GXV_morx_subtable_type1_StateOptRec  st_rec;
 
 
@@ -218,19 +241,24 @@
 
     st_rec.substitutionTable_num_lookupTables = 0;
 
-    valid->xstatetable.optdata               = &st_rec;
-    valid->xstatetable.optdata_load_func     = gxv_morx_subtable_type1_substitutionTable_load;
-    valid->xstatetable.subtable_setup_func   = gxv_morx_subtable_type1_subtable_setup;
-    valid->xstatetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_ULONG;
-    valid->xstatetable.entry_validate_func   = gxv_morx_subtable_type1_entry_validate;
+    valid->xstatetable.optdata =
+      &st_rec;
+    valid->xstatetable.optdata_load_func =
+      gxv_morx_subtable_type1_substitutionTable_load;
+    valid->xstatetable.subtable_setup_func =
+      gxv_morx_subtable_type1_subtable_setup;
+    valid->xstatetable.entry_glyphoffset_fmt =
+      GXV_GLYPHOFFSET_ULONG;
+    valid->xstatetable.entry_validate_func =
+      gxv_morx_subtable_type1_entry_validate;
+
     gxv_XStateTable_validate( p, limit, valid );
 
-    gxv_morx_subtable_type1_substitutionTable_validate( table
-                                                          + st_rec.substitutionTable,
-                                                        table
-                                                          + st_rec.substitutionTable
-                                                          + st_rec.substitutionTable_length,
-                                                        valid );
+    gxv_morx_subtable_type1_substitutionTable_validate(
+      table + st_rec.substitutionTable,
+      table + st_rec.substitutionTable + st_rec.substitutionTable_length,
+      valid );
+
     GXV_EXIT;
   }
 
diff --git a/src/gxvalid/gxvmorx2.c b/src/gxvalid/gxvmorx2.c
index 749bbc6..5c4fba6 100644
--- a/src/gxvalid/gxvmorx2.c
+++ b/src/gxvalid/gxvmorx2.c
@@ -17,13 +17,17 @@
 /***************************************************************************/
 
 /***************************************************************************/
+/*                                                                         */
 /* 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.                                           */
+/*                                                                         */
 /***************************************************************************/
 
+
 #include "gxvmorx.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -46,26 +50,36 @@
   }  GXV_morx_subtable_type2_StateOptRec,
     *GXV_morx_subtable_type2_StateOptRecData;
 
-#define  GXV_MORX_SUBTABLE_TYPE2_HEADER_SIZE ( GXV_XSTATETABLE_HEADER_SIZE + 4 + 4 + 4 )
+
+#define GXV_MORX_SUBTABLE_TYPE2_HEADER_SIZE \
+          ( GXV_XSTATETABLE_HEADER_SIZE + 4 + 4 + 4 )
+
 
   static void
   gxv_morx_subtable_type2_opttable_load( FT_Bytes       table,
                                          FT_Bytes       limit,
                                          GXV_Validator  valid )
   {
-    FT_Bytes p = table;
-    GXV_morx_subtable_type2_StateOptRecData  optdata = valid->xstatetable.optdata;
+    FT_Bytes  p = table;
+
+    GXV_morx_subtable_type2_StateOptRecData  optdata =
+                                               valid->xstatetable.optdata;
+
 
     GXV_LIMIT_CHECK( 4 + 4 + 4 );
     optdata->ligActionTable = FT_NEXT_ULONG( p );
     optdata->componentTable = FT_NEXT_ULONG( p );
     optdata->ligatureTable  = FT_NEXT_ULONG( p );
 
-    GXV_TRACE(( "offset to ligActionTable=0x%08x\n", optdata->ligActionTable ));
-    GXV_TRACE(( "offset to componentTable=0x%08x\n", optdata->componentTable ));
-    GXV_TRACE(( "offset to ligatureTable=0x%08x\n",  optdata->ligatureTable ));
+    GXV_TRACE(( "offset to ligActionTable=0x%08x\n",
+                optdata->ligActionTable ));
+    GXV_TRACE(( "offset to componentTable=0x%08x\n",
+                optdata->componentTable ));
+    GXV_TRACE(( "offset to ligatureTable=0x%08x\n",
+                optdata->ligatureTable ));
   }
 
+
   static void
   gxv_morx_subtable_type2_subtable_setup( FT_ULong       table_size,
                                           FT_ULong       classTable,
@@ -79,7 +93,9 @@
     FT_ULong   o[6];
     FT_ULong*  l[6];
     FT_ULong   buff[7];
-    GXV_morx_subtable_type2_StateOptRecData  optdata = valid->xstatetable.optdata;
+
+    GXV_morx_subtable_type2_StateOptRecData  optdata =
+                                               valid->xstatetable.optdata;
 
 
     GXV_NAME_ENTER( "subtable boundaries setup" );
@@ -100,35 +116,41 @@
     gxv_set_length_by_ulong_offset( o, l, buff, 6, table_size, valid );
 
     GXV_TRACE(( "classTable: offset=0x%08x length=0x%08x\n",
-                             classTable, *classTable_length_p));
+                classTable, *classTable_length_p ));
     GXV_TRACE(( "stateArray: offset=0x%08x length=0x%08x\n",
-                             stateArray, *stateArray_length_p));
+                stateArray, *stateArray_length_p ));
     GXV_TRACE(( "entryTable: offset=0x%08x length=0x%08x\n",
-                             entryTable, *entryTable_length_p));
+                entryTable, *entryTable_length_p ));
     GXV_TRACE(( "ligActionTable: offset=0x%08x length=0x%08x\n",
-                                 optdata->ligActionTable,
-                                 optdata->ligActionTable_length));
+                optdata->ligActionTable,
+                optdata->ligActionTable_length ));
     GXV_TRACE(( "componentTable: offset=0x%08x length=0x%08x\n",
-                                 optdata->componentTable,
-                                 optdata->componentTable_length));
+                optdata->componentTable,
+                optdata->componentTable_length ));
     GXV_TRACE(( "ligatureTable:  offset=0x%08x length=0x%08x\n",
-                                 optdata->ligatureTable,
-                                 optdata->ligatureTable_length));
+                optdata->ligatureTable,
+                optdata->ligatureTable_length ));
+
     GXV_EXIT;
   }
 
-#define GXV_MORX_LIGACTION_ENTRY_SIZE 4
+
+#define GXV_MORX_LIGACTION_ENTRY_SIZE  4
 
 
   static void
-  gxv_morx_subtable_type2_ligActionIndex_validate( FT_Bytes       table,
-                                                   FT_UShort      ligActionIndex,
-                                                   GXV_Validator  valid )
+  gxv_morx_subtable_type2_ligActionIndex_validate(
+    FT_Bytes       table,
+    FT_UShort      ligActionIndex,
+    GXV_Validator  valid )
   {
     /* access ligActionTable */
-    GXV_morx_subtable_type2_StateOptRecData optdata = valid->xstatetable.optdata;
+    GXV_morx_subtable_type2_StateOptRecData optdata =
+                                              valid->xstatetable.optdata;
+
     FT_Bytes lat_base  = table + optdata->ligActionTable;
-    FT_Bytes p         = lat_base + ligActionIndex * GXV_MORX_LIGACTION_ENTRY_SIZE;
+    FT_Bytes p         = lat_base +
+                         ligActionIndex * GXV_MORX_LIGACTION_ENTRY_SIZE;
     FT_Bytes lat_limit = lat_base + optdata->ligActionTable;
 
 
@@ -152,32 +174,35 @@
 
 
       lig_action = FT_NEXT_ULONG( p );
-      last   = (lig_action & 0x80000000) / 0x80000000;
-      store  = (lig_action & 0x40000000) / 0x40000000;
-      offset =  lig_action & 0x3FFFFFFF;
-
+      last   = (lig_action & 0x80000000UL) / 0x80000000UL;
+      store  = (lig_action & 0x40000000UL) / 0x40000000UL;
+      offset =  lig_action & 0x3FFFFFFFUL;
     }
   }
 
 
   static void
-  gxv_morx_subtable_type2_entry_validate( FT_UShort      state,
-                                          FT_UShort      flags,
-                                          GXV_StateTable_GlyphOffsetDesc
-                                                         glyphOffset,
-                                          FT_Bytes       table,
-                                          FT_Bytes       limit,
-                                          GXV_Validator  valid )
+  gxv_morx_subtable_type2_entry_validate(
+    FT_UShort                       state,
+    FT_UShort                       flags,
+    GXV_StateTable_GlyphOffsetDesc  glyphOffset,
+    FT_Bytes                        table,
+    FT_Bytes                        limit,
+    GXV_Validator                   valid )
   {
-    FT_UShort setComponent;
-    FT_UShort dontAdvance;
-    FT_UShort performAction;
-    FT_UShort reserved;
-    FT_UShort ligActionIndex;
-
-    setComponent   = ( flags & 0x8000 ) / 0x8000;
-    dontAdvance    = ( flags & 0x4000 ) / 0x4000;
-    performAction  = ( flags & 0x2000 ) / 0x2000;
+    FT_UShort  setComponent;
+    FT_UShort  dontAdvance;
+    FT_UShort  performAction;
+    FT_UShort  reserved;
+    FT_UShort  ligActionIndex;
+
+    FT_UNUSED( state );
+    FT_UNUSED( limit );
+
+
+    setComponent   = ( flags & 0x8000U ) / 0x8000U;
+    dontAdvance    = ( flags & 0x4000  ) / 0x4000;
+    performAction  = ( flags & 0x2000  ) / 0x2000;
     reserved       =   flags & 0x1FFF;
     ligActionIndex = glyphOffset.u;
 
@@ -185,7 +210,8 @@
       GXV_TRACE(( "  reserved 14bit is non-zero\n" ));
 
     if ( 0 < ligActionIndex )
-      gxv_morx_subtable_type2_ligActionIndex_validate( table, ligActionIndex, valid );
+      gxv_morx_subtable_type2_ligActionIndex_validate(
+        table, ligActionIndex, valid );
   }
 
 
@@ -193,23 +219,29 @@
   gxv_morx_subtable_type2_ligatureTable_validate( FT_Bytes       table,
                                                   GXV_Validator  valid )
   {
-    GXV_morx_subtable_type2_StateOptRecData optdata = valid->xstatetable.optdata;
+    GXV_morx_subtable_type2_StateOptRecData  optdata =
+                                               valid->xstatetable.optdata;
+
     FT_Bytes p     = table + optdata->ligatureTable;
     FT_Bytes limit = table + optdata->ligatureTable
                            + optdata->ligatureTable_length;
 
+
     GXV_NAME_ENTER( "morx chain subtable type2 - substitutionTable" );
+
     if ( 0 != optdata->ligatureTable )
     {
       /* Apple does not give specification of ligatureTable format */
       while ( p < limit )
       {
-        FT_UShort lig_gid;
+        FT_UShort  lig_gid;
+
 
         GXV_LIMIT_CHECK( 2 );
         lig_gid = FT_NEXT_USHORT( p );
       }
     }
+
     GXV_EXIT;
   }
 
@@ -220,20 +252,30 @@
                                     GXV_Validator  valid )
   {
     FT_Bytes  p = table;
+
     GXV_morx_subtable_type2_StateOptRec  lig_rec;
 
+
     GXV_NAME_ENTER( "morx chain subtable type2 (Ligature Substitution)" );
 
     GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE2_HEADER_SIZE );
 
-    valid->xstatetable.optdata               = &lig_rec;
-    valid->xstatetable.optdata_load_func     = gxv_morx_subtable_type2_opttable_load;
-    valid->xstatetable.subtable_setup_func   = gxv_morx_subtable_type2_subtable_setup;
-    valid->xstatetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_USHORT;
-    valid->xstatetable.entry_validate_func   = gxv_morx_subtable_type2_entry_validate;
+    valid->xstatetable.optdata =
+      &lig_rec;
+    valid->xstatetable.optdata_load_func =
+      gxv_morx_subtable_type2_opttable_load;
+    valid->xstatetable.subtable_setup_func =
+      gxv_morx_subtable_type2_subtable_setup;
+    valid->xstatetable.entry_glyphoffset_fmt =
+      GXV_GLYPHOFFSET_USHORT;
+    valid->xstatetable.entry_validate_func =
+      gxv_morx_subtable_type2_entry_validate;
+
     gxv_XStateTable_validate( p, limit, valid );
+
     p += valid->subtable_length;
     gxv_morx_subtable_type2_ligatureTable_validate( table, valid );
+
     GXV_EXIT;
   }
 
diff --git a/src/gxvalid/gxvmorx4.c b/src/gxvalid/gxvmorx4.c
index 3b43ada..68ad746 100644
--- a/src/gxvalid/gxvmorx4.c
+++ b/src/gxvalid/gxvmorx4.c
@@ -17,13 +17,17 @@
 /***************************************************************************/
 
 /***************************************************************************/
+/*                                                                         */
 /* 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.                                           */
+/*                                                                         */
 /***************************************************************************/
 
+
 #include "gxvmorx.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -34,17 +38,18 @@
 #define FT_COMPONENT  trace_gxvmorx
 
 
- static void
- gxv_morx_subtable_type4_validate( FT_Bytes       table,
-                                   FT_Bytes       limit,
-                                   GXV_Validator  valid )
- {
-   GXV_NAME_ENTER( "morx chain subtable type4 (Non-Contextual Glyph Substitution)" );
+  static void
+  gxv_morx_subtable_type4_validate( FT_Bytes       table,
+                                    FT_Bytes       limit,
+                                    GXV_Validator  valid )
+  {
+    GXV_NAME_ENTER( "morx chain subtable type4 "
+                    "(Non-Contextual Glyph Substitution)" );
 
-   gxv_mort_subtable_type4_validate( table, limit, valid );
+    gxv_mort_subtable_type4_validate( table, limit, valid );
 
-   GXV_EXIT;
- }
+    GXV_EXIT;
+  }
 
 
 /* END */
diff --git a/src/gxvalid/gxvmorx5.c b/src/gxvalid/gxvmorx5.c
index 43f7fe9..ef5536c 100644
--- a/src/gxvalid/gxvmorx5.c
+++ b/src/gxvalid/gxvmorx5.c
@@ -17,13 +17,17 @@
 /***************************************************************************/
 
 /***************************************************************************/
+/*                                                                         */
 /* 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.                                           */
+/*                                                                         */
 /***************************************************************************/
 
+
 #include "gxvmorx.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -34,14 +38,14 @@
 #define FT_COMPONENT  trace_gxvmorx
 
 
-/*
- * morx subtable type5 (Contextual Glyph Insertion)
- * has format of StateTable with insertion-glyph-list
- * without name. however, 32bit offset from the head
- * of subtable to the i-g-l is given after "entryTable",
- * without variable name specification (the exist of
- * offset to the table is different from mort type5).
- */
+  /*
+   * `morx' subtable type5 (Contextual Glyph Insertion)
+   * has format of a StateTable with insertion-glyph-list
+   * without name.  However, the 32bit offset from the head
+   * of subtable to the i-g-l is given after `entryTable',
+   * without variable name specification (the existence of
+   * this offset to the table is different from mort type5).
+   */
 
 
   typedef struct  GXV_morx_subtable_type5_StateOptRec_
@@ -52,7 +56,10 @@
   }  GXV_morx_subtable_type5_StateOptRec,
     *GXV_morx_subtable_type5_StateOptRecData;
 
-#define  GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE ( GXV_STATETABLE_HEADER_SIZE + 4 )
+
+#define GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE \
+          ( GXV_STATETABLE_HEADER_SIZE + 4 )
+
 
   static void
   gxv_morx_subtable_type5_insertionGlyphList_load( FT_Bytes       table,
@@ -60,7 +67,9 @@
                                                    GXV_Validator  valid )
   {
     FT_Bytes  p = table;
-    GXV_morx_subtable_type5_StateOptRecData  optdata = valid->xstatetable.optdata;
+
+    GXV_morx_subtable_type5_StateOptRecData  optdata =
+                                               valid->xstatetable.optdata;
 
 
     GXV_LIMIT_CHECK( 4 );
@@ -81,7 +90,9 @@
     FT_ULong   o[4];
     FT_ULong*  l[4];
     FT_ULong   buff[5];
-    GXV_morx_subtable_type5_StateOptRecData  optdata = valid->xstatetable.optdata;
+
+    GXV_morx_subtable_type5_StateOptRecData  optdata =
+                                               valid->xstatetable.optdata;
 
 
     o[0] = classTable;
@@ -104,11 +115,12 @@
                                                FT_Bytes       limit,
                                                GXV_Validator  valid )
   {
-    FT_Bytes p = table + ( index * 2 );
+    FT_Bytes p = table + index * 2;
+
 
-    while ( p < table + ( count * 2 ) + ( index * 2 ) )
+    while ( p < table + count * 2 + index * 2 )
     {
-      FT_UShort insert_glyphID;
+      FT_UShort  insert_glyphID;
 
 
       GXV_LIMIT_CHECK( 2 );
@@ -121,13 +133,13 @@
 
 
   static void
-  gxv_morx_subtable_type5_entry_validate( FT_UShort      state,
-                                          FT_UShort      flags,
-                                          GXV_StateTable_GlyphOffsetDesc
-                                                         glyphOffset,
-                                          FT_Bytes       table,
-                                          FT_Bytes       limit,
-                                          GXV_Validator  valid )
+  gxv_morx_subtable_type5_entry_validate(
+    FT_UShort                       state,
+    FT_UShort                       flags,
+    GXV_StateTable_GlyphOffsetDesc  glyphOffset,
+    FT_Bytes                        table,
+    FT_Bytes                        limit,
+    GXV_Validator                   valid )
   {
     FT_Bool    setMark;
     FT_Bool    dontAdvance;
@@ -140,6 +152,8 @@
     FT_Byte    currentInsertList;
     FT_UShort  markedInsertList;
 
+    FT_UNUSED( state );
+
 
     setMark              = ( flags >> 15 ) & 1;
     dontAdvance          = ( flags >> 14 ) & 1;
@@ -149,24 +163,20 @@
     markedInsertBefore   = ( flags >> 10 ) & 1;
     currentInsertCount   = ( flags & 0x03E0 ) / 0x20;
     markedInsertCount    = ( flags & 0x001F );
-    currentInsertList    = glyphOffset.ul / 0x00010000;
-    markedInsertList     = glyphOffset.ul & 0x0000FFFF;
+    currentInsertList    = glyphOffset.ul / 0x00010000UL;
+    markedInsertList     = glyphOffset.ul & 0x0000FFFFUL;
 
     if ( currentInsertList && 0 != currentInsertCount )
-    {
       gxv_morx_subtable_type5_InsertList_validate( currentInsertList,
                                                    currentInsertCount,
                                                    table, limit,
                                                    valid );
-    }
 
     if ( markedInsertList && 0 != markedInsertCount )
-    {
       gxv_morx_subtable_type5_InsertList_validate( markedInsertList,
                                                    markedInsertCount,
                                                    table, limit,
                                                    valid );
-    }
   }
 
 
@@ -176,6 +186,7 @@
                                     GXV_Validator  valid )
   {
     FT_Bytes  p = table;
+
     GXV_morx_subtable_type5_StateOptRec      et_rec;
     GXV_morx_subtable_type5_StateOptRecData  et = &et_rec;
 
@@ -184,12 +195,19 @@
 
     GXV_LIMIT_CHECK( GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE );
 
-    valid->xstatetable.optdata               = et;
-    valid->xstatetable.optdata_load_func     = gxv_morx_subtable_type5_insertionGlyphList_load;
-    valid->xstatetable.subtable_setup_func   = gxv_morx_subtable_type5_subtable_setup;
-    valid->xstatetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_ULONG;
-    valid->xstatetable.entry_validate_func   = gxv_morx_subtable_type5_entry_validate;
+    valid->xstatetable.optdata =
+      et;
+    valid->xstatetable.optdata_load_func =
+      gxv_morx_subtable_type5_insertionGlyphList_load;
+    valid->xstatetable.subtable_setup_func =
+      gxv_morx_subtable_type5_subtable_setup;
+    valid->xstatetable.entry_glyphoffset_fmt =
+      GXV_GLYPHOFFSET_ULONG;
+    valid->xstatetable.entry_validate_func =
+      gxv_morx_subtable_type5_entry_validate;
+
     gxv_XStateTable_validate( p, limit, valid );
+
     GXV_EXIT;
   }