2007-07-02 17:16 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/common.mak
* harbour/source/rtl/Makefile
+ harbour/source/rtl/hbhex.c
* added HB_HEXTONUM() and HB_NUMTOHEX()
* harbour/include/hbcompat.ch
* added trnaslation rules for expresions in parentheses which use
new xHarbour operators: HAS, IN, LIKE, &, |, ^^, >>, <<
Please note that only code which uses above operators in parentheses
will be translated, f.e. this code will not be translated:
if cVal1 IN cVal2
nVal := nVal1 | nVal2 | nVal3 | nVal4
endif
will not be translated but this one will:
if ( cVal1 IN cVal2 )
nVal := ( nVal1 | nVal2 | nVal3 | nVal4 )
endif
* harbour/contrib/tip/thtml.prg
* harbour/contrib/tip/thtml.ch
+ added $\Id
* harbour/source/rtl/hbbit.c
+ added $\Id
! fixed typo in HB_BITSHIFT()
This commit is contained in:
@@ -8,6 +8,32 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2007-07-02 17:16 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/common.mak
|
||||
* harbour/source/rtl/Makefile
|
||||
+ harbour/source/rtl/hbhex.c
|
||||
* added HB_HEXTONUM() and HB_NUMTOHEX()
|
||||
|
||||
* harbour/include/hbcompat.ch
|
||||
* added trnaslation rules for expresions in parentheses which use
|
||||
new xHarbour operators: HAS, IN, LIKE, &, |, ^^, >>, <<
|
||||
Please note that only code which uses above operators in parentheses
|
||||
will be translated, f.e. this code will not be translated:
|
||||
if cVal1 IN cVal2
|
||||
nVal := nVal1 | nVal2 | nVal3 | nVal4
|
||||
endif
|
||||
will not be translated but this one will:
|
||||
if ( cVal1 IN cVal2 )
|
||||
nVal := ( nVal1 | nVal2 | nVal3 | nVal4 )
|
||||
endif
|
||||
|
||||
* harbour/contrib/tip/thtml.prg
|
||||
* harbour/contrib/tip/thtml.ch
|
||||
+ added $\Id
|
||||
* harbour/source/rtl/hbbit.c
|
||||
+ added $\Id
|
||||
! fixed typo in HB_BITSHIFT()
|
||||
|
||||
2007-07-02 14:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbcompat.ch
|
||||
+ added hb_CStr() <=> CStr() translations
|
||||
|
||||
@@ -414,6 +414,7 @@ RTL_LIB_OBJS = \
|
||||
$(OBJ_DIR)\hbadler$(OBJEXT) \
|
||||
$(OBJ_DIR)\hbbit$(OBJEXT) \
|
||||
$(OBJ_DIR)\hbcrc$(OBJEXT) \
|
||||
$(OBJ_DIR)\hbhex$(OBJEXT) \
|
||||
$(OBJ_DIR)\hbmd5$(OBJEXT) \
|
||||
$(OBJ_DIR)\hbffind$(OBJEXT) \
|
||||
$(OBJ_DIR)\hbgtcore$(OBJEXT) \
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Directives for HTML Classes
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* HTML Classes
|
||||
@@ -51,13 +55,6 @@
|
||||
#include "hbclass.ch"
|
||||
#include "thtml.ch"
|
||||
|
||||
#xtranslate ( <exp1> HAS <exp2> ) => HB_REGEXHAS( <exp2>, <exp1> )
|
||||
#xtranslate ( <exp1> LIKE <exp2> ) => HB_REGEXLIKE( <exp2>, <exp1> )
|
||||
#xtranslate ( <exp1> | <exp2> [ | <exp3> ] ) => HB_BITOR( <exp1>, <exp2>[, <exp3>] )
|
||||
#xtranslate ( <exp1> & <exp2> [ & <exp3> ] ) => HB_BITAND( <exp1>, <exp2>[, <exp3>] )
|
||||
#xtranslate HB_BITOR( [<expN>,] <exp2> | <exp3> ) => HB_BITOR( [<expN>,] <exp2>, <exp3> )
|
||||
#xtranslate HB_BITAND( [<expN>,] <exp2> & <exp3> ) => HB_BITAND( [<expN>,] <exp2>, <exp3> )
|
||||
|
||||
// A Html document can have more than 16 nesting levels.
|
||||
// The current implementation of FOR EACH is not suitable for the HTML classes
|
||||
|
||||
|
||||
@@ -123,8 +123,8 @@
|
||||
#xtranslate HALLOCATE([<x,...>]) => HB_HALLOCATE(<x>)
|
||||
#xtranslate HDEFAULT([<x,...>]) => HB_HDEFAULT(<x>)
|
||||
|
||||
#xtranslate NUMTOHEX(<n>) => NTOC(<n>, 16)
|
||||
#xtranslate HEXTONUM(<c>) => CTON(<c>, 16)
|
||||
#xtranslate HEXTONUM([<c,...>]) => HB_HEXTONUM(<c>)
|
||||
#xtranslate NUMTOHEX([<n,...>]) => HB_NUMTOHEX(<n>)
|
||||
|
||||
#xcommand TEXT INTO <v> => #pragma __text|<v>+=%s+HB_OSNEWLINE();<v>:=""
|
||||
|
||||
@@ -140,6 +140,29 @@
|
||||
#xtranslate \<|[<x,...>]| => {|<x>|
|
||||
#xcommand > [<*x*>] => } <x>
|
||||
|
||||
/* xHarbour operators: IN, HAS, LIKE, >>, <<, |, &, ^^ */
|
||||
#translate ( <exp1> IN <exp2> => ( <exp1> $ <exp2>
|
||||
#translate ( <exp1> HAS <exp2> => ( HB_REGEXHAS( <exp2>, <exp1> )
|
||||
#translate ( <exp1> LIKE <exp2> => ( HB_REGEXLIKE( <exp2>, <exp1> )
|
||||
#translate ( <exp1> \<\< <exp2> => ( HB_BITSHIFT( <exp1>, <exp2> )
|
||||
#translate ( <exp1> >> <exp2> => ( HB_BITSHIFT( <exp1>, -<exp2> )
|
||||
#translate ( <exp1> | <exp2> => ( HB_BITOR( <exp1>, <exp2> )
|
||||
#translate ( <exp1> & <exp2> => ( HB_BITAND( <exp1>, <exp2> )
|
||||
#translate ( <exp1> ^^ <exp2> => ( HB_BITXOR( <exp1>, <exp2> )
|
||||
|
||||
#translate , <exp1> IN <exp2> => , <exp1> $ <exp2>
|
||||
#translate , <exp1> HAS <exp2> => , HB_REGEXHAS( <exp2>, <exp1> )
|
||||
#translate , <exp1> LIKE <exp2> => , HB_REGEXLIKE( <exp2>, <exp1> )
|
||||
#translate , <exp1> \<\< <exp2> => , HB_BITSHIFT( <exp1>, <exp2> )
|
||||
#translate , <exp1> >> <exp2> => , HB_BITSHIFT( <exp1>, -<exp2> )
|
||||
#translate , <exp1> | <exp2> => , HB_BITOR( <exp1>, <exp2> )
|
||||
#translate , <exp1> & <exp2> => , HB_BITAND( <exp1>, <exp2> )
|
||||
#translate , <exp1> ^^ <exp2> => , HB_BITXOR( <exp1>, <exp2> )
|
||||
|
||||
#xtranslate HB_BITOR( [<expN>,] <exp2> | <exp3> ) => HB_BITOR( [<expN>,] <exp2>, <exp3> )
|
||||
#xtranslate HB_BITAND( [<expN>,] <exp2> & <exp3> ) => HB_BITAND( [<expN>,] <exp2>, <exp3> )
|
||||
#xtranslate HB_BITXOR( [<expN>,] <exp2> ^^ <exp3> ) => HB_BITXOR( [<expN>,] <exp2>, <exp3> )
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __HARBOUR__ */
|
||||
|
||||
@@ -52,6 +52,7 @@ C_SOURCES=\
|
||||
hbadler.c \
|
||||
hbbit.c \
|
||||
hbcrc.c \
|
||||
hbhex.c \
|
||||
hbmd5.c \
|
||||
hbffind.c \
|
||||
hbgtcore.c \
|
||||
|
||||
@@ -153,7 +153,7 @@ HB_FUNC( HB_BITSHIFT )
|
||||
if( hb_numParam( 1, &lValue ) && hb_numParam( 2, &lBits ) )
|
||||
{
|
||||
if( lBits < 0 )
|
||||
hb_retnint( lValue >> lBits );
|
||||
hb_retnint( lValue >> -lBits );
|
||||
else
|
||||
hb_retnint( lValue << lBits );
|
||||
}
|
||||
|
||||
128
harbour/source/rtl/hbhex.c
Normal file
128
harbour/source/rtl/hbhex.c
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* HB_NUMTOHEX()
|
||||
* HB_HEXTONUM()
|
||||
*
|
||||
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* 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 "hbapi.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
HB_FUNC( HB_HEXTONUM )
|
||||
{
|
||||
char * szHex = hb_parc( 1 );
|
||||
|
||||
if( szHex )
|
||||
{
|
||||
HB_ULONG ulNum = 0;
|
||||
|
||||
while( *szHex == ' ' ) szHex++;
|
||||
while( *szHex )
|
||||
{
|
||||
int iDigit;
|
||||
char c = *szHex++;
|
||||
if ( c >= '0' && c <= '9' )
|
||||
iDigit = c - '0';
|
||||
else if ( c >= 'A' && c <= 'F' )
|
||||
iDigit = c - 'A' + 10;
|
||||
else if ( c >= 'a' && c <= 'f' )
|
||||
iDigit = c - 'a' + 10;
|
||||
else
|
||||
{
|
||||
ulNum = 0;
|
||||
break;
|
||||
}
|
||||
ulNum = ( ulNum << 4 ) + iDigit;
|
||||
}
|
||||
hb_retnint( ulNum );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, &hb_errFuncName, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_NUMTOHEX )
|
||||
{
|
||||
HB_ULONG ulNum;
|
||||
int iLen;
|
||||
BOOL fDefaultLen;
|
||||
char ret[ 33 ];
|
||||
|
||||
if( ISNUM( 2 ) )
|
||||
{
|
||||
iLen = hb_parni( 2 );
|
||||
iLen = ( iLen < 1 ) ? 1 : ( ( iLen > 32 ) ? 32 : iLen );
|
||||
fDefaultLen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
iLen = 32;
|
||||
fDefaultLen = 1;
|
||||
}
|
||||
|
||||
if( ISNUM( 1 ) )
|
||||
ulNum = hb_parnint( 1 );
|
||||
else if( ISPOINTER( 1 ) )
|
||||
ulNum = (HB_PTRDIFF) hb_parptr( 1 );
|
||||
else
|
||||
{
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, &hb_errFuncName, HB_ERR_ARGS_BASEPARAMS );
|
||||
return;
|
||||
}
|
||||
|
||||
ret[ iLen ] = '\0';
|
||||
do
|
||||
{
|
||||
int iDigit = ( int ) ( ulNum & 0x0F );
|
||||
ret[ --iLen ] = iDigit + ( iDigit < 10 ? '0' : 'A' - 10 );
|
||||
ulNum >>= 4;
|
||||
}
|
||||
while( fDefaultLen ? ulNum : iLen );
|
||||
|
||||
hb_retc( &ret[ iLen ] );
|
||||
}
|
||||
Reference in New Issue
Block a user