2006-08-10 14:00 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbapifs.h
    * changed order of members in HB_FNAME structure to avoid possible
      problems with alignment

  * harbour/include/hbexprb.c
    ! cleaned usGroups usage to avoid BCC warnings

  * harbour/source/rtl/filesys.c
  * harbour/source/rtl/fstemp.c
    * code formatting and casting

  * harbour/include/hbset.h
  * harbour/source/rtl/set.c
    * some minor updates for future incoming hb_set structure
      modifications

  * harbour/source/vm/hvm.c
    * use HB_MACRO2STRING() macro for default lang setting

  * harbour/include/hbrdddel.h
  * harbour/source/rdd/delim1.c
  * harbour/source/rdd/dbcmd.c
    + extended COPY TO ... DELIMITED ... / APPEND FROM ... DELIMITED ...
      to support some other common formats.
          COPY TO ... DELIMITED WITH TAB
          APPEND FROM ... DELIMITED WITH TAB
      uses chr(9) as field separator and without string delimiters
          COPY TO ... DELIMITED WITH PIPE
          APPEND FROM ... DELIMITED WITH PIPE
      uses '|' as field separator and without string delimiters
          COPY TO ... DELIMITED WITH ( { cStrDelim, cFldSeparator } )
          APPEND FROM ... DELIMITED WITH ( { cStrDelim, cFldSeparator } )
      allows users to set and any character field delimiters and fields
      separators
This commit is contained in:
Przemyslaw Czerpak
2006-08-10 12:09:14 +00:00
parent 9e344dcbce
commit 24f045e4e4
11 changed files with 118 additions and 50 deletions

View File

@@ -8,6 +8,42 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2006-08-10 14:00 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapifs.h
* changed order of members in HB_FNAME structure to avoid possible
problems with alignment
* harbour/include/hbexprb.c
! cleaned usGroups usage to avoid BCC warnings
* harbour/source/rtl/filesys.c
* harbour/source/rtl/fstemp.c
* code formatting and casting
* harbour/include/hbset.h
* harbour/source/rtl/set.c
* some minor updates for future incoming hb_set structure
modifications
* harbour/source/vm/hvm.c
* use HB_MACRO2STRING() macro for default lang setting
* harbour/include/hbrdddel.h
* harbour/source/rdd/delim1.c
* harbour/source/rdd/dbcmd.c
+ extended COPY TO ... DELIMITED ... / APPEND FROM ... DELIMITED ...
to support some other common formats.
COPY TO ... DELIMITED WITH TAB
APPEND FROM ... DELIMITED WITH TAB
uses chr(9) as field separator and without string delimiters
COPY TO ... DELIMITED WITH PIPE
APPEND FROM ... DELIMITED WITH PIPE
uses '|' as field separator and without string delimiters
COPY TO ... DELIMITED WITH ( { cStrDelim, cFldSeparator } )
APPEND FROM ... DELIMITED WITH ( { cStrDelim, cFldSeparator } )
allows users to set and any character field delimiters and fields
separators
2006-08-10 12:30 UTC+0100 Ryszard Glab <rglab//imid.med.pl>
* source/compiler/harbour.c
* fixed some 'memory unreleased' errors

View File

@@ -160,11 +160,11 @@ extern HB_EXPORT FHANDLE hb_fsGetOsHandle( FHANDLE hFileHandle );
/* Filename support */
typedef struct
{
char szBuffer[ _POSIX_PATH_MAX + HB_MAX_DRIVE_LENGTH + 4 ];
char * szPath;
char * szName;
char * szExtension;
char * szDrive;
char szBuffer[ _POSIX_PATH_MAX + HB_MAX_DRIVE_LENGTH + 4 ];
} HB_FNAME, * PHB_FNAME, * HB_FNAME_PTR;
extern HB_EXPORT PHB_FNAME hb_fsFNameSplit( char * pszFileName ); /* Split given filename into path, name and extension */

View File

@@ -1231,7 +1231,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacroArgList )
case HB_EA_PUSH_PCODE:
{
HB_EXPR_PTR pExpr = pSelf->value.asList.pExprList;
USHORT usItems = 0, usGroups = 0;
USHORT usItems = 0;
while( pExpr )
{
@@ -1242,9 +1242,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacroArgList )
{
HB_EXPR_PCODE1( hb_compGenPushLong, usItems );
usItems = 0;
++usGroups;
}
++usGroups;
}
else
++usItems;

View File

