Jean-Marc Lasgouttes wrote:
> Angus> Mmmm, but the ISpell class encapsulates our interaction with
> Angus> the external ispell process. Not being able to interact with
> Angus> this external process (no select(), different API to open
> Angus> pipes) is conceptually the same to the rest of LyX as being
> Angus> unable to launch the ispell process. In both cases all that
> Angus> matters is that ISpell tells the caller that we failed to
> Angus> launch ispell.
> 
> What about turning your dummy ispell implementation into a SpellBase
> implementation (that is make it non-working instead of abstract)? Then
> ControlSpellCheck would just use a SpellBase instance when the rest
> fails.
> 
> Angus> Anyway, here is the patch as it is, implementing stub versions
> Angus> of ISpell and of LyXComm. Something similar is needed for
> Angus> LyXSocket but I can't remember what the errors were when
> Angus> compiling with mingw, so will check again later.
> 
> The LyXComm dummy implementation looks good (at least to me).
> 
> Concerning the configure stuff, I do not like much checking directly
> against cached variables, but the alternative would probably by
> uglier.
> 
> JMarc

Well, see how you like this, which extends the previous patch as you 
suggest. It leads to the following variables being defined in config.h

/* Define to 1 if you have the `close' function. */
#define HAVE_CLOSE 1
/* Define to 1 if you have the `dup2' function. */
#define HAVE_DUP2 1
/* Define to 1 if you have the `read' function. */
#define HAVE_READ 1
/* Define to 1 if you have the `select' function. */
#define HAVE_SELECT 1
/* Define to 1 if you have the `socket' function. */
#define HAVE_SOCKET 1
/* Define to 1 if you have the `write' function. */
#define HAVE_WRITE 1
/* Define as 1 to use an external ispell process. */
#define USE_ISPELL 1

It also implements stubs for the lyxsocket as well if close(), read() or 
write() are not defined.

-- 
Angus
Index: configure.ac
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/configure.ac,v
retrieving revision 1.47
diff -u -p -r1.47 configure.ac
--- configure.ac	11 Mar 2005 10:49:09 -0000	1.47
+++ configure.ac	25 Apr 2005 16:22:35 -0000
@@ -288,10 +288,25 @@ dnl work correctly because of some confl
 dnl We aim to remove this eventually, since we should test as much as
 dnl possible with the compiler which will use the functions (JMarc)
 AC_LANG_PUSH(C)
-AC_CHECK_FUNCS(mkfifo mkstemp mktemp lstat readlink)
+AC_CHECK_FUNCS(close dup2 lstat mkfifo mkstemp mktemp read readlink select socket write)
 AC_LANG_POP(C)
 
 AC_FUNC_SELECT_ARGTYPES
+
+test x$ac_cv_func_dup2 = xyes -a x$ac_cv_func_select = xyes && {
+	ac_use_ispell=1
+	AC_DEFINE(USE_ISPELL, 1, [Define as 1 to use an external ispell process.])
+} || {
+	ac_use_ispell=0
+	AC_DEFINE(USE_ISPELL, 0, [Define as 1 to use an external ispell process.])
+}
+
+AM_CONDITIONAL(USE_ISPELL, test $ac_use_ispell -eq 1)
+
+AM_CONDITIONAL(BUILD_CLIENT_SUBDIR, \
+               test x$ac_cv_func_select = xyes -a x$ac_cv_func_socket = xyes)
+
+AM_CONDITIONAL(USE_SOCKTOOLS, test x$ac_cv_func_socket = xyes)
 
 ### Some information on what just happened
 real_bindir=`eval "echo \`eval \"echo ${bindir}\"\`"`
Index: src/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Makefile.am,v
retrieving revision 1.224
diff -u -p -r1.224 Makefile.am
--- src/Makefile.am	31 Jan 2005 10:42:17 -0000	1.224
+++ src/Makefile.am	25 Apr 2005 16:22:35 -0000
@@ -4,7 +4,11 @@ DISTCLEANFILES += config.h libintl.h ver
 
 MAINTAINERCLEANFILES += $(srcdir)/config.h.in
 
-SUBDIRS = mathed insets graphics support frontends . client tex2lyx
+if BUILD_CLIENT_SUBDIR
+CLIENT = client
+endif
+
+SUBDIRS = mathed insets graphics support frontends . $(CLIENT) tex2lyx
 
 EXTRA_DIST = config.h.in stamp-h.in version.C.in \
 	Sectioning.h \
@@ -51,6 +55,10 @@ BUILT_SOURCES = version.C
 
 AM_CPPFLAGS = $(PCH_FLAGS) $(BOOST_INCLUDES)
 
