← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/markos-scratch into lp:zorba

 

Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch into lp:zorba.

Commit message:
Fixed 2 compiler warnings (one of them actually being a bug in  determining the IsId property of constructed attribute nodes)

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/126869

Fixed 2 compiler warnings (one of them actually being a bug in determining the IsId property of constructed attribute nodes)
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/126869
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-09-27 22:25:40 +0000
+++ ChangeLog	2012-09-28 07:30:33 +0000
@@ -40,6 +40,7 @@
   * Fixed bug #867227 (Improved error message for missing commas)
   * Fixed bug #1024033 and #1023170 (segfaults in parse-xml:parse())
   * Fixed bug #898792 (Dynamically computed strings can now be cast to xs:QName)
+  * Fixed bug in determining the IsId property of constructed attribute nodes
   * Fixed bug #1034990 (text serialization with jsoniq fails)
   * Fixed bugs #899364 and 899363 (throw XQST0103 in case of non-distinct window
     variables)

=== modified file 'src/api/serialization/serializer.cpp'
--- src/api/serialization/serializer.cpp	2012-09-21 04:09:29 +0000
+++ src/api/serialization/serializer.cpp	2012-09-28 07:30:33 +0000
@@ -123,10 +123,10 @@
   :
   ser(the_serializer),
   tr(the_stream),
-  previous_item(INVALID_ITEM),
+  thePreviousItemKind(INVALID_ITEM),
   theChildIters(8),
   theFirstFreeChildIter(0),
-  isFirstElementNode(true),
+  theIsFirstElementNode(true),
   theEmitAttributes(aEmitAttributes)
 {
   for (ulong i = 0; i < 8; i++)
@@ -445,7 +445,7 @@
 
   if (item->isAtomic())
   {
-    if (previous_item == PREVIOUS_ITEM_WAS_TEXT)
+    if (thePreviousItemKind == PREVIOUS_ITEM_WAS_TEXT)
       tr << " ";
 
     if (item->isStreamable())
@@ -453,7 +453,7 @@
     else
       emit_expanded_string(item->getStringValue().c_str(), item->getStringValue().size());
 
-    previous_item = PREVIOUS_ITEM_WAS_TEXT;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT;
   }
   else if (!theEmitAttributes 
         && item->getNodeKind() == store::StoreConsts::attributeNode)
@@ -479,7 +479,7 @@
   {
     emit_node_children(item, depth);
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     break;
   }
@@ -489,10 +489,10 @@
     const zstring& prefix = qnameItem->getPrefix();
     const zstring& local = qnameItem->getLocalName();
 
-    if (isFirstElementNode)
+    if (theIsFirstElementNode)
     {
       emit_doctype(local);
-      isFirstElementNode = false;
+      theIsFirstElementNode = false;
     }
     else if (ser->indent && depth == 0)
     {
@@ -504,7 +504,7 @@
     else
       tr << "<" << prefix << ":" << local;
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     bool should_remove_binding = emit_bindings(item, depth);
 
@@ -525,7 +525,7 @@
       tr << "/>";
     }
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     break;
   }
@@ -547,7 +547,7 @@
 
     tr << "\"";
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     break;
   }
@@ -558,14 +558,15 @@
 
     emit_text_node(item, text);
 
+    // Put a space between consecutive text nodes (or a text node and an
+    // atomic item), unless the text node contains whitespace only.
     if (!ascii::is_whitespace(text.c_str()))
     {
-      // ignore whitespace text nodes when doing indentation
-      previous_item = PREVIOUS_ITEM_WAS_TEXT;
+      thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT;
     }
     else
     {
-      previous_item = PREVIOUS_ITEM_WAS_NODE;
+      thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
     }
 
     break;
@@ -573,7 +574,7 @@
   case store::StoreConsts::commentNode:
   {
     tr << "<!--" << item->getStringValue() << "-->";
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     break;
   }
