2002-10-21 12:00 UTC-0500 Paul Tucker <ptucker@sympatico.ca>

This commit is contained in:
Paul Tucker
2002-10-21 16:10:50 +00:00
parent 05c8446d48
commit 08763f7da7
5 changed files with 255 additions and 19 deletions

View File

@@ -8,6 +8,13 @@
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2002-10-21 12:00 UTC-0500 Paul Tucker <ptucker@sympatico.ca>
+ tests/vidtest.prg by Brian Dukes <bdukes@yellowthingy.co.uk>
* source/rdd/dbcmd.c
* source/rdd/workarea.c
* source/rdd/dbf1.c
! modified string copy operations for efficiency where appropriate.
2002-10-21 10:20 UTC+0300 Alexander Kresin <alex@belacy.belgorod.su>
* contrib/rdd_ads/adsfunc.c
! Few fixes - checking for hb_parc() return value

View File

@@ -357,7 +357,9 @@ static int hb_rddRegister( char * szDriver, USHORT uiType )
memset( pRddNewNode, 0, sizeof( RDDNODE ) );
/* Fill the new RDD node */
strncpy( pRddNewNode->szName, szDriver, HARBOUR_MAX_RDD_DRIVERNAME_LENGTH );
strncat( pRddNewNode->szName, szDriver, HARBOUR_MAX_RDD_DRIVERNAME_LENGTH );
pRddNewNode->uiType = uiType;
/* Call <szDriver>_GETFUNCTABLE() */
@@ -1285,12 +1287,14 @@ HB_FUNC( DBCREATE )
szDriver = s_szDefDriver;
pFileName = hb_fsFNameSplit( szFileName );
if( ISCHAR(5) )
strncpy( szAlias, hb_parc( 5 ), HARBOUR_MAX_RDD_ALIAS_LENGTH );
uiLen = ( USHORT ) hb_parclen( 5 );
szAlias[0] = '\0';
if( ISCHAR(5) )
strncat( szAlias, hb_parc( 5 ), HARBOUR_MAX_RDD_ALIAS_LENGTH );
uiLen = strlen( szAlias );
if( uiLen == 0 )
strncpy( szAlias, pFileName->szName, HARBOUR_MAX_RDD_ALIAS_LENGTH );
strncat( szAlias, pFileName->szName, HARBOUR_MAX_RDD_ALIAS_LENGTH );
else if( uiLen == 1 )
{
/* Alias with a single letter. Only are valid 'L' and > 'M' */
@@ -1305,6 +1309,7 @@ HB_FUNC( DBCREATE )
/* Create a new WorkArea node */
if( !hb_rddInsertAreaNode( szDriver ) )
{
hb_xfree( pFileName );
hb_errRT_DBCMD( EG_ARG, EDBCMD_BADPARAMETER, NULL, "DBCREATE" );
return;
}
@@ -1313,7 +1318,7 @@ HB_FUNC( DBCREATE )
szFileName[0] = '\0';
if( ISCHAR(1) )
strncpy( szFileName, hb_parc( 1 ), _POSIX_PATH_MAX );
strncat( szFileName, hb_parc( 1 ), _POSIX_PATH_MAX );
if( !pFileName->szExtension )
{
@@ -1936,6 +1941,8 @@ HB_FUNC( DBUSEAREA )
char szDriverBuffer[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH + 1 ];
char szAlias[ HARBOUR_MAX_RDD_ALIAS_LENGTH + 1 ];
szDriverBuffer[0] = '\0';
s_bNetError = FALSE;
/* New area? */
@@ -1965,9 +1972,9 @@ HB_FUNC( DBUSEAREA )
szAlias[0] = '\0';
if( ISCHAR(4) )
strncpy( szAlias, hb_parc( 4 ), HARBOUR_MAX_RDD_ALIAS_LENGTH );
strncat( szAlias, hb_parc( 4 ), HARBOUR_MAX_RDD_ALIAS_LENGTH );
else
strncpy( szAlias, pFileName->szName, HARBOUR_MAX_RDD_ALIAS_LENGTH );
strncat( szAlias, pFileName->szName, HARBOUR_MAX_RDD_ALIAS_LENGTH );
uiLen = strlen( szAlias );
if( szAlias[ 0 ] >= '0' && szAlias[ 0 ] <= '9' )
@@ -1976,6 +1983,7 @@ HB_FUNC( DBUSEAREA )
hb_errRT_DBCMD( EG_DUPALIAS, EDBCMD_DUPALIAS, NULL, "DBUSEAREA" );
return;
}
if( uiLen == 1 )
{
/* Alias with a single letter. Only are valid 'L' and > 'M' */
@@ -1990,12 +1998,15 @@ HB_FUNC( DBUSEAREA )
/* Create a new WorkArea node */
if( !hb_rddInsertAreaNode( szDriver ) )
{
hb_xfree( pFileName );
hb_errRT_DBCMD( EG_ARG, EDBCMD_BADPARAMETER, NULL, "DBUSEAREA" );
return;
}
szFileName = ( char * ) hb_xgrab( _POSIX_PATH_MAX + 1 );
strncpy( szFileName, hb_parc( 3 ), _POSIX_PATH_MAX );
szFileName[0] = '\0';
strncat( szFileName, hb_parc( 3 ), _POSIX_PATH_MAX );
if( !pFileName->szExtension )
{
pFileExt = hb_itemPutC( NULL, "" );
@@ -2886,18 +2897,15 @@ HB_FUNC( __RDDSETDEFAULT )
uiLen = ( USHORT ) hb_parclen( 1 );
if( uiLen > 0 )
{
if( uiLen > HARBOUR_MAX_RDD_DRIVERNAME_LENGTH )
uiLen = HARBOUR_MAX_RDD_DRIVERNAME_LENGTH;
s_szDefDriver = ( char * ) hb_xrealloc( s_szDefDriver, uiLen + 1 );
hb_strncpyUpper( s_szDefDriver, hb_parc( 1 ), uiLen );
hb_strncpyUpper( s_szDefDriver, hb_parc( 1 ), uiLen+1 );
}
}
HB_FUNC( RDDSETDEFAULT )
{
USHORT uiLen;
char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH ];
char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH +1 ];
hb_rddCheck();
hb_retc( s_szDefDriver );
@@ -2921,7 +2929,7 @@ HB_FUNC( RDDSETDEFAULT )
HB_FUNC( DBSETDRIVER )
{
USHORT uiLen;
char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH ];
char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH +1 ];
hb_rddCheck();
hb_retc( s_szDefDriver );
@@ -3363,6 +3371,8 @@ HB_FUNC( DBFILEGET )
char szFileName[ _POSIX_PATH_MAX + 1 ];
USHORT uiFields, uiIndex;
szFileName[0] = '\0';
if( s_pCurrArea )
{
uiIndex = hb_parni( 1 );
@@ -3372,7 +3382,7 @@ HB_FUNC( DBFILEGET )
SELF_FIELDCOUNT( ( AREAP ) s_pCurrArea->pArea, &uiFields ) == SUCCESS &&
uiIndex > 0 && uiIndex <= uiFields )
{
strncpy( szFileName, hb_itemGetCPtr( pFileName ), _POSIX_PATH_MAX );
strncat( szFileName, hb_itemGetCPtr( pFileName ), _POSIX_PATH_MAX );
hb_retl( SELF_GETVALUEFILE( ( AREAP ) s_pCurrArea->pArea, uiIndex, szFileName,
hb_itemGetNI( pMode ) ) );
return;
@@ -3391,6 +3401,8 @@ HB_FUNC( DBFILEPUT )
char szFileName[ _POSIX_PATH_MAX + 1 ];
USHORT uiFields, uiIndex;
szFileName[0] = '\0';
if( s_pCurrArea )
{
uiIndex = hb_parni( 1 );
@@ -3399,7 +3411,7 @@ HB_FUNC( DBFILEPUT )
SELF_FIELDCOUNT( ( AREAP ) s_pCurrArea->pArea, &uiFields ) == SUCCESS &&
uiIndex > 0 && uiIndex <= uiFields )
{
strncpy( szFileName, hb_itemGetCPtr( pFileName ), _POSIX_PATH_MAX );
strncat( szFileName, hb_itemGetCPtr( pFileName ), _POSIX_PATH_MAX );
hb_retl( SELF_PUTVALUEFILE( ( AREAP ) s_pCurrArea->pArea, uiIndex, szFileName ) );
return;
}

View File

@@ -1956,7 +1956,7 @@ ERRCODE hb_dbfSysName( DBFAREAP pArea, BYTE * pBuffer )
HB_TRACE(HB_TR_DEBUG, ("hb_dbfSysName(%p, %p)", pArea, pBuffer));
HB_SYMBOL_UNUSED( pArea );
strncpy( ( char * ) pBuffer, "DBF", HARBOUR_MAX_RDD_DRIVERNAME_LENGTH );
strncpy( ( char * ) pBuffer, "DBF", 4 );
return SUCCESS;
}

