20000512-13:31 GMT+2 Maurilio Longo <maurilio.longo@libero.it>

This commit is contained in:
Maurilio Longo
2000-05-12 11:35:33 +00:00
parent 3d1d1d3875
commit e2dec8ecae
4 changed files with 288 additions and 11 deletions

View File

@@ -1,3 +1,12 @@
20000512-13:31 GMT+2 Maurilio Longo <maurilio.longo@libero.it>
+ source/rtl/stringsx.c
+ added to rtl since teditor.prg needs StrToken()
* source/rtl/Makefile
+ added stringsx.c to list of needed files
* source/rtl/teditor.prg
% Text2Array() is twice as fast and uses A LOT less memory.
20000510-22:01 GMT+2 Maurilio Longo <maurilio.longo@libero.it>
* source/vm/fm.c

View File

@@ -1,154 +1,311 @@
#
# $Id$
#
ROOT = ../../
C_SOURCES=\
abs.c \
accept.c \
ampm.c \
at.c \
binnum.c \
binnumx.c \
box.c \
chrasc.c \
colorind.c \
console.c \
copyfile.c \
datec.c \
dates.c \
dateshb.c \
datesx.c \
defpath.c \
descend.c \
dir.c \
dirdrive.c \
diskspac.c \
do.c \
empty.c \
errorapi.c \
filesys.c \
fkmax.c \
fnsplit.c \
fssize.c \
fstemp.c \
gete.c \
gt.c \
gtapi.c \
gx.c \
hardcr.c \
inkey.c \
is.c \
isprint.c \
langapi.c \
left.c \
len.c \
lennum.c \
math.c \
maxrow.c \
memofile.c \
memoline.c \
minmax.c \
mlcount.c \
mlpos.c \
mod.c \
mouseapi.c \
mousex.c \
mtran.c \
natmsg.c \
net.c \
oemansi.c \
oldbox.c \
oldclear.c \
pad.c \
padc.c \
padl.c \
padr.c \
philes.c \
philes53.c \
philesx.c \
rat.c \
replic.c \
right.c \
round.c \
run.c \
samples.c \
saverest.c \
scroll.c \
seconds.c \
set.c \
setcolor.c \
setcurs.c \
setpos.c \
setposbs.c \
shadow.c \
soundex.c \
space.c \
str.c \
strcase.c \
strings.c \
stringsx.c \
strmatch.c \
strtran.c \
strzero.c \
stuff.c \
substr.c \
tone.c \
trace.c \
transfrm.c \
trim.c \
type.c \
val.c \
valtostr.c \
valtype.c \
version.c \
word.c \
xhelp.c \
xsavescr.c \
PRG_SOURCES=\
achoice.prg \
adir.prg \
alert.prg \
browdb.prg \
browdbx.prg \
browse.prg \
dbedit.prg \
devoutp.prg \
dircmd.prg \
dummy.prg \
errorsys.prg \
fieldbl.prg \
getlist.prg \
getsys.prg \
input.prg \
memoedit.prg \
memvarbl.prg \
menuto.prg \
objfunc.prg \
readkey.prg \
readvar.prg \
setfunc.prg \
setkey.prg \
setta.prg \
tclass.prg \
tbcolumn.prg \
tbrowse.prg \
teditor.prg \
terror.prg \
text.prg \
tget.prg \
tgetlist.prg \
tlabel.prg \
treport.prg \
typefile.prg \
wait.prg \
LIBNAME=rtl
# The list of all valid GT drivers is defined in config/<arch>/global.cf.
DIRS=$(HB_GT_LIBS)
include $(TOP)$(ROOT)config/lib.cf
include $(TOP)$(ROOT)config/dir.cf


View File

@@ -0,0 +1,109 @@
/*
* $Id$
*/
#include "hbapi.h"
/* TODO: search this file for TODO and find 'em! */
char *hb_strtoken(char *szText,
long lText,
long lIndex,
char cDelimiter,
long *lLen)
{
long wStart;
long wEnd = 0;
long wCounter = 0;
HB_TRACE(HB_TR_DEBUG, ("hb_strtoken(%s, %ld, %ld, %d, %p)", szText, lText, lIndex, (int) cDelimiter, lLen));
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 */
HB_FUNC( STRTOKEN )
{
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);
}
/* debug function to dump the ASCII values of an entire string */
HB_FUNC( STRDUMP )
{
char *szText = hb_parc(1);
long i, lLength = hb_parclen(1);
for( i = 0; i < lLength; i++ )
printf("%d ", szText[i]);
printf("\n");
}
HB_FUNC( ROT13 )
{
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') )
c += 13;
else if( (c >= 'N' && c <= 'Z') || (c >= 'n' && c <= 'z') )
c -= 13;
szResult[i] = c;
}
hb_retclen(szResult, lLen);
hb_xfree(szResult);
}
else
hb_retc("");
}

View File

@@ -110,23 +110,25 @@ return Self
// Converts a string to an array of strings splitting input string at EOL boundaries
STATIC function Text2Array(cString)
LOCAL cLine, i, nLastEOL, aArray, cEOL, nEOLLen
LOCAL cLine, nTokNum, aArray, cEOL, nEOLLen, nRetLen, ncSLen
nLastEOL := 1
nTokNum := 1
aArray := {}
cEOL := HB_OSNewLine()
nEOLLen := Len(cEOL)
while nLastEOL > 0
cLine := Left(cString, (nLastEOL := At(cEOL, cString)) - 1)
if nLastEOL > 0
AAdd(aArray, StrTran(cLine, Chr(9), " "))
cString := SubStr(cString, nLastEOL + nEOLLen)
nRetLen := 0
ncSLen := Len(cString)
while nRetLen < ncSLen
cLine := StrToken(cString, nTokNum++, cEOL)
nRetLen += Len(cLine) + iif(nEOLLen > 1, nEOLLen - 1, 1)
if nEOLLen > 1
AAdd(aArray, StrTran(Right(cLine, Len(cLine) - (nEOLLen - 1)), Chr(9), " "))
else
if !Empty(cString)
AAdd(aArray, cString)
endif
AAdd(aArray, StrTran(cLine, Chr(9), " "))
endif
enddo
@@ -228,7 +230,7 @@ METHOD GetLine(nRow) CLASS TEditor
return Self
// Redraws a screenfull of text (or part of it if nFromRow is not nil)
// Redraws a screenfull of text
METHOD RefreshWindow() CLASS TEditor
LOCAL i, nOCol, nORow