diff options
author | Mathias Bauer <mba@openoffice.org> | 2009-09-09 11:45:13 +0200 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2009-09-09 11:45:13 +0200 |
commit | 0cb550725d7e128e72e67739aff5338865c28abc (patch) | |
tree | 0ffabe03dd8b83e273539f26f633273d50c37397 /tools | |
parent | aa611d78df11fcc1e35ead5fa093143bf17e4cf6 (diff) | |
parent | 1f0839c836781bc41f8c301b6262eabc978c90f8 (diff) |
merge commit to DEV300_m57
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bootstrp/md5.cxx | 64 | ||||
-rw-r--r-- | tools/inc/tools/poly.hxx | 1 | ||||
-rw-r--r-- | tools/source/fsys/urlobj.cxx | 9 | ||||
-rw-r--r-- | tools/source/generic/makefile.mk | 4 | ||||
-rw-r--r-- | tools/source/generic/poly2.cxx | 114 | ||||
-rw-r--r-- | tools/util/makefile.mk | 7 | ||||
-rw-r--r-- | tools/workben/solar.c | 2 | ||||
-rw-r--r-- | tools/workben/urltest.cxx | 19 |
8 files changed, 104 insertions, 116 deletions
diff --git a/tools/bootstrp/md5.cxx b/tools/bootstrp/md5.cxx index bca89725fac2..a234f278cc9d 100644 --- a/tools/bootstrp/md5.cxx +++ b/tools/bootstrp/md5.cxx @@ -44,8 +44,62 @@ #define FILE_OPEN_READ "r" #endif +// Extended calc_md5_checksum to recognize Windows executables and libraries. To +// create the same md5 checksum for a (code/data) identical file it ignores a different +// date and header checksum. Please see crashrep/source/win32/soreport.cpp +// where the same method is also used. The crash reporter uses the MD5 +// checksums to transfer them to the crash database. You have to make sure that both +// methods use the same algorithm otherwise there could be problems with stack reports. + +void normalize_pe_image(sal_uInt8* buffer, size_t nBufferSize) +{ + const int OFFSET_PE_OFFSET = 0x3c; + const int OFFSET_COFF_TIMEDATESTAMP = 4; + const int PE_SIGNATURE_SIZE = 4; + const int COFFHEADER_SIZE = 20; + const int OFFSET_PE_OPTIONALHEADER_CHECKSUM = 64; + + // Check the header part of the file buffer + if (buffer[0] == sal_uInt8('M') && buffer[1] == sal_uInt8('Z')) + { + unsigned long PEHeaderOffset = (long)buffer[OFFSET_PE_OFFSET]; + if (PEHeaderOffset < nBufferSize-4) + { + if ( buffer[PEHeaderOffset+0] == sal_uInt8('P') && + buffer[PEHeaderOffset+1] == sal_uInt8('E') && + buffer[PEHeaderOffset+2] == 0 && + buffer[PEHeaderOffset+3] == 0 ) + { + PEHeaderOffset += PE_SIGNATURE_SIZE; + if (PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP < nBufferSize-4) + { + // Set timedatestamp and checksum fields to a normalized + // value to enforce the same MD5 checksum for identical + // Windows executables/libraries. + buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+0] = 0; + buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+1] = 0; + buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+2] = 0; + buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+3] = 0; + } + + if (PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM < nBufferSize-4) + { + // Set checksum to a normalized value + buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM] = 0; + buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM+1] = 0; + buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM+2] = 0; + buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM+3] = 0; + } + } + } + } +} + rtlDigestError calc_md5_checksum( const char *filename, ByteString &aChecksum ) { + const size_t BUFFER_SIZE = 0x1000; + const size_t MINIMAL_SIZE = 512; + sal_uInt8 checksum[RTL_DIGEST_LENGTH_MD5]; rtlDigestError error = rtl_Digest_E_None; @@ -58,11 +112,19 @@ rtlDigestError calc_md5_checksum( const char *filename, ByteString &aChecksum ) if ( digest ) { size_t nBytesRead; - sal_uInt8 buffer[0x1000]; + sal_uInt8 buffer[BUFFER_SIZE]; + bool bHeader(true); while ( rtl_Digest_E_None == error && 0 != (nBytesRead = fread( buffer, 1, sizeof(buffer), fp )) ) { + if (bHeader) + { + bHeader = false; + if (nBytesRead >= MINIMAL_SIZE && buffer[0] == sal_uInt8('M') && buffer[1] == sal_uInt8('Z') ) + normalize_pe_image(buffer, nBytesRead); + } + error = rtl_digest_updateMD5( digest, buffer, nBytesRead ); } diff --git a/tools/inc/tools/poly.hxx b/tools/inc/tools/poly.hxx index 606c9c91e879..a77782bc963c 100644 --- a/tools/inc/tools/poly.hxx +++ b/tools/inc/tools/poly.hxx @@ -260,7 +260,6 @@ private: ImplPolyPolygon* mpImplPolyPolygon; //#if 0 // _SOLAR__PRIVATE - TOOLS_DLLPRIVATE void *ImplCreateGPCPolygon() const; TOOLS_DLLPRIVATE void ImplDoOperation( const PolyPolygon& rPolyPoly, PolyPolygon& rResult, ULONG nOperation ) const; TOOLS_DLLPRIVATE void *ImplCreateArtVpath() const; TOOLS_DLLPRIVATE void ImplSetFromArtVpath( void *pVpath ); diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index e3484aee4e2d..2aff0d734bf6 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -1523,8 +1523,15 @@ bool INetURLObject::convertRelToAbs(rtl::OUString const & rTheRelURIRef, else if (pEnd - q >= 2 && q[0] == '\\' && q[1] == '\\') { q += 2; - if (scanDomain(q, pEnd) > 0 && (q == pEnd || *q == '\\')) + sal_Int32 n = rtl_ustr_indexOfChar_WithLength( + q, pEnd - q, '\\'); + sal_Unicode const * qe = n == -1 ? pEnd : q + n; + if (parseHostOrNetBiosName( + q, qe, bOctets, ENCODE_ALL, RTL_TEXTENCODING_DONTKNOW, + true, NULL)) + { bFSys = true; // 1st + } } if (bFSys) { diff --git a/tools/source/generic/makefile.mk b/tools/source/generic/makefile.mk index 9562999bd5d7..6340e4daae08 100644 --- a/tools/source/generic/makefile.mk +++ b/tools/source/generic/makefile.mk @@ -39,10 +39,6 @@ TARGET=gen .INCLUDE : settings.mk .INCLUDE : $(PRJ)$/util$/makefile.pmk -.IF "$(WITH_GPC)"!="NO" -CDEFS+=-DHAVE_GPC_H -.ENDIF - # --- Files -------------------------------------------------------- EXCEPTIONSFILES = $(SLO)$/poly.obj $(OBJ)$/poly.obj diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx index a560c961f481..ff97e6006a41 100644 --- a/tools/source/generic/poly2.cxx +++ b/tools/source/generic/poly2.cxx @@ -33,17 +33,10 @@ #define _SV_POLY2_CXX -extern "C" -{ -#if defined (HAVE_GPC_H) && !defined (__gpc_h) -# include <external/gpc/gpc.h> -#else -# define GPC_INT 0 -# define GPC_UNION 1 -# define GPC_DIFF 2 -# define GPC_XOR 3 -#endif // HAVE_GPC_H -} +#define POLY_CLIP_INT 0 +#define POLY_CLIP_UNION 1 +#define POLY_CLIP_DIFF 2 +#define POLY_CLIP_XOR 3 #include <rtl/math.hxx> #include <poly.h> @@ -389,115 +382,34 @@ void PolyPolygon::AdaptiveSubdivide( PolyPolygon& rResult, const double d ) cons void PolyPolygon::GetIntersection( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const { - ImplDoOperation( rPolyPoly, rResult, GPC_INT ); + ImplDoOperation( rPolyPoly, rResult, POLY_CLIP_INT ); } // ----------------------------------------------------------------------- void PolyPolygon::GetUnion( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const { - ImplDoOperation( rPolyPoly, rResult, GPC_UNION ); + ImplDoOperation( rPolyPoly, rResult, POLY_CLIP_UNION ); } // ----------------------------------------------------------------------- void PolyPolygon::GetDifference( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const { - ImplDoOperation( rPolyPoly, rResult, GPC_DIFF ); + ImplDoOperation( rPolyPoly, rResult, POLY_CLIP_DIFF ); } // ----------------------------------------------------------------------- void PolyPolygon::GetXOR( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const { - ImplDoOperation( rPolyPoly, rResult, GPC_XOR ); -} - -// ----------------------------------------------------------------------- - -#ifdef HAVE_GPC_H - -void* PolyPolygon::ImplCreateGPCPolygon() const -{ - gpc_polygon* pRet = new gpc_polygon; - - pRet->num_contours = 0; - pRet->hole = NULL; - pRet->contour = NULL; - - for( USHORT i = 0, nCount = Count(); i < nCount; i++ ) - { - const Polygon& rPoly = GetObject( i ); - const USHORT nSize = rPoly.GetSize(); - - if( nSize > 1 ) - { - gpc_vertex_list aVertexList; - gpc_vertex* pVertex; - - aVertexList.num_vertices = nSize; - aVertexList.vertex = pVertex = new gpc_vertex[ nSize ]; - - for( USHORT nPos = 0; nPos < nSize; nPos++, pVertex++ ) - { - const Point& rPoint = rPoly[ nPos ]; - pVertex->x = rPoint.X(); - pVertex->y = rPoint.Y(); - } - - gpc_add_contour( pRet, &aVertexList, 0 ); - delete[] aVertexList.vertex; - } - } - - return pRet; + ImplDoOperation( rPolyPoly, rResult, POLY_CLIP_XOR ); } // ----------------------------------------------------------------------- void PolyPolygon::ImplDoOperation( const PolyPolygon& rPolyPoly, PolyPolygon& rResult, ULONG nOperation ) const { - gpc_polygon* pGPCPoly1 = (gpc_polygon*) ImplCreateGPCPolygon(); - gpc_polygon* pGPCPoly2 = (gpc_polygon*) rPolyPoly.ImplCreateGPCPolygon(); - gpc_polygon* pResult = new gpc_polygon; - - pResult->num_contours = 0; - pResult->hole = NULL; - pResult->contour = NULL; - - gpc_polygon_clip( (gpc_op) nOperation, pGPCPoly1, pGPCPoly2, pResult ); - - rResult.Clear(); - - for( int i = 0; i < pResult->num_contours; i++ ) - { - gpc_vertex_list& rVertexList = pResult->contour[ i ]; - Polygon aPoly( ::sal::static_int_cast< USHORT >( rVertexList.num_vertices ) ); - - for( int j = 0; j < rVertexList.num_vertices; j++ ) - { - Point& rPt = aPoly[ ::sal::static_int_cast< USHORT >( j ) ]; - rPt.X() = FRound( rVertexList.vertex[ j ].x ); - rPt.Y() = FRound( rVertexList.vertex[ j ].y ); - } - - rResult.Insert( aPoly ); - } - - gpc_free_polygon( pGPCPoly1 ); - delete pGPCPoly1; - - gpc_free_polygon( pGPCPoly2 ); - delete pGPCPoly2; - - gpc_free_polygon( pResult ); - delete pResult; -} - -#else - -void PolyPolygon::ImplDoOperation( const PolyPolygon& rPolyPoly, PolyPolygon& rResult, ULONG nOperation ) const -{ // Convert to B2DPolyPolygon, temporarily. It might be // advantageous in the future, to have a PolyPolygon adaptor that // just simulates a B2DPolyPolygon here... @@ -514,21 +426,21 @@ void PolyPolygon::ImplDoOperation( const PolyPolygon& rPolyPoly, PolyPolygon& rR // All code extracted from svx/source/svdraw/svedtv2.cxx // ----------------------------------------------------- - case GPC_UNION: + case POLY_CLIP_UNION: { // merge A and B (OR) aMergePolyPolygonA = basegfx::tools::solvePolygonOperationOr(aMergePolyPolygonA, aMergePolyPolygonB); break; } - case GPC_DIFF: + case POLY_CLIP_DIFF: { // substract B from A (DIFF) aMergePolyPolygonA = basegfx::tools::solvePolygonOperationDiff(aMergePolyPolygonA, aMergePolyPolygonB); break; } - case GPC_XOR: + case POLY_CLIP_XOR: { // compute XOR between poly A and B aMergePolyPolygonA = basegfx::tools::solvePolygonOperationXor(aMergePolyPolygonA, aMergePolyPolygonB); @@ -536,7 +448,7 @@ void PolyPolygon::ImplDoOperation( const PolyPolygon& rPolyPoly, PolyPolygon& rR } default: - case GPC_INT: + case POLY_CLIP_INT: { // cut poly 1 against polys 2..n (AND) aMergePolyPolygonA = basegfx::tools::solvePolygonOperationAnd(aMergePolyPolygonA, aMergePolyPolygonB); @@ -547,8 +459,6 @@ void PolyPolygon::ImplDoOperation( const PolyPolygon& rPolyPoly, PolyPolygon& rR rResult = PolyPolygon( aMergePolyPolygonA ); } -#endif // HAVE_GPC_H - // ----------------------------------------------------------------------- USHORT PolyPolygon::Count() const diff --git a/tools/util/makefile.mk b/tools/util/makefile.mk index 546ef29a449a..d9ba720543e3 100644 --- a/tools/util/makefile.mk +++ b/tools/util/makefile.mk @@ -113,13 +113,6 @@ SHL1IMPLIB= itools SHL1USE_EXPORTS=name SHL1STDLIBS+= $(SALLIB) $(VOSLIB) $(BASEGFXLIB) $(I18NISOLANGLIB) $(COMPHELPERLIB) -.IF "$(WITH_LIBART)"=="YES" -SHL1STDLIBS+= $(LIBART_LIBS) -.ELSE -SHL1STDLIBS+= $(GPC3RDLIB) -.ENDIF - - .IF "$(GUI)"=="WNT" SHL1STDLIBS+= $(SHELL32LIB) \ $(MPRLIB) \ diff --git a/tools/workben/solar.c b/tools/workben/solar.c index 91460614fe9b..05e9c103b8b4 100644 --- a/tools/workben/solar.c +++ b/tools/workben/solar.c @@ -352,6 +352,8 @@ void Description_Print( struct Description* pThis, char* name ) fprintf( f, "#define __SIZEOFDOUBLE\t%d\n", sizeof( double ) ); fprintf( f, "#define __IEEEDOUBLE\n" ); fprintf( f, "#define _SOLAR_NODESCRIPTION\n" ); + + fclose(f); } int diff --git a/tools/workben/urltest.cxx b/tools/workben/urltest.cxx index 542297eb4bd6..a232f8ebdd93 100644 --- a/tools/workben/urltest.cxx +++ b/tools/workben/urltest.cxx @@ -799,6 +799,25 @@ main() bSuccess = false; } } + { + bool bWasAbsolute; + if (!rtl::OUString(INetURLObject(rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "file:///"))). + smartRel2Abs( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "\\\\unc_host\\path")), + bWasAbsolute). + GetMainURL(INetURLObject::NO_DECODE)). + equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("file://unc_host/path")) + || !bWasAbsolute) + { + printf("BAD smartRel2Abs(\"\\\\unc_host\\path\")\n"); + bSuccess = false; + } + } } if (true) |