See ChangeLog entry 19990614-15:40 EDT David G. Holm <dholm@jsd-llc.com>
This commit is contained in:
@@ -1,3 +1,29 @@
|
||||
19990614-15:40 EDT David G. Holm <dholm@jsd-llc.com>
|
||||
* include/extend.h
|
||||
- Added declaration for hb_stricmp()
|
||||
* include/version.h
|
||||
- Changed revision code to "b"
|
||||
* source/rtl/classes.c
|
||||
- Now uses hb_stricmp() instead of stricmp()
|
||||
* source/rtl/console.c
|
||||
- Now uses hb_stricmp() instead of stricmp()
|
||||
* source/rtl/dates.c
|
||||
- Fixed several bugs reported by Jose Lalin, who included
|
||||
the appropriate fix for most of them.
|
||||
* source/rtl/files.c
|
||||
- Removed test code that was accidentally included in CVS
|
||||
- Added default #define for O_BINARY
|
||||
* source/rtl/set.c
|
||||
- Now uses hb_stricmp() instead of stricmp()
|
||||
- Added default #define for O_BINARY
|
||||
* source/rtl/strcmp.c
|
||||
- Added new hb_stricmp() function, because stricmp() is not
|
||||
an ANSI C function. If stricmp() exists, it is used, else
|
||||
if strcasecmp exists, then it is used, otherwise use byte
|
||||
by byte comparision.
|
||||
* tests/working/dates3.prg
|
||||
- Added more test cases
|
||||
|
||||
19990614 11:50 CET Eddie Runia
|
||||
* source/compiler/harbour.y
|
||||
help text changed
|
||||
|
||||
@@ -159,6 +159,7 @@ void hb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pItemValue );
|
||||
|
||||
int hb_itemStrCmp( PHB_ITEM pFirst, PHB_ITEM pSecond, BOOL bForceExact ); /* our string compare */
|
||||
char * hb_str( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec ); /* convert number to string */
|
||||
int hb_stricmp( const char *s1, const char *s2 );
|
||||
BOOL hb_strempty( char * szText, ULONG ulLen );
|
||||
long hb_dateEncode( long lDay, long lMonth, long lYear );
|
||||
void hb_dateDecode( long julian, long * plDay, long * plMonth, long * plYear );
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#define hb_major 0 /* Major version number */
|
||||
#define hb_minor 0 /* Minor version number */
|
||||
#define hb_revision "a" /* Revision letter */
|
||||
#define hb_revision "b" /* Revision letter */
|
||||
#define hb_build 26 /* Build number */
|
||||
#define hb_year 1999 /* Build year */
|
||||
#define hb_month 6 /* Build month */
|
||||
|
||||
@@ -970,7 +970,7 @@ HARBOUR HB___INSTSUPER( void )
|
||||
|
||||
for( w = 0; !bFound && w < wClasses; w++ )
|
||||
{ /* Locate the entry */
|
||||
if( !stricmp( pString->value.szText, pClasses[ w ].szName ) )
|
||||
if( !hb_stricmp( pString->value.szText, pClasses[ w ].szName ) )
|
||||
{
|
||||
_retni( w + 1 ); /* Entry + 1 = ClassH */
|
||||
bFound = TRUE;
|
||||
|
||||
@@ -204,7 +204,7 @@ static void hb_altout( char * fpStr, WORD uiLen )
|
||||
{
|
||||
#ifdef USE_GTAPI
|
||||
_gtWriteCon( fpStr, uiLen );
|
||||
if( stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) || hb_set_printhan < 0 )
|
||||
if( hb_stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) || hb_set_printhan < 0 )
|
||||
_gtGetPos( &dev_row, &dev_col );
|
||||
#else
|
||||
WORD uiCount;
|
||||
@@ -229,7 +229,7 @@ static void hb_altout( char * fpStr, WORD uiLen )
|
||||
/* Output an item to the screen and/or printer */
|
||||
static void hb_devout( char * fpStr, WORD uiLen )
|
||||
{
|
||||
if( stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 )
|
||||
if( hb_stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 )
|
||||
{
|
||||
/* Display to printer if SET DEVICE TO PRINTER and valid printer file */
|
||||
write( hb_set_printhan, fpStr, uiLen );
|
||||
@@ -260,7 +260,7 @@ void hb_devpos( USHORT row, USHORT col )
|
||||
int count;
|
||||
/* Position printer if SET DEVICE TO PRINTER and valid printer file
|
||||
otherwise position console */
|
||||
if( stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 )
|
||||
if( hb_stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 )
|
||||
{
|
||||
if( row < p_row )
|
||||
{
|
||||
@@ -368,7 +368,7 @@ HARBOUR HB_DEVOUT( void ) /* writes a single values to the current device (scree
|
||||
|
||||
HARBOUR HB_EJECT( void ) /* Ejects the current page from the printer */
|
||||
{
|
||||
if( stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 )
|
||||
if( hb_stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 )
|
||||
{
|
||||
write( hb_set_printhan, "\x0C", 1 );
|
||||
p_row = p_col = 0;
|
||||
|
||||
@@ -14,11 +14,6 @@
|
||||
#define _OPTIMIZE_DTOS
|
||||
#endif
|
||||
|
||||
/*
|
||||
ADJ is 7 for ISO, 6 for no ISO
|
||||
*/
|
||||
#define ADJ 7
|
||||
|
||||
extern STACK stack;
|
||||
|
||||
/* In msgxxx.c modules */
|
||||
@@ -69,20 +64,9 @@ long hb_dateEncode( long lDay, long lMonth, long lYear )
|
||||
{
|
||||
/* Month, year, and lower day limits are simple,
|
||||
but upper day limit is dependent upon month and leap year */
|
||||
BOOL bLeapYear = FALSE;
|
||||
int aiDayLimit [12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
if( lYear % 4 == 0 )
|
||||
{
|
||||
/* Check for leap year (every year that is evenly divisible by 4,
|
||||
except for centuries, which must be evenly divisible by 400 */
|
||||
if( lYear % 100 == 0 )
|
||||
{
|
||||
if( lYear % 400 == 0) bLeapYear = TRUE; /* Leap century */
|
||||
}
|
||||
else bLeapYear = TRUE; /* Leap year */
|
||||
|
||||
if( bLeapYear ) aiDayLimit[ 1 ] = 29;
|
||||
}
|
||||
if( (( lYear % 4 == 0 && lYear % 100 != 0 ) || lYear % 400 == 0 ) )
|
||||
aiDayLimit[ 1 ] = 29;
|
||||
if( lDay <= (long)aiDayLimit[ (int)lMonth - 1 ] ) bValid = TRUE;
|
||||
}
|
||||
if( bValid )
|
||||
@@ -97,16 +81,25 @@ void hb_dateDecode( long julian, long * plDay, long * plMonth, long * plYear )
|
||||
{
|
||||
long U, V, W, X;
|
||||
|
||||
julian += 68569;
|
||||
W = ( julian * 4 ) / 146097;
|
||||
julian -= ( ( 146097 * W ) + 3 ) / 4;
|
||||
X = 4000 * ( julian + 1 ) / 1461001;
|
||||
julian -= ( ( 1461 * X ) / 4 ) - 31;
|
||||
V = 80 * julian / 2447;
|
||||
U = V / 11;
|
||||
if( plDay ) * plDay = julian - ( 2447 * V / 80 );
|
||||
if( plMonth ) * plMonth = V + 2 - ( U * 12 );
|
||||
if( plYear ) * plYear = X + U + ( W - 49 ) * 100;
|
||||
if( julian > 0 )
|
||||
{
|
||||
julian += 68569;
|
||||
W = ( julian * 4 ) / 146097;
|
||||
julian -= ( ( 146097 * W ) + 3 ) / 4;
|
||||
X = 4000 * ( julian + 1 ) / 1461001;
|
||||
julian -= ( ( 1461 * X ) / 4 ) - 31;
|
||||
V = 80 * julian / 2447;
|
||||
U = V / 11;
|
||||
if( plDay ) * plDay = julian - ( 2447 * V / 80 );
|
||||
if( plMonth ) * plMonth = V + 2 - ( U * 12 );
|
||||
if( plYear ) * plYear = X + U + ( W - 49 ) * 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
* plDay = 0;
|
||||
* plMonth = 0;
|
||||
* plYear = 0;
|
||||
}
|
||||
}
|
||||
|
||||
HARBOUR HB_CTOD( void )
|
||||
@@ -170,14 +163,14 @@ HARBOUR HB_CTOD( void )
|
||||
y_value = (y_value * 10) + digit - '0';
|
||||
}
|
||||
}
|
||||
else
|
||||
else if( digit != ' ' )
|
||||
{
|
||||
d_pos--;
|
||||
m_pos--;
|
||||
y_pos--;
|
||||
}
|
||||
}
|
||||
if (y_value < 100)
|
||||
if (y_value > 0 && y_value < 100)
|
||||
{
|
||||
count = hb_set.HB_SET_EPOCH % 100;
|
||||
digit = hb_set.HB_SET_EPOCH / 100;
|
||||
@@ -504,7 +497,7 @@ long hb_dow( long d, long m, long y )
|
||||
else
|
||||
m++;
|
||||
|
||||
return ( d + 26 * m / 10 + y + y / 4 - y / 100 + y / 400 + ADJ ) % 7;
|
||||
return ( ( d + 26 * m / 10 + y + y / 4 - y / 100 + y / 400 + 6 ) % 7 + 1 );
|
||||
}
|
||||
|
||||
HARBOUR HB_DOW( void )
|
||||
@@ -514,8 +507,13 @@ HARBOUR HB_DOW( void )
|
||||
|
||||
if( pDate )
|
||||
{
|
||||
hb_dateDecode( pDate->value.lDate, &lDay, &lMonth, &lYear );
|
||||
_retni( hb_dow( lDay, lMonth, lYear ) );
|
||||
if( pDate->value.lDate )
|
||||
{
|
||||
hb_dateDecode( pDate->value.lDate, &lDay, &lMonth, &lYear );
|
||||
_retni( hb_dow( lDay, lMonth, lYear ) );
|
||||
}
|
||||
else
|
||||
_retni( 0 );
|
||||
stack.Return.wLength = 3;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -56,6 +56,9 @@
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0 /* O_BINARY not defined on Linux */
|
||||
#endif
|
||||
|
||||
#ifndef S_IEXEC
|
||||
#define S_IEXEC 0x0040 /* owner may execute <directory search> */
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
#include <set.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0 /* O_BINARY not defined on Linux */
|
||||
#endif
|
||||
|
||||
HB_set_struct hb_set;
|
||||
|
||||
BOOL hb_set_century;
|
||||
@@ -122,13 +126,6 @@ static int open_handle (char * file_name, BOOL bMode, char * def_ext)
|
||||
handle = open (path,
|
||||
O_BINARY|O_WRONLY|O_CREAT|(bMode?O_APPEND:O_TRUNC),
|
||||
S_IWRITE );
|
||||
if (handle < 0)
|
||||
{
|
||||
printf("\nError %d creating %s", errno, path);
|
||||
#if !defined(__GNUC__) && !defined(__DJGPP__)
|
||||
printf(" (DOS error %02x)", _doserrno);
|
||||
#endif
|
||||
}
|
||||
if (handle < 0)
|
||||
{
|
||||
char error_message [32];
|
||||
@@ -332,7 +329,7 @@ HARBOUR HB_SET (void)
|
||||
{
|
||||
/* If the print file is not already open, open it. */
|
||||
hb_set.HB_SET_DEVICE = set_string (pArg2, hb_set.HB_SET_DEVICE);
|
||||
if (stricmp (hb_set.HB_SET_DEVICE, "PRINTER") == 0 && hb_set_printhan < 0
|
||||
if (hb_stricmp (hb_set.HB_SET_DEVICE, "PRINTER") == 0 && hb_set_printhan < 0
|
||||
&& hb_set.HB_SET_PRINTFILE && strlen (hb_set.HB_SET_PRINTFILE) > 0)
|
||||
hb_set_printhan = open_handle (hb_set.HB_SET_PRINTFILE, bFlag, ".prn");
|
||||
}
|
||||
|
||||
@@ -5,6 +5,37 @@
|
||||
#include <extend.h>
|
||||
#include <set.h>
|
||||
|
||||
int hb_stricmp( const char *s1, const char *s2 )
|
||||
{
|
||||
#ifdef stricmp
|
||||
return( stricmp( s1, s2 ) );
|
||||
#else
|
||||
#ifdef strcasecmp
|
||||
return( strcasecmp( s1, s2 ) );
|
||||
#else
|
||||
int rc = 0;
|
||||
USHORT c1, c2, count;
|
||||
c1 = strlen( s1 );
|
||||
c2 = strlen( s2 );
|
||||
if( c1 < c2 ) count = c1;
|
||||
else count = c2;
|
||||
while( rc == 0 && count > 0 )
|
||||
{
|
||||
if( *s1 != *s2 ) rc = ( *s1 < *s2 ? -1 : 1 );
|
||||
s1++;
|
||||
s2++;
|
||||
count--;
|
||||
}
|
||||
if( rc == 0 && c1 != c2 )
|
||||
{
|
||||
if( c1 < c2 ) rc = -1;
|
||||
else rc = 1;
|
||||
}
|
||||
return rc;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check whether two strings are equal (0), smaller (-1), or greater (1) */
|
||||
int hb_itemStrCmp( PHB_ITEM pFirst, PHB_ITEM pSecond, BOOL bForceExact )
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
function main()
|
||||
|
||||
LOCAL dDate
|
||||
LOCAL dDate, i
|
||||
|
||||
set( _SET_DATEFORMAT, "dd/mm/yyyy" )
|
||||
dDate := cToD( "25/05/1999" )
|
||||
@@ -31,6 +31,14 @@ function main()
|
||||
|
||||
dDate += 4
|
||||
OutStd( dDate, dow( dDate ), chr( 10 ) )
|
||||
|
||||
OutStd( chr( 10 ) )
|
||||
dDate := DATE ()
|
||||
FOR i := 1 TO 7
|
||||
OutStd( dDate, dow( dDate ), chr( 10 ) )
|
||||
dDate++
|
||||
NEXT
|
||||
OutStd( ctod( "" ), dow( ctod( "" ) ), chr( 10 ) )
|
||||
|
||||
return nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user