Skip to content

Commit

Permalink
2024-05-31 11:49 UTC+0200 Aleksander Czajczynski (hb fki.pl)
Browse files Browse the repository at this point in the history
  * contrib/rddmisc/arrayrdd.prg
    ! group of fixes contributed in #355 by @VarenL:
      IndexOrd() didn't work, DbZap() didn't update indexes, problem
      with larger number of indexes, erroneous AR_GOBOTTOM function.

  + doc/en/rdddb.txt
    + readded a 2017 copy

  * contrib/hbamf/amfstdio.c
    * flow-control is now optional, but still enabled by default

    ! fix missing free when exiting the loop

  * contrib/hbpgsql/rddcopy.c
    ! fix c&p bug/typo in HB_PQCOPYFROMWA, corrected handling field list
      passed in <aFiledNames> parameter

      <lResult> := HB_PQCOPYFROMWA( <pConn>, <cTargetTable>, [<bWhileBlock>],
                                   [<bForBlock>], [<aFieldNames>], [<nCount>],
                                   [<lTrimStrings>], [<nPreBuffer>] )
  • Loading branch information
alcz committed May 31, 2024
1 parent a10feba commit 217d507
Show file tree
Hide file tree
Showing 5 changed files with 1,333 additions and 13 deletions.
22 changes: 22 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@
Entries may not always be in chronological/commit order.
See license at the end of file. */

2024-05-31 11:49 UTC+0200 Aleksander Czajczynski (hb fki.pl)
* contrib/rddmisc/arrayrdd.prg
! group of fixes contributed in #355 by @VarenL:
IndexOrd() didn't work, DbZap() didn't update indexes, problem
with larger number of indexes, erroneous AR_GOBOTTOM function.

+ doc/en/rdddb.txt
+ readded a 2017 copy

* contrib/hbamf/amfstdio.c
* flow-control is now optional, but still enabled by default

! fix missing free when exiting the loop

* contrib/hbpgsql/rddcopy.c
! fix c&p bug/typo in HB_PQCOPYFROMWA, corrected handling field list
passed in <aFiledNames> parameter

<lResult> := HB_PQCOPYFROMWA( <pConn>, <cTargetTable>, [<bWhileBlock>],
[<bForBlock>], [<aFieldNames>], [<nCount>],
[<lTrimStrings>], [<nPreBuffer>] )

2024-05-13 02:39 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* ChangeLog.txt
* src/rtl/fscopy.c
Expand Down
34 changes: 24 additions & 10 deletions contrib/hbamf/amfstdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,40 +55,52 @@

static int s_nCount = 0;

static void countCheck( int n )
static void countCheck( int n, int nFlowCtrl )
{
/* yes, this is flow-control */
/* implements flow control for interacting with ill-strange non-configurable
environments that lose data when writing too much into such STDIN pipe.
specify nFlowCtrl = 0 to disable */
if( ! nFlowCtrl )
return;

s_nCount += n;

while( s_nCount >= SINGLEBUF )
while( s_nCount >= nFlowCtrl )
{
/* this 32-bit uint 'zero' should be discarded from buffer every
nFlowCtrl bytes, when received on the other side - after such
notification other process is allowed to send more data */
hb_conOutStd( "\0\0\0\0", 4 );
s_nCount -= SINGLEBUF;
s_nCount -= nFlowCtrl;
}
}

