>>>>> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:

Angus> Angus Leeming wrote:
>> AC_DEFINE(SPELL_ENGINE, [$lyx_spell_engine], [Define as "ASPELL",
>> "PSPELL" or "ISPELL" to specify the spell-checker.])

Angus> I found it. AC_DEFINE_UNQUOTED.

Angus> The patch attached does what I/we want but I'm not sure if it's
Angus> optimal. Perhaps you'd care to have a look?

After way too much time (this stuff takes long to get right), hare is
my version of your patch. It has to be good since diffstat says
 14 files changed, 218 insertions(+), 80 deletions(-)
whereas yours says
 15 files changed, 255 insertions(+), 50 deletions(-)

;)

Of course I did not test aspell/pspell support, since I do not have
them here.

What still has to be done for spell stuff: create a new
config/spell.m4 file and shove the [aip]spell checking code in there,
along with a master LYX_CHECK_SPELLCHECKER macro. This is easy, but
obscures the patch. Then [ap]spell.m4 can be removed, they are
ridiculously small anyway.

JMarc

? src/SpellBase.C
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	28 Apr 2005 15:45:59 -0000
@@ -132,12 +132,6 @@ AC_LIBTOOL_WIN32_DLL
 #AM_PROG_LIBTOOL
 LYX_PROG_LIBTOOL
 
-### Check if we want spell libraries, prefer new aspell
-CHECK_WITH_ASPELL
-if test "$USING_ASPELL" != "yes"; then
-	CHECK_WITH_PSPELL
-fi
-
 ### Check for some Cygwin-specific details.
 CHECK_WITH_CYGWIN
 
@@ -290,6 +284,37 @@ dnl possible with the compiler which wil
 AC_LANG_PUSH(C)
 AC_CHECK_FUNCS(mkfifo mkstemp mktemp lstat readlink)
 AC_LANG_POP(C)
+
+### Check if we want spell libraries, prefer new aspell
+CHECK_WITH_ASPELL
+if $lyx_use_aspell ; then : ; else
+  CHECK_WITH_PSPELL
+  if $lyx_use_pspell ; then : ; else
+    lyx_use_ispell=true
+    AC_LANG_PUSH(C)
+    AC_CHECK_FUNCS(select dup2,, [lyx_use_ispell=false])
+    AC_LANG_POP(C)
+    AC_MSG_CHECKING([whether to use ispell])
+    if $lyx_use_ispell ; then
+      AC_MSG_RESULT(yes)
+      AC_DEFINE(USE_ISPELL, 1, [Define as 1 to use an external ispell process for spell-checking])
+      lyx_flags="$lyx_flags use-ispell"
+    else
+      AC_MSG_RESULT(no)
+    fi
+  fi
+fi
+AM_CONDITIONAL(USE_ASPELL, $lyx_use_aspell)
+AM_CONDITIONAL(USE_PSPELL, $lyx_use_pspell)
+AM_CONDITIONAL(USE_ISPELL, $lyx_use_ispell)
+
+lyx_client_subdir=true
+AC_LANG_PUSH(C)
+AC_CHECK_FUNCS(select socket,, [lyx_client_subdir=false])
+AM_CONDITIONAL(BUILD_CLIENT_SUBDIR, $lyx_client_subdir)
+
+AC_LANG_POP(C)
+
 
 AC_FUNC_SELECT_ARGTYPES
 
Index: config/aspell.m4
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/aspell.m4,v
retrieving revision 1.2
diff -u -p -r1.2 aspell.m4
--- config/aspell.m4	25 May 2004 14:42:08 -0000	1.2
+++ config/aspell.m4	28 Apr 2005 15:46:00 -0000
@@ -4,27 +4,23 @@
 
 AC_DEFUN([CHECK_WITH_ASPELL],
 [
-    AC_ARG_WITH(aspell,
-	AC_HELP_STRING([--with-aspell],[use ASpell libraries]),
-	[
-	    case "$withval" in
-		y*) USING_ASPELL="yes";;
-		*) USING_ASPELL="no";;
-	    esac
-	    ],
-	[
-	    USING_ASPELL="yes"
-	    ])
+    lyx_use_aspell=true
+    AC_ARG_WITH(aspell,	AC_HELP_STRING([--with-aspell],[use ASpell libraries]))
+    test "$with_aspell" = "no" && lyx_use_aspell=false
 
-    if test "$USING_ASPELL" = "yes" ; then
-	AC_CHECK_HEADERS(aspell.h aspell/aspell.h, USING_ASPELL="yes", USING_ASPELL="no")
-	AC_CHECK_LIB(aspell, new_aspell_config, LIBS="-laspell $LIBS"; USING_ASPELL="yes", USING_ASPELL="no")
+    if $lyx_use_aspell ; then
+	AC_CHECK_HEADERS(aspell.h aspell/aspell.h, 
+	    [lyx_use_aspell=true; break;], 
+	    [lyx_use_aspell=false])
+	AC_CHECK_LIB(aspell, new_aspell_config, LIBS="-laspell $LIBS", lyx_use_aspell=false)
 
