The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
/* -*- c -*- */

#ifdef __WIN__
#include <windows.h>
#define sleep(x) Sleep((x)*1000)
#endif

#define VERSION "[% VERSION %]"

#include <sys/param.h>
#include <sys/types.h>

/*
****** instalation directories ******
*/
/** 
  #i fndef BINDIR
  #d efine BINDIR        " PREFIX %]/bin"
  #e ndif
  #i fndef INDDIR
  #d efine INDDIR        " PREFIX %]/include"
  #e ndif
*/
#ifndef LIBDIR
#define LIBDIR        "[% LIBDIR %]/jspell"
#endif
/*
  #i fndef MAN1DIR
  #d efine MAN1DIR        " PREFIX %]/man/man1"
  #e ndif
  #i fndef MAN4DIR
  #d efine MAN4DIR        " PREFIX %]/man/man4"
  #e ndif
*/
  
/*
** Extensions to put on manual pages.  Usually these are ".1" or ".1l".
*/
#ifndef MAN1EXT
#define MAN1EXT        ".1"
#endif
#ifndef MAN4EXT
#define MAN4EXT        ".4"
#endif

/*
** List of all hash files (languages) which will be supported by jspell.
**
** This variable has a complex format so that many options can be
** specified.  The format is as follows:
**
**        <language>[,<make-options>...] [<language> [,<make-options> ...] ...]
**
** where
**
**        language        is the name of a subdirectory of the
**                        "languages" directory
**        make-options        are options that are to be passed to "make" in
**                        the specified directory.  The make-options
**                        should not, in general, specify a target, as
**                        this will be provided by the make process.
**
** For example, if LANGUAGES is:
**
**        "{english,VARIANTS=american altamer} {deutsch}",
**
** then the English and Deutsch (German) languages will be supported,
** and when the English dictionary is built, the variable
** 'VARIANTS=american altamer' will be passed to the makefile.
**
** Notes on the syntax: The makefile is not very robust.  If you have
** make problems, or if make seems to in the language-subdirs
** dependency, check your syntax.  The makefile adds single quotes to
** the individual variables in the LANGUAGES specification, so don't
** use quotes of any kind.
**
** In the future, the first language listed in this variable will
** become the default, and the DEFHASH, DEFLANG, DEFDICT, and DEFPAFF,
** variables will all become obsolete.  So be sure to put your default
** language first, to make later conversion easier!
**
** Notes on options for the various languages will be found in the
** Makefiles for those languages.  Some of those languages may require
** you to also change various limits limits like MASKBITS or the
** length parameters.
*/
#ifndef LANGUAGES
#define LANGUAGES "{english,MASTERDICTS=english.med+,HASHFILES=med+.hash,VARIANTS=american,EXTRADICT=/usr/dict/words}"
#endif /* LANGUAGES */

/*
** Default native-language hash file.  This is the name given to the
** hash table that will be used if no language is specified to
** jspell.  It is a link to MASTERHASH, above.
*/
#ifndef DEFHASH
#define DEFHASH "port.hash"
#endif

/*
** Language tables for the default language.  This must be the name of
** the affix file that was used to generate the MASTERHASH/DEFHASH,
** above.
*/
#ifndef DEFLANG
#define DEFLANG        "port.aff"
#endif

/*
** Language to use for error messages.  If there are no messages in this
** language, English will be used instead.
*/
#ifndef MSGLANG
#define MSGLANG        "english"
#endif /* MSGLANG */

/*
** If your sort command accepts the -T switch to set temp file
** locations (try it out; it exists but is undocumented on some
** systems), make the following variable the null string.  Otherwise
** leave it as the sed script.
*/
#ifndef SORTTMP
#define SORTTMP        "-e '/!!SORTTMP!!/s/=.*$/=/'"
#endif

/*
** If your sort command accepts the -T switch (see above), make the
** following variable refer to a temporary directory with lots of
** space.  Otherwise make it the null string.
*/
#ifndef MAKE_SORTTMP
#define MAKE_SORTTMP "-T ${TMPDIR-/usr/tmp}"
#endif

/* Aliases for some routines */
#define bcopy(s, d, n)        (void) memcpy (d, s, n)
#define bzero(d, n)        (void) memset (d, 0, n)
#define index strchr
#define rindex strrchr

