home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d191 / ispell.lha / ISpell / src.zoo / local.c < prev    next >
C/C++ Source or Header  |  1989-02-22  |  1KB  |  60 lines

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