[ 
https://issues.apache.org/jira/browse/XERCESC-1619?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Scott Cantor reassigned XERCESC-1619:
-------------------------------------

    Assignee: Alberto Massari

> Allow compilation with gcc -pedantic-errors -ansi
> -------------------------------------------------
>
>                 Key: XERCESC-1619
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1619
>             Project: Xerces-C++
>          Issue Type: Improvement
>          Components: Build
>         Environment: Linux (SVN revision 422672)
>            Reporter: Daniel Burr
>            Assignee: Alberto Massari
>            Priority: Minor
>
> First problem is a couple of stray semi-colons:
> --- src/xercesc/dom/impl/DOMLSSerializerImpl.hpp      (revision 422672)
> +++ src/xercesc/dom/impl/DOMLSSerializerImpl.hpp      (working copy)
> @@ -214,12 +214,12 @@
>                                      , bool      val)
>  {
>      (val)? fFeatures |= (1<<featureId) : fFeatures &= ~(1<<featureId);
> -};
> +}
>  
>  inline bool DOMLSSerializerImpl::getFeature(const int featureId) const
>  {
>      return ((fFeatures & ( 1<<featureId )) != 0) ? true : false;
> -};
> +}
>  
>  inline void DOMLSSerializerImpl::setURCharRef()
>  {
> gcc complains about a missing return value here:
> --- src/xercesc/util/XMLNumber.cpp    (revision 422672)
> +++ src/xercesc/util/XMLNumber.cpp    (working copy)
> @@ -88,7 +88,7 @@
>          return 0;
>          break;
>      }
> -
> +    return NULL;
>  }
> Sometimes TOP_LEVEL_SCOPE is passed as argument 3 of 
> RefHash3KeysIdPool::getByKey() which is signed, causing gcc to complain that 
> there is an implicit conversion from unsigned to signed.  Fix:
>  --- src/xercesc/validators/common/Grammar.hpp        (revision 422672)
> +++ src/xercesc/validators/common/Grammar.hpp (working copy)
> @@ -67,7 +67,7 @@
>       // These are well-known values that must simply be larger
>       // than any reasonable scope
>                UNKNOWN_SCOPE          = UINT_MAX - 0
> -        , TOP_LEVEL_SCOPE    = UINT_MAX - 1
> +        , TOP_LEVEL_SCOPE    = INT_MAX - 1
>      };
>  
>      // 
> -----------------------------------------------------------------------
> Lastly, C99 can not have variable sized arrays allocated on the stack:
> --- src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp    
> (revision 422672)
> +++ src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp    
> (working copy)
> @@ -239,7 +239,9 @@
>      if (ch <= 0x7F)
>          return toupper(ch);
>  
> -    char    wcbuf[fUChSize * 2];
> +    char* wcbuf = new char[fUChSize << 1];
> +    if(!wcbuf) return 0;
> +
>      xmlChToMbc (ch, wcbuf);
>  
>      char    tmpArr[4];
> @@ -250,8 +252,11 @@
>  
>      ICONV_LOCK;
>      if (::iconv (fCDTo, &ptr, &len,
> -         &pTmpArr, &bLen) == (size_t) -1)
> -    return 0;
> +         &pTmpArr, &bLen) == (size_t) -1) {
> +        delete[] wcbuf;
> +        return 0;
> +    }
> +
>      tmpArr[1] = toupper (*((unsigned char *)tmpArr));
>      *tmpArr = tmpArr[1];
>      len = 1;
> @@ -259,9 +264,12 @@
>      bLen = fUChSize;
>      ptr = tmpArr;
>      if (::iconv (fCDFrom, &ptr, &len,
> -         &pTmpArr, &bLen) == (size_t) -1)
> -    return 0;
> +         &pTmpArr, &bLen) == (size_t) -1) {
> +        delete[] wcbuf;
> +        return 0;
> +    }
>      mbcToXMLCh (wcbuf, (XMLCh*) &ch);
> +    delete[] wcbuf;
>      return ch;
>  }
>  
> @@ -271,7 +279,9 @@
>      if (ch <= 0x7F)
>          return tolower(ch);
>  
> -    char    wcbuf[fUChSize * 2];
> +    char* wcbuf = new char[fUChSize << 1];
> +    if(!wcbuf) return 0;
> +
>      xmlChToMbc (ch, wcbuf);
>  
>      char    tmpArr[4];
> @@ -282,8 +292,10 @@
>  
>      ICONV_LOCK;
>      if (::iconv (fCDTo, &ptr, &len,
> -         &pTmpArr, &bLen) == (size_t) -1)
> -    return 0;
> +         &pTmpArr, &bLen) == (size_t) -1) {
> +        delete[] wcbuf;
> +        return 0;
> +    }
>      tmpArr[1] = tolower (*((unsigned char*)tmpArr));
>      *tmpArr = tmpArr[1];
>      len = 1;
> @@ -291,9 +303,12 @@
>      bLen = fUChSize;
>      ptr = tmpArr;
>      if (::iconv (fCDFrom, &ptr, &len,
> -         &pTmpArr, &bLen) == (size_t) -1)
> -    return 0;
> +         &pTmpArr, &bLen) == (size_t) -1) {
> +        delete[] wcbuf;
> +        return 0;
> +    }
>      mbcToXMLCh (wcbuf, (XMLCh*) &ch);
> +    delete[] wcbuf;
>      return ch;
>  }
>  
> @@ -303,8 +318,9 @@
>      if (toCheck <= 0x7F)
>          return isspace(toCheck);
>  
> -    char    wcbuf[fUChSize * 2];
>      char    tmpArr[4];
> +    char* wcbuf = new char[fUChSize << 1];
> +    if(!wcbuf) return 0;
>  
>      xmlChToMbc (toCheck, wcbuf);
>      char*    ptr = wcbuf;
> @@ -315,9 +331,12 @@
>      {
>          ICONV_LOCK;
>          if (::iconv (fCDTo, &ptr, &len,
> -                 &pTmpArr, &bLen) == (size_t) -1)
> +                 &pTmpArr, &bLen) == (size_t) -1) {
> +            delete[] wcbuf;
>              return 0;
> +        }
>      }
> +    delete[] wcbuf;
>      return isspace(*tmpArr);
>  }
>  
> @@ -1153,7 +1172,9 @@
>      //  If the passed value is really a surrogate embedded together, then
>      //  we need to break it out into its two chars. Else just one.
>      //
> -    char        srcBuf[2 * uChSize()];
> +    char* srcBuf = new char[uChSize() << 1];
> +    if(!srcBuf) return 0;
> +
>      unsigned int    srcCount = 1;
>      if (toCheck & 0xFFFF0000) {
>          XMLCh    ch1 = (toCheck >> 10) + 0xD800;
> @@ -1168,6 +1189,7 @@
>      char*    pTmpBuf = tmpBuf;
>  
>      size_t    rc = iconvTo( srcBuf, &len, &pTmpBuf, 64);
> +    delete[] srcBuf;
>      return (rc != (size_t)-1) && (len == 0);
>  }
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org

Reply via email to