jberry      2003/02/05 10:11:41

  Modified:    c/src/xercesc/util/Compilers CodeWarriorDefs.cpp
                        CodeWarriorDefs.hpp
  Log:
  Partial patch to address bug #14599 by Zeid Derhally at Metrowerks in support of 
CodeWarrior for Windows
  
  Revision  Changes    Path
  1.4       +74 -2     xml-xerces/c/src/xercesc/util/Compilers/CodeWarriorDefs.cpp
  
  Index: CodeWarriorDefs.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Compilers/CodeWarriorDefs.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CodeWarriorDefs.cpp       22 Aug 2002 23:57:02 -0000      1.3
  +++ CodeWarriorDefs.cpp       5 Feb 2003 18:11:41 -0000       1.4
  @@ -60,12 +60,14 @@
   
   #include <xercesc/util/XercesDefs.hpp>
   #include <ctype.h>
  +#include <string.h>
  +#include <stdlib.h>
   
   // These functions are needed because MacOS doesn't define them
   //   (these routines are defined in CW 8 by extras.h, but there is no MachO
   //   library for extras).
   
  -#if __MACH__ && __MWERKS__
  +#if __MACH__
   // Compare lexigraphically two strings
   int stricmp(const char *s1, const char *s2)
   {
  @@ -96,4 +98,74 @@
       return 0;
   }
   #endif
  +
  +
  +#if defined(_WIN32) || defined(WIN32)
  +int mbswcslen(const char * s, const unsigned int n)
  +{
  +     int     result;
  +     char *  source;
  +     int count = -1;
  +     size_t  source_len;
  +     
  +     source_len = strlen(s);
  +
  +    source      = (char *)s;
  +    
  +    for (count = 0; count < n; count++)
  +    {
  +     if (*source)
  +     {
  +             result = mbtowc(0, source, source_len);
  +             if (result > 0)
  +             {
  +                     source += result;
  +                     source_len -= result;
  +             }
  +             else
  +                     return((size_t)-1);                                            
                 /*- mm 011102 -*/
  +        }
  +        else
  +             break;
  +    }
  +
  +     return(count);
  +}
  +
  +int wcsmbslen(const wchar_t * pwcs, const unsigned int n)
  +{
  +     int     count = 0;
  +     int     result;
  +     wchar_t * source;
  +     char    temp[3];
  +     
  +     if (!pwcs)
  +             return (0);
  +     
  +     source = (wchar_t*)pwcs;
  +     
  +     while(count <= n)
  +     {
  +             if (!*source)
  +             {
  +                     break;
  +             }
  +             else
  +             {
  +                     result = wctomb(temp, *source++);
  +                     if ((count + result) <= n)
  +                     {
  +                             count += result;
  +                     }
  +                     else
  +                             break;
  +             }
  +     }
  +                     
  +     return(count);
  +}
  +#endif
  +
  +
  +
   
  
  
  
  1.9       +27 -6     xml-xerces/c/src/xercesc/util/Compilers/CodeWarriorDefs.hpp
  
  Index: CodeWarriorDefs.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Compilers/CodeWarriorDefs.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CodeWarriorDefs.hpp       4 Nov 2002 14:45:20 -0000       1.8
  +++ CodeWarriorDefs.hpp       5 Feb 2003 18:11:41 -0000       1.9
  @@ -64,19 +64,30 @@
   // ---------------------------------------------------------------------------
   //  Include some runtime files that will be needed product wide
   // ---------------------------------------------------------------------------
  -//#include <sys/types.h>  // for size_t and ssize_t
  -//#include <limits.h>  // for MAX of size_t and ssize_t
  +//#include <sys/types.h>     // for size_t and ssize_t
  +//#include <limits.h>                // for MAX of size_t and ssize_t
   //#include <extras.h>
   
  +#if defined(_WIN32) || defined(WIN32)
  +#include <wchar.h>
  +#include <wctype.h>
  +#endif
  + 
  +
   // ---------------------------------------------------------------------------
   //  A define in the build for each project is also used to control whether
   //  the export keyword is from the project's viewpoint or the client's.
   //  These defines provide the platform specific keywords that they need
   //  to do this.
   // ---------------------------------------------------------------------------
  -#define PLATFORM_EXPORT __declspec(export)
  -#define PLATFORM_IMPORT __declspec(import)
  -
  +#if defined(macintosh)
  +#define PLATFORM_EXPORT              __declspec(export)
  +#define PLATFORM_IMPORT              __declspec(import)
  +#elif defined(_WIN32) || defined(WIN32)
  +#define PLATFORM_EXPORT     __declspec(dllexport)
  +#define PLATFORM_IMPORT     __declspec(dllimport)
  +#endif
  + 
   // ---------------------------------------------------------------------------
   //  Indicate that we do not support native bools
   //  If the compiler can handle boolean itself, do not define it
  @@ -100,7 +111,11 @@
   // ---------------------------------------------------------------------------
   //  Define our version of the XML character
   // ---------------------------------------------------------------------------
  +#if defined(macintosh)
   typedef unsigned short  XMLCh;
  +#elif defined(_WIN32) || defined(WIN32)
  +typedef wchar_t                      XMLCh;
  +#endif
   
   // ---------------------------------------------------------------------------
   //  Define unsigned 16 and 32 bits integers
  @@ -143,6 +158,12 @@
   #if __MACH__ && __MWERKS__
   int stricmp(const char* const str1, const char* const  str2);
   int strnicmp(const char* const str1, const char* const  str2, const unsigned int 
count);
  +#endif
  +
  +#if __MWERKS__ && (defined(_WIN32) || defined(WIN32))
  +/* used in place of calling mbstowcs or wcstombs with a NULL destination */
  +int mbswcslen(const char * s, const unsigned int n);
  +int wcsmbslen(const wchar_t * pwcs, const unsigned int n);
   #endif
   
   // ---------------------------------------------------------------------------
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to