From a26fe9587156ee0fa9cd49d1c713f7e382b7e6e6 Mon Sep 17 00:00:00 2001 From: Petr Chornyj Date: Sun, 16 Jan 2011 22:07:42 +0000 Subject: [PATCH] 2011-01-17 00:05 UTC+0200 Petr Chornyj (myorg63 at mail.ru) * contrib/hbmxml/hbmxml.c ! Fixed warning reported by bcc55 in mxmlNewCustom() * contrib/hbmxml/tests/testmxml.prg * Changed whitespace_cb() to respect official mxml test result f.e. hb_eol() -> e"\n" --- harbour/ChangeLog | 7 +++ harbour/contrib/hbmxml/hbmxml.c | 54 ++++++++++------------- harbour/contrib/hbmxml/tests/testmxml.prg | 16 +++---- 3 files changed, 38 insertions(+), 39 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 672cc83d41..d3f54268cc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,13 @@ The license applies to all entries newer than 2009-04-28. */ +2011-01-17 00:05 UTC+0200 Petr Chornyj (myorg63 at mail.ru) + * contrib/hbmxml/hbmxml.c + ! Fixed warning reported by bcc55 in mxmlNewCustom() + * contrib/hbmxml/tests/testmxml.prg + * Changed whitespace_cb() to respect official mxml test result + f.e. hb_eol() -> e"\n" + 2011-01-16 17:06 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbmxml/hbmxml.c % optimized user callback calls diff --git a/harbour/contrib/hbmxml/hbmxml.c b/harbour/contrib/hbmxml/hbmxml.c index a007f7f99d..f063cd1b14 100644 --- a/harbour/contrib/hbmxml/hbmxml.c +++ b/harbour/contrib/hbmxml/hbmxml.c @@ -1743,41 +1743,31 @@ static void custom_destroy_cb( void * Cargo ) HB_FUNC( MXMLNEWCUSTOM ) { - mxml_node_t * node = MXML_NO_PARENT; - if( hb_pcount() > 1 ) { + PHB_ITEM pItem = hb_itemClone( hb_param( 2, HB_IT_ANY ) ); + mxml_node_t * parent = NULL; + mxml_node_t * node = NULL; + if( HB_ISNIL( 1 ) || ( HB_ISNUM( 1 ) && hb_parni( 1 ) == MXML_NO_PARENT ) ) - { - PHB_ITEM pItem = hb_itemClone( hb_param( 2, HB_IT_ANY ) ); - node = mxmlNewCustom( MXML_NO_PARENT, pItem, custom_destroy_cb ); - - if( node ) - mxml_node_ret( node, 1 ); - else - hb_itemRelease( pItem ); - } + node = mxmlNewCustom( MXML_NO_PARENT, pItem, custom_destroy_cb ); else { - mxml_node_t * node_parent = mxml_node_param( 1 ); + parent = mxml_node_param( 1 ); - if( node_parent ) - { - PHB_ITEM pItem = hb_itemClone( hb_param( 2, HB_IT_ANY ) ); - node = mxmlNewCustom( node_parent, pItem, custom_destroy_cb ); - - if( node ) - mxml_node_ret( node, 0 ); - else - hb_itemRelease( pItem ); - } - else - MXML_ERR_ARGS; + if( parent != NULL ) + node = mxmlNewCustom( parent, pItem, custom_destroy_cb ); } - } - else - MXML_ERR_ARGS; + if( node != NULL ) + { + mxml_node_ret( node, ( parent != NULL ) ? 0 : 1 ); + return; + } + + hb_itemRelease( pItem ); + } + MXML_ERR_ARGS; } /* @@ -1932,8 +1922,9 @@ HB_FUNC( HB_MXMLGETATTRSARRAY ) int i; mxml_attr_t * attr; - for ( i = node->value.element.num_attrs, attr = node->value.element.attrs ; - i > 0; i --, attr++ ) + for ( i = node->value.element.num_attrs, attr = node->value.element.attrs; + i > 0; + i--, attr++ ) { PHB_ITEM pAttr = hb_itemArrayNew( 2 ); @@ -1963,8 +1954,9 @@ HB_FUNC( HB_MXMLGETATTRS ) hb_hashSetFlags( pAttrs, HB_HASH_KEEPORDER ); - for ( i = node->value.element.num_attrs, attr = node->value.element.attrs ; - i > 0; i --, attr++ ) + for ( i = node->value.element.num_attrs, attr = node->value.element.attrs; + i > 0; + i--, attr++ ) { PHB_ITEM pKey = hb_itemPutStrUTF8( NULL, attr->name ); PHB_ITEM pValue = hb_itemPutStrUTF8( NULL, attr->value ); diff --git a/harbour/contrib/hbmxml/tests/testmxml.prg b/harbour/contrib/hbmxml/tests/testmxml.prg index 5bf13e4017..f364eead44 100644 --- a/harbour/contrib/hbmxml/tests/testmxml.prg +++ b/harbour/contrib/hbmxml/tests/testmxml.prg @@ -658,7 +658,7 @@ FUNCTION whitespace_cb( hNode, nWhere ) /* O - Whitespace string or nil */ */ IF nWhere == MXML_WS_BEFORE_OPEN .OR. nWhere == MXML_WS_AFTER_CLOSE - RETURN hb_eol() + RETURN e"\n" ENDIF ELSEIF cName == "dl" .OR. cName == "ol" .OR. cName == "ul" @@ -666,7 +666,7 @@ FUNCTION whitespace_cb( hNode, nWhere ) /* O - Whitespace string or nil */ * Put a newline before and after list elements... */ - RETURN hb_eol() + RETURN e"\n" ELSEIF cName == "dd" .OR. cName == "dd" .OR. cName == "li" /* @@ -674,13 +674,13 @@ FUNCTION whitespace_cb( hNode, nWhere ) /* O - Whitespace string or nil */ */ IF nWhere == MXML_WS_BEFORE_OPEN - RETURN Space( 8 ) + RETURN e"\t" ELSEIF nWhere == MXML_WS_AFTER_CLOSE - RETURN hb_eol() + RETURN e"\n" ENDIF ELSEIF Left( cName, 4 ) == "?xml" IF nWhere == MXML_WS_AFTER_OPEN - RETURN hb_eol() + RETURN e"\n" ELSE RETURN nil ENDIF @@ -699,14 +699,14 @@ FUNCTION whitespace_cb( hNode, nWhere ) /* O - Whitespace string or nil */ nLevel := 0 ENDIF - RETURN Replicate( Chr( 9 ), nLevel ) + RETURN Replicate( e"\t", nLevel ) ELSEIF nWhere == MXML_WS_AFTER_CLOSE .OR. ; ( ( cName == "group" .OR. cName == "option" .OR. cName == "choice" ) .AND. ; nWhere == MXML_WS_AFTER_OPEN ) - RETURN hb_eol() + RETURN e"\n" ELSEIF nWhere == MXML_WS_AFTER_OPEN .AND. Empty( mxmlGetFirstChild( hNode ) ) - RETURN hb_eol() + RETURN e"\n" ENDIF /*