+if USE_ISPELL
+ISPELL = ispell.C ispell.h
+endif
+
 lyx_SOURCES = \
 	Bidi.C \
 	Bidi.h \
@@ -242,9 +250,7 @@ lyx_SOURCES = \
 	pariterator.C \
 	pariterator.h \
 	SpellBase.h \
-	ispell.C \
-	ispell.h \
-	pspell.C \
+	$(ISPELL) pspell.C \
 	pspell.h \
 	rowpainter.C \
 	rowpainter.h \
Index: src/SpellBase.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/SpellBase.h,v
retrieving revision 1.9
diff -u -p -r1.9 SpellBase.h
--- src/SpellBase.h	20 Jan 2005 16:17:35 -0000	1.9
+++ src/SpellBase.h	25 Apr 2005 16:22:35 -0000
@@ -13,6 +13,7 @@
 #ifndef SPELL_BASE_H
 #define SPELL_BASE_H
 
+#include "gettext.h"
 #include <string>
 
 class BufferParams;
@@ -20,6 +21,7 @@ class WordLangTuple;
 
 /**
  * Base class of all spell checker implementations.
+ * The class can be instantiated but will have no functionality.
  */
 class SpellBase {
 public:
@@ -43,22 +45,23 @@ public:
 	virtual ~SpellBase() {}
 
 	/// return true if the spellchecker instance still exists
-	virtual bool alive() = 0;
+	virtual bool alive() { return false; }
 
 	/// check the given word of the given lang code and return the result
-	virtual enum Result check(WordLangTuple const &) = 0;
+	virtual enum Result check(WordLangTuple const &) { return UNKNOWN_WORD; }
 
 	/// insert the given word into the personal dictionary
-	virtual void insert(WordLangTuple const &) = 0;
+	virtual void insert(WordLangTuple const &) {}
 
 	/// accept the given word temporarily
-	virtual void accept(WordLangTuple const &) = 0;
+	virtual void accept(WordLangTuple const &) {}
 
 	/// return the next near miss after a SUGGESTED_WORDS result
-	virtual std::string const nextMiss() = 0;
+	virtual std::string const nextMiss() { return std::string(); }
 
 	/// give an error message on messy exit
-	virtual std::string const error() = 0;
+	virtual std::string const error()
+		{ return _("Native OS API not yet supported."); }
 
 };
 
Index: src/lyxserver.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxserver.C,v
retrieving revision 1.60
diff -u -p -r1.60 lyxserver.C
--- src/lyxserver.C	15 Feb 2005 11:04:40 -0000	1.60
+++ src/lyxserver.C	25 Apr 2005 16:22:35 -0000
@@ -55,13 +55,13 @@
 #include <fcntl.h>
 
 #ifdef __EMX__
-#include <cstdlib>
-#include <io.h>
-#define OS2EMX_PLAIN_CHAR
-#define INCL_DOSNMPIPES
-#define INCL_DOSERRORS
-#include <os2.h>
-#include "support/os2_errortable.h"
+# include <cstdlib>
+# include <io.h>
+# define OS2EMX_PLAIN_CHAR
+# define INCL_DOSNMPIPES
+# define INCL_DOSERRORS
+# include <os2.h>
+# include "support/os2_errortable.h"
 #endif
 
 using lyx::support::compare;
@@ -73,13 +73,39 @@ using std::endl;
 using std::string;
 
 
-// provide an empty mkfifo() if we do not have one. This disables the
-// lyxserver.
-#ifndef HAVE_MKFIFO
-int mkfifo(char const * __path, mode_t __mode) {
-	return 0;
+#if !defined (HAVE_MKFIFO)
+// We provide a stub class that disables the lyxserver.
+
+void LyXComm::openConnection()
+{}
+
+
+void LyXComm::closeConnection()
+{}
+
+
+int LyXComm::startPipe(string const & filename, bool write)
+{
+	return -1;
 }
-#endif
+
+
+void LyXComm::endPipe(int & fd, string const & filename, bool write)
+{}
+
+
+void LyXComm::emergencyCleanup()
+{}
+
+void LyXComm::read_ready()
+{}
+
+
+void LyXComm::send(string const & msg)
+{}
+
+
+#else // defined (HAVE_MKFIFO)
 
 
 void LyXComm::openConnection()
@@ -352,6 +378,8 @@ void LyXComm::send(string const & msg)
 	}
 #endif
 }
+
+#endif // defined (HAVE_MKFIFO)
 
 
 string const LyXComm::inPipeName() const
