2009-03-11 16:27 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/source/common/hbdate.c
  * harbour/source/compiler/cmdcheck.c
  * harbour/source/rtl/idle.c
  * harbour/source/rtl/seconds.c
  * harbour/source/rtl/fssize.c
  * harbour/source/rtl/hbffind.c
  * harbour/source/rtl/filesys.c
  * harbour/contrib/hbct/files.c
    * cleaned feature test macros usage
This commit is contained in:
Przemyslaw Czerpak
2009-03-11 15:22:17 +00:00
parent b5c713fb88
commit f3bf261945
9 changed files with 150 additions and 164 deletions

View File

@@ -8,6 +8,17 @@
2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2009-03-11 16:27 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/common/hbdate.c
* harbour/source/compiler/cmdcheck.c
* harbour/source/rtl/idle.c
* harbour/source/rtl/seconds.c
* harbour/source/rtl/fssize.c
* harbour/source/rtl/hbffind.c
* harbour/source/rtl/filesys.c
* harbour/contrib/hbct/files.c
* cleaned feature test macros usage
2009-03-11 08:51 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* doc/whatsnew.txt
+ Added new entries since last update. Please review, etc...

View File

@@ -331,10 +331,12 @@ HB_FUNC( SETFDATI )
time_t current_time;
current_time = time( NULL );
# if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
new_value = *localtime( &current_time );
# else
#if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
localtime_r( &current_time, &new_value );
# else
new_value = *localtime( &current_time );
# endif
}
else

View File

@@ -268,7 +268,9 @@ void hb_dateToday( int * piYear, int * piMonth, int * piDay )
*piMonth = st.wMonth;
*piDay = st.wDay;
#elif defined( HB_OS_UNIX ) && _POSIX_C_SOURCE >= 199506L && !defined( HB_OS_DARWIN_5 )
#elif ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
time_t t;
struct tm st;
@@ -305,7 +307,9 @@ void hb_dateTimeStr( char * pszTime )
GetLocalTime( &st );
hb_snprintf( pszTime, 9, "%02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond );
}
#elif defined( HB_OS_UNIX ) && _POSIX_C_SOURCE >= 199506L && !defined( HB_OS_DARWIN_5 )
#elif ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
{
time_t t;
struct tm st;

View File

@@ -103,33 +103,32 @@ static ULONG PackDateTime( void )
szString[3] |= nValue;
#else
time_t t;
struct tm *oTime;
#if !defined( HB_OS_UNIX ) || _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
time( &t );
oTime = localtime( &t );
#else
struct tm tm;
time( &t );
oTime = &tm;
localtime_r( &t, oTime );
#if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
localtime_r( &t, &tm );
#else
tm = *localtime( &t );
#endif
nValue = ( BYTE ) ( ( ( oTime->tm_year + 1900 ) - 1980 ) & ( 2 ^ 6 ) ); /* 6 bits */
nValue = ( BYTE ) ( ( ( tm.tm_year + 1900 ) - 1980 ) & ( 2 ^ 6 ) ); /* 6 bits */
szString[0] = nValue << 2;
nValue = ( BYTE ) ( oTime->tm_mon + 1 ); /* 4 bits */
nValue = ( BYTE ) ( tm.tm_mon + 1 ); /* 4 bits */
szString[0] |= nValue >> 2;
szString[1] = nValue << 6;
nValue = ( BYTE ) ( oTime->tm_mday ); /* 5 bits */
nValue = ( BYTE ) ( tm.tm_mday ); /* 5 bits */
szString[1] |= nValue << 1;
nValue = ( BYTE ) oTime->tm_hour; /* 5 bits */
nValue = ( BYTE ) tm.tm_hour; /* 5 bits */
szString[1] = nValue >> 4;
szString[2] = nValue << 4;
nValue = ( BYTE ) oTime->tm_min; /* 6 bits */
nValue = ( BYTE ) tm.tm_min; /* 6 bits */
szString[2] |= nValue >> 2;
szString[3] = nValue << 6;
nValue = ( BYTE ) oTime->tm_sec; /* 6 bits */
nValue = ( BYTE ) tm.tm_sec; /* 6 bits */
szString[3] |= nValue;
#endif

View File

@@ -95,8 +95,8 @@
#if !defined( _LARGEFILE64_SOURCE )
# define _LARGEFILE64_SOURCE
#endif
#if !defined( _XOPEN_SOURCE )
# define _XOPEN_SOURCE 500
#if !defined( _GNU_SOURCE )
# define _GNU_SOURCE
#endif
/* OS2 */
@@ -107,8 +107,6 @@
/* Windows */
#define HB_OS_WIN_USED
#include <string.h>
#include "hbapi.h"
#include "hbvm.h"
#include "hbstack.h"
@@ -205,11 +203,11 @@
#if defined( __USE_LARGEFILE64 )
/*
* The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is
* define and efectively enables lseek64/flock64/ftruncate64 functions
* defined and efectively enables lseek64/flock64/ftruncate64 functions
* on 32bit machines.
*/
#define HB_USE_LARGEFILE64
#elif defined( HB_OS_HPUX ) && defined( O_LARGEFILE )
#elif defined( HB_OS_UNIX ) && defined( O_LARGEFILE ) && ! defined( __WATCOMC__ )
#define HB_USE_LARGEFILE64
#endif
#endif
@@ -966,10 +964,12 @@ BOOL hb_fsGetFileTime( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec )
struct tm ft;
ftime = sStat.st_mtime;
# if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
ft = *localtime( &ftime );
# else
# if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
localtime_r( &ftime, &ft );
# else
ft = *localtime( &ftime );
# endif
*plJulian = hb_dateEncode( ft.tm_year + 1900, ft.tm_mon + 1, ft.tm_mday );
@@ -1204,10 +1204,12 @@ BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec )
time_t current_time;
current_time = time( NULL );
# if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
new_value = *localtime( &current_time );
# else
# if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
localtime_r( &current_time, &new_value );
# else
new_value = *localtime( &current_time );
# endif
}
else
@@ -1226,10 +1228,12 @@ BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec )
new_value.tm_sec = iSecond;
}
tim = mktime( &new_value );
# if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
new_value = *gmtime( &tim );
# else
# if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
gmtime_r( &tim, &new_value );
# else
new_value = *gmtime( &tim );
# endif
buf.actime = buf.modtime = mktime( &new_value );
fResult = utime( ( char * ) pszFileName, &buf ) == 0;

