Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.

Commit message:
Removed double-tree printing.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/207332

Removed double-tree printing.
-- 
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/207332
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'bin/zorbacmd.cpp'
--- bin/zorbacmd.cpp	2014-02-10 01:15:42 +0000
+++ bin/zorbacmd.cpp	2014-02-20 00:55:20 +0000
@@ -227,12 +227,14 @@
   return true;
 }
 
-bool populateDynamicContext( Zorba *zorba, XmlDataManager *xmlMgr,
-                             DynamicContext *dctx ) {
+bool populateDynamicContext( Zorba *zorba, DynamicContext *dctx ) {
   ZorbaCmdProperties const &zc_props = ZorbaCmdProperties::instance();
 
+  XmlDataManager_t xmlMgr;
   if ( !zc_props.ctx_item_.empty() ) {
     ifstream is( zc_props.ctx_item_.c_str() );
+    if ( !xmlMgr )
+      xmlMgr = zorba->getXmlDataManager();
     Item doc( xmlMgr->parseXML( is ) );
     dctx->setContextItem( doc );
   }
@@ -243,6 +245,8 @@
     try {
       if ( i->inline_file ) {
         ifstream is( i->var_value.c_str() );
+          if ( !xmlMgr )
+            xmlMgr = zorba->getXmlDataManager();
         Item doc( xmlMgr->parseXML( is ) );
         dctx->setVariable( i->var_name, doc );
       } else {
@@ -321,7 +325,7 @@
 #endif /* ZORBA_WITH_FILE_ACCESS */
 }
 
-static int compileAndExecute( Zorba *zorba, XmlDataManager *xmlDataMgr,
+static int compileAndExecute( Zorba *zorba,
                               StaticContext_t &sctx,
                               string const &qfilepath,
                               istream &qstream,
@@ -383,6 +387,7 @@
 
   XQuery_t query;
   DiagnosticHandler diagnosticHandler;
+  XmlDataManager_t xmlDataMgr;
 
   for ( unsigned long exec = 0; exec < lNumExecutions; ++exec ) {
     if ( zc_props.timing_ )
@@ -467,7 +472,7 @@
         // Populate the dynamic context
         try {
           DynamicContext *const dctx = query->getDynamicContext();
-          if ( !populateDynamicContext( zorba, xmlDataMgr, dctx ) ) {
+          if ( !populateDynamicContext( zorba, dctx ) ) {
             print_help();
             return 21;
           }
@@ -517,7 +522,8 @@
     //
     if ( zc_props.timing_ ) {
       timers.startTimer( Timers::unload, exec );
-
+      if ( !xmlDataMgr )
+        xmlDataMgr = zorba->getXmlDataManager();
       DocumentManager *const docMgr = xmlDataMgr->getDocumentManager();
       ItemSequence_t docsSeq = docMgr->availableDocuments();
       Iterator_t i( docsSeq->getIterator() );
@@ -639,8 +645,6 @@
   void *const store = StoreManager::getStore();
   Zorba *const zorba = Zorba::getInstance( store );
 
-  XmlDataManager_t xmlDataMgr = zorba->getXmlDataManager();
-
 #ifdef DO_AUDIT
   audit::Provider* lAuditProvider = zorba->getAuditProvider();
 
@@ -783,7 +787,6 @@
       Timers queryTiming( zc_props.multiple_ );
 
       int status = compileAndExecute(zorba,
-                                     xmlDataMgr,
                                      sctx,
                                      path,
                                      *qstream,
@@ -828,11 +831,8 @@
         hints.opt_level = ZORBA_OPT_LEVEL_O0;
 
         query->compile( *lXQ.get(), hints );
-        if (!populateDynamicContext(zorba, xmlDataMgr,
-                                    query->getDynamicContext()))
-        {
+        if (!populateDynamicContext(zorba, query->getDynamicContext()))
           return 9;
-        }
 
         Zorba_SerializerOptions ser_opts( zc_props.serialization_params_ );
         set_serializer_opts( ser_opts );

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to