You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Steven J. Hathaway (JIRA)" <ji...@apache.org> on 2012/09/21 07:18:07 UTC
[jira] [Created] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Steven J. Hathaway created XALANC-733:
-----------------------------------------
Summary: Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
Key: XALANC-733
URL: https://issues.apache.org/jira/browse/XALANC-733
Project: XalanC
Issue Type: Bug
Components: XalanC, XPathC
Affects Versions: 1.11
Reporter: Steven J. Hathaway
Assignee: Steven J. Hathaway
The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
ensures that getSystemId() and getPublicId() do not return NULL pointers.
XalanC source files that can benefit from the patch include:
xalanc/PlatformSupport/ProblemListenerBase.cpp
xalanc/PlatformSupport/XSLException.cpp
xalanc/XPath/XPathExecutionContextDefault.cpp
The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Martin Elzen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461797#comment-13461797 ]
Martin Elzen commented on XALANC-733:
-------------------------------------
Looks good to me. OTOH, there does tend to be one issue when you define a static class member like this: it's storage needs to be allocated somewhere, usually in the relevant .cpp file. Eg (assuming its within the XalanLocator class), in XalanLocator.cpp there ought to be a line that 'allocates the storage', something like: XalanLocator::s_dczero;
... Was something like that not needed anymore? OTOH, maybe I'm too used to old-fashioned C++ and the above syntax "just works" on recent compilers...
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464045#comment-13464045 ]
Steven J. Hathaway commented on XALANC-733:
-------------------------------------------
Modification based on IBM C++ definition of static members within a class.
Example from IBM Document:
class Test
{ public:
static const int N = 10;
};
const int Test::N;
Note that the constant initializer is not a definition. You still need to
define the static member in an enclosing namespace. See the above example.
class XalanLocator
{
public:
static const XalanDOMChar*
getSystemId(
const Locator* theLocator,
const XalanDOMChar* theAlternateId = &s_dczero)
{
return theLocator == 0 ? theAlternateId : (theLocator->getSystemId() ?
theLocator->getPublicId() : theAlternateId);
}
...
private:
const static XalanDOMChar s_dczero = 0;
};
const XalanDOMChar XalanLocator::s_dczero; // THIS LINE NEEDS TO BE ADDED
Adding this line to the XalanLocator.hpp file should solve the link problem.
- Steve
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Updated] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steven J. Hathaway updated XALANC-733:
--------------------------------------
Attachment: XalanLocator-3.patch
Only "const static" members can be initialized within a class.
BAD: static XalanDOMChar s_dczero = 0;
GOOD: const static XalanDOMChar s_dczero = 0;
Steven J. Hathaway
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Martin Elzen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464742#comment-13464742 ]
Martin Elzen commented on XALANC-733:
-------------------------------------
Okay, well, IBM is telling you a part of the story... but not all of it. They failed to mention that the "const int Test::N;" bit needs to be in a .cpp file. If you put in in the header instead you mess up what IIRC they call C++'s seperate compilation model. If you then happen to include the same header file into 2 different translation units, those two translation units can't be combined since they contain a duplicate definition.
Here's a "mored-together" file (if you want to use it esp. the makefile you will need to put the tabs where they belong!)
::::::::::::::
test.h
::::::::::::::
#if !defined(TEST_HDR)
#define TEST_HDR
class Test
{
public:
static const int N = 10;
void sayHi() const;
};
#if defined(BAD)
const int Test::N;
#endif
#endif
::::::::::::::
test.cpp
::::::::::::::
#include "test.h"
#include <iostream>
#if defined(GOOD)
const int Test::N;
#endif
void Test::sayHi() const
{
std::cout << "Test says 'Hi'.\n";
}
::::::::::::::
testUserOne.h
::::::::::::::
class UserOne {
public:
void sayHi() const;
};
::::::::::::::
testUserTwo.h
::::::::::::::
class UserTwo {
public:
void sayHi() const;
};
::::::::::::::
testUserOne.cpp
::::::::::::::
#include "test.h"
#include "testUserOne.h"
#include <iostream>
void UserOne::sayHi() const
{
std::cout << "UserOne, Test::N == " << Test::N << "\n";
}
::::::::::::::
testUserTwo.cpp
::::::::::::::
#include "test.h"
#include "testUserTwo.h"
#include <iostream>
void UserTwo::sayHi() const
{
std::cout << "UserTwo, Test::N == " << Test::N << "\n";
}
::::::::::::::
main.cpp
::::::::::::::
#include "test.h"
#include "testUserOne.h"
#include "testUserTwo.h"
#include <iostream>
int main(int argc, const char *argv[] )
{
std::cout << "at start of main\n";
Test tst;
UserOne one;
UserTwo two;
tst.sayHi();
one.sayHi();
two.sayHi();
std::cout << "at end of main\n";
return 0;
}
::::::::::::::
makefile
::::::::::::::
CC=g++
#OPTIONS=-DBAD
OPTIONS=-DGOOD
clean:
rm main main.o test.o testUserOne.o testUserTwo.o
test.o: test.h test.cpp
$(CC) $(OPTIONS) -o test.o -c test.cpp
testUserOne.o: test.h testUserOne.h testUserOne.cpp
$(CC) $(OPTIONS) -o testUserOne.o -c testUserOne.cpp
testUserTwo.o: test.h testUserTwo.h testUserTwo.cpp
$(CC) $(OPTIONS) -o testUserTwo.o -c testUserTwo.cpp
main.o: main.cpp
$(CC) $(OPTIONS) -o main.o -c main.cpp
main: test.o testUserOne.o testUserTwo.o main.o
$(CC) $(OPTIONS) -o main test.o testUserOne.o testUserTwo.o main.o
#####
GNU g++ (4.4) won't compile this when the BAD define in the Makefile isn't commented-out, while it will compile and link just fine when the GOOD define isn't commented out.
That's why I'm pushing for an approach using a static inline member function that returns a reference to a static object that is constructed within said static function. First of all, this is a well-known idiom (it's the singelton design pattern). You are also making the language work for you: doing it like this makes it C++'s responsibility to create the object exactly once. And as a plus point, this kind of design will even be more thread-safe when C++ compilers more completely support the C++11 standard.
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13465343#comment-13465343 ]
Steven J. Hathaway commented on XALANC-733:
-------------------------------------------
With the release distribution of 1.11 coming up, I don't have
the time to integrate a new source.cpp into the build. I therefore
have a patch to the existing source.hpp that should work.
The integration effort for a new source file requires not just
Makefile integration but four versions of Microsoft Visual Studio
.NET project file maintenance.
Steven J. Hathaway
Xalan Documentation Project
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator-4.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Resolved] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steven J. Hathaway resolved XALANC-733.
---------------------------------------
Resolution: Fixed
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator-4.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461033#comment-13461033 ]
Steven J. Hathaway commented on XALANC-733:
-------------------------------------------
XalanLocator-3.patch // committed to SVN trunk.
- Steven J. Hathaway
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13460225#comment-13460225 ]
Steven J. Hathaway commented on XALANC-733:
-------------------------------------------
Martin,
I recommend fixing the issue in
xalanc/PlatformSupport/XalanLocator.hpp
instead of in
xalanc/PlatformSupport/XSLException.cpp
A fix here should fix other attempts to initialize an XalanDOMString
with the reference to a NULL pointer. Your usoft patch ensures that
XalanDOMString url is initialized to an empty string when the Xerces
Locator::getSystemId() returns a NULL.
The patch recommended for xalanc/PlatformSupport/XalanLocator.hpp
means that &s_dummy is no longer required to be in the source for
xalanc/PlatformSupport/XSLException.cpp
SOME PATCH INFORMATION :: STRUCTURAL ANALYSIS
[1] The XERCESC sax/Locator.hpp
class SAX_EXPORT Locator
{
public:
virtual const XMLCh* getPublicId() const = 0;
virtual const XMLCh* getSystemId() const = 0;
}
The XMLCh* return values may be NULL if these methods are not implemented.
[2] The XALANC PlatformSupport/XalanLocator.hpp
XALAN_USING_XERCES(Locator)
class XALAN_PLATFORMSUPPORT_EXPORT XalanLocator : public Locator
{
public:
virtual const XMLCh*
getPublicId() const = 0;
virtual const XMLCh*
getSystemId() const = 0;
virtual XalanFileLoc
getLineNumber() const = 0;
virtual XalanFileLoc
getColumnNumber() const = 0;
static const XalanDOMChar*
getPublicId(
const Locator* theLocator,
// const XalanDOMChar* theAlternateId = 0) // OLD a NULL value
const XalanDOMChar* theAlternateId = &(0)) // NEW address of value zero
{
// return theLocator == 0 ? theAlternateId : theLocator->getPublicId(); // OLD
return theLocator == 0 ? theAlternateId : theLocator->getPublicId() ? // NEW
theLocator->getSystemId() : theAlternateId); // NEW
}
static const XalanDOMChar*
getSystemId(
const Locator* theLocator,
// const XalanDOMChar* theAlternateId = 0) // OLD a NULL value
const XalanDOMChar* theAlternateId = &(0)) // NEW address of value zero
{
// return theLocator == 0 ? theAlternateId : theLocator->getSystemId(); // OLD
return theLocator == 0 ? theAlternateId : (theLocator->getSystemId() ? // NEW
theLocator->getSystemId() : theAlternateId); // NEW
}
// Note: If theAlternateId is not passed as a parameter, the default is NULL.
// We may want the default to be an address of a zero value so that
// initializing an XalanDOMString does not fault.
===================================
The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
ensures that getSystemId() and getPublicId() do not return NULL pointers.
XalanC source files that can benefit from the above patch include:
xalanc/PlatformSupport/ProblemListenerBase.cpp
xalanc/PlatformSupport/XSLException.cpp
xalanc/XPath/XPathExecutionContextDefault.cpp
===================================
Sincerely,
Steven J. Hathaway
Xalan Documentation Project
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Martin Elzen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464754#comment-13464754 ]
Martin Elzen commented on XALANC-733:
-------------------------------------
Oh, and one more advantage to using the static inline function: that way you can get away with defining things only in a header file instead of also having to create an extra .cpp file...
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464948#comment-13464948 ]
Steven J. Hathaway commented on XALANC-733:
-------------------------------------------
I have found something that appears to work -- here is the C++ issue
related to static integer member initializations within a class.
Here is my set of Three tests.
[1]-- START OF FILE --
class Test
{
public:
static const XalanDOMChar * some_method (XalanNode * theNode,
const XalanDOMChar * AltString = &s_empty)
{ return AltString; }
private:
static const XalanDOMChar s_empty = 0;
};
-- END OF FILE --
The initialization and linking works OK for GNU G++ Version 4.4.
The initialization and linking works OK for Microsoft .NET 2003 and newer.
The initialization and linking fail for GNU G++ 4.2 and (BSD)
The initialization and linking fail for AIX.
[2]-- START OF FILE =
class Test
{
public:
static const XalanDOMChar * some_method (XalanNode * theNode,
const XalanDOMChar * AltString = &s_empty)
{ return AltString; }
private:
static const XalanDOMChar s_empty = 0;
};
static const XalanDOMChar s_empty;
-- END OF FILE --
This has a problem for each .cpp source file that includes the
above .hpp header file. Each instance of s_empty outside of
class becomes a duplicate initialization issue for which linkers
have problem.
[3]-- START OF FILE --
class Test
{
public:
static const XalanDOMChar * some_method (XalanNode * theNode,
const XalanDOMChar * AltString = getEmpty())
{ return AltString; }
private:
static const XalanDOMChar * getEmpty()
{
static const XalanDOMChar theZero = 0;
static const XalanDOMChar * theEmpty = &theZero;
return (theEmpty)
}
};
-- END OF FILE --
The initialization and linking works OK for all the above systems.
I will construct a new patch to handle the issue in light of these
findings.
- Steve
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13460559#comment-13460559 ]
Steven J. Hathaway commented on XALANC-733:
-------------------------------------------
XalanDOMChar is a 16bit value and not good for "".
There is also a problem in the patch for the pointer. Some compiler implementations
will make the pointer go out-of-scope with segment fault when access is attempted
outside the method.
Declaring a static variable in the class as an empty string will preserve its
usability outside the methods.
I will create a modified patch and post it.
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator.patch
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461903#comment-13461903 ]
Steven J. Hathaway commented on XALANC-733:
-------------------------------------------
C++ Static Member Initialization
A C++ static member declared within a class can be initialized either inside or outside the class.
If initialized within a class, the static member should also be declared with const. This also promotes thread safety.
A static member can only be initialized once. Static member methods() can only access other static members.
A .cpp file is often used to initialize static members outside the class.
All static members are normally initialized before main() is started or immediately after a shared object or DLL is loaded.
Steven J. Hathaway
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Martin Elzen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464808#comment-13464808 ]
Martin Elzen commented on XALANC-733:
-------------------------------------
the following patch against XalanLocator.hpp *as in rev 1389910* compiles on AIX, and after using it the samples/SimpleTransform executable seems to work okay :
--- XalanLocator.hpp.orig 2012-09-27 17:08:30.936963206 +0200
+++ XalanLocator.hpp 2012-09-27 17:08:39.515962213 +0200
@@ -67,7 +67,7 @@
static const XalanDOMChar*
getPublicId(
const Locator* theLocator,
- const XalanDOMChar* theAlternateId = &s_dczero)
+ const XalanDOMChar* theAlternateId = &( nullChar() ) )
{
return theLocator == 0 ? theAlternateId : (theLocator->getPublicId() ?
theLocator->getPublicId() : theAlternateId);
@@ -76,7 +76,7 @@
static const XalanDOMChar*
getSystemId(
const Locator* theLocator,
- const XalanDOMChar* theAlternateId = &s_dczero)
+ const XalanDOMChar* theAlternateId = &( nullChar() ) )
{
return theLocator == 0 ? theAlternateId : (theLocator->getSystemId() ?
theLocator->getPublicId() : theAlternateId);
@@ -125,7 +125,13 @@
XalanLocator&
operator=(const XalanLocator&);
- const static XalanDOMChar s_dczero = 0;
+ inline
+ static
+ const XalanDOMChar& nullChar()
+ {
+ const static XalanDOMChar sm_dczero = 0;
+ return sm_dczero;
+ }
};
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Updated] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steven J. Hathaway updated XALANC-733:
--------------------------------------
Attachment: XalanLocator.patch2
Patch update to ensure that default return pointers remain usable. See: XalanLocator.patch2
- Steve
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Updated] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steven J. Hathaway updated XALANC-733:
--------------------------------------
Attachment: XalanLocator.patch
Here is the patch file - XalanLocator.patch
- Steve
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator.patch
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Martin Elzen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13463861#comment-13463861 ]
Martin Elzen commented on XALANC-733:
-------------------------------------
Okay, that's interesting, but it's also not quite what I was trying to get at. My real question wasn't meant to be "does it compile?", but "does it link?". And it doesn't ... link, that is, on AIX. Either a XalanLocator.cpp file needs to be added to the Xalan SVN-tree in the appropriate place with contents something like as I specified already... Or a static inline member function needs to be defined, eg something like (note: I haven't tried to compile this yet, tomorrow maybe...)
inline
static
const XalanDOMChar& nullChar()
{
const static XalanDOMChar sm_dczero = 0;
return sm_dczero;
}
and then the other places that used &s_dczero would need to use something like "theAlternateId = &nullChar()".... assuming this code and the previous fn definition actually compiles.
See also:
http://stackoverflow.com/questions/3025997/c-defining-static-const-integer-members-in-class-definition
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Updated] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Steven J. Hathaway (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steven J. Hathaway updated XALANC-733:
--------------------------------------
Attachment: XalanLocator-4.patch
XalanLocator-4.patch .. implements a private method that returns a pointer to a null XalanDOMChar value. This appears to be compatible with builds on:
Windows Studio .NET 2003, 2010
FreeBSD-6 with GCC 4.2 (previously exhibited linker err)
Debian Linux with GCC 4.4
I am committing this patch to the source trunk.
- Steve
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator-3.patch, XalanLocator-4.patch, XalanLocator.patch, XalanLocator.patch2
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org
[jira] [Commented] (XALANC-733) Ensure that
XalanLocator::getSystemId() and getPublicId() do not return NULL
Posted by "Martin Elzen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/XALANC-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13460508#comment-13460508 ]
Martin Elzen commented on XALANC-733:
-------------------------------------
Hi Steven,
thanks for looking into this! I like your proposed solution much more than the patch I was proposing. However, taking the address-of NULL... Sounds *really* likely to be undefined behavior... Maybe it would be better to either:
a) do = "" // ie assign as default an empty string in the relevant XalanLocator constructor?
b) define a static inline fn as part of the XalanLocator class that would return an empty string,
something like:
inline static const XalanDOMChar* emptyString()
{
return "";
}
and then in the relevant XalanLocator constructor do:
= emptyString()
> Ensure that XalanLocator::getSystemId() and getPublicId() do not return NULL
> ----------------------------------------------------------------------------
>
> Key: XALANC-733
> URL: https://issues.apache.org/jira/browse/XALANC-733
> Project: XalanC
> Issue Type: Bug
> Components: XalanC, XPathC
> Affects Versions: 1.11
> Reporter: Steven J. Hathaway
> Assignee: Steven J. Hathaway
> Attachments: XalanLocator.patch
>
>
> The recommended patch to "xalanc/PlatformSupport/XalanLocator.hpp"
> ensures that getSystemId() and getPublicId() do not return NULL pointers.
> XalanC source files that can benefit from the patch include:
> xalanc/PlatformSupport/ProblemListenerBase.cpp
> xalanc/PlatformSupport/XSLException.cpp
> xalanc/XPath/XPathExecutionContextDefault.cpp
> The patch will be submitted shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org