View File

@@ -72,7 +72,7 @@
* on 32bit machines.
*/
#define HB_USE_LARGEFILE64
#elif defined( HB_OS_HPUX ) && defined( O_LARGEFILE )
#elif defined( HB_OS_UNIX ) && defined( O_LARGEFILE ) && ! defined( __WATCOMC__ )
#define HB_USE_LARGEFILE64
#endif
#endif

View File

@@ -137,9 +137,6 @@
#elif defined(HB_OS_UNIX)
#ifndef __USE_BSD
#define __USE_BSD
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -168,7 +165,7 @@
* on 32bit machines.
*/
#define HB_USE_LARGEFILE64
#elif defined( HB_OS_HPUX ) && defined( O_LARGEFILE )
#elif defined( HB_OS_UNIX ) && defined( O_LARGEFILE ) && ! defined( __WATCOMC__ )
#define HB_USE_LARGEFILE64
#endif
#endif
@@ -712,10 +709,12 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind )
raw_attr = sStat.st_mode;
ftime = sStat.st_mtime;
# if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
lt = *localtime( &ftime );
# else
# if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
localtime_r( &ftime, &lt );
# else
lt = *localtime( &ftime );
# endif
nYear = lt.tm_year + 1900;

View File

@@ -75,9 +75,6 @@
#include "hbdate.h"
#include "error.ch"
#if defined( HB_OS_UNIX )
#ifndef __USE_POSIX199309
#define __USE_POSIX199309
#endif
#include <sys/time.h>
#include <sys/times.h>
#include <unistd.h>

View File