@@ -106,9 +106,8 @@ typedef struct _DELIMAREA
char * szFileName; /* Name of data file */
char * szEol; /* EOL marker */
USHORT uiEolLen; /* Size of EOL marker */
BOOL fDelim; /* Use character field delimiter? */
char cDelim; /* Character field delimiter */
char cSeparator; /* Field delimiter */
char cSeparator; /* Field separator */
USHORT uiRecordLen; /* Size of record */
USHORT * pFieldOffset; /* Pointer to field offset array */
BYTE * pRecord; /* Buffer of record data */

View File

@@ -149,7 +149,7 @@ typedef struct
int HB_SET_AUTOSHARE;
BOOL HB_SET_BELL;
BOOL HB_SET_CANCEL;
char HB_SET_COLOR[ CLR_STRLEN ];
char * HB_SET_COLOR;
BOOL HB_SET_CONFIRM;
BOOL HB_SET_CONSOLE;
char * HB_SET_DATEFORMAT;
@@ -190,7 +190,7 @@ typedef struct
BOOL HB_SET_UNIQUE;
int HB_SET_FILECASE;
int HB_SET_DIRCASE;
char HB_SET_DIRSEPARATOR;
int HB_SET_DIRSEPARATOR;
int HB_SET_VIDEOMODE;
BOOL HB_SET_WRAP;
int HB_SET_DBFLOCKSCHEME;

View File