/* type given to signal() by signal.h */
#ifndef SIGNAL_TYPE
#define SIGNAL_TYPE void
#endif

/* environment variable for user's word list */
#ifndef PDICTVAR
#define PDICTVAR "WORDLIST"
#endif

/* prefix part of default word list */
#ifndef DEFPDICT
#define DEFPDICT ".jspell_"
#endif

/*
** suffix part of default word list - you may want to make this
** a language name, such as "english", "norsk", or "deutsch".
**
** This should really be part of the language selection above.
*/
#ifndef DEFPAFF
#define DEFPAFF "port"
#endif

/* old place to look for default word list */
#ifndef OLDPDICT
#define OLDPDICT ".jspell_"
#endif /* OLDPDICT */
#ifndef OLDPAFF
#define OLDPAFF "words"
#endif /* OLDPAFF */

/* environment variable for include file string */
#ifndef INCSTRVAR
#define INCSTRVAR "INCLUDE_STRING"
#endif

/* default include string */
#ifndef DEFINCSTR
#define DEFINCSTR "&Include_File&"
#endif

/* mktemp template for temporary file - MUST contain 6 consecutive X's */
#ifndef TEMPNAME
#define TEMPNAME "/tmp/jspellXXXXXX"
#endif

/* path to egrep (use speeded up version if available) */
#ifndef EGREPCMD
#define EGREPCMD "/bin/egrep"
#endif

/* path to wordlist for Lookup command (typically /usr/dict/{words|web2}) */
/* note that /usr/dict/web2 is usually a bad idea due to obscure words */
#ifndef WORDS
#define WORDS        "/usr/dict/words"
#endif

/* buffer size to use for file names if not in sys/param.h */
#ifndef MAXPATHLEN
#define MAXPATHLEN 240
#endif

/* max file name length (will truncate to fit BAKEXT) if not in sys/param.h */
#ifndef MAXNAMLEN
#define MAXNAMLEN 14
#endif

/* largest word accepted from a file by any input routine, plus one */
/* in ispell it was 100 */
#ifndef        INPUTWORDLEN
#define INPUTWORDLEN 50
#endif

/* largest amount that a word might be extended by adding affixes */
/* in ispell it was 20 */
#ifndef MAXAFFIXLEN
#define MAXAFFIXLEN 20
#endif

 /* Max no. of possibilities to generate */
 /* BE CAREFUL:
    if you change this #define here, you'll have to change it in jslib.h too */
#ifndef MAXPOSSIBLE
#define MAXPOSSIBLE  50
#endif

 /* Max. length of a string "solution"  or "near misse" */
 /* BE CAREFUL:
    if you change this #define here, you'll have to change it in jslib.h too */
#ifndef MAXSOLLEN
#define MAXSOLLEN  255
#endif

/* Max. length of a the classification string */
#ifndef MAXCLASS
#define MAXCLASS  65
#endif


/*
** Number of mask bits (affix flags) supported.  Must be 32, 64, 128, or
** 256.  If MASKBITS is 32 or 64, there are really only 26 or 58 flags
** available, respectively.  If it is 32, the flags are named with the
** 26 English uppercase letters;  lowercase will be converted to uppercase.
** If MASKBITS is 64, the 58 flags are named 'A' through 'z' in ASCII
** order, including the 6 special characters from 'Z' to 'a': "[\]^_`".
** If MASKBITS is 128 or 256, all the 7-bit or 8-bit characters,
** respectively, are theoretically available, though a few (newline, slash,
** null byte) are pretty hard to actually use successfully.
**
** Note that a number of non-English affix files depend on having a
** larger value for MASKBITS.  See the affix files for more
** information.
*/
#ifndef MASKBITS
#define MASKBITS        64
/* #define MASKBITS        256 */ 
#endif

/*
** C type to use for masks.  This should be a type that the processor
** accesses efficiently.
**
** MASKTYPE_WIDTH must correctly reflect the number of bits in a
** MASKTYPE.  Unfortunately, it is also required to be a constant at
** preprocessor time, which means you can't use the sizeof operator to
** define it.
**
** Note that MASKTYPE *must* match MASKTYPE_WIDTH or you may get
** division-by-zero errors! 
*/
#ifndef MASKTYPE
#define MASKTYPE        long
#endif
#ifndef MASKTYPE_WIDTH
#define MASKTYPE_WIDTH        32
#endif

/* maximum number of include files supported by xgets;  set to 0 to disable */
#ifndef MAXINCLUDEFILES
#define MAXINCLUDEFILES        5
#endif

/*
** Maximum hash table fullness percentage.  Larger numbers trade space
** for time.
**/
#ifndef MAXPCT
#define MAXPCT        70                /* Expand table when 70% full */
#endif

/*
** Maximum number of "string" characters that can be defined in a
** language (affix) file.  Don't forget that an upper/lower string
** character counts as two!
*/
#ifndef MAXSTRINGCHARS
#define MAXSTRINGCHARS 155
#endif /* MAXSTRINGCHARS */

/*
** Maximum length of a "string" character.  The default is appropriate for
** nroff-style characters starting with a backslash.
*/
#ifndef MAXSTRINGCHARLEN
#define MAXSTRINGCHARLEN 10
#endif /* MAXSTRINGCHARLEN */

/*
** the NOPARITY mask is applied to user input characters from the terminal
** in order to mask out the parity bit.
*/
#ifdef NO8BIT
#define NOPARITY 0x7f
#else
#define NOPARITY 0xff
#endif


/*
** the terminal mode for jspell, set to CBREAK or RAW
**
*/
#ifndef TERM_MODE
#define TERM_MODE        CBREAK
#endif

/*
** Define this if you want your columns of words to be of equal length.
** This will spread short word lists across the screen instead of down it.
*/
#ifndef EQUAL_COLUMNS
#undef EQUAL_COLUMNS
#endif /* EQUAL_COLUMNS */

/*
** This is the extension that will be added to backup files
*/
#ifndef        BAKEXT
#define        BAKEXT        ".bak"
#endif

/*
** Define this if you want to suppress the capitalization-checking
** feature.  This will reduce the size of the hashed dictionary on
** most 16-bit and some 32-bit machines.  This option is not
** recommended.
*/
#ifndef NO_CAPITALIZATION_SUPPORT
#undef NO_CAPITALIZATION_SUPPORT
#endif /* NO_CAPITALIZATION_SUPPORT */

/*
** Define this if you want your personal dictionary sorted.  This may take
** a long time for very large dictionaries.  Dictionaries larger than
** SORTPERSONAL words will not be sorted.  Define SORTPERSONAL as zero
** to disable this feature.
*/
#ifndef SORTPERSONAL
#define SORTPERSONAL        1000
#endif

/*
** Maximum language-table search size.  Smaller numbers make jspell
** run faster, at the expense of more memory (the lowest reasonable value
** is 2).  If a given character appears in a significant position in
** more than MAXSEARCH suffixes, it will be given its own index table.
** If you change this, define INDEXDUMP in lookup.c to be sure your
** index table looks reasonable.
*/
#ifndef MAXSEARCH
#define MAXSEARCH 4
#endif

/*
** Define this if you want to be able to type any command at a "type space
** to continue" prompt.
*/
#ifndef COMMANDFORSPACE
#undef COMMANDFORSPACE
#endif /* COMMANDFORSPACE */

/*
** Memory-allocation increment.  Buildhash allocates memory in chunks
** of this size, and then subdivides it to get its storage.  This saves
** much malloc execution time.  A good number for this is the system
** page size less the malloc storage overhead.
**
** Define this to zero to revert to using malloc/realloc.  This is normally
** useful only on systems with limited memory.
*/
#ifndef MALLOC_INCREMENT
#define MALLOC_INCREMENT        (4096 - 8)
#endif

/*
** Maximum number of "hits" expected on a word.  This is basically the
** number of different ways different affixes can produce the same word.
** For example, with "english.aff", "brothers" can be produced 3 ways:
** "brothers," "brother+s", or "broth+ers".  If this is too low, no major
** harm will be done, but jspell may occasionally forget a capitalization.
*/
/* in port.aff by Ulisses, there were 16 hits for any word finished with "as"*/
#ifndef MAX_HITS
#define MAX_HITS        20
#endif

/* Define this to ignore spelling check of entire LaTeX bibliography listings */
#ifndef IGNOREBIB
#undef IGNOREBIB
#endif

