home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 495a.lha / ISpell_v3.1ljr / src / local.c < prev    next >
C/C++ Source or Header  |  1991-04-06  |  1KB  |  76 lines

  1. /*
  2.  *   handles local words.  simple hack.  no pride.
  3.  *
  4.  *   (Thanks tgr! Not a bad hack. --- LJR)
  5.  */
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include <proto/all.h>
  10. #include "ispell.h"
  11.  
  12. static int localcount = 0;
  13.  
  14. #define MAXLINELEN 70
  15.  
  16. struct wptr
  17. {
  18.   struct wptr *next;
  19.   char word[4];
  20. } *wptr;
  21.  
  22. void lldump (void)
  23. {
  24.   FILE *f;
  25.   char localname[32];
  26.   struct wptr *p, *q;
  27.   int loc;
  28.   int len;
  29.  
  30.   strcpy (localname, "local.words");
  31.   if (localcount)
  32.     sprintf (localname + strlen (localname), "%d", localcount);
  33.   f = fopen (localname, "w");
  34.   if (f != NULL)
  35.     {
  36.       loc = 0;
  37.       for (p = wptr; p;)
  38.     {
  39.       q = p->next;
  40.       len = strlen (p->word) + 1;
  41.       if (len + loc > MAXLINELEN)
  42.         {
  43.           putc ('\n', f);
  44.           loc = 0;
  45.         }
  46.       if (loc == 0)
  47.         {
  48.           fprintf (f, " ispell'local'words");
  49.           loc = 19;
  50.         }
  51.       fputc (' ', f);
  52.       fputs (p->word, f);
  53.       loc += len;
  54.       free (p);
  55.       p = q;
  56.     }
  57.       wptr = NULL;
  58.       fclose (f);
  59.     }
  60.   localcount++;
  61. }
  62.  
  63. void llinsert (char *s)
  64. {
  65.   int len;
  66.   struct wptr *p;
  67.  
  68.   len = 5 + strlen (s);
  69.   if ((p = malloc (len)))
  70.     {
  71.       strcpy (p->word, s);
  72.       p->next = wptr;
  73.       wptr = p;
  74.     }
  75. }
  76.