diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 49ba7086c2..f02c02d092 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,31 @@ The license applies to all entries newer than 2009-04-28. */ +2010-11-20 17:27 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/sha1.c + * Settling back to original version of some lines. + + - contrib/hbgd/tests/tpoly.hbp + - contrib/hbgd/tests/tpolyc.c + - Using hbct functions with same name, so this is not needed. + + * contrib/hbgd/tests/tpoly.prg + * Applied patch from Tamas. + * Since final patch didn't apply I went on to rename static + vars to have s_ prefix. + + * contrib/hbgd/tests/gdtest.prg + * contrib/hbgd/tests/barms.prg + * contrib/hbgd/tests/bartest.prg + * contrib/hbgd/tests/gdtestcl.prg + * contrib/hbgd/tests/tostring.prg + * contrib/hbgd/tests/animgif.prg + * contrib/hbgd/tests/testdpi.prg + * contrib/hbgd/tests/test.prg + * contrib/hbgd/tests/counter.prg + * contrib/hbgd/tests/antialia.prg + * Using hb_ps(). Patch from Tamas. + 2010-11-20 13:22 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/sha1.c * cleaned casting to not drop canst attribute diff --git a/harbour/contrib/hbgd/tests/animgif.prg b/harbour/contrib/hbgd/tests/animgif.prg index 406235d777..256158c425 100644 --- a/harbour/contrib/hbgd/tests/animgif.prg +++ b/harbour/contrib/hbgd/tests/animgif.prg @@ -13,8 +13,8 @@ #include "gd.ch" #include "common.ch" -#define IMAGES_IN "imgs_in/" -#define IMAGES_OUT "imgs_out/" +#define IMAGES_IN "imgs_in" + hb_ps() +#define IMAGES_OUT "imgs_out" + hb_ps() PROCEDURE Main() diff --git a/harbour/contrib/hbgd/tests/antialia.prg b/harbour/contrib/hbgd/tests/antialia.prg index 7cb0799f25..79bdbc626b 100644 --- a/harbour/contrib/hbgd/tests/antialia.prg +++ b/harbour/contrib/hbgd/tests/antialia.prg @@ -11,8 +11,8 @@ #include "gd.ch" #include "common.ch" -#define IMAGES_IN "imgs_in/" -#define IMAGES_OUT "imgs_out/" +#define IMAGES_IN "imgs_in" + hb_ps() +#define IMAGES_OUT "imgs_out" + hb_ps() PROCEDURE Main() diff --git a/harbour/contrib/hbgd/tests/barms.prg b/harbour/contrib/hbgd/tests/barms.prg index 2aecbc0763..142b641e5e 100644 --- a/harbour/contrib/hbgd/tests/barms.prg +++ b/harbour/contrib/hbgd/tests/barms.prg @@ -2,7 +2,7 @@ * $Id$ */ -#define IMAGES_OUT "imgs_out/" +#define IMAGES_OUT "imgs_out" + hb_ps() Function Main() diff --git a/harbour/contrib/hbgd/tests/bartest.prg b/harbour/contrib/hbgd/tests/bartest.prg index 11a4dd542c..b94325191b 100644 --- a/harbour/contrib/hbgd/tests/bartest.prg +++ b/harbour/contrib/hbgd/tests/bartest.prg @@ -2,7 +2,7 @@ * $Id$ */ -#define IMAGES_OUT "imgs_out/" +#define IMAGES_OUT "imgs_out" + hb_ps() Function Main() diff --git a/harbour/contrib/hbgd/tests/counter.prg b/harbour/contrib/hbgd/tests/counter.prg index 3b1e747fa9..2079b3d627 100644 --- a/harbour/contrib/hbgd/tests/counter.prg +++ b/harbour/contrib/hbgd/tests/counter.prg @@ -17,8 +17,8 @@ /* Some digits images from: http://www.digitmania.holowww.com/all.html */ -#define IMAGES_IN "digits/" -#define IMAGES_OUT "imgs_out/" +#define IMAGES_IN "digits" + hb_ps() +#define IMAGES_OUT "imgs_out" + hb_ps() #define DISPLAY_NUM 10 diff --git a/harbour/contrib/hbgd/tests/gdtest.prg b/harbour/contrib/hbgd/tests/gdtest.prg index fcc2104a0a..263bcb4fb4 100644 --- a/harbour/contrib/hbgd/tests/gdtest.prg +++ b/harbour/contrib/hbgd/tests/gdtest.prg @@ -11,8 +11,8 @@ #include "gd.ch" #include "common.ch" -#define IMAGES_IN "imgs_in/" -#define IMAGES_OUT "imgs_out/" +#define IMAGES_IN "imgs_in" + hb_ps() +#define IMAGES_OUT "imgs_out" + hb_ps() PROCEDURE Main() diff --git a/harbour/contrib/hbgd/tests/gdtestcl.prg b/harbour/contrib/hbgd/tests/gdtestcl.prg index 3be9d085a7..68e385fc4a 100644 --- a/harbour/contrib/hbgd/tests/gdtestcl.prg +++ b/harbour/contrib/hbgd/tests/gdtestcl.prg @@ -11,8 +11,8 @@ #include "gd.ch" #include "common.ch" -#define IMAGES_IN "imgs_in/" -#define IMAGES_OUT "imgs_out/" +#define IMAGES_IN "imgs_in" + hb_ps() +#define IMAGES_OUT "imgs_out" + hb_ps() PROCEDURE Main() diff --git a/harbour/contrib/hbgd/tests/test.prg b/harbour/contrib/hbgd/tests/test.prg index 8b8c3b1459..b580e47e14 100644 --- a/harbour/contrib/hbgd/tests/test.prg +++ b/harbour/contrib/hbgd/tests/test.prg @@ -2,7 +2,7 @@ * $Id$ */ -#define IMAGES_OUT "imgs_out/" +#define IMAGES_OUT "imgs_out" + hb_ps() PROCEDURE Main() diff --git a/harbour/contrib/hbgd/tests/testdpi.prg b/harbour/contrib/hbgd/tests/testdpi.prg index aaea99faaf..2915673a44 100644 --- a/harbour/contrib/hbgd/tests/testdpi.prg +++ b/harbour/contrib/hbgd/tests/testdpi.prg @@ -12,8 +12,8 @@ #include "gd.ch" #include "common.ch" -#define IMAGES_IN "imgs_in/" -#define IMAGES_OUT "imgs_out/" +#define IMAGES_IN "imgs_in" + hb_ps() +#define IMAGES_OUT "imgs_out" + hb_ps() PROCEDURE Main() diff --git a/harbour/contrib/hbgd/tests/tostring.prg b/harbour/contrib/hbgd/tests/tostring.prg index fad28c651e..a769667867 100644 --- a/harbour/contrib/hbgd/tests/tostring.prg +++ b/harbour/contrib/hbgd/tests/tostring.prg @@ -12,8 +12,8 @@ #include "gd.ch" #include "common.ch" -#define IMAGES_IN "imgs_in/" -#define IMAGES_OUT "imgs_out/" +#define IMAGES_IN "imgs_in" + hb_ps() +#define IMAGES_OUT "imgs_out" + hb_ps() PROCEDURE Main() diff --git a/harbour/contrib/hbgd/tests/tpoly.hbp b/harbour/contrib/hbgd/tests/tpoly.hbp deleted file mode 100644 index 7c4c53d602..0000000000 --- a/harbour/contrib/hbgd/tests/tpoly.hbp +++ /dev/null @@ -1,8 +0,0 @@ -# -# $Id$ -# - -hbmk.hbm - -tpoly.prg -tpolyc.c diff --git a/harbour/contrib/hbgd/tests/tpoly.prg b/harbour/contrib/hbgd/tests/tpoly.prg index 487f202e2b..16075a0c8d 100644 --- a/harbour/contrib/hbgd/tests/tpoly.prg +++ b/harbour/contrib/hbgd/tests/tpoly.prg @@ -1,76 +1,98 @@ -/* +/* * $Id$ */ /* - * Not Quite a Koch Flake -- but good for testing gdImage*Polygon() + * Koch Flake -- for testing gdImage*Polygon() */ #include "gd.ch" +#include "simpleio.ch" -REQUEST HB_GT_CGI_DEFAULT +#command TurnRight( ) => nAngle += M_PI / 3 * +#command TurnLeft( ) => nAngle -= M_PI / 3 * #define M_PI 3.14159265358979323846 -#define IMAGES_OUT "imgs_out/" +#define IMAGES_OUT "imgs_out" + hb_ps() -STATIC aCoords -STATIC nSideLen -STATIC nAngle, nCoordX, nCoordY +STATIC s_aCoords +STATIC s_nSides, s_nSideLen +STATIC s_nAngle, s_nCoordX, s_nCoordY PROCEDURE Main() LOCAL nDepth, nSide LOCAL gdImage, gdColor - nSideLen := 100 - nDepth := 4 + s_nSides := 3 + s_nSideLen := 1500 + nDepth := 7 - nCoordX := 50 - nCoordY := 50 - aCoords := { { nCoordX, nCoordY } } - nAngle := 0 + s_nCoordX := 200 + s_nCoordY := 600 + s_aCoords := { { s_nCoordX, s_nCoordY } } + s_nAngle := 0 - FOR nSide := 1 TO 3 - NQKochFlake( nDepth, nSideLen ) - nAngle += M_PI * 2 / 3 + /* Regular flake */ + FOR nSide := 1 TO s_nSides + KochFlake( nDepth, s_nSideLen, .T. ) + s_nAngle += M_PI * 2 / s_nSides NEXT - NQKochFlake( nDepth, nSideLen ) + /* Flake inside out */ + FOR nSide := 1 TO s_nSides + KochFlake( nDepth, s_nSideLen, .F. ) + s_nAngle += M_PI * 2 / s_nSides + NEXT - OutStd( hb_strFormat( "Drawing %d coordinate pairs%s", Len( aCoords ), hb_eol() ) ) + OutStd( hb_strFormat( "Drawing %d vertices%s", Len( s_aCoords ), hb_eol() ) ) - gdImage := gdImageCreate( 8200, 7115 ) + gdImage := gdImageCreate( 1900, 2100 ) gdImageColorAllocate( gdImage, 0, 0, 0 ) - gdColor := gdImageColorAllocate( gdImage, 255, 255, 255 ) - gdImagePolygon( gdImage, aCoords, gdColor ) + gdColor := gdImageColorAllocate( gdImage, 255, 255, 0 ) + gdImagePolygon( gdImage, s_aCoords, gdColor ) gdImagePng( gdImage, IMAGES_OUT + "flake.png" ) gdImageDestroy( gdImage ) - gdImage := gdImageCreate( 8200, 7115 ) + gdImage := gdImageCreate( 1900, 2100 ) gdImageColorAllocate( gdImage, 0, 0, 0 ) - gdColor := gdImageColorAllocate( gdImage, 255, 255, 255 ) - gdImageOpenPolygon( gdImage, aCoords, gdColor ) + gdColor := gdImageColorAllocate( gdImage, 255, 255, 0 ) + gdImageOpenPolygon( gdImage, s_aCoords, gdColor ) gdImagePng( gdImage, IMAGES_OUT + "flakeo.png" ) gdImageDestroy( gdImage ) RETURN -PROCEDURE NQKochFlake( nDepth, nSideLen ) +PROCEDURE KochFlake( nDepth, s_nSideLen, lLeftFirst ) IF nDepth == 0 - AAdd( aCoords, {; - nCoordX += Cos( nAngle ) * nSideLen,; - nCoordY += Sin( nAngle ) * nSideLen; + AAdd( s_aCoords, {; + s_nCoordX += Cos( s_nAngle ) * s_nSideLen,; + s_nCoordY += Sin( s_nAngle ) * s_nSideLen; }) ELSE - NQKochFlake( nDepth - 1, nSideLen ) - nAngle += M_PI / 3 - NQKochFlake( nDepth - 1, nSideLen ) - nAngle -= M_PI * 2 / 3 - NQKochFlake( nDepth - 1, nSideLen ) - nAngle += M_PI / 3 - NQKochFlake( nDepth - 1, nSideLen ) + KochFlake( nDepth - 1, s_nSideLen / 3, lLeftFirst ) + + IF lLeftFirst + TurnLeft( 1 ) + ELSE + TurnRight( 1 ) + ENDIF + KochFlake( nDepth - 1, s_nSideLen / 3, lLeftFirst ) + + IF lLeftFirst + TurnRight( 2 ) + ELSE + TurnLeft( 2 ) + ENDIF + KochFlake( nDepth - 1, s_nSideLen / 3, lLeftFirst ) + + IF lLeftFirst + TurnLeft( 1 ) + ELSE + TurnRight( 1 ) + ENDIF + KochFlake( nDepth - 1, s_nSideLen / 3, lLeftFirst ) ENDIF RETURN - diff --git a/harbour/contrib/hbgd/tests/tpolyc.c b/harbour/contrib/hbgd/tests/tpolyc.c deleted file mode 100644 index 5ca2c4dfcb..0000000000 --- a/harbour/contrib/hbgd/tests/tpolyc.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * $Id$ - */ - -#include - -#include "hbapi.h" -#include "hbapierr.h" - -#define WRAP( hbfunc, mfunc ) \ - HB_FUNC( hbfunc ) \ - { \ - if( HB_ISNUM( 1 ) ) \ - { \ - double dArg, dResult; \ - dArg = hb_parnd( 1 ); \ - dResult = mfunc( dArg ); \ - hb_retnd( dResult ); \ - } \ - else \ - hb_errRT_BASE_SubstR( EG_ARG, 1097, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); \ - } - -WRAP( SIN, sin ) -WRAP( COS, cos ) diff --git a/harbour/src/rtl/sha1.c b/harbour/src/rtl/sha1.c index 5ef9df1fb5..6a5e71fd48 100644 --- a/harbour/src/rtl/sha1.c +++ b/harbour/src/rtl/sha1.c @@ -148,16 +148,14 @@ void hb_SHA1_Update(SHA_CTX *context, const void *datav, unsigned int len) { void hb_SHA1_Final(sha1_byte digest[SHA1_DIGEST_LENGTH], SHA_CTX *context) { sha1_quadbyte i; sha1_byte finalcount[8]; - sha1_byte str1[ 1 ] = { '\x80' }; - sha1_byte str2[ 1 ] = { '\0' }; for (i = 0; i < 8; i++) { finalcount[i] = (sha1_byte)((context->count[(i >= 4 ? 0 : 1)] >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ } - hb_SHA1_Update(context, str1, 1); + hb_SHA1_Update(context, (const sha1_byte *)"\x80", 1); while ((context->count[0] & 504) != 448) { - hb_SHA1_Update(context, str2, 1); + hb_SHA1_Update(context, (const sha1_byte *)"\0", 1); } /* Should cause a SHA1_Transform() */ hb_SHA1_Update(context, finalcount, 8);