diff --git a/configure.ac b/configure.ac index b3be436e..8fb8c0de 100644 --- a/configure.ac +++ b/configure.ac @@ -214,8 +214,13 @@ fi AC_ARG_ENABLE(speller, AS_HELP_STRING([--disable-speller], [Disable the spell-checker functions])) -if test "x$enable_speller" = xno; then - AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.]) +if test "x$enable_tiny" = xyes; then + if test "x$enable_speller" != xyes; then + enable_speller=no + fi +fi +if test "x$enable_speller" != xno; then + AC_DEFINE(ENABLE_SPELLER, 1, [Define this to have the spell-checker functions.]) fi AC_ARG_ENABLE(tabcomp, @@ -285,9 +290,6 @@ if test "x$enable_tiny" = xyes; then if test "x$enable_libmagic" != xyes; then enable_libmagic=no fi - if test "x$enable_speller" != xyes; then - AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.]) - fi fi AM_CONDITIONAL(USE_COLOR, test x$color_support = xyes) diff --git a/src/files.c b/src/files.c index 9ca0cafd..28a71a41 100644 --- a/src/files.c +++ b/src/files.c @@ -506,7 +506,7 @@ bool open_buffer(const char *filename, bool undoable) return TRUE; } -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER /* Open the specified file, and if that succeeds, blow away the text of * the current buffer and read the file contents into its place. */ void replace_buffer(const char *filename) @@ -564,7 +564,7 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x, UNSET(NO_NEWLINES); } #endif /* !NANO_TINY */ -#endif /* !DISABLE_SPELLER */ +#endif /* ENABLE_SPELLER */ /* Update the titlebar and the multiline cache to match the current buffer. */ void prepare_for_display(void) diff --git a/src/global.c b/src/global.c index e6f3acdf..10097aaf 100644 --- a/src/global.c +++ b/src/global.c @@ -174,7 +174,7 @@ char *operating_dir = NULL; /* The path to our confining "operating" directory, when given. */ #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER char *alt_speller = NULL; /* The command to use for the alternate spell checker. */ #endif @@ -553,7 +553,7 @@ void shortcut_init(void) const char *uncut_gist = N_("Uncut from the cutbuffer into the current line"); const char *cursorpos_gist = N_("Display the position of the cursor"); -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER const char *spell_gist = N_("Invoke the spell checker, if available"); #endif const char *replace_gist = N_("Replace a string or a regular expression"); @@ -674,7 +674,7 @@ void shortcut_init(void) const char *lint_gist = N_("Invoke the linter, if available"); const char *prevlint_gist = N_("Go to previous linter msg"); const char *nextlint_gist = N_("Go to next linter msg"); -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER const char *formatter_gist = N_("Invoke formatter, if available"); #endif #endif @@ -775,14 +775,14 @@ void shortcut_init(void) justify_tag, WITHORSANS(justify_gist), TOGETHER, NOVIEW); #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER add_to_funcs(do_spell, MMAIN, N_("To Spell"), WITHORSANS(spell_gist), TOGETHER, NOVIEW); #endif #ifndef DISABLE_COLOR add_to_funcs(do_linter, MMAIN, N_("To Linter"), WITHORSANS(lint_gist), TOGETHER, NOVIEW); -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER add_to_funcs(do_formatter, MMAIN, N_("Formatter"), WITHORSANS(formatter_gist), BLANKAFTER, NOVIEW); #endif @@ -792,8 +792,8 @@ void shortcut_init(void) add_to_funcs(do_cursorpos_void, MMAIN, N_("Cur Pos"), WITHORSANS(cursorpos_gist), TOGETHER, VIEW); -#if (defined(ENABLE_JUSTIFY) && (!defined(DISABLE_SPELLER) || !defined(DISABLE_COLOR)) || \ - !defined(ENABLE_JUSTIFY) && defined(DISABLE_SPELLER) && defined(DISABLE_COLOR)) +#if (defined(ENABLE_JUSTIFY) && (defined(ENABLE_SPELLER) || !defined(DISABLE_COLOR)) || \ + !defined(ENABLE_JUSTIFY) && !defined(ENABLE_SPELLER) && defined(DISABLE_COLOR)) /* Conditionally placing this one here or further on, to keep the * help items nicely paired in most conditions. */ add_to_funcs(do_gotolinecolumn_void, MMAIN, @@ -906,8 +906,8 @@ void shortcut_init(void) N_("Next File"), WITHORSANS(nextfile_gist), BLANKAFTER, VIEW); #endif -#if (!defined(ENABLE_JUSTIFY) && (!defined(DISABLE_SPELLER) || !defined(DISABLE_COLOR)) || \ - defined(ENABLE_JUSTIFY) && defined(DISABLE_SPELLER) && defined(DISABLE_COLOR)) +#if (!defined(ENABLE_JUSTIFY) && (defined(ENABLE_SPELLER) || !defined(DISABLE_COLOR)) || \ + defined(ENABLE_JUSTIFY) && !defined(ENABLE_SPELLER) && defined(DISABLE_COLOR)) add_to_funcs(do_gotolinecolumn_void, MMAIN, gotoline_tag, WITHORSANS(gotoline_gist), BLANKAFTER, VIEW); #endif @@ -1106,7 +1106,7 @@ void shortcut_init(void) add_to_sclist(MMAIN, "^J", 0, do_justify_void, 0); add_to_sclist(MMAIN, "F4", 0, do_justify_void, 0); #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER add_to_sclist(MMAIN, "^T", 0, do_spell, 0); add_to_sclist(MMAIN, "F12", 0, do_spell, 0); #else @@ -1365,7 +1365,7 @@ void shortcut_init(void) #ifndef DISABLE_COLOR void set_lint_or_format_shortcuts(void) { -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER if (openfile->syntax->formatter) { replace_scs_for(do_spell, do_formatter); replace_scs_for(do_linter, do_formatter); @@ -1378,7 +1378,7 @@ void set_lint_or_format_shortcuts(void) void set_spell_shortcuts(void) { -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER replace_scs_for(do_formatter, do_spell); replace_scs_for(do_linter, do_spell); #endif @@ -1502,7 +1502,7 @@ sc *strtosc(const char *input) else if (!strcasecmp(input, "mark")) s->scfunc = do_mark; #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER else if (!strcasecmp(input, "tospell") || !strcasecmp(input, "speller")) s->scfunc = do_spell; @@ -1744,7 +1744,7 @@ int strtomenu(const char *input) else if (!strcasecmp(input, "help")) return MHELP; #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER else if (!strcasecmp(input, "spell")) return MSPELL; #endif @@ -1791,7 +1791,7 @@ void thanks_for_all_the_fish(void) free(answer); free(last_search); free(present_path); -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER free(alt_speller); #endif free_filestruct(cutbuffer); diff --git a/src/help.c b/src/help.c index 257c7ff1..2116ae48 100644 --- a/src/help.c +++ b/src/help.c @@ -389,7 +389,7 @@ void help_init(void) htx[2] = NULL; } #endif /* ENABLE_BROWSER */ -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER else if (currmenu == MSPELL) { htx[0] = N_("Spell Check Help Text\n\n " "The spell checker checks the spelling of all text in " @@ -403,7 +403,7 @@ void help_init(void) htx[1] = NULL; htx[2] = NULL; } -#endif /* !DISABLE_SPELLER */ +#endif /* ENABLE_SPELLER */ #ifndef NANO_TINY else if (currmenu == MEXTCMD) { htx[0] = N_("Execute Command Help Text\n\n " diff --git a/src/nano.c b/src/nano.c index 4ac48c6f..ba4fca9c 100644 --- a/src/nano.c +++ b/src/nano.c @@ -889,7 +889,7 @@ void usage(void) print_opt(_("-r <#cols>"), _("--fill=<#cols>"), N_("Set hard-wrapping point at column #cols")); #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER if (!ISSET(RESTRICTED)) print_opt(_("-s "), _("--speller="), N_("Enable alternate speller")); @@ -963,7 +963,7 @@ void version(void) #ifdef ENABLE_OPERATINGDIR printf(" --enable-operatingdir"); #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER printf(" --enable-speller"); #endif #ifdef ENABLE_TABCOMP @@ -1012,7 +1012,7 @@ void version(void) #ifndef ENABLE_OPERATINGDIR printf(" --disable-operatingdir"); #endif -#ifdef DISABLE_SPELLER +#ifndef ENABLE_SPELLER printf(" --disable-speller"); #endif #ifndef ENABLE_TABCOMP @@ -1948,7 +1948,7 @@ int main(int argc, char **argv) #ifdef ENABLED_WRAPORJUSTIFY {"fill", 1, NULL, 'r'}, #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER {"speller", 1, NULL, 's'}, #endif {"tempfile", 0, NULL, 't'}, @@ -2183,7 +2183,7 @@ int main(int argc, char **argv) #endif break; #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER case 's': alt_speller = mallocstrcpy(alt_speller, optarg); break; @@ -2265,7 +2265,7 @@ int main(int argc, char **argv) #ifdef ENABLE_JUSTIFY char *quotestr_cpy = quotestr; #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER char *alt_speller_cpy = alt_speller; #endif ssize_t tabsize_cpy = tabsize; @@ -2284,7 +2284,7 @@ int main(int argc, char **argv) #ifdef ENABLE_JUSTIFY quotestr = NULL; #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER alt_speller = NULL; #endif @@ -2322,7 +2322,7 @@ int main(int argc, char **argv) quotestr = quotestr_cpy; } #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER if (alt_speller_cpy != NULL) { free(alt_speller); alt_speller = alt_speller_cpy; @@ -2416,7 +2416,7 @@ int main(int argc, char **argv) } #endif /* ENABLE_JUSTIFY */ -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER /* If we don't have an alternative spell checker after reading the * command line and/or rcfile(s), check $SPELL for one, as Pico * does (unless we're using restricted mode, in which case spell diff --git a/src/proto.h b/src/proto.h index e830b4f5..e72e6630 100644 --- a/src/proto.h +++ b/src/proto.h @@ -141,7 +141,7 @@ extern const char *locking_suffix; extern char *operating_dir; #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER extern char *alt_speller; #endif @@ -271,7 +271,7 @@ void do_uncut_text(void); /* Most functions in files.c. */ void initialize_buffer_text(void); bool open_buffer(const char *filename, bool undoable); -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER void replace_buffer(const char *filename); #ifndef NANO_TINY void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x, @@ -565,7 +565,7 @@ void do_justify(bool full_justify); void do_justify_void(void); void do_full_justify(void); #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER void do_spell(void); #endif #ifndef DISABLE_COLOR @@ -590,7 +590,7 @@ void null_at(char **data, size_t index); void unsunder(char *str, size_t true_len); void sunder(char *str); const char *fixbounds(const char *r); -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER bool is_separate_word(size_t position, size_t length, const char *buf); #endif const char *strstrwrapper(const char *haystack, const char *needle, diff --git a/src/rcfile.c b/src/rcfile.c index 68ca5f0f..e7b21e1a 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -79,7 +79,7 @@ static const rcoption rcopts[] = { {"rebinddelete", REBIND_DELETE}, {"rebindkeypad", REBIND_KEYPAD}, {"regexp", USE_REGEXP}, -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER {"speller", 0}, #endif {"suspend", SUSPEND}, @@ -994,7 +994,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only) else if (strcasecmp(keyword, "linter") == 0) pick_up_name("linter", ptr, &live_syntax->linter); else if (strcasecmp(keyword, "formatter") == 0) -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER pick_up_name("formatter", ptr, &live_syntax->formatter); #else ; @@ -1165,7 +1165,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only) word_chars = option; else #endif -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER if (strcasecmp(rcopts[i].name, "speller") == 0) alt_speller = option; else diff --git a/src/search.c b/src/search.c index 5ce07f2b..183a1ed0 100644 --- a/src/search.c +++ b/src/search.c @@ -273,7 +273,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus, /* When doing a regex search, compute the length of the match. */ if (ISSET(USE_REGEXP)) found_len = regmatches[0].rm_eo - regmatches[0].rm_so; -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER /* When we're spell checking, a match should be a separate word; * if it's not, continue looking in the rest of the line. */ if (whole_word_only && !is_separate_word(found - line->data, diff --git a/src/text.c b/src/text.c index d5be0675..95392d21 100644 --- a/src/text.c +++ b/src/text.c @@ -73,7 +73,7 @@ void do_mark(void) } #endif /* !NANO_TINY */ -#if !defined(DISABLE_COLOR) || !defined(DISABLE_SPELLER) +#if !defined(DISABLE_COLOR) || defined(ENABLE_SPELLER) /* Return an error message containing the given name. */ char *invocation_error(const char *name) { @@ -2558,7 +2558,7 @@ void do_full_justify(void) } #endif /* ENABLE_JUSTIFY */ -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER /* A word is misspelled in the file. Let the user replace it. We * return FALSE if the user cancels. */ bool do_int_spell_fix(const char *word) @@ -3049,7 +3049,7 @@ void do_spell(void) } else statusbar(_("Finished checking spelling")); } -#endif /* !DISABLE_SPELLER */ +#endif /* ENABLE_SPELLER */ #ifndef DISABLE_COLOR /* Run a linting program on the current buffer. Return NULL for normal @@ -3373,7 +3373,7 @@ void do_linter(void) } } -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER /* Run a formatter for the current syntax. This expects the formatter * to be non-interactive and operate on a file in-place, which we'll * pass it on the command line. */ @@ -3497,7 +3497,7 @@ void do_formatter(void) /* If there were any messages, clear them off. */ total_refresh(); } -#endif /* !DISABLE_SPELLER */ +#endif /* ENABLE_SPELLER */ #endif /* !DISABLE_COLOR */ #ifndef NANO_TINY diff --git a/src/utils.c b/src/utils.c index 352f6bec..42f12540 100644 --- a/src/utils.c +++ b/src/utils.c @@ -201,7 +201,7 @@ const char *fixbounds(const char *r) return r; } -#ifndef DISABLE_SPELLER +#ifdef ENABLE_SPELLER /* Is the word starting at the given position in buf and of the given length * a separate word? That is: is it not part of a longer word?*/ bool is_separate_word(size_t position, size_t length, const char *buf) @@ -219,7 +219,7 @@ bool is_separate_word(size_t position, size_t length, const char *buf) return ((position == 0 || !is_alpha_mbchar(before)) && (buf[word_end] == '\0' || !is_alpha_mbchar(after))); } -#endif /* !DISABLE_SPELLER */ +#endif /* ENABLE_SPELLER */ /* Return the position of the needle in the haystack, or NULL if not found. * When searching backwards, we will find the last match that starts no later