19991021-01:48 GMT+1

This commit is contained in:
Viktor Szakats
1999-10-21 00:04:00 +00:00
parent 8fc39abfde
commit 89d15d3c42
7 changed files with 1262 additions and 1250 deletions

View File

@@ -1,3 +1,13 @@
19991021-01:48 GMT+1 Victor Szel <info@szelvesz.hu>
* include/hbtrace.h
! TRACE() fixed to HB_TRACE() (that was a bit late :)
* Some formatting.
* source/common/hbtrace.c
* Formatting.
* source/pp/*.c
source/pp/stdalone/*.c
* Tabs removed.
19991020-19:40 EDT David G. Holm <dholm@jsd-llc.com>
* include/hbtrace.h

View File

@@ -38,22 +38,22 @@
#if defined(HB_DO_TRACE)
extern char* hb_tr_file_;
extern int hb_tr_line_;
extern char * hb_tr_file_;
extern int hb_tr_line_;
void hb_tr_trace(char* fmt, ...);
void hb_tr_trace( char* fmt, ... );
#define HB_TRACE(x) \
#define HB_TRACE( x ) \
do { \
hb_tr_file_ = __FILE__; \
hb_tr_line_ = __LINE__; \
hb_tr_trace x ; \
} while (0)
} while( 0 )
#else
#define HB_TRACE(x)
#define HB_TRACE( x )
#endif /* #if defined(HB_DO_TRACE) */
#endif /* #if defined(HB_DO_TRACE) */
#endif /* HB_TRACE_H_ */

View File

@@ -39,36 +39,38 @@
#include <stdarg.h>
#include "hbtrace.h"
char* hb_tr_file_ = "";
int hb_tr_line_ = 0;
char * hb_tr_file_ = "";
int hb_tr_line_ = 0;
void hb_tr_trace(char* fmt, ...)
void hb_tr_trace( char * fmt, ...)
{
char buf[1024];
char file[256];
int i, j;
char buf[ 1024 ];
char file[ 256 ];
int i, j;
va_list ap;
va_list ap;
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
va_end(ap);
va_start( ap, fmt );
vsprintf( buf, fmt, ap );
va_end( ap );
for (i = 0; hb_tr_file_[i] != '\0'; ++i) {
if (hb_tr_file_[i] != '.' &&
hb_tr_file_[i] != '/' &&
hb_tr_file_[i] != '\\')
break;
}
for (j = 0; hb_tr_file_[i] != '\0'; ++i, ++j) {
file[j] = hb_tr_file_[i];
}
file[j] = '\0';
for( i = 0; hb_tr_file_[ i ] != '\0'; ++i )
{
if( hb_tr_file_[ i ] != '.' &&
hb_tr_file_[ i ] != '/' &&
hb_tr_file_[ i ] != '\\' )
break;
}
fprintf(stderr, "%s:%d: %s\n",
file, hb_tr_line_, buf);
for( j = 0; hb_tr_file_[ i ] != '\0'; ++i, ++j )
file[ j ] = hb_tr_file_[ i ];
hb_tr_file_ = "";
hb_tr_line_ = 0;
file[ j ] = '\0';
fprintf( stderr, "%s:%d: %s\n", file, hb_tr_line_, buf );
hb_tr_file_ = "";
hb_tr_line_ = 0;
}
#endif /* #if defined(HB_DO_TRACE) */
#endif /* #if defined(HB_DO_TRACE) */

File diff suppressed because it is too large Load Diff

View File