@@ -581,7 +582,7 @@
   {
     tr << "<?" << item->getTarget() << " " << item->getStringValue() << "?>";
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     break;
   }
@@ -741,19 +742,17 @@
 ********************************************************************************/
 bool serializer::emitter::emit_bindings(const store::Item* item, int depth)
 {
-  // emit namespace bindings
   store::NsBindings nsBindings;
+
   if (depth == 0)
   {
     item->getNamespaceBindings(nsBindings);
   }
   else
   {
-    //item->getNamespaceBindings(nsBindings, store::StoreConsts::ONLY_LOCAL_NAMESPACES);
     item->getNamespaceBindings(nsBindings);
 
     store::Item* nodeName = item->getNodeName();
-
     const zstring& prefix = nodeName->getPrefix();
     const zstring& nsuri = nodeName->getNamespace();
     if (prefix.empty() && nsuri.empty())
@@ -789,18 +788,17 @@
           }
           else if (ser->undeclare_prefixes == PARAMETER_VALUE_YES)
           {
-            tr << " xmlns";
-            if (nsBindings[i].first.size() > 0)
-              tr << ":" <<  nsBindings[i].first;
-            tr << "=\"\"";
+            tr << " xmlns:" <<  nsBindings[i].first << "=\"\"";
           }
         }
       }
       else
       {
         tr << " xmlns";
+
         if (!nsBindings[i].first.empty())
           tr << ":" <<  nsBindings[i].first;
+
         tr << "=\"" << nsBindings[i].second << "\"";
       }
     }
@@ -841,11 +839,11 @@
 ********************************************************************************/
 bool serializer::emitter::havePrefix(const zstring& pre) const
 {
-  for (unsigned long i = 0; i < theBindings.size(); ++i)
+  for (csize i = 0; i < theBindings.size(); ++i)
   {
     const store::NsBindings& nsBindings = theBindings[i];
 
-    for (unsigned long j = 0; j < nsBindings.size(); ++j)
+    for (csize j = 0; j < nsBindings.size(); ++j)
     {
       if (nsBindings[j].first == pre)
         return true;
@@ -1410,10 +1408,10 @@
 
     unsigned closed_parent_tag = 0;
 
-    if (isFirstElementNode)
+    if (theIsFirstElementNode)
     {
       emit_doctype(qname);
-      isFirstElementNode = false;
+      theIsFirstElementNode = false;
     }
 
     // If a meta element has been added to the head element as described above,
@@ -1429,7 +1427,7 @@
 
     tr << "<" << qname;
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     bool should_remove_binding = emit_bindings(item, depth);
 
@@ -1489,7 +1487,7 @@
       }
     }
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     break;
   }
@@ -1516,7 +1514,7 @@
       tr << "\"";
     }
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     break;
   }
@@ -1548,21 +1546,21 @@
       tr << item->getStringValue();  // no character expansion
     }
 
-    previous_item = PREVIOUS_ITEM_WAS_TEXT;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT;
     break;
   }
   case store::StoreConsts::commentNode:
   {
     tr << "<!--" << item->getStringValue() << "-->";
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
     break;
   }
   case store::StoreConsts::piNode:
   {
     tr << "<?" << item->getTarget() << " " << item->getStringValue() << "?>";
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
     break;
   }
   default:
@@ -1605,10 +1603,10 @@
     const store::Item* element_parent = item->getParent();
     unsigned closed_parent_tag = 0;
 
-    if (isFirstElementNode)
+    if (theIsFirstElementNode)
     {
       emit_doctype(item->getNodeName()->getStringValue());
-      isFirstElementNode = false;
+      theIsFirstElementNode = false;
     }
 
     // If a meta element has been added to the head element as described above
@@ -1628,7 +1626,7 @@
 
     tr << "<" << nodename;
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     // If there is a head element, and the include-content-type parameter has
     // the value yes, the HTML output method MUST add a meta element as the
