|
This is patch to bug #456, titled "Spell check breaks if you rename AbiSuite directory"
The title is the symptom that the executable cannot
find the relative position of the "dictionary" directory containing the *.hash
file.
There are globaly two use cases. Theses use cases
have to do with the two directory structure schemes.
1- In the normal distribution format the directory
structure is
.../AbiSuite/AbiWord/bin/AbiWord.exe
.../AbiSuite/AbiWord/strings/*.strings .../AbiSuite/AbiWord/help/en-US/*.html .../AbiSuite/AbiWord/samples/en-US/*.abw .../AbiSuite/dictionary/*.hash With the patch installed, renaming the "Abisuite"
directory is now permitted. This is, to my understanding, the intention of the
bug description.
2- In the developer build canonical
format for directory structure is $(OUT)/$os_..._$dbg/bin/AbiWord.exe
$(OUT)/$os_..._$dbg/obj/*.obj $(OUT)/$os_..._$dbg/AbiSuite/AbiWord/strings/*.strings $(OUT)/$os_..._$dbg/AbiSuite/help/... $(OUT)/$os_..._$dbg/AbiSuite/samples/... $(OUT)/$os_..._$dbg/AbiSuite/dictionary/*.hash Since it is a canonical structure it should not change!. It is not the job of this patch to change anything here. Please note that this patch also include a pragma
directive that should have been added to the same file previously. I sent
patch 282 containing that correction last week.
Gilles Saint-Denis
|
Index: abi/src/af/xap/win/xap_Win32App.cpp
===================================================================
RCS file: /cvsroot/abi/src/af/xap/win/xap_Win32App.cpp,v
retrieving revision 1.35
diff -u -r1.35 xap_Win32App.cpp
--- abi/src/af/xap/win/xap_Win32App.cpp 2000/02/18 06:51:09 1.35
+++ abi/src/af/xap/win/xap_Win32App.cpp 2000/09/16 12:11:13
@@ -28,6 +28,8 @@
#include "xap_Win32_TB_CFactory.h"
#include "xap_Win32Slurp.h"
+#pragma warning(disable:4355)
+
/*****************************************************************/
XAP_Win32App::XAP_Win32App(HINSTANCE hInstance, XAP_Args * pArgs, const char *
szAppName)
@@ -178,6 +180,7 @@
{
char buf[PATH_MAX];
char buf2[PATH_MAX];
+ char szApplicationName[PATH_MAX];
const char * sz = NULL;
// see if a command line option [-lib <AbiSuiteLibraryDirectory>] was given
@@ -229,7 +232,8 @@
// /samples/en-US/*.abw
// /dictionary/*.hash
//
- // we want to set the library directory to .../AbiSuite
+ // we want to set the library directory to the
+ // directory which stand for .../AbiSuite
// (aka "getExeDir()/../..")
//
// if this is a developer build in the canonical build
@@ -263,12 +267,15 @@
while ( (p=strtok(NULL,"\\")) )
v.addItem(p);
+ strcpy(szApplicationName, getApplicationName());
+ strtok(szApplicationName, " ");
+
int n = v.getItemCount();
if ( (n > 2)
&& (UT_stricmp((const char *)v.getNthItem(n-1),"bin")==0)
- && (UT_stricmp((const char *)v.getNthItem(n-3),"AbiSuite")==0))
+ && (UT_stricmp((const char
+*)v.getNthItem(n-2),szApplicationName)==0))
{
- strcat(buf,"\\..\\.."); // TODO trim the string rather
than use ..'s
+ _buildDirName(v, n - 2, buf);
XAP_App::_setAbiSuiteLibDir(buf);
return;
}
@@ -276,7 +283,8 @@
if ( (n > 1)
&& (UT_stricmp((const char *)v.getNthItem(n-1),"bin")==0))
{
- strcat(buf,"\\..\\AbiSuite"); // TODO trim the string rather
than use ..'s
+ _buildDirName(v, n - 1, buf);
+ strcat(buf,"\\AbiSuite");
XAP_App::_setAbiSuiteLibDir(buf);
return;
}
@@ -289,6 +297,26 @@
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
return;
+}
+
+void XAP_Win32App::_buildDirName(const UT_Vector& vDirComponents, UT_uint32
+iComponentsNeeded, char* pDirBuf)
+{
+ UT_ASSERT(iComponentsNeeded <= vDirComponents.getItemCount());
+
+ if(iComponentsNeeded == 0)
+ {
+ strcpy(pDirBuf, "\\");
+ return;
+ }
+
+ UT_uint32 i = 0;
+ strcpy(pDirBuf, (const char*) vDirComponents.getNthItem(i++));
+
+ while(--iComponentsNeeded)
+ {
+ strcat(pDirBuf, "\\");
+ strcat(pDirBuf, (const char*) vDirComponents.getNthItem(i++));
+ }
}
void XAP_Win32App::enableAllTopLevelWindows(UT_Bool b)
Index: abi/src/af/xap/win/xap_Win32App.h
===================================================================
RCS file: /cvsroot/abi/src/af/xap/win/xap_Win32App.h,v
retrieving revision 1.32
diff -u -r1.32 xap_Win32App.h
--- abi/src/af/xap/win/xap_Win32App.h 2000/05/26 21:24:49 1.32
+++ abi/src/af/xap/win/xap_Win32App.h 2000/09/16 12:11:14
@@ -69,6 +69,8 @@
protected:
UT_uint32
_getExeDir(char* pDirBuf, UT_uint32 iBufLen);
void
_setAbiSuiteLibDir(void);
+
+ void
+_buildDirName(const UT_Vector& vDirComponents, UT_uint32 iComponentsNeeded, char*
+pDirBuf);
AP_Win32Toolbar_Icons * m_pWin32ToolbarIcons;
HINSTANCE
m_hInstance;
