From 6b02648ff2bedd962567734ca895916a2ec805a8 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 22 Nov 2007 00:44:50 +0000 Subject: [PATCH] 2007-11-22 01:44 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/fssize.c * harbour/source/rtl/hbffind.c * harbour/source/rtl/filesys.c * set _LARGEFILE64_SOURCE in all builds and use HB_USE_LARGEFILE64 macro (set automatically when __USE_LARGEFILE64 is defined too or HB_OS_HPUX && O_LARGEFILE) to enable large file support in 32 bit POSIX systems. It should help to enable large file support in other then Linux different 32 bit *nixes. I hope it will resolve Sandro problems with HPUX. * harbour/source/vm/itemapi.c * do not return DATE item value in hb_itemGetNDDec() It was old and unused xHarbour only code - now hb_itemGetNDDec() is compatible with hb_itemGetND() * harbour/source/rtl/seconds.c ! fixed typo in BSD builds BTW can someone test current SVN code with Solaris? I will not be able to make such test myself in the nearest few weeks. --- harbour/ChangeLog | 21 ++++++++++++++++ harbour/source/rtl/filesys.c | 47 +++++++++++++++--------------------- harbour/source/rtl/fssize.c | 23 ++++++++++++------ harbour/source/rtl/hbffind.c | 22 +++++++++++------ harbour/source/rtl/seconds.c | 2 +- harbour/source/vm/itemapi.c | 7 +----- 6 files changed, 73 insertions(+), 49 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d82a616b0a..2417af643e 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,27 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-11-22 01:44 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/fssize.c + * harbour/source/rtl/hbffind.c + * harbour/source/rtl/filesys.c + * set _LARGEFILE64_SOURCE in all builds and use HB_USE_LARGEFILE64 + macro (set automatically when __USE_LARGEFILE64 is defined too or + HB_OS_HPUX && O_LARGEFILE) to enable large file support in 32 bit + POSIX systems. It should help to enable large file support in other + then Linux different 32 bit *nixes. + I hope it will resolve Sandro problems with HPUX. + + * harbour/source/vm/itemapi.c + * do not return DATE item value in hb_itemGetNDDec() + It was old and unused xHarbour only code - now hb_itemGetNDDec() + is compatible with hb_itemGetND() + + * harbour/source/rtl/seconds.c + ! fixed typo in BSD builds + BTW can someone test current SVN code with Solaris? + I will not be able to make such test myself in the nearest few weeks. + 2007-11-21 21:45 UTC+0100 Marek Paliwoda (mpaliwoda at interia pl) * harbour/contrib/mtpl_defs.mak * harbour/contrib/mtpl_b32.mak diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index bfe021bd6a..2f827370b5 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -90,7 +90,7 @@ This has been corrected by ptucker */ -#if defined(HB_OS_LINUX) +#if !defined( _LARGEFILE64_SOURCE ) # define _LARGEFILE64_SOURCE #endif @@ -166,9 +166,7 @@ #include #endif -#if defined(HB_OS_HPUX) - extern int fdatasync(int fildes); -#elif defined(HB_OS_DOS) +#if defined(HB_OS_DOS) #include #elif defined(HB_OS_OS2) #include @@ -190,6 +188,19 @@ #include #endif +#if !defined( HB_USE_LARGEFILE64 ) && defined( OS_UNIX_COMPATIBLE ) + #if defined( __USE_LARGEFILE64 ) + /* + * The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is + * define and efectively enables lseek64/flock64/ftruncate64 functions + * on 32bit machines. + */ + #define HB_USE_LARGEFILE64 + #elif defined( HB_OS_HPUX ) && defined( O_LARGEFILE ) + #define HB_USE_LARGEFILE64 + #endif +#endif + #if defined(OS_HAS_DRIVE_LETTER) /* 27/08/2004 - HB_FS_GETDRIVE() should return a number in the range 0..25 ('A'..'Z') @@ -970,12 +981,7 @@ HB_EXPORT USHORT hb_fsWrite( FHANDLE hFileHandle, const BYTE * pBuff, USHORT uiC } else { -#if defined(HB_OS_LINUX) && defined(__USE_LARGEFILE64) - /* - * The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is - * define and efectively enables lseek64/flock64/ftruncate64 functions - * on 32bit machines. - */ +#if defined(HB_USE_LARGEFILE64) hb_fsSetIOError( ftruncate64( hFileHandle, lseek64( hFileHandle, 0L, SEEK_CUR ) ) != -1, 0 ); #else hb_fsSetIOError( ftruncate( hFileHandle, lseek( hFileHandle, 0L, SEEK_CUR ) ) != -1, 0 ); @@ -1140,12 +1146,7 @@ HB_EXPORT ULONG hb_fsWriteLarge( FHANDLE hFileHandle, const BYTE * pBuff, ULONG #endif else { -#if defined(HB_OS_LINUX) && defined(__USE_LARGEFILE64) - /* - * The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is - * define and efectively enables lseek64/flock64/ftruncate64 functions - * on 32bit machines. - */ +#if defined(HB_USE_LARGEFILE64) hb_fsSetIOError( ftruncate64( hFileHandle, lseek64( hFileHandle, 0L, SEEK_CUR ) ) != -1, 0 ); #else hb_fsSetIOError( ftruncate( hFileHandle, lseek( hFileHandle, 0L, SEEK_CUR ) ) != -1, 0 ); @@ -1493,12 +1494,7 @@ HB_EXPORT BOOL hb_fsLockLarge( FHANDLE hFileHandle, HB_FOFFSET ulStart, } hb_fsSetIOError( bResult, 0 ); } -#elif defined(HB_OS_LINUX) && defined(__USE_LARGEFILE64) - /* - * The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is - * define and efectively enables lseek64/flock64/ftruncate64 functions - * on 32bit machines. - */ +#elif defined(HB_USE_LARGEFILE64) { struct flock64 lock_info; @@ -1659,12 +1655,7 @@ HB_EXPORT HB_FOFFSET hb_fsSeekLarge( FHANDLE hFileHandle, HB_FOFFSET llOffset, U llPos = ( ( HB_FOFFSET ) ulOffsetHigh << 32 ) | ulOffsetLow; } } -#elif defined(HB_OS_LINUX) && defined(__USE_LARGEFILE64) - /* - * The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is - * define and efectively enables lseek64/flock64/ftruncate64 functions - * on 32bit machines. - */ +#elif defined(HB_USE_LARGEFILE64) { USHORT Flags = convert_seek_flags( uiFlags ); diff --git a/harbour/source/rtl/fssize.c b/harbour/source/rtl/fssize.c index 86cdc74b43..36f5063523 100644 --- a/harbour/source/rtl/fssize.c +++ b/harbour/source/rtl/fssize.c @@ -51,7 +51,7 @@ * */ -#if defined(HB_OS_LINUX) +#if !defined( _LARGEFILE64_SOURCE ) # define _LARGEFILE64_SOURCE #endif @@ -63,6 +63,20 @@ # include #endif +#if !defined( HB_USE_LARGEFILE64 ) && defined( OS_UNIX_COMPATIBLE ) + #if defined( __USE_LARGEFILE64 ) + /* + * The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is + * define and efectively enables lseek64/flock64/ftruncate64 functions + * on 32bit machines. + */ + #define HB_USE_LARGEFILE64 + #elif defined( HB_OS_HPUX ) && defined( O_LARGEFILE ) + #define HB_USE_LARGEFILE64 + #endif +#endif + + HB_FOFFSET hb_fsFSize( BYTE * pszFileName, BOOL bUseDirEntry ) { if( bUseDirEntry ) @@ -81,12 +95,7 @@ HB_FOFFSET hb_fsFSize( BYTE * pszFileName, BOOL bUseDirEntry ) hb_fsFindClose( ffind ); return size; } -#elif defined(HB_OS_LINUX) && defined(__USE_LARGEFILE64) - /* - * The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is - * define and efectively enables lseek64/flock64/ftruncate64 functions - * on 32bit machines. - */ +#elif defined( HB_USE_LARGEFILE64 ) BOOL fResult, fFree; struct stat64 statbuf; pszFileName = hb_fsNameConv( pszFileName, &fFree ); diff --git a/harbour/source/rtl/hbffind.c b/harbour/source/rtl/hbffind.c index 4388030f21..938fded326 100644 --- a/harbour/source/rtl/hbffind.c +++ b/harbour/source/rtl/hbffind.c @@ -52,7 +52,7 @@ * */ -#if defined(HB_OS_LINUX) +#if !defined( _LARGEFILE64_SOURCE ) # define _LARGEFILE64_SOURCE #endif @@ -164,6 +164,19 @@ HB_FILE_VER( "$Id$" ) #endif +#if !defined( HB_USE_LARGEFILE64 ) && defined( OS_UNIX_COMPATIBLE ) + #if defined( __USE_LARGEFILE64 ) + /* + * The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is + * define and efectively enables lseek64/flock64/ftruncate64 functions + * on 32bit machines. + */ + #define HB_USE_LARGEFILE64 + #elif defined( HB_OS_HPUX ) && defined( O_LARGEFILE ) + #define HB_USE_LARGEFILE64 + #endif +#endif + /* ------------------------------------------------------------- */ USHORT hb_fsAttrFromRaw( ULONG raw_attr ) @@ -677,12 +690,7 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind ) { time_t ftime; struct tm * ft; -#if defined(HB_OS_LINUX) && defined(__USE_LARGEFILE64) - /* - * The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is - * define and efectively enables lseek64/flock64/ftruncate64 functions - * on 32bit machines. - */ +#if defined( HB_USE_LARGEFILE64 ) struct stat64 sStat; if( stat64( dirname, &sStat ) == 0 ) #else diff --git a/harbour/source/rtl/seconds.c b/harbour/source/rtl/seconds.c index 944575df61..bb62407247 100644 --- a/harbour/source/rtl/seconds.c +++ b/harbour/source/rtl/seconds.c @@ -110,7 +110,7 @@ HB_EXPORT void hb_dateTimeStamp( LONG * plJulian, LONG * plMilliSec ) st = localtime( &seconds ); *plJulian = hb_dateEncode( st->tm_year + 1900, st->tm_mon + 1, st->tm_mday ); *plMilliSec = ( ( st->tm_hour * 60 + st->tm_min ) * 60 + st->tm_sec ) * 1000 + - tv->tv_usec / 1000.0; + tv.tv_usec / 1000.0; #else struct timeb tb; struct tm * st; diff --git a/harbour/source/vm/itemapi.c b/harbour/source/vm/itemapi.c index a63f6a01a0..d2270d341d 100644 --- a/harbour/source/vm/itemapi.c +++ b/harbour/source/vm/itemapi.c @@ -964,7 +964,7 @@ HB_EXPORT PHB_ITEM hb_itemPutNDDec( PHB_ITEM pItem, double dNumber, int iDec ) HB_EXPORT double hb_itemGetNDDec( PHB_ITEM pItem, int * piDec ) { - HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNDDec(%p,p%)", pItem, piDec)); + HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNDDec(%p,%p)", pItem, piDec)); if( HB_IS_INTEGER( pItem ) ) { @@ -981,11 +981,6 @@ HB_EXPORT double hb_itemGetNDDec( PHB_ITEM pItem, int * piDec ) *piDec = pItem->item.asDouble.decimal; return pItem->item.asDouble.value; } - else if( HB_IS_DATE( pItem ) ) - { - *piDec = 0; - return ( double ) pItem->item.asDate.value; - } *piDec = 0; return 0.0;