@@ -1701,7 +1699,7 @@
         tr << ">" << "</" << nodename << ">";
     }
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
   }
   else
   {
@@ -1820,11 +1818,11 @@
     unsigned long namespaces_emited = 0;
     store::NsBindings::size_type ns_size = 0;
 
-    if (isFirstElementNode)
+    if (theIsFirstElementNode)
     {
       // TODO: emit doctype declaration
       // emit_doctype(qname->getLocalName());
-      isFirstElementNode = false;
+      theIsFirstElementNode = false;
     }
 
     if (theSAX2ContentHandler)
@@ -2058,16 +2056,14 @@
 #ifdef ZORBA_WITH_JSON
   if (item->isJSONItem())
   {
-    throw ZORBA_EXCEPTION(
-        jerr::JNSE0022,
-        ERROR_PARAMS("text", item->getType()->getStringValue())
-      );
+    throw ZORBA_EXCEPTION(jerr::JNSE0022,
+    ERROR_PARAMS("text", item->getType()->getStringValue()));
   }
 #endif
 
   if (item->isAtomic())
   {
-    if (previous_item == PREVIOUS_ITEM_WAS_TEXT)
+    if (thePreviousItemKind == PREVIOUS_ITEM_WAS_TEXT)
       tr << " ";
 
     if (item->isStreamable())
@@ -2075,13 +2071,12 @@
     else
       tr << item->getStringValue();
 
-    previous_item = PREVIOUS_ITEM_WAS_TEXT;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT;
   }
   else if (item->getNodeKind() == store::StoreConsts::attributeNode)
   {
-    throw XQUERY_EXCEPTION(
-      err::SENR0001, ERROR_PARAMS( item->getStringValue(), ZED( AttributeNode ) )
-    );
+    throw XQUERY_EXCEPTION(err::SENR0001,
+    ERROR_PARAMS(item->getStringValue(), ZED( AttributeNode)));
   }
   else
   {
@@ -2101,28 +2096,28 @@
   }
   else if (item->getNodeKind() == store::StoreConsts::elementNode)
   {
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
 
     emit_node_children(item, depth);
 
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
   }
   else if (item->getNodeKind() == store::StoreConsts::attributeNode )
   {
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
   }
   else if (item->getNodeKind() == store::StoreConsts::textNode)
   {
     tr << item->getStringValue();
-    previous_item = PREVIOUS_ITEM_WAS_TEXT;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT;
   }
   else if (item->getNodeKind() == store::StoreConsts::commentNode)
   {
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
   }
   else if (item->getNodeKind() == store::StoreConsts::piNode )
   {
-    previous_item = PREVIOUS_ITEM_WAS_NODE;
+    thePreviousItemKind = PREVIOUS_ITEM_WAS_NODE;
   }
   else
   {

=== modified file 'src/api/serialization/serializer.h'
--- src/api/serialization/serializer.h	2012-09-20 04:54:07 +0000
+++ src/api/serialization/serializer.h	2012-09-28 07:30:33 +0000
@@ -216,9 +216,9 @@
      * @param aEmitAttributes If true, attributes are emitted.
      */
     emitter(
-        serializer* the_serializer, 
-        std::ostream& the_stream,
-        bool aEmitAttributes = false);
+        serializer* serializer, 
+        std::ostream& stream,
+        bool emitAttributes = false);
 
     /**
      * Outputs the start of the serialized document, which, depending on
@@ -329,13 +329,13 @@
       INVALID_ITEM,
       PREVIOUS_ITEM_WAS_TEXT,
       PREVIOUS_ITEM_WAS_NODE
-    }                                     previous_item;
+    }                                     thePreviousItemKind;
 
     std::vector<store::ChildrenIterator*> theChildIters;
     ulong                                 theFirstFreeChildIter;
     store::AttributesIterator           * theAttrIter;
 
-    bool                                  isFirstElementNode;
+    bool                                  theIsFirstElementNode;
     bool                                  theEmitAttributes;
   };
 
@@ -359,9 +359,6 @@
 
   protected:
     virtual void emit_doctype(const zstring& elementName);
-
-  protected:
-    bool theEmitAttributes;
   };
 
   ///////////////////////////////////////////////////////////

=== modified file 'src/compiler/expression/expr_put.cpp'
--- src/compiler/expression/expr_put.cpp	2012-09-19 18:18:02 +0000
+++ src/compiler/expression/expr_put.cpp	2012-09-28 07:30:33 +0000
@@ -449,11 +449,12 @@
 
   theTryExpr->put(os);
 
-  ulong numClauses = (ulong)theCatchClauses.size();
+  csize numClauses = theCatchClauses.size();
 
-  for (ulong i = 0; i < numClauses; ++i)
+  for (csize i = 0; i < numClauses; ++i)
   {
-    catch_clause* cc = theCatchClauses[i];
+    // TODO: print the error codes and vars of the catch clause
+    //catch_clause* cc = theCatchClauses[i];
     os << indent << "CATCH ";
     os << "\n";
     theCatchExprs[i]->put(os);
@@ -465,7 +466,7 @@
 ostream& eval_expr::put(ostream& os) const
 {
   BEGIN_PUT( eval_expr );
-  for (ulong i = 0; i < theArgs.size(); i++)
+  for (csize i = 0; i < theArgs.size(); i++)
   {
     os << indent << "using $" << theVars[i]->get_name()->getStringValue() << " := [";
     os << endl << inc_indent;

=== modified file 'src/runtime/core/constructors.cpp'
--- src/runtime/core/constructors.cpp	2012-09-17 00:36:37 +0000
+++ src/runtime/core/constructors.cpp	2012-09-28 07:30:33 +0000
@@ -621,14 +621,12 @@
     // (bug 955135)
     if (theRaiseXQDY0074)
     {
-      RAISE_ERROR(err::XQDY0074, loc,
-      ERROR_PARAMS("", ZED(NoEmptyLocalname)));
+      RAISE_ERROR(err::XQDY0074, loc, ERROR_PARAMS("", ZED(NoEmptyLocalname)));
     }
 
     if (theRaiseXQDY0044)
     {
-      RAISE_ERROR(err::XQDY0044, loc,
-      ERROR_PARAMS(theQName->getStringValue()));
+      RAISE_ERROR(err::XQDY0044, loc, ERROR_PARAMS(theQName->getStringValue()));
     }
   }
 
@@ -647,22 +645,14 @@
 
     if (qname->getLocalName().empty())
     {
-      throw XQUERY_EXCEPTION(
-        err::XQDY0074,
-        ERROR_PARAMS( "", ZED( NoEmptyLocalname ) ),
-        ERROR_LOC( loc )
-      );
+      RAISE_ERROR(err::XQDY0074, loc, ERROR_PARAMS("", ZED(NoEmptyLocalname)));
     }
 
     if (ZSTREQ(qname->getNamespace(), "http://www.w3.org/2000/xmlns/";) ||
         (qname->getNamespace().empty() &&
          ZSTREQ(qname->getLocalName(), "xmlns")))
     {
-      throw XQUERY_EXCEPTION(
-        err::XQDY0044,
-        ERROR_PARAMS( qname->getStringValue() ),
-        ERROR_LOC( loc )
-      );
+      RAISE_ERROR(err::XQDY0044, loc, ERROR_PARAMS(qname->getStringValue()));
     }
   }
   else
@@ -682,7 +672,7 @@
   }
 
   // normalize value of xml:id
-  if (theIsId)
+  if (isId)
   {
     ascii::normalize_whitespace(lexicalValue);
   }
@@ -700,7 +690,7 @@
                                         typeName,
                                         typedValue);
   STACK_PUSH(true, state);
-  STACK_END (state);
+  STACK_END(state);
 }
 
 


Follow ups