@@ -74,60 +74,60 @@ int PreProcess( FILE * handl_i, FILE * handl_o, char * sOut )
int rezParse;
HB_TRACE(("PreProcess(%p, %p, %s)",
handl_i, handl_o, sOut));
handl_i, handl_o, sOut));
HB_SYMBOL_UNUSED( handl_o );
while( ( rdlen = pp_RdStr( handl_i, sLine + lens, STR_SIZE - lens, lContinue,
sBuffer, &lenBuffer, &iBuffer ) ) >= 0 )
sBuffer, &lenBuffer, &iBuffer ) ) >= 0 )
{
if( ! lInclude )
nline++;
nline++;
lens += rdlen;
if( sLine[ lens - 1 ] == ';' )
{
lContinue = 1;
lens--;
lens--;
while( sLine[ lens ] == ' ' || sLine[ lens ] == '\t' ) lens--;
sLine[ ++lens ] = ' ';
sLine[ ++lens ] = '\0';
{
lContinue = 1;
lens--;
lens--;
while( sLine[ lens ] == ' ' || sLine[ lens ] == '\t' ) lens--;
sLine[ ++lens ] = ' ';
sLine[ ++lens ] = '\0';
*ptrOut++ = '\n';
}
*ptrOut++ = '\n';
}
else
{
lContinue = 0;
lens = 0;
}
{
lContinue = 0;
lens = 0;
}
if( !lContinue )
{
if( *sLine != '\0' )
{
ptr = sLine;
SKIPTABSPACES( ptr );
if( *ptr == '#' )
{
if( ( rezParse = ParseDirective( ptr + 1 ) ) == 0 )
*sLine = '\0';
}
else
{
if( nCondCompile == 0 || aCondCompile[ nCondCompile - 1 ] )
{
if( ( rezParse = ParseExpression( ptr, sOutLine ) ) > 0 )
{
printf( "\nError number %u in line %u\n", rezParse, nline );
}
}
else
*sLine = '\0';
}
}
break;
}
{
if( *sLine != '\0' )
{
ptr = sLine;
SKIPTABSPACES( ptr );
if( *ptr == '#' )
{
if( ( rezParse = ParseDirective( ptr + 1 ) ) == 0 )
*sLine = '\0';
}
else
{
if( nCondCompile == 0 || aCondCompile[ nCondCompile - 1 ] )
{
if( ( rezParse = ParseExpression( ptr, sOutLine ) ) > 0 )
{
printf( "\nError number %u in line %u\n", rezParse, nline );
}
}
else
*sLine = '\0';
}
}
break;
}
}
if( rdlen < 0 ) return 0;
@@ -152,40 +152,40 @@ int Hp_Parse( FILE * handl_i, FILE * handl_o )
HB_TRACE(("Hp_Parse(%p, %p)", handl_i, handl_o));
while( ( rdlen = pp_RdStr( handl_i, sLine + lens, STR_SIZE - lens, lContinue,
sBuffer, &lenBuffer, &iBuffer ) ) >= 0 )
sBuffer, &lenBuffer, &iBuffer ) ) >= 0 )
{
lens += rdlen;
if( sLine[ lens - 1 ] == ';' )
{
lContinue = 1;
lens--;
lens--;
while( sLine[ lens ] == ' ' || sLine[ lens ] == '\t' ) lens--;
sLine[ ++lens ] = ' ';
sLine[ ++lens ] = '\0';
}
{
lContinue = 1;
lens--;
lens--;
while( sLine[ lens ] == ' ' || sLine[ lens ] == '\t' ) lens--;
sLine[ ++lens ] = ' ';
sLine[ ++lens ] = '\0';
}
else
{
lContinue = 0;
lens = 0;
}
{
lContinue = 0;
lens = 0;
}
if( !lContinue )
{
if( *sLine != '\0' )
{
ptr = sLine;
SKIPTABSPACES( ptr );
if( *ptr == '#' )
{
ParseDirective( ptr + 1 );
*sLine = '\0';
}
else
GenWarning( _szPWarnings, 'I', WARN_NONDIRECTIVE, NULL, NULL );
}
}
{
if( *sLine != '\0' )
{
ptr = sLine;
SKIPTABSPACES( ptr );
if( *ptr == '#' )
{
ParseDirective( ptr + 1 );
*sLine = '\0';
}
else
GenWarning( _szPWarnings, 'I', WARN_NONDIRECTIVE, NULL, NULL );
}
}
}
hb_xfree( sBuffer );

View File