@@ -4618,7 +4618,7 @@ HB_FUNC( __DBAPP )
ISNIL( 6 ) ? NULL : hb_param( 6, HB_IT_ANY ), /* RecID */
hb_param( 7, HB_IT_LOGICAL ), /* Rest */
hb_parc( 10 ), /* Codepage */
hb_param( 11, HB_IT_STRING ) ) ); /* Delimiter */
hb_param( 11, HB_IT_ANY ) ) ); /* Delimiter */
}
else
{
@@ -4652,7 +4652,7 @@ HB_FUNC( __DBCOPY )
ISNIL( 6 ) ? NULL : hb_param( 6, HB_IT_ANY ), /* RecID */
hb_param( 7, HB_IT_LOGICAL ), /* Rest */
hb_parc( 10 ), /* Codepage */
hb_param( 11, HB_IT_STRING ) ) ); /* Delimiter */
hb_param( 11, HB_IT_ANY ) ) ); /* Delimiter */
}
else
{

View File

@@ -130,7 +130,7 @@ static ULONG hb_delimEncodeBuffer( DELIMAREAP pArea )
uiLen = pField->uiLen;
while( uiLen && pFieldBuf[ uiLen - 1 ] == ' ' )
--uiLen;
if( pArea->fDelim )
if( pArea->cDelim )
{
pBuffer[ ulSize++ ] = pArea->cDelim;
memcpy( pBuffer + ulSize, pFieldBuf, uiLen );
@@ -280,7 +280,7 @@ static ERRCODE hb_delimReadRecord( DELIMAREAP pArea )
while( ch == ' ' );
/* set the stop character */
if( pArea->fDelim && ch == pArea->cDelim )
if( pArea->cDelim && ch == pArea->cDelim )
{
cStop = pArea->cDelim;
ch = hb_delimNextChar( pArea );
@@ -916,15 +916,54 @@ static ERRCODE hb_delimInfo( DELIMAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
if( hb_itemType( pItem ) & HB_IT_STRING )
{
char * szDelim = hb_itemGetCPtr( pItem );
if( hb_stricmp( szDelim, "BLANK" ) == 0 )
{
pArea->fDelim = FALSE;
pArea->cDelim = '\0';
pArea->cSeparator = ' ';
}
#ifndef HB_C52_STRICT
else if( hb_stricmp( szDelim, "PIPE" ) == 0 )
{
pArea->cDelim = '\0';
pArea->cSeparator = '|';
}
else if( hb_stricmp( szDelim, "TAB" ) == 0 )
{
pArea->cDelim = '\0';
pArea->cSeparator = '\t';
}
else
#else
else if( *szDelim )
#endif
{
pArea->cDelim = *szDelim;
}
}
/*
* a small trick which allow to set character field delimiter and
* field separator in COPY TO ... and APPEND FROM ... commands as
* array. F.e.:
* COPY TO test DELIMITED WITH ({"","|"})
*/
#ifndef HB_C52_STRICT
else if( hb_itemType( pItem ) & HB_IT_ARRAY )
{
PHB_ITEM pDelim, pSeparator;
pDelim = hb_arrayGetItemPtr( pItem, 1 );
pSeparator = hb_arrayGetItemPtr( pItem, 2 );
if( hb_itemType( pDelim ) & HB_IT_STRING )
pArea->cDelim = *hb_itemGetCPtr( pDelim );
if( hb_itemType( pSeparator ) & HB_IT_STRING )
{
char * szSeparator = hb_itemGetCPtr( pSeparator );
if( *szSeparator )
pArea->cSeparator = *szSeparator;
}
}
#endif
break;
case DBI_SEPARATOR:
@@ -1081,10 +1120,9 @@ static ERRCODE hb_delimNewArea( DELIMAREAP pArea )
pArea->ulBufferSize = 0;
/* set character field delimiter */
pArea->fDelim = TRUE;
pArea->cDelim = '"';
/* set field delimiter */
/* set field separator */
pArea->cSeparator = ',';
return SUCCESS;

View File

@@ -2350,7 +2350,7 @@ HB_EXPORT BYTE * hb_fileNameConv( char *str ) {
ULONG ulDirLen, ulFileLen;
#ifdef __XHARBOUR__
if ( hb_set.HB_SET_TRIMFILENAME )
if( hb_set.HB_SET_TRIMFILENAME )
{
char *szFileTrim;
ULONG ulLen;
@@ -2365,11 +2365,10 @@ HB_EXPORT BYTE * hb_fileNameConv( char *str ) {
}
#endif
/* Look for filename (Last "\" or DIRSEPARATOR) */
if( hb_set.HB_SET_DIRSEPARATOR != '\\' )
{
char *p = str;
while ( *p )
while( *p )
{
if( *p == '\\' )
{
@@ -2379,7 +2378,8 @@ HB_EXPORT BYTE * hb_fileNameConv( char *str ) {
}
}
if ( ( filename = strrchr( str, hb_set.HB_SET_DIRSEPARATOR ) ) != NULL )
/* Look for filename (Last "\" or DIRSEPARATOR) */
if( ( filename = strrchr( str, hb_set.HB_SET_DIRSEPARATOR ) ) != NULL )
{
filename++;
}
@@ -2391,7 +2391,7 @@ HB_EXPORT BYTE * hb_fileNameConv( char *str ) {
ulDirLen = filename - str;
/* FILECASE */
if ( ulFileLen > 0 )
if( ulFileLen > 0 )
{
if( hb_set.HB_SET_FILECASE == HB_SET_CASE_LOWER )
hb_strLower( filename, strlen(filename) );
@@ -2400,14 +2400,14 @@ HB_EXPORT BYTE * hb_fileNameConv( char *str ) {
}
/* DIRCASE */
if ( ulDirLen > 0 )
if( ulDirLen > 0 )
{
if ( hb_set.HB_SET_DIRCASE == HB_SET_CASE_LOWER )
if( hb_set.HB_SET_DIRCASE == HB_SET_CASE_LOWER )
hb_strLower( str, ulDirLen );
else if( hb_set.HB_SET_DIRCASE == HB_SET_CASE_UPPER )
hb_strUpper( str, ulDirLen );
}
return (( BYTE * ) str);
return ( BYTE * ) str;
}
HB_EXPORT BOOL hb_fsDisableWaitLocks( int iSet )

View File

@@ -198,7 +198,7 @@ HB_EXPORT FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix,
{
int len;
len = strlen( ( char * ) pszName );
pszName[ len ] = hb_set.HB_SET_DIRSEPARATOR;
pszName[ len ] = ( BYTE ) hb_set.HB_SET_DIRSEPARATOR;
pszName[ len + 1 ] = '\0';
}

View File

@@ -73,8 +73,6 @@ static PHB_SET_LISTENER sp_sl_first;
static PHB_SET_LISTENER sp_sl_last;
static int s_next_listener;
static char hb_dirsep_string[2];
static HB_PATHNAMES * sp_set_path;
static void hb_setFreeSetPath( void )
@@ -219,15 +217,16 @@ static FHANDLE open_handle( char * file_name, BOOL bAppend, char * def_ext, HB_s
user_ferror = hb_fsError(); /* Save the current user file error code */
/* Create full filename */
#if defined(OS_UNIX_COMPATIBLE)
if( ( bPipe = ( set_specifier == HB_SET_PRINTFILE && \
(char) *file_name == '|' ) ) ) {
file_name++;
bAppend = FALSE;
}
#endif
if( ! bPipe ) {
#if defined(OS_UNIX_COMPATIBLE)
bPipe = set_specifier == HB_SET_PRINTFILE && file_name[ 0 ] == '|';
if( bPipe )
{
file_name++;
bAppend = FALSE;
}
#endif
if( ! bPipe )
{
pFilename = hb_fsFNameSplit( file_name );
if( ! pFilename->szPath && hb_set.HB_SET_DEFAULT )
@@ -856,11 +855,14 @@ HB_FUNC( SET )
}
break;
case HB_SET_DIRSEPARATOR :
hb_dirsep_string[0] = hb_set.HB_SET_DIRSEPARATOR;
hb_dirsep_string[1] = '\0';
hb_retc( hb_dirsep_string );
if( args > 1 ) hb_set.HB_SET_DIRSEPARATOR = set_char( pArg2, hb_set.HB_SET_DIRSEPARATOR );
{
char szDirSep[ 2 ];
szDirSep[ 0 ] = ( char ) hb_set.HB_SET_DIRSEPARATOR;
szDirSep[ 1 ] = '\0';
hb_retc( szDirSep );
if( args > 1 ) hb_set.HB_SET_DIRSEPARATOR = set_char( pArg2, hb_set.HB_SET_DIRSEPARATOR );
break;
}
case HB_SET_DBFLOCKSCHEME:
hb_retni( hb_set.HB_SET_DBFLOCKSCHEME );
if( args > 1 )
@@ -911,8 +913,8 @@ void hb_setInitialize( void )
hb_set.HB_SET_BELL = FALSE;
hb_set.HB_SET_CANCEL = TRUE;
hb_set.hb_set_century = FALSE;
strncpy( hb_set.HB_SET_COLOR, "W/N,N/W,N/N,N/N,N/W", sizeof( hb_set.HB_SET_COLOR ) );
hb_set.HB_SET_COLOR[ sizeof( hb_set.HB_SET_COLOR ) - 1 ] = '\0';
hb_set.HB_SET_COLOR = ( char * ) hb_xgrab( CLR_STRLEN + 1 );
hb_strncpy( hb_set.HB_SET_COLOR, "W/N,N/W,N/N,N/N,N/W", CLR_STRLEN );
hb_set.HB_SET_CONFIRM = FALSE;
hb_set.HB_SET_CONSOLE = TRUE;
hb_set.HB_SET_DATEFORMAT = ( char * ) hb_xgrab( 9 );
@@ -973,11 +975,7 @@ void hb_setInitialize( void )
hb_set.HB_SET_UNIQUE = FALSE;
hb_set.HB_SET_FILECASE = HB_SET_CASE_MIXED;
hb_set.HB_SET_DIRCASE = HB_SET_CASE_MIXED;
#ifdef HB_OS_UNIX
hb_set.HB_SET_DIRSEPARATOR = '/';
#else
hb_set.HB_SET_DIRSEPARATOR = '\\';
#endif
hb_set.HB_SET_DIRSEPARATOR = OS_PATH_DELIMITER;
hb_set.HB_SET_VIDEOMODE = 0;
hb_set.HB_SET_WRAP = FALSE;
hb_set.HB_SET_DBFLOCKSCHEME = 0;
@@ -1016,6 +1014,7 @@ void hb_setRelease( void )
if( hb_set.HB_SET_MFILEEXT ) hb_xfree( hb_set.HB_SET_MFILEEXT );
if( hb_set.HB_SET_PATH ) hb_xfree( hb_set.HB_SET_PATH );
if( hb_set.HB_SET_PRINTFILE ) hb_xfree( hb_set.HB_SET_PRINTFILE );
if( hb_set.HB_SET_COLOR ) hb_xfree( hb_set.HB_SET_COLOR );
hb_set.HB_SET_TYPEAHEAD = 0; hb_inkeyReset(); /* reset keyboard buffer */

View File

@@ -415,9 +415,7 @@ HB_EXPORT void hb_vmInit( BOOL bStartMainProc )
/* Set the language to the default */
/* This trick is needed to stringify the macro value */
#define HB_LANG_SELECT_DEFAULT( id ) HB_LANG_SELECT_DEFAULT_( id )
#define HB_LANG_SELECT_DEFAULT_( id ) hb_langSelectID( #id )
HB_LANG_SELECT_DEFAULT( HB_LANG_DEFAULT );
hb_langSelectID( HB_MACRO2STRING( HB_LANG_DEFAULT ) );
/* Check for some internal switches */
s_VMFlags = hb_cmdargProcessVM( &s_VMCancelKey, &s_VMCancelKeyEx );
@@ -447,7 +445,7 @@ HB_EXPORT void hb_vmInit( BOOL bStartMainProc )
* explicitly in VM initialization process before hb_vmDoInitFunctions()
* and not depends on INIT clause.
*/
hb_vmDoInitClip();
hb_vmDoInitClip();
hb_vmDoModuleInitFunctions(); /* process AtInit registered functions */
hb_vmDoInitFunctions(); /* process defined INIT functions */