diff options
-rw-r--r-- | external/hyphen/UnpackedTarball_hyphen.mk | 1 | ||||
-rw-r--r-- | external/hyphen/hyphen-fdo48017-wfopen.patch | 46 | ||||
-rw-r--r-- | external/mythes/UnpackedTarball_mythes.mk | 1 | ||||
-rw-r--r-- | external/mythes/mythes-fdo48017-wfopen.patch | 72 | ||||
-rw-r--r-- | lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx | 10 | ||||
-rw-r--r-- | lingucomponent/source/lingutil/lingutil.cxx | 27 | ||||
-rw-r--r-- | lingucomponent/source/lingutil/lingutil.hxx | 10 | ||||
-rw-r--r-- | lingucomponent/source/thesaurus/libnth/nthesimp.cxx | 14 |
8 files changed, 130 insertions, 51 deletions
diff --git a/external/hyphen/UnpackedTarball_hyphen.mk b/external/hyphen/UnpackedTarball_hyphen.mk index 5cd0af80bd22..c112b3597338 100644 --- a/external/hyphen/UnpackedTarball_hyphen.mk +++ b/external/hyphen/UnpackedTarball_hyphen.mk @@ -17,6 +17,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,hyphen,\ external/hyphen/hyphen-android.patch \ external/hyphen/hyphen-rhmin.patch \ external/hyphen/hyphen-build.patch \ + external/hyphen/hyphen-fdo48017-wfopen.patch \ )) # vim: set noet sw=4 ts=4: diff --git a/external/hyphen/hyphen-fdo48017-wfopen.patch b/external/hyphen/hyphen-fdo48017-wfopen.patch new file mode 100644 index 000000000000..9a73b4a75025 --- /dev/null +++ b/external/hyphen/hyphen-fdo48017-wfopen.patch @@ -0,0 +1,46 @@ +diff -u hyphen/hyphen.c build/hyphen/hyphen.c +--- hyphen/hyphen.c 2014-05-22 00:28:13.164587974 +0200 ++++ build/hyphen/hyphen.c 2014-05-22 11:08:55.000000000 +0200 +@@ -44,6 +44,11 @@ + #include <unistd.h> /* for exit */ + #endif + ++#ifdef _WIN32 ++#include <windows.h> ++#include <wchar.h> ++#endif ++ + #define noVERBOSE + + /* calculate hyphenmin values with long ligature length (2 or 3 characters +@@ -371,6 +376,21 @@ + } + } + ++FILE * hnj_fopen(const char * path, const char * mode) { ++#ifdef _WIN32 ++#define WIN32_LONG_PATH_PREFIX "\\\\?\\" ++ if (strncmp(path, WIN32_LONG_PATH_PREFIX, 4) == 0) { ++ int len = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0); ++ wchar_t *buff = (wchar_t *) malloc(len * sizeof(wchar_t)); ++ MultiByteToWideChar(CP_UTF8, 0, path, -1, buff, len); ++ FILE * f = _wfopen(buff, (strcmp(mode, "r") == 0) ? L"r" : L"rb"); ++ free(buff); ++ return f; ++ } ++#endif ++ return fopen(path, mode); ++} ++ + HyphenDict * + hnj_hyphen_load (const char *fn) + { +@@ -383,7 +403,7 @@ + HashEntry *e; + int state_num = 0; + +- f = fopen (fn, "r"); ++ f = hnj_fopen (fn, "r"); + if (f == NULL) + return NULL; + diff --git a/external/mythes/UnpackedTarball_mythes.mk b/external/mythes/UnpackedTarball_mythes.mk index d2d4e1d6e772..7571c34e3a37 100644 --- a/external/mythes/UnpackedTarball_mythes.mk +++ b/external/mythes/UnpackedTarball_mythes.mk @@ -15,6 +15,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,mythes,\ external/mythes/mythes-1.2.0-vanilla-th-gen-idx.patch \ external/mythes/mythes-1.2.0-android.patch \ external/mythes/mythes-ssizet.patch \ + external/mythes/mythes-fdo48017-wfopen.patch \ )) # vim: set noet sw=4 ts=4: diff --git a/external/mythes/mythes-fdo48017-wfopen.patch b/external/mythes/mythes-fdo48017-wfopen.patch new file mode 100644 index 000000000000..1621b1d35641 --- /dev/null +++ b/external/mythes/mythes-fdo48017-wfopen.patch @@ -0,0 +1,72 @@ +diff -u mythes/mythes.cxx build/mythes/mythes.cxx +--- mythes/mythes.cxx 2014-05-22 00:27:38.508588487 +0200 ++++ build/mythes/mythes.cxx 2014-05-22 10:07:06.107547417 +0200 +@@ -8,6 +8,11 @@ + + #include "mythes.hxx" + ++#ifdef _WIN32 ++#include <windows.h> ++#include <wchar.h> ++#endif ++ + MyThes::MyThes(const char* idxpath, const char * datpath) + { + nw = 0; +@@ -35,7 +40,7 @@ + { + + // open the index file +- FILE * pifile = fopen(idxpath,"r"); ++ FILE * pifile = myfopen(idxpath,"r"); + if (!pifile) { + return 0; + } +@@ -90,7 +95,7 @@ + fclose(pifile); + + /* next open the data file */ +- pdfile = fopen(datpath,"r"); ++ pdfile = myfopen(datpath,"r"); + if (!pdfile) { + return 0; + } +@@ -370,3 +375,17 @@ + return -1; + } + ++FILE * MyThes::myfopen(const char * path, const char * mode) { ++#ifdef _WIN32 ++#define WIN32_LONG_PATH_PREFIX "\\\\?\\" ++ if (strncmp(path, WIN32_LONG_PATH_PREFIX, 4) == 0) { ++ int len = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0); ++ wchar_t *buff = (wchar_t *) malloc(len * sizeof(wchar_t)); ++ MultiByteToWideChar(CP_UTF8, 0, path, -1, buff, len); ++ FILE * f = _wfopen(buff, (strcmp(mode, "r") == 0) ? L"r" : L"rb"); ++ free(buff); ++ return f; ++ } ++#endif ++ return fopen(path, mode); ++} +diff -u mythes/mythes.hxx build/mythes/mythes.hxx +--- mythes/mythes.hxx 2010-03-04 12:56:23.000000000 +0100 ++++ build/mythes/mythes.hxx 2014-05-22 10:11:14.363543731 +0200 +@@ -30,6 +30,7 @@ + MyThes & operator = (const MyThes &); + + public: ++ // use UTF-8 encoded paths in WIN32 environment + MyThes(const char* idxpath, const char* datpath); + ~MyThes(); + +@@ -66,6 +67,9 @@ + // return index of char in string + int mystr_indexOfChar(const char * d, int c); + ++ // fopen or _wfopen ++ FILE * myfopen(const char * path, const char * mode); ++ + }; + + #endif diff --git a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx index 2fb10c1d70a2..86b0d5e36c8d 100644 --- a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx +++ b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx @@ -285,14 +285,12 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo OUString dictpath; osl::FileBase::getSystemPathFromFileURL( DictFN, dictpath ); - OString sTmp( OU2ENC( dictpath, osl_getThreadTextEncoding() ) ); #if defined(WNT) - // workaround for Windows specific problem that the - // path length in calls to 'fopen' is limted to somewhat - // about 120+ characters which will usually be exceed when - // using dictionaries as extensions. - sTmp = Win_GetShortPathName( dictpath ); + // Hyphen waits UTF-8 encoded paths with \\?\ long path prefix. + OString sTmp = OUStringToOString(dicpath, RTL_TEXTENCODING_UTF8); +#else + OString sTmp( OU2ENC( dictpath, osl_getThreadTextEncoding() ) ); #endif if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == NULL ) diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx index 18e5f57890e6..769a023c9096 100644 --- a/lingucomponent/source/lingutil/lingutil.cxx +++ b/lingucomponent/source/lingutil/lingutil.cxx @@ -17,10 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#if defined(WNT) -#include <windows.h> -#endif - #include <osl/thread.h> #include <osl/file.hxx> #include <tools/debug.hxx> @@ -45,29 +41,6 @@ using ::com::sun::star::lang::Locale; using namespace ::com::sun::star; -#if defined(WNT) -OString Win_GetShortPathName( const OUString &rLongPathName ) -{ - OString aRes; - - sal_Unicode aShortBuffer[1024] = {0}; - sal_Int32 nShortBufSize = SAL_N_ELEMENTS( aShortBuffer ); - - // use the version of 'GetShortPathName' that can deal with Unicode... - sal_Int32 nShortLen = GetShortPathNameW( - reinterpret_cast<LPCWSTR>( rLongPathName.getStr() ), - reinterpret_cast<LPWSTR>( aShortBuffer ), - nShortBufSize ); - - if (nShortLen < nShortBufSize) // conversion successful? - aRes = OString( OU2ENC( OUString( aShortBuffer, nShortLen ), osl_getThreadTextEncoding()) ); - else - OSL_FAIL( "Win_GetShortPathName: buffer to short" ); - - return aRes; -} -#endif //defined(WNT) - // build list of old style diuctionaries (not as extensions) to use. // User installed dictionaries (the ones residing in the user paths) // will get precedence over system installed ones for the same language. diff --git a/lingucomponent/source/lingutil/lingutil.hxx b/lingucomponent/source/lingutil/lingutil.hxx index 9a4f0f6a830d..bda6de1a7432 100644 --- a/lingucomponent/source/lingutil/lingutil.hxx +++ b/lingucomponent/source/lingutil/lingutil.hxx @@ -48,16 +48,6 @@ inline bool operator == ( const ::com::sun::star::lang::Locale &rL1, const ::com rL1.Variant == rL2.Variant; } -#if defined(WNT) - -// to be use to get a short path name under Windows that still can be used with -// the 'fopen' call. This is necessary since under Windows there seems to be -// a restriction of only about 110-130 characters length to a path name in order -// for it to work with 'fopen'. And that length is usually easily exceeded -// when using extensions... -OString Win_GetShortPathName( const OUString &rLongPathName ); -#endif - // temporary function, to be removed when new style dictionaries // using configuration entries are fully implemented and provided std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char * pDicType ); diff --git a/lingucomponent/source/thesaurus/libnth/nthesimp.cxx b/lingucomponent/source/thesaurus/libnth/nthesimp.cxx index 679aba9a0a95..73d05426e8c3 100644 --- a/lingucomponent/source/thesaurus/libnth/nthesimp.cxx +++ b/lingucomponent/source/thesaurus/libnth/nthesimp.cxx @@ -328,16 +328,14 @@ Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL Thes OUString nidx; osl::FileBase::getSystemPathFromFileURL(datpath,ndat); osl::FileBase::getSystemPathFromFileURL(idxpath,nidx); - OString aTmpidx(OU2ENC(nidx,osl_getThreadTextEncoding())); - OString aTmpdat(OU2ENC(ndat,osl_getThreadTextEncoding())); #if defined(WNT) - // workaround for Windows specific problem that the - // path length in calls to 'fopen' is limted to somewhat - // about 120+ characters which will usually be exceed when - // using dictionaries as extensions. - aTmpidx = Win_GetShortPathName( nidx ); - aTmpdat = Win_GetShortPathName( ndat ); + // MyThes waits UTF-8 encoded paths with \\?\ long path prefix. + OString aTmpidx = OUStringToOString(nidx, RTL_TEXTENCODING_UTF8); + OString aTmpdat = OUStringToOString(ndat, RTL_TEXTENCODING_UTF8); +#else + OString aTmpidx(OU2ENC(nidx,osl_getThreadTextEncoding())); + OString aTmpdat(OU2ENC(ndat,osl_getThreadTextEncoding())); #endif aThes[i] = new MyThes(aTmpidx.getStr(),aTmpdat.getStr()); |