Control: tags 1030619 + patch
Hi there!
The attached patch fixes this issue.
Best regards,
mt
Description: Add option "--ispell-dictionary, -D" to spell
Author: Kaare Hviid
Author: Marcos Talau
Bug-Debian: https://bugs.debian.org/297308
Bug-Debian: https://bugs.debian.org/1030619
Last-Update: 2023-02-07
Index: spell/spell.c
===
--- spell.orig/spell.c
+++ spell/spell.c
@@ -93,7 +93,6 @@ static char *xstrdup (const char *);
static void *xmalloc (size_t);
static void *xrealloc (void *, size_t);
static void error (int status, int errnum, const char *message,...);
-static void sig_chld (int);
static void sig_pipe (int);
void new_pipe (pipe_t *);
void parent (pipe_t *, int, char **);
@@ -110,6 +109,7 @@ const struct option long_options[] =
{"dictionary", required_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
{"ispell", required_argument, NULL, 'i'},
+ {"ispell-dictionary", required_argument, NULL, 'D'},
{"ispell-version", no_argument, NULL, 'I'},
{"number", no_argument, NULL, 'n'},
{"print-file-name", no_argument, NULL, 'o'},
@@ -129,6 +129,9 @@ char *ispell_prog = NULL;
/* Dictionary to use. Just use the default if NULL. */
char *dictionary = NULL;
+/* Ispell dictionary to use (--ispell-dictionary, -D). */
+char *ispell_dict = NULL;
+
/* Display Ispell's version (--ispell-version, -I). */
int show_ispell_version = 0;
@@ -167,8 +170,8 @@ main (int argc, char **argv)
/* Option processing loop. */
while (1)
{
- opt = getopt_long (argc, argv, "IVbdhilnosvx", long_options,
-(int *) 0);
+ opt = getopt_long (argc, argv, "IVbd:D:hi:lnos:vx", long_options,
+(int *) 0);
if (opt == EOF)
break;
@@ -190,6 +193,12 @@ main (int argc, char **argv)
else
error (0, 0, "option argument not given");
break;
+ case 'D':
+ if (optarg != NULL)
+ ispell_dict = xstrdup (optarg);
+ else
+ error (0, 0, "option argument not given");
+ break;
case 'h':
show_help = 1;
break;
@@ -245,6 +254,7 @@ main (int argc, char **argv)
" -V, --version\t\t\tPrint the version number.\n"
" -b, --british\t\t\tUse the British dictionary.\n"
" -d, --dictionary=FILE\t\tUse FILE to look up words.\n"
+ " -D, --ispell-dictionary=DICT\tUse DICTIONARY to look up
words.\n"
" -h, --help\t\t\tPrint a summary of the options.\n"
" -i, --ispell=PROGRAM\t\tCalls PROGRAM as Ispell.\n"
" -l, --all-chains\t\tIgnored; for compatibility.\n"
@@ -475,7 +485,7 @@ new_pipe (pipe_t * the_pipe)
if (signal (SIGPIPE, sig_pipe) == SIG_ERR)
error (EXIT_FAILURE, errno, "error creating SIGPIPE handler");
- if (signal (SIGCHLD, sig_chld) == SIG_ERR)
+ if (signal (SIGCHLD, SIG_IGN) == SIG_ERR)
error (EXIT_FAILURE, errno, "error creating SIGCHLD handler");
if (pipe (ifd) < 0)
@@ -511,14 +521,6 @@ sig_pipe (int signo)
error (EXIT_FAILURE, 0, "broken pipe");
}
-/* Handle the SIGCHLD signal. */
-
-static void
-sig_chld (int signo)
-{
- error (EXIT_FAILURE, 0, "Ispell died");
-}
-
/* Send lines to and retrieve lines from *THE_PIPE (created by
`new_pipe'). Accept `argc' (the number of arguments) and `argv'
(the array of arguments), so we can search for the files we are to
@@ -555,9 +557,12 @@ parent (pipe_t * the_pipe, int argc, cha
len = getline(, _size, the_pipe->fpin);
if (len == -1) {
- if (feof(the_pipe->fpin))
+ if (feof(the_pipe->fpin)) {
+ len = getline(, _size, the_pipe->fperr);
+ if (len != -1)
+ fprintf(stderr, "%s", buff);
error (EXIT_FAILURE, 0, "premature EOF from Ispell's stdout");
- else
+ } else
error(EXIT_FAILURE, errno, "error reading errors of ispell/aspell");
}
@@ -649,6 +654,12 @@ run_ispell_in_child (pipe_t * the_pipe)
execlp ("aspell", "aspell", "-a", "-p", dictionary, NULL) < 0)
error (EXIT_FAILURE, errno, "error executing ispell/aspell");
+ if (ispell_dict != NULL)
+if (execlp (ispell_prog, "ispell", "-a", "-d", ispell_dict, NULL) < 0)
+ if (errno != ENOENT ||
+ execlp ("aspell", "aspell", "-a", "-d", ispell_dict, NULL) < 0)
+ error (EXIT_FAILURE, errno, "error executing ispell/aspell");
+
if (british)
if (execlp (ispell_prog, "ispell", "-a", "-d", "british", NULL) < 0)
if (errno != ENOENT ||
Index: spell/spell.texi
===
--- spell.orig/spell.texi
+++ spell/spell.texi
@@ -113,6 +113,10 @@ this dictionary was installed with Ispel
@itemx -d @var{file}
Use the named dictionary.
+@item --ispell-dictionary=@var{dictionary}
+@itemx -D @var{dictionary}
+Use the named Ispell dictionary.
+
@item --help
@itemx -h
Print