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

* harbour/include/hbdate.h
  * harbour/source/common/hbgete.c
  * harbour/source/common/hbdate.c
  * harbour/source/rtl/seconds.c
  * harbour/source/rtl/hbffind.c
  * harbour/source/rtl/filesys.c
  * harbour/source/compiler/cmdcheck.c
  * harbour/contrib/hbct/files.c
  * harbour/contrib/xhb/filestat.c
  * harbour/contrib/hbmzip/hbmzip.c
  * harbour/contrib/hbtip/utils.c
  * harbour/contrib/examples/uhttpd/uhttpdc.c
    * cleaned feature test macros usage
This commit is contained in:
Przemyslaw Czerpak
2009-03-11 16:39:32 +00:00
parent f3bf261945
commit d44fea92a9
13 changed files with 91 additions and 107 deletions

View File

@@ -8,6 +8,21 @@
2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2009-03-11 17:45 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbdate.h
* harbour/source/common/hbgete.c
* harbour/source/common/hbdate.c
* harbour/source/rtl/seconds.c
* harbour/source/rtl/hbffind.c
* harbour/source/rtl/filesys.c
* harbour/source/compiler/cmdcheck.c
* harbour/contrib/hbct/files.c
* harbour/contrib/xhb/filestat.c
* harbour/contrib/hbmzip/hbmzip.c
* harbour/contrib/hbtip/utils.c
* harbour/contrib/examples/uhttpd/uhttpdc.c
* cleaned feature test macros usage
2009-03-11 16:27 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/common/hbdate.c
* harbour/source/compiler/cmdcheck.c

View File

@@ -60,6 +60,7 @@
#define HB_OS_WIN_USED
#include "hbapi.h"
#include "hbdate.h"
#if !defined( HB_OS_WIN )
#include <time.h>
@@ -154,22 +155,17 @@ HB_FUNC( HB_UTCOFFSET )
nLen = strlen( szRet );
}
#elif defined( HB_OS_UNIX ) && _POSIX_C_SOURCE >= 199506L && !defined( HB_OS_DARWIN_5 )
{
struct tm tmTime;
time_t current;
time( &current );
localtime_r( &current , &tmTime );
nLen = strftime( szRet, 6, "%z", &tmTime );
}
#else
{
struct tm tmTime;
time_t current;
memcpy( ( void * ) &tmTime, ( void * ) localtime( &current ), sizeof( tmTime ) );
time( &current );
# if defined( HB_HAS_LOCALTIME_R )
localtime_r( &current, &tmTime );
# else
tmTime = *localtime( &current );
# endif
nLen = strftime( szRet, 6, "%z", &tmTime );
}
#endif

View File

@@ -331,9 +331,7 @@ HB_FUNC( SETFDATI )
time_t current_time;
current_time = time( NULL );
#if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
#if defined( HB_HAS_LOCALTIME_R )
localtime_r( &current_time, &new_value );
# else
new_value = *localtime( &current_time );

View File

