[Libreoffice-commits] .: 3 commits - comphelper/inc comphelper/source sal/cppunittester sal/osl

Tor Lillqvist tml at kemper.freedesktop.org
Wed Aug 17 11:00:36 PDT 2011


 comphelper/inc/comphelper/property.hxx                 |   13 --------
 comphelper/source/property/propagg.cxx                 |    3 +
 comphelper/source/property/property.cxx                |    6 ++-
 comphelper/source/property/propertycontainerhelper.cxx |   26 ++++++-----------
 sal/cppunittester/cppunittester.cxx                    |    8 +++++
 sal/osl/w32/diagnose.c                                 |   18 +++++------
 6 files changed, 33 insertions(+), 41 deletions(-)

New commits:
commit 9890c98480161040e048f37d94004b7b05f6c79f
Author: Tor Lillqvist <tlillqvist at novell.com>
Date:   Wed Aug 17 18:35:21 2011 +0300

    Fix dubious std::lower_bound() usage that breaks a _DEBUG MSVC build
    
    Always pass the value to search for of type equal to what the
    iterators return.

diff --git a/comphelper/inc/comphelper/property.hxx b/comphelper/inc/comphelper/property.hxx
index 662fa84..a294b33 100644
--- a/comphelper/inc/comphelper/property.hxx
+++ b/comphelper/inc/comphelper/property.hxx
@@ -51,19 +51,6 @@ namespace comphelper
 
 /** compare two properties by name
 */
-    struct PropertyStringLessFunctor : ::std::binary_function< ::com::sun::star::beans::Property, ::rtl::OUString, bool >
-    {
-        // ................................................................
-        inline bool operator()( const ::com::sun::star::beans::Property& lhs, const ::rtl::OUString& rhs ) const
-        {
-            return lhs.Name.compareTo(rhs) < 0;
-        }
-        // ................................................................
-        inline bool operator()( const ::rtl::OUString& lhs, const ::com::sun::star::beans::Property& rhs ) const
-        {
-            return lhs.compareTo(rhs.Name) < 0;
-        }
-    };
     //--------------------------------------------------------------------------
     // comparing two property instances
     struct PropertyCompareByName : public ::std::binary_function< ::com::sun::star::beans::Property, ::com::sun::star::beans::Property, bool >
diff --git a/comphelper/source/property/propagg.cxx b/comphelper/source/property/propagg.cxx
index b83c292..945ace8 100644
--- a/comphelper/source/property/propagg.cxx
+++ b/comphelper/source/property/propagg.cxx
@@ -60,7 +60,8 @@ namespace comphelper
         {
             sal_Int32 nLen = _rProps.getLength();
             const Property* pProperties = _rProps.getConstArray();
-            const Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen,_rName, ::comphelper::PropertyStringLessFunctor());
+            Property aNameProp(_rName, 0, Type(), 0);
+            const Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen, aNameProp, PropertyCompareByName());
             if ( pResult && ( pResult == pProperties + nLen || pResult->Name != _rName) )
                 pResult = NULL;
 
diff --git a/comphelper/source/property/property.cxx b/comphelper/source/property/property.cxx
index 37bb62c..b20eba9 100644
--- a/comphelper/source/property/property.cxx
+++ b/comphelper/source/property/property.cxx
@@ -180,7 +180,8 @@ void RemoveProperty(Sequence<Property>& _rProps, const rtl::OUString& _rPropName
 
     // binaere Suche
     const Property* pProperties = _rProps.getConstArray();
-    const Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen, _rPropName,PropertyStringLessFunctor());
+    Property aNameProp(_rPropName, 0, Type(), 0);
+    const Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen, aNameProp, PropertyCompareByName());
 
     // gefunden ?
     if ( pResult && (pResult != pProperties + nLen) && (pResult->Name == _rPropName) )
@@ -197,7 +198,8 @@ void ModifyPropertyAttributes(Sequence<Property>& seqProps, const ::rtl::OUStrin
 
     // binaere Suche
     Property* pProperties = seqProps.getArray();
-    Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen,sPropName, PropertyStringLessFunctor());
+    Property aNameProp(sPropName, 0, Type(), 0);
+    Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen, aNameProp, PropertyCompareByName());
 
     // gefunden ?
     if ( pResult && (pResult != pProperties + nLen) && (pResult->Name == sPropName) )
diff --git a/comphelper/source/property/propertycontainerhelper.cxx b/comphelper/source/property/propertycontainerhelper.cxx
index 6233efb..b984c3a 100644
--- a/comphelper/source/property/propertycontainerhelper.cxx
+++ b/comphelper/source/property/propertycontainerhelper.cxx
@@ -60,15 +60,11 @@ namespace
         }
     };
     // comparing two property descriptions
-    struct PropertyDescriptionHandleCompare : public ::std::binary_function< PropertyDescription, sal_Int32, bool >
+    struct PropertyDescriptionHandleCompare : public ::std::binary_function< PropertyDescription, PropertyDescription, bool >
     {
-        bool operator() (const PropertyDescription& x, const sal_Int32& y) const
-        {
-            return x.aProperty.Handle < y;
-        }
-        bool operator() (const sal_Int32& x, const PropertyDescription& y) const
+        bool operator() (const PropertyDescription& x, const PropertyDescription& y) const
         {
-            return x < y.aProperty.Handle;
+            return x.aProperty.Handle < y.aProperty.Handle;
         }
     };
     // comparing two property descriptions (by name)
@@ -194,15 +190,11 @@ sal_Bool OPropertyContainerHelper::isRegisteredProperty( const ::rtl::OUString&
 //--------------------------------------------------------------------------
 namespace
 {
-    struct ComparePropertyWithHandle
+    struct ComparePropertyHandles
     {
-        bool operator()( const PropertyDescription& _rLHS, sal_Int32 _nRHS ) const
-        {
-            return _rLHS.aProperty.Handle < _nRHS;
-        }
-        bool operator()( sal_Int32 _nLHS, const PropertyDescription& _rRHS ) const
+        bool operator()( const PropertyDescription& _rLHS, const PropertyDescription& _nRHS ) const
         {
-            return _nLHS < _rRHS.aProperty.Handle;
+            return _rLHS.aProperty.Handle < _nRHS.aProperty.Handle;
         }
     };
 }
@@ -223,7 +215,7 @@ void OPropertyContainerHelper::implPushBackProperty(const PropertyDescription& _
 
     PropertiesIterator pos = ::std::lower_bound(
         m_aProperties.begin(), m_aProperties.end(),
-        _rProp.aProperty.Handle, ComparePropertyWithHandle() );
+        _rProp, ComparePropertyHandles() );
 
     m_aProperties.insert( pos, _rProp );
 }
@@ -466,11 +458,13 @@ void OPropertyContainerHelper::getFastPropertyValue(Any& _rValue, sal_Int32 _nHa
 //--------------------------------------------------------------------------
 OPropertyContainerHelper::PropertiesIterator OPropertyContainerHelper::searchHandle(sal_Int32 _nHandle)
 {
+    PropertyDescription aHandlePropDesc;
+    aHandlePropDesc.aProperty.Handle = _nHandle;
     // search a lower bound
     PropertiesIterator aLowerBound = ::std::lower_bound(
         m_aProperties.begin(),
         m_aProperties.end(),
-        _nHandle,
+        aHandlePropDesc,
         PropertyDescriptionHandleCompare());
 
     // check for identity
commit 44c513636f67d7710d5046e3212c77dc438ffaa3
Author: Tor Lillqvist <tlillqvist at novell.com>
Date:   Wed Aug 17 18:34:26 2011 +0300

    chmod -x

diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c
old mode 100755
new mode 100644
diff --git a/sal/osl/w32/thread.c b/sal/osl/w32/thread.c
old mode 100755
new mode 100644
commit 2495f15abb72cfcaea07fc20151b574e4d254df0
Author: Tor Lillqvist <tlillqvist at novell.com>
Date:   Wed Aug 17 18:33:04 2011 +0300

    Do use _CrtDbgReport() in a _DEBUG (enable-dbgutil, non-pro) build

diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx
index b351870..78da5dd 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -126,6 +126,14 @@ SAL_IMPLEMENT_MAIN() {
     //windows
     DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
     SetErrorMode(SEM_NOGPFAULTERRORBOX|dwMode);
+#ifdef _DEBUG // These functions are present only in the debgging runtime
+    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
+    _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+    _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
+    _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+    _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
+    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+#endif
 #endif
 
     CppUnit::TestResult result;
diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c
index 30356ee..f8fc997 100755
--- a/sal/osl/w32/diagnose.c
+++ b/sal/osl/w32/diagnose.c
@@ -28,15 +28,11 @@
 
 #include "system.h"
 
-#define NO_DEBUG_CRT
-
 #include <osl/diagnose.h>
 #include <osl/thread.h>
 
 #include "printtrace.h"
 
-#define NO_DEBUG_CRT
-
 static pfunc_osl_printDebugMessage  _pPrintDebugMessage = NULL;
 static pfunc_osl_printDetailedDebugMessage  _pPrintDetailedDebugMessage = NULL;
 
@@ -61,7 +57,10 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf
 
 void SAL_CALL osl_breakDebug(void)
 {
-    DebugBreak();
+    if ( IsDebuggerPresent() )
+        DebugBreak();
+    else
+        abort ();
 }
 
 void osl_trace(char const * pszFormat, ...) {
@@ -84,8 +83,10 @@ void osl_trace(char const * pszFormat, ...) {
 
 sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nLine, const sal_Char* pszMessage)
 {
-#ifndef NO_DEBUG_CRT
-    return (_CrtDbgReport(_CRT_ASSERT, pszFileName, nLine, NULL, pszMessage));
+    char const * env = getenv( "SAL_DIAGNOSE_ABORT" );
+#if defined(_DEBUG) && !defined(NO_DEBUG_CRT)
+    _CrtDbgReport(_CRT_ASSERT, pszFileName, nLine, NULL, pszMessage);
+    return ( ( env != NULL ) && ( *env != '\0' ) );
 #else
     HWND hWndParent;
     UINT nFlags;
@@ -93,7 +94,6 @@ sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nL
     /* get app name or NULL if unknown (don't call assert) */
     LPCSTR lpszAppName = "Error";
     sal_Char   szMessage[512];
-    char const * env = getenv( "SAL_DIAGNOSE_ABORT" );
 
     /* format message into buffer */
     szMessage[sizeof(szMessage)-1] = '\0';  /* zero terminate always */
@@ -144,7 +144,7 @@ sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nL
     }
 
     return sal_False;
-#endif /* NO_DEBUG_CRT */
+#endif /* _DEBUG && !NO_DEBUG_CRT */
 }
 
 sal_Int32 SAL_CALL osl_reportError(sal_uInt32 nType, const sal_Char* pszMessage)


More information about the Libreoffice-commits mailing list