@@ -70,22 +70,22 @@ HARBOUR HB___PREPROCESS( void )
SKIPTABSPACES( ptr );
if( setjmp( s_env ) == 0 )
{
int resParse;
if( ( resParse = ParseExpression( ptr, pOut ) ) > 0 )
{
/* Some error here? */
}
hb_retc( pText ); /* Preprocessor returns parsed line in input buffer */
}
{
int resParse;
if( ( resParse = ParseExpression( ptr, pOut ) ) > 0 )
{
/* Some error here? */
}
hb_retc( pText ); /* Preprocessor returns parsed line in input buffer */
}
else
{
/* an error occured during parsing.
* The longjmp was used in GenError()
*/
hb_retc( "ERROR" );
}
{
/* an error occured during parsing.
* The longjmp was used in GenError()
*/
hb_retc( "ERROR" );
}
hb_xfree( pText );
hb_xfree( pOut );
@@ -97,7 +97,7 @@ HARBOUR HB___PREPROCESS( void )
void GenError( char * _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 )
{
HB_TRACE(("GenError(%p, %c, %d, %s, %s)",
_szErrors, cPrefix, iError, szError1, szError2));
_szErrors, cPrefix, iError, szError1, szError2));
/* TODO: The internal buffers allocated by the preprocessor should be
* deallocated here
@@ -113,7 +113,7 @@ void GenError( char * _szErrors[], char cPrefix, int iError, char * szError1, ch
void GenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2)
{
HB_TRACE(("GenWarning(%p, %c, %d, %s, %s)",
_szWarnings, cPrefix, iWarning, szWarning1, szWarning2));
_szWarnings, cPrefix, iWarning, szWarning1, szWarning2));
/* NOTE:
* All warnings are simply ignored

View File

@@ -78,74 +78,74 @@ int main( int argc, char * argv[] )
HB_TRACE(("main(%d, %p)", argc, argv));
printf( "Harbour Preprocessor, Build %i%s (%04d.%02d.%02d)\n",
hb_build, hb_revision, hb_year, hb_month, hb_day );
hb_build, hb_revision, hb_year, hb_month, hb_day );
printf( "Copyright 1999, http://www.harbour-project.org\n" );
while( iArg < argc )
{
if( IS_OPT_SEP(argv[ iArg ][ 0 ]))
{
switch( argv[ iArg ][ 1 ] )
{
{
switch( argv[ iArg ][ 1 ] )
{
case 'd':
case 'D': /* defines a #define from the command line */
{
i = 0;
szDefText = strodup( argv[ iArg ] + 2 );
while( i < strolen( szDefText ) && szDefText[ i ] != '=' )
i++;
if( szDefText[ i ] != '=' )
AddDefine( szDefText, 0 );
else
{
i = 0;
szDefText = strodup( argv[ iArg ] + 2 );
while( i < strolen( szDefText ) && szDefText[ i ] != '=' )
i++;
if( szDefText[ i ] != '=' )
AddDefine( szDefText, 0 );
else
{
szDefText[ i ] = 0;
AddDefine( szDefText, szDefText + i + 1 );
szDefText[ i ] = 0;
AddDefine( szDefText, szDefText + i + 1 );
}
free( szDefText );
}
break;
free( szDefText );
}
break;
case 'i':
case 'I':
AddSearchPath( argv[ iArg ]+2, &_pIncludePath );
break;
AddSearchPath( argv[ iArg ]+2, &_pIncludePath );
break;
case 'o':
case 'O':
bOutTable = TRUE;
break;
bOutTable = TRUE;
break;
case 'n':
case 'N':
bOutNew = TRUE;
break;
bOutNew = TRUE;
break;
case 'w':
case 'W':
_iWarnings = 1;
if( argv[ iArg ][ 2 ] )
{ /*there is -w<0,1,2,3> probably */
_iWarnings = 1;
if( argv[ iArg ][ 2 ] )
{ /*there is -w<0,1,2,3> probably */
_iWarnings = argv[ iArg ][ 2 ] - '0';
if( _iWarnings < 0 || _iWarnings > 3 )
printf( "\nInvalid command line option: %s\n", argv[ iArg ] );
}
break;
printf( "\nInvalid command line option: %s\n", argv[ iArg ] );
}
break;
default:
printf( "\nInvalid command line option: %s\n", &argv[ iArg ][ 1 ] );
break;
}
}
printf( "\nInvalid command line option: %s\n", &argv[ iArg ][ 1 ] );
break;
}
}
else _pFileName = hb_fsFNameSplit( argv[ iArg ] );
iArg++;
}
if( _pFileName )
{
if( ! _pFileName->szExtension )
_pFileName->szExtension =".prg";
_pFileName->szExtension =".prg";
hb_fsFNameMerge( szFileName, _pFileName );
if( ( handl_i = fopen( szFileName, "r" ) ) == NULL )
{
printf("\nCan't open %s\n", szFileName );
return 1;
}
{
printf("\nCan't open %s\n", szFileName );
return 1;
}
printf( "\nParsing file %s\n", szFileName );
}
@@ -162,7 +162,7 @@ int main( int argc, char * argv[] )
, argv[ 0 ] );
if( bOutTable )
OutTable( NULL, NULL );
OutTable( NULL, NULL );
return 1;
}
@@ -181,17 +181,17 @@ int main( int argc, char * argv[] )
if( szInclude )
{
char * pPath;
char * pDelim;
char * pPath;
char * pDelim;
pPath = szInclude = strodup( szInclude );
while( ( pDelim = strchr( pPath, OS_PATH_LIST_SEPARATOR ) ) != NULL )
{
pPath = szInclude = strodup( szInclude );
while( ( pDelim = strchr( pPath, OS_PATH_LIST_SEPARATOR ) ) != NULL )
{
*pDelim = '\0';
AddSearchPath( pPath, &_pIncludePath );
pPath = pDelim + 1;
}
AddSearchPath( pPath, &_pIncludePath );
}
AddSearchPath( pPath, &_pIncludePath );
}
}
@@ -222,50 +222,50 @@ int Hp_Parse( FILE * handl_i, FILE * handl_o )
HB_TRACE(("Hp_parse(%p, %p)", handl_i, handl_o));
while( ( rdlen = pp_RdStr( handl_i, sLine + lens, STR_SIZE - lens, lContinue,
sBuffer, &lenBuffer, &iBuffer ) ) >= 0 )
sBuffer, &lenBuffer, &iBuffer ) ) >= 0 )
{
if( ! lInclude ) nline++;
lens += rdlen;
if( sLine[ lens - 1 ] == ';' )
{
lContinue = 1;
lens--;
lens--;
while( sLine[ lens ] == ' ' || sLine[ lens ] == '\t' ) lens--;
sLine[ ++lens ] = ' ';
sLine[ ++lens ] = '\0';
}
{
lContinue = 1;
lens--;
lens--;
while( sLine[ lens ] == ' ' || sLine[ lens ] == '\t' ) lens--;
sLine[ ++lens ] = ' ';
sLine[ ++lens ] = '\0';
}
else
{
lContinue = 0;
lens = 0;
}
{
lContinue = 0;
lens = 0;
}
if( *sLine != '\0' && !lContinue )
{
printf( "\r line %i", nline );
ptr = sLine;
SKIPTABSPACES( ptr );
if( *ptr == '#' )
{
if( ParseDirective( ptr + 1 ) == 0 )
*sLine = '\0';
}
else
{
if( nCondCompile == 0 || aCondCompile[ nCondCompile - 1 ] )
ParseExpression( ptr, sOutLine );
else
*sLine = '\0';
}
}
{
printf( "\r line %i", nline );
ptr = sLine;
SKIPTABSPACES( ptr );
if( *ptr == '#' )
{
if( ParseDirective( ptr + 1 ) == 0 )
*sLine = '\0';
}
else
{
if( nCondCompile == 0 || aCondCompile[ nCondCompile - 1 ] )
ParseExpression( ptr, sOutLine );
else
*sLine = '\0';
}
}
if( ! lInclude )
{
if( lContinue ) pp_WrStr( handl_o, "\n" );
else pp_WrStr( handl_o, sLine );
}
{
if( lContinue ) pp_WrStr( handl_o, "\n" );
else pp_WrStr( handl_o, sLine );
}
}
return 0;
@@ -308,18 +308,18 @@ void OutTable( DEFINES * endDefine, COMMANDS * endCommand )
fprintf( handl_o, "\n static DEFINES sD___%i = ", num );
fprintf( handl_o, "{\"%s\",", stdef2->name );
if( stdef2->pars )
fprintf( handl_o, "\"%s\",", stdef2->pars );
fprintf( handl_o, "\"%s\",", stdef2->pars );
else
fprintf( handl_o, "NULL," );
fprintf( handl_o, "NULL," );
fprintf( handl_o, "%d,", stdef2->npars );
if( stdef2->value )
fprintf( handl_o, "\"%s\"", stdef2->value );
fprintf( handl_o, "\"%s\"", stdef2->value );
else
fprintf( handl_o, "NULL" );
fprintf( handl_o, "NULL" );
if( num == 1 )
fprintf( handl_o, ", NULL };" );
fprintf( handl_o, ", NULL };" );
else
fprintf( handl_o, ", &sD___%i };", num - 1 );
fprintf( handl_o, ", &sD___%i };", num - 1 );
stdef2 = stdef2->last;
num++;
}
@@ -335,34 +335,34 @@ void OutTable( DEFINES * endDefine, COMMANDS * endCommand )
fprintf( handl_o, "\n static COMMANDS sC___%i = ", num );
fprintf( handl_o, "{%d,\"%s\",", stcmd2->com_or_xcom, stcmd2->name );
if( stcmd2->mpatt != NULL )
{
len_mpatt = strocpy( sLine, stcmd2->mpatt );
while( ( ipos = pp_strAt( "\1", 1, sLine, len_mpatt ) ) > 0 )
{
pp_Stuff( "\\1", sLine + ipos - 1, 2, 1, len_mpatt );
len_mpatt++;
}
fprintf( handl_o, "\"%s\",", sLine );
}
{
len_mpatt = strocpy( sLine, stcmd2->mpatt );
while( ( ipos = pp_strAt( "\1", 1, sLine, len_mpatt ) ) > 0 )
{
pp_Stuff( "\\1", sLine + ipos - 1, 2, 1, len_mpatt );
len_mpatt++;
}
fprintf( handl_o, "\"%s\",", sLine );
}
else
fprintf( handl_o, "NULL," );
fprintf( handl_o, "NULL," );
if( stcmd2->value != NULL )
{
len_value = strocpy( sLine, stcmd2->value );
while( ( ipos = pp_strAt( "\1", 1, sLine, len_value ) ) > 0 )
{
pp_Stuff( "\\1", sLine + ipos - 1, 2, 1, len_value );
len_value++;
}
if( len_mpatt + len_value > 80 )
{
len_value = strocpy( sLine, stcmd2->value );
while( ( ipos = pp_strAt( "\1", 1, sLine, len_value ) ) > 0 )
{
pp_Stuff( "\\1", sLine + ipos - 1, 2, 1, len_value );
len_value++;
}
if( len_mpatt + len_value > 80 )
fprintf( handl_o, "\n " );
fprintf( handl_o, "\"%s\"", sLine );
}
fprintf( handl_o, "\"%s\"", sLine );
}
else fprintf( handl_o, "NULL" );
if( num == 1 )
fprintf( handl_o, ",NULL };" );
fprintf( handl_o, ",NULL };" );
else
fprintf( handl_o, ",&sC___%i };", num - 1 );
fprintf( handl_o, ",&sC___%i };", num - 1 );
stcmd2 = stcmd2->last;
num++;
}
@@ -387,34 +387,34 @@ void OutTable( DEFINES * endDefine, COMMANDS * endCommand )
fprintf( handl_o, "\n static COMMANDS sC___%i = ", num );
fprintf( handl_o, "{%d,\"%s\",", stcmd2->com_or_xcom, stcmd2->name );
if( stcmd2->mpatt != NULL )
{
len_mpatt = strocpy( sLine, stcmd2->mpatt );
while( ( ipos = pp_strAt( "\1", 1, sLine, len_mpatt ) ) > 0 )
{
pp_Stuff( "\\1", sLine + ipos - 1, 2, 1, len_mpatt );
len_mpatt++;
}
fprintf( handl_o, "\"%s\",", sLine );
}
{
len_mpatt = strocpy( sLine, stcmd2->mpatt );
while( ( ipos = pp_strAt( "\1", 1, sLine, len_mpatt ) ) > 0 )
{
pp_Stuff( "\\1", sLine + ipos - 1, 2, 1, len_mpatt );
len_mpatt++;
}
fprintf( handl_o, "\"%s\",", sLine );
}
else
fprintf( handl_o, "NULL," );
fprintf( handl_o, "NULL," );
if( stcmd2->value != NULL )
{
len_value = strocpy( sLine, stcmd2->value );
while( ( ipos = pp_strAt( "\1", 1, sLine, len_value ) ) > 0 )
{
pp_Stuff( "\\1", sLine + ipos - 1, 2, 1, len_value );
len_value++;
}
if( len_mpatt + len_value > 80 )
{
len_value = strocpy( sLine, stcmd2->value );
while( ( ipos = pp_strAt( "\1", 1, sLine, len_value ) ) > 0 )
{
pp_Stuff( "\\1", sLine + ipos - 1, 2, 1, len_value );
len_value++;
}
if( len_mpatt + len_value > 80 )
fprintf( handl_o, "\n " );
fprintf( handl_o, "\"%s\"", sLine );
}
fprintf( handl_o, "\"%s\"", sLine );
}
else fprintf( handl_o, "NULL" );
if( num == 1 )
fprintf( handl_o, ",NULL };" );
fprintf( handl_o, ",NULL };" );
else
fprintf( handl_o, ",&sC___%i };", num - 1 );
fprintf( handl_o, ",&sC___%i };", num - 1 );
stcmd2 = stcmd2->last;
num++;
}
@@ -439,7 +439,7 @@ void AddSearchPath( char * szPath, PATHNAMES * * pSearchList )
if( pPath )
{
while( pPath->pNext )
pPath = pPath->pNext;
pPath = pPath->pNext;
pPath->pNext = ( PATHNAMES * ) hb_xgrab( sizeof( PATHNAMES ) );
pPath = pPath->pNext;
}
@@ -454,7 +454,7 @@ void AddSearchPath( char * szPath, PATHNAMES * * pSearchList )
void GenError( char * _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 )
{
HB_TRACE(("GenError(%p, %c, %d, %s, %s)",
_szErrors, cPrefix, iError, szError1, szError2));
_szErrors, cPrefix, iError, szError1, szError2));
printf( "\r(%i) ", nline );
printf( "Error %c%04i ", cPrefix, iError );
@@ -467,19 +467,19 @@ void GenError( char * _szErrors[], char cPrefix, int iError, char * szError1, ch
void GenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2)
{
HB_TRACE(("GenWarning(%p, %c, %d, %s, %s)",
_szWarnings, cPrefix, iWarning, szWarning1, szWarning2));
_szWarnings, cPrefix, iWarning, szWarning1, szWarning2));
if( _iWarnings )
{
char *szText = _szWarnings[ iWarning - 1 ];
if( (szText[ 0 ] - '0') <= _iWarnings )
{
printf( "\r(%i) ", nline );
printf( "Warning %c%04i ", cPrefix, iWarning );
printf( szText + 1, szWarning1, szWarning2 );
printf( "\n" );
}
{
printf( "\r(%i) ", nline );
printf( "Warning %c%04i ", cPrefix, iWarning );
printf( szText + 1, szWarning1, szWarning2 );
printf( "\n" );
}
}
}
@@ -519,20 +519,20 @@ PHB_FNAME hb_fsFNameSplit( char * szFileName )
{
/* If we are after a drive letter let's keep the following backslash */
if( IS_PATH_SEP( ':' ) &&
( szFileName[ iSlashPos ] == ':' || szFileName[ iSlashPos - 1 ] == ':' ) )
{
/* path with separator -> d:\path\filename or d:path\filename */
memcpy( pFileName->szBuffer, szFileName, iSlashPos + 1 );
pFileName->szBuffer[ iSlashPos + 1 ] = '\0';
iPos = iSlashPos + 2; /* first free position after the slash */
}
( szFileName[ iSlashPos ] == ':' || szFileName[ iSlashPos - 1 ] == ':' ) )
{
/* path with separator -> d:\path\filename or d:path\filename */
memcpy( pFileName->szBuffer, szFileName, iSlashPos + 1 );
pFileName->szBuffer[ iSlashPos + 1 ] = '\0';
iPos = iSlashPos + 2; /* first free position after the slash */
}
else
{
/* path with separator -> path\filename */
memcpy( pFileName->szBuffer, szFileName, iSlashPos );
pFileName->szBuffer[ iSlashPos ] = '\0';
iPos = iSlashPos + 1; /* first free position after the slash */
}
{
/* path with separator -> path\filename */
memcpy( pFileName->szBuffer, szFileName, iSlashPos );
pFileName->szBuffer[ iSlashPos ] = '\0';
iPos = iSlashPos + 1; /* first free position after the slash */
}
pFileName->szPath = pFileName->szBuffer;
}
@@ -547,19 +547,19 @@ PHB_FNAME hb_fsFNameSplit( char * szFileName )
* and there is at least one character between a slash and a dot
*/
if( iDotPos == iLen - 1 )
{
/* the dot is the last character - use it as extension name */
pFileName->szExtension = pFileName->szBuffer + iPos;
pFileName->szBuffer[ iPos++ ] = '.';
pFileName->szBuffer[ iPos++ ] = '\0';
}
{
/* the dot is the last character - use it as extension name */
pFileName->szExtension = pFileName->szBuffer + iPos;
pFileName->szBuffer[ iPos++ ] = '.';
pFileName->szBuffer[ iPos++ ] = '\0';
}
else
{
pFileName->szExtension = pFileName->szBuffer + iPos;
/* copy rest of the string with terminating ZERO character */
memcpy( pFileName->szExtension, szFileName + iDotPos + 1, iLen - iDotPos );
iPos += iLen - iDotPos;
}
{
pFileName->szExtension = pFileName->szBuffer + iPos;
/* copy rest of the string with terminating ZERO character */
memcpy( pFileName->szExtension, szFileName + iDotPos + 1, iLen - iDotPos );
iPos += iLen - iDotPos;
}
}
else
/* there is no dot in the filename or it is '.filename' */
@@ -596,24 +596,24 @@ char * hb_fsFNameMerge( char * szFileName, PHB_FNAME pFileName )
/* if the path is a root directory then we don't need to add path separator */
if( !( IS_PATH_SEP( pFileName->szPath[ 0 ] ) && pFileName->szPath[ 0 ] == '\0' ) )
{
/* add the path separator only in cases:
* when a name doesn't start with it
* when the path doesn't end with it
*/
if( !( IS_PATH_SEP( pFileName->szName[ 0 ] ) || IS_PATH_SEP( pFileName->szPath[ iLen-1 ] ) ) )
{
szFileName[ iLen++ ] = OS_PATH_DELIMITER;
szFileName[ iLen ] = '\0';
}
}
{
/* add the path separator only in cases:
* when a name doesn't start with it
* when the path doesn't end with it
*/
if( !( IS_PATH_SEP( pFileName->szName[ 0 ] ) || IS_PATH_SEP( pFileName->szPath[ iLen-1 ] ) ) )
{
szFileName[ iLen++ ] = OS_PATH_DELIMITER;
szFileName[ iLen ] = '\0';
}
}
if( pFileName->szName )
strcpy( szFileName + iLen, pFileName->szName );
strcpy( szFileName + iLen, pFileName->szName );
}
else
{
if( pFileName->szName )
strcpy( szFileName, pFileName->szName );
strcpy( szFileName, pFileName->szName );
}
if( pFileName->szExtension )
@@ -621,11 +621,11 @@ char * hb_fsFNameMerge( char * szFileName, PHB_FNAME pFileName )
int iLen = strlen( szFileName );
if( !( pFileName->szExtension[ 0 ] == '.' || szFileName[ iLen - 1 ] == '.') )
{
/* add extension separator only when extansion doesn't contain it */
szFileName[ iLen++ ] = '.';
szFileName[ iLen ] = '\0';
}
{
/* add extension separator only when extansion doesn't contain it */
szFileName[ iLen++ ] = '.';
szFileName[ iLen ] = '\0';
}
strcpy( szFileName + iLen, pFileName->szExtension );
}