You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@locus.apache.org on 2000/10/14 00:47:58 UTC

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

andyh       00/10/13 15:47:58

  Modified:    c/src/util XMLString.cpp XMLString.hpp
  Log:
  Fix bug (failure to null-terminate result) in XMLString::trim().
  Patch contributed by Nadav Aharoni
  
  Revision  Changes    Path
  1.12      +8 -3      xml-xerces/c/src/util/XMLString.cpp
  
  Index: XMLString.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/XMLString.cpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XMLString.cpp	2000/07/25 22:28:15	1.11
  +++ XMLString.cpp	2000/10/13 22:47:57	1.12
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLString.cpp,v 1.11 2000/07/25 22:28:15 aruna1 Exp $
  + * $Id: XMLString.cpp,v 1.12 2000/10/13 22:47:57 andyh Exp $
    */
   
   
  @@ -63,6 +63,7 @@
   //  Includes
   // ---------------------------------------------------------------------------
   #include <string.h>
  +#include <ctype.h>
   #include <util/ArrayIndexOutOfBoundsException.hpp>
   #include <util/IllegalArgumentException.hpp>
   #include <util/Janitor.hpp>
  @@ -534,13 +535,13 @@
       unsigned int skip, scrape;
       for (skip = 0; skip < len; skip++)
       {
  -        if (toTrim[skip] > ' ')
  +        if (! isspace(toTrim[skip]))
               break;
       }
   
       for (scrape = len; scrape > skip; scrape--)
       {
  -        if (toTrim[scrape - 1] > ' ')
  +        if (! isspace(toTrim[scrape - 1] ))
               break;
       }
   
  @@ -554,6 +555,8 @@
           unsigned int index = 0;
           while (toTrim[skip])
               toTrim[index++] = toTrim[skip++];
  +
  +        toTrim[index] = 0;
       }
   }
   
  @@ -1059,6 +1062,8 @@
           unsigned int index = 0;
           while (toTrim[skip])
               toTrim[index++] = toTrim[skip++];
  +
  +        toTrim[index] = 0;
       }
   }
   
  
  
  
  1.14      +8 -2      xml-xerces/c/src/util/XMLString.hpp
  
  Index: XMLString.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/XMLString.hpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XMLString.hpp	2000/04/12 18:42:15	1.13
  +++ XMLString.hpp	2000/10/13 22:47:57	1.14
  @@ -56,6 +56,10 @@
   
   /*
    * $Log: XMLString.hpp,v $
  + * Revision 1.14  2000/10/13 22:47:57  andyh
  + * Fix bug (failure to null-terminate result) in XMLString::trim().
  + * Patch contributed by Nadav Aharoni
  + *
    * Revision 1.13  2000/04/12 18:42:15  roddey
    * Improved docs in terms of what 'max chars' means in the method
    * parameters.
  @@ -872,13 +876,15 @@
           , const unsigned int    maxChars
       );
   
  -    /** Trims off extra space characters from the end of the string
  +    /** Trims off extra space characters from the start and end of the string,
  +      * moving the non-space string content back to the start.
         * @param toTrim The string to be trimmed. On return this contains the
         * trimmed string
         */
       static void trim(char* const toTrim);
   
  -    /** Trims off extra space characters from the end of the string
  +    /** Trims off extra space characters from the start and end of the string,
  +      * moving the non-space string content back to the start.
         * @param toTrim The string to be trimmed. On return this contains
         * the trimmed string
         */