%%s 4/5/355 %%d D 1.2 16-Jun-83 09:20:01 sventek 2 1 %%c Replaced runtime calls to `impath' with static declaration of search %%c path using STD_PATH. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:15:07 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 #-h- cspell 483 asc 25-mar-82 08:53:28 v1.1 (sw-tools v1.1) common / cspell / nlines, dunit, freep, freec, strptr(MAX_DIR_ENTRIES), linptr(MAX_DIR_ENTRIES), charay(MAX_CHARS) integer nlines # number of entries read from index integer dunit # rat4 unit for dictionary file integer freep # next free loc in strptr integer freec # next free loc in charay integer strptr # index into charay for the key for the n'th entry linepointer linptr # values to load into seek to locate record character charay # key strings stored here %%D 2 #-h- spell.r 6376 asc 25-mar-82 08:53:32 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- spell.r 6318 asc 16-jun-83 09:19:02 sventek (joseph sventek) %%E 2 #-h- defns 156 asc 25-mar-82 08:52:53 v1.1 (sw-tools v1.1) ifdef(LARGE_ADDRESS_SPACE) define(MAX_DIR_ENTRIES,7200) define(MAX_CHARS,72000) elsedef define(MAX_DIR_ENTRIES,1800) define(MAX_CHARS,18000) enddef #-h- main 553 asc 25-mar-82 08:52:54 v1.1 (sw-tools v1.1) DRIVER(spell) integer i, status, unit integer getarg, equal, open character file(FILENAMESIZE) string minust "-" call query("usage: spell [-ddictname] [file] ...") call lodidx i = 1 repeat { status = getarg(i, file, FILENAMESIZE) if (status == EOF) if (i > 1) break else unit = STDIN else if (equal(file, minust) == YES) unit = STDIN else { unit = open(file, READ) if (unit == ERR) call cant(file) } call dospel(unit) if (unit != STDIN) call close(unit) i = i + 1 } DRETURN end #-h- alphan 149 asc 25-mar-82 08:52:55 v1.1 (sw-tools v1.1) integer function alphan(c) character c, t character type t = type(c) if (t == LETTER | t == DIGIT) return(YES) else return(NO) end #-h- binsrc 510 asc 25-mar-82 08:52:56 v1.1 (sw-tools v1.1) integer function binsrc(word) character word(ARB) integer first, last, i, m, c integer strcmp include cspell m = strptr(nlines) if (strcmp(word, charay(m)) > 0) return(nlines) m = strptr(1) if (strcmp(word, charay(m)) < 0) return(1) first = 1 last = nlines while ((last - first) > 1) { i = (first + last) / 2 m = strptr(i) c = strcmp(word, charay(m)) if (c == 1) first = i else if (c == 0) { last = i first = i } else last = i } return(first) end #-h- dospel 704 asc 25-mar-82 08:52:57 v1.1 (sw-tools v1.1) subroutine dospel(unit) integer i, m, n, iferr, j, start, unit integer getlin, findwd, gtnwrd character buf(MAXLINE), word(MAXLINE), errbuf(MAXLINE) include cspell for (n=getlin(buf,unit); n != EOF; n=getlin(buf,unit)) { call putlin(buf, STDOUT) for (j=1; buf(j) != EOS; j=j+1) if (buf(j) == '@t') errbuf(j) = '@t' else if (buf(j) == '@n') errbuf(j) = '@n' else errbuf(j) = ' ' errbuf(j) = EOS i = 1 iferr = NO while (gtnwrd(buf, i, word, start) > 0) { call fold(word) if (findwd(word) == NO) { iferr = YES for (j=start; j < i; j=j+1) errbuf(j) = '*' } } if (iferr == YES) call putlin(errbuf, STDOUT) } return end #-h- findwd 670 asc 25-mar-82 08:52:57 v1.1 (sw-tools v1.1) integer function findwd(word) character word(ARB) integer i, junk, n integer getlin, binsrc, strcmp, equal, wdlook, okword character buf(MAXLINE) include cspell if (okword(word) == YES) # group of known correct words return(YES) if (wdlook(word) == YES) # seen this mis-spelled word before return(NO) i = binsrc(word) call seek(linptr(i), dunit) for (n=getlin(buf,dunit); n != EOF; n=getlin(buf,dunit)) { buf(n) = EOS if (strcmp(word, buf) <= 0) break } if (n == EOF) buf(1) = EOS if (equal(word, buf) == NO) { call wdstal(word) # install mis-spelled word findwd = NO } else findwd = YES return end #-h- gtroot 376 asc 25-mar-82 08:52:59 v1.1 (sw-tools v1.1) subroutine gtroot(root) character root(FILENAMESIZE) integer i, found integer getarg string dict "dict" found = NO for (i=1; getarg(i, root, FILENAMESIZE) != EOF; i=i+1) if (root(1) == '-' & (root(2) == 'd' | root(2) == 'D')) { call scopy(root, 3, root, 1) call delarg(i) found = YES break } if (found == NO) call strcpy(dict, root) return end #-h- gtnwrd 345 asc 25-mar-82 08:52:59 v1.1 (sw-tools v1.1) integer function gtnwrd(buf, i, word, start) integer i, start, j character buf(ARB), word(ARB) integer alphan, length while (alphan(buf(i)) == NO) if (buf(i) == EOS) break else i = i + 1 start = i for (j=1; alphan(buf(i)) == YES; j=j+1) { word(j) = buf(i) i = i + 1 } word(j) = EOS return(length(word)) end %%D 2 #-h- lodidx 1121 asc 25-mar-82 08:53:00 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- lodidx 1059 asc 16-jun-83 09:12:09 sventek (joseph sventek) %%E 2 # load dictionary index file subroutine lodidx %%D 2 character file(FILENAMESIZE), buf(MAXLINE), root(FILENAMESIZE), spath(arith(3,*,FILENAMESIZE)) %%E 2 %%I 2 character file(FILENAMESIZE), buf(MAXLINE), root(FILENAMESIZE) %%E 2 integer int, n, m, i, junk integer open, getlin, indexs, loccom include cspell string suffix "dx" string srcsuf NO_SUFFIX %%I 2 string spath STD_PATH %%E 2 call gtroot(root) # get file root call concat(root, suffix, buf) %%D 2 call impath(spath) # fetch standard search path %%E 2 if (loccom(buf, spath, srcsuf, file) != ASCII) call cant(buf) int = open(file, READ) if (int != ERR) { m = 1 for (n=1; getlin(buf, int) != EOF; n=n+1) { i = 1 while (buf(i) != ' ') i = i + 1 junk = m + i if (n > MAX_DIR_ENTRIES | junk > MAX_CHARS) call error("Dictionary index too large for internal storage!") strptr(n) = m buf(i) = EOS i = i + 1 call stcopy(buf, 1, charay, m) m = m + 1 call ctoptr(buf, i, linptr(n)) } nlines = n - 1 freep = n freec = m call close(int) } else call cant(file) i = indexs(file, suffix) # find suffix in file spec file(i) = EOS # lop it off dunit = open(file, READ) if (dunit == ERR) call cant(file) return end #-h- okword 277 asc 25-mar-82 08:53:01 v1.1 (sw-tools v1.1) integer function okword(word) character word(ARB) integer type, equal string a "a" string i "i" okword = NO if (type(word(1)) == DIGIT) okword = YES else if (equal(word, a) == YES) okword = YES else if (equal(word, i) == YES) okword = YES return end #-h- wdlook 235 asc 25-mar-82 08:53:02 v1.1 (sw-tools v1.1) integer function wdlook(word) character word(ARB) integer i, j integer equal include cspell for (i=nlines+1; i < freep; i=i+1) { j = strptr(i) if (equal(word, charay(j)) == YES) return(YES) } return(NO) end #-h- wdstal 404 asc 25-mar-82 08:53:03 v1.1 (sw-tools v1.1) subroutine wdstal(word) character word(ARB) integer i integer length include cspell if (freep <= MAX_DIR_ENTRIES) { i = freec + length(word) if (i <= MAX_CHARS) # word will fit { strptr(freep) = freec # fill in pointer freep = freep + 1 # bump pointer call stcopy(word, 1, charay, freec) # copy word, bumping freec freec = freec + 1 # point past EOS } } return end #-h- spell.fmt 900 asc 25-mar-82 08:53:37 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Spell (1) 11-Jan-79 find spelling errors .sy spell [-ddictname] [file] ... .ds Spell copies the named files (or standard input if none are specified) to standard output while looking up each word in a dictionary. If any spelling errors are found in a particular line, an additional line will be printed immediately following the line with asterisks (*) beneath the offending words. If the -d switch is used, `spell' will use the files `dictname' and `dictname'dx for the dictionary and index. .fl dict - a dictionary file .br dictdx - the index generated by isam for the dictionary .sa isam - generate an index for pseudo-indexed-sequential access .br ospell - the script pipeline suggested in K&P for spelling errors .di .au Joe Sventek .bu This is a skeleton spelling error detector. It is expected that various modifications to flesh it out will be performed for local use. %%E 1