Files
harbour-core/harbour/source/compiler/cmdcheck.c
Przemyslaw Czerpak c3e1436da0 2009-06-26 02:22 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbvm.h
  * harbour/include/hbrdddbf.h
  * harbour/include/hbapidbg.h
  * harbour/include/hbset.h
  * harbour/include/hbcomp.h
  * harbour/include/hbapirdd.h
  * harbour/include/hbstack.h
  * harbour/include/hbsxfunc.h
  * harbour/include/hbapilng.h
  * harbour/include/hbgtcore.h
  * harbour/include/hbapifs.h
  * harbour/include/hbdbsort.h
  * harbour/include/hbapigt.h
  * harbour/include/hbapi.h
  * harbour/include/hbapierr.h
  * harbour/include/hbapiitm.h
  * harbour/include/hbrddfpt.h
  * harbour/contrib/hbmysql/mysql.c
  * harbour/contrib/hbct/bitnum.c
  * harbour/contrib/hbct/token2.c
  * harbour/contrib/hbct/charsprd.c
  * harbour/contrib/hbct/ctnet.c
  * harbour/contrib/hbct/charonly.c
  * harbour/contrib/hbct/atadjust.c
  * harbour/contrib/hbct/ctwin.c
  * harbour/contrib/hbct/charsort.c
  * harbour/contrib/hbct/ctwin.h
  * harbour/contrib/hbct/charmix.c
  * harbour/contrib/hbct/charevod.c
  * harbour/contrib/hbct/maxline.c
  * harbour/contrib/hbct/wordrepl.c
  * harbour/contrib/hbct/charrepl.c
  * harbour/contrib/hbct/files.c
  * harbour/contrib/hbct/video.c
  * harbour/contrib/hbct/charswap.c
  * harbour/contrib/hbct/dattime3.c
  * harbour/contrib/hbct/charop.c
  * harbour/contrib/hbct/misc2.c
  * harbour/contrib/hbct/charone.c
  * harbour/contrib/hbct/ctstr.c
  * harbour/contrib/hbct/screen1.c
  * harbour/contrib/hbct/token1.c
  * harbour/contrib/hbct/ctstr.h
  * harbour/contrib/hbct/charmirr.c
  * harbour/contrib/hbct/relation.c
  * harbour/contrib/hbct/atnum.c
  * harbour/contrib/hbct/like.c
  * harbour/contrib/hbct/count.c
  * harbour/contrib/hbct/disk.c
  * harbour/contrib/hbct/ctstrfil.c
  * harbour/contrib/hbct/posdiff.c
  * harbour/contrib/hbct/addascii.c
  * harbour/contrib/hbct/tab.c
  * harbour/contrib/hbct/numline.c
  * harbour/contrib/hbct/dattime2.c
  * harbour/contrib/hbct/asciisum.c
  * harbour/contrib/hbct/expand.c
  * harbour/contrib/hbct/pos2.c
  * harbour/contrib/hbct/numat.c
  * harbour/contrib/hbct/atrepl.c
  * harbour/contrib/hbct/wordtoch.c
  * harbour/contrib/hbct/print.c
  * harbour/contrib/hbct/justify.c
  * harbour/contrib/xhb/hbxml.c
  * harbour/contrib/xhb/dbf2txt.c
  * harbour/contrib/xhb/xhbis.c
  * harbour/contrib/xhb/fparse.c
  * harbour/contrib/xhb/xstrdel.c
  * harbour/contrib/xhb/hbcomprs.c
  * harbour/contrib/xhb/datesxhb.c
  * harbour/contrib/xhb/xhbmsgs.c
  * harbour/contrib/xhb/freadlin.c
  * harbour/contrib/xhb/txtline.c
  * harbour/contrib/xhb/xhbtrim.c
  * harbour/contrib/xhb/xhbcopyf.c
  * harbour/contrib/xhb/cstructc.c
  * harbour/contrib/xhb/xhbfunc.c
  * harbour/contrib/hbtpathy/tplinux.c
  * harbour/contrib/hbgt/charmixg.c
  * harbour/contrib/hbgt/strexpan.c
  * harbour/contrib/hbgt/charodd.c
  * harbour/contrib/hbgt/strright.c
  * harbour/contrib/hbgt/asciisgt.c
  * harbour/contrib/hbgt/strdiffg.c
  * harbour/contrib/hbgt/chrtotal.c
  * harbour/contrib/hbgt/strcount.c
  * harbour/contrib/hbgt/strleft.c
  * harbour/contrib/hbgt/ascposgt.c
  * harbour/contrib/hbgt/chrfirst.c
  * harbour/contrib/hbgt/chrcount.c
  * harbour/contrib/hbgt/strpbrk.c
  * harbour/contrib/hbgt/chareven.c
  * harbour/contrib/hbgt/strcspn.c
  * harbour/contrib/hbgt/atdiff.c
  * harbour/contrib/hbsqlit3/hbsqlit3.c
  * harbour/contrib/hbmzip/hbmzip.c
  * harbour/contrib/hbnf/proper.c
  * harbour/contrib/hbnf/fttext.c
  * harbour/contrib/hbnf/chdir.c
  * harbour/contrib/hbnf/getver.c
  * harbour/contrib/hbnf/ftattr.c
  * harbour/contrib/hbnf/mkdir.c
  * harbour/contrib/hbnf/rmdir.c
  * harbour/contrib/Makefile
  * harbour/contrib/hbcurl/hbcurl.c
  * harbour/contrib/rddsql/sddmy/mysqldd.c
  * harbour/contrib/rddsql/sddpg/pgsqldd.c
  * harbour/contrib/rddsql/sddfb/fbirddd.c
  * harbour/contrib/rddsql/sddodbc/odbcdd.c
  * harbour/contrib/rddsql/sqlmix.c
  * harbour/contrib/hbhpdf/harupdf.c
  * harbour/contrib/rddads/adsx.c
  * harbour/contrib/rddads/adsfunc.c
  * harbour/contrib/rddads/rddads.h
  * harbour/contrib/rddads/ads1.c
  * harbour/contrib/hbmisc/hb_f.c
  * harbour/contrib/hbmisc/strfmt.c
  * harbour/contrib/hbmisc/stringsx.c
  * harbour/contrib/hbmisc/spd.c
  * harbour/contrib/hbtip/utils.c
  * harbour/contrib/hbwin/wapi_winbase.c
  * harbour/contrib/hbwin/win_misc.c
  * harbour/contrib/hbbtree/hb_btree.h
  * harbour/contrib/hbbtree/hb_btree.c
  * harbour/source/pp/hbpp.c
  * harbour/source/vm/runner.c
  * harbour/source/vm/estack.c
  * harbour/source/vm/itemapi.c
  * harbour/source/vm/hvm.c
  * harbour/source/vm/cmdarg.c
  * harbour/source/vm/memvars.c
  * harbour/source/vm/dynlibhb.c
  * harbour/source/vm/set.c
  * harbour/source/main/harbour.c
  * harbour/source/debug/dbgentry.c
  * harbour/source/common/hbfsapi.c
  * harbour/source/common/hbfopen.c
  * harbour/source/rtl/gtdos/gtdos.c
  * harbour/source/rtl/diskspac.c
  * harbour/source/rtl/console.c
  * harbour/source/rtl/chrasc.c
  * harbour/source/rtl/fscopy.c
  * harbour/source/rtl/run.c
  * harbour/source/rtl/spfiles.c
  * harbour/source/rtl/defpath.c
  * harbour/source/rtl/philes.c
  * harbour/source/rtl/oldbox.c
  * harbour/source/rtl/math.c
  * harbour/source/rtl/hbgtcore.c
  * harbour/source/rtl/cdpapi.c
  * harbour/source/rtl/gtcrs/gtcrs.c
  * harbour/source/rtl/dirdrive.c
  * harbour/source/rtl/hbi18n1.c
  * harbour/source/rtl/trim.c
  * harbour/source/rtl/hbzlibgz.c
  * harbour/source/rtl/philesx.c
  * harbour/source/rtl/mlcfunc.c
  * harbour/source/rtl/filehb.c
  * harbour/source/rtl/fstemp.c
  * harbour/source/rtl/is.c
  * harbour/source/rtl/hbrunfun.c
  * harbour/source/rtl/ampm.c
  * harbour/source/rtl/setcolor.c
  * harbour/source/rtl/oemansi.c
  * harbour/source/rtl/disksphb.c
  * harbour/source/rtl/hbzlib.c
  * harbour/source/rtl/strpeek.c
  * harbour/source/rtl/replic.c
  * harbour/source/rtl/stuff.c
  * harbour/source/rtl/hbstrfmt.c
  * harbour/source/rtl/transfrm.c
  * harbour/source/rtl/hbhex.c
  * harbour/source/rtl/trace.c
  * harbour/source/rtl/hbadler.c
  * harbour/source/rtl/samples.c
  * harbour/source/rtl/filebuf.c
  * harbour/source/rtl/hbcrc.c
  * harbour/source/rtl/gete.c
  * harbour/source/rtl/hbmd5.c
  * harbour/source/rtl/langapi.c
  * harbour/source/rtl/gtcgi/gtcgi.c
  * harbour/source/rtl/errapi.c
  * harbour/source/rtl/hbregexc.c
  * harbour/source/rtl/natmsg.c
  * harbour/source/rtl/fssize.c
  * harbour/source/rtl/hbinet.c
  * harbour/source/rtl/colorind.c
  * harbour/source/rtl/copyfile.c
  * harbour/source/rtl/mouseapi.c
  * harbour/source/rtl/soundex.c
  * harbour/source/rtl/memofile.c
  * harbour/source/rtl/hbffind.c
  * harbour/source/rtl/gtapi.c
  * harbour/source/rtl/direct.c
  * harbour/source/rtl/filesys.c
  * harbour/source/rtl/file.c
  * harbour/source/rtl/val.c
  * harbour/source/rtl/hbregex.c
  * harbour/source/rtl/rat.c
  * harbour/source/rtl/isprint.c
  * harbour/source/rdd/dbfntx/dbfntx1.c
  * harbour/source/rdd/dbsql.c
  * harbour/source/rdd/workarea.c
  * harbour/source/rdd/wacore.c
  * harbour/source/rdd/sdf1.c
  * harbour/source/rdd/dbdetach.c
  * harbour/source/rdd/dbcmdx.c
  * harbour/source/rdd/dbfnsx/dbfnsx1.c
  * harbour/source/rdd/dbcmd.c
  * harbour/source/rdd/dbfcdx/dbfcdx1.c
  * harbour/source/rdd/delim1.c
  * harbour/source/rdd/dbf1.c
  * harbour/source/rdd/hsx/hsx.c
  * harbour/source/rdd/dbcmd53.c
  * harbour/source/rdd/usrrdd/usrrdd.c
  * harbour/source/rdd/wafunc.c
  * harbour/source/rdd/dbffpt/dbffpt1.c
  * harbour/source/rdd/hbsix/sxsem.c
  * harbour/source/rdd/hbsix/sxord.c
  * harbour/source/rdd/hbsix/sxfname.c
  * harbour/source/rdd/hbsix/sxtable.c
  * harbour/source/rdd/hbsix/sxdate.c
  * harbour/source/rdd/hbsix/sxutil.c
  * harbour/source/rdd/hbsix/sxcompr.c
  * harbour/source/compiler/hbmain.c
  * harbour/source/compiler/cmdcheck.c
  * harbour/source/compiler/hbpcode.c
  * harbour/source/compiler/genc.c
  * harbour/source/compiler/gencc.c
  * harbour/source/compiler/hbcmplib.c
  * harbour/source/compiler/ppcomp.c
    * changed 'char *' and changed 'BYTE *' to 'const char *' in
      the following functions:
         const char * hb_vmFindModuleSymbolName( PHB_SYMB pSym );
         void  hb_vmInitSymbolGroup( void * hNewDynLib, int argc,
                                     const char * argv[] );
         void hb_dbgEntry( int nMode, int nLine, const char *szName,
                           int nIndex, PHB_ITEM pFrame );
         void hb_dbgAddBreak( void *handle, const char *cModule,
                              int nLine, const char *szFunction );
         void hb_dbgAddWatch( void *handle, const char *szExpr, BOOL bTrace );
         PHB_ITEM hb_dbgGetExpressionValue( void *handle,
                                            const char *expression );
         BOOL hb_dbgIsValidStopLine( void *handle, const char *szModule,
                                     int nLine );
         void hb_dbgSetToCursor( void *handle, const char *szModule,
                                 int nLine );
         void hb_dbgSetWatch( void *handle, int nWatch,
                              const char *szExpr, BOOL bTrace );
         const char * hb_setGetCPtr( HB_set_enum set_specifier );
         const char * hb_setGetAltFile( void );
         const char * hb_setGetDateFormat( void );
         const char * hb_setGetTimeFormat( void );
         const char * hb_setGetDefault( void );
         const char * hb_setGetDelimChars( void );
         const char * hb_setGetDevice( void );
         const char * hb_setGetExtraFile( void );
         const char * hb_setGetPath( void );
         const char * hb_setGetMFileExt( void );
         const char * hb_setGetPrintFile( void );
         const char * hb_setGetEOL( void );
         const char * hb_setGetHBOUTLOG( void );
         const char * hb_setGetHBOUTLOGINFO( void );
         const char * hb_setGetOSCODEPAGE( void );
         void hb_compInitPP( HB_COMP_DECL, int argc,
                             const char * const argv[] );
         void hb_compGenPCodeN( const BYTE * pBuffer, ULONG ulSize,
                                HB_COMP_DECL );
         int  hb_compMain( int argc, const char * const argv[],
                           BYTE ** pBufPtr, ULONG * pulSize,
                           const char * szSource );
         void hb_compChkCompilerSwitch( HB_COMP_DECL, int,
                                        const char * const args[] );
         void hb_compChkDefines( HB_COMP_DECL, int iArg,
                                 const char * const args[] );
         void hb_compGenCString( FILE * yyc, const BYTE * pText, ULONG ulLen );
         AREAP hb_rddRequestArea( const char * szAlias, PHB_ITEM pCargo,
                                  BOOL fNewArea, BOOL fWait );
         char * hb_stackDirBuffer( void );
         LONG hb_sxPtoD( const char * pDate );
         const char * hb_langID( void );
         const char * hb_langSelectID( const char * pszID );
         const char * hb_langDGetItem( int iIndex );
         const char * hb_langDGetErrorDesc( ULONG ulIndex );
         BOOL       hb_fsChDir( const char * pszDirName );
         HB_FHANDLE hb_fsCreate( const char * pszFileName, ULONG ulAttr );
         HB_FHANDLE hb_fsCreateEx( const char * pszFilename, ULONG ulAttr,
                                   USHORT uiFlags );
         HB_FHANDLE hb_fsCreateTemp( const char * pszDir,
                                     const char * pszPrefix,
                                     ULONG ulAttr, char * pszName );
         HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir,
                                       const char * pszPrefix,
                                       const char * pszExt, ULONG ulAttr );
         const char * hb_fsCurDir( USHORT uiDrive );
         USHORT     hb_fsCurDirBuff( USHORT uiDrive, char * pbyBuffer,
                                     ULONG ulLen );
         void       hb_fsBaseDirBuff( char * pbyBuffer );
         BOOL       hb_fsDelete( const char * pszFileName );
         BOOL       hb_fsFile( const char * pszFileName );
         BOOL       hb_fsIsDirectory( const char * pszFilename );
         HB_FOFFSET hb_fsFSize( const char * pszFileName, BOOL bUseDirEntry );
         HB_FHANDLE hb_fsExtOpen( const char * pszFileName,
                                  const char * pDefExt,
         char *     hb_fsExtName( const char * pFilename,
                                  const char * pDefExt, USHORT uiExFlags,
                                  const char * pPaths );
         BOOL       hb_fsMkDir( const char * pszDirName );
         HB_FHANDLE hb_fsOpen( const char * pszFileName, USHORT uiFlags );
         BOOL       hb_fsRmDir( const char * pszDirName );
         BOOL       hb_fsRename( const char * pszOldName,
                                 const char * pszNewName );
         BOOL       hb_fsGetFileTime( const char * pszFileName,
                                      LONG * plJulian, LONG * plMillisec );
         BOOL       hb_fsSetFileTime( const char * pszFileName,
                                      LONG lJulian, LONG lMillisec );
         BOOL       hb_fsGetAttr( const char * pszFileName, ULONG * pulAttr );
         BOOL       hb_fsSetAttr( const char * pszFileName, ULONG ulAttr );
         HB_FHANDLE hb_fsPOpen( const char * pFilename, const char * pMode );
         BOOL       hb_fsCopy( const char * pSource, const char * pDest );
         BOOL       hb_spFile( const char * pFilename, char * pRetPath );
         BOOL       hb_spFileExists( const char * pFilename, char * pRetPath );
         HB_FHANDLE hb_spOpen( const char * pFilename, USHORT uiFlags );
         HB_FHANDLE hb_spCreate( const char * pFilename, ULONG ulAttr );
         HB_FHANDLE hb_spCreateEx( const char * pFilename,
                                   ULONG ulAttr, USHORT uiFlags );
         PHB_FILE   hb_fileExtOpen( const char * pFilename,
                                    const char * pDefExt, USHORT uiExFlags,
                                    const char * pPaths, PHB_ITEM pError );
         PHB_FILE   hb_fileCreateTemp( const char * pszDir,
                                       const char * pszPrefix,
                                       ULONG ulAttr, char * pszName );
         PHB_FILE   hb_fileCreateTempEx( char * pszName, const char * pszDir,
                                         const char * pszPrefix,
                                         const char * pszExt, ULONG ulAttr );
         HB_ERRCODE hb_gtBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom,
                              SHORT uiRight, const BYTE * pbyFrame );
         HB_ERRCODE hb_gtDrawBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom,
                                  SHORT uiRight, const BYTE * pbyFrame,
                                  int iColor );
         HB_ERRCODE hb_gtWrite( const BYTE * pbyStr, ULONG ulLen );
         HB_ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol,
                                  const BYTE * pbyStr, ULONG ulLen );
         HB_ERRCODE hb_gtWriteCon( const BYTE * pbyStr, ULONG ulLen );
         HB_ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol,
                                  const BYTE * pStr, ULONG ulLength,
                                  int iColor );
         HB_ERRCODE hb_gtOutStd( const BYTE * pbyStr, ULONG ulLen );
         HB_ERRCODE hb_gtOutErr( const BYTE * pbyStr, ULONG ulLen );
         HB_ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight,
                                const BYTE * pbyFrame, int iColor );
         void       hb_mouseRestoreState( const BYTE * pBuffer );
         const char * hb_strLTrim( const char * szText, ULONG * ulLen );
         const char * hb_conNewLine( void );
         const char * hb_conSetColor( const char * szColor );
         const char * hb_errGetDescription( PHB_ITEM pError );
         const char * hb_errGetFileName( PHB_ITEM pError );
         const char * hb_errGetOperation( PHB_ITEM pError );
         const char * hb_errGetSubSystem( PHB_ITEM pError );
         int hb_ctwAddWindowBox( int iWindow, const BYTE * szBox, int iColor );
         const char *ct_at_exact_forward
                              ( const char *pcString, size_t sStrLen,
                                const char *pcMatch, size_t sMatchLen,
                                size_t *psMatchStrLen );
         const char *ct_at_exact_backward
                              ( const char *pcString, size_t sStrLen,
                                const char *pcMatch, size_t sMatchLen,
                                size_t *psMatchStrLen );
         const char *ct_at_wildcard_forward
                              ( const char *pcString, size_t sStrLen,
                                const char *pcMatch, size_t sMatchLen,
                                char cWildCard, size_t *psMatchStrLen );
         const char *ct_at_wildcard_backward
                              ( const char *pcString, size_t sStrLen,
                                const char *pcMatch, size_t sMatchLen,
                                char cWildCard, size_t *psMatchStrLen );
         const char *ct_at_charset_forward
                              ( const char *pcString, size_t sStrLen,
                                const char *pcCharSet, size_t sCharSetLen,
                                size_t *psMatchedCharPos );
         const char *ct_at_charset_backward
                              ( const char *pcString, size_t sStrLen,
                                const char *pcCharSet, size_t sCharSetLen,
                                size_t *psMatchedCharPos );
         char * hb_adsOemToAnsi( const char * pcString, ULONG ulLen );
         char * hb_adsAnsiToOem( const char * pcString, ULONG ulLen );
         struct hb_BTree * hb_BTreeNew( const char *FileName,
                                        USHORT usPageSize, USHORT usKeySize,
                                        ULONG ulFlags, USHORT usBuffers );
         struct hb_BTree * hb_BTreeOpen( const char *FileName, ULONG lFlags,
                                         USHORT usBuffers );
         BOOL hb_BTreeInsert( struct hb_BTree * pBTree, const char * szKey,
                              PHB_ITEM pData );
         BOOL hb_BTreeDelete( struct hb_BTree * pBTree, const char * szKey,
                              LONG lData );
         BOOL hb_BTreeSeek( struct hb_BTree * pBTree, const char * szKey,
                            LONG lData, BOOL bSoftSeek );
         const char * hb_BTreeKey( struct hb_BTree * pBTree );

    * modified RDD methods:
         HB_ERRCODE PUTVALUEFILE( AREAP, USHORT, const char *, USHORT );
         HB_ERRCODE GETVALUEFILE( AREAP, USHORT, const char *, USHORT );
    * modified GT methods:
         void REST( HB_GT_PTR, int, int, int, int, const BYTE * );
         void PUTTEXT( HB_GT_PTR, int, int, BYTE, const BYTE *, ULONG );
         void WRITEAT( HB_GT_PTR, int, int, const BYTE *, ULONG );
         void WRITE( HB_GT_PTR, const BYTE *, ULONG );
         void WRITECON( HB_GT_PTR, const BYTE *, ULONG );
         void BOX( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE );
         void BOXD( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE );
         void BOXS( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE );
         void OUTSTD( HB_GT_PTR, BYTE *, ULONG );
         void OUTERR( HB_GT_PTR, BYTE *, ULONG );
         void MOUSERESTORESTATE( HB_GT_PTR, const BYTE * );
    * modified RDD structers:
         DBFIELDINFO, DBOPENINFO, DBORDERCONDINFO, DBCONSTRAINTINFO,
         DBORDERCREATEINFO
    + modified parameters and behevior:
         const char * hb_fsNameConv( const char * szFileName, char ** pszFree );
         const char * hb_osEncode( const char * szFileName, char ** pszFree );
         const char * hb_osDecode( const char * szFileName, char ** pszFree );
      Please look at implementation and current usage of these functions.
    + added new function:
         BOOL hb_itemGetWriteCL( PHB_ITEM pItem,
                                 char ** pszValue, ULONG * pulLen );
      which converts item string buffer to writable state to use with
      functions like FREAD() instead of hb_itemUnShare*()
    * updatd other code to respect above modifications
    ! fixed bugs (also GPF traps) located by above modifications

   TODO: please make build tests. Especially in OS2 - not tested at all.