Index: src/lyxsocket.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxsocket.C,v
retrieving revision 1.7
diff -u -p -r1.7 lyxsocket.C
--- src/lyxsocket.C	15 Feb 2005 13:45:40 -0000	1.7
+++ src/lyxsocket.C	25 Apr 2005 16:22:36 -0000
@@ -12,8 +12,66 @@
  * Full author contact details are available in file CREDITS.
  */
 
+#include <config.h>
+
 #include "lyxsocket.h"
 
+
+#if !(defined(HAVE_READ) && defined(HAVE_WRITE) && defined(HAVE_CLOSE))
+// We provide stub classes to disables the sockets.
+
+LyXServerSocket::LyXServerSocket(LyXFunc *, std::string const &)
+{}
+
+
+LyXServerSocket::~LyXServerSocket()
+{}
+
+
+std::string const & LyXServerSocket::address() const
+{
+	return std::string();
+}
+
+
+void LyXServerSocket::serverCallback()
+{}
+
+
+void LyXServerSocket::dataCallback(int)
+{}
+
+
+void LyXServerSocket::writeln(std::string const &)
+{}
+
+
+LyXDataSocket::LyXDataSocket(int)
+{}
+
+
+LyXDataSocket::~LyXDataSocket()
+{}
+
+
+bool LyXDataSocket::connected() const
+{
+	return false;
+}
+
+
+bool LyXDataSocket::readln(std::string &)
+{
+	return false;
+}
+
+
+void LyXDataSocket::writeln(std::string const &)
+{}
+
+#else // defined(HAVE_READ) && defined(HAVE_WRITE) && defined(HAVE_CLOSE)
+
+
 #include "debug.h"
 #include "funcrequest.h"
 #include "LyXAction.h"
@@ -268,3 +326,5 @@ void LyXDataSocket::writeln(string const
 		connected_ = false;
 	}
 }
+
+#endif // defined(HAVE_READ) && defined(HAVE_WRITE) && defined(HAVE_CLOSE)
Index: src/frontends/controllers/ControlSpellchecker.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlSpellchecker.C,v
retrieving revision 1.80
diff -u -p -r1.80 ControlSpellchecker.C
--- src/frontends/controllers/ControlSpellchecker.C	8 Feb 2005 13:18:03 -0000	1.80
+++ src/frontends/controllers/ControlSpellchecker.C	25 Apr 2005 16:22:36 -0000
@@ -23,7 +23,10 @@
 #include "lyxrc.h"
 #include "paragraph.h"
 
-#include "ispell.h"
+#include "SpellBase.h"
+#ifdef USE_ISPELL
+# include "ispell.h"
+#endif
 #ifdef USE_PSPELL
 # include "pspell.h"
 #else
@@ -76,11 +79,14 @@ SpellBase * getSpeller(BufferParams cons
 	if (lyxrc.use_spell_lib)
 		return new PSpell(bp, lang);
 #endif
+#ifdef USE_ISPELL
 
 	lang = (lyxrc.isp_use_alt_lang) ?
 		lyxrc.isp_alt_lang : bp.language->lang();
 
 	return new ISpell(bp, lang);
+#endif
+	return new SpellBase;
 }
 
 } // namespace anon
@@ -91,6 +97,8 @@ bool ControlSpellchecker::initialisePara
 	lyxerr[Debug::GUI] << "Spellchecker::initialiseParams" << endl;
 
 	speller_.reset(getSpeller(kernel().buffer().params()));
+	if (!speller_.get())
+		return false;
 
 	// reset values to initial
 	oldval_ = 0;
Index: src/support/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.342
diff -u -p -r1.342 ChangeLog
--- src/support/ChangeLog	25 Apr 2005 11:09:53 -0000	1.342
+++ src/support/ChangeLog	25 Apr 2005 16:22:36 -0000
@@ -1,5 +1,10 @@
 2005-04-25  Angus Leeming  <[EMAIL PROTECTED]>
 
+	* socktools.C (listen, accept): provide stub versions for Windows.
+
+	* os_win32.C (init): merge in changes from
+	development/Win32/win32_kludge.diff.
+
 	* globbing.[Ch]: removed to frontends/xforms.
 
 	* Makefile.am: associated change.
@@ -22,7 +27,7 @@
 
 2005-04-21  Angus Leeming  <[EMAIL PROTECTED]>
 
-	* forkedcontr.h: 
+	* forkedcontr.h:
 	* forkedcall.h: define pid_t for MSVC.
 
 	* forkedcall.C (kill): work around evil MSVC max macro.
