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 2005/05/12 09:41:45 UTC

cvs commit: xml-xalan/c/src/xalanc/XSLT ElemNumber.cpp ElemNumber.hpp

dbertoni    2005/05/12 00:41:45

  Modified:    c/src/xalanc/XSLT ElemNumber.cpp ElemNumber.hpp
  Log:
  Fix for Jira issue XALANC-508.
  
  Revision  Changes    Path
  1.18      +101 -42   xml-xalan/c/src/xalanc/XSLT/ElemNumber.cpp
  
  Index: ElemNumber.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemNumber.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ElemNumber.cpp	29 Apr 2005 21:39:44 -0000	1.17
  +++ ElemNumber.cpp	12 May 2005 07:41:45 -0000	1.18
  @@ -1338,12 +1338,12 @@
                   break;
               }
           case XalanUnicode::charLetter_I:
  -            long2roman(listElement, true, theResult);
  +            toRoman(listElement, true, theResult);
               break;
   
           case XalanUnicode::charLetter_i:
               {
  -                long2roman(listElement, true, theResult);
  +                toRoman(listElement, true, theResult);
   
                   StylesheetExecutionContext::GetAndReleaseCachedString theGuard(executionContext);
                   
  @@ -1548,25 +1548,14 @@
   
   
   void
  -ElemNumber::tradAlphaCount(
  -            CountType           /* val */,
  -            XalanDOMString&     /* theResult */)
  -{
  -//  @@ JMD: We don't do languages yet, so this is just a placeholder
  -    assert(false);
  -}
  -
  -
  -
  -void
  -ElemNumber::long2roman(
  +ElemNumber::toRoman(
               CountType           val,
               bool                prefixesAreOK,
               XalanDOMString&     theResult)
   {
       if(val == 0)
       {
  -        theResult = XalanUnicode::charDigit_0;;
  +        theResult = XalanUnicode::charDigit_0;
       }
       else if (val > 3999)
       {
  @@ -1582,18 +1571,23 @@
   
           do
           {
  -            while (localValue >= s_romanConvertTable[place].m_postValue)
  +            assert(place < s_romanConvertTableSize);
  +
  +            const DecimalToRoman&   theCurrent =
  +                s_romanConvertTable[place];
  +
  +            while (localValue >= theCurrent.m_postValue)
               {
  -                theResult += s_romanConvertTable[place].m_postLetter;
  -                localValue -= s_romanConvertTable[place].m_postValue;
  +                theResult += theCurrent.m_postLetter;
  +                localValue -= theCurrent.m_postValue;
               }
   
               if (prefixesAreOK)
               {
  -                if (localValue >= s_romanConvertTable[place].m_preValue)
  +                if (localValue >= theCurrent.m_preValue)
                   {
  -                    theResult += s_romanConvertTable[place].m_preLetter;
  -                    localValue -= s_romanConvertTable[place].m_preValue;
  +                    theResult += theCurrent.m_preLetter;
  +                    localValue -= theCurrent.m_preValue;
                   }
               } 
   
  @@ -1906,8 +1900,7 @@
   
   
   const DecimalToRoman    ElemNumber::s_romanConvertTable[] =
  -{
  -    {
  +{    {
           1000,
           { XalanUnicode::charLetter_M, 0 },
           900,
  @@ -1958,6 +1951,8 @@
   };
   
   
  +const size_t    ElemNumber::s_romanConvertTableSize = sizeof(s_romanConvertTable) / sizeof(s_romanConvertTable[0]);
  +
   
   static XalanNumberingResourceBundle     s_staticElalphaResourceBundle(XalanMemMgrs::getDummyMemMgr());
   
  @@ -1967,8 +1962,9 @@
   
   
   static void
  -initializeTraditionalElalphaBundle(MemoryManagerType& theManager, 
  -                                   XalanNumberingResourceBundle&    theBundle)
  +initializeTraditionalElalphaBundle(
  +            MemoryManagerType&              theManager, 
  +            XalanNumberingResourceBundle&   theBundle)
   {
   
   
  @@ -2034,9 +2030,20 @@
       theElalphaDigitsTable.resize(3);
   
       // Swap the empty tables with temporary ones...
  -    XalanDOMCharVectorType(elalphaDigits, elalphaDigits + length(elalphaDigits), theManager).swap(theElalphaDigitsTable[0]);
  -    XalanDOMCharVectorType(elalphaTens, elalphaTens + length(elalphaTens), theManager).swap(theElalphaDigitsTable[1]);
  -    XalanDOMCharVectorType(elalphaHundreds, elalphaHundreds + length(elalphaHundreds), theManager).swap(theElalphaDigitsTable[2]);
  +    XalanDOMCharVectorType(
  +        elalphaDigits,
  +        elalphaDigits + length(elalphaDigits),
  +        theManager).swap(theElalphaDigitsTable[0]);
  +
  +    XalanDOMCharVectorType(
  +        elalphaTens,
  +        elalphaTens + length(elalphaTens),
  +        theManager).swap(theElalphaDigitsTable[1]);
  +
  +    XalanDOMCharVectorType(
  +        elalphaHundreds,
  +        elalphaHundreds + length(elalphaHundreds),
  +        theManager).swap(theElalphaDigitsTable[2]);
   
       // This table will indicate which positions the vectors of digits are in
       // the table...
  @@ -2049,61 +2056,113 @@
       theDigitsTableTable.push_back(1);
       theDigitsTableTable.push_back(0);
   
  -    const XalanDOMString    theLanguageString("el",theManager);
  +    const XalanDOMString    theLanguageString("el", theManager);
   
       // Create an instance...
       XalanNumberingResourceBundle    theElaphaBundle(
           theLanguageString,
           theLanguageString,
           theLanguageString,
  -        XalanDOMCharVectorType(elalphaAlphabet, elalphaAlphabet + length(elalphaAlphabet), theManager),
  -        XalanDOMCharVectorType(elalphaTraditionalAlphabet, elalphaTraditionalAlphabet + length(elalphaTraditionalAlphabet), theManager),
  +        XalanDOMCharVectorType(
  +            elalphaAlphabet,
  +            elalphaAlphabet + length(elalphaAlphabet),
  +            theManager),
  +        XalanDOMCharVectorType(
  +            elalphaTraditionalAlphabet,
  +            elalphaTraditionalAlphabet + length(elalphaTraditionalAlphabet),
  +            theManager),
           XalanNumberingResourceBundle::eLeftToRight,
           XalanNumberingResourceBundle::eMultiplicativeAdditive,
           XalanNumberingResourceBundle::ePrecedes,
           ~NumberType(0),
  -        NumberTypeVectorType(elalphaNumberGroups, elalphaNumberGroups + elalphaNumberGroupsCount, theManager),
  -        NumberTypeVectorType(elalphaMultipliers, elalphaMultipliers + elalphaMultipliersCount, theManager),
  +        NumberTypeVectorType(
  +            elalphaNumberGroups,
  +            elalphaNumberGroups + elalphaNumberGroupsCount,
  +            theManager),
  +        NumberTypeVectorType(
  +            elalphaMultipliers,
  +            elalphaMultipliers + elalphaMultipliersCount,
  +            theManager),
           XalanDOMCharVectorType(theManager),
  -        XalanDOMCharVectorType(elalphaMultiplierChars, elalphaMultiplierChars + length(elalphaMultiplierChars), theManager),
  +        XalanDOMCharVectorType(
  +            elalphaMultiplierChars,
  +            elalphaMultiplierChars + length(elalphaMultiplierChars),
  +            theManager),
           theElalphaDigitsTable,
           theDigitsTableTable,
           theManager);
   
  -
       // Swap it with the one (this avoids making a copy...)
       theBundle.swap(theElaphaBundle);
   }
   
   
   
  +static const XalanDOMChar   s_textStringChars[] =
  +{
  +    XalanUnicode::charLetter_t,
  +    XalanUnicode::charLetter_e,
  +    XalanUnicode::charLetter_x,
  +    XalanUnicode::charLetter_t,
  +    XalanUnicode::charLeftParenthesis,
  +    XalanUnicode::charRightParenthesis,
  +    0
  +};
  +
  +
  +
  +static const XalanDOMChar   s_commentStringChars[] =
  +{
  +    XalanUnicode::charLetter_c,
  +    XalanUnicode::charLetter_o,
  +    XalanUnicode::charLetter_m,
  +    XalanUnicode::charLetter_m,
  +    XalanUnicode::charLetter_e,
  +    XalanUnicode::charLetter_n,
  +    XalanUnicode::charLetter_t,
  +    XalanUnicode::charLeftParenthesis,
  +    XalanUnicode::charRightParenthesis,
  +    0
  +};
  +
  +
  +
  +static const XalanDOMChar   s_solidusStringChars[] =
  +{
  +    XalanUnicode::charSolidus,
  +    0
  +};
  +
  +
  +
   void
   ElemNumber::initialize(MemoryManagerType&  theManager)
   {
  +    s_staticTextString.reset(theManager, s_textStringChars);
   
  -    s_staticTextString.reset( theManager, "text()");
  -
  -    s_staticCommentString.reset( theManager, "comment()");
  +    s_staticCommentString.reset(theManager, s_commentStringChars);
   
  -    s_staticSlashString.reset( theManager, "/");
  +    s_staticSlashString.reset(theManager, s_solidusStringChars);
   
       initializeTraditionalElalphaBundle(theManager, s_staticElalphaResourceBundle);
   }
   
   
  +
   void
   ElemNumber::terminate()
   {
       MemoryManagerType& theManager = XalanMemMgrs::getDummyMemMgr();
   
  -    releaseMemory(s_staticTextString, theManager );
  -    releaseMemory(s_staticCommentString, theManager );
  -    releaseMemory(s_staticSlashString, theManager );
  +    releaseMemory(s_staticTextString, theManager);
  +    releaseMemory(s_staticCommentString, theManager);
  +    releaseMemory(s_staticSlashString, theManager);
   
       XalanNumberingResourceBundle(theManager).swap(s_staticElalphaResourceBundle);
   }
   
   
  +
   const XPath*
   ElemNumber::getXPath(unsigned int   index) const
   {
  
  
  
  1.10      +2 -17     xml-xalan/c/src/xalanc/XSLT/ElemNumber.hpp
  
  Index: ElemNumber.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemNumber.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ElemNumber.hpp	8 Nov 2004 18:18:56 -0000	1.9
  +++ ElemNumber.hpp	12 May 2005 07:41:45 -0000	1.10
  @@ -289,22 +289,6 @@
   			XalanDOMString&				theResult);
   
   	/**
  -	 * Convert a long integer into traditional alphabetic counting, in other words
  -	 * count using the traditional numbering.
  -	 * @param val Value to convert -- must be greater than zero.
  -	 * @param table a table containing one character for each digit in the radix
  -	 * @return String representing alpha count of number.
  -	 * @see XSLProcessor#DecimalToRoman
  -	 *
  -	 * Note that the radix of the conversion is inferred from the size
  -	 * of the table.
  -	 */
  -	static void
  -	tradAlphaCount(
  -			CountType			val,
  -			XalanDOMString&		theResult);
  -
  -	/**
   	 * Convert an integral into roman numerals.
   	 * @param val Value to convert.
   	 * @param prefixesAreOK true to enable prefix notation (e.g. 4 = "IV"), false to disable prefix notation (e.g. 4 = "IIII").
  @@ -313,7 +297,7 @@
   	 * @see m_romanConvertTable
   	 */
   	static void
  -	long2roman(
  +	toRoman(
   			CountType			val,
   			bool				prefixesAreOK,
   			XalanDOMString&		theResult);
  @@ -434,6 +418,7 @@
   	 */
   	static const DecimalToRoman				s_romanConvertTable[];
   
  +    static const size_t                     s_romanConvertTableSize;
   	/**
   	 * numbering resource bundle for Greek numbering.
   	 */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org