diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ff53c82b79..54cebe3985 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,30 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-05-31 19:47 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * utils/hbmk2/hbmk2.prg + + Added experimental support for filters containing string + comparisons, f.e.: '{MY_VAR='hello'}-cflag=-DMY_FLAG' + ; NOTE: It's not guaranteed yet that this feature will stay. + + * include/hbzlib.ch + + Added HB_ZLIB_RES_* zlib result values. + + * contrib/xhb/Makefile + - contrib/xhb/hbcomprs.c + + contrib/xhb/hbcomprs.prg + + contrib/xhb/tests/compress.prg + + Rewritten xhb compatiblity compression functions in .prg. + The main reason was to avoid dependence on zlib.h on C level. + This simplifies the build layout. + ! This fixes last zip error to work in MT programs. + + Added test/demo program from xhb. Work by Giancarlo Niccolai. + ; NOTE: Tested only with xhb test/demo program. + + * contrib/xhb/hbcomprs.ch + + Changed to use HB_ZLIB_* constants. So it's now only a wrapper + instead of replicating values. + 2010-05-31 18:05 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbxpp/binnumx.c ! fixed typo in W2BIN() function - problem reported by Bicahi Esgici diff --git a/harbour/contrib/xhb/Makefile b/harbour/contrib/xhb/Makefile index 1d6c2b71cf..e517d0d548 100644 --- a/harbour/contrib/xhb/Makefile +++ b/harbour/contrib/xhb/Makefile @@ -17,7 +17,6 @@ C_SOURCES := \ filestat.c \ fparse.c \ freadlin.c \ - hbcomprs.c \ hbcrypt.c \ hboutdbg.c \ hbserv.c \ @@ -64,6 +63,7 @@ PRG_SOURCES := \ dirrec.prg \ diskhb.prg \ dumpvar.prg \ + hbcomprs.prg \ hblog.prg \ hblognet.prg \ hbstruct.prg \ @@ -99,12 +99,5 @@ PRG_HEADERS := \ hbcompat.ch \ xhb.ch \ -ifneq ($(HB_HAS_ZLIB),) - HB_CFLAGS += -DHB_HAS_ZLIB $(foreach d,$(HB_HAS_ZLIB),-I$(d)) - - include $(TOP)$(ROOT)config/header.mk - include $(TOP)$(ROOT)config/lib.mk -else - HB_SKIP_REASON := $(_DET_RES_TEXT) - include $(TOP)$(ROOT)config/none.mk -endif +include $(TOP)$(ROOT)config/header.mk +include $(TOP)$(ROOT)config/lib.mk diff --git a/harbour/contrib/xhb/hbcomprs.c b/harbour/contrib/xhb/hbcomprs.c deleted file mode 100644 index e833c8438c..0000000000 --- a/harbour/contrib/xhb/hbcomprs.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - * $Id$ - */ - -/* - * xHarbour Project source code: - * Compression related functions - * - * Copyright 2003 Giancarlo Niccolai - * www - http://www.xharbour.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, 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 - * 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 software; see the file COPYING. 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/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * 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. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * 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. - * - * 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 "hbapi.h" -#include "hbapiitm.h" -#include "hbstack.h" -#include "hbapierr.h" -#include "hbvm.h" - -#include - -/******************************************************************* -* Giancarlo Niccolai: -* Calculates the minimum length of destination buffer -*/ - -int s_hb_compress_error; - -HB_SIZE hb_destBuflen( HB_SIZE srclen ) -{ - HB_SIZE ret = srclen; - - ret += ret / 100*15 + 12; - if ( srclen % 100 != 0 ) ret+=15; - return ret; -} - -/****** COMPRESSOR WRAPPER ***** -* HB_COMPRESS( cSource [, nSourceLen ] ) --> cDest -* HB_COMPRESS( nComprFactor, cSource [,nSourceLen ] ) --> cDest -* HB_COMPRESS( cSource, nSourceLen, @cDest, @nDestLen ) --> nError -* HB_COMPRESS( nComprFactor, cSource, nSourceLen, @cDest, @nDestLen ) --> nError -*/ - -HB_FUNC( HB_COMPRESS ) -{ - const char *cSource; - char *cDest; - HB_SIZE ulSrclen, ulDstlen, ulBufLen; - PHB_ITEM pSource, pDest =NULL, pDestLen = NULL; - int nCompFactor, iFirst; - int cerr; - - if ( HB_ISNUM(1) ) - { - nCompFactor = hb_parni( 1 ); - iFirst = 1; - } - else - { - nCompFactor = Z_DEFAULT_COMPRESSION; - iFirst = 0; - } - - pSource = hb_param( iFirst + 1, HB_IT_STRING ); - - if( pSource == NULL ) - { - hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, hb_paramError(1) ); - return; - } - - cSource = hb_itemGetCPtr( pSource ); - if (hb_pcount() > iFirst + 1 ) - { - ulSrclen = (HB_SIZE) hb_parnl( iFirst + 2 ); - } - else - { - ulSrclen = hb_itemGetCLen( pSource ); - } - - /* Allocation mode: user provided or allocated here */ - if ( hb_pcount() == iFirst + 4 ) - { - pDest = hb_param( iFirst + 3, HB_IT_BYREF); - pDestLen = hb_param( iFirst + 4, HB_IT_BYREF); - ulDstlen = hb_parnl( iFirst + 4 ); - cDest = NULL; - ulBufLen = 0; - if( pDest && pDestLen && ulDstlen > 0 ) - { - hb_itemGetWriteCL( pDest, &cDest, &ulBufLen ); - } - if( cDest == NULL || ulBufLen < ulDstlen ) - { - hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, hb_paramError(1) ); - return; - } - } - else - { - ulDstlen = hb_destBuflen( ulSrclen ); - cDest = (char *) hb_xgrab( ulDstlen + 1 ); - } - - cerr = compress2( ( Bytef * ) cDest, &ulDstlen, ( const Bytef * ) cSource, ulSrclen, nCompFactor ); - - if ( cerr != Z_OK ) - { - if ( pDest != NULL ) - { - hb_retni( cerr ); - } - else - { - hb_xfree( cDest ); - hb_ret(); - } - } - else - { - if (pDestLen != NULL ) - { - hb_stornl( iFirst + 4, ( long ) ulDstlen ); - hb_retni( Z_OK ); - } - else - { - hb_retclen_buffer( cDest, ulDstlen ); - } - } - s_hb_compress_error = cerr; -} - - -/****** DECOMPRESSOR WRAPPER ***** -* HB_UNCOMPRESS( nDestLen, cSource [, nSourceLen ] ) --> cDest -* HB_UNCOMPRESS( nDestLen, cSource, nSourceLen, @cDest ) --> nError -*/ - -HB_FUNC( HB_UNCOMPRESS ) -{ - const char *cSource; - char *cDest; - HB_SIZE ulSrclen, ulDstlen, ulBufLen; - PHB_ITEM pSource, pDest; - int cerr; - - pSource = hb_param( 2, HB_IT_STRING ); - - if( ! HB_ISNUM(1) || pSource == NULL ) - { - hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, hb_paramError(1) ); - return; - } - - cSource = hb_itemGetCPtr( pSource ); - ulDstlen = (HB_SIZE) hb_parnl( 1 ); - if (hb_pcount() > 2 ) - { - ulSrclen = (HB_SIZE) hb_parnl( 3 ); - } - else - { - ulSrclen = hb_itemGetCLen( pSource ); - } - - /* Allocation mode: user provided or allocated here */ - if ( hb_pcount() == 4 ) - { - pDest = hb_param( 4, HB_IT_BYREF); - cDest = NULL; - ulBufLen = 0; - if( pDest ) - { - hb_itemGetWriteCL( pDest, &cDest, &ulBufLen ); - } - if( cDest == NULL || ulBufLen < ulDstlen ) - { - hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, hb_paramError(1) ); - return; - } - } - else - { - cDest = (char *) hb_xgrab( ulDstlen + 1 ); - } - - cerr = uncompress( ( Bytef * ) cDest, &ulDstlen, ( const Bytef * ) cSource, ulSrclen ); - - if ( cerr != Z_OK ) - { - if ( hb_pcount() == 4 ) - { - hb_retni( cerr ); - } - else - { - hb_xfree( cDest ); - hb_ret(); - } - } - else - { - if ( hb_pcount() == 4 ) - hb_retni( Z_OK ); - else - hb_retclen_buffer( cDest, ulDstlen ); - } - s_hb_compress_error = cerr; -} - -/********************************* -* HB_COMPRESSERROR() --> nError -*/ -HB_FUNC( HB_COMPRESSERROR ) -{ - hb_retni( s_hb_compress_error ); -} - -/********************************* -* HB_COMPRESSERRORDESC( nErrorCode ) --> cDesc -*/ - -HB_FUNC( HB_COMPRESSERRORDESC ) -{ - hb_retc_buffer( hb_strdup( zError( hb_parni( 1 ) ) ) ); -} - -/******************************* -* HB_COMPRESSBUFLEN( nSrcLen ) -->nDestLen -*/ - -HB_FUNC( HB_COMPRESSBUFLEN ) -{ - hb_retnl( ( long ) hb_destBuflen( hb_parni( 1 ) ) ); -} diff --git a/harbour/contrib/xhb/hbcomprs.ch b/harbour/contrib/xhb/hbcomprs.ch index 101ba9b92f..7efc66994b 100644 --- a/harbour/contrib/xhb/hbcomprs.ch +++ b/harbour/contrib/xhb/hbcomprs.ch @@ -51,38 +51,24 @@ * */ -/* This file is based upon ZLIB source code, whose copyright holder is: - * - * Copyright (C) 1995-2002 Jean-loup Gailly. - * - * Also, this file includes code slices from adler32.c for advanced CRC - * Holder of copyright for this code is: - * - * Copyright (C) 1995-2002 Mark Adler - * - * ZLIB (containing adler32 code) can be found at: - * http://www.gzip.org/zlib/ - */ - #ifndef HB_COMPRESS_CH #define HB_COMPRESS_CH -#define HB_Z_OK 0 -#define HB_Z_STREAM_END 1 -#define HB_Z_NEED_DICT 2 -#define HB_Z_ERRNO (-1) -#define HB_Z_STREAM_ERROR (-2) -#define HB_Z_DATA_ERROR (-3) -#define HB_Z_MEM_ERROR (-4) -#define HB_Z_BUF_ERROR (-5) -#define HB_Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ +#include "hbzlib.ch" -#define HB_Z_NO_COMPRESSION 0 -#define HB_Z_BEST_SPEED 1 -#define HB_Z_BEST_COMPRESSION 9 -#define HB_Z_DEFAULT_COMPRESSION (-1) +#define HB_Z_OK HB_ZLIB_RES_OK +#define HB_Z_STREAM_END HB_ZLIB_RES_STREAM_END +#define HB_Z_NEED_DICT HB_ZLIB_RES_NEED_DICT +#define HB_Z_ERRNO HB_ZLIB_RES_ERRNO +#define HB_Z_STREAM_ERROR HB_ZLIB_RES_STREAM_ERROR +#define HB_Z_DATA_ERROR HB_ZLIB_RES_DATA_ERROR +#define HB_Z_MEM_ERROR HB_ZLIB_RES_MEM_ERROR +#define HB_Z_BUF_ERROR HB_ZLIB_RES_BUF_ERROR +#define HB_Z_VERSION_ERROR HB_ZLIB_RES_VERSION_ERROR + +#define HB_Z_NO_COMPRESSION HB_ZLIB_COMPRESSION_NONE +#define HB_Z_BEST_SPEED HB_ZLIB_COMPRESSION_SPEED +#define HB_Z_BEST_COMPRESSION HB_ZLIB_COMPRESSION_SIZE +#define HB_Z_DEFAULT_COMPRESSION HB_ZLIB_COMPRESSION_DEFAULT #endif diff --git a/harbour/contrib/xhb/hbcomprs.prg b/harbour/contrib/xhb/hbcomprs.prg new file mode 100644 index 0000000000..50b795b2ef --- /dev/null +++ b/harbour/contrib/xhb/hbcomprs.prg @@ -0,0 +1,193 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Reimplementation of xhb .zip functions. EXPERIMENTAL CODE. USE AT YOUR OWN RISK. NO GUARANTEES. + * + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * 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, 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 + * 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 software; see the file COPYING. 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/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * 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. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * 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. + * + * 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 "common.ch" +#include "error.ch" + +#include "hbzlib.ch" + +THREAD STATIC s_nLastError := HB_ZLIB_RES_OK + +/****** COMPRESSOR WRAPPER ***** +* HB_COMPRESS( cSource [,nSourceLen ] ) --> cDest +* HB_COMPRESS( nComprFactor, cSource [,nSourceLen ] ) --> cDest +* HB_COMPRESS( cSource, nSourceLen, @cDest, @nDestLen ) --> nError +* HB_COMPRESS( nComprFactor, cSource, nSourceLen, @cDest, @nDestLen ) --> nError +*/ +FUNCTION HB_COMPRESS( xPar1, xPar2, xPar3, xPar4, xPar5 ) + LOCAL nComprFactor + LOCAL cSource + LOCAL nSourceLen + LOCAL nDestLen + + LOCAL lReturnByRef + + LOCAL oError + + IF ISNUMBER( xPar1 ) + nComprFactor := xPar1 + cSource := xPar2 + nSourceLen := xPar3 + nDestLen := xPar5 + lReturnByRef := PCount() >= 4 + ELSE + nComprFactor := HB_ZLIB_COMPRESSION_DEFAULT + cSource := xPar1 + nSourceLen := xPar2 + nDestLen := xPar4 + lReturnByRef := PCount() >= 3 + ENDIF + + IF ! ISCHARACTER( cSource ) + oError := ErrorNew() + + oError:severity := ES_ERROR + oError:genCode := EG_ARG + oError:subSystem := "BASE" + oError:subCode := 3012 + oError:args := { cSource } + + Eval( ErrorBlock(), oError ) + RETURN NIL + ENDIF + + IF ! ISNUMBER( nDestLen ) + nDestLen := NIL + ENDIF + + IF ISNUMBER( nSourceLen ) .AND. nSourceLen >= 0 .AND. nSourceLen < Len( cSource ) + cSource := Left( cSource, nSourceLen ) + ENDIF + + IF lReturnByRef + IF ISNUMBER( xPar1 ) + xPar4 := HB_ZCOMPRESS( cSource, nDestLen, @s_nLastError, nComprFactor ) + IF ! ISCHARACTER( xPar4 ) + xPar4 := "" + ENDIF + xPar5 := Len( xPar4 ) + ELSE + xPar3 := HB_ZCOMPRESS( cSource, nDestLen, @s_nLastError, nComprFactor ) + IF ! ISCHARACTER( xPar3 ) + xPar3 := "" + ENDIF + xPar4 := Len( xPar3 ) + ENDIF + RETURN s_nLastError + ENDIF + + RETURN HB_ZCOMPRESS( cSource, nDestLen, @s_nLastError, nComprFactor ) + +/****** DECOMPRESSOR WRAPPER ***** +* HB_UNCOMPRESS( nDestLen, cSource [, nSourceLen ] ) --> cDest +* HB_UNCOMPRESS( nDestLen, cSource, nSourceLen, @cDest ) --> nError +*/ +FUNCTION HB_UNCOMPRESS( nDestLen, cSource, nSourceLen, /* @ */ cDest ) + LOCAL oError + + IF ! ISNUMBER( nDestLen ) .OR. ; + ! ISCHARACTER( cSource ) + + oError := ErrorNew() + + oError:severity := ES_ERROR + oError:genCode := EG_ARG + oError:subSystem := "BASE" + oError:subCode := 3012 + oError:args := { nDestLen } + + Eval( ErrorBlock(), oError ) + RETURN NIL + ENDIF + + IF ISNUMBER( nSourceLen ) .AND. nSourceLen >= 0 .AND. nSourceLen < Len( cSource ) + cSource := Left( cSource, nSourceLen ) + ENDIF + + IF PCount() >= 4 + cDest := HB_ZUNCOMPRESS( cSource, nDestLen, @s_nLastError ) + RETURN s_nLastError + ENDIF + + RETURN HB_ZUNCOMPRESS( cSource, nDestLen, @s_nLastError ) + +/********************************* +* HB_COMPRESSERROR() --> nError +*/ +FUNCTION HB_COMPRESSERROR() + RETURN s_nLastError + +/********************************* +* HB_COMPRESSERRORDESC( nErrorCode ) --> cDesc +*/ +FUNCTION HB_COMPRESSERRORDESC( nError ) + RETURN HB_ZERROR( nError ) + +/******************************* +* HB_COMPRESSBUFLEN( nSrcLen ) --> nDestLen +*/ +FUNCTION HB_COMPRESSBUFLEN( nSrcLen ) + LOCAL nRet + + IF ! ISNUMBER( nSrcLen ) + nSrcLen := 0 + ENDIF + + nRet := nSrcLen + + nRet += nRet / 100 * 15 + 12 + + IF ( nSrcLen % 100 ) != 0 + nRet += 15 + ENDIF + + RETURN nRet diff --git a/harbour/contrib/xhb/tests/compress.prg b/harbour/contrib/xhb/tests/compress.prg new file mode 100644 index 0000000000..c75fa9a9ab --- /dev/null +++ b/harbour/contrib/xhb/tests/compress.prg @@ -0,0 +1,71 @@ +/* + * $Id$ + */ + +***************************************************** +* Demo of realtime string compression +* +* Giancarlo Niccolai + +#include "hbcomprs.ch" + +PROCEDURE Main() + LOCAL cText := "A text to be compressed " + LOCAL cComp + LOCAL cDecomp + LOCAL nError, nBufLen + + CLEAR SCREEN + @1,15 SAY "X H A R B O U R - ZLIB based compression test" + + @2,5 SAY "TEST 1: using on-the-fly Buffer creation" + + nBufLen := HB_CompressBuflen( Len( cText ) ) + //cComp and cDecomp will be created with the correct length + cComp := HB_Compress( cText ) + cDecomp := HB_Uncompress( nBuflen, cComp ) + + @3,7 SAY "Uncompressed: (" + hb_ntos( Len( cText ) ) + ")" + cText + "<<" + @4,7 SAY "Compressed (" + hb_ntos( Len( cComp ) ) + ")" + cComp + "<<" + @5,7 SAY "Decompressed: (" + hb_ntos( Len( cDecomp ) ) + ")" + cDecomp + "<<" + + @7,5 SAY "TEST 2: using preallocated buffers" + + cComp := Space( nBufLen ) + //We allocate more space (manual says 0.1% + 12, but you can never know...) + // to allow compression of uncompressable strings to grow a little. + cDecomp := Space( Int(nBufLen * 1.1) ) + + //on exit, nBuflen will contain the length of the compressed buffer + HB_Compress( cText, Len( cText ), @cComp, @nBuflen ) + HB_Uncompress( Len( cText ), cComp, nBuflen , @cDecomp ) + + @8,7 SAY "Uncompressed: (" + hb_ntos( Len( cText) ) + ")" + cText + "<<" + @9,7 SAY "Compressed (" + hb_ntos( nBuflen ) + ")" + cComp + "<<" + //Notice: this time the lenght of the destination buffer is not the lenght of + // the original buffer, but Int(nBufLen * 1.1) + @10,7 SAY "Decompressed: (" + hb_ntos( Len( cDecomp ) ) + ")" + cDecomp + "<<" + + @12,5 SAY "TEST 3: Generating an error" + + nBufLen := HB_CompressBuflen( Len( cText ) ) + cComp := Space( nBufLen ) + cDecomp := Space( Len( cText ) ) + + // we generate an error: 3 is not a valid length for this buffer + nBuflen := 3 + nError := HB_Compress( cText, Len( cText), @cComp, @nBuflen ) + + IF nError != HB_Z_OK + @13,7 SAY "Error generated (" + hb_ntos( Len( cComp ) ) + ")" + ; + HB_CompressErrorDesc( nError ) + ELSE + @13,7 SAY "NO Error generated (" + hb_ntos( Len( cComp ) ) + ")" + ; + HB_CompressErrorDesc( nError ) + ENDIF + + @22,25 SAY "Press a key to terminate" + + INKEY(0) + + RETURN diff --git a/harbour/include/hbzlib.ch b/harbour/include/hbzlib.ch index 6b245102d5..3df91b626d 100644 --- a/harbour/include/hbzlib.ch +++ b/harbour/include/hbzlib.ch @@ -68,4 +68,14 @@ #define HB_ZLIB_STRATEGY_RLE 3 #define HB_ZLIB_STRATEGY_FIXED 4 +#define HB_ZLIB_RES_OK 0 +#define HB_ZLIB_RES_STREAM_END 1 +#define HB_ZLIB_RES_NEED_DICT 2 +#define HB_ZLIB_RES_ERRNO (-1) +#define HB_ZLIB_RES_STREAM_ERROR (-2) +#define HB_ZLIB_RES_DATA_ERROR (-3) +#define HB_ZLIB_RES_MEM_ERROR (-4) +#define HB_ZLIB_RES_BUF_ERROR (-5) +#define HB_ZLIB_RES_VERSION_ERROR (-6) + #endif /* HB_ZLIB_CH_ */ diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 934f8c35e9..338a0f9d7d 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -7536,10 +7536,14 @@ STATIC FUNCTION ArchCompFilter( hbmk, cItem ) LOCAL cFilterHarb LOCAL bFilter LOCAL xResult + LOCAL cKeyword LOCAL cValue LOCAL cChar + LOCAL lSkipQuote LOCAL cExpr := "hbmk_KEYW( hbmk, '%1' )" + LOCAL cExprWithValue := "hbmk_KEYW( hbmk, '%1', '%2' )" + LOCAL tmp IF ( nStart := At( _MACRO_OPEN, cItem ) ) > 0 .AND. ; !( SubStr( cItem, nStart - 1, 1 ) $ _MACRO_PREFIX_ALL ) .AND. ; @@ -7553,23 +7557,54 @@ STATIC FUNCTION ArchCompFilter( hbmk, cItem ) /* Parse filter and convert it to Harbour expression */ cFilterHarb := "" - cValue := "" + cKeyword := "" + cValue := NIL + lSkipQuote := .F. FOR EACH cChar IN cFilterSrc - IF iif( Empty( cValue ),; - HB_ISFIRSTIDCHAR( cChar ),; - HB_ISNEXTIDCHAR( cChar ) ) - cValue += cChar - ELSE - IF ! Empty( cValue ) - cFilterHarb += StrTran( cExpr, "%1", cValue ) + cChar + IF cValue == NIL + IF iif( Empty( cKeyword ),; + HB_ISFIRSTIDCHAR( cChar ),; + HB_ISNEXTIDCHAR( cChar ) ) + cKeyword += cChar + ELSEIF cChar == "=" .AND. SubStr( cFilterSrc, cChar:__enumIndex() + 1, 1 ) == "'" cValue := "" + lSkipQuote := .T. ELSE - cFilterHarb += cChar + IF ! Empty( cKeyword ) + cFilterHarb += StrTran( cExpr, "%1", cKeyword ) + cChar + cKeyword := "" + ELSE + cFilterHarb += cChar + ENDIF + ENDIF + ELSE + IF !( cChar == "'" ) .OR. lSkipQuote + IF lSkipQuote + lSkipQuote := .F. + ELSE + cValue += cChar + ENDIF + ELSE + IF ! Empty( cKeyword ) .AND. ! Empty( cValue ) + tmp := cExprWithValue + tmp := StrTran( tmp, "%1", cKeyword ) + tmp := StrTran( tmp, "%2", cValue ) + cFilterHarb += tmp + cKeyword := "" + cValue := NIL + ENDIF ENDIF ENDIF NEXT - IF ! Empty( cValue ) - cFilterHarb += StrTran( cExpr, "%1", cValue ) + IF ! Empty( cKeyword ) + IF ! Empty( cValue ) + tmp := cExprWithValue + tmp := StrTran( tmp, "%1", cKeyword ) + tmp := StrTran( tmp, "%2", cValue ) + cFilterHarb += tmp + ELSE + cFilterHarb += StrTran( cExpr, "%1", cKeyword ) + ENDIF ENDIF cFilterHarb := StrTran( cFilterHarb, "&&", "&" ) @@ -8824,7 +8859,7 @@ STATIC FUNCTION hbmk_CPU( hbmk ) RETURN "" /* Keep this public, it's used from macro. */ -FUNCTION hbmk_KEYW( hbmk, cKeyword ) +FUNCTION hbmk_KEYW( hbmk, cKeyword, cValue ) LOCAL tmp IF cKeyword == hbmk[ _HBMK_cPLAT ] .OR. ; @@ -8872,8 +8907,14 @@ FUNCTION hbmk_KEYW( hbmk, cKeyword ) "|icc|iccia64|clang|open64|sunpro" + ; "|x86|x86_64|ia64|arm|mips|sh" ) tmp := GetEnv( cKeyword ) - IF ! Empty( tmp ) .AND. !( tmp == "0" ) .AND. !( Lower( tmp ) == "no" ) - RETURN .T. + IF cValue != NIL + IF hb_asciiUpper( tmp ) == hb_asciiUpper( cValue ) + RETURN .T. + ENDIF + ELSE + IF ! Empty( tmp ) .AND. !( tmp == "0" ) .AND. !( Lower( tmp ) == "no" ) + RETURN .T. + ENDIF ENDIF ENDIF