Jean-Marc Lasgouttes wrote:
> Angus> I've come round to the opinion that ISpell.C should have a stub
> Angus> implementation for the case when HAVE_SELECT is not defined.
> Angus> The existing ISpell interface is sufficient to enable the rest
> Angus> of LyX to know that communication with the ispell binary has
> Angus> failed.
> 
> Setting the pointer to the spellcheck to 0 should be enough...

Mmmm, but the ISpell class encapsulates our interaction with the external 
ispell process. Not being able to interact with this external process (no 
select(), different API to open pipes) is conceptually the same to the 
rest of LyX as being unable to launch the ispell process. In both cases 
all that matters is that ISpell tells the caller that we failed to launch 
ispell.

Having special code in ControlSpellchecker breaks this encapsulation, no?

Anyway, here is the patch as it is, implementing stub versions of ISpell 
and of LyXComm. Something similar is needed for LyXSocket but I can't 
remember what the errors were when compiling with mingw, so will check 
again later.

Angus (who's not convinced one way or the other and values your feedback :)
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 12:37:05 -0000
@@ -288,10 +288,15 @@ 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(mkfifo mkstemp mktemp lstat readlink select socket)
 AC_LANG_POP(C)
 
 AC_FUNC_SELECT_ARGTYPES
+
+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 12:37:05 -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 \
Index: src/ispell.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ispell.C,v
retrieving revision 1.25
diff -u -p -r1.25 ispell.C
--- src/ispell.C	20 Jan 2005 16:17:36 -0000	1.25
+++ src/ispell.C	25 Apr 2005 12:37:05 -0000
@@ -43,6 +43,57 @@ using std::max;
 using std::string;
 
 
+#if !defined (HAVE_SELECT)
+// We provide a stub class that disables ISpell.
+
+ISpell::ISpell(BufferParams const &, string const &)
+	: in(0), out(0), inerr(0), str(0)
+{}
+
+
+ISpell::~ISpell()
+{}
+
+
+bool ISpell::select(bool &)
+{
+	return false;
+}
+
+
+string const ISpell::nextMiss()
+{
+	return string();
+}
+
+
+bool ISpell::alive()
+{
+	return false;
+}
+
+
+enum ISpell::Result ISpell::check(WordLangTuple const &)
+{
+	return UNKNOWN_WORD;
+}
+
+
+void ISpell::accept(WordLangTuple const &)
+{}
+
+
+void ISpell::insert(WordLangTuple const &)
+{}
+
+
+string const ISpell::error()
+{
+	return _("Native OS API not yet supported.");
+}
+
+#else // defined (HAVE_SELECT)
+
 namespace {
 
 class LaunchIspell : public lyx::support::ForkedProcess {
@@ -446,3 +497,5 @@ string const ISpell::error()
 {
 	return error_;
 }
+
+#endif // defined (HAVE_SELECT)
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 12:37:06 -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/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 12:37:06 -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 \

Reply via email to