ChangeLogTag:Wed Aug 04 11:00:07 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
Wed Aug 04 11:00:07 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>
|
||||
|
||||
* source/tools/stringsx.c:
|
||||
* source/rtl/Makefile:
|
||||
* source/rtl/stringsx.c:
|
||||
Moved STRTOKEN from tools/ to rtl/, even though it is not a 100%
|
||||
Clipper standard function. The reason is because we will probably
|
||||
be using this function a lot (such as Antonio did in TGet.prg).
|
||||
|
||||
* source/rtl/gt/gtwin.c:
|
||||
* source/vm/hvm.c:
|
||||
Fixed two minor warnings.
|
||||
|
||||
Wed Aug 04 10:12:24 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>
|
||||
|
||||
* config/win32/gcc.cf:
|
||||
|
||||
@@ -29,6 +29,7 @@ C_SOURCES=\
|
||||
set.c \
|
||||
setcolor.c \
|
||||
strings.c \
|
||||
stringsx.c \
|
||||
transfrm.c \
|
||||
\
|
||||
gtxxx.c \
|
||||
@@ -42,9 +43,12 @@ PRG_SOURCES=\
|
||||
devoutp.prg \
|
||||
error.prg \
|
||||
errorsys.prg \
|
||||
menu.prg \
|
||||
objfunc.prg \
|
||||
setkey.prg \
|
||||
tclass.prg \
|
||||
tget.prg \
|
||||
tgetlist.prg \
|
||||
|
||||
LIB=rtl
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ void hb_gt_PutText(char cTop, char cLeft, char cBottom, char cRight, char *srce)
|
||||
{
|
||||
*(pstr + i) = *srce;
|
||||
srce++;
|
||||
*(pwattr + i) = (WORD)((unsigned char)*srce)&0xff | 0x8000;
|
||||
*(pwattr + i) = ((WORD)((unsigned char)*srce)&0xff) | 0x8000;
|
||||
*pwattr |= 0x8000;
|
||||
srce++;
|
||||
}
|
||||
|
||||
68
harbour/source/rtl/stringsx.c
Normal file
68
harbour/source/rtl/stringsx.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "extend.h"
|
||||
|
||||
char *hb_strtoken(char *szText,
|
||||
long lText,
|
||||
long lIndex,
|
||||
char cDelimiter,
|
||||
long *lLen)
|
||||
{
|
||||
long wStart, wEnd = 0, wCounter = 0;
|
||||
|
||||
do
|
||||
{
|
||||
wStart = wEnd;
|
||||
|
||||
if( cDelimiter != ' ' )
|
||||
{
|
||||
if( szText[wStart] == cDelimiter )
|
||||
wStart++;
|
||||
}
|
||||
else
|
||||
{
|
||||
while( wStart < lText && szText[wStart] == cDelimiter )
|
||||
wStart++;
|
||||
}
|
||||
|
||||
if( wStart < lText && szText[wStart] != cDelimiter )
|
||||
{
|
||||
wEnd = wStart + 1;
|
||||
|
||||
while( wEnd < lText && szText[wEnd] != cDelimiter )
|
||||
wEnd++;
|
||||
}
|
||||
else
|
||||
wEnd = wStart;
|
||||
} while( wCounter++ < lIndex - 1 && wEnd < lText );
|
||||
|
||||
if( wCounter < lIndex )
|
||||
{
|
||||
*lLen = 0;
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
*lLen = wEnd - wStart;
|
||||
return szText + wStart;
|
||||
}
|
||||
}
|
||||
|
||||
/* returns the nth occurence of a substring within a token-delimited string */
|
||||
HARBOUR HB_STRTOKEN( void )
|
||||
{
|
||||
char *szText;
|
||||
long lIndex = hb_parnl(2);
|
||||
char cDelimiter = *hb_parc(3);
|
||||
long lLen;
|
||||
|
||||
if( !cDelimiter )
|
||||
cDelimiter = ' ';
|
||||
|
||||
szText = hb_strtoken(hb_parc(1), hb_parclen(1), lIndex, cDelimiter, &lLen);
|
||||
|
||||
hb_stornl(lLen, 4);
|
||||
hb_retclen(szText, lLen);
|
||||
}
|
||||
@@ -9,94 +9,34 @@
|
||||
/* debug function to dump the ASCII values of an entire string */
|
||||
HARBOUR HB_STRDUMP( void )
|
||||
{
|
||||
char *szText = hb_parc(1);
|
||||
long i, lLength = hb_parclen(1);
|
||||
for( i = 0; i < lLength; i++ )
|
||||
printf("%d ", szText[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
char *hb_strtoken(char *szText, long lText, long lIndex, char cDelimiter, long *lLen)
|
||||
{
|
||||
long wStart, wEnd = 0, wCounter = 0;
|
||||
|
||||
do
|
||||
{
|
||||
wStart = wEnd;
|
||||
|
||||
if( cDelimiter != ' ' )
|
||||
{
|
||||
if( szText[wStart] == cDelimiter )
|
||||
wStart++;
|
||||
}
|
||||
else
|
||||
{
|
||||
while( wStart < lText && szText[wStart] == cDelimiter )
|
||||
wStart++;
|
||||
}
|
||||
|
||||
if( wStart < lText && szText[wStart] != cDelimiter )
|
||||
{
|
||||
wEnd = wStart + 1;
|
||||
|
||||
while( wEnd < lText && szText[wEnd] != cDelimiter )
|
||||
wEnd++;
|
||||
}
|
||||
else
|
||||
wEnd = wStart;
|
||||
} while( wCounter++ < lIndex - 1 && wEnd < lText );
|
||||
|
||||
if( wCounter < lIndex )
|
||||
{
|
||||
*lLen = 0;
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
*lLen = wEnd - wStart;
|
||||
return szText + wStart;
|
||||
}
|
||||
}
|
||||
|
||||
/* returns the nth occurence of a substring within a token-delimited string */
|
||||
HARBOUR HB_STRTOKEN( void )
|
||||
{
|
||||
char *szText;
|
||||
long lIndex = hb_parnl(2);
|
||||
char cDelimiter = *hb_parc(3);
|
||||
long lLen;
|
||||
|
||||
if( !cDelimiter )
|
||||
cDelimiter = ' ';
|
||||
|
||||
szText = hb_strtoken(hb_parc(1), hb_parclen(1), lIndex, cDelimiter, &lLen);
|
||||
|
||||
hb_stornl(lLen, 4);
|
||||
hb_retclen(szText, lLen);
|
||||
char *szText = hb_parc(1);
|
||||
long i, lLength = hb_parclen(1);
|
||||
for( i = 0; i < lLength; i++ )
|
||||
printf("%d ", szText[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
HARBOUR HB_ROT13( void )
|
||||
{
|
||||
if( ISCHAR(1) )
|
||||
{
|
||||
if( ISCHAR(1) )
|
||||
{
|
||||
char *szText = hb_parc( 1 );
|
||||
ULONG i, lLen = hb_parclen( 1 );
|
||||
char *szResult = (char*)hb_xgrab(lLen + 1);
|
||||
|
||||
for( i = 0; i < lLen; i++ )
|
||||
{
|
||||
char c = szText[i];
|
||||
if( (c >= 'A' && c <= 'M') || (c >= 'a' && c <= 'm') )
|
||||
{
|
||||
char c = szText[i];
|
||||
if( (c >= 'A' && c <= 'M') || (c >= 'a' && c <= 'm') )
|
||||
c += 13;
|
||||
else if( (c >= 'N' && c <= 'Z') || (c >= 'n' && c <= 'z') )
|
||||
else if( (c >= 'N' && c <= 'Z') || (c >= 'n' && c <= 'z') )
|
||||
c -= 13;
|
||||
|
||||
szResult[i] = c;
|
||||
}
|
||||
szResult[i] = c;
|
||||
}
|
||||
hb_retclen(szResult, lLen);
|
||||
hb_xfree(szResult);
|
||||
}
|
||||
else
|
||||
hb_retc("");
|
||||
}
|
||||
else
|
||||
hb_retc("");
|
||||
}
|
||||
|
||||
|
||||
@@ -780,7 +780,7 @@ void Do( WORD wParams )
|
||||
|
||||
if( ! pFunc )
|
||||
{
|
||||
printf( "error: message %s not implemented for class %s in line %i\n",
|
||||
printf( "error: message %s not implemented for class %s in line %li\n",
|
||||
pSym->szName, hb_GetClassName( pSelf ), lLineNo );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user