Apply fixes for cppcheck nitpicks. http://cppcheck.sourceforge.net/ Note that the current version heavily chokes on FreeType, delivering even wrong results. I will report those issues to the cppcheck team so that a newer version gives improved results hopefully. */* Improve variable scopes. */* Remove redundant initializations which get overwritten. * src/base/ftmac.c ,builds/mac/ftmac.c (count_faces_scalable): Remove unused variable. * src/base/ftdbgmem.c (ft_mem_table_destroy): `table' can't be zero. * src/gxvalid/gxvkern.c (gxv_kern_subtable_fmt1_entry_validate): Remove functionless code. * src/tools/ftrandom.c (main): Fix memory leak.
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
diff --git a/ChangeLog b/ChangeLog
index d10c8f8..a8d2e03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2013-06-04 Werner Lemberg <wl@gnu.org>
+
+ Apply fixes for cppcheck nitpicks.
+
+ http://cppcheck.sourceforge.net/
+
+ Note that the current version heavily chokes on FreeType, delivering
+ even wrong results. I will report those issues to the cppcheck team
+ so that a newer version gives improved results hopefully.
+
+ */* Improve variable scopes.
+ */* Remove redundant initializations which get overwritten.
+
+ * src/base/ftmac.c ,builds/mac/ftmac.c (count_faces_scalable):
+ Remove unused variable.
+
+ * src/base/ftdbgmem.c (ft_mem_table_destroy): `table' can't be zero.
+
+ * src/gxvalid/gxvkern.c (gxv_kern_subtable_fmt1_entry_validate):
+ Remove functionless code.
+
+ * src/tools/ftrandom.c (main): Fix memory leak.
+
2013-06-03 Werner Lemberg <wl@gnu.org>
Add CFF_CONFIG_OPTION_OLD_ENGINE configuration option.
diff --git a/builds/mac/ftmac.c b/builds/mac/ftmac.c
index 2c12e72..16d50e8 100644
--- a/builds/mac/ftmac.c
+++ b/builds/mac/ftmac.c
@@ -696,11 +696,9 @@ typedef short ResourceIndex;
count_faces_scalable( char* fond_data )
{
AsscEntry* assoc;
- FamRec* fond;
short i, face, face_all;
- fond = (FamRec*)fond_data;
face_all = EndianS16_BtoN( *( (short *)( fond_data +
sizeof ( FamRec ) ) ) ) + 1;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
@@ -1186,7 +1184,7 @@ typedef short ResourceIndex;
ResFileRefNum res_ref;
ResourceIndex res_index;
Handle fond;
- short num_faces_in_res, num_faces_in_fond;
+ short num_faces_in_res;
if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
@@ -1199,6 +1197,9 @@ typedef short ResourceIndex;
num_faces_in_res = 0;
for ( res_index = 1; ; ++res_index )
{
+ short num_faces_in_fond;
+
+
fond = Get1IndResource( TTAG_FOND, res_index );
if ( ResError() )
break;
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index ffc44fe..f69a528 100644
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -966,14 +966,15 @@
/* can make a single edge. */
if ( link )
{
- AF_Segment seg1 = edge->first;
- AF_Segment link1;
+ AF_Segment seg1 = edge->first;
FT_Pos dist2 = 0;
do
{
- link1 = seg1->link;
+ AF_Segment link1 = seg1->link;
+
+
if ( link1 )
{
dist2 = AF_SEGMENT_DIST( link, link1 );
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index bcdec50..3e41465 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -55,7 +55,7 @@
static FT_Error
af_face_globals_compute_script_coverage( AF_FaceGlobals globals )
{
- FT_Error error = FT_Err_Ok;
+ FT_Error error;
FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap;
FT_Byte* gscripts = globals->glyph_scripts;
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 12fed04..6fb86fe 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -4,7 +4,7 @@
/* */
/* Memory debugger (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2009 by */
+/* Copyright 2001-2006, 2009, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -344,85 +344,80 @@
ft_mem_table_destroy( FT_MemTable table )
{
FT_ULong i;
+ FT_Long leak_count = 0;
+ FT_ULong leaks = 0;
FT_DumpMemory( table->memory );
- if ( table )
+ /* remove all blocks from the table, revealing leaked ones */
+ for ( i = 0; i < table->size; i++ )
{
- FT_Long leak_count = 0;
- FT_ULong leaks = 0;
+ FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
- /* remove all blocks from the table, revealing leaked ones */
- for ( i = 0; i < table->size; i++ )
+ while ( node )
{
- FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
+ next = node->link;
+ node->link = 0;
-
- while ( node )
+ if ( node->size > 0 )
{
- next = node->link;
- node->link = 0;
-
- if ( node->size > 0 )
- {
- printf(
- "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
- node->address, node->size,
- FT_FILENAME( node->source->file_name ),
- node->source->line_no );
+ printf(
+ "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
+ node->address, node->size,
+ FT_FILENAME( node->source->file_name ),
+ node->source->line_no );
- leak_count++;
- leaks += node->size;
+ leak_count++;
+ leaks += node->size;
- ft_mem_table_free( table, node->address );
- }
+ ft_mem_table_free( table, node->address );
+ }
- node->address = NULL;
- node->size = 0;
+ node->address = NULL;
+ node->size = 0;
- ft_mem_table_free( table, node );
- node = next;
- }
- table->buckets[i] = 0;
+ ft_mem_table_free( table, node );
+ node = next;
}
+ table->buckets[i] = 0;
+ }
- ft_mem_table_free( table, table->buckets );
- table->buckets = NULL;
-
- table->size = 0;
- table->nodes = 0;
+ ft_mem_table_free( table, table->buckets );
+ table->buckets = NULL;
- /* remove all sources */
- for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
- {
- FT_MemSource source, next;
+ table->size = 0;
+ table->nodes = 0;
+ /* remove all sources */
+ for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
+ {
+ FT_MemSource source, next;
- for ( source = table->sources[i]; source != NULL; source = next )
- {
- next = source->link;
- ft_mem_table_free( table, source );
- }
- table->sources[i] = NULL;
+ for ( source = table->sources[i]; source != NULL; source = next )
+ {
+ next = source->link;
+ ft_mem_table_free( table, source );
}
- printf(
- "FreeType: total memory allocations = %ld\n", table->alloc_total );
- printf(
- "FreeType: maximum memory footprint = %ld\n", table->alloc_max );
+ table->sources[i] = NULL;
+ }
- ft_mem_table_free( table, table );
+ printf( "FreeType: total memory allocations = %ld\n",
+ table->alloc_total );
+ printf( "FreeType: maximum memory footprint = %ld\n",
+ table->alloc_max );
- if ( leak_count > 0 )
- ft_mem_debug_panic(
- "FreeType: %ld bytes of memory leaked in %ld blocks\n",
- leaks, leak_count );
+ ft_mem_table_free( table, table );
- printf( "FreeType: no memory leaks detected\n" );
- }
+ if ( leak_count > 0 )
+ ft_mem_debug_panic(
+ "FreeType: %ld bytes of memory leaked in %ld blocks\n",
+ leaks, leak_count );
+
+ printf( "FreeType: no memory leaks detected\n" );
}
diff --git a/src/base/ftmac.c b/src/base/ftmac.c
index 456b1a5..5b5aae6 100644
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -358,11 +358,9 @@
count_faces_scalable( char* fond_data )
{
AsscEntry* assoc;
- FamRec* fond;
short i, face, face_all;
- fond = (FamRec*)fond_data;
face_all = EndianS16_BtoN( *( (short *)( fond_data +
sizeof ( FamRec ) ) ) ) + 1;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
@@ -800,7 +798,7 @@
ResFileRefNum res_ref;
ResourceIndex res_index;
Handle fond;
- short num_faces_in_res, num_faces_in_fond;
+ short num_faces_in_res;
if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
@@ -813,6 +811,9 @@
num_faces_in_res = 0;
for ( res_index = 1; ; ++res_index )
{
+ short num_faces_in_fond;
+
+
fond = Get1IndResource( TTAG_FOND, res_index );
if ( ResError() )
break;
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 9206479..b02d643 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -520,7 +520,7 @@
unsigned long *alen )
{
unsigned long i, j;
- char *fp, *dp;
+ char* dp;
*alen = 0;
@@ -531,7 +531,9 @@
dp = list->field[0];
for ( i = j = 0; i < list->used; i++ )
{
- fp = list->field[i];
+ char* fp = list->field[i];
+
+
while ( *fp )
dp[j++] = *fp++;
diff --git a/src/cff/cf2font.c b/src/cff/cf2font.c
index 69642b2..0a5bb42 100644
--- a/src/cff/cf2font.c
+++ b/src/cff/cf2font.c
@@ -143,7 +143,7 @@
/* pointer to parsed font object */
CFF_Decoder* decoder = font->decoder;
- FT_Bool needExtraSetup = FALSE;
+ FT_Bool needExtraSetup;
/* character space units */
CF2_Fixed boldenX = font->syntheticEmboldeningAmountX;
diff --git a/src/gxvalid/gxvkern.c b/src/gxvalid/gxvkern.c
index 0ec978f..557c5f1 100644
--- a/src/gxvalid/gxvkern.c
+++ b/src/gxvalid/gxvkern.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT kern table validation (body). */
/* */
-/* Copyright 2004, 2005, 2006, 2007 */
+/* Copyright 2004-2007, 2013 */
/* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -303,8 +303,6 @@
#ifdef GXV_LOAD_UNUSED_VARS
kernAction = FT_NEXT_USHORT( p );
kernValue = FT_NEXT_USHORT( p );
-#else
- p += 4;
#endif
}
}
diff --git a/src/gxvalid/gxvmod.c b/src/gxvalid/gxvmod.c
index 58a82d0..278d476 100644
--- a/src/gxvalid/gxvmod.c
+++ b/src/gxvalid/gxvmod.c
@@ -200,7 +200,7 @@
/* without volatile on `error' GCC 4.1.1. emits: */
/* warning: variable 'error' might be clobbered by 'longjmp' or 'vfork' */
/* this warning seems spurious but --- */
- FT_Error volatile error = FT_Err_Ok;
+ FT_Error volatile error;
FT_ValidatorRec volatile valid;
diff --git a/src/gxvalid/gxvmort.c b/src/gxvalid/gxvmort.c
index 465462a..5356e67 100644
--- a/src/gxvalid/gxvmort.c
+++ b/src/gxvalid/gxvmort.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT mort table validation (body). */
/* */
-/* Copyright 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
+/* Copyright 2005, 2013 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -163,14 +163,15 @@
};
- GXV_Validate_Func func;
- FT_UShort i;
+ FT_UShort i;
GXV_NAME_ENTER( "subtables in a chain" );
for ( i = 0; i < nSubtables; i++ )
{
+ GXV_Validate_Func func;
+
FT_UShort length;
FT_UShort coverage;
#ifdef GXV_LOAD_UNUSED_VARS
diff --git a/src/gxvalid/gxvmorx.c b/src/gxvalid/gxvmorx.c
index 4b1dd00..5ae04d3 100644
--- a/src/gxvalid/gxvmorx.c
+++ b/src/gxvalid/gxvmorx.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT morx table validation (body). */
/* */
-/* Copyright 2005, 2008 by */
+/* Copyright 2005, 2008, 2013 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -57,8 +57,6 @@
};
- GXV_Validate_Func func;
-
FT_UShort i;
@@ -66,6 +64,8 @@
for ( i = 0; i < nSubtables; i++ )
{
+ GXV_Validate_Func func;
+
FT_ULong length;
FT_ULong coverage;
#ifdef GXV_LOAD_UNUSED_VARS
diff --git a/src/lzw/ftlzw.c b/src/lzw/ftlzw.c
index c7dd66a..82e6c00 100644
--- a/src/lzw/ftlzw.c
+++ b/src/lzw/ftlzw.c
@@ -111,7 +111,7 @@
FT_Stream source )
{
FT_LzwState lzw = &zip->lzw;
- FT_Error error = FT_Err_Ok;
+ FT_Error error;
zip->stream = stream;
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 4b822f7..3c1bb7d 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -92,7 +92,7 @@ THE SOFTWARE.
PCF_Toc toc = &face->toc;
PCF_Table tables;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_UInt n;
@@ -402,7 +402,7 @@ THE SOFTWARE.
FT_ULong nprops, i;
FT_ULong format, size;
FT_Error error;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_ULong string_size;
FT_String* strings = 0;
@@ -566,10 +566,10 @@ THE SOFTWARE.
pcf_get_metrics( FT_Stream stream,
PCF_Face face )
{
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Error error;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_ULong format, size;
- PCF_Metric metrics = 0;
+ PCF_Metric metrics = 0;
FT_ULong nmetrics, i;
@@ -663,8 +663,8 @@ THE SOFTWARE.
pcf_get_bitmaps( FT_Stream stream,
PCF_Face face )
{
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Error error;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_Long* offsets = NULL;
FT_Long bitmapSizes[GLYPHPADOPTIONS];
FT_ULong format, size;
@@ -765,8 +765,8 @@ THE SOFTWARE.
pcf_get_encodings( FT_Stream stream,
PCF_Face face )
{
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Error error;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_ULong format, size;
int firstCol, lastCol;
int firstRow, lastRow;
@@ -914,7 +914,7 @@ THE SOFTWARE.
FT_ULong type )
{
FT_ULong format, size;
- FT_Error error = FT_Err_Ok;
+ FT_Error error;
PCF_Accel accel = &face->accel;
@@ -1014,20 +1014,20 @@ THE SOFTWARE.
( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
{
face->style_flags |= FT_STYLE_FLAG_BOLD;
- strings[1] = (char *)"Bold";
+ strings[1] = (char*)"Bold";
}
prop = pcf_find_property( pcf, "SETWIDTH_NAME" );
if ( prop && prop->isString &&
*(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
- strings[3] = (char *)(prop->value.atom);
+ strings[3] = (char*)( prop->value.atom );
prop = pcf_find_property( pcf, "ADD_STYLE_NAME" );
if ( prop && prop->isString &&
*(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
- strings[0] = (char *)(prop->value.atom);
+ strings[0] = (char*)( prop->value.atom );
for ( len = 0, nn = 0; nn < 4; nn++ )
{
@@ -1041,7 +1041,7 @@ THE SOFTWARE.
if ( len == 0 )
{
- strings[0] = (char *)"Regular";
+ strings[0] = (char*)"Regular";
lengths[0] = ft_strlen( strings[0] );
len = lengths[0] + 1;
}
@@ -1079,7 +1079,7 @@ THE SOFTWARE.
for ( mm = 0; mm < len; mm++ )
- if (s[mm] == ' ')
+ if ( s[mm] == ' ' )
s[mm] = '-';
}
@@ -1097,7 +1097,7 @@ THE SOFTWARE.
PCF_Face face )
{
FT_Error error = FT_Err_Ok;
- FT_Memory memory = FT_FACE(face)->memory;
+ FT_Memory memory = FT_FACE( face )->memory;
FT_Bool hasBDFAccelerators;
diff --git a/src/psaux/afmparse.c b/src/psaux/afmparse.c
index abec503..6a40e11 100644
--- a/src/psaux/afmparse.c
+++ b/src/psaux/afmparse.c
@@ -120,7 +120,6 @@
afm_stream_read_one( AFM_Stream stream )
{
char* str;
- int ch;
afm_stream_skip_spaces( stream );
@@ -131,7 +130,9 @@
while ( 1 )
{
- ch = AFM_GETC();
+ int ch = AFM_GETC();
+
+
if ( AFM_IS_SPACE( ch ) )
break;
else if ( AFM_IS_NEWLINE( ch ) )
@@ -160,7 +161,6 @@
afm_stream_read_string( AFM_Stream stream )
{
char* str;
- int ch;
afm_stream_skip_spaces( stream );
@@ -172,7 +172,9 @@
/* scan to eol */
while ( 1 )
{
- ch = AFM_GETC();
+ int ch = AFM_GETC();
+
+
if ( AFM_IS_NEWLINE( ch ) )
{
stream->status = AFM_STREAM_STATUS_EOL;
diff --git a/src/pshinter/pshalgo.c b/src/pshinter/pshalgo.c
index 9a1311b..343472d 100644
--- a/src/pshinter/pshalgo.c
+++ b/src/pshinter/pshalgo.c
@@ -401,13 +401,13 @@
FT_Fixed delta,
FT_Int dimension )
{
- PSH_Hint hint;
- FT_UInt count;
+ FT_UInt count;
for ( count = 0; count < table->max_hints; count++ )
{
- hint = table->hints + count;
+ PSH_Hint hint = table->hints + count;
+
hint->cur_pos = FT_MulFix( hint->org_pos, scale ) + delta;
hint->cur_len = FT_MulFix( hint->org_len, scale );
diff --git a/src/pshinter/pshrec.c b/src/pshinter/pshrec.c
index 3f41a65..cd66ea8 100644
--- a/src/pshinter/pshrec.c
+++ b/src/pshinter/pshrec.c
@@ -316,7 +316,7 @@
FT_UInt bit_count,
FT_Memory memory )
{
- FT_Error error = FT_Err_Ok;
+ FT_Error error;
PS_Mask mask;
@@ -583,12 +583,13 @@
FT_UInt end_point )
{
FT_UInt count = dim->masks.num_masks;
- PS_Mask mask;
if ( count > 0 )
{
- mask = dim->masks.masks + count - 1;
+ PS_Mask mask = dim->masks.masks + count - 1;
+
+
mask->end_point = end_point;
}
}
@@ -621,7 +622,7 @@
FT_UInt end_point,
FT_Memory memory )
{
- FT_Error error = FT_Err_Ok;
+ FT_Error error;
/* reset current mask, if any */
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index 01c1a7e..d214806 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -806,8 +806,7 @@
static Bool
End_Profile( RAS_ARGS Bool overshoot )
{
- Long h;
- PProfile oldProfile;
+ Long h;
h = (Long)( ras.top - ras.cProfile->offset );
@@ -821,6 +820,9 @@
if ( h > 0 )
{
+ PProfile oldProfile;
+
+
FT_TRACE6(( "Ending profile %p, start = %ld, height = %ld\n",
ras.cProfile, ras.cProfile->start, h ));
@@ -877,7 +879,7 @@
Insert_Y_Turn( RAS_ARGS Int y )
{
PLong y_turns;
- Int y2, n;
+ Int n;
n = ras.numTurns - 1;
@@ -891,7 +893,9 @@
if ( n >= 0 && y > y_turns[n] )
while ( n >= 0 )
{
- y2 = (Int)y_turns[n];
+ Int y2 = (Int)y_turns[n];
+
+
y_turns[n] = y;
y = y2;
n--;
@@ -927,7 +931,6 @@
static Bool
Finalize_Profile_Table( RAS_ARG )
{
- Int bottom, top;
UShort n;
PProfile p;
@@ -939,6 +942,9 @@
{
while ( n > 0 )
{
+ Int bottom, top;
+
+
if ( n > 1 )
p->link = (PProfile)( p->offset + p->height );
else
@@ -2032,8 +2038,6 @@
int i;
unsigned start;
- PProfile lastProfile;
-
ras.fProfile = NULL;
ras.joint = FALSE;
@@ -2051,7 +2055,8 @@
for ( i = 0; i < ras.outline.n_contours; i++ )
{
- Bool o;
+ PProfile lastProfile;
+ Bool o;
ras.state = Unknown_State;
@@ -2275,8 +2280,6 @@
PProfile right )
{
Long e1, e2;
- int c1, c2;
- Byte f1, f2;
Byte* target;
FT_UNUSED( y );
@@ -2295,6 +2298,10 @@
if ( e2 >= 0 && e1 < ras.bWidth )
{
+ int c1, c2;
+ Byte f1, f2;
+
+
if ( e1 < 0 )
e1 = 0;
if ( e2 >= ras.bWidth )
@@ -2518,21 +2525,24 @@
PProfile left,
PProfile right )
{
- Long e1, e2;
- PByte bits;
- Byte f1;
-
FT_UNUSED( left );
FT_UNUSED( right );
if ( x2 - x1 < ras.precision )
{
+ Long e1, e2;
+ Byte f1;
+
+
e1 = CEILING( x1 );
e2 = FLOOR ( x2 );
if ( e1 == e2 )
{
+ PByte bits;
+
+
bits = ras.bTarget + ( y >> 3 );
f1 = (Byte)( 0x80 >> ( y & 7 ) );
@@ -2729,8 +2739,6 @@
static void
Vertical_Gray_Sweep_Step( RAS_ARG )
{
- Int c1, c2;
- PByte pix, bit, bit2;
short* count = (short*)count_table;
Byte* grays;
@@ -2739,6 +2747,9 @@
if ( ras.traceOfs > ras.gray_width )
{
+ PByte pix;
+
+
pix = ras.gTarget + ras.traceG + ras.gray_min_x * 4;
grays = ras.grays;
@@ -2749,6 +2760,9 @@
Int last_bit = last_pixel & 3;
Bool over = 0;
+ Int c1, c2;
+ PByte bit, bit2;
+
if ( ras.gray_max_x >= last_cell && last_bit != 3 )
{
@@ -2841,7 +2855,6 @@
{
Long e1, e2;
PByte pixel;
- Byte color;
/* During the horizontal sweep, we only take care of drop-outs */
@@ -2895,6 +2908,9 @@
if ( e1 >= 0 )
{
+ Byte color;
+
+
if ( x2 - x1 >= ras.precision_half )
color = ras.grays[2];
else
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index de2bc01..d2158e7 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -630,7 +630,7 @@ typedef ptrdiff_t FT_PtrDist;
TPos x2,
TCoord y2 )
{
- TCoord ex1, ex2, fx1, fx2, delta, mod, lift, rem;
+ TCoord ex1, ex2, fx1, fx2, delta, mod;
long p, first, dx;
int incr;
@@ -691,6 +691,9 @@ typedef ptrdiff_t FT_PtrDist;
if ( ex1 != ex2 )
{
+ TCoord lift, rem;
+
+
p = ONE_PIXEL * ( y2 - y1 + delta );
lift = (TCoord)( p / dx );
rem = (TCoord)( p % dx );
@@ -1257,9 +1260,7 @@ typedef ptrdiff_t FT_PtrDist;
TPos area,
TCoord acount )
{
- FT_Span* span;
- int count;
- int coverage;
+ int coverage;
/* compute the coverage line's coverage, depending on the */
@@ -1301,6 +1302,10 @@ typedef ptrdiff_t FT_PtrDist;
if ( coverage )
{
+ FT_Span* span;
+ int count;
+
+
/* see whether we can add this span to the current list */
count = ras.num_gray_spans;
span = ras.gray_spans + count - 1;
diff --git a/src/tools/apinames.c b/src/tools/apinames.c
index f940859..c85df72 100644
--- a/src/tools/apinames.c
+++ b/src/tools/apinames.c
@@ -155,8 +155,6 @@ names_dump( FILE* out,
case OUTPUT_WATCOM_LBC:
{
- /* we must omit the .dll suffix from the library name */
- char temp[512];
const char* dot;
@@ -167,10 +165,12 @@ names_dump( FILE* out,
exit( 4 );
}
+ /* we must omit the .dll suffix from the library name */
dot = strchr( dll_name, '.' );
if ( dot != NULL )
{
- int len = dot - dll_name;
+ char temp[512];
+ int len = dot - dll_name;
if ( len > (int)( sizeof ( temp ) - 1 ) )
diff --git a/src/tools/ftrandom/ftrandom.c b/src/tools/ftrandom/ftrandom.c
index 4daac0d..7c97957 100644
--- a/src/tools/ftrandom/ftrandom.c
+++ b/src/tools/ftrandom/ftrandom.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2007, 2008 by George Williams */
+/* Copyright (C) 2005, 2007, 2008, 2013 by George Williams */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -184,7 +184,6 @@
{
FT_Library context;
FT_Face face;
- int i, num;
if ( FT_Init_FreeType( &context ) )
@@ -203,6 +202,9 @@
TestFace( face );
else
{
+ int i, num;
+
+
num = face->num_faces;
FT_Done_Face( face );
@@ -327,12 +329,9 @@
FindFonts( char** fontdirs,
char** extensions )
{
- DIR* examples;
- struct dirent* ent;
-
- int i, max;
- char buffer[1025];
- struct stat statb;
+ int i, max;
+ char buffer[1025];
+ struct stat statb;
max = 0;
@@ -340,6 +339,10 @@
for ( i = 0; fontdirs[i] != NULL; ++i )
{
+ DIR* examples;
+ struct dirent* ent;
+
+
examples = opendir( fontdirs[i] );
if ( examples == NULL )
{
@@ -555,7 +558,6 @@
char** argv )
{
char **dirs, **exts;
- char *pt, *end;
int dcnt = 0, ecnt = 0, rset = false, allexts = false;
int i;
time_t now;
@@ -567,7 +569,10 @@
for ( i = 1; i < argc; ++i )
{
- pt = argv[i];
+ char* pt = argv[i];
+ char* end;
+
+
if ( pt[0] == '-' && pt[1] == '-' )
++pt;
@@ -633,12 +638,21 @@
}
if ( allexts )
+ {
+ free( exts );
exts = NULL;
+ }
else if ( ecnt == 0 )
+ {
+ free( exts );
exts = default_ext_list;
+ }
if ( dcnt == 0 )
+ {
+ free( dirs );
dirs = default_dir_list;
+ }
if ( testfile != NULL )
ExecuteTest( testfile ); /* This should never return */
diff --git a/src/tools/test_trig.c b/src/tools/test_trig.c
index 451e999..d1dec7e 100644
--- a/src/tools/test_trig.c
+++ b/src/tools/test_trig.c
@@ -17,12 +17,15 @@
static void
test_cos( void )
{
- FT_Fixed f1, f2;
- double d1, d2;
- int i;
+ int i;
+
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
+ FT_Fixed f1, f2;
+ double d1, d2;
+
+
f1 = FT_Cos(i);
d1 = f1/65536.0;
d2 = cos( i*SPI );
@@ -38,16 +41,18 @@
}
-
static void
test_sin( void )
{
- FT_Fixed f1, f2;
- double d1, d2;
- int i;
+ int i;
+
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
+ FT_Fixed f1, f2;
+ double d1, d2;
+
+
f1 = FT_Sin(i);
d1 = f1/65536.0;
d2 = sin( i*SPI );
@@ -66,12 +71,15 @@
static void
test_tan( void )
{
- FT_Fixed f1, f2;
- double d1, d2;
- int i;
+ int i;
+
for ( i = 0; i < FT_ANGLE_PI2-0x2000000; i += 0x10000 )
{
+ FT_Fixed f1, f2;
+ double d1, d2;
+
+
f1 = FT_Tan(i);
d1 = f1/65536.0;
d2 = tan( i*SPI );
@@ -90,12 +98,16 @@
static void
test_atan2( void )
{
- FT_Fixed c2, s2;
- double l, a, c1, s1;
- int i, j;
+ int i;
+
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
+ FT_Fixed c2, s2;
+ double l, a, c1, s1;
+ int j;
+
+
l = 5.0;
a = i*SPI;
@@ -117,16 +129,20 @@
}
}
+
static void
test_unit( void )
{
- FT_Vector v;
- double a, c1, s1;
- FT_Fixed c2, s2;
- int i;
+ int i;
+
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
+ FT_Vector v;
+ double a, c1, s1;
+ FT_Fixed c2, s2;
+
+
FT_Vector_Unit( &v, i );
a = ( i*SPI );
c1 = cos(a);
@@ -150,12 +166,15 @@
static void
test_length( void )
{
- FT_Vector v;
- FT_Fixed l, l2;
- int i;
+ int i;
+
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
+ FT_Vector v;
+ FT_Fixed l, l2;
+
+
l = (FT_Fixed)(500.0*65536.0);
v.x = (FT_Fixed)( l * cos( i*SPI ) );
v.y = (FT_Fixed)( l * sin( i*SPI ) );
@@ -174,19 +193,27 @@
static void
test_rotate( void )
{
- FT_Fixed c2, s2, c4, s4;
- FT_Vector v;
- double l, ra, a, c1, s1, cra, sra, c3, s3;
- int i, j, rotate;
+ int rotate;
+
for ( rotate = 0; rotate < FT_ANGLE_2PI; rotate += 0x10000 )
{
+ double ra, cra, sra;
+ int i;
+
+
ra = rotate*SPI;
cra = cos( ra );
sra = sin( ra );
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
+ FT_Fixed c2, s2, c4, s4;
+ FT_Vector v;
+ double l, a, c1, s1, c3, s3;
+ int j;
+
+
l = 500.0;
a = i*SPI;
diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c
index b2db9bf..de9c199 100644
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -122,7 +122,6 @@
start = (FT_Byte*)stream->cursor;
limit = (FT_Byte*)stream->limit;
- p = start;
/* Figure out how long the width table is. */
/* This info is a little-endian short at offset 99. */
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index a5a8c3c..f96faa9 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -69,13 +69,13 @@
t1_get_name_index( T1_Face face,
FT_String* glyph_name )
{
- FT_Int i;
- FT_String* gname;
+ FT_Int i;
for ( i = 0; i < face->type1.num_glyphs; i++ )
{
- gname = face->type1.glyph_names[i];
+ FT_String* gname = face->type1.glyph_names[i];
+
if ( !ft_strcmp( glyph_name, gname ) )
return (FT_UInt)i;
diff --git a/src/type42/t42drivr.c b/src/type42/t42drivr.c
index 7e5e5a2..3ad1bde 100644
--- a/src/type42/t42drivr.c
+++ b/src/type42/t42drivr.c
@@ -72,13 +72,13 @@
t42_get_name_index( T42_Face face,
FT_String* glyph_name )
{
- FT_Int i;
- FT_String* gname;
+ FT_Int i;
for ( i = 0; i < face->type1.num_glyphs; i++ )
{
- gname = face->type1.glyph_names[i];
+ FT_String* gname = face->type1.glyph_names[i];
+
if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) )
return (FT_UInt)ft_atol( (const char *)face->type1.charstrings[i] );
diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c
index fd18b25..18e2c0b 100644
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -93,7 +93,6 @@
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
- FT_Byte* char_name;
FT_Byte* glyph_name;
@@ -109,6 +108,9 @@
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
+ FT_Byte* char_name;
+
+
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";