2012-11-24 16:48 UTC+0100 Viktor Szakats (harbour syenar.net)

* contrib/hbgt/hbgt.hbp
  * contrib/hbgt/hbgt.hbx
  * contrib/hbgt/asciisgt.c
  * contrib/hbgt/ascposgt.c
  * contrib/hbgt/atdiff.c
  * contrib/hbgt/bitflags.c
  * contrib/hbgt/chareven.c
  * contrib/hbgt/charmixg.c
  * contrib/hbgt/charodd.c
  * contrib/hbgt/chrcount.c
  * contrib/hbgt/chrfirst.c
  * contrib/hbgt/chrtotal.c
  * contrib/hbgt/strasint.c
  * contrib/hbgt/strcount.c
  * contrib/hbgt/strcspn.c
  * contrib/hbgt/strdiffg.c
  * contrib/hbgt/strexpan.c
  * contrib/hbgt/strleft.c
  * contrib/hbgt/strpbrk.c
  * contrib/hbgt/strright.c
  * contrib/hbgt/doc/en/hbgt.txt
    * code cleanup and optimizations
    + fixed flag functions (they wrote to read-only buffer)
    + enabled flag functions
This commit is contained in:
Viktor Szakats
2012-11-24 15:51:28 +00:00
parent 4b2790b65e
commit 7ec3746550
22 changed files with 180 additions and 282 deletions

View File

