/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2015 Gary Mills
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include "hash.h"
/*
* ANSI prototypes
*/
static int ily(char *, char *, char *, int);
static int s(char *, char *, char *, int);
static int es(char *, char *, char *, int);
static int subst(char *, char *, char *, int);
static int nop(void);
static int bility(char *, char *, char *, int);
static int i_to_y(char *, char *, char *, int);
static int CCe(char *, char *, char *, int);
static int y_to_e(char *, char *, char *, int);
static int strip(char *, char *, char *, int);
static int ize(char *, char *, char *, int);
static int tion(char *, char *, char *, int);
static int an(char *, char *, char *, int);
int prime(char *);
static int tryword(char *, char *, int);
static int trypref(char *, char *, int);
static int trysuff(char *, int);
static int vowel(int);
static int dict(char *, char *);
static int monosyl(char *, char *);
static int VCe(char *, char *, char *, int);
static char *skipv(char *);
struct suftab {
char *suf;
int (*p1)();
int n1;
char *d1;
char *a1;
int (*p2)();
int n2;
char *d2;
char *a2;
};
{"s'", s, 2, "", "+'s"},
{"s", s, 1, "", "+s"},
0
};
{"s'", s, 2, "", "+'s"},
{"s", s, 1, "", "+s"},
0
};
static char *preftab[] = {
"anti",
"auto",
"bio",
"counter",
"dis",
"electro",
"en",
"fore",
"geo",
"hyper",
"intra",
"inter",
"iso",
"kilo",
"magneto",
"meta",
"micro",
"mid",
"milli",
"mis",
"mono",
"multi",
"non",
"out",
"over",
"photo",
"poly",
"pre",
"pseudo",
"psycho",
"re",
"semi",
"stereo",
"sub",
"super",
"tele",
"thermo",
"ultra",
"under", /* must precede un */
"un",
0
};
static int bflag;
static int vflag;
static int xflag;
static char *prog;
/*
* deriv is stack of pointers to notes like +micro +ed
* affix is concatenated string of notes
* the buffer size 141 stems from the sizes of original and affix.
*/
/*
* in an attempt to defray future maintenance misunderstandings, here is
* program.
*
* spellprog is intended to be called from the shell file spell.
* because of this, there is little error checking (this is historical, not
* necessarily advisable).
*
* spellprog options hashed-list pass
*
* the hashed-list is a list of the form made by spellin.
* there are 2 types of hashed lists:
* 1. a stop list: this specifies words that by the rules embodied
* in spellprog would be recognized as correct, BUT are really
* errors.
* 2. a dictionary of correctly spelled words.
* the pass number determines how the words found in the specified
* hashed-list are treated. If the pass number is 1, the hashed-list is
* treated as the stop-list, otherwise, it is treated as the regular
* dictionary list. in this case, the value of "pass" is a filename. Found
* words are written to this file.
*
* is specified, the derivations are written to this file.
* The spellprog looks up words in the hashed-list; if a word is found, it
* is printed to the stdout. If the hashed-list was the stop-list, the
* words found are presumed to be misspellings. in this case,
* a control character is printed ( a "-" is appended to the word.
* a hyphen will never occur naturally in the input list because deroff
* is used in the shell file before calling spellprog.)
* If the regualar spelling list was used (hlista or hlistb), the words
* are correct, and may be ditched. (unless the -v option was used -
* see the manual page).
*
* spellprog should be called twice : first with the stop-list, to flag all
* a priori incorrectly spelled words; second with the dictionary.
*
* spellprog hstop 1 |\
*
* for a complete scenario, see the shell file: spell.
*
*/
int
{
char *dp;
int fold;
int c, j;
int pass;
/* Set locale environment variables local definitions */
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'b':
bflag++;
break;
case 'v':
vflag++;
break;
case 'x':
xflag++;
break;
}
}
exit(1);
}
argc--;
argv++;
/* Select the correct suffix table */
/*
* if pass is not 1, it is assumed to be a filename.
* found words are written to this file.
*/
if (pass != '1')
for (;;) {
affix[0] = 0;
if (j == EOF)
exit(0);
/*
* here is the hyphen processing. these words were found in the stop
* list. however, if they exist as is, (no derivations tried) in the
* dictionary, let them through as correct.
*
*/
*--ep = 0;
continue;
}
*dp = 0;
fold = 0;
goto lcase;
continue;
goto foundit;
++fold;
continue;
goto foundit;
goto lcase;
}
continue;
if (pass == '1')
original);
}
}
}
/*
* strip exactly one suffix and do
* indicated routine(s), which may recursively
* strip suffixes
*/
static int
{
struct suftab *t;
while (*sp)
goto next;
;
return (0);
return (1);
if (t->p2 != 0) {
}
return (0);
next:;
}
return (0);
}
static int
nop(void)
{
return (0);
}
/* ARGSUSED */
static int
{
}
static int
{
return (0);
return (0);
}
/* ARGSUSED */
static int
{
return (0);
}
/* ARGSUSED */
static int
{
}
/* ARGSUSED */
static int
{
*ep++ = 'e';
}
static int
{
else
}
static int
{
*ep++ = 'l';
}
static int
{
a = d;
}
}
static int
{
return (0);
switch (ep[-1]) {
default:
return (0);
case 'i':
case 's':
case 'h':
case 'z':
case 'x':
}
}
/* ARGSUSED */
static int
{
char *u, *t;
return (0);
for (t = d; *t != '+'; t++)
continue;
for (u = ep; *--t != '-'; )
*--u = *t;
}
static int
{
switch (ep[-2]) {
case 'c':
case 'r':
case 'a':
}
return (0);
}
/* possible consonant-consonant-e ending */
static int
{
switch (ep[-1]) {
case 'r':
break;
case 'l':
break;
switch (ep[-2]) {
case 'l':
case 'r':
case 'w':
break;
default:
}
break;
case 's':
break;
if (*ep == 'a')
return (0);
break;
return (1);
return (0);
break;
case 'c':
case 'g':
if (*ep == 'a')
return (0);
break;
return (1);
return (0);
break;
case 'v':
case 'z':
break;
return (1);
return (0);
break;
case 'u':
return (1);
return (0);
break;
}
}
/* possible consonant-vowel-consonant-e ending */
static int
{
char c;
c = ep[-1];
if (c == 'e')
return (0);
c = *ep;
*ep++ = 'e';
return (1);
ep--;
*ep = c;
}
}
static char *
{
char **sp;
goto next;
return (*sp);
}
next:;
}
return (0);
}
/*
* while word is not in dictionary try stripping
* prefixes. Fail if no more prefixes.
*/
static int
{
char *cp;
char *bp;
char *pp;
int val = 0;
return (1);
*pp++ = '+';
pp++;
val = 1;
break;
}
}
return (val);
}
static int
{
int i, j;
return (0);
return (0);
}
ep--;
duple[0] = '+';
duple[2] = 0;
}
if (vflag == 0 || i == 0)
return (i);
/*
* when derivations are wanted, collect them
* for printing
*/
j = lev;
do {
if (deriv[j])
} while (--j > 0);
return (i);
}
static int
{
return (0);
return (0);
return (0);
return (1);
}
static char *
skipv(char *s)
{
s--;
s--;
return (s);
}
static int
vowel(int c)
{
switch (Tolower(c)) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'y':
return (1);
}
return (0);
}
static int
{
if (xflag)
*ep = 0;
return (result);
}