Added autoconf tests FT_MUNMAP_DECL and FT_MUNMAP_PARAM to fix some devils. Updating unix/ftsystem.c accordingly. More warning fixes.
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
diff --git a/builds/unix/aclocal.m4 b/builds/unix/aclocal.m4
index 47abe43..2da46d3 100644
--- a/builds/unix/aclocal.m4
+++ b/builds/unix/aclocal.m4
@@ -1,3 +1,31 @@
+## FreeType specific autoconf tests
+
+AC_DEFUN(FT_MUNMAP_DECL,
+[AC_MSG_CHECKING([whether munmap must be declared])
+AC_CACHE_VAL(ft_cv_munmap_decl,
+[AC_TRY_COMPILE([
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <sys/mman.h>],
+[char *(*pfn) = (char *(*))munmap],
+ft_cv_munmap_decl=no,
+ft_cv_munmap_decl=yes)])
+AC_MSG_RESULT($ft_cv_munmap_decl)
+if test $ft_cv_munmap_decl = yes; then
+ AC_DEFINE(NEED_MUNMAP_DECL)
+fi])
+
+AC_DEFUN(FT_MUNMAP_PARAM,
+[AC_MSG_CHECKING([for munmap's first parameter type])
+AC_TRY_COMPILE([
+#include <unistd.h>
+#include <sys/mman.h>
+int munmap(void *, size_t);],,
+ AC_MSG_RESULT([void *]);AC_DEFINE(MUNMAP_USES_VOIDP),
+ AC_MSG_RESULT([char *]))
+])
+
## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
## Copyright (C) 1996-1999 Free Software Foundation, Inc.
## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
diff --git a/builds/unix/configure b/builds/unix/configure
index 6080f03..1b28cde 100644
--- a/builds/unix/configure
+++ b/builds/unix/configure
@@ -1667,18 +1667,82 @@ if test "$ac_cv_func_mmap_fixed_mapped" != yes; then
FTSYS_SRC='$(BASE_)ftsystem.c'
else
FTSYS_SRC='$(BUILD)/ftsystem.c'
+
+ echo $ac_n "checking whether munmap must be declared""... $ac_c" 1>&6
+echo "configure:1673: checking whether munmap must be declared" >&5
+if eval "test \"`echo '$''{'ft_cv_munmap_decl'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1678 "configure"
+#include "confdefs.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <sys/mman.h>
+int main() {
+char *(*pfn) = (char *(*))munmap
+; return 0; }
+EOF
+if { (eval echo configure:1689: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ft_cv_munmap_decl=no
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ft_cv_munmap_decl=yes
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ft_cv_munmap_decl" 1>&6
+if test $ft_cv_munmap_decl = yes; then
+ cat >> confdefs.h <<\EOF
+#define NEED_MUNMAP_DECL 1
+EOF
+
+fi
+ echo $ac_n "checking for munmap's first parameter type""... $ac_c" 1>&6
+echo "configure:1709: checking for munmap's first parameter type" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1711 "configure"
+#include "confdefs.h"
+
+#include <unistd.h>
+#include <sys/mman.h>
+int munmap(void *, size_t);
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1721: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""void *" 1>&6;cat >> confdefs.h <<\EOF
+#define MUNMAP_USES_VOIDP 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""char *" 1>&6
+fi
+rm -f conftest*
+
fi
for ac_func in memcpy memmove
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1677: checking for $ac_func" >&5
+echo "configure:1741: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1682 "configure"
+#line 1746 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1701,7 +1765,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1705: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1798,7 +1862,7 @@ fi
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1802: checking for $ac_word" >&5
+echo "configure:1866: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1837,7 +1901,7 @@ ac_prog=ld
if test "$ac_cv_prog_gcc" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
-echo "configure:1841: checking for ld used by GCC" >&5
+echo "configure:1905: checking for ld used by GCC" >&5
ac_prog=`($CC -print-prog-name=ld) 2>&5`
case "$ac_prog" in
# Accept absolute paths.
@@ -1861,10 +1925,10 @@ echo "configure:1841: checking for ld used by GCC" >&5
esac
elif test "$with_gnu_ld" = yes; then
echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:1865: checking for GNU ld" >&5
+echo "configure:1929: checking for GNU ld" >&5
else
echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-echo "configure:1868: checking for non-GNU ld" >&5
+echo "configure:1932: checking for non-GNU ld" >&5
fi
if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1899,7 +1963,7 @@ else
fi
test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
-echo "configure:1903: checking if the linker ($LD) is GNU ld" >&5
+echo "configure:1967: checking if the linker ($LD) is GNU ld" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1915,7 +1979,7 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6
echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
-echo "configure:1919: checking for BSD-compatible nm" >&5
+echo "configure:1983: checking for BSD-compatible nm" >&5
if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1951,7 +2015,7 @@ NM="$ac_cv_path_NM"
echo "$ac_t""$NM" 1>&6
echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:1955: checking whether ln -s works" >&5
+echo "configure:2019: checking whether ln -s works" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2000,8 +2064,8 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
case "$lt_target" in
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 2004 "configure"' > conftest.$ac_ext
- if { (eval echo configure:2005: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ echo '#line 2068 "configure"' > conftest.$ac_ext
+ if { (eval echo configure:2069: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
case "`/usr/bin/file conftest.o`" in
*32-bit*)
LD="${LD-ld} -32"
@@ -2022,19 +2086,19 @@ case "$lt_target" in
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -belf"
echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
-echo "configure:2026: checking whether the C compiler needs -belf" >&5
+echo "configure:2090: checking whether the C compiler needs -belf" >&5
if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2031 "configure"
+#line 2095 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:2038: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2102: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
lt_cv_cc_needs_belf=yes
else
diff --git a/builds/unix/configure.in b/builds/unix/configure.in
index 48ef13e..139c3d0 100644
--- a/builds/unix/configure.in
+++ b/builds/unix/configure.in
@@ -68,6 +68,9 @@ if test "$ac_cv_func_mmap_fixed_mapped" != yes; then
FTSYS_SRC='$(BASE_)ftsystem.c'
else
FTSYS_SRC='$(BUILD)/ftsystem.c'
+
+ FT_MUNMAP_DECL
+ FT_MUNMAP_PARAM
fi
AC_SUBST(FTSYS_SRC)
diff --git a/builds/unix/ftsystem.c b/builds/unix/ftsystem.c
index 0f0179a..091ec09 100644
--- a/builds/unix/ftsystem.c
+++ b/builds/unix/ftsystem.c
@@ -27,7 +27,7 @@
#include <string.h>
- /* memory-mapping includes and definitions */
+ /* memory-mapping includes and definitions */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -37,17 +37,27 @@
#define MAP_FILE 0x00
#endif
- /*************************************************************************/
- /* */
- /* The prototype for munmap() is not provided on SunOS. This needs to */
- /* have a check added later to see if the GNU C library is being used. */
- /* If so, then this prototype is not needed. */
- /* */
-#if defined( __sun__ ) && !defined( SVR4 ) && !defined( __SVR4 )
- extern int munmap( caddr_t addr,
- int len );
+#ifdef MUNMAP_USES_VOIDP
+#define MUNMAP_ARG_CAST void *
+#else
+#define MUNMAP_ARG_CAST char *
#endif
+#ifdef NEED_MUNMAP_DECL
+
+#ifdef __cplusplus
+ extern "C"
+#else
+ extern
+#endif
+ int munmap( char* addr,
+ int len );
+
+#define MUNMAP_ARG_CAST char *
+
+#endif /* NEED_DECLARATION_MUNMAP */
+
+
#include <sys/stat.h>
#ifdef HAVE_FCNTL_H
@@ -182,7 +192,7 @@
static
void ft_close_stream( FT_Stream stream )
{
- munmap ( stream->descriptor.pointer, stream->size );
+ munmap( (MUNMAP_ARG_CAST)stream->descriptor.pointer, stream->size );
stream->descriptor.pointer = NULL;
stream->size = 0;
@@ -235,12 +245,12 @@
stream->size = stat_buf.st_size;
stream->pos = 0;
- stream->base = (unsigned char*)mmap( NULL,
- stream->size,
- PROT_READ,
- MAP_FILE | MAP_PRIVATE,
- file,
- 0 );
+ stream->base = (unsigned char *)mmap( NULL,
+ stream->size,
+ PROT_READ,
+ MAP_FILE | MAP_PRIVATE,
+ file,
+ 0 );
if ( (long)stream->base == -1 )
{
diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c
index 1023e3c..ba86a60 100644
--- a/src/cff/t2gload.c
+++ b/src/cff/t2gload.c
@@ -597,7 +597,6 @@
{
T2_Operator op;
FT_Byte v;
- FT_Byte count;
/********************************************************************/
@@ -841,7 +840,7 @@
goto Syntax_Error;
/* check arguments */
- req_args = count = t2_argument_counts[op];
+ req_args = t2_argument_counts[op];
if ( req_args & T2_COUNT_CHECK_WIDTH )
{
args = stack;
@@ -1534,8 +1533,8 @@
case t2_op_roll:
{
- FT_Int count = (FT_Int)( args[0] >> 16 );
- FT_Int index = (FT_Int)( args[1] >> 16 );
+ FT_Int count = (FT_Int)( args[0] >> 16 );
+ FT_Int index = (FT_Int)( args[1] >> 16 );
FT_TRACE4(( " roll" ));
@@ -1551,8 +1550,8 @@
{
while ( index > 0 )
{
- FT_Fixed tmp = args[count - 1];
- FT_Int i;
+ FT_Fixed tmp = args[count - 1];
+ FT_Int i;
for ( i = count - 2; i >= 0; i-- )
diff --git a/src/cff/t2load.c b/src/cff/t2load.c
index 9f89845..9223346 100644
--- a/src/cff/t2load.c
+++ b/src/cff/t2load.c
@@ -126,7 +126,8 @@
else
{
/* skip the data */
- (void)FILE_Skip( data_size );
+ if ( FILE_Skip( data_size ) )
+ goto Exit;
}
}
@@ -609,7 +610,8 @@
}
/* skip the rest of the header */
- (void)FILE_Skip( font->header_size - 4 );
+ if ( FILE_Skip( font->header_size - 4 ) )
+ goto Exit;
/* read the name, top dict, string and global subrs index */
error = t2_new_cff_index( &font->name_index, stream, 0 ) ||
diff --git a/src/cff/t2parse.c b/src/cff/t2parse.c
index b71b0ea..fbc4f2b 100644
--- a/src/cff/t2parse.c
+++ b/src/cff/t2parse.c
@@ -563,7 +563,6 @@
FT_Byte* qcount = (FT_Byte*)parser->object +
field->count_offset;
- FT_Long val;
FT_Byte** data = parser->stack;
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 438fe99..32338d5 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -434,7 +434,9 @@
size = *length;
stream = face->root.stream;
- (void)FILE_Read_At( offset, buffer, size );
+ /* the `if' is syntactic sugar for picky compilers */
+ if ( FILE_Read_At( offset, buffer, size ) )
+ ;
Exit:
return error;
@@ -941,7 +943,8 @@
FT_ULong upper;
- (void)READ_Fields( name_record_fields, cur );
+ if ( READ_Fields( name_record_fields, cur ) )
+ break;
upper = (FT_ULong)( cur->stringOffset + cur->stringLength );
if ( upper > storageSize )
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 7652f27..20d7a98 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -503,12 +503,11 @@
while ( count > 0 )
{
- (void)READ_Fields( strike_start_fields, strike );
-
- (void)READ_Fields( sbit_line_metrics_fields, &strike->hori );
- (void)READ_Fields( sbit_line_metrics_fields, &strike->vert );
-
- (void)READ_Fields( strike_end_fields, strike );
+ if ( READ_Fields( strike_start_fields, strike ) ||
+ READ_Fields( sbit_line_metrics_fields, &strike->hori ) ||
+ READ_Fields( sbit_line_metrics_fields, &strike->vert ) ||
+ READ_Fields( strike_end_fields, strike ) )
+ break;
count--;
strike++;
@@ -884,7 +883,8 @@
case 7:
case 9:
/* variable big metrics */
- (void)READ_Fields( sbit_metrics_fields, metrics );
+ if ( READ_Fields( sbit_metrics_fields, metrics ) )
+ goto Exit;
break;
case 5:
diff --git a/src/type1z/z1load.c b/src/type1z/z1load.c
index 1ce67d7..7877c06 100644
--- a/src/type1z/z1load.c
+++ b/src/type1z/z1load.c
@@ -576,13 +576,13 @@
/* count the number of map points */
{
- FT_Byte* p = token->start;
+ FT_Byte* ptr = token->start;
FT_Byte* limit = token->limit;
num_points = 0;
- for ( ; p < limit; p++ )
- if ( p[0] == '[' )
+ for ( ; ptr < limit; ptr++ )
+ if ( ptr[0] == '[' )
num_points++;
}
if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS )
@@ -1692,7 +1692,7 @@
for ( ; charcode < loader.encoding_table.num_elems; charcode++ )
{
type1->encoding.char_index[charcode] = 0;
- type1->encoding.char_name [charcode] = ".notdef";
+ type1->encoding.char_name [charcode] = (char *)".notdef";
char_name = loader.encoding_table.elements[charcode];
if ( char_name )
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index afba6e3..79a549e 100644
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -347,7 +347,6 @@
if ( error )
{
/* this didn't work, now try to load a single FNT font */
- FT_Memory memory = FT_FACE_MEMORY( face );
FNT_Font* font;
if ( ALLOC( face->fonts, sizeof ( *face->fonts ) ) )
@@ -423,17 +422,17 @@
root->family_name = (FT_String*)fonts->fnt_frame +
fonts->header.face_name_offset;
- root->style_name = "Regular";
+ root->style_name = (char *)"Regular";
if ( root->style_flags & FT_STYLE_FLAG_BOLD )
{
if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
- root->style_name = "Bold Italic";
+ root->style_name = (char *)"Bold Italic";
else
- root->style_name = "Bold";
+ root->style_name = (char *)"Bold";
}
else if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
- root->style_name = "Italic";
+ root->style_name = (char *)"Italic";
}
Fail: