You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2002/09/24 21:39:51 UTC

cvs commit: xml-xerces/c/src/xercesc/util XMLString.cpp

tng         2002/09/24 12:39:51

  Modified:    c/src/xercesc/util XMLString.cpp
  Log:
  Modify the fixURI to take a preallocated target string instead of using XMLBuffer.
  
  Revision  Changes    Path
  1.9       +28 -19    xml-xerces/c/src/xercesc/util/XMLString.cpp
  
  Index: XMLString.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLString.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XMLString.cpp	23 Sep 2002 18:42:18 -0000	1.8
  +++ XMLString.cpp	24 Sep 2002 19:39:51 -0000	1.9
  @@ -1742,10 +1742,8 @@
    * 1. Windows: fix 'x:' to 'file:///x:' and convert any backslash to forward slash
    * 2. UNIX: fix '/blah/blahblah' to 'file:///blah/blahblah'
    */
  -void XMLString::fixURI(const XMLCh* const str, XMLBuffer& toFill)
  +void XMLString::fixURI(const XMLCh* const str, XMLCh* const target)
   {
  -    toFill.reset();
  -
       if (!str || !*str)
           return;
   
  @@ -1755,27 +1753,34 @@
       // If starts with a '/' we assume
       // this is an absolute (UNIX) file path and prefix it with file://
       if (colonIdx == -1 && XMLString::indexOf(str, chForwardSlash) == 0) {
  -        const XMLCh FILE_SCHEME[] = {
  -            chLatin_f, chLatin_i, chLatin_l, chLatin_e, chColon,
  -            chForwardSlash, chForwardSlash, chNull};
  -
  -        toFill.set(FILE_SCHEME);
  +        unsigned index = 0;
  +        target[index++] = chLatin_f;
  +        target[index++] = chLatin_i;
  +        target[index++] = chLatin_l;
  +        target[index++] = chLatin_e;
  +        target[index++] = chColon;
  +        target[index++] = chForwardSlash;
  +        target[index++] = chForwardSlash;
   
           // copy the string
           const XMLCh* inPtr = str;
           while (*inPtr)
  -            toFill.append(*inPtr++);
  +            target[index++] = *inPtr++;
   
  -        toFill.append(chNull);
  +        target[index] = chNull;
       }
       else if (colonIdx == 1 && XMLString::isAlpha(*str)) {
           // If starts with a driver letter 'x:' we assume
           // this is an absolute (Windows) file path and prefix it with file:///
  -        const XMLCh FILE_SCHEME[] = {
  -            chLatin_f, chLatin_i, chLatin_l, chLatin_e, chColon,
  -            chForwardSlash, chForwardSlash, chForwardSlash, chNull};
  -
  -        toFill.set(FILE_SCHEME);
  +        unsigned index = 0;
  +        target[index++] = chLatin_f;
  +        target[index++] = chLatin_i;
  +        target[index++] = chLatin_l;
  +        target[index++] = chLatin_e;
  +        target[index++] = chColon;
  +        target[index++] = chForwardSlash;
  +        target[index++] = chForwardSlash;
  +        target[index++] = chForwardSlash;
   
           // copy the string and fix any backward slash
           const XMLCh* inPtr = str;
  @@ -1783,14 +1788,18 @@
               if (*inPtr == chYenSign ||
                   *inPtr == chWonSign ||
                   *inPtr == chBackSlash)
  -                toFill.append(chForwardSlash);
  +                target[index++] = chForwardSlash;
               else
  -                toFill.append(*inPtr);
  +                target[index++] = *inPtr;
               inPtr++;
           }
   
           // cap it with null
  -        toFill.append(chNull);
  +        target[index] = chNull;
  +    }
  +    else {
  +        // not specific case, so just copy the string over
  +        copyString(target, str);
       }
   }
   
  
  
  

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