2007-09-10 22:51 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/libct/ctnet.c
   * contrib/libct/dattime2.c
   * contrib/samples/date.c
   * contrib/bmdbfcdx/bmdbfcdx1.c
     * Changed hb_set. access to hb_setGet*() in all 
       contrib code.

   * source/rtl/hbini.prg
     + Further cleanup.
This commit is contained in:
Viktor Szakats
2007-09-10 20:54:06 +00:00
parent ea77a0b9fb
commit b09b3da47b
6 changed files with 170 additions and 167 deletions

View File

@@ -8,6 +8,17 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2007-09-10 22:51 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/libct/ctnet.c
* contrib/libct/dattime2.c
* contrib/samples/date.c
* contrib/bmdbfcdx/bmdbfcdx1.c
* Changed hb_set. access to hb_setGet*() in all
contrib code.
* source/rtl/hbini.prg
+ Further cleanup.
2007-09-10 22:12 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/rtl/hbtoken.c
! fixed bad typo in hb_tokenCount()

View File

@@ -3883,7 +3883,7 @@ static BOOL hb_cdxCheckRecordFilter( CDXAREAP pArea, ULONG ulRecNo )
if( pArea->ulRecNo != ulRecNo || pArea->lpdbPendingRel )
SELF_GOTO( ( AREAP ) pArea, ulRecNo );
if( hb_set.HB_SET_DELETED )
if( hb_setGetL( HB_SET_DELETED ) )
SUPER_DELETED( ( AREAP ) pArea, &lResult );
if( !lResult && pArea->dbfi.itmCobExpr )
@@ -3903,12 +3903,12 @@ static BOOL hb_cdxCheckRecordFilter( CDXAREAP pArea, ULONG ulRecNo )
else
lResult = TRUE;
}
else if ( pArea->dbfi.itmCobExpr || hb_set.HB_SET_DELETED )
else if ( pArea->dbfi.itmCobExpr || hb_setGetL( HB_SET_DELETED ) )
{
if( pArea->ulRecNo != ulRecNo || pArea->lpdbPendingRel )
SELF_GOTO( ( AREAP ) pArea, ulRecNo );
if( hb_set.HB_SET_DELETED )
if( hb_setGetL( HB_SET_DELETED ) )
SUPER_DELETED( ( AREAP ) pArea, &lResult );
if( !lResult && pArea->dbfi.itmCobExpr )
@@ -6852,7 +6852,7 @@ HB_FUNC( BM_DBSEEKWILD )
if( !ISNIL( 1 ) )
{
pKey = hb_param( 1, HB_IT_ANY );
bSoftSeek = ISLOG( 2 ) ? (BOOL) hb_parl( 2 ) : hb_set.HB_SET_SOFTSEEK;
bSoftSeek = ISLOG( 2 ) ? (BOOL) hb_parl( 2 ) : hb_setGetL( HB_SET_SOFTSEEK );
bFindLast = ISLOG( 3 ) ? hb_parl( 3 ) : FALSE;
bNext = ISLOG( 4 ) ? hb_parl( 4 ) : FALSE;
bAll = ISLOG( 5 ) ? hb_parl( 5 ) : FALSE;
@@ -6974,7 +6974,7 @@ ERRCODE hb_cdxSkipFilter( CDXAREAP pArea, LONG lUpDown )
HB_TRACE(HB_TR_DEBUG, ("hb_cdxSkipFilter(%p, %ld)", pArea, lUpDown));
if( !hb_set.HB_SET_DELETED && pArea->dbfi.itmCobExpr == NULL )
if( !hb_setGetL( HB_SET_DELETED ) && pArea->dbfi.itmCobExpr == NULL )
return SUCCESS;
/* Since lToSkip is passed to SkipRaw, it should never request more than
@@ -6990,7 +6990,7 @@ ERRCODE hb_cdxSkipFilter( CDXAREAP pArea, LONG lUpDown )
while( !pArea->fBof && !pArea->fEof )
{
/* SET DELETED */
if( hb_set.HB_SET_DELETED )
if( hb_setGetL( HB_SET_DELETED ) )
{
LPCDXTAG pTag = hb_cdxGetActiveTag( pArea );
@@ -7239,7 +7239,7 @@ static ERRCODE hb_cdxFlush( CDXAREAP pArea )
uiError = SUPER_FLUSH( ( AREAP ) pArea );
if ( hb_set.HB_SET_HARDCOMMIT )
if ( hb_setGetL( HB_SET_HARDCOMMIT ) )
{
pIndex = pArea->lpIndexes;
while ( pIndex )
@@ -7583,9 +7583,9 @@ static ERRCODE hb_cdxOpen( CDXAREAP pArea, LPDBOPENINFO pOpenInfo )
/* If SET_AUTOPEN open index */
#ifdef HB_CDX_CLIP_AUTOPEN
if ( hb_set.HB_SET_AUTOPEN )
if ( hb_setGetL( HB_SET_AUTOPEN ) )
#else
if ( pArea->fHasTags && hb_set.HB_SET_AUTOPEN )
if ( pArea->fHasTags && hb_setGetL( HB_SET_AUTOPEN ) )
#endif
{
char szFileName[ _POSIX_PATH_MAX + 1 ];
@@ -7603,7 +7603,7 @@ static ERRCODE hb_cdxOpen( CDXAREAP pArea, LPDBOPENINFO pOpenInfo )
errCode = SELF_ORDLSTADD( ( AREAP ) pArea, &pOrderInfo );
if( errCode == SUCCESS )
{
pOrderInfo.itmOrder = hb_itemPutNI( NULL, hb_set.HB_SET_AUTORDER );
pOrderInfo.itmOrder = hb_itemPutNI( NULL, hb_setGetNI( HB_SET_AUTORDER ) );
errCode = SELF_ORDLSTFOCUS( ( AREAP ) pArea, &pOrderInfo );
hb_itemRelease( pOrderInfo.itmOrder );
if( errCode == SUCCESS )
@@ -7803,9 +7803,9 @@ static ERRCODE hb_cdxOrderListClear( CDXAREAP pArea )
return FAILURE;
#ifdef HB_CDX_CLIP_AUTOPEN
hb_cdxOrdListClear( pArea, !hb_set.HB_SET_AUTOPEN, NULL );
hb_cdxOrdListClear( pArea, !hb_setGetL( HB_SET_AUTOPEN ), NULL );
#else
hb_cdxOrdListClear( pArea, !pArea->fHasTags || !hb_set.HB_SET_AUTOPEN, NULL );
hb_cdxOrdListClear( pArea, !pArea->fHasTags || !hb_setGetL( HB_SET_AUTOPEN ), NULL );
#endif
pArea->uiTag = 0;
@@ -8043,9 +8043,9 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo
if ( !pArea->lpdbOrdCondInfo ||
( pArea->lpdbOrdCondInfo->fAll && !pArea->lpdbOrdCondInfo->fAdditive ) )
#ifdef HB_CDX_CLIP_AUTOPEN
hb_cdxOrdListClear( pArea, !hb_set.HB_SET_AUTOPEN, NULL );
hb_cdxOrdListClear( pArea, !hb_setGetL( HB_SET_AUTOPEN ), NULL );
#else
hb_cdxOrdListClear( pArea, !pArea->fHasTags || !hb_set.HB_SET_AUTOPEN, NULL );
hb_cdxOrdListClear( pArea, !pArea->fHasTags || !hb_setGetL( HB_SET_AUTOPEN ), NULL );
#endif
pIndex = hb_cdxFindBag( pArea, szFileName );
@@ -8166,9 +8166,9 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo
!pArea->lpdbOrdCondInfo->fAdditive ) )
{
#ifdef HB_CDX_CLIP_AUTOPEN
hb_cdxOrdListClear( pArea, !hb_set.HB_SET_AUTOPEN, pIndex );
hb_cdxOrdListClear( pArea, !hb_setGetL( HB_SET_AUTOPEN ), pIndex );
#else
hb_cdxOrdListClear( pArea, !pArea->fHasTags || !hb_set.HB_SET_AUTOPEN, pIndex );
hb_cdxOrdListClear( pArea, !pArea->fHasTags || !hb_setGetL( HB_SET_AUTOPEN ), pIndex );
#endif
}
hb_cdxIndexUnLockWrite( pIndex );
@@ -8179,7 +8179,7 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo
if ( !pArea->fReadonly && ( pArea->dbfHeader.bHasTags & 0x01 ) == 0 )
{
#ifdef HB_CDX_CLIP_AUTOPEN
if ( hb_set.HB_SET_AUTOPEN )
if ( hb_setGetL( HB_SET_AUTOPEN ) )
#endif
SELF_WRITEDBHEADER( ( AREAP ) pArea );
}
@@ -8250,7 +8250,7 @@ static ERRCODE hb_cdxOrderDestroy( CDXAREAP pArea, LPDBORDERINFO pOrderInfo )
if ( !pArea->fReadonly && ( pArea->dbfHeader.bHasTags & 0x01 ) != 0 )
{
#ifdef HB_CDX_CLIP_AUTOPEN
if ( hb_set.HB_SET_AUTOPEN )
if ( hb_setGetL( HB_SET_AUTOPEN ) )
#endif
SELF_WRITEDBHEADER( ( AREAP ) pArea );
}
@@ -9014,7 +9014,7 @@ static ERRCODE hb_cdxSetFilter( CDXAREAP pArea, LPDBFILTERINFO pFilterInfo )
if ( SUPER_SETFILTER( ( AREAP ) pArea, pFilterInfo ) != SUCCESS )
return FAILURE;
pArea->dbfi.fOptimized = hb_set.HB_SET_OPTIMIZE;
pArea->dbfi.fOptimized = hb_setGetL( HB_SET_OPTIMIZE );
if ( pArea->dbfi.fOptimized )
{
@@ -9882,7 +9882,7 @@ static void hb_cdxTagDoIndex( LPCDXTAG pTag, BOOL fReindex )
pArea->uiTag = 0;
}
}
fDirectRead = !hb_set.HB_SET_STRICTREAD && /* !pArea->lpdbRelations && */
fDirectRead = !hb_setGetL( HB_SET_STRICTREAD ) && /* !pArea->lpdbRelations && */
( !pArea->lpdbOrdCondInfo || pArea->lpdbOrdCondInfo->fAll ||
( pArea->uiTag == 0 && !fUseFilter ) );

View File

@@ -1,45 +1,14 @@
/*
* $Id$
*
*/
/*
* xHarbour Project source code:
* CT3 NET functions to PC-LAN/MS-NET.
*
* Copyright 2004 Eduardo Fernandes <eduardo@modalsistemas.com.br>
* www - http://www.xharbour.org
*
*******
*
* CT3 NET Functions Comments:
*
* NETCANCEL( <cLocalDevice> ) -> lReleased
* Return true if <cLocalDevice> was disconnected.
*
* NETDISK( cDrive ) -> lSuccess
* Return true if <cDrive> is a network drive, otherwise return false if is a local drive.
*
* NETLOCNAME( cSahredDevice ) -> cLocalDevice
* Not implemented yet.
*
* NETPRINTER() -> lSuccess
* Return true if a current local printer seted by SET PRINTER TO was connected to a
* network printer.
*
* NETREDIR( cLocalDevice, cSharedDevice, [ cPassword ], [ lShowError] ) -> lSuccess
* Return true if <cLocalDevice> was connected to <cSharedDevice> with <cPassword>, if any.
*
* NETRMTNAME( cLocalDevice ) -> cSharedName
* Return the shared resource name connected to a <cLocalDevice>.
* The original parameter <nDevice> in CA-Clipper Tools was changed to <cLocalName> in
* xHarbour because in Windows Network I didn´t find a number table like in MS-DOS. See
* CA-Tools help for more details.
*
* NETWORK() -> lSuccess
* Return true if a PC-LAN/MS-NET or Netware type is active.
*
* NNETWORK() -> lSuccess
* Return true if a Netware type is active.
*
******
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
@@ -79,8 +48,38 @@
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
/*
* CT3 NET Functions Comments:
*
* See doc/license.txt for licensing terms.
* NETCANCEL( <cLocalDevice> ) -> lReleased
* Return true if <cLocalDevice> was disconnected.
*
* NETDISK( cDrive ) -> lSuccess
* Return true if <cDrive> is a network drive, otherwise return false if is a local drive.
*
* NETLOCNAME( cSahredDevice ) -> cLocalDevice
* Not implemented yet.
*
* NETPRINTER() -> lSuccess
* Return true if a current local printer seted by SET PRINTER TO was connected to a
* network printer.
*
* NETREDIR( cLocalDevice, cSharedDevice, [ cPassword ], [ lShowError] ) -> lSuccess
* Return true if <cLocalDevice> was connected to <cSharedDevice> with <cPassword>, if any.
*
* NETRMTNAME( cLocalDevice ) -> cSharedName
* Return the shared resource name connected to a <cLocalDevice>.
* The original parameter <nDevice> in CA-Clipper Tools was changed to <cLocalName> in
* xHarbour because in Windows Network I didn´t find a number table like in MS-DOS. See
* CA-Tools help for more details.
*
* NETWORK() -> lSuccess
* Return true if a PC-LAN/MS-NET or Netware type is active.
*
* NNETWORK() -> lSuccess
* Return true if a Netware type is active.
*
*/
@@ -180,7 +179,7 @@ HB_FUNC( NETCANCEL )
HB_FUNC( NETPRINTER )
{
char *cPrn = hb_set.HB_SET_PRINTFILE; /* query default local printer port. */
char * cPrn = hb_setGetCPtr( HB_SET_PRINTFILE ); /* query default local printer port. */
if( !cPrn || !*cPrn || stricmp( cPrn, "PRN" ) == 0 )
cPrn = "LPT1";

View File

@@ -152,7 +152,7 @@ HB_FUNC( CTODOW )
szDow = hb_strdup( ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_DAY + iDow ) );
hb_strupr( szDow );
if( hb_set.HB_SET_EXACT )
if( hb_setGetL( HB_SET_EXACT ) )
{
iEqual = ( strlen( szDow ) == strlen( szParam ) )
&& !memcmp( szDow, szParam, strlen( szParam ) );
@@ -227,7 +227,7 @@ HB_FUNC( CTOMONTH )
szMonth = hb_strdup( ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_MONTH + iMonth - 1 ) );
hb_strupr( szMonth );
if( hb_set.HB_SET_EXACT )
if( hb_setGetL( HB_SET_EXACT ) )
{
iEqual = ( strlen( szMonth ) == strlen( szParam ) )
&& !memcmp( szMonth, szParam, strlen( szParam ) );
@@ -339,7 +339,7 @@ HB_FUNC( DMY )
szMDY[iLen] = ' ';
iLen++;
if( hb_set.hb_set_century )
if( hb_setGetL( hb_set_century ) )
{
snprintf( szMDY + iLen, 5, "%04d", iYear );
iLen += 4;
@@ -425,7 +425,7 @@ HB_FUNC( MDY )
}
szMDY[iLen++] = ' ';
if( hb_set.hb_set_century )
if( hb_setGetL( hb_set_century ) )
{
snprintf( szMDY + iLen, 5, "%04d", iYear );
iLen += 4;
@@ -945,8 +945,8 @@ HB_FUNC( WEEK )
{
LONG lDate2;
if( hb_set.HB_SET_DATEFORMAT && ( hb_set.HB_SET_DATEFORMAT[0] == 'd' ||
hb_set.HB_SET_DATEFORMAT[0] == 'D' ) )
if( hb_setGetCPtr( HB_SET_DATEFORMAT ) && ( hb_setGetCPtr( HB_SET_DATEFORMAT )[0] == 'd' ||
hb_setGetCPtr( HB_SET_DATEFORMAT )[0] == 'D' ) )
lDate2 = lDate + 3 - ( hb_dateDOW( iYear, iMonth, iDay ) + 5 ) % 7;
else
lDate2 = lDate + 4 - hb_dateDOW( iYear, iMonth, iDay );

View File

@@ -71,14 +71,14 @@ HB_FUNC( MDY )
iLen = strlen( hb_dateCMonth( iMonth ) );
iBufferLen = iLen + ( hb_set.hb_set_century ? 9 : 7 );
iBufferLen = iLen + ( hb_setGetL( hb_set_century ) ? 9 : 7 );
szReturn = ( char * ) hb_xgrab( iBufferLen );
memset( szReturn, ' ', iBufferLen + 1 );
memcpy( szReturn, hb_dateCMonth( iMonth ), iLen );
memcpy( szReturn + iLen + 1, szFormatted + 3, 2 );
szReturn[ iLen + 3 ] = ',';
memcpy( szReturn + iLen + 5, szFormatted + 6 + ( hb_set.hb_set_century ? 0 : 2 ), 2 + ( hb_set.hb_set_century ? 2 : 0 ) );
memcpy( szReturn + iLen + 5, szFormatted + 6 + ( hb_setGetL( hb_set_century ) ? 0 : 2 ), 2 + ( hb_setGetL( hb_set_century ) ? 2 : 0 ) );
hb_retclen( szReturn, iBufferLen );
hb_xfree( szReturn );
@@ -100,13 +100,13 @@ HB_FUNC( DMY )
iLen = strlen( hb_dateCMonth( iMonth ) );
iBufferLen = iLen + ( hb_set.hb_set_century ? 9 : 7 );
iBufferLen = iLen + ( hb_setGetL( hb_set_century ) ? 9 : 7 );
szReturn = ( char * ) hb_xgrab( iBufferLen );
memset( szReturn, ' ', iBufferLen );
memcpy( szReturn, szFormatted + 3, 2 );
memcpy( szReturn + 3, hb_dateCMonth( iMonth ), iLen );
memcpy( szReturn + iLen + 4, szFormatted + 6 + ( hb_set.hb_set_century ? 0 : 2 ), 2 + ( hb_set.hb_set_century ? 2 : 0 ) );
memcpy( szReturn + iLen + 4, szFormatted + 6 + ( hb_setGetL( hb_set_century ) ? 0 : 2 ), 2 + ( hb_setGetL( hb_set_century ) ? 2 : 0 ) );
hb_retclen( szReturn, iBufferLen );
hb_xfree( szReturn );

View File

@@ -4,32 +4,7 @@
/*
* xHarbour Project source code:
* HB_ReadIni - Reading .ini files
*
* Copyright 2002 Giancarlo Niccolai [gian@niccolai.ws]
* www - http://www.xharbour.org
*
* This small procedure reads a .ini file in the standard .ini format into
* an hash array:
* ; A line starting with a ';' is a comment
* # Also, a '#' marks a comment up to the end of the line
* [NewSection]
* Variable = Value
* OtherVariable: Value
*
* You can pass a list of "potential" .ini files in a ';' separated path;
* the first readable file will be loaded.
*
* On error, the function returns NIL. On success, you will have an hash
* array of this form:
*
* { 'MAIN' => { 'Key1' => 'Val1', ... ,'KeyN' => 'ValN'},
* 'Section1' => { 'Key1' => 'Val1', ... ,'KeyN' => 'ValN'},
* ...
* 'SectionN' => { 'Key1' => 'Val1', ... ,'KeyN' => 'ValN'}
* }
*
* Main is the default section (variables that are declared without a section).
* Handling .ini files
*
* Copyright 2002 Giancarlo Niccolai [gian@niccolai.ws]
* www - http://www.xharbour.org
@@ -74,46 +49,63 @@
*
*/
#include "fileio.ch"
/*
* This small procedure reads a .ini file in the standard .ini format into
* an hash array:
* ; A line starting with a ';' is a comment
* # Also, a '#' marks a comment up to the end of the line
* [NewSection]
* Variable = Value
* OtherVariable: Value
*
* You can pass a list of "potential" .ini files in a ';' separated path;
* the first readable file will be loaded.
*
* On error, the function returns NIL. On success, you will have an hash
* array of this form:
*
* { 'MAIN' => { 'Key1' => 'Val1', ... ,'KeyN' => 'ValN'},
* 'Section1' => { 'Key1' => 'Val1', ... ,'KeyN' => 'ValN'},
* ...
* 'SectionN' => { 'Key1' => 'Val1', ... ,'KeyN' => 'ValN'}
* }
*
* Main is the default section (variables that are declared without a section).
*
*/
#include "common.ch"
static s_cLineComment := ";"
static s_cHalfLineComment := "#"
#include "fileio.ch"
PROCEDURE HB_SetIniComment( cLc, cHlc )
STATIC s_cLineComment := ";"
STATIC s_cHalfLineComment := "#"
PROCEDURE hb_SetIniComment( cLc, cHlc )
s_cLineComment := cLc
s_cHalfLineComment := cHlc
RETURN
FUNCTION HB_ReadIni( cFileSpec, bKeyCaseSens, cSplitters, bAutoMain )
LOCAL hIni
FUNCTION hb_ReadIni( cFileSpec, bKeyCaseSens, cSplitters, bAutoMain )
LOCAL hIni := hb_Hash()
/* Default case sensitiveness for keys */
IF bKeyCaseSens == NIL
bKeyCaseSens := .T.
ENDIF
DEFAULT bKeyCaseSens TO .T.
DEFAULT cSplitters TO "=|:"
DEFAULT bAutoMain TO .T.
IF cSplitters == NIL
cSplitters := "=|:"
ENDIF
IF bAutoMain == NIL
bAutoMain := .T.
END
hIni := HB_Hash()
HB_HCaseMatch( hIni, bKeyCaseSens )
HB_HAutoAdd( hIni, HB_HAUTOADD_ASSIGN )
hb_HCaseMatch( hIni, bKeyCaseSens )
hb_HAutoAdd( hIni, HB_HAUTOADD_ASSIGN )
IF bAutoMain
hIni[ "MAIN" ] := hb_Hash()
END
ENDIF
RETURN HB_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMain )
RETURN hb_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMain )
STATIC FUNCTION HB_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMain )
STATIC FUNCTION hb_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMain )
LOCAL aFiles
LOCAL cFile, nLen
LOCAL aKeyVal, hCurrentSection
@@ -121,26 +113,26 @@ STATIC FUNCTION HB_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMai
LOCAL cData, cBuffer, cLine
LOCAL reComment, reInclude, reSection, reSplitters
reComment := HB_RegexComp( s_cHalfLineComment + "|^[ \t]*" + s_cLineComment )
reInclude := HB_RegexComp( "include (.*)" )
reSection := HB_RegexComp( "[[](.*)[]]" )
reSplitters := HB_RegexComp( cSplitters )
reComment := hb_RegexComp( s_cHalfLineComment + "|^[ \t]*" + s_cLineComment )
reInclude := hb_RegexComp( "include (.*)" )
reSection := hb_RegexComp( "[[](.*)[]]" )
reSplitters := hb_RegexComp( cSplitters )
aFiles := HB_aTokens( cFileSpec, HB_OSPATHLISTSEPARATOR() )
aFiles := hb_aTokens( cFileSpec, hb_OSPathListSeparator() )
IF Empty( aFiles )
aFiles := { cFileSpec }
ENDIF
hFile := -1
hFile := F_ERROR
FOR EACH cFile IN aFiles
IF !EMPTY( cFile ) .AND. File( cFile )
IF ( hFile := FOpen( cFile ) ) != -1
IF ! Empty( cFile ) .AND. File( cFile )
IF ( hFile := FOpen( cFile ) ) != F_ERROR
EXIT
ENDIF
ENDIF
NEXT
IF hFile == -1
IF hFile == F_ERROR
RETURN NIL
ENDIF
@@ -156,19 +148,19 @@ STATIC FUNCTION HB_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMai
hCurrentSection := hIni[ "MAIN" ]
ELSE
hCurrentSection := hIni
END
ENDIF
cLine := ""
DO WHILE Len( cData ) > 0
nLen := 2
nLineEnd := At( chr( 13 ) + chr( 10 ), cData )
nLineEnd := At( Chr( 13 ) + Chr( 10 ), cData )
IF nLineEnd == 0
nLineEnd := At( chr( 10 ) + chr( 13 ), cData )
nLineEnd := At( Chr( 10 ) + Chr( 13 ), cData )
IF nLineEnd == 0
nLen := 1
nLineEnd := At( chr( 10 ), cData )
nLineEnd := At( Chr( 10 ), cData )
IF nLineEnd == 0
nLineEnd := At( chr( 13 ), cData )
nLineEnd := At( Chr( 13 ), cData )
IF nLineEnd == 0
nLineEnd := Len( cData )
ENDIF
@@ -177,9 +169,9 @@ STATIC FUNCTION HB_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMai
ENDIF
/* Get the current line */
cLine += AllTrim( Substr( cData, 1, nLineEnd - 1 ) )
cLine += AllTrim( SubStr( cData, 1, nLineEnd - 1 ) )
/* remove current line */
cData := Substr( cData, nLineEnd + nLen )
cData := SubStr( cData, nLineEnd + nLen )
/* Skip void lines */
IF Empty( cLine )
@@ -187,9 +179,9 @@ STATIC FUNCTION HB_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMai
ENDIF
/* Sum up lines terminating with "<space>||" ...*/
IF Len( cLine ) > 3 .and. SubStr( cLine, -3, 3 ) == " ||"
IF Len( cLine ) > 3 .AND. SubStr( cLine, -3, 3 ) == " ||"
cLine := Substr( cLine, 1, Len( cLine ) -2 )
cLine := SubStr( cLine, 1, Len( cLine ) - 2 )
/* ... but proceed if stream over */
IF Len( cData ) > 0
LOOP
@@ -198,9 +190,9 @@ STATIC FUNCTION HB_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMai
ENDIF
/* remove eventual comments */
aKeyVal := HB_RegexSplit( reComment, cLine )
aKeyVal := hb_RegexSplit( reComment, cLine )
IF ! Empty( aKeyVal )
cLine := AllTrim( aKeyVal[1] )
cLine := AllTrim( aKeyVal[ 1 ] )
ENDIF
/* Skip all comment lines */
@@ -209,20 +201,20 @@ STATIC FUNCTION HB_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMai
ENDIF
/* Is it an "INCLUDE" statement ? */
aKeyVal := HB_RegEx( reInclude, cLine )
aKeyVal := hb_RegEx( reInclude, cLine )
IF ! Empty( aKeyVal )
/* ignore void includes */
aKeyVal[ 2 ] := AllTrim( aKeyVal[ 2 ] )
IF Len( aKeyVal[ 2 ] ) == 0
LOOP
ENDIF
HB_ReadIni2( hIni, aKeyVal[ 2 ], bKeyCaseSens, cSplitters, bAutoMain )
hb_ReadIni2( hIni, aKeyVal[ 2 ], bKeyCaseSens, cSplitters, bAutoMain )
cLine := ""
LOOP
ENDIF
/* Is it a NEW section? */
aKeyVal := HB_Regex( reSection, cLine )
aKeyVal := hb_Regex( reSection, cLine )
IF ! Empty( aKeyVal )
cLine := AllTrim( aKeyVal[ 2 ] )
IF Len( cLine ) != 0
@@ -237,7 +229,7 @@ STATIC FUNCTION HB_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMai
ENDIF
/* Is it a valid key */
aKeyVal := HB_RegexSplit( reSplitters, cLine,,, 2 )
aKeyVal := hb_RegexSplit( reSplitters, cLine,,, 2 )
IF Len( aKeyVal ) == 1
/* TODO: Signal error */
cLine := ""
@@ -256,29 +248,28 @@ STATIC FUNCTION HB_ReadIni2( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMai
RETURN hIni
FUNCTION HB_WriteIni( cFileName, hIni, cCommentBegin, cCommentEnd, bAutoMain )
LOCAL hFile := -1
LOCAL lClose := .F.
LOCAL cNewLine := HB_OSNewLine()
FUNCTION hb_WriteIni( xFileName, hIni, cCommentBegin, cCommentEnd, bAutoMain )
LOCAL hFile
LOCAL lClose
LOCAL cNewLine := hb_OSNewLine()
LOCAL cSection
LOCAL cBuffer
IF bAutoMain == NIL
bAutoMain := .T.
END
IF VALTYPE( cFileName ) == "C"
hFile := FCreate( cFileName )
IF ISCHARACTER( xFileName )
hFile := FCreate( xFileName )
lClose := .T.
ELSEIF VALTYPE( cFileName ) == "N"
hFile := cFileName
ENDIF
IF hFile == -1
ELSEIF ISNUMBER( xFileName )
hFile := xFileName
lClose := .F.
ELSE
RETURN .F.
ENDIF
IF !Empty( cCommentBegin )
IF hFile == F_ERROR
RETURN .F.
ENDIF
IF ! Empty( cCommentBegin )
cBuffer := cCommentBegin + cNewLine
IF FWrite( hFile, cBuffer ) != Len( cBuffer )
IF lClose
@@ -288,18 +279,20 @@ FUNCTION HB_WriteIni( cFileName, hIni, cCommentBegin, cCommentEnd, bAutoMain )
ENDIF
ENDIF
DEFAULT bAutoMain TO .T.
/* Write toplevel section */
IF bAutoMain
/* When automain is on, write the main section */
hb_HEval( hIni[ "MAIN" ], ;
{ |cKey, xVal| FWrite( hFile, HB_CStr( cKey ) + " = " + ;
HB_CStr( xVal ) + cNewLine ) } )
{ |cKey, xVal| FWrite( hFile, hb_CStr( cKey ) + " = " + ;
hb_CStr( xVal ) + cNewLine ) } )
ELSE
/* When automain is off, just write all the toplevel variables. */
hb_HEval( hIni, { |cKey, xVal| IIF( ! HB_IsHash( xVal ),;
FWrite( hFile, HB_CStr( cKey ) + " = " + ;
HB_CStr( xVal ) + cNewLine ), /* nothing */ ) } )
hb_HEval( hIni, { |cKey, xVal| IIF( ! hb_IsHash( xVal ),;
FWrite( hFile, hb_CStr( cKey ) + " = " + ;
hb_CStr( xVal ) + cNewLine ), /* nothing */ ) } )
ENDIF
FOR EACH cSection IN hIni
@@ -312,12 +305,12 @@ FUNCTION HB_WriteIni( cFileName, hIni, cCommentBegin, cCommentEnd, bAutoMain )
ENDIF
ELSE
/* When automain is off, skip all the toplevel variables. */
IF ! HB_IsHash( cSection )
IF ! hb_IsHash( cSection )
LOOP
END
ENDIF
ENDIF
cBuffer := cNewLine + "[" + HB_CStr( cSection:__enumKey ) + "]" + cNewLine
cBuffer := cNewLine + "[" + hb_CStr( cSection:__enumKey ) + "]" + cNewLine
IF FWrite( hFile, cBuffer ) != Len( cBuffer )
IF lClose
FClose( hFile )
@@ -326,11 +319,11 @@ FUNCTION HB_WriteIni( cFileName, hIni, cCommentBegin, cCommentEnd, bAutoMain )
ENDIF
hb_HEval( cSection, ;
{ |cKey, xVal| FWrite( hFile, HB_CStr( cKey ) + "=" + ;
HB_CStr( xVal ) + cNewLine ) } )
{ |cKey, xVal| FWrite( hFile, hb_CStr( cKey ) + "=" + ;
hb_CStr( xVal ) + cNewLine ) } )
NEXT
IF !Empty( cCommentEnd )
IF ! Empty( cCommentEnd )
cBuffer := cCommentEnd + cNewLine
IF FWrite( hFile, cBuffer ) != Len( cBuffer )
IF lClose