@@ -755,11 +755,11 @@ static int hb_zipStoreFile( zipFile hZip, const char* szFileName, const char* sz
( ( statbuf.st_mode & S_IWUSR ) ? 0x00800000 : 0 ) |
( ( statbuf.st_mode & S_IRUSR ) ? 0x01000000 : 0 );
# if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
st = *localtime( &statbuf.st_mtime );
# else
# if defined( HB_HAS_LOCALTIME_R )
localtime_r( &statbuf.st_mtime, &st );
# endif
# else
st = *localtime( &statbuf.st_mtime );
# endif
zfi.tmz_date.tm_sec = st.tm_sec;
zfi.tmz_date.tm_min = st.tm_min;
@@ -1144,11 +1144,11 @@ static int hb_unzipExtractCurrentFile( unzFile hUnzip, const char* szFileName, c
st.tm_year = ufi.tmu_date.tm_year - 1900;
tim = mktime( &st );
# if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
st = *gmtime( &tim );
# else
# if defined( HB_HAS_LOCALTIME_R )
gmtime_r( &tim, &st );
# endif
# else
st = *gmtime( &tim );
# endif
utim.actime = utim.modtime = mktime( &st );
utime( szName, &utim );

View File

@@ -171,13 +171,12 @@ HB_FUNC( TIP_TIMESTAMP )
ulHour = 0;
}
/* init time structure anyway */
time( &current );
#if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
memcpy( (void *) &tmTime, (void *) localtime( &current ), sizeof(tmTime) );
#else
#if defined( HB_HAS_LOCALTIME_R )
localtime_r( &current , &tmTime );
#else
tmTime = *localtime( &current );
#endif
if ( pDate )

View File

@@ -153,7 +153,7 @@ static BOOL hb_fsFileStats(
*llSize = ( HB_FOFFSET ) statbuf.st_size;
ftime = statbuf.st_mtime;
#if _POSIX_C_SOURCE >= 199506L && !defined( HB_OS_DARWIN_5 )
#if defined( HB_HAS_LOCALTIME_R )
ptms = localtime_r( &ftime, &tms );
#else
ptms = localtime( &ftime );
@@ -164,7 +164,7 @@ static BOOL hb_fsFileStats(
*lcTime = ptms->tm_hour*3600 + ptms->tm_min * 60 + ptms->tm_sec;
ftime = statbuf.st_atime;
#if _POSIX_C_SOURCE >= 199506L && !defined( HB_OS_DARWIN_5 )
#if defined( HB_HAS_LOCALTIME_R )
ptms = localtime_r( &ftime, &tms );
#else
ptms = localtime( &ftime );

View File

@@ -82,6 +82,14 @@ extern HB_EXPORT void hb_dateStrGet( const char * szDate, int * piYear, int *
extern HB_EXPORT char * hb_dateDecStr( char * szDate, long lJulian );
extern HB_EXPORT long hb_dateEncStr( const char * szDate );
#if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) || \
defined( HB_OS_SUNOS ) ) && \
! defined( HB_OS_DARWIN_5 ) && !defined( HB_HAS_LOCALTIME_R )
# define HB_HAS_LOCALTIME_R
#endif
HB_EXTERN_END
#endif /* HB_DATE_H_ */

View File

@@ -260,40 +260,31 @@ int hb_dateDOW( int iYear, int iMonth, int iDay )
void hb_dateToday( int * piYear, int * piMonth, int * piDay )
{
#if defined(HB_OS_WIN)
{
SYSTEMTIME st;
SYSTEMTIME st;
GetLocalTime( &st );
*piYear = st.wYear;
*piMonth = st.wMonth;
*piDay = st.wDay;
#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;
time( &t );
localtime_r( &t, &st );
*piYear = st.tm_year + 1900;
*piMonth = st.tm_mon + 1;
*piDay = st.tm_mday;
GetLocalTime( &st );
*piYear = st.wYear;
*piMonth = st.wMonth;
*piDay = st.wDay;
}
#else
{
time_t t;
struct tm st;
time_t t;
struct tm * oTime;
time( &t );
oTime = localtime( &t );
*piYear = oTime->tm_year + 1900;
*piMonth = oTime->tm_mon + 1;
*piDay = oTime->tm_mday;
time( &t );
# if defined( HB_HAS_LOCALTIME_R )
localtime_r( &t, &st );
# else
st = *localtime( &t );
# endif
*piYear = st.tm_year + 1900;
*piMonth = st.tm_mon + 1;
*piDay = st.tm_mday;
}
#endif
}
@@ -307,26 +298,17 @@ void hb_dateTimeStr( char * pszTime )
GetLocalTime( &st );
hb_snprintf( pszTime, 9, "%02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond );
}
#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;
time( &t );
localtime_r( &t, &st );
hb_snprintf( pszTime, 9, "%02d:%02d:%02d", st.tm_hour, st.tm_min, st.tm_sec );
}
#else
{
time_t t;
struct tm * oTime;
struct tm st;
time( &t );
oTime = localtime( &t );
hb_snprintf( pszTime, 9, "%02d:%02d:%02d", oTime->tm_hour, oTime->tm_min, oTime->tm_sec );
# if defined( HB_HAS_LOCALTIME_R )
localtime_r( &t, &st );
# else
st = *localtime( &t );
# endif
hb_snprintf( pszTime, 9, "%02d:%02d:%02d", st.tm_hour, st.tm_min, st.tm_sec );
}
#endif
}

View File

@@ -158,7 +158,7 @@ BOOL hb_setenv( const char * szName, const char * szValue )
#elif defined( _BSD_SOURCE ) || _POSIX_C_SOURCE >= 200112L || \
_XOPEN_SOURCE >= 600 || defined( __WATCOMC__ ) || defined( __DJGPP__ ) || \
defined( HB_OS_BSD ) || defined( HB_OS_DARWIN )
defined( HB_OS_SUNOS ) || defined( HB_OS_BSD ) || defined( HB_OS_DARWIN )
if( szValue )
return setenv( szName, szValue, 1 ) == 0;

View File

@@ -106,9 +106,7 @@ static ULONG PackDateTime( void )
struct tm tm;
time( &t );
#if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
#if defined( HB_HAS_LOCALTIME_R )
localtime_r( &t, &tm );
#else
tm = *localtime( &t );

View File

@@ -964,13 +964,11 @@ BOOL hb_fsGetFileTime( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec )
struct tm ft;
ftime = sStat.st_mtime;
# if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
# if defined( HB_HAS_LOCALTIME_R )
localtime_r( &ftime, &ft );
# else
# else
ft = *localtime( &ftime );
# endif
# endif
*plJulian = hb_dateEncode( ft.tm_year + 1900, ft.tm_mon + 1, ft.tm_mday );
*plMillisec = hb_timeStampEncode( ft.tm_hour, ft.tm_min, ft.tm_sec, 0 );
@@ -1204,13 +1202,11 @@ BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec )
time_t current_time;
current_time = time( NULL );
# if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
# if defined( HB_HAS_LOCALTIME_R )
localtime_r( &current_time, &new_value );
# else
# else
new_value = *localtime( &current_time );
# endif
# endif
}
else
memset( &new_value, 0, sizeof( new_value ) );
@@ -1228,13 +1224,11 @@ BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec )
new_value.tm_sec = iSecond;
}
tim = mktime( &new_value );
# if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
# if defined( HB_HAS_LOCALTIME_R )
gmtime_r( &tim, &new_value );
# else
# else
new_value = *gmtime( &tim );
# endif
# endif
buf.actime = buf.modtime = mktime( &new_value );
fResult = utime( ( char * ) pszFileName, &buf ) == 0;
}