2009-06-26 00:33:38 +00:00

1145 lines
38 KiB
C

/*
* $Id$
*/
/*
* Harbour Project source code:
* Compiler command line and HARBOURCMD/CLIPPERCMD checking
*
* Copyright 1999 {list of individual authors and e-mail addresses}
* www - http://www.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:
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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/).
*
*/
/*
* The following parts are Copyright of the individual authors.
* www - http://www.harbour-project.org
*
* Copyright 2000 Ron Pinkas <Ron@Profit-Master.com>
* hb_compChkCompilerSwitch()
*
* Copyright 1999 Jose Lalin <dezac@corevia.com>
* hb_compChkEnvironVar()
*
* Copyright 1999-2001 Viktor Szakats (harbour.01 syenar.hu)
* PackDateTime()
* hb_compChkDefineSwitch()
* hb_compChkDefines()
*
* See COPYING for licensing terms.
*
*/
#include "hbcomp.h"
#include "hbdate.h"
/* TODO: Add support for this compiler switches
-r -t || hb_getenv( "TMP" )
*/
/* 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 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 ULONG PackDateTime( void )
{
union
{
struct
{
UINT32 second : 6; /* bits: 0 - 5 */
UINT32 minute : 6; /* bits: 6 - 11 */
UINT32 hour : 5; /* bits: 12 - 16 */
UINT32 day : 5; /* bits: 16 - 21 */
UINT32 month : 4; /* bits: 22 - 25 */
UINT32 year : 6; /* bits: 26 - 31 */
} ts;
UINT32 val;
} u;
int iYear, iMonth, iDay, iHour, iMinute, iSecond, iMillisec;
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;
}
static void hb_notSupportedInfo( HB_COMP_DECL, const char *szSwitch )
{
char buffer[ 512 ];
hb_snprintf( buffer, sizeof( buffer ),
"Not yet supported command line option: %s\n", szSwitch );
hb_compOutStd( HB_COMP_PARAM, buffer );
}
static void hb_compChkEnvironVar( HB_COMP_DECL, 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 = FALSE;
else
HB_COMP_PARAM->fAutoMemvarAssume = 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 = TRUE;
else
{
if( *( s + 1 ) == '-' )
HB_COMP_PARAM->fDebugInfo = FALSE;
else
{
HB_COMP_PARAM->fDebugInfo = TRUE;
HB_COMP_PARAM->fLineNumbers = 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 = 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;
#ifdef HB_LEGACY_LEVEL2
case 'o':
case 'O':
HB_COMP_PARAM->iLanguage = HB_LANG_OBJ_MODULE;
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;
#endif
case 'h':
case 'H':
HB_COMP_PARAM->iLanguage = HB_LANG_PORT_OBJ;
break;
#ifdef HB_GEN_OBJ32
case 'w':
case 'W':
HB_COMP_PARAM->iLanguage = HB_LANG_OBJ32;
break;
#endif
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':
hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, s + 1, FALSE );
break;
case 'j':
case 'J':
HB_COMP_PARAM->fI18n = 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 = FALSE;
HB_COMP_PARAM->fQuiet = 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 '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;
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 = TRUE;
else
HB_COMP_PARAM->fLineNumbers = FALSE;
break;
case 'm':
case 'M':
if( *( s + 1 ) == '-' )
HB_COMP_PARAM->fAutoOpen = TRUE;
else
HB_COMP_PARAM->fAutoOpen = FALSE;
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 = 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 = FALSE;
else
{
if( s[ 1 ] )
HB_COMP_PARAM->pPpoPath = hb_fsFNameSplit( s + 1 );
HB_COMP_PARAM->fPPO = TRUE;
}
}
break;
case 'q':
case 'Q':
switch( *( s + 1 ) )
{
case '2':
HB_COMP_PARAM->fFullQuiet = TRUE;
case '0':
HB_COMP_PARAM->fLogo = FALSE;
default:
HB_COMP_PARAM->fQuiet = 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':
if( *( s + 1 ) == '-' )
HB_COMP_PARAM->fSyntaxCheckOnly = FALSE;
else
HB_COMP_PARAM->fSyntaxCheckOnly = TRUE;
break;
case 't':
case 'T':
/* TODO: Implement this switch */
hb_notSupportedInfo( HB_COMP_PARAM, s );
break;
case 'u':
case 'U':
if( s[1] && ( s[1] == 'N' || s[1] == 'n' ) &&
s[2] && ( s[2] == 'D' || s[2] == 'd' ) &&
s[3] && ( s[3] == 'E' || s[3] == 'e' ) &&
s[4] && ( s[4] == 'F' || s[4] == 'f' ) && s[5] == ':' )
{
/* NOTE: Ignore these -undef: switches will be processed separately */
break;
}
/* extended definitions file (-u+<file>) */
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 = FALSE;
else
HB_COMP_PARAM->fForceMemvars = 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 = 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;
}
}
}
}
void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, const char * const Args[] )
{
/* If iArg is passed check the command line options */
if( iArg )
{
int i;
/* Check all switches in command line
They start with an OS_OPT_DELIMITER char
*/
for( i = 1; i < iArg && !HB_COMP_PARAM->fExit; i++ )
{
const char * szSwitch = Args[i];
if( !HB_ISOPTSEP( szSwitch[0] ) )
continue;
if( szSwitch[0] == '-' )
{
int j = 1;
char Switch[7];
Switch[0] = '-';
while( szSwitch[j] && !HB_COMP_PARAM->fExit )
{
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] && ( szSwitch[j + 1] == 'U' || szSwitch[j + 1] == 'u' ) &&
szSwitch[j + 2] && ( szSwitch[j + 2] == 'I' || szSwitch[j + 2] == 'i' ) &&
szSwitch[j + 3] && ( szSwitch[j + 3] == 'L' || szSwitch[j + 3] == 'l' ) &&
szSwitch[j + 4] && ( 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] && ( szSwitch[j + 1] == 'R' || szSwitch[j + 1] == 'r' ) &&
szSwitch[j + 2] && ( szSwitch[j + 2] == 'E' || szSwitch[j + 2] == 'e' ) &&
szSwitch[j + 3] && ( 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] && ( szSwitch[j] == 'I' || szSwitch[j] == 'i' ) )
{
j++;
if( szSwitch[j] && ( szSwitch[j] == 'T' || szSwitch[j] == 't' ) )
{
j++;
if( szSwitch[j] && ( 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 = 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':
/* 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 = strlen( szSwitch );
continue;
case 'j':
case 'J':
szSwitch += ( j - 1 );
hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );
j = 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 = 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 = 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 += strlen( szSwitch ) - 1;
}
else
{
Switch[2] = '\0';
hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
j++;
}
continue;
case 'q':
case 'Q':
if( szSwitch[j + 1] && 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 'r':
case 'R':
hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );
j = strlen( szSwitch ) - 1;
break;
case 'u':
case 'U':
szSwitch += ( j - 1 );
hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );
/* Accept rest as part of .ch Path or "undef:<id>" and continue with next Args[]. */
j = strlen( szSwitch );
continue;
case 'w':
case 'W':
if( szSwitch[j + 1] && 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 = 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 = TRUE;
HB_COMP_PARAM->fQuiet = TRUE;
}
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++;
}
continue;
}
while( !HB_COMP_PARAM->fExit )
{
int j = 1;
while( szSwitch[j] && !HB_ISOPTSEP( szSwitch[j] ) )
j++;
if( szSwitch[j] && szSwitch[j] == '/' )
{
char * szTmp = hb_strndup( szSwitch, j );
hb_compChkEnvironVar( HB_COMP_PARAM, szTmp );
hb_xfree( szTmp );
szSwitch += j;
}
else
{
hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );
break;
}
}
}
}
else
/* Chech 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( ( void * ) 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( ( void * ) szStrEnv );
}
}
}
void hb_compChkPaths( HB_COMP_DECL )
{
char *szInclude = hb_getenv( "INCLUDE" );
if( szInclude )
{
if( szInclude[0] != '\0' )
hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, szInclude, FALSE );
hb_xfree( ( void * ) szInclude );
}
}
static void hb_compChkDefineSwitch( HB_COMP_DECL, const char *pszSwitch )
{
if( pszSwitch && HB_ISOPTSEP( pszSwitch[0] ) )
{
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] && ( pszSwitch[1] == 'U' || pszSwitch[1] == 'u' ) &&
pszSwitch[2] && ( pszSwitch[2] == 'N' || pszSwitch[2] == 'n' ) &&
pszSwitch[3] && ( pszSwitch[3] == 'D' || pszSwitch[3] == 'd' ) &&
pszSwitch[4] && ( pszSwitch[4] == 'E' || pszSwitch[4] == 'e' ) &&
pszSwitch[5] && ( 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] )
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( ( void * ) 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( ( void * ) 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] );
}
}