/*
** Default nroff and TeX special characters.  Normally, you won't want to
** change this;  instead you would override it in the language-definition
** file.
*/
#ifndef TEXSPECIAL
#define TEXSPECIAL        "()[]{}<>\\$*.%"
#endif

#ifndef NRSPECIAL
#define NRSPECIAL        "().\\*"
#endif

/*
** Defaults for certain command-line flags.
*/
#ifndef DEFNOBACKUPFLAG
#define DEFNOBACKUPFLAG        0                    /* Don't suppress backup file */
#endif
#ifndef DEFTEXFLAG
#define DEFTEXFLAG        0                    /* Default to nroff mode */
#endif

/*
** The next three variables are used to provide a variable-size context
** display at the bottom of the screen.  Normally, the user will see
** a number of lines equal to CONTEXTPCT of his screen, rounded down
** (thus, with CONTEXTPCT == 10, a 24-line screen will produce two lines
** of context).  The context will never be greater than MAXCONTEXT or
** less than MINCONTEXT.  To disable this feature entirely, set MAXCONTEXT
** and MINCONTEXT to the same value.  To round context percentages up,
** define CONTEXTROUNDUP.
**
** Warning: don't set MAXCONTEXT ridiculously large.  There is a
** static buffer of size MAXCONTEXT*BUFSIZ; since BUFSIZ is frequently
** 1K or larger, this can create a remarkably large executable.
*/
#ifndef CONTEXTPCT
#define CONTEXTPCT        20        /* Use 20% of the screen for context */
#endif
#ifndef MINCONTEXT
#define MINCONTEXT        2        /* Always show at least 2 lines of context */
#endif
#ifndef MAXCONTEXT
#define MAXCONTEXT        10        /* Never show more than 10 lines of context */
#endif
#ifndef CONTEXTROUNDUP
#undef CONTEXTROUNDUP                /* Don't round context up */
#endif

/*
** Define this if you want the context lines to be displayed at the
** bottom of the screen, the way they used to be, rather than at the top.
*/
#ifndef BOTTOMCONTEXT
#undef BOTTOMCONTEXT
#endif /* BOTTOMCONTEXT */

/*
** Define this if you want the "mini-menu," which gives the most important
** options at the bottom of the screen, to be the default (in any case, it
** can be controlled with the "-M" switch).
*/
#ifndef MINIMENU
#undef MINIMENU
#endif

/*
** You might want to change this to zero if your users want to check
** single-letter words against the dictionary.  However, you should try
** some sample runs using the -W switch before you try it out;  you'd
** be surprised how many single letters appear in documents.  If you increase
** MINWORD beyond 1, don't say I didn't warn you that it was a bad idea.
*/
#ifndef MINWORD
#define MINWORD                1        /* Words this short and shorter are always ok */
#endif

/*
** ANSI C compilers are supposed to provide an include file,
** "stdlib.h", which gives function prototypes for all library
** routines.  Define NO_STDLIB_H if you have a compiler that claims to
** be ANSI, but doesn't provide this include file.
*/
#ifndef NO_STDLIB_H
#ifndef __STDC__
#define NO_STDLIB_H
#endif /* __STDC__ */
#endif /* NO_STDLIB_H */

/*
** Symbols below this point are generally intended to cater to
** idiosyncracies of specific machines and operating systems.
**
** Define PIECEMEAL_HASH_WRITES if your system can't handle huge write
** operations.  This is known to be a problem on some MS-DOS systems.
*/
#ifndef PIECEMEAL_HASH_WRITES
#undef PIECEMEAL_HASH_WRITES
#endif /* PIECEMEAL_HASH_WRITES */

/*
** Redefine GETKEYSTROKE() to getkey() on some MS-DOS systems where
** getchar() doesn't operate properly in raw mode.
*/
#ifndef GETKEYSTROKE
#define GETKEYSTROKE()        getchar ()
#endif /* GETKEYSTROKE */

#define MACRO_MARK '#'
#define DEFAULT_SIGNS ".;:!?,()\""
#define SEP1 ", "
#define SEP2 "; "
#define SEP3 "= "
#define SEP4 "\n"

/* AUTOMATICALLY-GENERATED SYMBOLS */
#define SIGNAL_TYPE_STRING "void"
#define MASKTYPE_STRING "long"