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

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