You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2002/11/07 02:48:50 UTC
cvs commit: xml-xalan/c/src/XSLT CountersTable.cpp CountersTable.hpp
dbertoni 2002/11/06 17:48:50
Modified: c/src/XSLT CountersTable.cpp CountersTable.hpp
Log:
Migrate to unsigned type for node counts.
Revision Changes Path
1.5 +10 -4 xml-xalan/c/src/XSLT/CountersTable.cpp
Index: CountersTable.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/CountersTable.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CountersTable.cpp 24 Sep 2002 06:57:42 -0000 1.4
+++ CountersTable.cpp 7 Nov 2002 01:48:50 -0000 1.5
@@ -87,7 +87,7 @@
-int
+CountersTable::CountType
CountersTable::countNode(
StylesheetExecutionContext& support,
const ElemNumber& numberElem,
@@ -95,7 +95,7 @@
{
assert(numberElem.getID() < m_countersVector.size());
- int count = 0;
+ CountType count = 0;
CounterVectorType& counters = m_countersVector[numberElem.getID()];
@@ -112,7 +112,9 @@
count = counter.getPreviouslyCounted(support, target);
if(count > 0)
+ {
return count;
+ }
}
// In the loop below, we collect the nodes in backwards doc order, so
@@ -123,6 +125,7 @@
// the backwards list (m_newFound) to the forwards list
// (counter.m_countNodes).
count = 0;
+
for(; 0 != target; target = numberElem.getPreviousNode(support, target))
{
// First time in, we should not have to check for previous counts,
@@ -173,14 +176,14 @@
-int
+Counter::CountType
Counter::getPreviouslyCounted(
StylesheetExecutionContext& executionContext,
const XalanNode* node) const
{
const NodeVectorType::size_type n = m_countNodes.size();
- int result = 0;
+ CountType result = 0;
for(NodeVectorType::size_type i = n; i > 0; --i)
{
@@ -191,13 +194,16 @@
// Since the list is in backwards order, the count is
// how many are in the rest of the list.
result = i + m_countNodesStartCount;
+
break;
}
// Try to see if the given node falls after the counted node...
// if it does, don't keep searching backwards.
if(executionContext.isNodeAfter(*countedNode, *node))
+ {
break;
+ }
}
return result;
1.7 +11 -5 xml-xalan/c/src/XSLT/CountersTable.hpp
Index: CountersTable.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/CountersTable.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CountersTable.hpp 24 Sep 2002 06:57:42 -0000 1.6
+++ CountersTable.hpp 7 Nov 2002 01:48:50 -0000 1.7
@@ -92,18 +92,22 @@
*/
struct Counter
{
+ typedef unsigned long CountType;
+
#if defined(XALAN_NO_NAMESPACES)
typedef vector<XalanNode*> NodeVectorType;
#else
typedef std::vector<XalanNode*> NodeVectorType;
#endif
+
+
/**
* The start count from where m_countNodes counts
* from. In other words, the count of a given node
* in the m_countNodes vector is node position +
* m_countNodesStartCount.
*/
- int m_countNodesStartCount;
+ CountType m_countNodesStartCount;
/**
* A vector of all nodes counted so far.
@@ -150,9 +154,9 @@
* Try to find a node that was previously counted. If found, return a
* positive integer that corresponds to the count.
* @param node The node to be counted.
- * @returns The count of the node, or -1 if not found.
+ * @returns The count of the node, or 0 if not found.
*/
- int
+ CountType
getPreviouslyCounted(
StylesheetExecutionContext& support,
const XalanNode* node) const;
@@ -180,6 +184,8 @@
{
public:
+ typedef Counter::CountType CountType;
+
#if defined(XALAN_NO_NAMESPACES)
typedef vector<Counter> CounterVectorType;
typedef vector<CounterVectorType> ElemCounterVectorVectorType;
@@ -223,7 +229,7 @@
* @node The node to count.
* @return The node count, or 0 if not found.
*/
- int
+ CountType
countNode(
StylesheetExecutionContext& executionContext,
const ElemNumber& numberElem,
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org