View File

@@ -446,7 +446,9 @@ ERRCODE hb_waAlias( AREAP pArea, BYTE * szAlias )
{
HB_TRACE(HB_TR_DEBUG, ("hb_waAlias(%p, %p)", pArea, szAlias));
strncpy( ( char * ) szAlias, ( ( PHB_DYNS ) pArea->atomAlias )->pSymbol->szName,
szAlias[0] = '\0';
strncat( ( char * ) szAlias, ( ( PHB_DYNS ) pArea->atomAlias )->pSymbol->szName,
HARBOUR_MAX_RDD_ALIAS_LENGTH );
return SUCCESS;
}

215
harbour/tests/vidtest.prg Normal file
View File

@@ -0,0 +1,215 @@
/*
* $Id$
*/
/*
* Harbour project video test code
*
* Program originally by Brian Dukes <bdukes@yellowthingy.co.uk>
*
* Redirect the output of this program to a file.
*
* ie: VidTest >results
*
*/
#include "box.ch"
#ifndef __CLIP__
#ifndef FlagShip
#xtranslate secondscpu([<x>]) => seconds([<x>])
#define EOL chr(13) + chr(10)
#endif
#endif
#ifndef EOL
#define EOL chr(10)
#endif
#command ? => outstd(EOL);outerr(EOL)
#command ? <xx,...> => outstd(<xx>, EOL);outerr(<xx>, EOL)
#ifdef FlagShip
static nDispCount := 0
#xtranslate dispbegin() => iif((++nDispCount)==1, dispbegin(NIL),)
#xtranslate dispend() => iif(nDispCount>0 .and. (--nDispCount)==0, dispend(NIL),)
#endif
function main()
local aResult := {}
Initialise() // Initialise Screen Display
// Perform Tests
aadd(aResult, StaticText() )
aadd(aResult, WindowBounce() )
aadd(aResult, ColourBoxes() )
// Display Results
Summary(aResult)
return NIL
// initialise the screen
static function Initialise()
//SetMode(25,80)
set colour to "W+/BG"
dispbox(0,0,MaxRow(), MaxCol(), replicate(chr(176),9), "BG/B")
return NIL
// repeatedly display a string in the same position
// this test determines how well the Screen i/o subsystem is
// caching screen writes.
static function StaticText()
local cResult
local r := MaxRow() / 2
local str := Version()
local c
local i := 0
local nEnd := 0
local nStart := secondscpu()
str := "Hello World - From " + Left(str,At(" ",str)-1)
c := (MaxCol()-len(str)) / 2
for i := 1 to 5000
@ r, c say str
next i
nEnd := secondscpu()
cResult := "StaticText: Iterations=5000, Time="+alltrim(str(nEnd-nStart))+ ;
"secs, Average FPS = "+alltrim(str(round(5000 / (nEnd-nStart),0)))+" FPS"
return cResult
// Bounce a window around the screen a few thousand times
// timing the duration, and determining the average FPS
static function WindowBounce()
local cResult := ""
local nBoxes := Min(MaxRow(), MaxCol()-7)-6 /* keep the box in bounds */
local x := array(NBOXES)
local y := array(NBOXES)
local dx := array(NBOXES)
local dy := array(NBOXES)
local clr := array(NBOXES)
local scr := array(NBOXES)
local nFrames := 0
local nStart := 0
local nEnd := 0
local i := 0
local aCol := {"N", "B", "G", "BG", "R", "RB", "GR", "W", ;
"N*","B*","G*","BG*","R*","RB*","GR*","W*" }
// initialise boxes
for i := 1 to nBoxes
x[i] := i
y[i] := i-1
dx[i] := -1
dy[i] := 1
clr[i] := "W+/"+aCol[(i-1)%16+1]
next i
nStart := secondscpu()
dispbegin()
do while nFrames < 5000
for i := 1 to nBoxes
scr[i] := SaveScreen(x[i], y[i], x[i]+6, y[i]+12)
@ x[i], y[i], x[i]+6, y[i]+12 box B_SINGLE+" " color clr[i]
next i
dispend()
dispbegin()
for i := nBoxes to 1 step -1
// remove boxes from screen
RestScreen(x[i], y[i], x[i]+6, y[i]+12, scr[i])
// move
x[i] += dx[i]
y[i] += dy[i]
if x[i] <= 0 .or. x[i]+6 >= MaxRow()
dx[i] := -dx[i]
endif
if y[i] <= 0 .or. y[i]+12 >= MaxCol()
dy[i] := -dy[i]
endif
next i
++nFrames
enddo
dispend()
nEnd := secondscpu()
cResult := "WindowBounce:Iterations="+alltrim(str(nFrames))+", Time="+alltrim(str(nEnd-nStart))+ ;
"secs, Average FPS = "+alltrim(str(round(nFrames / (nEnd-nStart),0)))+" FPS"
return cResult
// Display colour boxes, repeatedly, this will determine
// how efficiently the screen i/o subsystem is caching the
// dispbegin()'s and dispend()'s
static function ColourBoxes()
local cResult := ""
local nFrames := 0
local nStart := 0
local nEnd := 0
local i := 0
local nDir := 1
local nDepth := 0
local aCol := {"N", "B", "G", "BG", "R", "RB", "GR", "W", ;
"N*","B*","G*","BG*","R*","RB*","GR*","W*" }
nStart := secondscpu()
// display boxes to screen
do while nFrames < 5000
if nDir = 1
dispbegin()
else
dispend()
endif
nDepth += nDir
if nDepth > 4 .or. nDepth < 1
nDir := -nDir
endif
i := nFrames %16 +1
dispbox(5,10, MaxRow()-5, MaxCol()-10, ;
replicate(chr(i+64),9),;
"W+/"+aCol[i] )
++nFrames
enddo
// remove any nested dispbegins()
do while nDepth > 0
dispend()
nDepth--
enddo
nEnd := secondscpu()
cResult := "ColourBoxes: Iterations="+alltrim(str(nFrames))+", Time="+alltrim(str(nEnd-nStart))+ ;
"secs, Average FPS = "+alltrim(str(round(nFrames / (nEnd-nStart),0)))+" FPS"
return cResult
// display results
static function Summary(aResult)
local i := 0
clear screen
? "Resolution: " + Ltrim(str( MaxRow()+1 )) + " x " + Ltrim(str( MaxCol()+1 )) + " " + Version()
for i := 1 to len(aResult)
? aResult[i]
next i
?
? "press any key to continue"
inkey(0)
return aResult