]> git.lyx.org Git - lyx.git/blobdiff - src/sp_spell.C
Fix working of the spellchecker dialog with ispell when there are no
[lyx.git] / src / sp_spell.C
index e10adc3f5134e2d7cd4861df7af9d3f27207a461..40d54da87370c73fdec641a50ee12572900ec24c 100644 (file)
 #pragma implementation
 #endif
 
-#ifdef USE_PSPELL
-
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdio.h>
 
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <ctime>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <ctime>
+# endif
+#endif
+
 #ifdef HAVE_SYS_SELECT_H
 # ifdef HAVE_STRINGS_H
    // <strings.h> is needed at least on AIX because FD_ZERO uses bzero().
 
 #include "LString.h"
 #include "support/lstrings.h"
+#include "lyxrc.h"
+#include "debug.h"
+#include "encoding.h"
+#include "sp_ispell.h"
+
+using std::endl;
+
+namespace {
+       /// pid for the `ispell' process. 
+       pid_t isp_pid = -1; 
+}
+
+/// can be found in src/insets/figinset.C
+extern void sigchldchecker(pid_t pid, int * status);
+
+///
+// ------------------- start special pspell code/class --------------------
+///
+#ifdef USE_PSPELL
+
 #include "support/LAssert.h"
 
 #define USE_ORIGINAL_MANAGER_FUNCS 1
 
 #include "sp_pspell.h"
 
-extern void sigchldchecker(pid_t pid, int *status);
-
 
 PSpell::PSpell() 
+       : sc(0), els(0), spell_error_object(0), flag(ISP_UNKNOWN)
 {
-       els = 0;
-       sc = 0;
-       spell_error_object = 0;
-       flag = ISP_UNKNOWN;
 }
 
 PSpell::PSpell(BufferParams const & params, string const & lang)
+       : sc(0), els(0), spell_error_object(0), flag(ISP_UNKNOWN)
 {
-       els = 0;
-       sc = 0;
-       spell_error_object = 0;
-       flag = ISP_UNKNOWN;
        initialize(params, lang);
 }
 
@@ -75,9 +96,7 @@ PSpell::~PSpell()
 void PSpell::initialize(BufferParams const &, string const & lang)
 {
        PspellConfig * config = new_pspell_config();
-       string code;
-       split(lang, code, '_');
-       config->replace("language-tag", code.c_str());
+       config->replace("language-tag", lang.c_str());
        spell_error_object = new_pspell_manager(config);
        if (pspell_error_number(spell_error_object) != 0) {
                error_ = pspell_error_message(spell_error_object);
@@ -154,6 +173,7 @@ char const * PSpell::nextMiss()
 {
        if (els)
                return pspell_string_emulation_next(els);
+       return "";
 }
 
 char const * PSpell::error()
@@ -166,65 +186,11 @@ void PSpell::sigchldhandler(pid_t pid, int * status)
        sigchldchecker(pid, status);
 }
 
-
-
-#else
-
-/*
- *This file is part of
- * ====================================================== 
- * 
- *           LyX, The Document Processor
- *      
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-1998 The LyX Team
- *
- * ====================================================== 
- */
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <ctime>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <ctime>
-# endif
-#endif
-
-#ifdef HAVE_SYS_SELECT_H
-# ifdef HAVE_STRINGS_H
-   // <strings.h> is needed at least on AIX because FD_ZERO uses bzero().
-   // BUT we cannot include both string.h and strings.h on Irix 6.5 :(
-#  ifdef _AIX
-#   include <strings.h>
-#  endif
-# endif
-#include <sys/select.h>
 #endif
 
-#include "LString.h"
-#include "support/lstrings.h"
-#include "lyxrc.h"
-#include "debug.h"
-#include "encoding.h"
-#include "sp_ispell.h"
-
-using std::endl;
-
-/// can be found in src/insets/figinset.C
-extern void sigchldchecker(pid_t pid, int * status);
-
-namespace {
-/// pid for the `ispell' process. 
-pid_t isp_pid = -1; 
-}
-
+///
+// ------------------- start special ispell code/class --------------------
+///
 
 ISpell::ISpell()
 {
@@ -574,7 +540,3 @@ char const * ISpell::error()
 {
        return error_;
 }
-
-
-
-#endif