@@ -10,6 +10,32 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2012-11-24 16:48 UTC+0100 Viktor Szakats (harbour syenar.net)
* contrib/hbgt/hbgt.hbp
* contrib/hbgt/hbgt.hbx
* contrib/hbgt/asciisgt.c
* contrib/hbgt/ascposgt.c
* contrib/hbgt/atdiff.c
* contrib/hbgt/bitflags.c
* contrib/hbgt/chareven.c
* contrib/hbgt/charmixg.c
* contrib/hbgt/charodd.c
* contrib/hbgt/chrcount.c
* contrib/hbgt/chrfirst.c
* contrib/hbgt/chrtotal.c
* contrib/hbgt/strasint.c
* contrib/hbgt/strcount.c
* contrib/hbgt/strcspn.c
* contrib/hbgt/strdiffg.c
* contrib/hbgt/strexpan.c
* contrib/hbgt/strleft.c
* contrib/hbgt/strpbrk.c
* contrib/hbgt/strright.c
* contrib/hbgt/doc/en/hbgt.txt
* code cleanup and optimizations
+ fixed flag functions (they wrote to read-only buffer)
+ enabled flag functions
2012-11-24 15:20 UTC+0100 Viktor Szakats (harbour syenar.net)
* contrib/hbct/addascii.c
* contrib/hbct/asciisum.c

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: asciisum.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: ascpos.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,13 +20,11 @@
HB_FUNC( GT_ASCPOS )
{
const char * s;
HB_SIZE p;
if( HB_ISCHAR( 1 ) && HB_ISNUM( 2 ) )
{
s = hb_parc( 1 );
p = hb_parns( 2 );
const char * s = hb_parc( 1 );
HB_SIZE p = hb_parns( 2 );
p--; /* decrement p to adjust for c strings */
/* starting at position 0 */
@@ -38,7 +35,5 @@ HB_FUNC( GT_ASCPOS )
/* character in string */
}
else
{
hb_retni( -1 ); /* parameter mismatch - error -1 */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: atdiff.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,14 +20,12 @@
HB_FUNC( GT_ATDIFF )
{
const char * s1, * s2;
HB_ISIZ pos, len;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
s1 = hb_parc( 1 );
s2 = hb_parc( 2 );
len = hb_parclen( 2 );
const char * s1 = hb_parc( 1 );
const char * s2 = hb_parc( 2 );
HB_ISIZ len = hb_parclen( 2 );
HB_ISIZ pos;
/*
loop through comparing both strings
@@ -46,7 +43,5 @@ HB_FUNC( GT_ATDIFF )
hb_retns( pos );
}
else
{
hb_retns( -1 ); /* parameter mismatch - error -1 */
}
}

View File

@@ -3,7 +3,6 @@
*/
/*
* File......: BITFLAGS.C
* Author....: Dave Pearson
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -25,64 +24,44 @@
*
*/
#include "hbapi.h"
#define _GT_MAX( x, y ) ( x > y ? x : y )
#include "hbapiitm.h"
HB_FUNC( GT_NEWFLAG )
{
char * FlagString;
unsigned ByteCount;
unsigned FlagCount = 1;
unsigned Byte;
unsigned FlagCount = ( unsigned ) hb_parnidef( 1, 1 );
if( ISNUM( 1 ) )
{
FlagCount = ( unsigned ) hb_parni( 1 );
}
if( FlagCount > 0 )
{
ByteCount = ( unsigned ) ( ( FlagCount / 8 ) + 1 );
char * FlagString;
unsigned ByteCount = ( unsigned ) ( ( FlagCount / 8 ) + 1 );
unsigned Byte;
if( ! ( FlagCount % 8 ) )
{
--ByteCount;
}
FlagString = hb_xgrab( ByteCount );
FlagString = ( char * ) hb_xgrab( ByteCount );
for( Byte = 0; Byte < ByteCount; Byte++ )
{
FlagString[ Byte ] = 0;
}
hb_retclen( FlagString, ByteCount );
hb_xfree( FlagString );
}
else
{
hb_retc_null();
}
}
HB_FUNC( GT_SETFLAG )
{
char * FlagString;
unsigned StartBit = 1;
unsigned EndBit = 1;
unsigned BitCount;
unsigned BitPointer;
unsigned BytePointer;
if( HB_ISCHAR( 1 ) )
{
FlagString = hb_parc( 1 );
if( HB_ISNUM( 2 ) )
{
StartBit = hb_parni( 2 );
}
if( HB_ISNUM( 3 ) )
{
EndBit = hb_parni( 3 );
}
EndBit = _GT_MAX( StartBit, EndBit );
char * FlagString = hb_itemGetC( hb_param( 1, HB_IT_STRING ) );
unsigned StartBit = hb_parnidef( 2, 1 );
unsigned EndBit = hb_parnidef( 3, 1 );
unsigned BitCount;
unsigned BitPointer;
unsigned BytePointer;
EndBit = HB_MAX( StartBit, EndBit );
if( StartBit > 0 && EndBit <= ( hb_parclen( 1 ) * 8 ) )
{
for( BitCount = StartBit; BitCount <= EndBit; BitCount++ )
@@ -97,35 +76,25 @@ HB_FUNC( GT_SETFLAG )
FlagString[ BytePointer ] |= 1 << ( BitPointer - 1 );
}
}
hb_retclen( FlagString, hb_parclen( 1 ) );
hb_retclen_buffer( FlagString, hb_parclen( 1 ) );
}
else
{
hb_retc_null();
}
}
HB_FUNC( GT_CLRFLAG )
{
char * FlagString;
unsigned StartBit = 1;
unsigned EndBit = 1;
unsigned BitCount;
unsigned BitPointer;
unsigned BytePointer;
if( HB_ISCHAR( 1 ) )
{
FlagString = hb_parc( 1 );
if( HB_ISNUM( 2 ) )
{
StartBit = hb_parni( 2 );
}
if( HB_ISNUM( 3 ) )
{
EndBit = hb_parni( 3 );
}
EndBit = _GT_MAX( StartBit, EndBit );
char * FlagString = hb_itemGetC( hb_param( 1, HB_IT_STRING ) );
unsigned StartBit = hb_parnidef( 2, 1 );
unsigned EndBit = hb_parnidef( 3, 1 );
unsigned BitCount;
unsigned BitPointer;
unsigned BytePointer;
EndBit = HB_MAX( StartBit, EndBit );
if( StartBit > 0 && EndBit <= ( hb_parclen( 1 ) * 8 ) )
{
for( BitCount = StartBit; BitCount <= EndBit; BitCount++ )
@@ -140,30 +109,23 @@ HB_FUNC( GT_CLRFLAG )
FlagString[ BytePointer ] &= 0xff - ( 1 << ( BitPointer - 1 ) );
}
}
hb_retclen( FlagString, hb_parclen( 1 ) );
hb_retclen_buffer( FlagString, hb_parclen( 1 ) );
}
else
{
hb_retc_null();
}
}
HB_FUNC( GT_ISFLAG )
HB_FUNC( GT_ISFLAG )
{
HB_BOOL FlagStatus = HB_FALSE;
unsigned Bit = 1;
unsigned BitPointer;
unsigned BytePointer;
char * FlagString;
HB_BOOL FlagStatus = HB_FALSE;
if( HB_ISCHAR( 1 ) )
{
FlagString = hb_parc( 1 );
if( HB_ISNUM( 2 ) )
{
Bit = hb_parni( 2 );
}
unsigned Bit = hb_parnidef( 2, 1 );
unsigned BitPointer;
unsigned BytePointer;
const char * FlagString = hb_parc( 1 );
if( Bit > 0 && Bit <= ( hb_parclen( 1 ) * 8 ) )
{
BitPointer = Bit % 8;

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: chareven.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,14 +20,12 @@
HB_FUNC( GT_CHAREVEN )
{
const char * s1;
char * s2;
HB_ISIZ len, i;
if( HB_ISCHAR( 1 ) )
{
s1 = hb_parc( 1 );
len = hb_parclen( 1 );
const char * s1 = hb_parc( 1 );
char * s2;
HB_ISIZ len = hb_parclen( 1 );
HB_ISIZ i;
s2 = ( char * ) hb_xgrab( len / 2 + 1 ); /* grab us some mem to work with */
@@ -38,7 +35,5 @@ HB_FUNC( GT_CHAREVEN )
hb_retclen_buffer( s2, len / 2 );
}
else
{
hb_retc_null(); /* parameter mismatch - error NullStr */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: charmix.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,17 +20,14 @@
HB_FUNC( GT_CHARMIX )
{
const char * s1, * s2;
char * s3;
HB_ISIZ l1, l2, i, pos3;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
s1 = hb_parc( 1 );
s2 = hb_parc( 2 );
l1 = hb_parclen( 1 );
l2 = hb_parclen( 2 );
pos3 = 0;
const char * s1 = hb_parc( 1 );
const char * s2 = hb_parc( 2 );
HB_ISIZ l1 = hb_parclen( 1 );
HB_ISIZ l2 = hb_parclen( 2 );
char * s3;
HB_ISIZ i, pos3 = 0;
s3 = ( char * ) hb_xgrab( l1 + l2 + 1 ); /* grab us some mem to work with */
@@ -48,11 +44,8 @@ HB_FUNC( GT_CHARMIX )
s3[ pos3++ ] = s2[ i ];
s3[ pos3 ] = '\0';
hb_retclen( s3, l1 + l2 );
hb_xfree( s3 ); /* free alloc'ed mem */
hb_retclen_buffer( s3, l1 + l2 );
}
else
{
hb_retc_null(); /* parameter mismatch - error NullStr */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: charodd.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,25 +20,20 @@
HB_FUNC( GT_CHARODD )
{
const char * s1;
char * s2;
HB_ISIZ len, i;
if( HB_ISCHAR( 1 ) )
{
s1 = hb_parc( 1 );
len = hb_parclen( 1 );
const char * s1 = hb_parc( 1 );
char * s2;
HB_ISIZ len = hb_parclen( 1 );
HB_ISIZ i;
s2 = ( char * ) hb_xgrab( len / 2 ); /* grab us some mem to work with */
s2 = ( char * ) hb_xgrab( len / 2 + 1 ); /* grab us some mem to work with */
for( i = 0; i <= len; i += 2 )
s2[ i / 2 ] = s1[ i ] & 0x7f;
hb_retclen( s2, len );
hb_xfree( s2 ); /* free alloc'ed mem */
hb_retclen_buffer( s2, len / 2 );
}
else
{
hb_retc_null(); /* parameter mismatch - error NullStr */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: chrcount.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,14 +20,12 @@
HB_FUNC( GT_CHRCOUNT )
{
const char * s1, * s2;
HB_ISIZ count, pos2, len;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
s1 = hb_parc( 1 );
s2 = hb_parc( 2 );
len = hb_parclen( 2 );
const char * s1 = hb_parc( 1 );
const char * s2 = hb_parc( 2 );
HB_ISIZ len = hb_parclen( 2 );
HB_ISIZ count, pos2;
/* loop through s2 matching passed character (s1) with
each character of s1 */
@@ -40,7 +37,5 @@ HB_FUNC( GT_CHRCOUNT )
hb_retns( count ); /* return result */
}
else
{
hb_retns( -1 ); /* parameter mismatch - error -1 */
}
hb_retns( -1 ); /* parameter mismatch - error -1 */
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: chrfirst.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,18 +20,15 @@
HB_FUNC( GT_CHRFIRST )
{
const char * string;
const char * cset;
HB_ISIZ l1, l2;
HB_ISIZ p1, p2;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
string = hb_parc( 2 );
cset = hb_parc( 1 );
l1 = hb_parclen( 2 );
l2 = hb_parclen( 1 );
p1 = p2 = 0;
const char * string = hb_parc( 2 );
const char * cset = hb_parc( 1 );
HB_ISIZ l1 = hb_parclen( 2 );
HB_ISIZ l2 = hb_parclen( 1 );
HB_ISIZ p1, p2;
p1 = p2 = 0;
do
{
@@ -48,10 +44,7 @@ HB_FUNC( GT_CHRFIRST )
if( p2 >= l2 )
hb_retni( 0 );
}
else
{
hb_retni( -1 ); /* parameter mismatch - error NullStr */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: chrtotal.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,15 +20,13 @@
HB_FUNC( GT_CHRTOTAL )
{
const char * s1, * s2;
HB_ISIZ count, p1, p2, l2, l1;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
s1 = hb_parc( 1 );
s2 = hb_parc( 2 );
l2 = hb_parclen( 2 );
l1 = hb_parclen( 1 );
const char * s1 = hb_parc( 1 );
const char * s2 = hb_parc( 2 );
HB_ISIZ l1 = hb_parclen( 1 );
HB_ISIZ l2 = hb_parclen( 2 );
HB_ISIZ count, p1, p2;
for( count = 0, p2 = 0; p2 < l2; p2++ )
for( p1 = 0; p1 < l1; p1++ )
@@ -40,7 +37,5 @@ HB_FUNC( GT_CHRTOTAL )
hb_retns( count ); /* return result */
}
else
{
hb_retns( -1 ); /* parameter mismatch - error -1 */
}
hb_retns( -1 ); /* parameter mismatch - error -1 */
}

View File

@@ -556,44 +556,44 @@
/* $DOC$
$NAME$
GT_NEWFLAG()
gt_NewFlag()
$CATEGORY$
General
$ONELINER$
Create a new bit flag string.
$SYNTAX$
GT_NewFlag(<nFlagCount>) --> cFlagString
gt_NewFlag(<nFlagCount>) --> cFlagString
$ARGUMENTS$
<nFlagCount> is the number of flags you wish to store.
$RETURNS$
A string to hold the bit flags. All flags are set to FALSE.
$DESCRIPTION$
GT_NewFlag() is used to construct a bit flag string. The bit flag
gt_NewFlag() is used to construct a bit flag string. The bit flag
functions can be used for storing a large number of logical values
in a small space.
To create a bit flag string you need to pass GT_NewFlag() a value
To create a bit flag string you need to pass gt_NewFlag() a value
that is equal to or greater than the number of flags required (you
may want to allow for future expansion). Each character in the
string returned from GT_NewFlag() will hold 8 logical values.
string returned from gt_NewFlag() will hold 8 logical values.
$EXAMPLES$
cFlags := GT_NewFlag( 20 ) // Create a bit flag string for 20 logical values.
cFlags := gt_NewFlag( 20 ) // Create a bit flag string for 20 logical values.
$SEEALSO$
GT_SETFLAG() GT_CLRFLAG() GT_ISFLAG()
gt_SetFlag() gt_ClrFlag() gt_IsFlag()
$END$
*/
/* $DOC$
$NAME$
GT_SETFLAG()
gt_SetFlag()
$CATEGORY$
General
$ONELINER$
Set a number of flags to TRUE in a bit flag string.
$SYNTAX$
GT_SetFlag(<cFlagString>,[<nStart>],[<nEnd>]) --> cFlagString
gt_SetFlag(<cFlagString>,[<nStart>],[<nEnd>]) --> cFlagString
$ARGUMENTS$
<cFlagString> is a bit flag string created with GT_NewFlag()
<cFlagString> is a bit flag string created with gt_NewFlag()
<nStart> is the starting flag. This is an optional numeric value.
If not supplied it defaults to 1.
@@ -603,38 +603,38 @@
$RETURNS$
The bit map string with the new flag settings.
$DESCRIPTION$
GT_SetFlag() is used to turn flags within the flag string on.
gt_SetFlag() is used to turn flags within the flag string on.
$EXAMPLES$
cFlags := GT_NewFlag( 20 ) // Create a bit flag string for 20
cFlags := gt_NewFlag( 20 ) // Create a bit flag string for 20
// logical values.
// Now set flags 10 to 15 to true.
cFlags := GT_SetFlag( cFlags, 10, 15 )
cFlags := gt_SetFlag( cFlags, 10, 15 )
// And set flag 18 to true.
cFlags := GT_SetFlag( cFlags, 18 )
cFlags := gt_SetFlag( cFlags, 18 )
// And set flag 1 to true.
cFlags := GT_SetFlag( cFlags )
cFlags := gt_SetFlag( cFlags )
$SEEALSO$
GT_NEWFLAG() GT_CLRFLAG() GT_ISFLAG()
gt_NewFlag() gt_ClrFlag() gt_IsFlag()
$END$
*/
/* $DOC$
$NAME$
GT_CLRFLAG()
gt_ClrFlag()
$CATEGORY$
General
$ONELINER$
Set a number of flags to FALSE in a bit flag string.
$SYNTAX$
GT_ClrFlag(<cFlagString>,[<nStart>],[<nEnd>]) --> cFlagString
gt_ClrFlag(<cFlagString>,[<nStart>],[<nEnd>]) --> cFlagString
$ARGUMENTS$
<cFlagString> is a bit flag string created with GT_NewFlag()
<cFlagString> is a bit flag string created with gt_NewFlag()
<nStart> is the starting flag. This is an optional numeric value.
If not supplied it defaults to 1.
@@ -644,56 +644,56 @@
$RETURNS$
The bit map string with the new flag settings.
$DESCRIPTION$
GT_ClrFlag() is used to turn flags within the flag string off.
gt_ClrFlag() is used to turn flags within the flag string off.
$EXAMPLES$
cFlags := GT_NewFlag( 20 ) // Create a bit flag string for 20
cFlags := gt_NewFlag( 20 ) // Create a bit flag string for 20
// logical values.
// Now, turn them all on.
cFlags := GT_SetFlag( cFlags, 1, 20 )
cFlags := gt_SetFlag( cFlags, 1, 20 )
// Now set flags 10 to 15 to false.
cFlags := GT_ClrFlag( cFlags, 10, 15 )
cFlags := gt_ClrFlag( cFlags, 10, 15 )
// And set flag 18 to false.
cFlags := GT_ClrFlag( cFlags, 18 )
cFlags := gt_ClrFlag( cFlags, 18 )
// And set flag 1 to false.
cFlags := GT_ClrFlag( cFlags )
cFlags := gt_ClrFlag( cFlags )
$SEEALSO$
GT_NEWFLAG() GT_SETFLAG() GT_ISFLAG()
gt_NewFlag() gt_SetFlag() gt_IsFlag()
$END$
*/
/* $DOC$
$NAME$
GT_ISFLAG()
gt_IsFlag()
$CATEGORY$
General
$ONELINER$
Test the setting of a flag in a bit flag string.
$SYNTAX$
GT_IsFlag(<cFlagString>,[<nFlag>]) --> lSetting
gt_IsFlag(<cFlagString>,[<nFlag>]) --> lSetting
$ARGUMENTS$
<cFlagString> is a bit flag string created with GT_NewFlag()
<cFlagString> is a bit flag string created with gt_NewFlag()
<nFlag> is the flag to be tested.
$RETURNS$
A boolean value, TRUE if the flag is on, FALSE if it's off.
$DESCRIPTION$
GT_IsFlag() is used to test the state of a flag with a bit flag
gt_IsFlag() is used to test the state of a flag with a bit flag
string.
$EXAMPLES$
// Print the setting of the flags in a flag string called ``cDave''
FOR nFlag := 1 to ( Len( cDave ) * 8 )
? "Flag number ", nFlag, " == ", GT_IsFlag( cDave, nFlag )
? "Flag number ", nFlag, " == ", gt_IsFlag( cDave, nFlag )
NEXT
$SEEALSO$
GT_NEWFLAG() GT_SETFLAG() GT_CLRFLAG()
gt_NewFlag() gt_SetFlag() gt_ClrFlag()
$END$
*/

View File

@@ -14,6 +14,7 @@ hbgt.hbx
asciisgt.c
ascposgt.c
atdiff.c
bitflags.c
chareven.c
charmixg.c
charodd.c

View File

@@ -30,6 +30,10 @@ DYNAMIC gt_CharOdd
DYNAMIC gt_ChrCount
DYNAMIC gt_ChrFirst
DYNAMIC gt_ChrTotal
DYNAMIC gt_ClrFlag
DYNAMIC gt_IsFlag
DYNAMIC gt_NewFlag
DYNAMIC gt_SetFlag
DYNAMIC gt_StrCount
DYNAMIC gt_StrCSPN
DYNAMIC gt_StrDiff

View File

@@ -27,5 +27,6 @@ int _GT_Internal_StringAsInt( char * String, HB_ISIZ Start, HB_ISIZ End )
Decimal *= 0xA;
}
}
return Value;
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: strcount.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,16 +20,14 @@
HB_FUNC( GT_STRCOUNT )
{
const char * s1, * s2;
HB_ISIZ count, p1, p2, l1, l2;
int match;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
s1 = hb_parc( 1 );
s2 = hb_parc( 2 );
l1 = hb_parclen( 1 );
l2 = hb_parclen( 2 );
const char * s1 = hb_parc( 1 );
const char * s2 = hb_parc( 2 );
HB_ISIZ l1 = hb_parclen( 1 );
HB_ISIZ l2 = hb_parclen( 2 );
HB_ISIZ count, p1, p2;
int match;
/* loop through s2 matching passed character (s1) with
each character of s1 */
@@ -52,7 +49,5 @@ HB_FUNC( GT_STRCOUNT )
hb_retns( count ); /* return result */
}
else
{
hb_retns( -1 ); /* parameter mismatch - error -1 */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: strcspn.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,17 +20,13 @@
HB_FUNC( GT_STRCSPN )
{
const char * string;
const char * cset;
HB_ISIZ l1, l2;
HB_ISIZ p1, p2;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
string = hb_parc( 1 );
cset = hb_parc( 2 );
l1 = hb_parclen( 1 );
l2 = hb_parclen( 2 );
const char * string = hb_parc( 1 );
const char * cset = hb_parc( 2 );
HB_ISIZ l1 = hb_parclen( 1 );
HB_ISIZ l2 = hb_parclen( 2 );
HB_ISIZ p1, p2;
for( p1 = 0; p1 < l1; ++p1 )
{
@@ -44,7 +39,5 @@ HB_FUNC( GT_STRCSPN )
hb_retns( p1 );
}
else
{
hb_retns( -1 ); /* parameter mismatch - error -1 */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: strdiff.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,14 +20,12 @@
HB_FUNC( GT_STRDIFF )
{
const char * s1, * s2;
HB_ISIZ pos, len;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
s1 = hb_parc( 1 );
s2 = hb_parc( 2 );
len = hb_parclen( 2 );
const char * s1 = hb_parc( 1 );
const char * s2 = hb_parc( 2 );
HB_ISIZ pos;
HB_ISIZ len = hb_parclen( 2 );
/*
loop through comparing both strings
@@ -46,7 +43,5 @@ HB_FUNC( GT_STRDIFF )
hb_retc( s2 );
}
else
{
hb_ret(); /* parameter mismatch - error return NIL */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: strexpan.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,21 +20,15 @@
HB_FUNC( GT_STREXPAND )
{
const char * in;
char * out;
int nIns = 1;
const char * insert = " ";
HB_ISIZ len;
HB_ISIZ i, p;
int j;
if( HB_ISCHAR( 1 ) && ( HB_ISNUM( 2 ) || hb_pcount() < 2 ) && ( HB_ISCHAR( 3 ) || hb_pcount() < 3 ) )
{
in = hb_parc( 1 );
len = hb_parclen( 1 );
if( HB_ISNUM( 2 ) )
nIns = hb_parni( 2 );
const char * in = hb_parc( 1 );
char * out;
int nIns = hb_parnidef( 2, 1 );
const char * insert = " ";
HB_ISIZ len = hb_parclen( 1 );
HB_ISIZ i, p;
int j;
if( HB_ISCHAR( 3 ) )
insert = hb_parc( 3 );
@@ -54,11 +47,8 @@ HB_FUNC( GT_STREXPAND )
}
out[ p ] = '\0'; /* Add terminating NUL */
hb_retc( out );
hb_xfree( out ); /* free alloc'ed mem */
hb_retc_buffer( out );
}
else
{
hb_retc_null(); /* parameter mismatch - error NullStr */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: strleft.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,17 +20,13 @@
HB_FUNC( GT_STRLEFT )
{
const char * string;
const char * cset;
HB_ISIZ l1, l2;
HB_ISIZ p1, p2;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
string = hb_parc( 1 );
cset = hb_parc( 2 );
l1 = hb_parclen( 1 );
l2 = hb_parclen( 2 );
const char * string = hb_parc( 1 );
const char * cset = hb_parc( 2 );
HB_ISIZ l1 = hb_parclen( 1 );
HB_ISIZ l2 = hb_parclen( 2 );
HB_ISIZ p1, p2;
for( p1 = 0; p1 < l1; p1++ )
{
@@ -42,10 +37,7 @@ HB_FUNC( GT_STRLEFT )
break;
}
hb_retns( p1 );
}
else
{
hb_retns( -1 ); /* parameter mismatch - error NullStr */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: strpbrk.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,18 +20,15 @@
HB_FUNC( GT_STRPBRK )
{
const char * string;
const char * cset;
HB_ISIZ l1, l2;
HB_ISIZ p1, p2;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
string = hb_parc( 1 );
cset = hb_parc( 2 );
l1 = hb_parclen( 1 );
l2 = hb_parclen( 2 );
p1 = p2 = 0;
const char * string = hb_parc( 1 );
const char * cset = hb_parc( 2 );
HB_ISIZ l1 = hb_parclen( 1 );
HB_ISIZ l2 = hb_parclen( 2 );
HB_ISIZ p1, p2;
p1 = p2 = 0;
do
{
@@ -48,10 +44,7 @@ HB_FUNC( GT_STRPBRK )
if( p2 >= l2 )
hb_retc_null();
}
else
{
hb_retc_null(); /* parameter mismatch - error NullStr */
}
}

View File

@@ -5,7 +5,6 @@
/*
* GT CLIPPER STANDARD HEADER
*
* File......: strright.c
* Author....: Andy M Leighton
* BBS.......: The Dark Knight Returns
* Net/Node..: 050/069
@@ -21,17 +20,13 @@
HB_FUNC( GT_STRRIGHT )
{
const char * string;
const char * cset;
HB_ISIZ l1, l2;
HB_ISIZ p1, p2;
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
string = hb_parc( 1 );
cset = hb_parc( 2 );
l1 = hb_parclen( 1 );
l2 = hb_parclen( 2 );
const char * string = hb_parc( 1 );
const char * cset = hb_parc( 2 );
HB_ISIZ l1 = hb_parclen( 1 );
HB_ISIZ l2 = hb_parclen( 2 );
HB_ISIZ p1, p2;
for( p1 = l1 - 1; p1 >= 0; p1-- )
{
@@ -42,10 +37,7 @@ HB_FUNC( GT_STRRIGHT )
break;
}
hb_retns( l1 - p1 - 1 );
}
else
{
hb_retns( -1 ); /* parameter mismatch - error NullStr */
}
}