home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
txtutl
/
cspelsrc.arc
/
CSPELLA.C
< prev
next >
Wrap
Text File
|
1987-12-09
|
49KB
|
2,320 lines
/* PROGRAM dumb.C */
/* by Peter A. Banks */
/* Home phone 481-8242 */
/* Work Phone 568-4855 */
/* Compiled under Turbo C (tcc) */
/* linked with Microsoft linker */
/* Turbo's linker did not work */
#include "stdio.h"
#include "io.h"
#include "alloc.h"
#include "conio.h"
#include "ctype.h"
#include "stdlib.h"
#include "dir.h"
#include "string.h"
#include "DOS.H"
#include "limits.h"
#include "stddef.h"
#define NO_DEBUG
#define LINELIM 255 /* maX NUMBER
CHARACTERS PER LINE */
#define WORDSTAR 0
#define SEDT_PTP 144
#define MAXWRD 20
#define MAXLINE 255
#define CRET 13
#define DEL 127
#define PERIOD 46
#define BCKSP 8
#define COLON 58
#define SLASH 47
#define BCKSLSH 92
#define HYPHEN 45
/* Globals varables define */
int video = 0;
int wrrd = 0;
int totwrd; /* TOTAL WORDS */
int mspwrd; /* miss-spelled words */
int result; /* RESULT OF FOPEN */
int letcnt = 0; /* LETTER COUNT OF WORD */
int hyphcnt = 0; /* LETTER COUNT OF WORD */
int perdex = 0; /* pointer of personal dictionary */
int lnlength = 0; /* length of line */
long int memaval;
char *path ;
char *drive;
char *dirr ;
char *nam ;
char *ext ;
char srcline [MAXLINE];
char wordtex[MAXWRD] = ""; /* word extracted from source line */
char hyphtex[MAXWRD] = ""; /* word extracted from source line with hyphen */
char srchtx[MAXWRD]; /* word extracted from source line */
char srchtex[MAXWRD]; /* word extracted from source line */
char *dctenv = NULL;
char *chrpnt = NULL;
char outln [MAXLINE];
char perdctt = 1;
unsigned char hyphen = 0;
unsigned char hyphen1 = 0;
unsigned char hyphen2 = 0;
unsigned char marker = SEDT_PTP;
char *srcdir = NULL;
char fylnam [60];
char tmmpnam [60];
char perdctnam [60];
char *tmpnam;
char *tmpfyl;
FILE *source;
FILE *perdct;
FILE *output;
FILE *temp;
/* dictionaries defined */
#define THREELN 478
extern char threedct [THREELN] [4];
int threesiz = THREELN;
#define FOURLN 1439
extern char fourdct [FOURLN] [5];
#define FIVELN 1968
extern char fivedct [FIVELN] [6];
#define SIXLN 2378
extern char sixdct [SIXLN] [7];
#define SEVNLN 2382
extern char sevndct [SEVNLN] [8];
#define EIGHTLN 2013
extern char eightdct [EIGHTLN] [9];
#define NINELN 1807
extern char ninedct [NINELN] [10];
#define TENLN 1331
extern char tendct [TENLN] [11];
#define ELEVENLN 943
extern char elevendct [ELEVENLN] [12];
#define TWELVELN 529
extern char twelvedct [TWELVELN] [13];
#define T3TENLN 347
extern char t3tendct [T3TENLN] [14];
#define FORTENLN 156
extern char fortendct [FORTENLN] [15];
#define FIVTENLN 74
extern char fivtendct [FIVTENLN] [16];
#define SIXTENLN 42
extern char sixtendct [SIXTENLN] [17];
#define SEVTENLN 18
extern char sevtendct [SEVTENLN] [18];
#define EITENLN 4
extern char eitendct [EITENLN] [19];
int persize;
extern char personaldct [1500] [21];
int collums;
int page;
int mode;
#ifdef TIMER
struct time st_time;
struct time end_time;
struct time tot_time;
#endif TIMER
union REGS reg;
void GOTOXY(x,y)
int x,y;
{
#ifdef CLONE
reg.h.ah = 2;
reg.h.bh = page;
reg.h.dl = x;
reg.h.dh = y;
int86(0x10,®,®);
#endif CLONE
#ifdef RAINBOW
cprintf("\033[%1d;%1df",y,x);
#endif RAINBOW
}
void selpage(page)
int page;
{
reg.h.ah = 5;
reg.h.al = 131;
reg.h.bh = page;
reg.h.bl = 01;
int86(0x10,®,®);
}
int getmode()
{
reg.h.ah = 15;
reg.h.al = 0;
reg.h.bh = 0;
reg.h.bl = 0;
int86(0x10,®,®);
mode = reg.h.al;
page = reg.h.bh;
collums = reg.h.ah;
#ifdef DEBUG
printf("%d active page %d mode %d collums",page,mode,collums);
getche();
#endif DEBUG
}
void CLRSCRN()
{
#ifdef CLONE
reg.h.ah = 6;
reg.h.al = 25;
reg.h.bh = 7;
reg.h.ch = 0;
reg.h.cl = 0;
reg.h.dl = 79;
reg.h.dh = 25;
int86(0x10,®,®);
#endif CLONE
#ifdef RAINBOW
cprintf("\033[2J");
#endif RAINBOW
GOTOXY(0,0);
}
#ifdef CLONE
void scrolup(x)
int x;
{
reg.h.ah = 6;
reg.h.al = x;
reg.h.bh = 7;
reg.h.ch = 6;
reg.h.cl = 0;
reg.h.dl = 79;
reg.h.dh = 20;
int86(0x10,®,®);
GOTOXY(00,19);
}
#endif CLONE
#ifdef CLONE
void scroldwn(x)
int x;
{
GOTOXY(30,22);
reg.h.ah = 7;
reg.h.al = x;
reg.h.bh = 7;
reg.h.ch = 22;
reg.h.cl = 30;
reg.h.dl = 60;
reg.h.dh = 25;
int86(0x10,®,®);
}
#endif CLONE
char *getpath(filnm)
char filnm [60];
{
char *dirr;
char *ptr;
int lnlgth;
int indx;
lnlgth = strlen(filnm);
while ((filnm[lnlgth] != COLON) && (filnm[lnlgth] != SLASH) && (filnm[lnlgth] != BCKSLSH))
lnlgth--;
if (coreleft())
dirr = malloc (61);
ptr = dirr;
for(indx = 0; indx <=lnlgth; indx++)
{
*ptr = filnm[indx];
ptr++;
}
if(filnm [indx-1] == COLON)
{
*ptr = SLASH;
ptr++;
}
*ptr = 0;
return(dirr);
}
void dumpdic()
{
char buf;
int totdic = 0;
register int index = 0;
#ifdef RAINBOW
GOTOXY(00,19);
#endif RAINBOW
while (index < THREELN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,threedct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,threedct [index],totdic);
#endif RAINBOW
index++;
}
index = 0;
while (index < FOURLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,fourdct [index], totdic);
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r ",index,fourdct [index], totdic);
#endif RAINBOW
index++;
}
index = 0;
while (index < FIVELN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,fivedct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,fivedct [index],totdic );
#endif
index++;
}
index = 0;
while (index < SIXLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,sixdct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,sixdct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < SEVNLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,sevndct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,sevndct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < EIGHTLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,eightdct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,eightdct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < NINELN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,ninedct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,ninedct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < TENLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,tendct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,tendct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < ELEVENLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,elevendct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,elevendct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < TWELVELN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,twelvedct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,twelvedct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < T3TENLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,t3tendct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,t3tendct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < FORTENLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,fortendct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,fortendct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < FIVTENLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,fivtendct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,fivtendct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < SIXTENLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,sixtendct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,sixtendct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < SEVTENLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,sevtendct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,sevtendct [index],totdic );
#endif RAINBOW
index++;
}
index = 0;
while (index < EITENLN)
{
totdic++;
#ifdef CLONE
scrolup (1);
cprintf ("%d %s %d ",index,eitendct [index],totdic );
#endif CLONE
#ifdef RAINBOW
cprintf ("%d %s %d \n\r",index,eitendct [index],totdic );
#endif RAINBOW
index++;
}
#ifdef CLONE
scrolup (1);
cprintf(" The total number of word in dictionary = %d ",totdic);
scrolup (1);
cprintf(" type any key to return to operating system ___\b\b");
#endif CLONE
#ifdef RAINBOW
cprintf ("\n\r The total number of word in dictionary = %d \n\r ",totdic);
cprintf ("\n\r type any key to return to operating system ___\b\b");
#endif CLONE
getch ();
CLRSCRN();
#ifdef RAINBOW
cputs("\033[00;24r");
#endif RAINBOW
exit(0);
}
char *header =
" COPYRIGHT (C) by Peter A. Banks\n\r"
" SUPA-DUPA-SPELLA\n\r"
" C-Version 1.0";
char *help_screen =
" The CSPELLA command line is\r\n\r\n"
" CSPELLA <FILENAME> <USERDIC> -V -D -N -M?\r\n\r\n"
" -V enable Video display of text\r\n"
" -D dumps all of the dictionaries to Video Screen\r\n"
" -M allows user to define mark character\r\n\r\n"
" -N WARNING DO NOT USE WITH SEDT OR PTP. LOSS OF DATA WILL RESULT\r\n"
" -N Is used for WORDSTAR Compatitibility Only.\r\n\r\n"
" Switches can be place before or after the file names\r\n\r\n"
" Source Document must be listed before the optional Personal Dictionary\r\n\r\n"
" Please hit any key to continue___\b\b";
#ifdef CLONE
char *srcdoc =
" Enter document to be Spelled [Default Exit]\n\r"
" ________________________________________________________________________";
char *personaldctnam =
" Enter Personal dictionary [Default None]\n\r"
" ________________________________________________________________________";
#endif CLONE
#ifdef RAINBOW
char *srcdoc =
" Enter document to be Spelled [Default Exit]\n\r"
" ________________________________________________________________________";
char *personaldctnam =
" Enter Personal dictionary [Default None]\n\r"
" ________________________________________________________________________";
#endif RAINBOW
char *set_enviroment =
" CSPELLA is not defined in AUTOEXEC.BAT.\n\r\n\r"
" Place the following in Autoexec.bat.\n\r\n\r"
" Set CSPELLA=DRV:\\CSPELLA PATH \n\r\n\r\n\r"
" The directory that Cspella is in should also be\n\r"
" placed in MSDOS PATH statement the Autoexec.bat.\n\r\n\r"
" PATH=DRV:\\CSPELLA PATH\\;\n\r\n\r\n\r"
" Hit any key to continue___\b\b";
char ootbuff [12288];
char inbuff [12288];
void setfyl(argc,argv)
int argc;
char **argv;
{
int newdir;
int ind,xx;
char buf,pd,src;
char bufa;
newdir = 0;
pd = 0;
src = 0;
dctenv = getenv("CSPELLA");
CLRSCRN();
cputs(header);
if (dctenv==NULL)
{
GOTOXY(00,06);
cputs(set_enviroment);
getch();
CLRSCRN();
cputs(header);
}
if (argc == 1)
{
GOTOXY(00,05);
cputs(help_screen);
getch();
CLRSCRN();
cputs(header);
}
else
{
ind =1;
while (ind < argc)
{
if (argv[ind][0] == '-')
{
switch (argv[ind][1])
{
case 'N':
marker = WORDSTAR;
break;
case 'M':
marker = argv[ind][2];
break;
case 'D':
dumpdic();
break;
case 'V':
video = 121;
break;
} /* end case */
}
else
if (!src)
{
strcpy(fylnam,argv[ind]);
src = 255;
}
else
if (src)
{
pd = 131;
strcpy(perdctnam,argv[ind]);
}
ind++;
} /* end while */
GOTOXY(00,07);
puts(srcdoc);
GOTOXY(3,8);
if (src)
{
cputs(fylnam);
if ((source = fopen(fylnam,"rt")) == NULL)
{
GOTOXY(3,9);
perror("Could not open FILE try again");
GOTOXY(3,8);
}
}
} /* END ELSE */
if ((source == NULL) || (argc == 1))
while (source== NULL)
{
GOTOXY(00,07);
cputs(srcdoc);
GOTOXY(3,8);
gets(fylnam);
ind = strlen(fylnam);
if (ind == 0)
{
CLRSCRN();
GOTOXY(0,0);
cputs("exiting to operating system");
#ifdef RAINBOW
cputs("\033[00;24r");
#endif RAINBOW
exit(0);
}
if ((source = fopen(fylnam,"rt")) == NULL)
{
GOTOXY(3,9);
perror("Could not open FILE try again");
GOTOXY(3,8);
}
}
if ((strchr(fylnam,COLON)) || (strchr(fylnam,SLASH)) || (strchr(fylnam,BCKSLSH)))
{ /* finds the directory is in and save it in srcdir */
srcdir=getpath(fylnam);
tmpfyl = strcat(srcdir,"$$$$.TMP");
}
else
tmpfyl = "$$$$.TMP";
if ((output = fopen(tmpfyl,"wt")) == NULL)
{ /* open file for spelled document to go into */
GOTOXY(3,9);
perror("Could not open temp FILE try again");
ClRSCRN();
#ifdef RAINBOW
cputs("\033[00;24r");
#endif RAINBOW
exit(0);
}
setvbuf(output,ootbuff,_IOFBF,12288);
setvbuf(source,inbuff,_IOFBF,12288);
/* code for Personal Dictionary needed next */
GOTOXY(00,10);
puts(personaldctnam);
GOTOXY(3,11);
if (pd)
{
cputs(perdctnam);
if ((perdct = fopen(perdctnam,"rt")) == NULL)
if (dctenv == NULL)
{
GOTOXY(3,13);
perror("file error try again ");
GOTOXY(3,11);
}
else
{
strcpy(perdctnam,(strcat(dctenv,perdctnam)));
if ((perdct = fopen(perdctnam,"rt")) == NULL)
{
GOTOXY(3,13);
perror("Could not open FILE try again");
GOTOXY(3,11);
}
}
}
else
newdir = 3;
ind = 12;
if (perdct == NULL)
while ((perdct== NULL) && (ind))
{
GOTOXY(00,10);
puts(personaldctnam);
GOTOXY(3,11);
gets(perdctnam);
ind = strlen(perdctnam);
if((ind) && ((perdct = fopen(perdctnam,"rt")) == NULL))
{
if (dctenv == NULL)
{
GOTOXY(3,13);
perror("file error try again ");
GOTOXY(3,11);
}
else
{
strcpy(perdctnam,(strcat(dctenv,perdctnam)));
if ((perdct = fopen(perdctnam,"rt")) == NULL)
{
GOTOXY(3,13);
perror("Could not open FILE try again");
GOTOXY(3,11);
}
}
}
else
newdir = 3;
}
if ((newdir)
&&
((strchr(perdctnam,COLON))
||
(strchr(perdctnam,SLASH))
||
(strchr(perdctnam,BCKSLSH))))
/*finds the directory is in and save it in dctenv */
dctenv=getpath(perdctnam);
if (perdct)
{
strcpy(personaldct[0],"@@@@@@@@@@@@@@@@");
ind =1;
while ((!feof(perdct)) && (ind <= 1498))
{
fgets(personaldct [ind],20,perdct);
xx=strlen(personaldct[ind]);
xx--;
personaldct[ind][xx]=0;
ind++;
}
ind--;
strcpy(personaldct[ind],"[[[[[[[[[[[[[[[[");
persize = ind;
fclose(perdct);
ind =0;
}
else persize= 0;
}
int serperdct (key)
char *key;
{
int high,low,mid,result;
high =persize;
low = 0;
while (low < (high-1))
{
mid = (low+high)/2;
if ((low+high)%2 == 1) mid++;
result = strcmp(key,personaldct[mid]);
#ifdef DEBUG
scrolup (1);
cprintf("%s key %s personal dct %d ",key,personaldct[mid],result);
getch();
#endif DEBUG
if (result == 0) return (9999);
else
if (result < 0) high = mid;
else
low = mid;
}
return (0);
}
int wordsearch(key,lngth)
char *key;
int lngth;
{
int location;
char *wrd;
wrd = 0;
switch(lngth)
{
case 5:
wrd = bsearch (key,fivedct,FIVELN,6,strcmp);
break;
case 4:
wrd = bsearch (key,fourdct,FOURLN,5,strcmp);
break;
case 3:
wrd =bsearch (key,threedct,THREELN,4,strcmp);
break;
case 6:
wrd = bsearch (key,sixdct,SIXLN,7,strcmp);
break;
case 7:
wrd = bsearch (key,sevndct,SEVNLN,8,strcmp);
break;
case 8:
wrd = bsearch (key,eightdct,EIGHTLN,9,strcmp);
break;
case 9:
wrd = bsearch (key,ninedct,NINELN,10,strcmp);
break;
case 10:
wrd = bsearch (key,tendct,TENLN,11,strcmp);
break;
case 11:
wrd = bsearch (key,elevendct,ELEVENLN,12,strcmp);
break;
case 12:
wrd = bsearch (key,twelvedct,TWELVELN,13,strcmp);
break;
case 13:
wrd = bsearch (key,t3tendct,T3TENLN,14,strcmp);
break;
case 14:
wrd = bsearch (key,fortendct,FORTENLN,15,strcmp);
break;
case 15:
wrd = bsearch (key,fivtendct,FIVTENLN,16,strcmp);
break;
case 16:
wrd = bsearch (key,sixtendct,SIXTENLN,17,strcmp);
break;
case 17:
wrd = bsearch (key,sevtendct,SEVTENLN,18,strcmp);
break;
case 18:
wrd = bsearch (key,eitendct,EITENLN,19,strcmp);
}
if (!wrd)
return (0);
else
return (127);
}
int stripsufix(lngth)
int lngth;
{
int wrd;
char tex [21];
int lstch; /* last chariter in string */
strcpy(tex,srchtex);
lstch = lngth;
wrd =0;
switch(tex [(--lstch)])
{
case 'S':
tex[lstch]= 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup (1);
printf("%s %s strip plural s",tex,srchtex);
getch ();
#endif DEBUG
if (wrd) return(wrd);
lstch--;
if ((tex[lstch]=='E') && (lngth >=5)) /* strip es*/
{
tex[lstch]= 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup (1);
cprintf("%s %s strip es ",tex,srchtex);
getch ();
#endif DEBUG
if (wrd) return(wrd);
if ((tex[--lstch]=='I') && (lngth >=5)) /* strip ies*/
{
tex[lstch++]= 'Y';
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup (1);
cprintf("%s %s str i add y ",tex,srchtex);
getch ();
#endif DEBUG
if (wrd) return(wrd);
}
}
else
if ((tex[lstch]=='R') && (lngth >=5))
{
/* strip rs */
tex[lstch]= 0;
wrd = wordsearch(tex,lstch);
if (wrd) return(wrd);
lstch--;
if ((tex[lstch]=='E') && (lngth >=6)) /* strip ers*/
{
tex[lstch]= 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup (1);
cprintf("%s %s strip ers",tex,srchtex);
getch ();
#endif DEBUG
if (wrd) return(wrd);
if ((tex[--lstch]=='I') && (lngth >=6)) /* strip iers*/
{
tex[lstch++]= 'Y';
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup (1);
cprintf("%s %s strip I add Y ",tex,srchtex);
getch();
#endif DEBUG
return(wrd);
}
}
}
else
if ((tex[lstch] == 'G')
&&
(tex[--lstch] == 'N')
&&
(tex[--lstch] == 'I')
&&
(lngth >=7)) /* ings */
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup (1);
cprintf("%s %s removing ings ",tex,srchtex);
getch ();
#endif DEBUG
if (wrd) return(wrd);
tex[lstch]='E';
lstch++;
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup (1);
cprintf("%s %s add E ",tex,srchtex);
getch ();
#endif DEBUG
return(wrd);
}
else
if ((tex[lstch] == 39) && (lngth >=5)) /* strip 's */
{
tex[lstch]= 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup (1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
return(wrd);
}
else
if ((tex[lstch] == 'S')
&&
(tex[(--lstch)] == 'E')
&&
(tex[(--lstch)] == 'N')
&&
(lngth >=7)) /* ness */
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup (1);
cprintf("%s %s ness ",tex,srchtex);
getch ();
#endif DEBUG
if (wrd) return(wrd);
lstch--;
if (tex[lstch] == 'I')
{
tex[lstch]='Y'; /* business to busy */
tex[++lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup (1);
cprintf("%s %s ",tex,srchtex);
getch ();
#endif DEBUG
}
}
else
if ((tex[lstch] == 'N') &&
(tex[--lstch] == 'O') &&
(tex[--lstch] == 'I') &&
(letcnt > 6))
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
if (wrd) return(wrd);
tex[lstch++]='E';
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
if (wrd) return(wrd);
lstch--;
if (( tex[--lstch] == 'T') && ( letcnt > 6 ))
{
tex[lstch] = 0;
wrd = wordsearch(tex,lstch);
if (wrd) return (wrd);
if (( tex[--lstch] == 'A') && ( tex[--lstch] == 'C')
&& ( tex[--lstch] == 'I') && ( letcnt > 9 ))
{
tex[lstch] = 0;
wrd = wordsearch(tex,lstch);
if (wrd) return (wrd);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
tex[lstch] = 'Y';
tex[++lstch] = 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
return(wrd);
}
}
}
/* END OF S CASE */
case 'D':
tex[lstch]= 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
cprintf("%s %s remove d",tex,srchtex);
scrolup (1);
getch ();
#endif DEBUG
if (wrd) return(wrd);
lstch--;
if ((tex[lstch]=='E') && (lngth >=5))
{
tex[lstch]= 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
cprintf("%s %s ",tex,srchtex);
scrolup (1);
getch ();
#endif DEBUG
if (wrd) return(wrd);
lstch--;
if ((tex[lstch]=='I') && (lngth >=5)) /* strip ies*/
{
tex[lstch]= 'Y';
tex[++lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
cprintf("%s %s ",tex,srchtex);
scrolup (1);
getch ();
#endif DEBUG
}
}
return(wrd);
case 'R':
tex[lstch]= 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
cprintf("%s %s remove R",tex,srchtex);
scrolup (1);
getch();
#endif DEBUG
if (wrd) return(wrd);
if ((tex[--lstch]=='E') && (lngth >=5))
{
tex[lstch]= 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
cprintf("%s %s remover er",tex,srchtex);
scrolup (1);
getch();
#endif DEBUG
if (wrd) return(wrd);
if ((tex[--lstch]=='I') && (lngth >=5)) /* strip ies*/
{
tex[lstch]= 'Y';
tex[++lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
cprintf("%s %s ",tex,srchtex);
scrolup (1);
getch ();
#endif DEBUG
}
}
return(wrd);
case 'G':
if ((tex[--lstch]== 'N') && (tex[--lstch] == 'I')
&&
(lngth >=5)) /* ing */
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s removing ing ",tex,srchtex);
getch ();
#endif DEBUG
if (wrd) return(wrd);
tex[lstch]='E';
lstch++;
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s add e",tex,srchtex);
getch ();
#endif DEBUG
}
return(wrd);
case 'Y':
if ((tex[--lstch]== 'L') &&
(lngth >=5)) /* ly */
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
if (wrd) return(wrd);
}
else
if ((tex[lstch]== 'C') &&
(lngth >=5)) /* cy */
{
tex[lstch]='T';
lstch++;
tex[lstch] = 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
}
return(wrd);
case 'T':
if ((tex[--lstch] == 'S') && (letcnt > 4))
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
if (wrd) return(wrd);
{
if((tex[--lstch] == 'E') && (letcnt >= 6))
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
if (wrd) return(wrd);
if ((tex[--lstch] == 'I') && (letcnt > 7))
{
tex[lstch] = 'Y';
tex[++lstch] = 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
return(wrd);
}
}
}
}
else
#ifdef DEBUG
scrolup(1);
cprintf("%s %c",tex,srchtex[lstch]);
getch();
#endif DEBUG
if ((tex[lstch] == 'N')
&&
(tex[--lstch] == 'E')
&&
(tex[--lstch] == 'M')) /* remove ment */
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
if (wrd) return(wrd);
if ((tex[--lstch] == 'I') && (letcnt > 7))
{
tex[lstch] = 'Y';
tex[++lstch] = 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
}
}
return(wrd);
case 'H':
if ((tex[(--lstch)] == 'T') || (tex[lstch] == 'S'))
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
if (wrd) return(wrd);
if ((tex[(--lstch)] == 'I') && (letcnt > 5))
{
tex[lstch] = 'Y';
tex[++lstch] = 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
}
}
return (wrd);
case 'E':
if ((tex[--lstch] == 'V') && (tex[--lstch] == 'I') && (letcnt > 5))
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
if (wrd) return(wrd);
tex[lstch]= 'E';
tex[++lstch] = 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
return(wrd);
}
case 'N':
if ((tex[--lstch] == 'O') && (tex[--lstch] == 'I') && (letcnt > 5))
{
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
if (wrd) return(wrd);
tex[lstch++]='E';
tex[lstch]=0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
if (wrd) return(wrd);
lstch--;
if (( tex[--lstch] == 'T') && ( letcnt > 6 ))
{
tex[lstch] = 0;
wrd = wordsearch(tex,lstch);
if (wrd) return (wrd);
if (( tex[--lstch] == 'A') && ( tex[--lstch] == 'C')
&& ( tex[--lstch] == 'I') && ( letcnt > 9 ))
{
tex[lstch] = 0;
wrd = wordsearch(tex,lstch);
if (wrd) return (wrd);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
tex[lstch] = 'Y';
tex[++lstch] = 0;
wrd = wordsearch(tex,lstch);
#ifdef DEBUG
scrolup(1);
cprintf("%s %s ",tex,srchtex);
getch();
#endif DEBUG
return(wrd);
}
}
}
} /* end of switch statement */
return(wrd);
} /* end of procedure */
struct misspword
{
char textword[MAXLINE];
char edtedword[MAXLINE];
char action;
struct misspword *grtrthan;
struct misspword *lessthan;
};
struct misspword rot;
struct misspword *root;
struct misspword *prrt;
char found;
char wrytt;
void wrtheep(prt)
struct misspword *prt;
{
if (prt==NULL)
{
if (coreleft())
root = malloc(sizeof(rot));
prt= root;
strcpy(prt->textword,srchtex);
prt->lessthan = NULL;
prt->grtrthan = NULL;
#ifdef CLONE
scroldwn(1);
cprintf("%s",wordtex);
if (video) GOTOXY(0,19);
#endif CLONE
#ifdef RAINBOW
if (video)
cprintf("\033[22;30f%s \033[19;00f",wordtex);
else
cprintf("\033[22;30f%s \r",wordtex);
#endif RAINBOW
#ifdef DEBUG
scrolup(1);
cprintf("root created NULL");
getch();
#endif DEBUG
}
else
if (0 == stricmp(prt->textword,srchtex))
found = 'F';
else
if(0 < stricmp(prt->textword,srchtex))
{
if (prt->lessthan == NULL)
{
if (coreleft())
prt->lessthan = malloc(sizeof(rot));
prt=prt->lessthan;
strcpy(prt->textword,srchtex);
prt->lessthan = NULL;
prt->grtrthan = NULL;
#ifdef CLONE
scroldwn(1);
cputs(wordtex);
if (video) GOTOXY(0,19);
#endif CLONE
#ifdef RAINBOW
if (video)
cprintf("\033[22;30f%s \033[19;00f",wordtex);
else
cprintf("\033[22;30f%s \r",wordtex);
#endif RAINBOW
#ifdef DEBUG
scrolup(1);
cprintf("node less than created");
getch();
#endif DEBUG
}
else
wrtheep(prt->lessthan);
}
else
if(0 > stricmp(prt->textword,srchtex))
{
if (prt->grtrthan == NULL)
{
if (coreleft())
prt->grtrthan = malloc(sizeof(rot));
prt=prt->grtrthan;
strcpy(prt->textword,srchtex);
prt->lessthan = NULL;
prt->grtrthan = NULL;
#ifdef CLONE
scroldwn(1);
cputs(wordtex);
if (video) GOTOXY(0,19);
#endif CLONE
#ifdef RAINBOW
if (video)
cprintf("\033[22;30f%s \033[19;00f",wordtex);
else
cprintf("\033[22;30f%s \r",wordtex);
#endif RAINBOW
#ifdef DEBUG
scrolup(1);
cputs("node greater than created");
getch();
#endif DEBUG
}
else
wrtheep(prt->grtrthan);
}
}
void readheep(prt)
struct misspword *prt;
{
char buf;
if (prt->lessthan != NULL)
readheep(prt->lessthan);
#ifdef CLONE
scrolup(2);
#endif CLONE
cprintf(" Add to dictionary %s ?? ___\b\b",prt->textword);
buf = (char)getche();
if ((buf =='Y') || (buf =='y'))
{
fprintf(perdct,"%s\n",prt->textword);
#ifdef RAINBOW
cputs("_ ADDED \n\r");
#endif RAINBOW
#ifdef CLONE
cputs("_ ADDED");
#endif CLONE
}
else
if ((buf == 'q') || (buf == 'Q'))
{
CLRSCRN();
#ifdef RAINBOW
cputs("\033[00;24r");
#endif RAINBOW
exit(0);
}
if (prt->grtrthan != NULL) readheep(prt->grtrthan);
}
void reedheep(prt)
struct misspword *prt;
{
char buf;
if (prt->lessthan != NULL)
reedheep(prt->lessthan);
while ((1 > strcmp(personaldct[perdex],prt->textword))
&&
( perdex < persize))
{
fprintf(perdct,"%s\n",personaldct[perdex]);
perdex++;
}
#ifdef CLONE
scrolup(2);
#endif CLONE
cprintf(" Add to dictionary %s ?? ___\b\b",prt->textword);
buf = (char)getche();
#ifdef RAINBOW
cputs("\n\r\n\r");
#endif RAINBOW
if ((buf =='Y') || (buf =='y'))
{
fprintf(perdct,"%s\n",prt->textword);
#ifdef RAINBOW
cputs("_ ADDED \n\r\n\r");
#endif RAINBOW
#ifdef CLONE
cputs("_ ADDED");
#endif CLONE
}
if ((buf == 'q') || (buf == 'Q'))
{
CLRSCRN();
#ifdef RAINBOW
cputs("\033[00;24r");
#endif RAINBOW
exit(0);
}
if (prt->grtrthan != NULL) reedheep(prt->grtrthan);
}
char *newdic= " Enter New Personal Dictionary file name \n\r"
" _________________________________________________________________________\r ";
void addtodic()
{
int ind;
char buf, buf1;
#ifdef TIMER
unsigned char hunsec,sec,min;
#endif TIMER
#ifdef TIMER
gettime(&end_time);
if (end_time.ti_hund < st_time.ti_hund)
{
end_time.ti_hund = end_time.ti_hund +100;
end_time.ti_sec--;
} /* borrow */
hunsec = end_time.ti_hund - st_time.ti_hund;
if (end_time.ti_sec < st_time.ti_sec)
{
end_time.ti_sec = end_time.ti_sec + 60;
end_time.ti_min--;
}
sec = end_time.ti_sec - st_time.ti_sec;
min = end_time.ti_min - st_time.ti_min;
#endif TIMER
#ifdef CLONE
scrolup(14);
cprintf("\07\07 %d words %d miss-spelled",totwrd,mspwrd);
#endif CLONE
#ifdef RAINBOW
GOTOXY(0,19);
cprintf("\07\07 %d words %d miss-spelled\n\r\n\r",totwrd,mspwrd);
#endif RAINBOW
#ifdef TIMER
#ifdef CLONE
scrolup(2);
cprintf(" PROCESS TIME TOOK %02d min :%02d.%02d sec",min,sec,hunsec);
#endif CLONE
#ifdef RAINBOW
cprintf("\n\r\n\r PROCESS TIME TOOK %02d min :%02d.%02d sec/n/r",min,sec,hunsec);
#endif RAINBOW
#endif TIMER
#ifdef CLONE
scrolup(2);
#endif CLONE
cprintf (" Save the source file as a .b$k file? (n) ___\b\b");
buf = (char) getche();
#ifdef RAINBOW
cputs("\n\r\n\r");
#endif RAINBOW
fclose(output);
fclose(source);
if ((buf == 'Y') || (buf == 'y'))
{
strcpy(tmmpnam,fylnam);
letcnt = strlen(fylnam);
while (letcnt >=1)
{
if (tmmpnam[letcnt] == '.')
{
tmmpnam[letcnt]=0;
break;
}
#ifdef DEBUG
scrolup(1);
cprintf("%d\n\r",letcnt);
#endif DEBUG
letcnt--;
}
strcat (tmmpnam,".b$k");
#ifdef DEBUG
cprintf ("\n\r%s\n\r",tmmpnam);
getch();
#endif DEBUG
rename (fylnam,tmmpnam);
rename (tmpfyl,fylnam);
}
else
{
unlink(fylnam);
rename (tmpfyl,fylnam);
}
if ((!persize) && (mspwrd))
{
#ifdef CLONE
scrolup(2);
cprintf(" Create a Personal dictionary? [Default no]___\b\b");
buf = (char) getche();
#endif CLONE
#ifdef RAINBOW
cprintf(" Create a Personal dictionary? [Default no]___\b\b");
buf = (char) getche();
cputs("\n\r\n\r");
#endif RAINBOW
if ((buf == 'y') || (buf == 'Y'))
{
ind = 12;
#ifdef CLONE
scrolup(1);
cputs(newdic);
gets(perdctnam);
scrolup(1);
#endif CLONE
#ifdef RAINBOW
cputs(newdic);
gets(perdctnam);
cputs("\n\r\n\r");
#endif RAINBOW
ind = strlen(perdctnam);
if (((!strchr(perdctnam,COLON))
||
(!strchr(perdctnam,SLASH))
||
(!strchr(perdctnam,BCKSLSH)))
&&
(dctenv))
strcpy(perdctnam,(strcat(dctenv,perdctnam)));
if((ind) && (!access(perdctnam,06)))
{
fclose (perdct);
#ifdef CLONE
scrolup(2);
#endif CLONE
cprintf (" The File already exists do you wish to overwrite (N) ___\b\b");
buf = (char) getche();
#ifdef RAINBOW
cputs("\n\r\n\r");
#endif RAINBOW
if ((buf == 'Y') || (buf == 'y'))
perdct = fopen(perdctnam,"wt");
}
else
perdct = fopen(perdctnam,"wt");
if (perdct) readheep(root);
}
}
else
if ((persize) && (mspwrd))
{
#ifdef CLONE
scrolup(2);
#endif CLONE
cprintf(" Do you wish to add any words to your personal dictionary (N)___\b\b");
buf = (char)getche();
#ifdef RAINBOW
cputs("\n\r\n\r");
#endif RAINBOW
if ((buf == 'y') || (buf == 'Y'))
{
perdct = fopen(perdctnam,"wt");
perdex = 1;
reedheep(root);
while (perdex < persize)
{
fprintf(perdct,"%s\n",personaldct[perdex]);
perdex++;
}
fclose (perdct);
}
}
}
void cdecl main(argc,argv)
int argc;
char **argv;
{
char buf;
int tmplnth = 0;
int dex; /* pointer of line */
#ifdef CLONE
getmode();
#endif CLONE
setcbrk(0); /* turns control c checking off */
setfyl (argc,argv);
#ifdef TIMER
gettime(&st_time);
#endif TIMER
#ifdef RAINBOW
GOTOXY(0,12);
cputs("\033[06;19r \033[?4l");
/* set scroll region and jump scroll for speed */
#endif RAINBOW
GOTOXY(30,21);
cputs("MISSPELLED WORDS");
GOTOXY(27,5);
cputs("Hit any key to stop SPELLA");
GOTOXY(0,19);
while (!feof(source))
{
fgets(srcline,MAXLINE,source);
if (feof(source)) break;
if (video)
{
#ifdef CLONE
scrolup(1);
cputs(srcline);
#endif CLONE
#ifdef RAINBOW
cprintf("%s\r",srcline);
#endif RAINBOW
}
lnlength = strlen(srcline);
dex = 0;
while (dex <= lnlength)
{
while ((isalpha(srcline[dex])) || ((letcnt) && (srcline[dex] == 39)))
{
hyphen1 = 0;
wordtex[letcnt] = srcline[dex];
if (hyphen2)
hyphtex[hyphcnt++] = srcline[dex];
letcnt++;
dex++;
}
if ((letcnt) && (srcline[dex]==HYPHEN) && (dex == (lnlength-2)))
{
#ifdef DEBUG
scrolup(1);
cputs("\n\rHyphen detected at end of line\n\r");
getch();
#endif DEBUG
hyphen = 255;
hyphen1 =255;
hyphen2 =255;
hyphcnt =0;
}
if (( letcnt >=3) && (letcnt <= 20) && (!hyphen1))
{
totwrd++;
wordtex[letcnt] = 0;
strcpy(srchtex,wordtex);
strupr(srchtex);
wrrd=wordsearch(srchtex,letcnt);
if((!wrrd) && (letcnt >= 4))
wrrd = stripsufix(letcnt);
if ((!wrrd) && (persize))
{
strcpy(srchtex,wordtex);
strupr(srchtex);
#ifdef DEBUG
scrolup(1);
cprintf("srchtex %s %s",srchtex,wordtex);
#endif DEBUG
wrrd =serperdct (srchtex);
}
if (!wrrd)
{
tmplnth=strlen(outln);
outln[tmplnth++]=marker;
outln[tmplnth]=0;
if (hyphen2)
{
hyphtex[hyphcnt]=0;
strcat(outln,hyphtex);
}
else
strcat(outln,wordtex);
mspwrd++;
wrtheep(root);
tmplnth=strlen(outln);
outln[tmplnth++]=srcline[dex];
outln[tmplnth]=0;
wordtex[0]=0;
letcnt = 0;
hyphen2 =0;
}
else
{
if (hyphen2)
{
hyphtex[hyphcnt]=0;
strcat(outln,hyphtex);
}
else
strcat(outln,wordtex);
tmplnth=strlen(outln);
outln[tmplnth++]=srcline[dex];
outln[tmplnth]=0;
letcnt = 0;
wordtex[0]=0;
hyphen2 =0;
}
}
else
if (((letcnt) && (!hyphen) && (!hyphen1))
||
((letcnt) && (hyphen) && (hyphen1)))
{
wordtex[letcnt] = 0;
hyphen = 0;
strcat(outln,wordtex);
tmplnth=strlen(outln);
outln[tmplnth++]=srcline[dex];
outln[tmplnth]=0;
}
else
{
tmplnth=strlen(outln);
outln[tmplnth++]=srcline[dex];
outln[tmplnth]=0;
}
if (!hyphen1)
{
wordtex[letcnt] = 0;
letcnt = 0;
}
dex++;
}
fputs(outln,output);
outln[0]=0;
if (kbhit())
{
CLRSCRN();
puts("Program interupted exiting to operating system ");
#ifdef RAINBOW
cputs("\033[00;24r");
#endif RAINBOW
exit(0);
}
}
addtodic();
CLRSCRN ();
#ifdef RAINBOW
cputs("\033[00;24r");
#endif RAINBOW
exit(0);
}