@@ -85,150 +85,120 @@
void hb_dateTimeStamp( LONG * plJulian, LONG * plMilliSec )
{
HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStamp(%p,%p)", plJulian, plMilliSec));
#if defined(HB_OS_WIN)
SYSTEMTIME st;
{
SYSTEMTIME st;
HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStamp(%p,%p)", plJulian, plMilliSec));
GetLocalTime( &st );
GetLocalTime( &st );
*plJulian = hb_dateEncode( st.wYear, st.wMonth, st.wDay );
*plMilliSec = ( ( st.wHour * 60 + st.wMinute ) * 60 + st.wSecond ) * 1000 +
st.wMilliseconds;
#elif defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )
struct timeval tv;
struct tm st;
time_t seconds;
HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStamp(%p,%p)", plJulian, plMilliSec));
gettimeofday( &tv, NULL );
seconds = tv.tv_sec;
localtime_r( &seconds, &st );
*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;
#elif defined( HB_OS_BSD )
struct timeval tv;
struct tm * st;
time_t seconds;
HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStamp(%p,%p)", plJulian, plMilliSec));
gettimeofday( &tv, NULL );
seconds = tv.tv_sec;
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;
*plJulian = hb_dateEncode( st.wYear, st.wMonth, st.wDay );
*plMilliSec = ( ( st.wHour * 60 + st.wMinute ) * 60 + st.wSecond ) * 1000 +
st.wMilliseconds;
}
#else
struct timeb tb;
struct tm * st;
time_t seconds;
{
struct tm st;
time_t seconds, millisecs;
HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStamp(%p,%p)", plJulian, plMilliSec));
# if defined( HB_OS_UNIX ) && !defined( __WATCOMC__ )
struct timeval tv;
gettimeofday( &tv, NULL );
seconds = tv.tv_sec;
millisecs = tv.tv_usec / 1000;
# else
struct timeb tb;
ftime( &tb );
seconds = tb.time;
millisecs = tb.millitm;
# endif
ftime( &tb );
seconds = tb.time;
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 +
tb.millitm;
#if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
localtime_r( &seconds, &st );
#else
st = *localtime( &seconds );
#endif
*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 +
millisecs;
}
#endif
}
HB_ULONG hb_dateMilliSeconds( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_dateMilliSeconds()"));
#if defined(HB_OS_WIN)
SYSTEMTIME st;
HB_TRACE(HB_TR_DEBUG, ("hb_dateMilliSeconds()"));
GetLocalTime( &st );
return ( HB_ULONG ) hb_dateEncode( st.wYear, st.wMonth, st.wDay ) * 86400000L +
( ( st.wHour * 60 + st.wMinute ) * 60 + st.wSecond ) * 1000 +
st.wMilliseconds;
#elif ( defined( HB_OS_LINUX ) || defined( HB_OS_BSD ) ) && !defined( __WATCOMC__ )
struct timeval tv;
HB_TRACE(HB_TR_DEBUG, ("hb_dateMilliSeconds()"));
gettimeofday( &tv, NULL );
return ( HB_ULONG ) tv.tv_sec * 1000 + tv.tv_usec / 1000;
{
SYSTEMTIME st;
GetLocalTime( &st );
return ( HB_ULONG ) hb_dateEncode( st.wYear, st.wMonth, st.wDay ) * 86400000L +
( ( st.wHour * 60 + st.wMinute ) * 60 + st.wSecond ) * 1000 +
st.wMilliseconds;
}
#elif defined( HB_OS_UNIX ) && !defined( __WATCOMC__ )
{
struct timeval tv;
gettimeofday( &tv, NULL );
return ( HB_ULONG ) tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
#else
struct timeb tb;
HB_TRACE(HB_TR_DEBUG, ("hb_dateMilliSeconds()"));
ftime( &tb );
return ( HB_ULONG ) tb.time * 1000 + tb.millitm;
{
struct timeb tb;
ftime( &tb );
return ( HB_ULONG ) tb.time * 1000 + tb.millitm;
}
#endif
}
double hb_dateSeconds( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_dateSeconds()"));
#if defined(HB_OS_WIN)
SYSTEMTIME SystemTime;
HB_TRACE(HB_TR_DEBUG, ("hb_dateSeconds()"));
GetLocalTime( &SystemTime );
return ( SystemTime.wHour * 3600 ) +
( SystemTime.wMinute * 60 ) +
SystemTime.wSecond +
( ( double ) SystemTime.wMilliseconds / 1000.0 );
#elif defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )
struct timeval tv;
struct tm oTime;
time_t seconds;
HB_TRACE(HB_TR_DEBUG, ("hb_dateSeconds()"));
gettimeofday( &tv, NULL );
seconds = tv.tv_sec;
localtime_r( &seconds, &oTime );
return ( oTime.tm_hour * 3600 ) +
( oTime.tm_min * 60 ) +
oTime.tm_sec +
( ( double ) tv.tv_usec / 1000000.0 );
#elif defined( HB_OS_BSD )
struct timeval tv;
struct tm * oTime;
time_t seconds;
HB_TRACE(HB_TR_DEBUG, ("hb_dateSeconds()"));
gettimeofday( &tv, NULL );
seconds = tv.tv_sec;
oTime = localtime( &seconds );
return ( oTime->tm_hour * 3600 ) +
( oTime->tm_min * 60 ) +
oTime->tm_sec +
( ( double ) tv.tv_usec / 1000000.0 );
{
SYSTEMTIME SystemTime;
GetLocalTime( &SystemTime );
return ( SystemTime.wHour * 3600 ) +
( SystemTime.wMinute * 60 ) +
SystemTime.wSecond +
( ( double ) SystemTime.wMilliseconds / 1000.0 );
}
#else
struct timeb tb;
struct tm * oTime;
time_t seconds;
{
struct tm oTime;
time_t seconds;
double msecs;
HB_TRACE(HB_TR_DEBUG, ("hb_dateSeconds()"));
# if defined( HB_OS_UNIX ) && !defined( __WATCOMC__ )
struct timeval tv;
gettimeofday( &tv, NULL );
seconds = tv.tv_sec;
msecs = ( double ) tv.tv_usec / 1000000.0;
# else
struct timeb tb;
ftime( &tb );
seconds = tb.time;
msecs = ( double ) tb.millitm / 1000.0;
# endif
ftime( &tb );
seconds = tb.time;
oTime = localtime( &seconds );
return ( oTime->tm_hour * 3600 ) +
( oTime->tm_min * 60 ) +
oTime->tm_sec +
( ( double ) tb.millitm / 1000.0 );
#if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
localtime_r( &seconds, &oTime );
#else
oTime = *localtime( &seconds );
#endif
return ( oTime.tm_hour * 3600 ) +
( oTime.tm_min * 60 ) +
oTime.tm_sec + msecs;
}
#endif
}
HB_FUNC( SECONDS )
{
hb_retnd( hb_dateSeconds() );