diff --git a/ChangeLog.txt b/ChangeLog.txt index 32b62c4bab..cc901763ab 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,14 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2015-02-09 00:22 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/rtl/hardcr.c + ! fixed HardCR() to work with codepages using custom character encoding + in which SoftCR can be part of valid character, i.e. UTF8. + + * ChangeLog.txt + * typos in prev my entry + 2015-02-08 23:32 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * include/harbour.hbx * src/vm/hvm.c @@ -19,7 +27,7 @@ * include/hbexprb.c % replace {|e| Break( e ) } with __BreakBlock() function call. __BreakBlock() returns exactly the same codeblock on each call - so using it save memory and improve a little bit speed because + so using it saves memory and improves a little bit speed because it's not necessary to allocate new GC memory block and register it in GC block list. Additionally in MT mode it eliminates mutex lock necessary to register new GC block. diff --git a/src/rtl/hardcr.c b/src/rtl/hardcr.c index 510484d1aa..0addf3da8d 100644 --- a/src/rtl/hardcr.c +++ b/src/rtl/hardcr.c @@ -48,22 +48,44 @@ #include "hbapi.h" #include "hbapiitm.h" +#include "hbapicdp.h" static char * hb_strHardCR( char * pszString, HB_SIZE nStringLen ) { HB_SIZE nStringPos; + PHB_CODEPAGE cdp; HB_TRACE( HB_TR_DEBUG, ( "hb_strHardCR(%s, %" HB_PFS "u)", pszString, nStringLen ) ); - for( nStringPos = 0; nStringPos < nStringLen; nStringPos++ ) + cdp = hb_vmCDP(); + if( HB_CDP_ISCUSTOM( cdp ) ) { - if( pszString[ nStringPos ] == HB_CHAR_SOFT1 && - pszString[ nStringPos + 1 ] == HB_CHAR_SOFT2 ) + HB_WCHAR wc; + + nStringPos = 0; + while( nStringPos < nStringLen ) { - pszString[ nStringPos ] = HB_CHAR_HARD1; + if( pszString[ nStringPos ] == HB_CHAR_SOFT1 && + pszString[ nStringPos + 1 ] == HB_CHAR_SOFT2 ) + { + pszString[ nStringPos ] = HB_CHAR_HARD1; + nStringPos += 2; + } + else if( ! HB_CDPCHAR_GET( cdp, pszString, nStringLen, &nStringPos, &wc ) ) + break; + } + } + else + { + for( nStringPos = 0; nStringPos < nStringLen; nStringPos++ ) + { + if( pszString[ nStringPos ] == HB_CHAR_SOFT1 && + pszString[ nStringPos + 1 ] == HB_CHAR_SOFT2 ) + { + pszString[ nStringPos++ ] = HB_CHAR_HARD1; + } } } - return pszString; }