0707070000020107071006660001460001440000010723750370056716400000500000000004Size170 0707070000020075221006660001460001440000011006150370056724200000600000000212Files./Size ./Files ./Install ./Name ./Remove ./MAKEflop ./MAKEcpio ./grope ./inspell ./vspell ./vspell.doc ./STICKDOCS ./inspell.c ./Makefile 0707070000020074351007770001460001440000010276550370057030200001000000001206Install# # Move all relevant files to their destination # BIN=/usr/bin if [ ! -s /usr/bin/spell ] then message "You cannot use VSPELL without having the Document Preparation Kit from the UNIX Development Set installed first.\n\nVSPELL will not be installed - please re-order and re-install when appropriate." exit 1 fi for i in vspell inspell do ln $i $BIN/$i done chown bin vspell inspell chgrp bin vspell inspell chmod 755 vspell chmod 711 inspell # make sure grope is in /usr/lbin (inspell needs it there) if [ ! -d /usr/lbin ] then mkdir /usr/lbin chmod 777 /usr/lbin fi ln grope /usr/lbin/grope chmod 755 /usr/lbin/grope ./STICKDOCS 0707070000020107451006660001460001440000011005110370054737600000500000000073NameVSPELL - Visual Spelling Correction 6/86 - from THE STORE! 0707070000020107311007770001460001440000011004700370054577300000700000000147RemoveBIN='/usr/bin' cd $BIN rm -f vspell inspell rm -f /usr/lbin/grope rm -rf $HOME/Filecabinet/DOCS/VSPELL 0707070000020106421007770001460001440000011005150364201367300001100000000060MAKEflopcat Files | cpio -ocBv > /dev/fp021 dismount -f 0707070000020027041007770001460001440000011005130365153051600001100000000043MAKEcpiocat Files | cpio -ocBv > VSPELL+IN 0707070000020075211007770001460001440000011005140365716332400000600000004173grope# grope: a shell procedure designed to suggest spelling # corrections for a misspelled word # # Brian Downs July 27, 1985 # awk 'BEGIN{ vow[1]="a";vow[2]="e";vow[3]="i";vow[4]="o";vow[5]="u" vowels="aeiouy" rep["i"]="a"; rep["a"]="i"; rep["o"]="a"; rep["c"]="s"; rep["s"]="c"; rep["y"]="ie"; rep["z"]="s"; rep["e"]="i"; rep["u"]="o" srep["a"]="e"; srep["s"]="z"; srep["e"]="a"; srep["o"]="u"; srep["i"]="e"; trep["a"]="o" junk="*************************************************************" w="'$1'" print w;print substr(w,2) len=length(w) # try inserting vowels for(i in vow) for(j=1;j/tmp/grp1$$ comm -13 /tmp/grp1$$ /tmp/grp$$ rm /tmp/grp$$ /tmp/grp1$$ 0707070000020106741007110001460001440000011004750370056655600001000000031756inspellRa %/ .text% .data ,@.bss  /.lib 7r 7r/< 7rN1X OQ./HJf/H#0NR`p&`x "|  qJgb. "| /1/.NfP(pfv`:# 7># 7BJg& S"n1HH"|0 1HHr€f "| ^رg" n0HHH"|0 1HHr€fJ f 9 7>"nq"nB1. p//9 6N1"P./< N1X 9 7>"n. p//9 6N1"P 9 7B"| ./< !N1X. p//9 6N1"P nAH./< $N1XpL`NVH<$n&n $.I(`6*L-K`RR nJg"Hg nJf L<N^NuRJfp`NVxH. p/p /p//9 7N1 @/N1"P. p//9 6N1"P. p/p /p//9 7N1 @/N1"P. 'N1. p//9 6N1"PS0m y0R0r?`.0p?/N1X. p//9 6N1"P. /N1. p/p /p//9 7N1 @/N1"P. :N1 y 7&Sm y 7&"hRp` . 7&N1$. p//9 6N1"P  g4N F. p/p /p//9 7N1 @/N1"P(  g ?g0 Ag Cg Ig Qg ag cg ig qg sf. bN1. p/p/p//9 7N1 @/N1"PB . wN1. p//9 6N1"P 9 7B"| .NL&f "S0m y0R0r`. CN1`. NN1`6. cN1 9 7B"| ./< {/9 7"N1P. p/p/p//9 7N1 @/N1"Pp#  9 7B"| ./< N1X 9 7B"|  qB`. N1 9 7B"| Jg. p/p/p//9 7N1 @/N1"P. p//9 6N1"P. p//9 6N1"P 9 7B"| .N1. p//9 6N1"P. N1. N1` y0R0r`.0p/N1X. p/p/p//9 7N1 @/N1"P. N1`H. N1`. N1J fp`p# pLN^NuN N N `S0m y0R0r`.0p/N1X` y 7&Sm y 7&"hRp` . 7&N1.N1$png&pyg S0l.0p/N1X`. p/p/p//9 7N1 @/N1"P. p//9 6N1"Ppyf 9 7B"| .Hn|N1X. p/p/p//9 7N1 @/N1"P. p//9 6N1"P` Hn|N1 X.N1B @$H 9 7B"| # 9 7BJf p# N(Hn| 9 7B"| /1N1P``. p/p/p//9 7N1 @/N1"P. p//9 6N1"P. N1 y 7&( HH.N . 7&pd/Hn|N1PHn|N1 XSC|B1J.|fS0m y0R0r`.0p/N1X. p/p/p//9 7N1 @/N1"P. p//9 6N1"P y 7&( HH.N ` Hn|/NPJg. p/p/p//9 7N1 @/N1"P. N1. p//9 6N1"PHn|/< 1N1P. p//9 6N1"P. 4N1. 7N1 y 7&( HH.N (` y0R0r`. p/p/p//9 7N1 @/N1"P. p//9 6N1"P. p/p/p//9 7N1 @/N1"P. p//9 6N1"P y 7&( HH.N j 9 76, 9 7>"| +B1 9 76. 9 7B"| .N1 й 7>"| +A.Hn|N1XHn| 9 76"| +A/N1PHn| 9 76"| +A/N1PB  9 7B"| Jg>. p/ 9 76R/p//9 7N1 @/N1"P. p//9 6N1"P 9 76"| +A./< N1Xp`` y 7&Sm y 7&"hRp` . 7&N1.N1$png&pyg S0l.0p/N1X` y 7&( HH.N8. p/p/p//9 7N1 @/N1"P. p//9 6N1"P. p/p/p//9 7N1 @/N1"P. p//9 6N1"Ppnfj` y0R0r`.0p/N1X. p/p/p//9 7N1 @/N1"PB . N1. N1. p//9 6N1"P y 7&( HH.N*<Hn|/< /9 7&N1 -@ y 7&( HH.NPHn|N1VX* g. 7&N1zJfN `ZJmoS0m`N "| 2.Hn|N1X`~NV  7Ff .c gJ 7Ff .C fpN^Nu. p/p/p//9 7N1 @/N1"P. N1HnN1XHnN1XN1Jfp.N1B.N1N.N1Bp.N1B.N1N.N1B.N1B.N1Bp./< )/< #N1lP. /N1p.N1x.N1B.N1B. HnN1X. ;HnN1XHnN1 X.Hn/.N1P.N1Bpd.Hn/.N1,P-@ f<. p/p/p//9 7N1 @/N1"P. N1.N1B.N1 .`JNVH  fB. p/p/p//9 7N1 @/N1"P. p//9 6`JJ 7 g\. p/p/p//9 7N1 @/N1"P. p//9 7 N1"Pp# LN^Nutpn. p//p//9 7N1 @/N1"P. p//9 6N1"PR`NVHJ 7 gR. p/p /p//9 7N1 @/N1"P. p//9 7 N1"PLN^Nut pn. p//p//9 7N1 @/N1"P. p//9 6N1"PR`NVHt` R.N1 "| Jf y 7&Sm y 7&"hR ILN^Nu. 7&N1`NV|H vHnN1XN1JfZp.N1B.N1N.N1Bp././< /< /< N1l. N1p.N1x.N1B. /.N1^X @-H. p/p/p//9 7N1 @/N1"P`J y0R0r `6.0p /N1X`".N1F.N1 SL N^Nu.pd/HnN1P @-Hg.gpnHnN1 XS$AB0(.N1B @&H "| 2#f p# NXHn "| 2/1N1PHn//< N1 RJj DD`fLS0m `NV.N1Jg\. 7J/<T/.N1P | 7J"| 7^""""2 7kB9 7ly 7d. 7^/<T/.N1PN^NuNV.N1Jg. 7J/<T/.N1PN^Nu @ =    7    & O tvspellr%s: Can't open %s r%s: Can't open %s w%s: Can't open %s LOCALDICT%s: LOCALDICT variable not set a%s: Can't open %s /dev/ttyr+%s: Can't open /dev/tty Line Number: File: %sLocal Dict: %.30s[a=Add to Dict c/C=Correct w/wo check i/I=Ignore/All s=Sgst Alt Q/q=Quit w/wo savedd to dict orrect %s check w/wowo/wgnore/all uggest alt uit w/wo savefscanf returned 0 Normal completion. No corrections were made. Normal completion. %s terminated via 'quit'. %s terminated via 'Quit'. %s terminated via interrupt. %s terminated due to insufficient memory. TERM%s: TERM variable not set Couldn't get termcap entry clso[se]cmcecdabort() called Segmentation violation Bus error %d%d%s%s%s%s(Press for help)Action: Ignore allIgnore this instanceAdd to local dictionary%s '%s' added to local dictionaryCorrect misspelling was previously entered as the correction. Do you want this used here? (y/n) Enter correction: spell(1) does not recognize %s. Do you still want to use this word? (y/n) Suggest alternatives Working...Sorry, no alternatives found.Enter no. of alternative you want to use (Just to use none): %[^ ]%*cQuit (No save)Quit (Save work)%sChecking ... spellspellexec failed The word that is highlighted above is considered by vspell as misspelled. You are now being asked to specify its disposition by entering a vspell command. Vspell commands are all single characters. Here is a brief description of some of them, a -- This command adds the highlighted word to your local dictionary c -- This command allows you to correct the highlighted word by entering its replacement i -- This command tells vspell that the highlighted word is correct and needs no correction q -- This commands aborts vspell See the documentation for more details. Press to continue... shsh/usr/lbin/gropeexec failedr%2d:%-16.16s0707070000020107361007550001460001440000011014640370056714400000700000006443vspell# # Vspell (visual spell) shell procedure. Sep. 1, 1985 # Brian Downs, AT&T Technologies, Inc. # if [ ${#} -eq 0 ] then echo "Usage: ${0} [-c] file_name (only 1 file name allowed)" exit fi set -- `getopt c $*` if [ $? != 0 ] then echo "Usage: ${0} [-c] file_name (only 1 file name allowed)" exit 1 fi FLAG=Y for i in $* do case $i in -c) FLAG=N shift;; --) shift;break;; esac done if [ ${#} -eq 0 ] then echo "Usage: ${0} [-c] file_name (only 1 file name allowed)" exit fi if test ! -f ${1} then echo "Can't read or locate the file ${1}" exit 1 fi #if # [ "$LOCALDICT" = "" ] #then # echo "vspell: LOCALDICT must be set" # exit #fi : ${LOCALDICT:=$HOME/.localdict} export LOCALDICT echo "Please wait while file ${1} is checked for spelling errors... \c" trap 'if [ -s /tmp/inspp$$ ] ; then rm /tmp/inspp$$;fi;exit' 0 1 2 3 15 9 10 if test -r "$LOCALDICT" -a -w "$LOCALDICT" then sort -o $LOCALDICT -u $LOCALDICT else cat /dev/null > $LOCALDICT if test ! -r $LOCALDICT then exit 0 fi fi spell ${1} | sort >/tmp/insp$$ if test -s /tmp/insp$$ then ISBSNM=VS.`basename ${1}` comm -23 /tmp/insp$$ $LOCALDICT >/tmp/inspp$$ rm /tmp/insp$$ if test ! -s /tmp/inspp$$ then echo "No spelling errors detected in ${1}" test -f /tmp/inspp$$ && rm /tmp/inspp$$ exit fi if u3b || vax then fgrep -n -f /tmp/inspp$$ ${1} | cut -d':' -f1 | inspell ${1} /tmp/inspp$$ ${ISBSNM} ${FLAG} rtn=${?} # get exit status of inspell else # The UNIX PC's fgrep does not support the '-f' option, so # we use sed here. (BWD) # This awk script didn't work because it is too SLOW. # awk 'BEGIN{wcnt=0;scndflag=0} # FILENAME=="/tmp/inspp'$$'" {word[wcnt++]=$0;next} # {if(scndflag==0){NR=1;scndflag=1} # for(i=0;i/tmp/insp$$ # sed -n -f /tmp/insp$$ $1 | inspell ${1} /tmp/inspp$$ ${ISBSNM} ${FLAG} `wc -l ${1}` rtn=${?} # get exit status of inspell fi sort -o $LOCALDICT -u $LOCALDICT case ${rtn} in 0) if [ -f ${ISBSNM} ] then rm ${ISBSNM} fi ;; 1) echo Corrected file is in ${ISBSNM} echo "Do you want ${ISBSNM} copied over ${1}? (y/n) \c" read ans if test "$ans" = "y" then mv ${ISBSNM} ${1} else rm ${ISBSNM} echo ${ISBSNM} has been deleted. fi ;; esac else echo No spelling errors detected in ${1} fi 0707070000020107341006660001460001440000010301200370054567700001300000103104vspell.doc vspell A UNIX(TM) System-Based, Full-Screen Spelling Checker and Correction Utility by Brian Downs AT&T Technologies, Inc. September 1, 1985 Table of Contents I. Introduction . . . . . . . . . . . . . . 1 II. Getting Started. . . . . . . . . . . . . 2 III. Using vspell - An Example. . . . . . . . 3 IV. Vspell Commands. . . . . . . . . . . . . 7 IV.1 'a' Command . . . . . . . . . . . . 7 IV.2 'c' Command . . . . . . . . . . . . 7 IV.3 'C' Command . . . . . . . . . . . . 7 IV.4 'i' Command . . . . . . . . . . . . 7 IV.5 'I' Command . . . . . . . . . . . . 7 IV.6 's' Command . . . . . . . . . . . . 8 IV.7 'q' Command . . . . . . . . . . . . 8 IV.8 'Q' Command . . . . . . . . . . . . 8 IV.9 '?' Command . . . . . . . . . . . . 8 V. Saving Your Changes . . . . . . . . . . 9 VI. Invocation Option. . . . . . . . . . . . 10 VII. Installing vspell. . . . . . . . . . . . 11 Appendix A Vspell Manual Page . . . . . . . . . . . 12 vspell A UNIX(TM) System-Based, Full-Screen Spelling Checker and Correction Utility I. Introduction Vspell is a program designed to provide UNIX(TM) System V users with a full-screen oriented, easy to use spelling checker and correction utility. Vspell checks the contents of a given file by using the standard UNIX system spell utility to identify those words that appear to be misspelled. Vspell uses the information provided by spell to present each misspelling in its context by displaying a seven line "window" on the terminal screen with the errant word highlighted in reverse video (or enclosed in square brackets ([]) on terminals incapable of reverse video). The user is then prompted as to whether this word should be, for example, corrected, added to a "local dictionary", or ignored. Details of each action vspell permits is described in upcoming sections. Vspell's "local dictionary" facility allows the user to specify special terms and names that spell should consider as correctly spelled. The "local dictionary" is simply a file to which words can be added at any time with either an editor or through the auspices of vspell as it is checking a document. The remainder of this manual guides you through a sample session to show you how easy it is to check for and correct spelling errors using vspell. The next section, Getting Started, begins by describing some preliminary information you must tell vspell in order to successfully run it. page 2 vspell II. Getting Started Since vspell utilizes many of the features of your terminal, it must know what type of terminal you are using. This information is very easy to convey to the program. Before invoking vspell, issue the following shell command level directives. (The '$' indicates the shell's prompt.) $ TERM= $ export TERM Where '' indicates the type of terminal being used. If you already use the vi screen editor the above lines probably look familiar and you probably know what to specify as your terminal type. On the other hand, if this is the first time you have had to identify your terminal, it's best to ask your system administrator or a knowledgeable user for the appropriate specification. A complete list of terminal types cannot be given here since it is dependent on the number of terminal descriptions being maintained by an administrative file (for a system using termcap) or set of files (for a system using terminfo). The following, therefore, is only a brief list of popular terminal types that are usually known to this terminal capabilities data base. 5420 5410 5620 vt100 concept100 adm3a 4424 h19 h19A hp2621 hp2645 dm1520 h1520 tab132w vt52 adm5 act5s mime3ax dm1521 delta terak vi200f regent100 regent40 vt132 adm3a+ pe550 t106f regent60 regent20 8001 ampex vt50h fox virtual microterm dtc dm3025 intext d800 dg microb c100rv ovt100 owl tvi912 adm42 soroc adm31 mime zen30 x183 exidy tvi9122p Vspell also needs to know the name of your own local dictionary. This file need not exist to initially use vspell, nevertheless, vspell requires that it knows the dictionary's name. To do this, set the shell variable LOCALDICT to the full pathname of the local dictionary and export it. For example, $ LOCALDICT=$HOME/lib/mydict $ export LOCALDICT Once the TERM and LOCALDICT variables have been set as shown above, you can then call upon the utility by simply issuing the command vspell with the name of a file to be checked, i.e., $ vspell file.doc Vspell accepts only one option, '-c', which is described later, and in the manual pages found in the appendix. page 3 vspell III. Using Vspell - An Example Vspell is very easy to use. To see this, let's assume we have a file called raven that contains the following lines. Once upon a midnight dreary, while I pondered weak and weary, Over many a quaint and curious volume of forgatten lore- While I nodded, nearly napping, suddenly there came a tapping, As of some one gently rapping, rapping at my chmaber door. "'Tis some visitor", I muttered, "tapping at my chmaber door- Only this and nothing more." Notice that lines 4, 8, and 10 contain spelling errors ('forgatten' and 'chmaber'-twice). In order to check this file and correct the errors, you would issue the command. $ vspell raven The first thing you will see on your terminal is that vspell is "Working..."; finding all potentially misspelled words in the raven file. Once this is complete, vspell draws its main display as shown in Figure 1. ------------------------------------------------------------ | Once upon a midnight dreary, | | while I pondered weak and weary, | | Over many a quaint and curious | | volume of [forgatten] lore- | | While I nodded, nearly napping, | | suddenly there came a tapping, | | As of some one gently rapping, | | Line Number: 4 File: raven | | ---------------------------------------------------------| | a=add to dic c/C=Cor i/I=Ign All s=sgst alt Q/q=quit | | Local Dict: /a1/bwd/lib/mydict | | | | Action: (Press ? for help) | | | ------------------------------------------------------------ Figure 1. Main Vspell Terminal Display If no errors had been found, vspell would have reported: No spelling errors detected in raven Figure 1 shows the misspelled word enclosed in square brackets on the middle (fourth) line of the seven line "window" into the raven file. Most terminals will show this word in reverse video, however, if your page 4 vspell terminal is incapable of reverse video, the misspelled word will be enclosed in square brackets as displayed in the above figure. In the lower righthand portion of the seven line window, notice that vspell shows the name of the file being checked and the number of the line that contains the misspelled word. Immediately below the window is a line indicating the eight most frequently used vspell commands. Figure 1 shows this line in a slightly different format as you'd actually see it (in order to make it fit the figure). Furthermore, it will appear differently depending on whether your terminal is capable of reverse video or not. The intent of the line is provide a reminder of the following vspell commands that will all be described shortly. Command Action ------- ------ a = Add word to local dictionary c or C = Correct the misspelled word i or I = Ignore this misspelled word s = Suggest alternative spellings for the misspelled word q or Q = Quit vspell The difference between the upper and lower case versions of the commands is described in Section IV. The command mnemonic line in Figure 1 is followed by a line indicating the name of your "local dictionary". Finally there is vspell's prompt, "Action:". Here, vspell is asking you what you want done with the misspelled word. Commands to vspell are specified by entering a single letter. For example, to correct the word "forgatten" you would enter the letter 'c'. This elicits the prompt: Enter correction: You can now enter the correct word (or words) that should replace "forgatten". Let's say we enter "forgotten" (terminated by a ). Next, you'll see the message "Checking...". This indicates that vspell is checking the word "forgotten" for correctness. In this case, since "forgotten" is correctly spelled, it will replace "forgatten" and vspell will move on to the next misspelling as shown in Figure 2. page 5 vspell ------------------------------------------------------------ | While I nodded, nearly napping, | | suddenly there came a tapping, | | As of some one gently rapping, | | rapping at my [chmaber] door. | | "'Tis some visitor", I muttered, | | "tapping at my chmaber door- | | Only this and nothing more." | | Line Number: 8 File: raven | | ---------------------------------------------------------| | a=add to dic c/C=Cor i/I=Ign All s=sgst alt Q/q=quit | | Local Dict: /a1/bwd/lib/mydict | | | | Action: (Press ? for help) | | | ------------------------------------------------------------ Figure 2. Again, let's correct this word by entering the 'c' command. And for the correction suppose we enter "chimber". After the "Checking..." response you'll see spell(1) does not recognize chimber. Do you still want to use this word? (y/n) Here, our "correction" is itself not correctly spelled (according to the standard spell utility) and so vspell asks if we really want to use this correction. If we respond with 'y', "chamber" will be replaced with "chimber" and vspell will proceed to the next misspelling. On the other hand, responding with 'n' to the above question prompts vspell to ask for a new correction. Let's have vspell suggest a correction for this misspelling. First, we'll have to return to the "Action:" prompt - this can be done by entering an empty correction by just pressing a in response to the "Enter correction:" prompt. Then enter an 's' (in response to the "Action:" prompt) for 'Suggest Alternatives'. You'll see vspell "Working..." as it looks for words spelled similarly to "chmaber" that spell accepts as correctly spelled. In this case, vspell will find only a single suggestion, and you'll see: Enter no. of alternative you want to use (Just to use none): 1:chamber If vspell had found more alternatives, each would have been numbered. To choose one, simply enter its number in response to the prompt and press (in our case '1'). The word "chamber" would then replace "chmaber" and vspell would proceed to the next misspelling. This is shown in Figure 3. page 6 vspell ------------------------------------------------------------ | As of some one gently rapping, | | rapping at my chamber door. | | "'Tis some visitor", I muttered, | | "tapping at my [chmaber] door- | | Only this and nothing more." | | | | | | Line Number: 10 File: raven | | -------------------------------------------------------- | | a=add to dic c/C=Cor i/I=Ign All s=sgst alt Q/q=quit | | Local Dict: /a1/bwd/lib/mydict | | | | Action: (Press ? for help) | | | ------------------------------------------------------------ Figure 3. To correct this error, you again enter 'c'. Vspell's response will be chamber was previously entered as the correction. Do you want this used here? (y/n) Vspell remembers all corrections entered by you or suggested by vspell itself. So, here, vspell is asking you if a previously entered correction is appropriate for this error. If you enter 'y', "chamber" will again replace "chmaber". If 'n' is entered, "chamber" will not be used and you will asked to "Enter correction:". In this case, let's enter 'y'. This is the last misspelling in the file raven, so, the vspell window is cleared and you'll see Normal completion. Corrected file is in VS.raven Do you want VS.raven copied over raven? (y/n) What this indicates, is that as vspell has been accepting changes to the file raven, it has been writing the corrected file to a temporary file called VS*raven. You are now being asked if you want to make your changes permanent by replacing the original file raven with the corrected file VS*raven. This occurs if you respond with 'y' and does not occur if you respond with 'n'. In either case, the file VS*raven will be deleted before vspell terminates. page 7 vspell IV. Vspell Commands As the file raven was checked in the previous section, two vspell commands were introduced: 'c' to correct a misspelling, and 's' to ask vspell to suggest a spelling correction. The purpose of this section is to describe all nine commands vspell accepts in response to the "Action:" prompt. IV.1. 'a' - Add Word to Dictionary If the word highlighted by vspell is a correctly spelled special term or name unknown to spell, entering 'a' instructs vspell to add this word to your local dictionary (as defined by the setting of your LOCALDICT shell variable). All subsequent occurrences of this word in the file being checked will be considered as correctly spelled and will not be shown to you. IV.2. 'c' - Correct Word and Check This command allows you to correct the highlighted word, i.e., replace it with a new word or words. The newly entered word is immediately checked for correctness. (See the 'C' command, next, and the '-c' option in Section VI.) If it is accepted by spell as correct it will replace the highlighted word. Otherwise, vspell indicates that the new word is not recognized by spell, and asks if you still wish to use it. Any word entered as a correction as a result of the 'c' command is remembered by vspell in order to allow you to quickly correct subsequent occurrences of the same misspelling. IV.3. 'C' - Correct Word With No Check Having vspell check the correctness of each newly entered word slows vspell down. Because of this, you might want to use the 'C' command to correct a misspelling when you are certain of the spelling of the correction. That is, the 'C' command is identical to the 'c' command with the exception that the newly entered word is not checked for correctness before it replaces the misspelled word. (See the '-c' option in Section VI.) Any word entered as a correction as a result of the 'C' command is remembered by vspell in order to allow you to quickly correct subsequent occurrences of the same misspelling. IV.4. 'i' - Ignore This Occurrence This command instructs vspell that the currently highlighted word is in fact correctly spelled and should be left as is. Subsequent occurrences of this word will be shown to you. (See 'I' command.) This word is not added to your local dictionary. For convenience pressing the space bar is equivalent to the 'i' command. IV.5. 'I' - Ignore All Occurrences This command, like the previous 'i' command, tells vspell that the currently highlighted word is spelled correctly. It differs, however, from the 'i' command in that 'I' causes all subsequent occurrences of this word to be considered as correctly spelled. This word is not added to your local dictionary. page 8 vspell IV.6. 's' - Suggest Alternatives This command requests vspell suggest the correct spelling for the word currently indicated as misspelled. This is done by generating a list of words that are similarly spelled but accepted by spell as correct. If vspell is successful in finding suggested corrections, you are shown a numbered list of words from which you can choose one to replace the highlighted word. On the other hand, if vspell is unsuccessful in locating possible corrections you will be asked to specify a different "Action:". IV.7. 'q' - Quit (Abort) This command terminates your vspell session without any of your changes being saved. However, words added to your local dictionary remain added. IV.8. 'Q' - Quit (Saving Work to This Point) This command allows you to terminate your vspell session without having completely checked the entire input file. All changes up to this point are saved as are any words that have been added to your local dictionary. IV.9. '?' - Help This command causes vspell to display a half page of help describing vspell and its most frequently used commands. page 9 vspell V. Saving Your Changes After processing all of the misspellings identified by vspell, or upon using the 'Q' command, vspell will indicate a "Normal Completion". If no corrections have been made or suggestions used, vspell will issue the message "No corrections made" and the input file will be untouched. On the other hand, if changes have been made via either the 'c' or 's' commands, vspell will say Corrected file is in VS. Do you want VS. copied over (y/n)? What this means is that as you have been making corrections to the input file, vspell has been writing the updated file to a temporary file whose name is created by prepending 'VS.' to the input file name. Responding to the above question with a 'y' causes the updated file to replace the original file. Responding with 'n' causes the corrected file to be deleted, leaving the input file untouched. In either case, words added to your local dictionary remain added. page 10 vspell VI. Invocation Option Vspell accepts a single invocation option, '-c'. For example: $ vspell -c raven This option tells vspell to reverse the roles of the 'c' and 'C' commands. That is, when the -c option is in effect, corrections entered via the 'c' command are not checked for their correctness. Whereas, words entered via 'C' are checked. page 11 vspell VII. Installing vspell This section is more technical than previous ones and is primarily intended for those individuals who are responsible for installing new utilities on their UNIX system(s). To date, vspell has been successfully tested on the following CPUs (all running System V Release 2.) AT&T 3B20S AT&T 3B5 AT&T 3B2 AT&T UNIX PC DEC VAX 11/780 Vspell is comprised of two shell procedures and one C program. vspell - primary shell procedure. grope - shell procedure called by vspell (inspell.c actually) for the 'Suggest Alternative' command. inspell.c - primary 'C' program that implements vspell's visual presentation. You need to modify (probably) one line in inspell.c before compiling it. Near the top of the file you'll see a line that says: #define GROPE "/usr/lbin/grope" This line informs inspell where the shell procedure grope can be found. This line needs to be changed to indicate the full pathname of where grope is located on your system. The C program, inspell.c, should be compiled via the command $ cc -O -s inspell.c -o inspell -lcurses -lmalloc If your system does not include the newer 'malloc(3X)' routines, delete or comment out the "#include " line that appears near the top of inspell.c and compile it via $ cc -O -s inspell.c -o inspell -lcurses If your system does not include the newer 'curses(3X)' library, the source file requires no changes but should be compiled via $ cc -O -s inspell.c -o inspell -ltermlib Lastly, to install vspell, move the shell procedures, vspell and grope, and the output of the C compile, inspell, to your system's public bin directory. Of course, all three of these files should be marked as executable by all. VVVVSSSSPPPPEEEELLLLLLLL((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 VVVVSSSSPPPPEEEELLLLLLLL((((1111)))) NNNNAAAAMMMMEEEE vspell - screen-oriented spelling checker SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS vvvvssssppppeeeellllllll [[[[----cccc]]]] ffffiiiilllleeee DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN _V_s_p_e_l_l is a screen-oriented utility designed to allow you to easily detect and correct spelling errors found in a document file. When _v_s_p_e_l_l detects a misspelled word a seven line "window" into the _f_i_l_e is displayed on the screen with the problematic word shown in reverse video (or enclosed in square brackets on terminals that are not capable of reverse video). In order to identify the misspelled words, _v_s_p_e_l_l uses the standard UNIX system _s_p_e_l_l(_1) command in conjunction with a personal, "local" dictionary. This local dictionary can contain words that you know are spelled correctly but are unknown to _s_p_e_l_l (e.g., names or special terms you use.) Each word placed in the local dictionary file should appear on a separate line. To tell _v_s_p_e_l_l the name of your local dictionary set and export the shell variable, LOCALDICT, to its pathname, e.g., $ LOCALDICT=/a1/bwd/doc/mydictionary $ export LOCALDICT (If this file does not exist the first time _v_s_p_e_l_l is called, it will be created for you.) As mentioned previously, when _v_s_p_e_l_l finds a misspelled word, it is shown to you on your screen. You are then asked to specify an action. Five responses, each designated by a single letter, are recognized. a Add this word to your local dictionary. All subsequent occurrences of this word will not be shown to you. c Correct this word. You will be asked to supply the word (or words) you want to replace the misspelled word with. The newly entered word is checked immediately for correctness by _s_p_e_l_l - this feature can be turned off by originally calling _v_s_p_e_l_l with the -_c option, or see the next command, "C". _V_s_p_e_l_l will remember this correction in the event the same misspelling is encountered. If it is, and you specify the 'c' command you will be shown the remembered correction and asked if it should be used again. Page 1 (printed 3/20/86) VVVVSSSSPPPPEEEELLLLLLLL((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 VVVVSSSSPPPPEEEELLLLLLLL((((1111)))) C Correct this word. This command is identical to 'c' except that the newly entered word is %not checked for correctness before it replaces the misspelled word. Calling _v_s_p_e_l_l with the -_c option changes the action of the "C" command so that newly entered words are checked for correctness. i Ignore this occurrence of the "misspelling". _V_s_p_e_l_l will go on to the next misspelled word. You will be shown subsequent occurrences of this string. This word is _n_o_t added to your local dictionary. (For convenience, entering a also performs this action.) I Ignore this and all further occurrences of this string. This word is nnnnooootttt added to your local dictionary. s Suggest alternative spellings for the misspelled word. _V_s_p_e_l_l (in cooperation with _s_p_e_l_l) will look for correctly spelled words that are similar to the one marked as misspelled. If alternatives are successfully found, they will be displayed on the bottom half of the screen. You are then asked to select one of the alternatives to replace the misspelled word. This is done by entering the number found just to the left of the alternative. Just entering indicates that none of the suggestions should be used. If you do select one of the alternatives, it will be remembered by _v_s_p_e_l_l in the event the same misspelling is encountered. If it is, and you specify the 'c' (not 's') command you will be shown the remembered correction and asked if it should be used again. q Quit _v_s_p_e_l_l. This prematurely terminates _v_s_p_e_l_l. No corrections made are remembered but words added to your local dictionary remain. Q Quit _v_s_p_e_l_l but save the corrections made so far. Any response other than those listed above will elicit a 'beep' at your terminal. Upon normal termination (not via quit or interrupt) _v_s_p_e_l_l writes the corrected file to a file named _V_S._f_i_l_e. (If _f_i_l_e contains slashes, the output file name will be _V_S.`_b_a_s_e_n_a_m_e _f_i_l_e`. ) To use _v_s_p_e_l_l, your TERM variable should be set to the type of the terminal you are using (as for _v_i.) Also, the variable LOCALDICT should be set to a fully qualified pathname that is both readable and writable. EEEENNNNVVVVIIIIRRRROOOONNNNMMMMEEEENNNNTTTT VVVVAAAARRRRIIIIAAAABBBBLLLLEEEESSSS iiiifffftttt vvvvssss 0000pppp VVVVSSSSPPPPEEEELLLLLLLL((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 VVVVSSSSPPPPEEEELLLLLLLL((((1111)))) TERM Should be set to your terminal type. LOCALDICT Should be set to the fully qualified pathname of the file containing the words of your local dictionary. NNNNOOOOTTTTEEEESSSS Only one file can be specified at a time. The alternatives suggested by the 's' command may appear nonsensical. All _v_s_p_e_l_l does is find words that are similar to the misspelled word and accepted by _s_p_e_l_l as 'correctly' spelled. PPPPRRRROOOOVVVVIIIIDDDDEEEERRRR Brian Downs SSSSEEEEEEEE AAAALLLLSSSSOOOO spell(1) 0707070000020106151007770001460001440000010062130370056703600001200000001417STICKDOCS# CHANGE THE VALUES ON THE FIRST TWO LINES AS APPROPRIATE NAME="VSPELL" LISTDOCS="vspell.doc inspell.c Makefile" FOLDER=/u/$LOGNAME/Filecabinet/DOCS DEST=$FOLDER/$NAME if [ -d $FOLDER ] then if [ ! -d $DEST ] then mkdir $DEST chown $LOGNAME $DEST fi message -i "Document file(s) called $LISTDOCS will be placed in your DOCS/$NAME folder.\n\nThese files contain information about $NAME.\n\nTouch to continue." else message -i "A folder called DOCS/$NAME is being created in your Filecabinet. Document file(s) $LISTDOCS will be placed there.\n\nThese files contain information about $NAME.\n\nTouch to continue." mkdir $FOLDER mkdir $DEST chown $LOGNAME $FOLDER chown $LOGNAME $DEST fi for i in $LISTDOCS do ln $i ${DEST}/$i chown $LOGNAME ${DEST}/$i done 0707070000020027101006440001460001440000011014670370056662000001200000060612inspell.c#include #include #include #include #include /* not available on UNIX PC #include */ #define GOTO(col,row) tputs(tgoto(CM,col,row),1,putchr) #define CLEARLINE tputs(CE,1,putchr) #define REVON tputs(SO,1,putchr) #define REVOFF tputs(SE,1,putchr) #define LINE 9 #define PROMPT 13 #define INSTR 11 #define ADDED 19 #define ALT 16 #define QUIT 2 #define NO 1 #define YES 0 #define INTR 3 #define MALLOC 4 #define QUITSV 5 #define GROPE "/usr/lbin/grope" #define BELL putchar('\007') #define BADWRDS 750 #define MAXALTS 28 /* words[*][0] will point to misspelled words. words[*][1] will point to entered corrections for words[*][0] */ char *words[BADWRDS][2]; int wordlen[BADWRDS]; char line[7][256],*malloc(),*prgname="vspell",*altwords[MAXALTS]; char *ldict,*tgoto(),*tgetstr(),entry[1024],caps[100],*getenv(),*area; char *CL, /* clear screen */ *SO, /* start highlight */ *SE, /* end highlight */ *CE, /* clear to end of line */ *AS, *AE, *CD, /* clear to end of display */ *CM; /* cursor motion */ char *term,*bufpt; FILE *fpdoc,*fpwrd,*fpldict,*fptty,*fpout; int dirtyalt=NO; int putchr(),first,last,wmid,numowrds,curpos,curwrd,change=NO,chkflag; int turnon(),turnoff(); struct termio termold,termnew; #ifdef DEBUG char debug1[100],debug2[100]; #endif main(argc,argv) int argc; char **argv; { register int i,j,ret,which; int lineno=1,fixret=1; int num_o_lines,intr(); char c; /* file being spell-checked */ if((fpdoc=fopen(argv[1],"r"))==NULL){ printf("%s: Can't open %s\n",prgname,argv[1]); exit(9); } /* misspelled words */ if((fpwrd=fopen(argv[2],"r"))==NULL){ printf("%s: Can't open %s\n",prgname,argv[2]); exit(9); } /* output file for corrected document */ if((fpout=fopen(argv[3],"w"))==NULL){ printf("%s: Can't open %s\n",prgname,argv[3]); exit(9); } chkflag=(*argv[4] == 'Y')?YES:NO; num_o_lines=atoi(argv[5]); ldict=getenv("LOCALDICT"); if(ldict==NULL){ printf("%s: LOCALDICT variable not set\n",prgname); exit(8); } if((fpldict=fopen(ldict,"a"))==NULL){ printf("%s: Can't open %s\n",prgname,ldict); exit(9); } if((fptty=fopen("/dev/tty","r+"))==NULL){ printf("%s: Can't open /dev/tty\n",prgname); exit(9); } setbuf(fptty,0); getrmcap(); /* get terminal caps */ getbadw(); /* get misspelled words */ setinit(); /* get initial window */ signal(SIGINT,intr); signal(SIGSEGV,intr); signal(SIGBUS,intr); signal(SIGIOT,intr); /* catch abort()'s */ turnoff(fileno(fptty)); /* turn off cannonical processing and echoing */ tputs(CL,1,putchr); GOTO(0,LINE); c='-'; for(i=1;i<=79;i++)putchar(c); GOTO(38,LINE-1);if(strlen(argv[1])>14)argv[1][14]='\0'; printf("Line Number: File: %s",argv[1]); GOTO(38,LINE+1); printf("Local Dict: %.30s",ldict); GOTO(0,INSTR); if(strcmp(SO,"[")==0){ /* no reverse video */ printf("a=Add to Dict c/C=Correct w/wo check \ i/I=Ignore/All s=Sgst Alt Q/q=Quit w/wo save"); } else{ /* we have reverse video */ REVON;putchar('a');REVOFF; printf("dd to dict "); /*REVON;putchar('c');REVOFF;putchar('/');REVON;putchar('C');REVOFF;*/ REVON;putchar('c');putchar('/');putchar('C');REVOFF; printf("orrect %s check ",chkflag==YES?"w/wo":"wo/w"); /*REVON;putchar('i');REVOFF;putchar('/');REVON;putchar('I');REVOFF;*/ REVON;putchar('i');putchar('/');putchar('I');REVOFF; printf("gnore/all "); REVON;putchar('s');REVOFF; printf("uggest alt "); /*REVON;putchar('Q');REVOFF;putchar('/');REVON;putchar('q');REVOFF;*/ REVON;putchar('Q');putchar('/');putchar('q');REVOFF; printf("uit w/wo save"); } /* Get next line number from fgrep */ /* while((ret=fscanf(stdin,"%d",&lineno)) != -1 && fixret){ */ while(lineno++ <= num_o_lines && fixret){ if(ret==0){ printf("fscanf returned 0\n"); abort(); } getlset(lineno); /* get a line set (i.e., window) */ which=0; /* "first search" flag */ /* 2nd arg==1 => just find word */ if(highword(which,1)==0)continue; while(showlset(which) && fixret){ /* correct errors in window */ fixret=fixit(); /* returns 0 on 'quit' */ which=1; } } /* clean up and go home */ /* flush remaining document */ if(fixret || change==QUITSV){ for(j=0;j<=6;j++)if(*line[j])fputs(line[j],fpout); while(fgets(line[0],256,fpdoc)!=NULL)fputs(line[0],fpout); } wrapup(); } wrapup() { fclose(fpdoc);fclose(fpwrd);fclose(fpldict),fclose(fpout); turnon(fileno(fptty)); tputs(CL,1,putchr); GOTO(0,0); switch(change){ case NO: printf("Normal completion.\n"); printf("No corrections were made.\n"); exit(0); case YES: printf("Normal completion.\n"); exit(1); case QUIT: printf("%s terminated via 'quit'.\n",prgname); exit(0); case QUITSV: printf("%s terminated via 'Quit'.\n",prgname); exit(1); case INTR: printf("%s terminated via interrupt.\n",prgname); exit(0); case MALLOC: printf("%s terminated due to insufficient memory.\n",prgname); exit(1); } } getbadw() { register int i=0,j; char temp[256]; bufpt=malloc(15000); /* buffer for all misspelled words */ if(bufpt==NULL){change=MALLOC;wrapup();} while( (fgets(temp,256,fpwrd) != NULL) && (i find and highlight word */ ret=highword(which,0); if(ret)continue; } CLEARLINE; printf("%s",line[i]); } } else{ /* next word in same window */ GOTO(0,wmid+1); ret=highword(which,0); /* if(ret)printf("%s",line[wmid]); */ } return(ret); /* ret=1 means found the word ret=0 means found no word */ } highword(which,testflag) /* highlight word */ int which; /* which=0 for 1st search on line[wmid] */ int testflag; /* =1 just find word, =0 find and highlight */ { /* static int curword,curpos; */ register int i,strtpos,j,len; char temp[256],*p,c; p=line[wmid]; len=strlen(p); i=which?curwrd:0; strtpos=which?curpos+1:0; for( ; i<=numowrds;i++){ if(*words[i][0]=='\0')continue; j=index(p,words[i][0],strtpos); if(j == -1){strtpos=0;continue;} /* found string - is it a 'word'? */ curpos=j;curwrd=i; if(j!=0 && isalpha(p[j-1])) continue; /* j=strlen(words[i][0])+j; */ j += wordlen[i]; if(j!=len && isalpha(p[j]))continue; /* we've found an errant word */ if(testflag)return(1); /* if just finding, return */ c=p[curpos]; p[curpos]='\0'; /* strcpy(temp,p); strcat(temp,SO);strcat(temp,words[curwrd]);strcat(temp,SE); strcat(temp,&p[j]); strcpy(p,temp); */ /* instead of modifying line, just print line with word highlighted */ CLEARLINE; printf("%s",p); p[curpos]=c; tputs(SO,1,putchr); printf("%s",words[curwrd][0]); tputs(SE,1,putchr); printf("%s",&p[j]); return(1); } /* if we get here we can't find a bad word */ return(curpos=curwrd=0); } index(s1,s2,p) /* find 1st occurrence of s2 in s1 starting at p in s1 */ register char *s1,*s2; register p; { /* old version register i,j,k; for(i=p;s1[i] != '\0'; i++){ for(j=i,k=0;s2[k]!='\0' && s1[j]==s2[k];j++,k++) ; if(s2[k]=='\0') return(i); } return(-1); */ register char *p1,*s11,*s22; for(p1=s1+p;*p1;p1++){ for(s11=p1,s22=s2;*s22 && *s11 == *s22;s11++,s22++) ; if( !(*s22) )return(p1-s1); } return(-1); } #ifdef DEBUG diag(s1,s2) char *s1,*s2; { GOTO(0,20); CLEARLINE; printf("%s",s1); CLEARLINE; printf("%s",s2); getc(fptty); } #endif fixit() { register ans; register int num_alts; register int savans,i; int j; char newword[100],temp[256]; resp1: GOTO(0,PROMPT); CLEARLINE; GOTO(25,PROMPT);printf("(Press "); REVON;putchar('?');REVOFF;printf(" for help)"); GOTO(0,PROMPT);printf("Action: "); resp: ans=getc(fptty); CLEARLINE; if(dirtyalt!=NO){clearalt();GOTO(8,PROMPT);} switch(savans=ans){ case 'I': /* ignore all */ printf("Ignore all"); *words[curwrd][0]='\0'; break; case 'i': /* ignore just this occurrence */ case ' ': printf("Ignore this instance"); break; case 'A': /* add to dictionary */ case 'a': printf("Add to local dictionary"); fprintf(fpldict,"%s\n",words[curwrd][0]); GOTO(0,ADDED); dirtyalt=ADDED; printf("'%s' added to local dictionary" ,words[curwrd][0]); *words[curwrd][0]='\0'; break; case 'C': /* correct word */ case 'c': printf("Correct misspelling"); getnwrd: /* see if we already have a correction */ if(words[curwrd][1]!=NULL){ GOTO(0,PROMPT+1); CLEARLINE; tputs(SO,1,putchr); printf(words[curwrd][1]); tputs(SE,1,putchr); printf(" was previously entered as the correction."); printf("\nDo you want this used here? (y/n) "); while((ans=tolower(getc(fptty)))!='n' && ans!='y')BELL; GOTO(0,PROMPT+2); CLEARLINE; if(ans=='y'){ strcpy(newword,words[curwrd][1]); GOTO(0,PROMPT+1); CLEARLINE; goto usenew; } } GOTO(0,PROMPT+1); CLEARLINE; printf("Enter correction: "); turnon(fileno(fptty)); fgets(newword,100,fptty); newword[strlen(newword)-1]='\0'; if(*newword=='\0'){ BELL; GOTO(0,PROMPT+1); CLEARLINE; turnoff(fileno(fptty)); goto resp1; } if(checkit(savans,newword)){ GOTO(0,PROMPT+2); printf("spell(1) does not recognize "); tputs(SO,1,putchr); printf("%s",newword); tputs(SE,1,putchr); printf(".\n"); printf("Do you still want to use this word? (y/n) "); turnoff(fileno(fptty)); while((ans=tolower(getc(fptty)))!='n' && ans!='y')BELL; turnon(fileno(fptty)); GOTO(0,PROMPT+2); CLEARLINE; GOTO(0,PROMPT+3); CLEARLINE; if(ans=='n')goto getnwrd; } else{ /* erase the 'Checking...' message */ GOTO(0,PROMPT+2); CLEARLINE; } /* erase the 'ENTER new word' prompt */ GOTO(0,PROMPT+1); CLEARLINE; turnoff(fileno(fptty)); usenew: line[wmid][curpos]='\0'; strcpy(temp, &(line[wmid][curpos+strlen(words[curwrd][0])])); strcat(line[wmid],newword); strcat(line[wmid],temp); change=YES; /* remember this correction */ if(words[curwrd][1]==NULL){ words[curwrd][1]=malloc(strlen(newword)); if(words[curwrd][1]==NULL){ change=MALLOC;wrapup(); } strcpy(words[curwrd][1],newword); } break; case 's': /* find alternatives */ printf("Suggest alternatives"); GOTO(0,ALT-1);dirtyalt=YES; printf("\nWorking..."); CLEARLINE; if((num_alts=showalts(words[curwrd][0]))==0){ BELL; GOTO(0,ALT); printf("Sorry, no alternatives found."); goto resp1; /* ask what to do next */ } altresp: GOTO(0,ALT);dirtyalt=YES; printf("Enter no. of alternative you want "); printf("to use (Just to use none): "); CLEARLINE; turnon(fileno(fptty)); i = -999; j=fscanf(fptty,"%[^\n]%*c",temp); turnoff(fileno(fptty)); i=atoi(temp); if(j!=1){fgetc(fptty);i= 0;} if(i==0){clearalt();goto resp1;} if(i<0 || i>num_alts){BELL;goto altresp;} clearalt(); strcpy(newword,altwords[i]); goto usenew; case 'q': /* quit */ printf("Quit (No save)"); change=QUIT; return(0); case 'Q': /* quit */ printf("Quit (Save work)"); change=(change==YES)?QUITSV:QUIT; return(0); case '?': /* help */ clearhelp(); printhelp(); clearhelp(); goto resp1; default: BELL; goto resp1; } GOTO(0,wmid+1); CLEARLINE; printf("%s",line[wmid]); return(1); } #define TOSPELL fd[1] #define FROMSPELL ffd[0] #define TOVSPELL ffd[1] #define FROMVSPELL fd[0] checkit(cmd,word) char cmd,*word; { int i,ffd[2],fd[2]; char temp[100]; if(chkflag==NO && cmd=='c')return(0); if(chkflag==YES && cmd=='C')return(0); GOTO(0,PROMPT+2); printf("Checking ...\n"); pipe(fd); pipe(ffd); if(fork()==0){ close(0); /* close stdin */ dup(FROMVSPELL); close(FROMVSPELL); close(1); /* close stdout */ dup(TOVSPELL); close(TOVSPELL); /* child now attached to pipe */ close(FROMSPELL); close(TOSPELL); execlp("spell","spell",0); perror("exec failed"); exit(0); } close(TOVSPELL);close(FROMVSPELL); strcpy(temp,word); strcat(temp,"\n"); write(TOSPELL,temp,strlen(temp)); close(TOSPELL); i=read(FROMSPELL,temp,100); if(i == -1){GOTO(0,PROMPT+5);perror(prgname);} /* printf("i=%d\n",i); printf("temp=%s\n",temp); */ close(FROMSPELL); wait((int *)0); /* clear zombie */ return(i); } clearalt() { register int i; if(dirtyalt==ADDED){GOTO(0,ADDED);CLEARLINE;} else{ if(CD){GOTO(0,ALT);tputs(CD,1,putchr);} else{ for(i=ALT;i<=24;i++){ GOTO(0,i); CLEARLINE; } } } dirtyalt=NO; } clearhelp() { register int i; if(CD){GOTO(0,PROMPT);tputs(CD,1,putchr);} else{ for(i=PROMPT;i<=24;i++){ GOTO(0,i); CLEARLINE; } } } char *help[]={ " The word that is highlighted above is considered by vspell as misspelled.\n", "You are now being asked to specify its disposition by entering a vspell\n", "command. Vspell commands are all single characters. Here is a brief \n", "description of some of them,\n", " a -- This command adds the highlighted word to your local dictionary\n", " c -- This command allows you to correct the highlighted word\n", " by entering its replacement\n", " i -- This command tells vspell that the highlighted word is\n", " correct and needs no correction\n", " q -- This commands aborts vspell\n", "See the documentation for more details. Press to continue... ", 0}; printhelp() { register int i; i=0; while(help[i])printf(help[i++]); getc(fptty); } #define FROMGROPE ffd[0] #define TOVSPELL ffd[1] showalts(word) char *word; { /* showalts will 'grope' the word and present the alternatives found on lines 18 through 24, 4 per line (max of MAXALTS alterna- tives). The alternatives are also stored in the array altwords[] for possible future replacement if selected. */ register i,cnt=1; int ffd[2]; FILE *fp; char temp[100],*t; pipe(ffd); if(fork()==0){ close(1); /* close stdout */ dup(TOVSPELL); close(TOVSPELL); /* child's stdout now attached to pipe to vspell */ execlp("sh","sh",GROPE,word,0); perror("exec failed"); exit(0); } close(TOVSPELL); fp=fdopen(FROMGROPE,"r"); GOTO(0,ALT+2); while((t=fgets(temp,100,fp)) && t!=NULL && cnt<=MAXALTS){ temp[i=(strlen(temp)-1)]='\0'; /* disgard newline */ if((altwords[cnt]=malloc(i))==NULL){ change=MALLOC; wrapup(); } strcpy(altwords[cnt],temp); printf("%2d:%-16.16s",cnt,temp); if(cnt++ % 4 == 0)putchar('\n'); } fclose(fp); wait((int *)0); return(cnt-1); /* return no. of alternatives found */ } /* * turnoff, turnon -- Routines to turn off and turn on canonical * input processing and echoing to a terminal. * Old terminal settings are saved in a static * structure for reinstatement. */ turnoff(fd) int fd; { if (isatty(fd)) { ioctl (fd, TCGETA, &termold); termnew = termold; termnew.c_cc[VMIN] = 1; termnew.c_cc[VTIME] = 0; termnew.c_lflag &= ~(ICANON | ECHO); ioctl (fd, TCSETA, &termnew); } } turnon(fd) int fd; { if (isatty(fd)) ioctl (fd, TCSETA, &termold); } 0707070000020107521006440001460001440000010633330370056663000001100000000324Makefile# gotten from Steve M. # call is 'make prog' where 'prog' is name of executable # to be made include $(MAKEINC)/Makepre.h .c: $(CC) $(CFLAGS) -c $< $(LD) $(LDFLAGS) -s $(SHAREDLIB) $(@F).o -o $@ \ && rm $@.o 0707070000020107521006440001460001440000010633330370056663000001300000000000TRAILER!!! close(FROMVSPELL); close(1); /* close stdout */ dup(TOVSPELL); close(TOVSPELL); /* child now attached to pipe */ close(FROMSPELL); close(TOSPELL); execlp("spell","spell",0); perror("exec failed"); exit(0); } close(TOVSPELL);close(FROMVSPELL); strcpy(temp,word); strcat(temp,"\