View File

@@ -709,13 +709,11 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind )
raw_attr = sStat.st_mode;
ftime = sStat.st_mtime;
# if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
# if defined( HB_HAS_LOCALTIME_R )
localtime_r( &ftime, &lt );
# else
# else
lt = *localtime( &ftime );
# endif
# endif
nYear = lt.tm_year + 1900;
nMonth = lt.tm_mon + 1;

View File

@@ -114,13 +114,11 @@ void hb_dateTimeStamp( LONG * plJulian, LONG * plMilliSec )
millisecs = tb.millitm;
# endif
#if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
# if defined( HB_HAS_LOCALTIME_R )
localtime_r( &seconds, &st );
#else
# else
st = *localtime( &seconds );
#endif
# 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;
@@ -185,13 +183,11 @@ double hb_dateSeconds( void )
msecs = ( double ) tb.millitm / 1000.0;
# endif
#if ( defined( _POSIX_C_SOURCE ) || defined( _XOPEN_SOURCE ) || \
defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \
! defined( HB_OS_DARWIN_5 )
# if defined( HB_HAS_LOCALTIME_R )
localtime_r( &seconds, &oTime );
#else
# else
oTime = *localtime( &seconds );
#endif
# endif
return ( oTime.tm_hour * 3600 ) +
( oTime.tm_min * 60 ) +
oTime.tm_sec + msecs;