-	if test "$USING_ASPELL" = "yes"; then
+	AC_MSG_CHECKING([whether to use aspell])
+	if $lyx_use_aspell ; then
+	    AC_MSG_RESULT(yes)
 	    AC_DEFINE(USE_ASPELL, 1, [Define as 1 to use the aspell library])
 	    lyx_flags="$lyx_flags use-aspell"
+	else
+	    AC_MSG_RESULT(no)
 	fi
     fi
-    AC_MSG_CHECKING([whether to use aspell])
-    AC_MSG_RESULT($USING_ASPELL)
     ])
Index: config/pspell.m4
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/pspell.m4,v
retrieving revision 1.10
diff -u -p -r1.10 pspell.m4
--- config/pspell.m4	25 May 2004 14:42:09 -0000	1.10
+++ config/pspell.m4	28 Apr 2005 15:46:00 -0000
@@ -3,27 +3,21 @@
 
 AC_DEFUN([CHECK_WITH_PSPELL],
 [
-    AC_ARG_WITH(pspell,
-	AC_HELP_STRING([--with-pspell],[use PSpell libraries]),
-	[
-	    case "$withval" in
-		y*) USING_PSPELL="yes";;
-		*) USING_PSPELL="no";;
-	    esac
-	    ],
-	[
-	    USING_PSPELL="yes"
-	    ])
+    lyx_use_pspell=true
+    AC_ARG_WITH(pspell,	AC_HELP_STRING([--with-pspell],[use PSpell libraries]))
+    test "$with_pspell" = "no" && lyx_use_pspell=false
 
-    if test "$USING_PSPELL" = "yes" ; then
-	AC_CHECK_HEADERS(pspell/pspell.h, USING_PSPELL="yes", USING_PSPELL="no")
-	AC_CHECK_LIB(pspell, main, LIBS="-lpspell $LIBS"; USING_PSPELL="yes", USING_PSPELL="no")
+    if $lyx_use_pspell ; then
+	AC_CHECK_HEADERS(pspell/pspell.h,, lyx_use_pspell=false)
+	AC_CHECK_LIB(pspell, main, LIBS="-lpspell $LIBS", lyx_use_pspell=false)
 
-	if test "$USING_PSPELL" = "yes"; then
+	AC_MSG_CHECKING([whether to use pspell])
+	if $lyx_use_pspell ; then
+	    AC_MSG_RESULT(yes)
 	    AC_DEFINE(USE_PSPELL, 1, [Define as 1 to use the pspell library])
 	    lyx_flags="$lyx_flags use-pspell"
+	else
+	    AC_MSG_RESULT(no)
 	fi
     fi
-    AC_MSG_CHECKING([whether to use pspell])
-    AC_MSG_RESULT($USING_PSPELL)
     ])
Index: po/POTFILES.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/po/POTFILES.in,v
retrieving revision 1.410
diff -u -p -r1.410 POTFILES.in
--- po/POTFILES.in	25 Apr 2005 11:07:54 -0000	1.410
+++ po/POTFILES.in	28 Apr 2005 15:46:00 -0000
@@ -6,6 +6,7 @@ src/CutAndPaste.C
 src/LColor.C
 src/LaTeX.C
 src/MenuBackend.C
+src/SpellBase.C
 src/buffer.C
 src/buffer_funcs.C
 src/bufferlist.C
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	28 Apr 2005 15:46:00 -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,18 @@ BUILT_SOURCES = version.C
 
 AM_CPPFLAGS = $(PCH_FLAGS) $(BOOST_INCLUDES)
 
+if USE_ASPELL
+ASPELL = aspell.C aspell_local.h
+endif
+if USE_PSPELL
+PSPELL = pspell.C pspell.h
+endif
+if USE_ISPELL
+ISPELL = ispell.C ispell.h
+endif
+
+
+
 lyx_SOURCES = \
 	Bidi.C \
 	Bidi.h \
@@ -101,8 +117,6 @@ lyx_SOURCES = \
 	ToolbarBackend.C \
 	ToolbarBackend.h \
 	WordLangTuple.h \
-	aspell.C \
-	aspell_local.h \
 	author.C \
 	author.h \
 	boost.C \
@@ -241,11 +255,8 @@ lyx_SOURCES = \
 	paragraph_pimpl.h \
 	pariterator.C \
 	pariterator.h \
+	$(ASPELL) $(PSPELL) $(ISPELL) SpellBase.C \
 	SpellBase.h \
-	ispell.C \
-	ispell.h \
-	pspell.C \
-	pspell.h \
 	rowpainter.C \
 	rowpainter.h \
 	sgml.C \
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	28 Apr 2005 15:46:00 -0000
@@ -20,6 +20,7 @@ class WordLangTuple;
 
 /**
  * Base class of all spell checker implementations.
+ * The class can be instantiated but will have no functionality.
  */
 class SpellBase {
 public:
@@ -43,23 +44,22 @@ public:
 	virtual ~SpellBase() {}
 
 	/// return true if the spellchecker instance still exists
-	virtual bool alive() = 0;
+	virtual bool alive();
 
 	/// 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 &);
 
 	/// 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();
 
 	/// give an error message on messy exit
-	virtual std::string const error() = 0;
-
+	virtual std::string const error();
 };
 
 #endif // SPELL_BASE_H
