antoine-source/appleworksgs/Spell/Src/SP.C

1 line
19 KiB
C++
Raw Normal View History

2023-03-04 02:45:20 +00:00
/* SP.C Robert A. Hearn */ #include <types.h> #include <memory.h> #include "sp.h" #include "spdef.h" #include "sc.h" #include "scparam.h" #include "string.h" /*#include "ctype.h"*/ #include "stdio.h" #include "query.h" #include "clam.h" #include "lex.h" #include "corelex.h" #include "driver.h" /* SP.C: This file contains the SP routines, which interface to the Proximity routines. The assembly language interface to these routines is in spint.src. Unless I hand-code some of these, which seems fairly probable. */ extern char *SPJumpLoc[]; extern unsigned _SPActive[]; extern unsigned _THActive; /* SP private globals */ unsigned _SPListAlts; unsigned _SPXVal; unsigned _SPID; long _SPHandler; char *_SPdir; char *WcurDoc; /* so it can be updated */ char *SPCancelled = "\pSpell checking was cancelled."; char *SPBroken = "\pCould not open the user dictionary.\rIt may be corrupt."; /* Stuff local to sp.c */ static unsigned inhyph; /* In hypenated word to scan word-by-word */ static unsigned mustbecap; /* This word must be capitalized */ static unsigned repeating; /* Calling GetWord at same place as before */ static unsigned wantperiod; /* GetWord should attach ending pd to word */ static unsigned firsttime; /* First time through SPCheck? */ static char *cmndtab; /* Command char table */ static char lastword[MAXWORD]; /* Previous word */ static unsigned lastflags; /* Previous word's flags */ static unsigned cancelled; /* Cancelled? */ static unsigned errcode; /* What spelling error occurred? */ static unsigned result; /* These are maintained by lots of things. */ static char *sp; /* Word start ptr */ static char *ep; /* Word end ptr */ static char *rp; /* Ptr to rest of text (after endpunc) */ char *prevp; /* pointer to the end of the previous word */ /* These are maintained by GetWord. */ static char wbuf[MAXWORD]; /* Word buffer */ static unsigned flags; /* Word characteristics */ static char epfirst; /* First chararacter in end punctuation */ static char eplast; /* Last character in end punctuation */ static char epnum; /* Number of end punctuation chars */ /* This is maintained by CheckWord. */ static char corbuf[MAXWORD]; /* Corrected word if SPCMISPUNC or SPCHYPH. */ /* This is for the udict stuff */ CLAM *_SPudtable[SPMAXUDICT]; /* CLAM ptrs */ char **_SPudpn[SPMAXUDICT]; /* Pathname handles */ /* Static declarations for wimpy C compiler */ static int NextChar(); static unsigned EatWhite(); static unsigned GetWord(); static unsigned CheckWord(); static void MakeLower(); static unsigned GetUDSlot(); extern pascal unsigned _SPMetaHandler(); /* Startup the spell checker. */ pascal void _SPStartUp(mmid, spdir) unsigned mmid; char *spdir; { unsigned len; unsigned x; if (_SPActive[0]) SPErr2(SPACTIVE, 0); _SPErrNum[0] = 0; _SPID = _SPTHID[0] = mmid + SPTHID; toolErr[0] = &_toolErr; /* &%^$%$!@@!@!! */ if (!meminit()) SPErr2(SPNOMEM, 0); len = *(unsigned *) spdir; _SPdir = spdir+2; _SPdir[len] = '\0'; if (!clxopen(1, SP_CORRECT + SP_DETECT)) if (*toolErr[0]) { SPErr2(SPPRODOS, *toolErr[0]); } else { SPErr2(SPCANTDOIT, 0); } strcat(_SPdir, "Dictionary"); if (!lexopen(2, SP_CORRECT + SP_DETECT, _SPdir)) { if (*toolErr[0]) { SPErr2(SPPRODOS, *toolErr[0]); } else { SPErr2(SPCANTDOIT, 0); } } for (x = 0; x < SPMAXUDICT; ++x) _SPudtable[x] = NULL; _SPActive[0] = 1; } /* Shut down SP */ pascal vo