Back to index

courier  0.68.2
Classes | Functions
ispell.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ispell
struct  ispell_misspelled
struct  ispell_suggestion

Functions

struct ispellispell_run (const char *dictionary, const char *line)
void ispell_free (struct ispell *)

Class Documentation

struct ispell

Definition at line 14 of file ispell.h.

Collaboration diagram for ispell:
Class Members
struct ispell_misspelled * first_misspelled
char * ispell_buf
struct ispell_misspelled

Definition at line 19 of file ispell.h.

Collaboration diagram for ispell_misspelled:
Class Members
struct ispell_suggestion * first_suggestion
const char * misspelled_word
struct ispell_misspelled * next
int word_pos
struct ispell_suggestion

Definition at line 26 of file ispell.h.

Collaboration diagram for ispell_suggestion:
Class Members
struct ispell_suggestion * next
const char * suggested_word

Function Documentation

void ispell_free ( struct ispell )

Definition at line 275 of file ispell.c.

{
struct ispell_misspelled *msp;

       while ((msp=isp->first_misspelled) != 0)
       {
       struct ispell_suggestion *sgp;

              isp->first_misspelled=msp->next;

              while ((sgp=msp->first_suggestion) != 0)
              {
                     msp->first_suggestion=sgp->next;
                     free(sgp);
              }

              free(msp);
       }

       if (isp->ispell_buf) free(isp->ispell_buf);
       free(isp);
}

Here is the caller graph for this function:

struct ispell* ispell_run ( const char *  dictionary,
const char *  line 
) [read]

Definition at line 181 of file ispell.c.

{
char   *p, *q;
struct ispell *isp;
struct ispell_misspelled **islistptr, *ip;
int    c;
int    nmisses;
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;

       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);
       }
       ++p;
       q=0;
       islistptr= &isp->first_misspelled;
       for ( ; p && *p != '\n'; p=q)
       {
              if ((q=strchr(p, '\n')) != 0)
                     *q++=0;

              if ( *p != '&' && *p != '?' && *p != '#') continue;

              if ( (ip=*islistptr=(struct ispell_misspelled *)
                     malloc(sizeof(struct ispell_misspelled))) == 0)
              {
                     perror("malloc");
                     ispell_free(isp);
                     return (0);
              }

              ip->next=0;
              islistptr= &ip->next;

              c=*p++;
              while (*p == ' ')    ++p;
              ip->misspelled_word=p;
              while (*p && *p != ' ')     ++p;
              if (*p)       *p++=0;

              nmisses=0;
              while (*p == ' ')    ++p;
              if (c == '&' || c == '?')
              {
                     while (*p >= '0' && *p <= '9')
                            nmisses=nmisses * 10 + *p++ - '0';
                     while (*p == ' ')    ++p;
              }

              ip->word_pos=0;
              while (*p >= '0' && *p <= '9')
                     ip->word_pos=ip->word_pos * 10 + *p++ - '0';
              ip->first_suggestion=0;
              if (nmisses == 0 || *p != ':')     continue;
              ++p;
              sp= &ip->first_suggestion;
              while (nmisses)
              {
                     if ( (*sp=(struct ispell_suggestion *)
                            malloc(sizeof(struct ispell_suggestion)))
                            == 0)
                     {
                            perror("malloc");
                            ispell_free(isp);
                            return (0);
                     }
                     (*sp)->suggested_word=strtok(p, ", ");
                     p=0;
                     (*sp)->next=0;
                     sp= &(*sp)->next;
                     --nmisses;
              }
       }
       return (isp);
}

Here is the call graph for this function:

Here is the caller graph for this function: