bug with large files
Oswald Buddenhagen
ossi at kde.org
Wed Nov 24 10:36:14 UTC 2004
On Wed, Nov 24, 2004 at 09:57:53AM +0100, Jindrich Novy wrote:
> > Source date: Nov 23 06:20, size 349060957
> > Target date: Nov 22 06:09, size 1899835145
> >
> The following patch fixes it.
>
it can't. sizeof(unsigned) == sizeof(unsigned long) on x86.
%llu is the right format.
i have such code in one of my projects:
configure.ac:
AC_CACHE_CHECK([whether off_t can be long long], ob_cv_type_off_t_ll, [
AC_TRY_RUN([#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
#include <stdlib.h>
int main()
{
if (sizeof(long long) == sizeof(long))
exit(1);
if (sizeof(off_t) != sizeof(long long))
exit(1);
exit(0);
}], ob_cv_type_off_t_ll=yes, ob_cv_type_off_t_ll=no)])
if test $ob_cv_type_off_t_ll = yes; then
AC_CACHE_CHECK([whether \"%lli\" works], ob_cv_func_printf_ok, [
AC_TRY_RUN([#include <stdio.h>
int main()
{
char ts[20];
sprintf(ts, "%lli", 1234567890123LL);
exit(strcmp(ts, "1234567890123"));
}], ob_cv_func_printf_ok=yes, ob_cv_func_printf_ok=no)])
if test $ob_cv_func_printf_ok = yes; then
AC_DEFINE(USE_LL, 1, [Defined if long long should be used for file offsets])
else
AC_MSG_WARN([your c library fails to format long long int correctly.
64 bit file offsets were disabled.])
fi
fi
c file:
#include <config.h>
#ifdef USE_LL
# define _FILE_OFFSET_BITS 64
# define SSOFFT "lli"
#else
# define SSOFFT "li"
#endif
#define SOFFT "%"SSOFFT
#include <sys/types.h> // off_t
#include <unistd.h> // lseek, etc.
off_t off;
printf(SOFFT "\n", off)
printf("%20" SSOFFT "\n", off)
--
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
More information about the mc-devel
mailing list