From b9908b462225a5812e88108d4c6e9c20f5ed04ec Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 5 Aug 2006 00:31:29 +0200 Subject: [PATCH] Use internal OFF_T_FORMAT instead of PRId64 ... since the latter is for printing int64_T and we don't check for that and we use PRId64 only for printing values having the off_t types. Besides off_t has it's own ELinks specific defaults so it should be safer to use an internal format string. If off_t is 8 bytes use "lld" else use "ld". Reported-by: Andy Tanenbaum --- configure.in | 2 ++ src/cache/cache.c | 4 ++-- src/cache/dialogs.c | 4 ++-- src/dialogs/document.c | 2 +- src/osdep/types.h | 8 ++++++++ 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/configure.in b/configure.in index cb2cd8e1..a15a01d5 100644 --- a/configure.in +++ b/configure.in @@ -209,6 +209,7 @@ AC_TYPE_SIZE_T AC_TYPE_OFF_T EL_CHECK_TYPE(ssize_t, int) EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, []) +EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, []) EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T) EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T) EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T) @@ -218,6 +219,7 @@ AC_CHECK_SIZEOF(short, 2) AC_CHECK_SIZEOF(int, 4) AC_CHECK_SIZEOF(long, 4) test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8) +test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4) dnl Check for variadic macros EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS, diff --git a/src/cache/cache.c b/src/cache/cache.c index 9bcafbd0..ea1185a3 100644 --- a/src/cache/cache.c +++ b/src/cache/cache.c @@ -39,8 +39,8 @@ static void truncate_entry(struct cache_entry *cached, off_t offset, int final); #define dump_frag(frag, count) \ do { \ - DBG(" [%d] f=%p offset=%" PRId64 " length=%" PRId64 \ - " real_length=%" PRId64, \ + DBG(" [%d] f=%p offset=%" OFF_T_FORMAT " length=%" OFF_T_FORMAT \ + " real_length=%" OFF_T_FORMAT, \ count, frag, frag->offset, frag->length, frag->real_length); \ } while (0) diff --git a/src/cache/dialogs.c b/src/cache/dialogs.c index b1a5f0e5..5a2dc985 100644 --- a/src/cache/dialogs.c +++ b/src/cache/dialogs.c @@ -82,9 +82,9 @@ get_cache_entry_info(struct listbox_item *item, struct terminal *term) } } - add_format_to_string(&msg, "\n%s: %" PRId64, _("Size", term), + add_format_to_string(&msg, "\n%s: %" OFF_T_FORMAT, _("Size", term), cached->length); - add_format_to_string(&msg, "\n%s: %" PRId64, _("Loaded size", term), + add_format_to_string(&msg, "\n%s: %" OFF_T_FORMAT, _("Loaded size", term), cached->data_size); if (cached->content_type) { add_format_to_string(&msg, "\n%s: %s", _("Content type", term), diff --git a/src/dialogs/document.c b/src/dialogs/document.c index 82e4ee1c..5600dbc0 100644 --- a/src/dialogs/document.c +++ b/src/dialogs/document.c @@ -152,7 +152,7 @@ document_info_dialog(struct session *ses) if (cached) { unsigned char *a; - add_format_to_string(&msg, "\n%s: %" PRId64, + add_format_to_string(&msg, "\n%s: %" OFF_T_FORMAT, _("Size", term), cached->length); if (cached->incomplete) { diff --git a/src/osdep/types.h b/src/osdep/types.h index d64a1c13..9d0f2820 100644 --- a/src/osdep/types.h +++ b/src/osdep/types.h @@ -124,4 +124,12 @@ typedef unsigned long long uint32_t; */ typedef long longptr_T; +/* Define internal off_t format macro for printing variables. */ +#if HAVE_OFF_T == 1 && SIZEOF_OFF_T == 8 +#define OFF_T_FORMAT "lld" +#else +/* For ELinks, off_t defaults to long. */ +#define OFF_T_FORMAT "ld" +#endif + #endif