Index: src/support/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/Makefile.am,v
retrieving revision 1.92
diff -u -p -r1.92 Makefile.am
--- src/support/Makefile.am	25 Apr 2005 11:09:53 -0000	1.92
+++ src/support/Makefile.am	25 Apr 2005 16:22:36 -0000
@@ -12,6 +12,10 @@ if USE_COMPRESSION
 COMPRESSION = gzstream.C gzstream.h
 endif
 
+if USE_SOCKTOOLS
+SOCKTOOLS = socktools.C socktools.h
+endif
+
 BUILT_SOURCES = package.C
 
 AM_CPPFLAGS = $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES)
@@ -64,9 +68,7 @@ libsupport_la_SOURCES = \
 	package.C \
 	package.h \
 	rename.C \
-	socktools.C \
-	socktools.h \
-	std_istream.h \
+	$(SOCKTOOLS) std_istream.h \
 	std_ostream.h \
 	systemcall.C \
 	systemcall.h \
Index: src/support/os_win32.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os_win32.C,v
retrieving revision 1.28
diff -u -p -r1.28 os_win32.C
--- src/support/os_win32.C	18 Apr 2005 17:43:11 -0000	1.28
+++ src/support/os_win32.C	25 Apr 2005 16:22:36 -0000
@@ -53,7 +53,7 @@ void os::init(int /* argc */, char * arg
 	 *
 	 * #if defined (_WIN32)
 	 * # define WIN32_LEAN_AND_MEAN
-	 * # include <stdlib.h>  // for __argc,__argv
+	 * # include <stdlib.h>  // for __argc, __argv
 	 * # include <windows.h> // for WinMain
 	 * #endif
 	 *
@@ -63,7 +63,7 @@ void os::init(int /* argc */, char * arg
 	 * #if defined (_WIN32)
 	 * int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
 	 * {
-	 *     return mymain(__argc, __argv);
+	 *     return mymain(__argc, __argv);
 	 * }
 	 * #endif
 	 *
@@ -89,12 +89,15 @@ void os::init(int /* argc */, char * arg
 	// Close the console when run (probably)
 	// not run from command prompt
 	char WindowTitle[1024];
-	HWND hwndFound;
-	GetConsoleTitle(WindowTitle,1024);
+	if (GetConsoleTitle(WindowTitle, sizeof(WindowTitle)) == 0) {
+		// Could not get the title, so we just leave things as they are
+		return;
+	}
+
 	if ((strcmp(WindowTitle, argv[0]) == 0) ||
-		(strcmp(WindowTitle,"LyX") == 0)) {
+		(strcmp(WindowTitle, "LyX") == 0)) {
 		// format a "unique" newWindowTitle
-		wsprintf(WindowTitle,"%d/%d",
+		wsprintf(WindowTitle, "%d/%d",
 			GetTickCount(),
 			GetCurrentProcessId());
 		// change current window title
@@ -102,9 +105,9 @@ void os::init(int /* argc */, char * arg
 		// ensure window title has been updated
 		Sleep(40);
 		// look for newWindowTitle
-		hwndFound=FindWindow(NULL, WindowTitle);
+		HWND const hwndFound = FindWindow(NULL, WindowTitle);
 		// If found, hide it
-		if ( hwndFound != NULL)
+		if (hwndFound != NULL)
 			ShowWindow( hwndFound, SW_HIDE);
 	}
 }
Index: src/support/socktools.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/socktools.C,v
retrieving revision 1.6
diff -u -p -r1.6 socktools.C
--- src/support/socktools.C	20 Jan 2005 15:38:14 -0000	1.6
+++ src/support/socktools.C	25 Apr 2005 16:22:36 -0000
@@ -11,6 +11,31 @@
 #include <config.h>
 
 #include "support/socktools.h"
+
+#if !defined (HAVE_SOCKET)
+// We provide stubs because we don't (yet?) support the native OS API.
+
+namespace lyx {
+namespace support {
+namespace socktools {
+
+int listen(std::string const &, int)
+{
+	return -1;
+}
+
+
+int accept(int)
+{
+	return -1;
+}
+
+} // namespace socktools
+} // namespace support
+} // namespace lyx
+
+#else // defined (HAVE_SOCKET)
+
 #include "support/lyxlib.h"
 
 #include "debug.h"
@@ -137,3 +162,5 @@ int accept(int sd)
 } // namespace socktools
 } // namespace support
 } // namespace lyx
+
+#endif // defined (HAVE_SOCKET)

Reply via email to