HB_FUNC( AMFSTDIO_READ )
{
char * pszStrIn = ( char * ) hb_xgrab( SINGLEBUF );
char * pszLenPrefix = ( char * ) hb_xgrab( 5 );
#if 0
char * pszBuf; = ( char * ) hb_xgrab( SINGLEBUF );
#endif
char * pszBuf;
char * pszTmp = pszLenPrefix;
HB_USHORT nBytes;
int nTotal = 0;
int nLen;
int nToRead;
HB_FHANDLE hStdIn = hb_fsGetOsHandle( HB_STDIN_HANDLE );
int nFlowCtrl = hb_parnidef( 1, SINGLEBUF );
/* 0 - disable flow control, 32768 - by default */

while( nTotal < 4 )
{
nToRead = ( s_nCount + 4 - nTotal > SINGLEBUF ? SINGLEBUF - s_nCount : 4 - nTotal );
nBytes = hb_fsRead( hStdIn, pszStrIn, ( HB_USHORT ) nToRead );

countCheck( nBytes );
if( ! nBytes )
{
hb_xfree( pszStrIn );
hb_xfree( pszLenPrefix );
hb_ret();
return;
}
countCheck( nBytes, nFlowCtrl );

memcpy( pszTmp, pszStrIn, nBytes );
nTotal += nBytes;
Expand All @@ -100,6 +112,8 @@ HB_FUNC( AMFSTDIO_READ )

if( nLen >= MAXLEN )
{
hb_xfree( pszStrIn );
hb_xfree( pszLenPrefix );
hb_ret();
return;
}
Expand All @@ -122,7 +136,7 @@ HB_FUNC( AMFSTDIO_READ )

nBytes = hb_fsRead( hStdIn, pszStrIn, ( HB_USHORT ) nToRead );

countCheck( nBytes );
countCheck( nBytes, nFlowCtrl );

memcpy( pszTmp, pszStrIn, nBytes );
nTotal += nBytes;
Expand Down
2 changes: 1 addition & 1 deletion contrib/hbpgsql/rddcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ HB_FUNC( HB_PQCOPYFROMWA )
{
if( SELF_GETVALUE( pArea, ( HB_USHORT ) hb_arrayGetNI( pFields, uiIter ), pItem ) != HB_SUCCESS ||
! exportBufSqlVar( context, pItem, sc_szQuote, sc_szEsc ) ||
! addStrToContext( context, uiIter == uiFields ? "\n" : sc_szDelim ) )
! addStrToContext( context, uiIter == uiFieldCopy ? "\n" : sc_szDelim ) )
{
bFail = HB_TRUE;
break;
Expand Down
8 changes: 6 additions & 2 deletions contrib/rddmisc/arrayrdd.prg
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ STATIC FUNCTION AR_GOBOTTOM( nWA )
aWAData[ WADATA_ORDRECNO ] := 0
nResult := AR_GOTO( nWA, 0 )
ELSE
aWAData[ WADATA_ORDRECNO ] := Len( ATail( aIndexes[ nIndex ][ INDEX_RECORDS ] ) )
aWAData[ WADATA_ORDRECNO ] := Len( aIndexes[ nIndex ][ INDEX_RECORDS ] )
nResult := AR_GOTO( nWA, ATail( aIndexes[ nIndex ][ INDEX_RECORDS ] )[ INDEXKEY_RECORD ] )
ENDIF
ELSE
Expand Down Expand Up @@ -1084,6 +1084,7 @@ STATIC FUNCTION AR_ZAP( nWA )
/* empty records */
aDBFData[ DATABASE_RECORDS ] := {}
aDBFData[ DATABASE_RECINFO ] := {}
AEval( aDBFData[ DATABASE_INDEX ], {| aIndex | ASize( aIndex[ INDEX_RECORDS ], 0 ) } )

/* move to 0 recno */
AR_GOTO( nWA, 0 )
Expand Down Expand Up @@ -1319,6 +1320,9 @@ STATIC FUNCTION AR_ORDINFO( nWA, nMsg, aOrderInfo )
ENDSWITCH

SWITCH nMsg
CASE DBOI_NUMBER
aOrderInfo[ UR_ORI_RESULT ] := nIndex
EXIT
CASE DBOI_EXPRESSION
IF nIndex < 1 .OR. Empty( aIndexes ) .OR. nIndex > Len( aIndexes[ nIndex ] )
aOrderInfo[ UR_ORI_RESULT ] := ""
Expand All @@ -1327,7 +1331,7 @@ STATIC FUNCTION AR_ORDINFO( nWA, nMsg, aOrderInfo )
ENDIF
EXIT
CASE DBOI_POSITION
IF nIndex < 1 .OR. Empty( aIndexes ) .OR. nIndex > Len( aIndexes[ nIndex ] ) .OR. Empty( aIndexes[ nIndex ][ INDEX_RECORDS ] ) .OR. aWAData[ WADATA_ORDRECNO ] == 0
IF nIndex < 1 .OR. Empty( aIndexes ) .OR. nIndex > Len( aIndexes ) .OR. Empty( aIndexes[ nIndex ][ INDEX_RECORDS ] ) .OR. aWAData[ WADATA_ORDRECNO ] == 0
aOrderInfo[ UR_ORI_RESULT ] := 0
ELSE
IF aIndexes[ nIndex ][ INDEX_RECORDS ][ aWAData[ WADATA_ORDRECNO ] ][ INDEXKEY_RECORD ] != aWAData[ WADATA_RECNO ]
Expand Down
Loading

0 comments on commit 217d507

Please sign in to comment.