From 418caaac5137d2df1f64b4719ec9296ca6a9001a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Tue, 17 Feb 2015 12:06:51 +0100 Subject: [PATCH] 2015-02-17 12:06 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbssl/tests/inetssl.prg * contrib/rddads/ads1.c * src/rtl/teditor.prg * formatting of my recent modifications taken from Viktor's branch * src/common/hbfsapi.c * src/compiler/complex.c * formatting * include/hbset.h * src/vm/set.c * src/nortl/nortl.c + add new C functions to change HVM set values: hb_setSetFileCase(), hb_setSetDirCase(), hb_setSetDirSeparator(), hb_setSetTrimFileName() * include/hbcomp.h * include/hbcompdf.h * src/compiler/cmdcheck.c * src/compiler/hbmain.c * src/compiler/ppcomp.c * src/compiler/genc.c * src/compiler/hbusage.c * src/nortl/nortl.c * rewritten code used to parse command line and environment parameters. New code is covered by GPL + Harbour exception license. All parameters are decoded by only one function and whole code is smaller so it's much easier to modify this code. ! fixed some small bugs and incompatibilities with Cl*pper in parameter parsing ! fixed -y undocumented (YYDEBUG) switch - removed -x[] set symbol init function name prefix (for .c only) compiler command line switch * moved -fn[:[l|u]|-] -fd[:[l|u]|-] -fp[:] and -fs[-] switches parsing to core compiler library. Now these switches are also works with compiler library linked with HBMK2. ; TOFIX: HBMK2 ignores -fn/-fd switches and allocates temporary names which are not compatible with names used later by harbour compiler when above switches are activated. HBMK2 should parse parameters and update SET FILECASE / SET DIRCASE before it creates temporary files. --- ChangeLog.txt | 43 + contrib/hbssl/tests/inetssl.prg | 72 +- contrib/rddads/ads1.c | 48 +- include/hbcomp.h | 11 +- include/hbcompdf.h | 10 +- include/hbset.h | 16 +- src/common/hbfsapi.c | 8 +- src/compiler/cmdcheck.c | 1976 +++++++++++++------------------ src/compiler/complex.c | 1 - src/compiler/genc.c | 13 +- src/compiler/hbmain.c | 18 +- src/compiler/hbusage.c | 1 - src/compiler/ppcomp.c | 5 +- src/main/harbour.c | 2 - src/nortl/nortl.c | 120 +- src/rtl/teditor.prg | 2 +- src/vm/set.c | 36 +- 17 files changed, 1017 insertions(+), 1365 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 314912b2b1..fb0efdf74c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,49 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2015-02-17 12:06 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbssl/tests/inetssl.prg + * contrib/rddads/ads1.c + * src/rtl/teditor.prg + * formatting of my recent modifications taken from Viktor's branch + + * src/common/hbfsapi.c + * src/compiler/complex.c + * formatting + + * include/hbset.h + * src/vm/set.c + * src/nortl/nortl.c + + add new C functions to change HVM set values: + hb_setSetFileCase(), hb_setSetDirCase(), hb_setSetDirSeparator(), + hb_setSetTrimFileName() + + * include/hbcomp.h + * include/hbcompdf.h + * src/compiler/cmdcheck.c + * src/compiler/hbmain.c + * src/compiler/ppcomp.c + * src/compiler/genc.c + * src/compiler/hbusage.c + * src/nortl/nortl.c + * rewritten code used to parse command line and environment parameters. + New code is covered by GPL + Harbour exception license. + All parameters are decoded by only one function and whole code is + smaller so it's much easier to modify this code. + ! fixed some small bugs and incompatibilities with Cl*pper in parameter + parsing + ! fixed -y undocumented (YYDEBUG) switch + - removed -x[] set symbol init function name prefix (for .c only) + compiler command line switch + * moved -fn[:[l|u]|-] -fd[:[l|u]|-] -fp[:] and -fs[-] switches + parsing to core compiler library. Now these switches are also works + with compiler library linked with HBMK2. + ; TOFIX: HBMK2 ignores -fn/-fd switches and allocates temporary names + which are not compatible with names used later by harbour + compiler when above switches are activated. HBMK2 should + parse parameters and update SET FILECASE / SET DIRCASE before + it creates temporary files. + 2015-02-15 21:31 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rdd/dbf1.c * slightly modified code which tries to detect if field flags were diff --git a/contrib/hbssl/tests/inetssl.prg b/contrib/hbssl/tests/inetssl.prg index a881bdc220..f60aae6d7c 100644 --- a/contrib/hbssl/tests/inetssl.prg +++ b/contrib/hbssl/tests/inetssl.prg @@ -9,25 +9,25 @@ #define EOL e"\r\n" #define PEM_CERT_FILE "inetssl.pem" -STATIC s_lReady := .f. -STATIC s_lStop := .f. +STATIC s_lReady := .F. +STATIC s_lStop := .F. -STATIC s_lDelaySrv := .f. -STATIC s_lDelayCli := .f. +STATIC s_lDelaySrv := .F. +STATIC s_lDelayCli := .F. REQUEST HB_MT PROCEDURE Main( delay ) LOCAL thrd - if !empty( delay ) - s_lDelayCli := "C" $ upper( delay ) - s_lDelaySrv := "S" $ upper( delay ) - endif + IF ! Empty( delay ) + s_lDelayCli := "C" $ Upper( delay ) + s_lDelaySrv := "S" $ Upper( delay ) + ENDIF /* initialize SSL library */ SSL_init() - RAND_seed( Time() + hb_tsToStr( hb_dateTime() ) + hb_DirBase() + NetName() ) + RAND_seed( Time() + hb_TSToStr( hb_DateTime() ) + hb_DirBase() + NetName() ) /* start server thread */ thrd := hb_threadStart( @Server() ) @@ -45,14 +45,14 @@ PROCEDURE Main( delay ) Client() /* inform server it should finish and wait for it */ - s_lStop := .t. + s_lStop := .T. hb_threadJoin( thrd ) ? RETURN -FUNCTION Client() +STATIC FUNCTION Client() LOCAL sock, ssl_ctx, ssl, nResult, nErr, cLine ssl_ctx := SSL_CTX_new() @@ -62,7 +62,7 @@ FUNCTION Client() hb_inetTimeout( sock, 5000 ) ? "CLIENT: connecting..." - IF empty( hb_inetConnectIP( "127.0.0.1", N_PORT, sock ) ) + IF Empty( hb_inetConnectIP( "127.0.0.1", N_PORT, sock ) ) ? "CLIENT: cannot connect to server." ELSE ? "CLIENT: connected to the server." @@ -76,29 +76,28 @@ FUNCTION Client() ? "CLIENT: SSL CONNECT..." nResult := hb_inetSSL_CONNECT( sock, ssl ) nErr := ERR_get_error() - ?? hb_strFormat( e"\nCLIENT: hb_inetSSL_CONNECT()=>%d (%d), '%s'\n", ; + ?? hb_StrFormat( e"\nCLIENT: hb_inetSSL_CONNECT()=>%d (%d), '%s'\n", ; nResult, nErr, ; ERR_error_string( nErr ) ) IF nResult == 1 - ? "CLIENT: connected with " + SSL_get_cipher( ssl ) + " encryption." + ? "CLIENT: connected with", SSL_get_cipher( ssl ), "encryption." DipsCertInfo( ssl, "CLIENT: " ) - hb_inetSendAll( sock, hb_tsToStr( hb_dateTime() ) + EOL ) - DO WHILE ! empty( cLine := hb_inetRecvLine( sock ) ) - ? "CLIENT: RECV:", hb_valToExp( cLine ) + hb_inetSendAll( sock, hb_TSToStr( hb_DateTime() ) + EOL ) + DO WHILE ! Empty( cLine := hb_inetRecvLine( sock ) ) + ? "CLIENT: RECV:", hb_ValToExp( cLine ) ENDDO ENDIF - ENDIF hb_inetClose( sock ) RETURN NIL -FUNCTION Server() +STATIC FUNCTION Server() LOCAL sockSrv, sockConn, ssl_ctx, ssl, nResult, nErr, cLine - ? "SERVER: create listen socekt..." + ? "SERVER: create listen socket..." IF Empty( sockSrv := hb_inetServer( N_PORT ) ) ? "SERVER: cannot create listen socket." ELSE @@ -107,11 +106,11 @@ FUNCTION Server() LoadCertificates( ssl_ctx, PEM_CERT_FILE, PEM_CERT_FILE ) ssl := SSL_new( ssl_ctx ) - ? "SERVER: waiting for connecitons..." + ? "SERVER: waiting for connections..." hb_inetTimeout( sockSrv, 100 ) - s_lReady := .t. + s_lReady := .T. DO WHILE ! s_lStop - IF !Empty( sockConn := hb_inetAccept( sockSrv ) ) + IF ! Empty( sockConn := hb_inetAccept( sockSrv ) ) ? "SERVER: accepted new connection." hb_inetTimeout( sockConn, 3000 ) @@ -123,18 +122,18 @@ FUNCTION Server() ? "SERVER: SSL ACCEPT..." nResult := hb_inetSSL_ACCEPT( sockConn, ssl ) nErr := ERR_get_error() - ?? hb_strFormat( e"\nSERVER: hb_inetSSL_ACCEPT()=>%d (%d), '%s'\n", ; + ?? hb_StrFormat( e"\nSERVER: hb_inetSSL_ACCEPT()=>%d (%d), '%s'\n", ; nResult, nErr, ; ERR_error_string( nErr ) ) IF nResult == 1 cLine := hb_inetRecvLine( sockConn ) - ? "SERVER: RECV:", hb_valToExp( cLine ) + ? "SERVER: RECV:", hb_ValToExp( cLine ) hb_inetSendAll( sockConn, ; "ECHO[ " + cLine + " ]" + EOL + ; - hb_tsToStr( hb_dateTime() ) + EOL + ; + hb_TSToStr( hb_DateTime() ) + EOL + ; OS() + EOL + ; - VERSION() + EOL + ; + Version() + EOL + ; EOL ) ENDIF @@ -143,21 +142,20 @@ FUNCTION Server() ENDIF ENDDO - s_lReady := .f. - + s_lReady := .F. ENDIF RETURN NIL -FUNCTION LoadCertificates( ssl_ctx, cCertFile, cKeyFile ) +STATIC FUNCTION LoadCertificates( ssl_ctx, cCertFile, cKeyFile ) /* Server using hb_inetSSL_ACCEPT() needs certificates, they can be generated using the following command: openssl req -x509 -nodes -days 365 -newkey rsa:1024 \ -out -keyout */ - IF ! hb_fileExists( cCertFile ) .AND. ! hb_fileExists( cKeyFile ) + IF ! hb_FileExists( cCertFile ) .AND. ! hb_FileExists( cKeyFile ) ? "SERVER: generating certificates..." hb_run( "openssl req -x509 -nodes -days 365 -newkey rsa:1024 " + ; "-out " + cCertFile + " -keyout " + cKeyFile ) @@ -165,14 +163,14 @@ FUNCTION LoadCertificates( ssl_ctx, cCertFile, cKeyFile ) /* set the local certificate from CertFile */ IF SSL_CTX_use_certificate_file( ssl_ctx, cCertFile, HB_SSL_FILETYPE_PEM ) <= 0 - OutErr( hb_strFormat( e"SERVER: SSL_CTX_use_certificate_file()=> '%s'\n", ; + OutErr( hb_StrFormat( e"SERVER: SSL_CTX_use_certificate_file()=> '%s'\n", ; ERR_error_string( ERR_get_error() ) ) ) QUIT ENDIF /* set the private key from KeyFile (may be the same as CertFile) */ IF SSL_CTX_use_PrivateKey_file( ssl_ctx, cKeyFile, HB_SSL_FILETYPE_PEM ) <= 0 - OutErr( hb_strFormat( e"SERVER: SSL_CTX_use_PrivateKey_file()=> '%s'\n", ; + OutErr( hb_StrFormat( e"SERVER: SSL_CTX_use_PrivateKey_file()=> '%s'\n", ; ERR_error_string( ERR_get_error() ) ) ) QUIT ENDIF @@ -186,13 +184,13 @@ FUNCTION LoadCertificates( ssl_ctx, cCertFile, cKeyFile ) RETURN NIL -FUNCTION DipsCertInfo( ssl, cWho ) +STATIC FUNCTION DipsCertInfo( ssl, cWho ) LOCAL cert - IF !Empty( cert := SSL_get_peer_certificate( ssl ) ) + IF ! Empty( cert := SSL_get_peer_certificate( ssl ) ) ? cWho + "Server certificates:" - ? cWho + "Subject:", X509_NAME_oneline( X509_get_subject_name( cert ), 0, 0 ) - ? cWho + "Issuer:", X509_NAME_oneline( X509_get_issuer_name( cert ), 0, 0 ) + ? cWho + "Subject:", X509_name_oneline( X509_get_subject_name( cert ), 0, 0 ) + ? cWho + "Issuer:", X509_name_oneline( X509_get_issuer_name( cert ), 0, 0 ) ELSE ? cWho + "No certificates." ENDIF diff --git a/contrib/rddads/ads1.c b/contrib/rddads/ads1.c index 60feebf099..4f3863ef78 100644 --- a/contrib/rddads/ads1.c +++ b/contrib/rddads/ads1.c @@ -170,9 +170,7 @@ static HB_ERRCODE commonError( ADSAREAP pArea, AdsGetLastError( &ulErrCode, aucError, &usLength ); if( ulErrCode != ( UNSIGNED32 ) errSubCode ) - { AdsGetErrorString( ( UNSIGNED32 ) errSubCode, aucError, &usLength ); - } hb_errPutDescription( pError, ( char * ) aucError ); } else @@ -1597,65 +1595,65 @@ static HB_ERRCODE adsCreateFields( ADSAREAP pArea, PHB_ITEM pStruct ) if( iNameLen > 1 ) { - if ( ! hb_strnicmp( szFieldType, "autoinc", 2 ) ) + if( ! hb_strnicmp( szFieldType, "autoinc", 2 ) ) iData = '+'; - else if ( ! hb_strnicmp( szFieldType, "binary", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "binary", 2 ) ) iData = 'W'; else if( ! hb_strnicmp( szFieldType, "character", 2 ) ) iData = 'C'; #if ADS_LIB_VERSION >= 710 - else if ( ! hb_strnicmp( szFieldType, "cicharacter", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "cicharacter", 2 ) ) iData = 'c'; #endif - else if ( ! hb_strnicmp( szFieldType, "curdouble", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "curdouble", 2 ) ) iData = 'Z'; else if( ! hb_strnicmp( szFieldType, "date", 2 ) ) iData = 'D'; else if( ! hb_strnicmp( szFieldType, "double", 2 ) ) iData = 'B'; - else if ( ! hb_strnicmp( szFieldType, "image", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "image", 2 ) ) iData = 'P'; - else if ( ! hb_strnicmp( szFieldType, "integer", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "integer", 2 ) ) iData = 'I'; - else if ( ! hb_strnicmp( szFieldType, "logical", 3 ) ) + else if( ! hb_strnicmp( szFieldType, "logical", 3 ) ) iData = 'L'; #if ADS_LIB_VERSION >= 700 - else if ( ! hb_strnicmp( szFieldType, "longlong", 3 ) ) + else if( ! hb_strnicmp( szFieldType, "longlong", 3 ) ) { iData = 'I'; uiLen = 8; } #endif - else if ( ! hb_strnicmp( szFieldType, "memo", 3 ) ) + else if( ! hb_strnicmp( szFieldType, "memo", 3 ) ) iData = 'M'; #if ADS_LIB_VERSION >= 800 - else if ( ! hb_strnicmp( szFieldType, "modtime", 3 ) ) + else if( ! hb_strnicmp( szFieldType, "modtime", 3 ) ) iData = '='; #endif #if ADS_LIB_VERSION >= 700 - else if ( ! hb_strnicmp( szFieldType, "money", 3 ) ) + else if( ! hb_strnicmp( szFieldType, "money", 3 ) ) iData = 'Y'; #endif - else if ( ! hb_strnicmp( szFieldType, "numeric", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "numeric", 2 ) ) iData = 'N'; #if ADS_LIB_VERSION >= 1000 - else if ( ! hb_strnicmp( szFieldType, "nchar", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "nchar", 2 ) ) { iData = 'C'; dbFieldInfo.uiFlags |= HB_FF_UNICODE; } - else if ( ! hb_strnicmp( szFieldType, "nmemo", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "nmemo", 2 ) ) { iData = 'M'; dbFieldInfo.uiFlags |= HB_FF_UNICODE; } - else if ( ! hb_strnicmp( szFieldType, "nvarchar", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "nvarchar", 2 ) ) { iData = 'Q'; dbFieldInfo.uiFlags |= HB_FF_UNICODE; } #endif - else if ( ! hb_strnicmp( szFieldType, "shortdate", 6 ) ) + else if( ! hb_strnicmp( szFieldType, "shortdate", 6 ) ) { iData = 'D'; #if ADS_LIB_VERSION >= 900 @@ -1665,33 +1663,33 @@ static HB_ERRCODE adsCreateFields( ADSAREAP pArea, PHB_ITEM pStruct ) uiLen = pArea->iFileType == ADS_ADT ? 4 : 3; #endif } - else if ( ! hb_strnicmp( szFieldType, "shortint", 6 ) ) + else if( ! hb_strnicmp( szFieldType, "shortint", 6 ) ) { iData = 'I'; uiLen = 2; } - else if ( ! hb_stricmp( szFieldType, "time" ) ) + else if( ! hb_stricmp( szFieldType, "time" ) ) { iData = 'T'; uiLen = 4; } - else if ( ! hb_strnicmp( szFieldType, "timestamp", 5 ) ) + else if( ! hb_strnicmp( szFieldType, "timestamp", 5 ) ) { iData = '@'; uiLen = 8; } - else if ( ! hb_strnicmp( szFieldType, "raw", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "raw", 2 ) ) { iData = 'C'; dbFieldInfo.uiFlags |= HB_FF_BINARY; } - else if ( ! hb_strnicmp( szFieldType, "rowversion", 2 ) ) + else if( ! hb_strnicmp( szFieldType, "rowversion", 2 ) ) iData = '^'; - else if ( ! hb_strnicmp( szFieldType, "varchar", 4 ) ) + else if( ! hb_strnicmp( szFieldType, "varchar", 4 ) ) { iData = 'Q'; } - else if ( ! hb_strnicmp( szFieldType, "varbinary", 4 ) ) + else if( ! hb_strnicmp( szFieldType, "varbinary", 4 ) ) { iData = 'Q'; dbFieldInfo.uiFlags |= HB_FF_BINARY; diff --git a/include/hbcomp.h b/include/hbcomp.h index 7e80d8e852..2581e7918a 100644 --- a/include/hbcomp.h +++ b/include/hbcomp.h @@ -72,9 +72,7 @@ extern void hb_compPCodeTrace( PHB_HFUNC, const PHB_PCODE_FUNC *, void * ); extern void hb_compGenLabelTable( PHB_HFUNC pFunc, PHB_LABEL_INFO label_info ); extern PHB_DEBUGINFO hb_compGetDebugInfo( HB_COMP_DECL ); -extern void hb_compChkFileSwitches( int argc, char * argv[] ); - -extern void hb_compInitPP( HB_COMP_DECL, int argc, const char * const argv[], PHB_PP_OPEN_FUNC pOpenFunc ); +extern void hb_compInitPP( HB_COMP_DECL, PHB_PP_OPEN_FUNC pOpenFunc ); extern void hb_compCompileEnd( HB_COMP_DECL ); extern int hb_comp_yyparse( HB_COMP_DECL ); @@ -294,9 +292,10 @@ extern void hb_compCodeBlockRewind( HB_COMP_DECL ); /* resta extern HB_SIZE hb_compExprListEval( HB_COMP_DECL, PHB_EXPR pExpr, PHB_COMP_CARGO_FUNC pEval ); extern HB_SIZE hb_compExprListEval2( HB_COMP_DECL, PHB_EXPR pExpr1, PHB_EXPR pExpr2, PHB_COMP_CARGO2_FUNC pEval ); -extern void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, const char * const args[] ); -extern void hb_compChkPaths( HB_COMP_DECL ); -extern void hb_compChkDefines( HB_COMP_DECL, int iArg, const char * const args[] ); +extern void hb_compChkCommandLine( HB_COMP_DECL, int argc, const char * const argv[] ); +extern void hb_compChkEnvironment( HB_COMP_DECL ); +extern void hb_compChkAddIncPaths( HB_COMP_DECL ); +extern void hb_compChkSetDefines( HB_COMP_DECL ); extern void hb_compPrintUsage( HB_COMP_DECL, const char * szSelf ); extern void hb_compPrintCredits( HB_COMP_DECL ); diff --git a/include/hbcompdf.h b/include/hbcompdf.h index 374c87730e..ab555bcb32 100644 --- a/include/hbcompdf.h +++ b/include/hbcompdf.h @@ -534,6 +534,14 @@ typedef struct _HB_HFUNC HB_USHORT wWithObjectCnt; } HB_HFUNC, * PHB_HFUNC; +/* structure to hold PP #define variables passed as command line parameters */ +typedef struct _HB_PPDEFINE +{ + char * szName; /* name of PP #define variable */ + const char * szValue; /* value of PP #define variable */ + struct _HB_PPDEFINE * pNext; /* pointer to the next var */ +} HB_PPDEFINE, * PHB_PPDEFINE; + /* structure to hold an INLINE block of source */ typedef struct _HB_HINLINE { @@ -750,6 +758,7 @@ typedef struct _HB_COMP PHB_MODULE modules; PHB_VARTYPE pVarType; PHB_INCLST incfiles; + PHB_PPDEFINE ppdefines; PHB_HDECLARED pFirstDeclared; PHB_HDECLARED pLastDeclared; @@ -783,7 +792,6 @@ typedef struct _HB_COMP const char * szAnnounce; const char * szDeclaredFun; const char * szFile; /* Source file name of compiled module */ - char szPrefix[ 20 ]; /* holds the prefix added to the generated symbol init function name (in C output currently) */ char * szDepExt; /* destination file extension used in decencies list */ char * szStdCh; /* standard definitions file name (-u) */ char ** szStdChExt; /* extended definitions file names (-u+) */ diff --git a/include/hbset.h b/include/hbset.h index cec0d4d9ab..0a94217033 100644 --- a/include/hbset.h +++ b/include/hbset.h @@ -264,6 +264,18 @@ extern HB_EXPORT HB_PATHNAMES * hb_setGetFirstSetPath( void ); extern HB_EXPORT HB_BOOL hb_setGetCentury( void ); extern HB_EXPORT HB_BOOL hb_setSetCentury( HB_BOOL ); +extern HB_EXPORT int hb_setGetFileCase( void ); +extern HB_EXPORT void hb_setSetFileCase( int iFileCase ); + +extern HB_EXPORT int hb_setGetDirCase( void ); +extern HB_EXPORT void hb_setSetDirCase( int iDirCase ); + +extern HB_EXPORT int hb_setGetDirSeparator( void ); +extern HB_EXPORT void hb_setSetDirSeparator( int iSeparator ); + +extern HB_EXPORT HB_BOOL hb_setGetTrimFileName( void ); +extern HB_EXPORT void hb_setSetTrimFileName( HB_BOOL fTrim ); + extern HB_EXPORT PHB_FILE hb_setGetAltHan( void ); extern HB_EXPORT PHB_FILE hb_setGetExtraHan( void ); extern HB_EXPORT PHB_FILE hb_setGetPrintHan( void ); @@ -315,9 +327,6 @@ extern HB_EXPORT HB_BOOL hb_setGetSoftSeek( void ); extern HB_EXPORT HB_BOOL hb_setGetStrictRead( void ); extern HB_EXPORT int hb_setGetTypeAhead( void ); extern HB_EXPORT HB_BOOL hb_setGetUnique( void ); -extern HB_EXPORT int hb_setGetFileCase( void ); -extern HB_EXPORT int hb_setGetDirCase( void ); -extern HB_EXPORT int hb_setGetDirSeparator( void ); extern HB_EXPORT int hb_setGetVideoMode( void ); extern HB_EXPORT HB_BOOL hb_setGetWrap( void ); extern HB_EXPORT int hb_setGetDBFLockScheme( void ); @@ -325,7 +334,6 @@ extern HB_EXPORT HB_BOOL hb_setGetHardCommit( void ); extern HB_EXPORT HB_BOOL hb_setGetForceOpt( void ); extern HB_EXPORT HB_BOOL hb_setGetDefExtension( void ); extern HB_EXPORT const char * hb_setGetEOL( void ); -extern HB_EXPORT HB_BOOL hb_setGetTrimFileName( void ); extern HB_EXPORT const char * hb_setGetHBOUTLOG( void ); extern HB_EXPORT const char * hb_setGetHBOUTLOGINFO( void ); extern HB_EXPORT const char * hb_setGetOSCODEPAGE( void ); diff --git a/src/common/hbfsapi.c b/src/common/hbfsapi.c index 034118ec29..e5907a6c48 100644 --- a/src/common/hbfsapi.c +++ b/src/common/hbfsapi.c @@ -100,18 +100,16 @@ void hb_fsAddSearchPath( const char * szPath, HB_PATHNAMES ** pSearchList ) HB_BOOL fFree = HB_TRUE; while( *pSearchList ) - { pSearchList = &( *pSearchList )->pNext; - } pPath = hb_strdup( szPath ); while( ( pDelim = strchr( pPath, HB_OS_PATH_LIST_SEP_CHR ) ) != NULL ) { *pDelim = '\0'; *pSearchList = ( HB_PATHNAMES * ) hb_xgrab( sizeof( HB_PATHNAMES ) ); - (*pSearchList)->szPath = pPath; - (*pSearchList)->fFree = fFree; - pSearchList = &(*pSearchList)->pNext; + ( *pSearchList )->szPath = pPath; + ( *pSearchList )->fFree = fFree; + pSearchList = &( *pSearchList )->pNext; pPath = pDelim + 1; fFree = HB_FALSE; } diff --git a/src/compiler/cmdcheck.c b/src/compiler/cmdcheck.c index 42bfc4ccd5..b86d9c2e38 100644 --- a/src/compiler/cmdcheck.c +++ b/src/compiler/cmdcheck.c @@ -1,14 +1,14 @@ /* * Harbour Project source code: - * Compiler command line and HARBOURCMD/CLIPPERCMD checking + * Compiler command line and environment parameters checking * - * Copyright 1999 {list of individual authors and e-mail addresses} + * Copyright 2015 Przemyslaw Czerpak * www - http://harbour-project.org * * 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 of the License, or - * (at your option) any later version, with one exception: + * the Free Software Foundation; either version 2, or (at your option) + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,1121 +16,864 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit - * their web site at http://www.gnu.org/). + * along with this software; see the file COPYING.txt. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). * - */ - -/* - * The following parts are Copyright of the individual authors. - * www - http://harbour-project.org + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. * - * Copyright 2000 Ron Pinkas - * hb_compChkCompilerSwitch() + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. * - * Copyright 1999 Jose Lalin - * hb_compChkEnvironVar() + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. * - * Copyright 1999-2001 Viktor Szakats (vszakats.net/harbour) - * PackDateTime() - * hb_compChkDefineSwitch() - * hb_compChkDefines() + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. * - * See COPYING.txt for licensing terms. + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. * */ #include "hbcomp.h" -#include "hbdate.h" +#include "hbset.h" -/* TODO: Add support for this compiler switches - -r -t || hb_GetEnv( "TMP" ) - */ +static char s_szUndefineMarker[ 1 ] = ""; - -/* NOTE: Making the date and time info to fit into 32 bits can only be done - in a "lossy" way, in practice that means it's not possible to unpack - the exact date/time info from the resulting HB_ULONG. Since the year - is only stored in 6 bits, 1980 will result in the same bit pattern - as 2044. The purpose of this value is only used to *differenciate* - between the dates ( the exact dates are not significant ), so this - can be used here without problems. [vszakats] */ - -/* 76543210765432107654321076543210 - |.......|.......|.......|....... - |____| Year 6 bits - . |__| Month 4 bits - . |___| Day 5 bits - . |___| Hour 5 bits - . |____| Minute 6 bits - . |____| Second 6 bits */ - -static HB_ULONG PackDateTime( void ) +static HB_SIZE hb_compChkOptionLen( const char * szSwitch, HB_BOOL fEnv ) { - union + HB_SIZE nLen; + + if( fEnv ) { - struct - { - HB_U32 second : 6; /* bits: 0 - 5 */ - HB_U32 minute : 6; /* bits: 6 - 11 */ - HB_U32 hour : 5; /* bits: 12 - 16 */ - HB_U32 day : 5; /* bits: 16 - 21 */ - HB_U32 month : 4; /* bits: 22 - 25 */ - HB_U32 year : 6; /* bits: 26 - 31 */ - } ts; - HB_U32 val; - } u; - int iYear, iMonth, iDay, iHour, iMinute, iSecond, iMillisec; + nLen = 0; + while( szSwitch[ nLen ] != '\0' && + szSwitch[ nLen ] != ' ' && szSwitch[ nLen ] != '-' ) + ++nLen; + } + else + nLen = strlen( szSwitch ); - hb_timeStampGetLocal( &iYear, &iMonth, &iDay, - &iHour, &iMinute, &iSecond, &iMillisec ); - - u.ts.year = iYear - 1980; - u.ts.month = iMonth; - u.ts.day = iDay; - u.ts.hour = iHour; - u.ts.minute = iMinute; - u.ts.second = iSecond; - - return u.val; + return nLen; } -static void hb_notSupportedInfo( HB_COMP_DECL, const char * szSwitch ) +static const char * hb_compChkAddDefine( HB_COMP_DECL, const char * szSwitch, + HB_BOOL fAdd, HB_BOOL fEnv ) { - char buffer[ 512 ]; + const char * szSwPtr = szSwitch; + HB_SIZE nValue = 0; + + while( *szSwPtr && *szSwPtr != ' ' && ! HB_ISOPTSEP( *szSwPtr ) ) + { + if( *szSwPtr == '=' ) + { + nValue = szSwPtr - szSwitch; + szSwPtr += hb_compChkOptionLen( szSwPtr, fEnv ); + break; + } + ++szSwPtr; + } + if( szSwPtr > szSwitch && *szSwitch != '=' ) + { + char * szDefine = hb_strndup( szSwitch, szSwPtr - szSwitch ); + char * szValue = NULL; + PHB_PPDEFINE * pDefinePtr; + + if( nValue ) + { + szValue = szDefine + nValue; + *szValue++ = '\0'; + } + if( ! fAdd ) + szValue = s_szUndefineMarker; + + pDefinePtr = &HB_COMP_PARAM->ppdefines; + while( *pDefinePtr != NULL && + strcmp( ( *pDefinePtr )->szName, szDefine ) != 0 ) + pDefinePtr = &( *pDefinePtr )->pNext; + + if( *pDefinePtr == NULL ) + { + *pDefinePtr = ( PHB_PPDEFINE ) hb_xgrab( sizeof( HB_PPDEFINE ) ); + ( *pDefinePtr )->pNext = NULL; + } + else + hb_xfree( ( *pDefinePtr )->szName ); + ( *pDefinePtr )->szName = szDefine; + ( *pDefinePtr )->szValue = szValue; + } + return szSwPtr; +} + +static void hb_compChkIgnoredInfo( HB_COMP_DECL, const char * szSwitch ) +{ + char buffer[ 64 ]; hb_snprintf( buffer, sizeof( buffer ), - "Not yet supported command line option: %s\n", szSwitch ); - + "Ignored unsupported command line option: %s\n", szSwitch ); hb_compOutStd( HB_COMP_PARAM, buffer ); } -static void hb_compChkEnvironVar( HB_COMP_DECL, const char * szSwitch ) +static char * hb_compChkOptionDup( const char * szSwitch ) { - if( szSwitch && ! HB_COMP_PARAM->fExit ) - { - const char * s = szSwitch; - - /* If szSwitch doesn't start with a HB_OSOPTSEP char - * show an error - */ - if( ! HB_ISOPTSEP( *s ) ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - else - { - s++; - switch( *s ) - { - case 'a': - case 'A': - if( *( s + 1 ) == '-' ) - HB_COMP_PARAM->fAutoMemvarAssume = HB_FALSE; - else - HB_COMP_PARAM->fAutoMemvarAssume = HB_TRUE; - break; - - case 'b': - case 'B': - { - unsigned int i = 0; - char *szOption = hb_strupr( hb_strdup( s ) ); - - while( i < strlen( szOption ) && ! HB_ISOPTSEP( szOption[ i ] ) ) - i++; - szOption[ i ] = '\0'; - - if( strcmp( szOption, "BUILD" ) == 0 ) - HB_COMP_PARAM->fBuildInfo = HB_TRUE; - else - { - if( *( s + 1 ) == '-' ) - HB_COMP_PARAM->fDebugInfo = HB_FALSE; - else - { - HB_COMP_PARAM->fDebugInfo = HB_TRUE; - HB_COMP_PARAM->fLineNumbers = HB_TRUE; - } - } - - hb_xfree( szOption ); - break; - } - - case 'c': - case 'C': - { - unsigned int i = 0; - char *szOption = hb_strupr( hb_strdup( s ) ); - - while( i < strlen( szOption ) && ! HB_ISOPTSEP( szOption[ i ] ) ) - i++; - szOption[ i ] = '\0'; - - if( strcmp( szOption, "CREDITS" ) == 0 || - strcmp( szOption, "CREDIT" ) == 0 || - strcmp( szOption, "CREDI" ) == 0 || - strcmp( szOption, "CRED" ) == 0 ) - HB_COMP_PARAM->fCredits = HB_TRUE; - else - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, szOption, NULL ); - - hb_xfree( szOption ); - break; - } - - case 'd': - case 'D': - /* NOTE: Ignore these -d switches will be processed separately */ - break; - - case 'e': - case 'E': - if( *( s + 1 ) == 's' || *( s + 1 ) == 'S' ) - { - switch( *( s + 2 ) ) - { - case '\0': - case '0': - HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DEFAULT; - break; - - case '1': - HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_SETEXIT; - break; - - case '2': - HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DELTARGET; - break; - - default: - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - } - } - else - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - - break; - - case 'g': - case 'G': - switch( *( s + 1 ) ) - { - case 'c': - case 'C': - HB_COMP_PARAM->iLanguage = HB_LANG_C; - - switch( *( s + 2 ) ) - { - case '3': - HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_REALCODE; - break; - - case '2': - HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_VERBOSE; - break; - - case '1': - HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_NORMAL; - break; - - case '\0': - case '0': - HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_COMPACT; - break; - - default: - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - } - break; - - case 'h': - case 'H': - HB_COMP_PARAM->iLanguage = HB_LANG_PORT_OBJ; - break; - - case 'd': - case 'D': - if( HB_COMP_PARAM->szDepExt ) - { - hb_xfree( HB_COMP_PARAM->szDepExt ); - HB_COMP_PARAM->szDepExt = NULL; - } - if( s[ 2 ] == '-' ) - HB_COMP_PARAM->iTraceInclude = 0; - else if( s[ 2 ] == '.' || s[ 2 ] == '\0' ) - { - HB_COMP_PARAM->iTraceInclude = 2; - if( s[ 2 ] != '\0' ) - HB_COMP_PARAM->szDepExt = hb_strdup( s + 2 ); - } - else - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - break; - - case 'e': - case 'E': - switch( *( s + 2 ) ) - { - case '1': - HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_IDE; - break; - - case '\0': - case '0': - HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_CLIPPER; - break; - - default: - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - } - break; - - default: - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_UNSUPPORTED_LANG, NULL, NULL ); - break; - } - break; - - /* NOTE: - h or H from HELP or help - */ - case 'h': - case 'H': - case '?': - break; - - /* NOTE: - It already has support for several include files - */ - case 'i': - case 'I': - switch( *( s + 1 ) ) - { - case '-': - HB_COMP_PARAM->fINCLUDE = HB_FALSE; - break; - - case '+': - HB_COMP_PARAM->fINCLUDE = HB_TRUE; - break; - - default: - hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, s + 1, HB_FALSE ); - } - break; - - case 'j': - case 'J': - HB_COMP_PARAM->fI18n = HB_TRUE; - if( s[ 1 ] ) - HB_COMP_PARAM->pI18nFileName = hb_fsFNameSplit( s + 1 ); - break; - - case 'k': - case 'K': - { - int i = 1; - - while( s[ i ] && ! HB_COMP_PARAM->fExit ) - { - switch( s[ i++ ] ) - { - case '?': - hb_compPrintLogo( HB_COMP_PARAM ); - hb_compPrintModes( HB_COMP_PARAM ); - HB_COMP_PARAM->fLogo = HB_FALSE; - HB_COMP_PARAM->fQuiet = HB_TRUE; - break; - - case 'h': - case 'H': - /* default Harbour mode */ - if( s[ i ] == '-' ) - { - i++; - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HARBOUR; - } - else - HB_COMP_PARAM->supported |= HB_COMPFLAG_HARBOUR; - break; - - case 'c': - case 'C': - /* clear all flags - minimal set of features */ - HB_COMP_PARAM->supported &= HB_COMPFLAG_SHORTCUTS; - HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP | - HB_COMPFLAG_MACROTEXT; - break; - - case 'x': - case 'X': - if( s[ i ] == '-' ) - { - i++; - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_XBASE; - } - else - HB_COMP_PARAM->supported |= HB_COMPFLAG_XBASE; - break; - - case 'i': - case 'I': - if( s[ i ] == '-' ) - { - i++; - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HB_INLINE; - } - else - HB_COMP_PARAM->supported |= HB_COMPFLAG_HB_INLINE; - break; - - case 'j': - case 'J': - if( s[ i ] == '+' ) - { - i++; - HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP; - } - else - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP; - break; - - case 'm': - case 'M': - if( s[ i ] == '+' ) - { - i++; - HB_COMP_PARAM->supported |= HB_COMPFLAG_MACROTEXT; - } - else - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACROTEXT; - break; - - case 'd': - case 'D': - if( s[ i ] == '-' ) - { - i++; - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACRODECL; - } - else - HB_COMP_PARAM->supported |= HB_COMPFLAG_MACRODECL; - break; - - case 'r': - case 'R': - if( s[ i ] == '-' ) - { - i++; - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_RT_MACRO; - } - else - HB_COMP_PARAM->supported |= HB_COMPFLAG_RT_MACRO; - break; - - case 's': - case 'S': - if( s[ i ] == '-' ) - { - i++; - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_ARRSTR; - } - else - HB_COMP_PARAM->supported |= HB_COMPFLAG_ARRSTR; - break; - - case 'o': - case 'O': - if( s[ i ] == '-' ) - { - i++; - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_EXTOPT; - } - else - HB_COMP_PARAM->supported |= HB_COMPFLAG_EXTOPT; - break; - - case 'u': - case 'U': - if( s[ i ] == '-' ) - { - i++; - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_USERCP; - } - else - HB_COMP_PARAM->supported |= HB_COMPFLAG_USERCP; - break; - - default: - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - break; - } - } - break; - } - - case 'l': - case 'L': - if( *( s + 1 ) == '-' ) - HB_COMP_PARAM->fLineNumbers = HB_TRUE; - else - HB_COMP_PARAM->fLineNumbers = HB_FALSE; - break; - - case 'm': - case 'M': - if( *( s + 1 ) == '-' ) - HB_COMP_PARAM->fSingleModule = HB_FALSE; - else - HB_COMP_PARAM->fSingleModule = HB_TRUE; - break; - - case 'n': - case 'N': - HB_COMP_PARAM->fNoStartUp = s[ 1 ] == '1'; - switch( s[ 1 ] ) - { - case '-': - HB_COMP_PARAM->iStartProc = 0; - break; - case '\0': - case '0': - case '1': - HB_COMP_PARAM->iStartProc = 1; - break; - case '2': - HB_COMP_PARAM->iStartProc = 2; - break; - default: - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - } - break; - - case 'o': - case 'O': - HB_COMP_PARAM->pOutPath = hb_fsFNameSplit( s + 1 ); - break; - - /* Added for preprocessor needs */ - case 'p': - case 'P': - if( s[ 1 ] == '+' && s[ 2 ] == '\0' ) - HB_COMP_PARAM->fPPT = HB_TRUE; - else - { - if( HB_COMP_PARAM->pPpoPath ) - { - hb_xfree( HB_COMP_PARAM->pPpoPath ); - HB_COMP_PARAM->pPpoPath = NULL; - } - if( s[ 1 ] == '-' && s[ 2 ] == '\0' ) - HB_COMP_PARAM->fPPO = HB_FALSE; - else - { - if( s[ 1 ] ) - HB_COMP_PARAM->pPpoPath = hb_fsFNameSplit( s + 1 ); - HB_COMP_PARAM->fPPO = HB_TRUE; - } - } - break; - - case 'q': - case 'Q': - switch( *( s + 1 ) ) - { - case 'l': - case 'L': - HB_COMP_PARAM->fGauge = HB_FALSE; - break; - case '2': - HB_COMP_PARAM->fFullQuiet = HB_TRUE; - case '0': - HB_COMP_PARAM->fLogo = HB_FALSE; - default: - HB_COMP_PARAM->fQuiet = HB_TRUE; - } - break; - - case 'r': - case 'R': - if( *( s + 1 ) == ':' ) - { - int iOverflow; - int iCycles = ( int ) hb_strValInt( s + 2, &iOverflow ); - - if( ! iOverflow && iCycles > 0 ) - HB_COMP_PARAM->iMaxTransCycles = iCycles; - } - else - { - /* TODO: Implement this switch */ - hb_notSupportedInfo( HB_COMP_PARAM, s ); - } - break; - - case 's': - case 'S': - switch( *( s + 1 ) ) - { - case '\0': - HB_COMP_PARAM->iSyntaxCheckOnly = 1; - break; - case '-': - HB_COMP_PARAM->iSyntaxCheckOnly = 0; - break; - case 'm': - case 'M': - if( s[ 2 ] == '\0' ) - { - HB_COMP_PARAM->iSyntaxCheckOnly = 2; - break; - } - default: - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - } - break; - - case 't': - case 'T': - /* TODO: Implement this switch */ - hb_notSupportedInfo( HB_COMP_PARAM, s ); - break; - - case 'u': - case 'U': - if( ( s[ 1 ] == 'N' || s[ 1 ] == 'n' ) && - ( s[ 2 ] == 'D' || s[ 2 ] == 'd' ) && - ( s[ 3 ] == 'E' || s[ 3 ] == 'e' ) && - ( s[ 4 ] == 'F' || s[ 4 ] == 'f' ) && s[ 5 ] == ':' ) - { - /* NOTE: Ignore these -undef: switches (will be processed - * separately) except -undef:.arch. - */ - if( s[ 6 ] == '.' && - ( s[ 7 ] == 'A' || s[ 7 ] == 'a' ) && - ( s[ 8 ] == 'R' || s[ 8 ] == 'r' ) && - ( s[ 9 ] == 'C' || s[ 9 ] == 'c' ) && - ( s[ 10 ] == 'H' || s[ 10 ] == 'h' ) && - s[ 11 ] == '.' ) - { - HB_COMP_PARAM->fNoArchDefs = HB_TRUE; - } - break; - } - /* extended definitions file (-u+) */ - if( s[ 1 ] == '+' ) - { - if( s[ 2 ] ) - { - if( HB_COMP_PARAM->iStdChExt == 0 ) - HB_COMP_PARAM->szStdChExt = ( char ** ) - hb_xgrab( sizeof( char * ) ); - else - HB_COMP_PARAM->szStdChExt = ( char ** ) - hb_xrealloc( HB_COMP_PARAM->szStdChExt, - ( HB_COMP_PARAM->iStdChExt + 1 ) * - sizeof( char * ) ); - HB_COMP_PARAM->szStdChExt[ HB_COMP_PARAM->iStdChExt++ ] = - hb_strdup( s + 2 ); - } - else - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - } - else - { - if( HB_COMP_PARAM->szStdCh ) - hb_xfree( HB_COMP_PARAM->szStdCh ); - HB_COMP_PARAM->szStdCh = hb_strdup( s + 1 ); - } - break; - - case 'v': - case 'V': - if( *( s + 1 ) == '-' ) - HB_COMP_PARAM->fForceMemvars = HB_FALSE; - else - HB_COMP_PARAM->fForceMemvars = HB_TRUE; - break; - - case 'w': - case 'W': - HB_COMP_PARAM->iWarnings = 1; - if( s[ 1 ] ) /* there is -w<0,1,2,3> probably */ - { - HB_COMP_PARAM->iWarnings = s[ 1 ] - '0'; - if( HB_COMP_PARAM->iWarnings < 0 || HB_COMP_PARAM->iWarnings > 3 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - } - break; - - case 'x': - case 'X': - { - unsigned int i = 1; - while( s[ i ] && ! HB_ISOPTSEP( s[ i ] ) && - i < sizeof( HB_COMP_PARAM->szPrefix ) - 1 ) - { - ++i; - } - if( i > 1 ) - { - memcpy( HB_COMP_PARAM->szPrefix, s + 1, i - 1 ); - HB_COMP_PARAM->szPrefix[ i - 1 ] = '_'; - HB_COMP_PARAM->szPrefix[ i ] = '\0'; - } - else - { - hb_snprintf( HB_COMP_PARAM->szPrefix, - sizeof( HB_COMP_PARAM->szPrefix ), - "%08lX_", PackDateTime() ); - } - break; - } - -#ifdef YYDEBUG - case 'y': - case 'Y': - yydebug = HB_TRUE; - break; -#endif - - case 'z': - case 'Z': - if( *( s + 1 ) == '-' ) - HB_COMP_PARAM->supported |= HB_COMPFLAG_SHORTCUTS; - else - HB_COMP_PARAM->supported &= ~HB_COMPFLAG_SHORTCUTS; - break; - - default: - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); - break; - } - } - } + return hb_strupr( hb_strndup( szSwitch, + hb_compChkOptionLen( szSwitch, HB_TRUE ) ) ); } -void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, const char * const Args[] ) +static const char * hb_compChkOptionGet( const char * szSwitch, + char ** pszResult, HB_BOOL fEnv ) { - /* If iArg is passed check the command line options */ - if( iArg ) + HB_SIZE nLen = hb_compChkOptionLen( szSwitch, fEnv ); + + if( pszResult ) + *pszResult = hb_strndup( szSwitch, nLen ); + + return szSwitch + nLen; +} + +static const char * hb_compChkOptionFName( const char * szSwitch, + PHB_FNAME * pResult, HB_BOOL fEnv ) +{ + HB_SIZE nLen = hb_compChkOptionLen( szSwitch, fEnv ); + + if( szSwitch[ nLen ] != '\0' ) { - int i; + char * szVal = hb_strndup( szSwitch, nLen ); + *pResult = hb_fsFNameSplit( szVal ); + hb_xfree( szVal ); + } + else + *pResult = hb_fsFNameSplit( szSwitch ); - /* Check all switches in command line - They start with an OS_OPT_DELIMITER char - */ - for( i = 1; i < iArg && ! HB_COMP_PARAM->fExit; i++ ) + return szSwitch + nLen; +} + +static const char * hb_compChkOptionAddPath( HB_COMP_DECL, const char * szSwitch, + HB_BOOL fEnv ) +{ + HB_SIZE nLen = hb_compChkOptionLen( szSwitch, fEnv ); + + if( nLen > 0 ) + { + if( szSwitch[ nLen ] != '\0' ) { - const char * szSwitch = Args[ i ]; + char * szVal = hb_strndup( szSwitch, nLen ); + hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, szSwitch, HB_FALSE ); + hb_xfree( szVal ); + } + else + hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, szSwitch, HB_FALSE ); + } + return szSwitch + nLen; +} - if( ! HB_ISOPTSEP( szSwitch[ 0 ] ) ) - continue; +static const char * hb_compChkParseSwitch( HB_COMP_DECL, const char * szSwitch, + HB_BOOL fEnv ) +{ + const char * szSwPtr = szSwitch; - if( szSwitch[ 0 ] == '-' ) - { - int j = 1; - char Switch[ 7 ]; - - Switch[ 0 ] = '-'; - - while( szSwitch[ j ] && ! HB_COMP_PARAM->fExit ) + if( szSwPtr[ 0 ] == '-' && szSwPtr[ 1 ] == '-' ) + { + if( strncmp( szSwPtr + 2, "version", 7 ) == 0 ) + { + szSwPtr += 9; + HB_COMP_PARAM->fLogo = HB_TRUE; + HB_COMP_PARAM->fQuiet = HB_TRUE; + } + else if( strncmp( szSwPtr + 2, "help", 4 ) == 0 ) + { + szSwPtr += 6; + HB_COMP_PARAM->fLogo = HB_TRUE; + HB_COMP_PARAM->fQuiet = HB_FALSE; + HB_COMP_PARAM->fExit = HB_FALSE; + } + } + else if( HB_ISOPTSEP( *szSwPtr ) ) + { + ++szSwPtr; + switch( HB_TOUPPER( *szSwPtr ) ) + { + case 'A': + ++szSwPtr; + if( *szSwPtr == '-' ) { - Switch[ 1 ] = szSwitch[ j ]; - - if( szSwitch[ j + 1 ] == '-' ) - { - Switch[ 2 ] = '-'; - Switch[ 3 ] = '\0'; - - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - - j += 2; - continue; - } - else - { - switch( Switch[ 1 ] ) - { - case 'b': - case 'B': - if( ( szSwitch[ j + 1 ] == 'U' || szSwitch[ j + 1 ] == 'u' ) && - ( szSwitch[ j + 2 ] == 'I' || szSwitch[ j + 2 ] == 'i' ) && - ( szSwitch[ j + 3 ] == 'L' || szSwitch[ j + 3 ] == 'l' ) && - ( szSwitch[ j + 4 ] == 'D' || szSwitch[ j + 4 ] == 'd' ) ) - { - Switch[ 2 ] = 'U'; - Switch[ 3 ] = 'I'; - Switch[ 4 ] = 'L'; - Switch[ 5 ] = 'D'; - Switch[ 6 ] = '\0'; - - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - - j += 5; - continue; - } - else if( ! szSwitch[ j + 1 ] ) - { - Switch[ 2 ] = '\0'; - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - j += 1; - continue; - } - break; - - case 'c': - case 'C': - if( ( szSwitch[ j + 1 ] == 'R' || szSwitch[ j + 1 ] == 'r' ) && - ( szSwitch[ j + 2 ] == 'E' || szSwitch[ j + 2 ] == 'e' ) && - ( szSwitch[ j + 3 ] == 'D' || szSwitch[ j + 3 ] == 'd' ) ) - { - Switch[ 2 ] = 'R'; - Switch[ 3 ] = 'E'; - Switch[ 4 ] = 'D'; - Switch[ 5 ] = '\0'; - - j += 4; - - if( szSwitch[ j ] == 'I' || szSwitch[ j ] == 'i' ) - { - j++; - if( szSwitch[ j ] == 'T' || szSwitch[ j ] == 't' ) - { - j++; - if( szSwitch[ j ] == 'S' || szSwitch[ j ] == 's' ) - { - j++; - } - } - } - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - } - else - { - Switch[ 2 ] = '\0'; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL ); - } - continue; - - case 'd': - case 'D': - szSwitch += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - - /* Accept rest as part of #define and continue with next Args[]. */ - j = ( int ) strlen( szSwitch ); - continue; - - case 'e': - case 'E': - if( ( szSwitch[ j + 1 ] == 'S' || szSwitch[ j + 1 ] == 's' ) && - HB_ISDIGIT( szSwitch[ j + 2 ] ) ) - { - Switch[ 2 ] = 'S'; - Switch[ 3 ] = szSwitch[ j + 2 ]; - Switch[ 4 ] = '\0'; - - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - j += 3; - } - else - { - Switch[ 2 ] = '\0'; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL ); - } - continue; - - case 'g': - case 'G': - if( szSwitch[ j + 1 ] == 'd' || szSwitch[ j + 1 ] == 'D' ) - { - szSwitch += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - j = ( int ) strlen( szSwitch ); - } - else - { - /* Required argument */ - Switch[ 2 ] = szSwitch[ j + 1 ]; - if( Switch[ 2 ] ) - { - if( HB_ISDIGIT( szSwitch[ j + 2 ] ) ) - { - /* Optional argument */ - Switch[ 3 ] = szSwitch[ j + 2 ]; - Switch[ 4 ] = '\0'; - j += 3; - } - else - { - /* No optional argument */ - Switch[ 3 ] = '\0'; - j += 2; - } - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - } - else - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL ); - } - continue; - - case 'i': - case 'I': - szSwitch += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - - /* Accept rest as IncludePath and continue with next Args[]. */ - j = ( int ) strlen( szSwitch ); - continue; - - case 'j': - case 'J': - szSwitch += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - j = ( int ) strlen( szSwitch ); - continue; - - case 'k': - case 'K': - szSwitch += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - - /* Accept rest as part of #define and continue with next Args[]. */ - j = ( int ) strlen( szSwitch ); - continue; - - case 'n': - case 'N': - /* Required argument */ - if( szSwitch[ j + 1 ] ) - { - /* Optional argument */ - Switch[ 2 ] = szSwitch[ j + 1 ]; - Switch[ 3 ] = '\0'; - j += 2; - } - else - { - /* No optional argument */ - Switch[ 2 ] = '\0'; - j += 1; - } - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - continue; - - case 'o': - case 'O': - szSwitch += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - - /* Accept rest as OutputPath and continue with next Args[]. */ - j = ( int ) strlen( szSwitch ); - continue; - - case 'p': - case 'P': - if( szSwitch[ j + 1 ] ) - { - szSwitch += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - - /* Accept rest as PPOPath and continue with next Args[]. */ - j += ( int ) strlen( szSwitch ) - 1; - } - else - { - Switch[ 2 ] = '\0'; - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - j++; - } - continue; - - case 'q': - case 'Q': - if( HB_ISDIGIT( szSwitch[ j + 1 ] ) || - szSwitch[ j + 1 ] == 'l' || - szSwitch[ j + 1 ] == 'L' ) - { - Switch[ 2 ] = szSwitch[ j + 1 ]; - Switch[ 3 ] = '\0'; - - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - - j += 2; - continue; - } - else - { - Switch[ 2 ] = '\0'; - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - } - - break; - - case 'r': - case 'R': - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - j = ( int ) strlen( szSwitch ) - 1; - break; - - case 's': - case 'S': - ++j; - Switch[ 2 ] = Switch[ 3 ] = Switch[ 4 ] = '\0'; - if( szSwitch[ j ] == 'm' || szSwitch[ j ] == 'M' ) - { - Switch[ 2 ] = szSwitch[ j++ ]; - if( HB_ISDIGIT( szSwitch[ j ] ) || szSwitch[ j ] == '-' ) - Switch[ 3 ] = szSwitch[ j++ ]; - } - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - continue; - - case 'u': - case 'U': - szSwitch += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - - /* Accept rest as part of .ch Path or "undef:" and continue with next Args[]. */ - j = ( int ) strlen( szSwitch ); - continue; - - case 'w': - case 'W': - if( HB_ISDIGIT( szSwitch[ j + 1 ] ) ) - { - Switch[ 2 ] = szSwitch[ j + 1 ]; - Switch[ 3 ] = '\0'; - - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - - j += 2; - continue; - } - else - { - Switch[ 2 ] = '\0'; - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - } - - break; - - case 'x': - case 'X': - szSwitch += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - - /* Accept rest as INIT Symbol and continue with next Args[]. */ - j = ( int ) strlen( szSwitch ); - continue; - - case '-': - { - int l = ++j; - while( szSwitch[ j ] && ! HB_ISOPTSEP( szSwitch[ j ] ) ) - j++; - if( szSwitch[ l - 1 ] == '-' && j - l == 7 && - memcmp( &szSwitch[ l ], "version", 7 ) == 0 ) - { - HB_COMP_PARAM->fLogo = HB_TRUE; - HB_COMP_PARAM->fQuiet = HB_TRUE; - } - else if( szSwitch[ l - 1 ] == '-' && j - l == 4 && - memcmp( &szSwitch[ l ], "help", 4 ) == 0 ) - { - HB_COMP_PARAM->fLogo = HB_TRUE; - HB_COMP_PARAM->fQuiet = HB_FALSE; - HB_COMP_PARAM->fExit = HB_FALSE; - } - else - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, &szSwitch[ l ], NULL ); - if( szSwitch[ j ] ) - ++j; - continue; - } - default: - Switch[ 2 ] = '\0'; - hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); - } - } - - j++; + ++szSwPtr; + HB_COMP_PARAM->fAutoMemvarAssume = HB_FALSE; } - continue; - } + else + HB_COMP_PARAM->fAutoMemvarAssume = HB_TRUE; + break; - while( ! HB_COMP_PARAM->fExit ) + case 'B': { - int j = 1; - const char * szSwitch1 = szSwitch + j; /* hack to avoid what is seems a bug in 'Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)' / XCode 4.1 [vszakats] */ + char *szOption = hb_compChkOptionDup( szSwPtr ); - while( *szSwitch1 && ! HB_ISOPTSEP( *szSwitch1 ) ) + if( strcmp( szOption, "BUILD" ) == 0 ) { - j++; - szSwitch1++; + HB_COMP_PARAM->fBuildInfo = HB_TRUE; + szSwPtr += 5; } - - if( szSwitch[ j ] == '/' ) + else if( szSwPtr[ 1 ] == '-' ) { - char * szTmp = hb_strndup( szSwitch, j ); - hb_compChkEnvironVar( HB_COMP_PARAM, szTmp ); - hb_xfree( szTmp ); - szSwitch += j; + HB_COMP_PARAM->fDebugInfo = HB_FALSE; + szSwPtr += 2; } else { - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); + HB_COMP_PARAM->fDebugInfo = HB_TRUE; + HB_COMP_PARAM->fLineNumbers = HB_TRUE; + ++szSwPtr; + } + hb_xfree( szOption ); + break; + } + + case 'C': + { + char *szOption = hb_compChkOptionDup( szSwPtr ); + + if( strlen( szOption ) >= 4 && + strncmp( "CREDITS", szOption, strlen( szOption ) ) == 0 ) + { + HB_COMP_PARAM->fCredits = HB_TRUE; + szSwPtr += strlen( szOption ); + } + hb_xfree( szOption ); + break; + } + + case 'D': + szSwPtr = hb_compChkAddDefine( HB_COMP_PARAM, szSwPtr + 1, HB_TRUE, fEnv ); + break; + + case 'E': + if( HB_TOUPPER( szSwPtr[ 1 ] ) == 'S' ) + { + switch( szSwPtr[ 2 ] ) + { + case '0': + ++szSwPtr; + case '\0': + szSwPtr += 2; + HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DEFAULT; + break; + case '1': + szSwPtr += 3; + HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_SETEXIT; + break; + case '2': + szSwPtr += 3; + HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DELTARGET; + } + } + break; + + case 'F': + switch( HB_TOUPPER( szSwPtr[ 1 ] ) ) + { + case 'N': + if( szSwPtr[ 2 ] == ':' ) + { + if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'U' ) + { + szSwPtr += 4; + hb_setSetFileCase( HB_SET_CASE_UPPER ); + } + else if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'L' ) + { + szSwPtr += 4; + hb_setSetFileCase( HB_SET_CASE_LOWER ); + } + } + else + { + szSwPtr += 2; + if( *szSwPtr == '-' ) + ++szSwPtr; + hb_setSetFileCase( HB_SET_CASE_MIXED ); + } + break; + case 'D': + if( szSwPtr[ 2 ] == ':' ) + { + if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'U' ) + { + szSwPtr += 4; + hb_setSetDirCase( HB_SET_CASE_UPPER ); + } + else if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'L' ) + { + szSwPtr += 4; + hb_setSetDirCase( HB_SET_CASE_LOWER ); + } + } + else + { + szSwPtr += 2; + if( *szSwPtr == '-' ) + ++szSwPtr; + hb_setSetDirCase( HB_SET_CASE_MIXED ); + } + break; + case 'P': + szSwPtr += 2; + if( *szSwPtr == ':' ) + { + if( szSwPtr[ 1 ] && szSwPtr[ 1 ] != ' ' ) + { + hb_setSetDirSeparator( szSwPtr[ 1 ] ); + szSwPtr += 2; + } + } + else + { + if( *szSwPtr == '-' ) + ++szSwPtr; + hb_setSetDirSeparator( HB_OS_PATH_DELIM_CHR ); + } + break; + case 'S': + szSwPtr += 2; + if( *szSwPtr == '-' ) + { + ++szSwPtr; + hb_setSetTrimFileName( HB_FALSE ); + } + else + hb_setSetTrimFileName( HB_TRUE ); + } + break; + + case 'G': + switch( HB_TOUPPER( szSwPtr[ 1 ] ) ) + { + case 'C': + HB_COMP_PARAM->iLanguage = HB_LANG_C; + szSwPtr += 2; + switch( *szSwPtr ) + { + case '0': + ++szSwPtr; + case '\0': + HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_COMPACT; + break; + case '1': + ++szSwPtr; + HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_NORMAL; + break; + case '2': + ++szSwPtr; + HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_VERBOSE; + break; + case '3': + ++szSwPtr; + HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_REALCODE; + } + break; + + case 'H': + HB_COMP_PARAM->iLanguage = HB_LANG_PORT_OBJ; + szSwPtr += 2; + break; + + case 'D': + if( HB_COMP_PARAM->szDepExt ) + { + hb_xfree( HB_COMP_PARAM->szDepExt ); + HB_COMP_PARAM->szDepExt = NULL; + } + szSwPtr += 2; + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->iTraceInclude = 0; + ++szSwPtr; + } + else + { + HB_COMP_PARAM->iTraceInclude = 2; + if( *szSwPtr == '.' ) + szSwPtr = hb_compChkOptionGet( szSwPtr, &HB_COMP_PARAM->szDepExt, fEnv ); + } + break; + + case 'E': + szSwPtr += 2; + switch( *szSwPtr ) + { + case '0': + ++szSwPtr; + case '\0': + HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_CLIPPER; + break; + case '1': + ++szSwPtr; + HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_IDE; + } + break; + + default: + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_UNSUPPORTED_LANG, NULL, NULL ); + break; + } + break; + + case 'H': + case '?': + /* HELP message */ + break; + + case 'I': + ++szSwPtr; + switch( *szSwPtr ) + { + case '-': + HB_COMP_PARAM->fINCLUDE = HB_FALSE; + ++szSwPtr; + break; + case '+': + HB_COMP_PARAM->fINCLUDE = HB_TRUE; + ++szSwPtr; + break; + default: + szSwPtr = hb_compChkOptionAddPath( HB_COMP_PARAM, szSwPtr, fEnv ); + } + break; + + case 'J': + ++szSwPtr; + HB_COMP_PARAM->fI18n = HB_TRUE; + if( *szSwPtr ) + szSwPtr = hb_compChkOptionFName( szSwPtr, &HB_COMP_PARAM->pI18nFileName, fEnv ); + break; + + case 'K': + ++szSwPtr; + while( *szSwPtr && ! HB_COMP_PARAM->fExit ) + { + int ch = HB_TOUPPER( *szSwPtr ); + + ++szSwPtr; + switch( ch ) + { + case '?': + hb_compPrintLogo( HB_COMP_PARAM ); + hb_compPrintModes( HB_COMP_PARAM ); + HB_COMP_PARAM->fLogo = HB_FALSE; + HB_COMP_PARAM->fQuiet = HB_TRUE; + break; + + case 'H': + /* default Harbour mode */ + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HARBOUR; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported |= HB_COMPFLAG_HARBOUR; + break; + + case 'C': + /* clear all flags - minimal set of features */ + HB_COMP_PARAM->supported &= HB_COMPFLAG_SHORTCUTS; + HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP | + HB_COMPFLAG_MACROTEXT; + break; + + case 'X': + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_XBASE; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported |= HB_COMPFLAG_XBASE; + break; + + case 'I': + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HB_INLINE; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported |= HB_COMPFLAG_HB_INLINE; + break; + + case 'J': + if( *szSwPtr == '+' ) + { + HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP; + break; + + case 'M': + if( *szSwPtr == '+' ) + { + HB_COMP_PARAM->supported |= HB_COMPFLAG_MACROTEXT; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACROTEXT; + break; + + case 'D': + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACRODECL; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported |= HB_COMPFLAG_MACRODECL; + break; + + case 'R': + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_RT_MACRO; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported |= HB_COMPFLAG_RT_MACRO; + break; + + case 'S': + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_ARRSTR; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported |= HB_COMPFLAG_ARRSTR; + break; + + case 'O': + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_EXTOPT; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported |= HB_COMPFLAG_EXTOPT; + break; + + case 'U': + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_USERCP; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported |= HB_COMPFLAG_USERCP; + break; + + default: + ch = -1; + --szSwPtr; + } + if( ch == -1 ) + break; + } + break; + + case 'L': + ++szSwPtr; + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->fLineNumbers = HB_TRUE; + ++szSwPtr; + } + else + HB_COMP_PARAM->fLineNumbers = HB_FALSE; + break; + + case 'M': + ++szSwPtr; + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->fSingleModule = HB_FALSE; + ++szSwPtr; + } + else + HB_COMP_PARAM->fSingleModule = HB_TRUE; + break; + + case 'N': + ++szSwPtr; + HB_COMP_PARAM->fNoStartUp = *szSwPtr == '1'; + switch( *szSwPtr ) + { + case '-': + HB_COMP_PARAM->iStartProc = 0; + ++szSwPtr; + break; + case '0': + case '1': + ++szSwPtr; + case '\0': + HB_COMP_PARAM->iStartProc = 1; + break; + case '2': + HB_COMP_PARAM->iStartProc = 2; + ++szSwPtr; + } + break; + + case 'O': + szSwPtr = hb_compChkOptionFName( szSwPtr + 1, &HB_COMP_PARAM->pOutPath, fEnv ); + break; + + case 'P': + ++szSwPtr; + if( *szSwPtr == '+' ) + { + HB_COMP_PARAM->fPPT = HB_TRUE; + ++szSwPtr; + } + else + { + if( HB_COMP_PARAM->pPpoPath ) + { + hb_xfree( HB_COMP_PARAM->pPpoPath ); + HB_COMP_PARAM->pPpoPath = NULL; + } + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->fPPT = HB_COMP_PARAM->fPPO = HB_FALSE; + ++szSwPtr; + } + else + { + if( *szSwPtr ) + szSwPtr = hb_compChkOptionFName( szSwPtr, &HB_COMP_PARAM->pPpoPath, fEnv ); + HB_COMP_PARAM->fPPO = HB_TRUE; + } + } + break; + + case 'Q': + ++szSwPtr; + switch( *szSwPtr ) + { + case 'l': + case 'L': + HB_COMP_PARAM->fGauge = HB_FALSE; + ++szSwPtr; + break; + case '2': + HB_COMP_PARAM->fFullQuiet = HB_TRUE; + /* no break */ + case '0': + HB_COMP_PARAM->fLogo = HB_FALSE; + ++szSwPtr; + /* no break */ + default: + HB_COMP_PARAM->fQuiet = HB_TRUE; + } + break; + + case 'R': + ++szSwPtr; + if( szSwPtr[ 0 ] == ':' ) + { + if( HB_ISDIGIT( szSwPtr[ 1 ] ) ) + { + int iCycles = 0; + ++szSwPtr; + while( HB_ISDIGIT( *szSwPtr ) ) + iCycles = iCycles * 10 + *szSwPtr++ - '0'; + if( iCycles > 0 ) + HB_COMP_PARAM->iMaxTransCycles = iCycles; + } + } + else + { + /* NOTE: ignored for Cl*pper compatibility: + /r[] request linker to search (or none) */ + hb_compChkIgnoredInfo( HB_COMP_PARAM, "-r[]" ); + szSwPtr = hb_compChkOptionGet( szSwPtr, NULL, fEnv ); + } + break; + + case 'S': + ++szSwPtr; + switch( *szSwPtr ) + { + case '\0': + HB_COMP_PARAM->iSyntaxCheckOnly = 1; + break; + case '-': + HB_COMP_PARAM->iSyntaxCheckOnly = 0; + ++szSwPtr; + break; + case 'm': + case 'M': + HB_COMP_PARAM->iSyntaxCheckOnly = 2; + ++szSwPtr; + } + break; + + case 'T': + /* NOTE: ignored for Cl*pper compatibility: + /t path for temp file creation */ + hb_compChkIgnoredInfo( HB_COMP_PARAM, "-t" ); + szSwPtr = hb_compChkOptionGet( szSwPtr + 1, NULL, fEnv ); + break; + + case 'U': + if( hb_strnicmp( szSwPtr, "UNDEF:", 6 ) == 0 ) + { + if( hb_strnicmp( szSwPtr + 6, ".ARCH.", 6 ) == 0 ) + { + HB_COMP_PARAM->fNoArchDefs = HB_TRUE; + szSwPtr += 12; + } + else + szSwPtr = hb_compChkAddDefine( HB_COMP_PARAM, szSwPtr + 6, HB_FALSE, fEnv ); break; } - } + ++szSwPtr; + /* extended definitions file: -u+ */ + if( *szSwPtr == '+' ) + { + if( szSwPtr[ 1 ] ) + { + HB_COMP_PARAM->szStdChExt = ( char ** ) + ( HB_COMP_PARAM->iStdChExt == 0 ? + hb_xgrab( sizeof( char * ) ) : + hb_xrealloc( HB_COMP_PARAM->szStdChExt, + ( HB_COMP_PARAM->iStdChExt + 1 ) * + sizeof( char * ) ) ); + szSwPtr = hb_compChkOptionGet( szSwPtr + 1, + &HB_COMP_PARAM->szStdChExt[ HB_COMP_PARAM->iStdChExt++ ], + fEnv ); + } + } + else + { + if( HB_COMP_PARAM->szStdCh ) + hb_xfree( HB_COMP_PARAM->szStdCh ); + szSwPtr = hb_compChkOptionGet( szSwPtr, &HB_COMP_PARAM->szStdCh, fEnv ); + } + break; + + case 'V': + ++szSwPtr; + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->fForceMemvars = HB_FALSE; + ++szSwPtr; + } + else + HB_COMP_PARAM->fForceMemvars = HB_TRUE; + break; + + case 'W': + ++szSwPtr; + HB_COMP_PARAM->iWarnings = 1; + if( *szSwPtr ) + { + HB_COMP_PARAM->iWarnings = *szSwPtr - '0'; + if( HB_COMP_PARAM->iWarnings >= 0 && + HB_COMP_PARAM->iWarnings <= 3 ) + ++szSwPtr; + } + break; + +#ifdef YYDEBUG + case 'Y': + ++szSwPtr; + extern int hb_comp_yydebug; + hb_comp_yydebug = HB_TRUE; + break; +#endif + + case 'Z': + ++szSwPtr; + if( *szSwPtr == '-' ) + { + HB_COMP_PARAM->supported |= HB_COMPFLAG_SHORTCUTS; + ++szSwPtr; + } + else + HB_COMP_PARAM->supported &= ~HB_COMPFLAG_SHORTCUTS; + break; } } - else /* Check the environment variables */ + + if( ! HB_COMP_PARAM->fExit ) { - /* NOTE: CLIPPERCMD enviroment variable - is overriden if HARBOURCMD exists - */ - char * szStrEnv = hb_getenv( "HARBOURCMD" ); + if( szSwPtr - szSwitch <= 1 || + ( *szSwPtr != '\0' && *szSwPtr != ' ' && ! HB_ISOPTSEP( *szSwPtr ) ) ) + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, szSwitch, NULL ); + else + return szSwPtr; + } - if( ! szStrEnv || szStrEnv[ 0 ] == '\0' ) + return ""; +} + +/* check command line parameters */ +void hb_compChkCommandLine( HB_COMP_DECL, int argc, const char * const argv[] ) +{ + int i; + + for( i = 1; i < argc && ! HB_COMP_PARAM->fExit; ++i ) + { + const char * szSwitch = argv[ i ]; + + if( HB_ISOPTSEP( szSwitch[ 0 ] ) ) { - if( szStrEnv ) - hb_xfree( szStrEnv ); - - szStrEnv = hb_getenv( "CLIPPERCMD" ); - } - - if( szStrEnv ) - { - char * szSwitch, * szPtr; - - szPtr = szStrEnv; - while( *szPtr && ! HB_COMP_PARAM->fExit ) - { - while( *szPtr == ' ' ) - ++szPtr; - szSwitch = szPtr; - if( *szSwitch ) - { - while( *++szPtr ) - { - if( *szPtr == ' ' ) - { - *szPtr++ = '\0'; - break; - } - } - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - } - } - hb_xfree( szStrEnv ); + do + szSwitch = hb_compChkParseSwitch( HB_COMP_PARAM, szSwitch, HB_FALSE ); + while( *szSwitch != '\0' ); } } } -void hb_compChkPaths( HB_COMP_DECL ) +/* check environment parameters */ +void hb_compChkEnvironment( HB_COMP_DECL ) +{ + /* NOTE: if HARBOURCMD envvar exists then it's used instead of CLIPPERCMD */ + char * szEnvCMD = hb_getenv( "HARBOURCMD" ); + + if( ! szEnvCMD || szEnvCMD[ 0 ] == '\0' ) + { + if( szEnvCMD ) + hb_xfree( szEnvCMD ); + szEnvCMD = hb_getenv( "CLIPPERCMD" ); + } + + if( szEnvCMD ) + { + const char * szSwitch = szEnvCMD; + + while( *szSwitch ) + { + while( *szSwitch == ' ' ) + ++szSwitch; + if( *szSwitch ) + szSwitch = hb_compChkParseSwitch( HB_COMP_PARAM, szSwitch, HB_TRUE ); + } + hb_xfree( szEnvCMD ); + } +} + +void hb_compChkAddIncPaths( HB_COMP_DECL ) { char * szInclude = hb_getenv( "INCLUDE" ); @@ -1142,99 +885,16 @@ void hb_compChkPaths( HB_COMP_DECL ) } } -static void hb_compChkDefineSwitch( HB_COMP_DECL, const char * pszSwitch ) +void hb_compChkSetDefines( HB_COMP_DECL ) { - if( pszSwitch && HB_ISOPTSEP( pszSwitch[ 0 ] ) ) + PHB_PPDEFINE pDefine = HB_COMP_PARAM->ppdefines; + + while( pDefine ) { - if( pszSwitch[ 1 ] == 'd' || pszSwitch[ 1 ] == 'D' ) - { - if( pszSwitch[ 2 ] ) - { - char * szDefText = hb_strdup( pszSwitch + 2 ), * szAssign; - - szAssign = strchr( szDefText, '=' ); - if( szAssign ) - *szAssign++ = '\0'; - hb_pp_addDefine( HB_COMP_PARAM->pLex->pPP, szDefText, szAssign ); - hb_xfree( szDefText ); - } - } - else if( ( pszSwitch[ 1 ] == 'U' || pszSwitch[ 1 ] == 'u' ) && - ( pszSwitch[ 2 ] == 'N' || pszSwitch[ 2 ] == 'n' ) && - ( pszSwitch[ 3 ] == 'D' || pszSwitch[ 3 ] == 'd' ) && - ( pszSwitch[ 4 ] == 'E' || pszSwitch[ 4 ] == 'e' ) && - ( pszSwitch[ 5 ] == 'F' || pszSwitch[ 5 ] == 'f' ) && - pszSwitch[ 6 ] == ':' ) - { - char *szDefText = hb_strdup( pszSwitch + 7 ); - unsigned int i = 0; - - while( szDefText[ i ] && ! HB_ISOPTSEP( szDefText[ i ] ) ) - { - i++; - } - szDefText[ i ] = '\0'; - - if( szDefText[ 0 ] ) - { - if( hb_stricmp( szDefText, ".ARCH." ) == 0 ) - hb_pp_delDefine( HB_COMP_PARAM->pLex->pPP, szDefText ); - } - hb_xfree( szDefText ); - } - } -} - -void hb_compChkDefines( HB_COMP_DECL, int iArg, const char * const Args[] ) -{ - /* Check the environment variables */ - { - /* NOTE: CLIPPERCMD enviroment variable is overriden - if HARBOURCMD exists */ - char * szStrEnv = hb_getenv( "HARBOURCMD" ); - - if( ! szStrEnv || szStrEnv[ 0 ] == '\0' ) - { - if( szStrEnv ) - hb_xfree( szStrEnv ); - - szStrEnv = hb_getenv( "CLIPPERCMD" ); - } - - if( szStrEnv ) - { - char * szSwitch, * szPtr; - - szPtr = szStrEnv; - while( *szPtr && ! HB_COMP_PARAM->fExit ) - { - while( *szPtr == ' ' ) - ++szPtr; - szSwitch = szPtr; - if( *szSwitch ) - { - while( *++szPtr ) - { - if( *szPtr == ' ' ) - { - *szPtr++ = '\0'; - break; - } - } - hb_compChkDefineSwitch( HB_COMP_PARAM, szSwitch ); - } - } - hb_xfree( szStrEnv ); - } - } - - /* Check the command line options */ - { - int i; - - /* Check all switches in command line They start with an OS_OPT_DELIMITER - char */ - for( i = 1; i < iArg; i++ ) - hb_compChkDefineSwitch( HB_COMP_PARAM, Args[ i ] ); + if( pDefine->szValue == s_szUndefineMarker ) + hb_pp_delDefine( HB_COMP_PARAM->pLex->pPP, pDefine->szName ); + else + hb_pp_addDefine( HB_COMP_PARAM->pLex->pPP, pDefine->szName, pDefine->szValue ); + pDefine = pDefine->pNext; } } diff --git a/src/compiler/complex.c b/src/compiler/complex.c index 644bbb98d9..a42d9c3680 100644 --- a/src/compiler/complex.c +++ b/src/compiler/complex.c @@ -47,7 +47,6 @@ * */ - #include "hbpp.h" #include "hbcomp.h" #include "hbdate.h" diff --git a/src/compiler/genc.c b/src/compiler/genc.c index 0d087fa0e2..b7f38041b8 100644 --- a/src/compiler/genc.c +++ b/src/compiler/genc.c @@ -277,7 +277,7 @@ void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the szFileName[ i ] = '_'; } } - fprintf( yyc, "\n\nHB_INIT_SYMBOLS_BEGIN( hb_vm_SymbolInit_%s%s )\n", HB_COMP_PARAM->szPrefix, szFileName ); + fprintf( yyc, "\n\nHB_INIT_SYMBOLS_BEGIN( hb_vm_SymbolInit_%s )\n", szFileName ); pSym = HB_COMP_PARAM->symbols.pFirst; while( pSym ) @@ -439,9 +439,7 @@ void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the static void hb_writeEndInit( HB_COMP_DECL, FILE * yyc, const char * szModulname, const char * szSourceFile ) { - fprintf( yyc, - "\nHB_INIT_SYMBOLS_EX_END( hb_vm_SymbolInit_%s%s, ", - HB_COMP_PARAM->szPrefix, szModulname ); + fprintf( yyc, "\nHB_INIT_SYMBOLS_EX_END( hb_vm_SymbolInit_%s, ", szModulname ); if( HB_COMP_PARAM->fHideSource ) szSourceFile = ""; hb_compGenCString( yyc, ( const HB_BYTE * ) szSourceFile, strlen( szSourceFile ) ); @@ -449,13 +447,12 @@ static void hb_writeEndInit( HB_COMP_DECL, FILE * yyc, const char * szModulname, fprintf( yyc, "#if defined( HB_PRAGMA_STARTUP )\n" - " #pragma startup hb_vm_SymbolInit_%s%s\n" + " #pragma startup hb_vm_SymbolInit_%s\n" "#elif defined( HB_DATASEG_STARTUP )\n" - " #define HB_DATASEG_BODY HB_DATASEG_FUNC( hb_vm_SymbolInit_%s%s )\n" + " #define HB_DATASEG_BODY HB_DATASEG_FUNC( hb_vm_SymbolInit_%s )\n" " #include \"hbiniseg.h\"\n" "#endif\n\n", - HB_COMP_PARAM->szPrefix, szModulname, - HB_COMP_PARAM->szPrefix, szModulname ); + szModulname, szModulname ); } static void hb_compGenCFunc( FILE * yyc, const char * cDecor, const char * szName, diff --git a/src/compiler/hbmain.c b/src/compiler/hbmain.c index 1f10d1be4a..6dc006bcb3 100644 --- a/src/compiler/hbmain.c +++ b/src/compiler/hbmain.c @@ -82,11 +82,12 @@ int hb_compMainExt( int argc, const char * const argv[], HB_COMP_PARAM->pOutPath = NULL; /* First check the environment variables */ - hb_compChkCompilerSwitch( HB_COMP_PARAM, 0, NULL ); + hb_compChkEnvironment( HB_COMP_PARAM ); /* Then check command line arguments This will override duplicated environment settings */ - hb_compChkCompilerSwitch( HB_COMP_PARAM, argc, argv ); + hb_compChkCommandLine( HB_COMP_PARAM, argc, argv ); + if( ! HB_COMP_PARAM->fExit ) { if( HB_COMP_PARAM->iTraceInclude == 0 && @@ -122,10 +123,10 @@ int hb_compMainExt( int argc, const char * const argv[], /* Set Search Path */ if( HB_COMP_PARAM->fINCLUDE ) - hb_compChkPaths( HB_COMP_PARAM ); + hb_compChkAddIncPaths( HB_COMP_PARAM ); /* Set standard rules */ - hb_compInitPP( HB_COMP_PARAM, argc, argv, pOpenFunc ); + hb_compInitPP( HB_COMP_PARAM, pOpenFunc ); /* Prepare the table of identifiers */ hb_compIdentifierOpen( HB_COMP_PARAM ); @@ -3960,6 +3961,15 @@ void hb_compCompileEnd( HB_COMP_DECL ) hb_xfree( pIncFile ); } + while( HB_COMP_PARAM->ppdefines ) + { + PHB_PPDEFINE pDefine = HB_COMP_PARAM->ppdefines; + + HB_COMP_PARAM->ppdefines = pDefine->pNext; + hb_xfree( pDefine->szName ); + hb_xfree( pDefine ); + } + while( HB_COMP_PARAM->inlines.pFirst ) { PHB_HINLINE pInline = HB_COMP_PARAM->inlines.pFirst; diff --git a/src/compiler/hbusage.c b/src/compiler/hbusage.c index 11c8c60898..5abd4a3151 100644 --- a/src/compiler/hbusage.c +++ b/src/compiler/hbusage.c @@ -99,7 +99,6 @@ void hb_compPrintUsage( HB_COMP_DECL, const char * szSelf ) "\n -undef: #undef ", "\n -v variables are assumed M->", "\n -w[] set warning level number (0..3, default 1)", - "\n -x[] set symbol init function name prefix (for .c only)", #ifdef YYDEBUG "\n -y trace lex & yacc activity", #endif diff --git a/src/compiler/ppcomp.c b/src/compiler/ppcomp.c index 36f4cc9be1..9838cf37c3 100644 --- a/src/compiler/ppcomp.c +++ b/src/compiler/ppcomp.c @@ -391,8 +391,7 @@ static void hb_pp_fileIncluded( void * cargo, const char * szFileName ) *pIncFilePtr = pIncFile; } -void hb_compInitPP( HB_COMP_DECL, int argc, const char * const argv[], - PHB_PP_OPEN_FUNC pOpenFunc ) +void hb_compInitPP( HB_COMP_DECL, PHB_PP_OPEN_FUNC pOpenFunc ) { HB_TRACE( HB_TR_DEBUG, ( "hb_compInitPP()" ) ); @@ -419,7 +418,7 @@ void hb_compInitPP( HB_COMP_DECL, int argc, const char * const argv[], hb_pp_initDynDefines( HB_COMP_PARAM->pLex->pPP, ! HB_COMP_PARAM->fNoArchDefs ); /* Add /D and /undef: command line or envvar defines */ - hb_compChkDefines( HB_COMP_PARAM, argc, argv ); + hb_compChkSetDefines( HB_COMP_PARAM ); /* add extended definitions files (-u+) */ if( HB_COMP_PARAM->iStdChExt > 0 ) diff --git a/src/main/harbour.c b/src/main/harbour.c index 22b2e0ed72..4419e9934e 100644 --- a/src/main/harbour.c +++ b/src/main/harbour.c @@ -124,8 +124,6 @@ int main( int argc, char * argv[] ) { int iResult; - hb_compChkFileSwitches( argc, argv ); - iResult = hb_compMain( argc, ( const char * const * ) argv ); hb_xexit(); diff --git a/src/nortl/nortl.c b/src/nortl/nortl.c index b55f11b696..3644a36e5e 100644 --- a/src/nortl/nortl.c +++ b/src/nortl/nortl.c @@ -691,108 +691,22 @@ int hb_setGetDirSeparator( void ) return s_cDirSep; } -void hb_compChkFileSwitches( int argc, char * argv[] ) +void hb_setSetFileCase( int iFileCase ) { - int i, n; - - for( i = 1; i < argc; ++i ) - { - if( HB_ISOPTSEP( argv[ i ][ 0 ] ) && argv[ i ][ 1 ] == 'f' ) - { - n = 0; - switch( argv[ i ][ 2 ] ) - { - case 'n': - if( ! argv[ i ][ 3 ] ) - { - s_iFileCase = HB_SET_CASE_MIXED; - n = 3; - } - else if( argv[ i ][ 3 ] == ':' ) - { - if( argv[ i ][ 4 ] == 'u' ) - { - s_iFileCase = HB_SET_CASE_UPPER; - n = 5; - } - else if( argv[ i ][ 4 ] == 'l' ) - { - s_iFileCase = HB_SET_CASE_LOWER; - n = 5; - } - } - else if( argv[ i ][ 3 ] == '-' ) - { - s_iFileCase = HB_SET_CASE_MIXED; - n = 4; - } - break; - - case 'd': - if( ! argv[ i ][ 3 ] ) - { - s_iDirCase = HB_SET_CASE_MIXED; - n = 3; - } - else if( argv[ i ][ 3 ] == ':' ) - { - if( argv[ i ][ 4 ] == 'u' ) - { - s_iDirCase = HB_SET_CASE_UPPER; - n = 5; - } - else if( argv[ i ][ 4 ] == 'l' ) - { - s_iDirCase = HB_SET_CASE_LOWER; - n = 5; - } - } - else if( argv[ i ][ 3 ] == '-' ) - { - s_iDirCase = HB_SET_CASE_MIXED; - n = 4; - } - break; - - case 'p': - if( ! argv[ i ][ 3 ] ) - { - s_cDirSep = HB_OS_PATH_DELIM_CHR; - n = 3; - } - else if( argv[ i ][ 3 ] == '-' ) - { - s_cDirSep = HB_OS_PATH_DELIM_CHR; - n = 4; - } - else if( argv[ i ][ 3 ] == ':' && argv[ i ][ 4 ] ) - { - s_cDirSep = argv[ i ][ 4 ]; - n = 5; - } - break; - - case 's': - if( ! argv[ i ][ 3 ] ) - { - s_fFnTrim = HB_TRUE; - n = 3; - } - else if( argv[ i ][ 3 ] == '-' ) - { - s_fFnTrim = HB_FALSE; - n = 4; - } - break; - } - if( n ) - { - argv[ i ] += n; - if( argv[ i ][ 0 ] ) - --i; - else - argv[ i ] = ( char * ) "-"; - } - } - } + s_iFileCase = iFileCase; +} + +void hb_setSetDirCase( int iDirCase ) +{ + s_iDirCase = iDirCase; +} + +void hb_setSetDirSeparator( int iSeparator ) +{ + s_cDirSep = ( char ) iSeparator; +} + +void hb_setSetTrimFileName( HB_BOOL fTrim ) +{ + s_fFnTrim = fTrim; } diff --git a/src/rtl/teditor.prg b/src/rtl/teditor.prg index 34310c6aa1..4ad3720bad 100644 --- a/src/rtl/teditor.prg +++ b/src/rtl/teditor.prg @@ -613,7 +613,7 @@ METHOD BrowseText( nPassedKey ) CLASS HBEditor nKeyStd := hb_keyStd( nKey ) IF ( bKeyBlock := SetKey( nKeyStd ) ) != NIL Eval( bKeyBlock ) - ELSEIF nKeyStd == K_ESC + ELSEIF nKeyStd == K_ESC ::lExitEdit := .T. ELSEIF ! ::MoveCursor( nKey ) ::KeyboardHook( nKey ) diff --git a/src/vm/set.c b/src/vm/set.c index 7825da1d0d..84b52d7087 100644 --- a/src/vm/set.c +++ b/src/vm/set.c @@ -2591,18 +2591,48 @@ int hb_setGetFileCase( void ) return hb_stackSetStruct()->HB_SET_FILECASE; } +void hb_setSetFileCase( int iFileCase ) +{ + HB_STACK_TLS_PRELOAD + hb_stackSetStruct()->HB_SET_FILECASE = iFileCase; +} + int hb_setGetDirCase( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_DIRCASE; } +void hb_setSetDirCase( int iDirCase ) +{ + HB_STACK_TLS_PRELOAD + hb_stackSetStruct()->HB_SET_DIRCASE = iDirCase; +} + int hb_setGetDirSeparator( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_DIRSEPARATOR; } +void hb_setSetDirSeparator( int iSeparator ) +{ + HB_STACK_TLS_PRELOAD + hb_stackSetStruct()->HB_SET_DIRSEPARATOR = iSeparator; +} + +HB_BOOL hb_setGetTrimFileName( void ) +{ + HB_STACK_TLS_PRELOAD + return hb_stackSetStruct()->HB_SET_TRIMFILENAME; +} + +void hb_setSetTrimFileName( HB_BOOL fTrim ) +{ + HB_STACK_TLS_PRELOAD + hb_stackSetStruct()->HB_SET_TRIMFILENAME = fTrim; +} + int hb_setGetVideoMode( void ) { HB_STACK_TLS_PRELOAD @@ -2645,12 +2675,6 @@ const char * hb_setGetEOL( void ) return hb_stackSetStruct()->HB_SET_EOL; } -HB_BOOL hb_setGetTrimFileName( void ) -{ - HB_STACK_TLS_PRELOAD - return hb_stackSetStruct()->HB_SET_TRIMFILENAME; -} - const char * hb_setGetHBOUTLOG( void ) { HB_STACK_TLS_PRELOAD