Index: src/aspell.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/aspell.C,v
retrieving revision 1.12
diff -u -p -r1.12 aspell.C
--- src/aspell.C	20 Jan 2005 16:17:35 -0000	1.12
+++ src/aspell.C	28 Apr 2005 15:46:00 -0000
@@ -11,8 +11,6 @@
 
 #include <config.h>
 
-#ifdef USE_ASPELL
-
 #include "debug.h"
 
 #include <aspell.h>
@@ -144,5 +142,3 @@ string const ASpell::error()
 
 	return (err ? err : "");
 }
-
-#endif // USE_ASPELL
Index: src/aspell_local.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/aspell_local.h,v
retrieving revision 1.5
diff -u -p -r1.5 aspell_local.h
--- src/aspell_local.h	20 Jan 2005 16:17:35 -0000	1.5
+++ src/aspell_local.h	28 Apr 2005 15:46:00 -0000
@@ -75,4 +75,4 @@ private:
 	AspellCanHaveError * spell_error_object;
 };
 
-#endif // ASPELL_H
+#endif // LYX_ASPELL_H
Index: src/lyxserver.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxserver.C,v
retrieving revision 1.61
diff -u -p -r1.61 lyxserver.C
--- src/lyxserver.C	26 Apr 2005 10:30:21 -0000	1.61
+++ src/lyxserver.C	28 Apr 2005 15:46:00 -0000
@@ -75,13 +75,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()
@@ -354,6 +380,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.8
diff -u -p -r1.8 lyxsocket.C
--- src/lyxsocket.C	26 Apr 2005 10:30:21 -0000	1.8
+++ src/lyxsocket.C	28 Apr 2005 15:46:00 -0000
@@ -14,8 +14,66 @@
 
 #include <config.h>
 
+#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"
@@ -270,3 +328,5 @@ void LyXDataSocket::writeln(string const
 		connected_ = false;
 	}
 }
+
+#endif // defined(HAVE_READ) && defined(HAVE_WRITE) && defined(HAVE_CLOSE)
Index: src/pspell.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/pspell.C,v
retrieving revision 1.15
diff -u -p -r1.15 pspell.C
--- src/pspell.C	20 Jan 2005 16:17:36 -0000	1.15
+++ src/pspell.C	28 Apr 2005 15:46:00 -0000
@@ -11,8 +11,6 @@
 
 #include <config.h>
 
-#ifdef USE_PSPELL
-
 #include "debug.h"
 
 #define USE_ORIGINAL_MANAGER_FUNCS 1
@@ -155,5 +153,3 @@ string const PSpell::error()
 		return err;
 	return "";
 }
-
-#endif // USE_PSPELL
Index: src/pspell.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/pspell.h,v
retrieving revision 1.8
diff -u -p -r1.8 pspell.h
--- src/pspell.h	20 Jan 2005 16:17:36 -0000	1.8
+++ src/pspell.h	28 Apr 2005 15:46:00 -0000
@@ -75,4 +75,4 @@ private:
 	PspellCanHaveError * spell_error_object;
 };
 
-#endif // PSPELL_H
+#endif // LYX_PSPELL_H
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	28 Apr 2005 15:46:00 -0000
@@ -23,13 +23,14 @@
 #include "lyxrc.h"
 #include "paragraph.h"
 
-#include "ispell.h"
-#ifdef USE_PSPELL
+#if defined(USE_ASPELL)
+# include "aspell_local.h"
+#elif defined(USE_PSPELL)
 # include "pspell.h"
+#elif defined(USE_ISPELL)
+# include "ispell.h"
 #else
-#ifdef USE_ASPELL
-# include "aspell_local.h"
-#endif
+# include "SpellBase.h"
 #endif
 
 #include "support/textutils.h"
@@ -68,19 +69,20 @@ SpellBase * getSpeller(BufferParams cons
 	              ? lyxrc.isp_alt_lang
 		      : bp.language->code();
 
-#ifdef USE_ASPELL
+#if defined(USE_ASPELL)
 	if (lyxrc.use_spell_lib)
 		return new ASpell(bp, lang);
-#endif
-#ifdef USE_PSPELL
+#elif defined(USE_PSPELL)
 	if (lyxrc.use_spell_lib)
 		return new PSpell(bp, lang);
-#endif
-
+#elif defined(USE_ISPELL)
 	lang = (lyxrc.isp_use_alt_lang) ?
 		lyxrc.isp_alt_lang : bp.language->lang();
 
 	return new ISpell(bp, lang);
+#else
+	return new SpellBase;
+#endif
 }
 
 } // namespace anon
@@ -91,6 +93,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/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	28 Apr 2005 15:46:00 -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