On Fri, May 07, 2004 at 09:23:32PM -0500, Michael D Schleif wrote:
> How can I tell whether or not ispell support is _actually_ compiled into
> my instance of sqwebmail-4.0.3?
# strings /usr/local/share/sqwebmail/libexec/sqwebmail/sqwebmaild | grep ispell
Also, look in sqwebmail/config.log
> Everything else sqwebmail appears to function properly: I can send and
> receive mail as any of several users. When I create a message, and try
> to Check spelling, then I get this page:
>
> Internal error (module sqispell.c, line 316) -
> contact system administrator
>
>
> # grep -n ispell ./sqwebmail/sqispell.c | grep 316
> 316: if (!ispellptr) enomem();
Hmm. Try adding one line of context and you'll see:
ispellptr=ispell_run(sqwebmail_content_ispelldict, line+pos);
if (!ispellptr) enomem();
Then you grep for ispell_run, which takes you to ispell.c
Then, you look through this function to see under what circumstances it
returns 0, since it never bothers to log anything. (To be fair, until
recently it was a pain to put this sort of debug info in, but in the next
release sqwebmaild's stderrr output is captured so it will be much easier to
do this)
The most likely candidates look like a failure in fork_ispell, or no output
line being returned by ispell (which in turn might be caused by bad
arguments, such as "-d <dict>" pointing to an unknown dictionary). You're
quite right, there's little here to help the system administrator - too many
variables.
If you're prepared to upgrade to sqwebmail-4.0.3.20040502, then I can do you
a patch to report the problem. Oh what the hell, here's the patch anyway.
Don't do this on a production system: there's a new config file
("sqwebmail") and a new startup script
(/usr/local/share/sqwebmail/libexec/sqwebmaild.rc)
Regards,
Brian.
--- sqwebmail-4.0.3.20040502/sqwebmail/ispell.c.orig Sat May 8 10:33:01 2004
+++ sqwebmail-4.0.3.20040502/sqwebmail/ispell.c Sat May 8 10:41:51 2004
@@ -59,15 +59,23 @@
prevsighandler=signal(SIGCHLD, SIG_DFL);
signal(SIGCHLD, prevsighandler);
- if (pipe(fdbuf) < 0) return (-1);
+ if (pipe(fdbuf) < 0)
+ {
+ perror("pipe");
+ return (-1);
+ }
switch (ispell_pid=fork()) {
case -1:
+ perror("fork");
close(fdbuf[0]);
close(fdbuf[1]);
return (-1);
case 0:
- if (pipe(fdbuf2) < 0) _exit(-1);
+ if (pipe(fdbuf2) < 0) {
+ perror("pipe");
+ _exit(-1);
+ }
/*
** First child will fork and run the real ispell, and write to
@@ -76,6 +84,7 @@
switch (ispell_pid=fork()) {
case -1:
+ perror("fork");
_exit(-1);
case 0:
close(0);
@@ -96,6 +105,7 @@
}
args[argn]=0;
execv(ISPELL, (char **)args);
+ perror("fork_ispell: execv " ISPELL);
_exit(1);
}
close(fdbuf[0]);
@@ -107,11 +117,19 @@
{
int n=write(fdbuf2[1], ispellline, l);
- if (n <= 0) _exit(1);
+ if (n <= 0)
+ {
+ perror("fork_ispell: write");
+ _exit(1);
+ }
ispellline += n;
l -= n;
}
- if (write(fdbuf2[1], "\n", 1) != 1) _exit(1);
+ if (write(fdbuf2[1], "\n", 1) != 1)
+ {
+ perror("fork_ispell: write");
+ _exit(1);
+ }
close(fdbuf2[1]);
while ( wait(&waitstat) != ispell_pid)
;
@@ -122,6 +140,7 @@
ispell_resp=fdopen(fdbuf[0], "r");
if (!ispell_resp)
{
+ perror("fork_ispell: fdopen");
close(fdbuf[0]);
wait4pid();
return (-1);
@@ -139,6 +158,7 @@
:malloc(l);
if (!newbuf)
{
+ perror("fork_ispell: malloc/realloc");
if (isp->ispell_buf) free(isp->ispell_buf);
isp->ispell_buf=0;
wait4pid();
@@ -171,7 +191,10 @@
struct ispell_suggestion **sp;
if ((isp=(struct ispell *)malloc(sizeof(struct ispell))) == 0)
+ {
+ perror("malloc");
return (0);
+ }
isp->ispell_buf=0;
isp->first_misspelled=0;
islistptr=&isp->first_misspelled;
@@ -179,11 +202,13 @@
if (fork_ispell(line, dict, isp))
{
ispell_free(isp);
+ fprintf(stderr, "ERR: ispell_run: fork_ispell failed\n");
return (0);
}
if ((p=strchr(isp->ispell_buf, '\n')) == 0)
{
+ fprintf(stderr, "ERR: ispell_run: incomplete result from ispell\n");
ispell_free(isp);
return (0);
}
@@ -200,6 +225,7 @@
if ( (ip=*islistptr=(struct ispell_misspelled *)
malloc(sizeof(struct ispell_misspelled))) == 0)
{
+ perror("malloc");
ispell_free(isp);
return (0);
}
@@ -235,6 +261,7 @@
malloc(sizeof(struct ispell_suggestion)))
== 0)
{
+ perror("malloc");
ispell_free(isp);
return (0);
}