1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-15 23:35:34 +00:00

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 <ast@cs.vu.nl>
This commit is contained in:
Jonas Fonseca 2006-08-05 00:31:29 +02:00 committed by Jonas Fonseca
parent 948d010088
commit b9908b4622
5 changed files with 15 additions and 5 deletions

View File

@ -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,

4
src/cache/cache.c vendored
View File

@ -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)

4
src/cache/dialogs.c vendored
View File

@ -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),

View File

@ -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) {

View File

@ -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