From d38dbf87106ade81266405fd542eb3fe6b9af753 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 6 Apr 2007 13:43:54 +0000 Subject: [PATCH] 2007-04-06 15:38 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * harbour/source/rtl/persist.prg * harbour/source/rtl/tbrowse.prg * harbour/source/rtl/teditor.prg % Replaced __StrT*() internal functions with native Harbour extensions hb_Token*(). % Removed workarounds for problems with the previous implementation of the __StrT*() functions. Please test TEditor (all) and TBrowse class (header/footer line splitting). --- harbour/ChangeLog | 10 ++++++++++ harbour/source/rtl/persist.prg | 34 +++++++++++++++++----------------- harbour/source/rtl/tbrowse.prg | 16 +++++----------- harbour/source/rtl/teditor.prg | 31 +++++++------------------------ 4 files changed, 39 insertions(+), 52 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4d0a73743c..3d8d43c4ed 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-04-06 15:38 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * harbour/source/rtl/persist.prg + * harbour/source/rtl/tbrowse.prg + * harbour/source/rtl/teditor.prg + % Replaced __StrT*() internal functions with native Harbour + extensions hb_Token*(). + % Removed workarounds for problems with the previous implementation + of the __StrT*() functions. + Please test TEditor (all) and TBrowse class (header/footer line splitting). + 2007-04-06 14:33 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/hbtoken.c ! fixed using delimiters longer then 1 character diff --git a/harbour/source/rtl/persist.prg b/harbour/source/rtl/persist.prg index 4e6723a20d..11d2287037 100644 --- a/harbour/source/rtl/persist.prg +++ b/harbour/source/rtl/persist.prg @@ -86,13 +86,13 @@ METHOD LoadFromText( cObjectText ) CLASS HBPersistent cLine := ExtractLine( cObjectText, @nFrom ) do case - case Upper( LTrim( __StrToken( cLine, 1 ) ) ) == "OBJECT" + case Upper( LTrim( hb_TokenGet( cLine, 1 ) ) ) == "OBJECT" if lStart lStart := .f. else endif - case Upper( LTrim( __StrToken( cLine, 1 ) ) ) == "ARRAY" + case Upper( LTrim( hb_TokenGet( cLine, 1 ) ) ) == "ARRAY" cLine := SubStr( cLine, At( "::", cLine ) ) M->oSelf := Self cLine := StrTran( cLine, "::", "oSelf:" ) @@ -100,7 +100,7 @@ METHOD LoadFromText( cObjectText ) CLASS HBPersistent cLine := RTrim( StrTran( cLine, "=", ":=", , 1 ) ) + " )" cLine := &( cLine ) - case Left( cToken := LTrim( __StrToken( cLine, 1, "=" ) ), 2 ) == "::" + case Left( cToken := LTrim( hb_TokenGet( cLine, 1, "=" ) ), 2 ) == "::" M->oSelf := Self cLine := StrTran( cLine, "::", "oSelf:" ) cLine := StrTran( cLine, "=", ":=", , 1 ) @@ -122,9 +122,9 @@ METHOD SaveToText( cObjectName ) CLASS HBPersistent DEFAULT cObjectName TO "o" + ::ClassName() nIndent += 3 - cObject := iif( nIndent > 0, HB_OsNewLine(), "" ) + Space( nIndent ) + ; + cObject := iif( nIndent > 0, hb_OsNewLine(), "" ) + Space( nIndent ) + ; "OBJECT " + iif( nIndent != 0, "::", "" ) + cObjectName + " AS " + ; - ::ClassName() + HB_OsNewLine() + ::ClassName() + hb_OsNewLine() aProperties := __ClsGetProperties( ::ClassH ) @@ -141,7 +141,7 @@ METHOD SaveToText( cObjectName ) CLASS HBPersistent cObject += ArrayToText( uValue, aProperties[ n ], nIndent ) nIndent -= 3 if n < Len( aProperties ) - cObject += HB_OsNewLine() + cObject += hb_OsNewLine() endif case cType == "O" @@ -149,31 +149,31 @@ METHOD SaveToText( cObjectName ) CLASS HBPersistent cObject += uValue:SaveToText( aProperties[ n ] ) endif if n < Len( aProperties ) - cObject += HB_OsNewLine() + cObject += hb_OsNewLine() endif otherwise if n == 1 - cObject += HB_OsNewLine() + cObject += hb_OsNewLine() endif cObject += Space( nIndent ) + " ::" + ; aProperties[ n ] + " = " + ValToText( uValue ) + ; - HB_OsNewLine() + hb_OsNewLine() endcase endif next - cObject += HB_OsNewLine() + Space( nIndent ) + "ENDOBJECT" + HB_OsNewLine() + cObject += hb_OsNewLine() + Space( nIndent ) + "ENDOBJECT" + hb_OsNewLine() nIndent -= 3 return cObject static function ArrayToText( aArray, cName, nIndent ) - local cArray := HB_OsNewLine() + Space( nIndent ) + "ARRAY ::" + cName + ; - " LEN " + AllTrim( Str( Len( aArray ) ) ) + HB_OsNewLine() + local cArray := hb_OsNewLine() + Space( nIndent ) + "ARRAY ::" + cName + ; + " LEN " + AllTrim( Str( Len( aArray ) ) ) + hb_OsNewLine() local n, uValue, cType for n := 1 to Len( aArray ) @@ -184,7 +184,7 @@ static function ArrayToText( aArray, cName, nIndent ) case cType == "A" nIndent += 3 cArray += ArrayToText( uValue, cName + "[ " + ; - AllTrim( Str( n ) ) + " ]", nIndent ) + HB_OsNewLine() + AllTrim( Str( n ) ) + " ]", nIndent ) + hb_OsNewLine() nIndent -= 3 case cType == "O" @@ -195,15 +195,15 @@ static function ArrayToText( aArray, cName, nIndent ) otherwise if n == 1 - cArray += HB_OsNewLine() + cArray += hb_OsNewLine() endif cArray += Space( nIndent ) + " ::" + cName + ; + "[ " + AllTrim( Str( n ) ) + " ]" + " = " + ; - ValToText( uValue ) + HB_OsNewLine() + ValToText( uValue ) + hb_OsNewLine() endcase next - cArray += HB_OsNewLine() + Space( nIndent ) + "ENDARRAY" + HB_OsNewLine() + cArray += hb_OsNewLine() + Space( nIndent ) + "ENDARRAY" + hb_OsNewLine() return cArray @@ -233,7 +233,7 @@ return cText static function ExtractLine( cText, nFrom ) - local nAt := At( HB_OsNewLine(), cText, nFrom ) + local nAt := At( hb_OsNewLine(), cText, nFrom ) if nAt > 0 cText := Substr( cText, nFrom, nAt - nFrom ) diff --git a/harbour/source/rtl/tbrowse.prg b/harbour/source/rtl/tbrowse.prg index 15c8f1716e..70eca6ba10 100644 --- a/harbour/source/rtl/tbrowse.prg +++ b/harbour/source/rtl/tbrowse.prg @@ -536,8 +536,8 @@ METHOD SetColumnWidth( oCol ) CLASS TBrowse endcase - cHeading := oCol:Heading + ";" - while ( nL := Len( __StrTkPtr( @cHeading, @nTokenPos, ";" ) ) ) > 0 + cHeading := oCol:Heading + while ( nL := Len( hb_TokenPtr( @cHeading, @nTokenPos, ";" ) ) ) > 0 nColWidth := Max( nL, nColWidth ) enddo endif @@ -1484,7 +1484,7 @@ return Self METHOD WriteMLineText( cStr, nPadLen, lHeader, cColor ) CLASS TBrowse - local n, cS + local n local nCol := Col() local nRow := Row() @@ -1496,12 +1496,9 @@ METHOD WriteMLineText( cStr, nPadLen, lHeader, cColor ) CLASS TBrowse DispOut( PadR( cStr, nPadLen ), cColor ) else - // __StrToken needs that even last token be ended with token separator - cS := cStr + ";" - for n := ::nHeaderHeight to 1 step -1 SetPos( nRow + n - 1, nCol ) - DispOut( PadR( __StrToken( @cS, n, ";" ), nPadLen ), cColor ) + DispOut( PadR( hb_TokenGet( @cStr, n, ";" ), nPadLen ), cColor ) next SetPos( nRow, nCol + nPadLen ) @@ -1516,12 +1513,9 @@ METHOD WriteMLineText( cStr, nPadLen, lHeader, cColor ) CLASS TBrowse DispOut( PadR( cStr, nPadLen ), cColor ) else - // __StrToken needs that even last token be ended with token separator - cS := cStr + ";" - for n := 0 to ( ::nFooterHeight - 1 ) SetPos( nRow - n, nCol ) - DispOut( PadR( __StrToken( @cS, ::nFooterHeight - n, ";" ), nPadLen ), cColor ) + DispOut( PadR( hb_TokenGet( @cStr, ::nFooterHeight - n, ";" ), nPadLen ), cColor ) next SetPos( nRow, nCol + nPadLen ) diff --git a/harbour/source/rtl/teditor.prg b/harbour/source/rtl/teditor.prg index 63875bf48b..11972e9467 100644 --- a/harbour/source/rtl/teditor.prg +++ b/harbour/source/rtl/teditor.prg @@ -176,30 +176,13 @@ STATIC function Text2Array(cString, nWordWrapCol) cEOL := WhichEOL(cString) nEOLLen := Len(cEOL) - // __StrTkPtr() needs that string to be tokenized be terminated with a token delimiter - if Rat(cEOL, cString) <> Len(cString) - nEOLLen + 1 - cString += cEOL - endif - nRetLen := 0 ncSLen := Len(cString) - // If cString starts with an EOL delimiter I have to add an empty line since __StrTkPtr - // gives back _next_ token and would skip this first EOL delimiter - if Left(cString, nEOLLen) == cEOL - AAdd(aArray, HBTextLine():New(cLine, .F.)) - nTokPos += nEOLLen - nRetLen += nEOLLen - endif - while nRetLen < ncSLen - /* TOFIX: Note that __StrToken is not able to cope with delimiters longer than one char */ - // Dos - OS/2 - Windows have CRLF as EOL - if nEOLLen > 1 - cLine := StrTran(__StrTkPtr(@cString, @nTokPos, cEOL), SubStr(cEOL, 2), "") - else - cLine := __StrTkPtr(@cString, @nTokPos, cEOL) - endif + + cLine := hb_TokenPtr(@cString, @nTokPos, cEOL) + nRetLen += Len(cLine) + nEOLLen if nWordWrapCol != NIL .AND. Len(cLine) > nWordWrapCol @@ -1066,8 +1049,8 @@ METHOD Hilite() CLASS HBEditor local cEnhanced := "" // Swap CLR_STANDARD and CLR_ENHANCED - cEnhanced += __StrToken(::cColorSpec, 2, ",") + "," - cEnhanced += __StrToken(::cColorSpec, 1, ",") + cEnhanced += hb_TokenGet(::cColorSpec, 2, ",") + "," + cEnhanced += hb_TokenGet(::cColorSpec, 1, ",") ::SetColor(cEnhanced + Right(::cColorSpec, Len(::cColorSpec) - Len(cEnhanced))) @@ -1079,8 +1062,8 @@ METHOD DeHilite() CLASS HBEditor local cStandard := "" // Swap CLR_STANDARD and CLR_ENHANCED back to their original position inside cColorSpec - cStandard += __StrToken(::cColorSpec, 2, ",") + "," - cStandard += __StrToken(::cColorSpec, 1, ",") + cStandard += hb_TokenGet(::cColorSpec, 2, ",") + "," + cStandard += hb_TokenGet(::cColorSpec, 1, ",") ::SetColor(cStandard + Right(::cColorSpec, Len(::cColorSpec) - Len(cStandard)))