From 1725166be375ed32512462def5cd46e12be30fb2 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 10 Oct 2011 18:59:35 +0000 Subject: [PATCH] 2011-10-10 20:59 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/natmsg.c ! modified __NATISAFFIRM() and __NATISNEGATIVE() to work with multibyte CPs --- harbour/ChangeLog | 5 +++++ harbour/src/rtl/natmsg.c | 47 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c32ada5f79..75efa952a8 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,11 @@ The license applies to all entries newer than 2009-04-28. */ +2011-10-10 20:59 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/src/rtl/natmsg.c + ! modified __NATISAFFIRM() and __NATISNEGATIVE() to work with + multibyte CPs + 2011-10-10 19:50 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbapi.h * harbour/src/rtl/cdpapi.c diff --git a/harbour/src/rtl/natmsg.c b/harbour/src/rtl/natmsg.c index 2af03d033e..8437b1319a 100644 --- a/harbour/src/rtl/natmsg.c +++ b/harbour/src/rtl/natmsg.c @@ -65,6 +65,7 @@ #include "hbapi.h" #include "hbapiitm.h" #include "hbapilng.h" +#include "hbapicdp.h" /* NOTE: Ad-hoc names mostly taken from various Clipper source files. These should be named properly if exported outside this file. @@ -93,16 +94,54 @@ static const char * hb_nationGetMsg( int iMsg ) HB_FUNC( __NATISAFFIRM ) { - PHB_ITEM pItem = hb_param( 1, HB_IT_STRING ); + HB_SIZE nLen = hb_parclen( 1 ); + HB_BOOL fIS = HB_FALSE; - hb_retl( pItem && hb_itemGetCLen( pItem ) >= 1 && hb_charUpper( hb_itemGetCPtr( pItem )[ 0 ] ) == hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + _LF_YN - 1 )[ 0 ] ); + if( nLen > 0 ) + { + const char * szYesNo = hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + _LF_YN - 1 ); + HB_SIZE nStr = 0; + + while( szYesNo[ nStr ] && szYesNo[ nStr ] != '/' ) + ++nStr; + + if( nStr && nLen >= nStr ) + { + PHB_CODEPAGE cdp = hb_vmCDP(); + if( cdp ) + fIS = hb_cdpicmp( hb_parc( 1 ), nLen, szYesNo, nStr, cdp, HB_FALSE ); + else + fIS = hb_strnicmp( hb_parc( 1 ), szYesNo, nStr ); + } + } + hb_retl( fIS ); } HB_FUNC( __NATISNEGATIVE ) { - PHB_ITEM pItem = hb_param( 1, HB_IT_STRING ); + HB_SIZE nLen = hb_parclen( 1 ); + HB_BOOL fIS = HB_FALSE; - hb_retl( pItem && hb_itemGetCLen( pItem ) >= 1 && hb_charUpper( hb_itemGetCPtr( pItem )[ 0 ] ) == hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + _LF_YN - 1 )[ 2 ] ); + if( nLen > 0 ) + { + const char * szYesNo = hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + _LF_YN - 1 ); + HB_SIZE nStr; + + while( *szYesNo ) + if( *szYesNo++ == '/' ) + break; + nStr = strlen( szYesNo ); + + if( nStr && nLen >= nStr ) + { + PHB_CODEPAGE cdp = hb_vmCDP(); + if( cdp ) + fIS = hb_cdpicmp( hb_parc( 1 ), nLen, szYesNo, nStr, cdp, HB_FALSE ); + else + fIS = hb_strnicmp( hb_parc( 1 ), szYesNo, nStr ); + } + } + hb_retl( fIS ); } HB_FUNC( __NATMSG )