/* * ChkTeX v1.5, header file for main program. * Copyright (C) 1995-96 Jens T. Berger Thielemann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Contact the author at: * Jens Berger * Spektrumvn. 4 * N-0666 Oslo * Norway * E-mail: * * */ #ifndef CHKTEX_H #define CHKTEX_H 1 #ifdef WIN32 # include # include "config.h" #else #if defined(HAVE_CONFIG_H) || defined(CONFIG_H_NAME) # ifndef CONFIG_H_NAME # define CONFIG_H_NAME "config.h" # endif # ifndef HAVE_CONFIG_H # define HAVE_CONFIG_H 1 # endif # include CONFIG_H_NAME #endif #endif #include #include #include #ifdef HAVE_STDARG_H # include #else #error Sorry, ChkTeX needs an _ANSI_ compiler w/stdarg.h installed to compile. #endif #ifndef HAVE_VPRINTF #error Sorry, ChkTeX needs an _ANSI_ compiler w/vprintf() to compile. #endif #include #include #include #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_LIMITS_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #include "chktypes.h" #ifndef __NOPROTO # ifndef __PROTO # define __PROTO(a) a # endif #else # ifndef __PROTO # define __PROTO(a) () # endif #endif #ifndef LONG_MAX # define LONG_MAX (0x7fffffff) #endif #ifndef CHAR_BIT # define CHAR_BIT (8) #endif #ifndef FINDERRS_H # include "FindErrs.h" #endif /* FINDERRS_H */ #ifndef CDECL #define CDECL #endif /* * Define aliases for preprocessor statements */ #if defined(__unix__) || defined(__unix) || defined(unix) #undef __unix__ #define __unix__ 1 #elif defined(AMIGA) || defined(__AMIGA) || defined(__amigados__) #undef AMIGA #define AMIGA 1 #elif defined(MSDOS) || defined(__MSDOS__) || defined(__msdos__) #undef __MSDOS__ #define __MSDOS__ 1 #endif /* * The next macro should contain a list of characters LaTeX (and you?) * considers as an end-of-sentence characters, which should be * detected when whether sentence spacing is correct. * */ #define LATEX_EOSPUNC CHAR('.') CHAR(':') CHAR('?') CHAR('!') /* -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- */ /* * The next macro should contain general punctuation characters * used on your system. */ #define LATEX_GENPUNC LATEX_EOSPUNC CHAR(',') CHAR(';') /* -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- */ /* * The next macro should contain a list of characters LaTeX (and you?) * considers as an small punctuation characters, which should not be * preceded by a \/. */ #define LATEX_SMALLPUNC CHAR('.') CHAR(',') /* -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- */ /* * NOTE: All macros below should return FALSE (0) if the input * character is 0. * * The next macro should return TRUE if LaTeX (and you?) considers * the character `c' as a space, which should be detected when * we're checking whether commands are terminated by spaces. * * Note: If you wish to change this macro, you'll have to update * the main loop in FindErrs.c as well. */ #define LATEX_SPACE(c) (c > 0 && c <= ' ') /* -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- -=><=- */ #define betw(a,b,c) ((a < b) && (b < c)) #define within(a,b,c) ((a <= b) && (b <= c)) #define elif else if #ifndef NOT # define NOT(a) (!(a)) #endif #define ifn(a) if(NOT(a)) #ifndef min # define min(a,b) ((a)<=(b)?(a):(b)) #endif #ifndef max # define max(a,b) ((a)>(b)?(a):(b)) #endif #ifndef abs # define abs(a) (a>=0?a:(-a)) #endif #define LOOP(name, body) {{body} _end__##name:;} #define LAST(name) goto _end__##name #define NUMBRACKETS 6 #define NEWBUF(name,len) \ static TEXT _ ## name [len + (WALLBYTES<<1)] = {0}; \ const STRPTR name = &_ ## name[WALLBYTES] #define INTFAULTMSG "INTERNAL FAULT OCCURED! PLEASE SUBMIT A BUG REPORT!\n" #define INTERNFAULT INTFAULTMSG #define BITDEF1(a) BIT_ ## a #define BITDEF2(a) FLG_ ## a = (1<'.")\ MSG(pmNoTermData, etErr, TRUE, 0,\ "Could not access the termcap data base.")\ MSG(pmNoTermDefd, etErr, TRUE, 0,\ "Terminal type `%s' is not defined.")\ MSG(pmNoRegExp, etWarn, TRUE, 0,\ "Regular expressions not compiled in. Please recompile.")\ MSG(pmNoCommon, etErr, TRUE, 0,\ "`%s' can't be a member of both `%s' and `%s'.") \ MSG(pmNoOpenDir, etWarn, TRUE, 0, \ "Could not open the directory `%s'.") \ MSG(pmNoDebugFlag, etWarn, TRUE, 0, \ "This version of doesn't support the -d flag. Please recompile.") #undef MSG #define MSG(num, type, inuse, ctxt, text) num, enum PrgErrNum { PRGMSGS pmMaxFault }; #undef MSG extern struct ErrMsg PrgMsgs [pmMaxFault + 1]; struct ErrInfo { STRPTR Data, LineBuf, File; ULONG Line, Column, ErrLen; enum { efNone = 0x00, efNoItal = 0x01, efItal = 0x02 } Flags; }; extern const STRPTR ReadBuffer, CmdBuffer, TmpBuffer; extern const TEXT BrOrder[NUMBRACKETS + 1]; extern ULONG Brackets [NUMBRACKETS]; extern FILE *OutputFile, *InputFile; #define OPTION_DEFAULTS \ DEF(BOOL, GlobalRC, TRUE) \ DEF(BOOL, WipeVerb, TRUE) \ DEF(BOOL, BackupOut, TRUE) \ DEF(BOOL, Quiet, FALSE) \ DEF(BOOL, LicenseOnly, FALSE) \ DEF(BOOL, UsingStdIn, FALSE) \ DEF(BOOL, InputFiles, TRUE) \ DEF(BOOL, HeadErrOut, TRUE) \ DEF(STRPTR, OutputName, "") \ DEF(STRPTR, PseudoInName, NULL) \ DEF(STRPTR, OutputFormat, VerbNormal) \ DEF(STRPTR, PipeOutputFormat, NULL) \ DEF(STRPTR, Delimit, ":") \ DEF(LONG, DebugLevel, 0) #define STATE_VARS \ DEF(enum ItState, ItState, itOff) /* Are we doing italics? */ \ DEF(BOOL, AtLetter, FALSE) /* Whether `@' is a letter or not. */ \ DEF(BOOL, InHeader, TRUE) /* Whether we're in the header */ \ DEF(BOOL, VerbMode, FALSE) /* Whether we're in complete ignore-mode */ \ DEF(LONG, MathMode, 0) /* Whether we're in math mode or not */ \ DEF(STRPTR, VerbStr, "") /* String we'll terminate verbmode upon */ \ DEF(ULONG, ErrPrint, 0) /* # errors printed */ \ DEF(ULONG, WarnPrint, 0) /* # warnings printed */ \ DEF(ULONG, UserSupp, 0) /* # user suppressed warnings */ #define DEF(type, name, value) extern type name; OPTION_DEFAULTS STATE_VARS #undef DEF extern struct Stack CharStack, InputStack, EnvStack; enum Quote { quLogic, quTrad }; extern enum Quote Quote; extern BOOL StdInTTY, StdOutTTY, UsingStdIn; int main __PROTO((int argc, char **argv)); void PrintPrgErr __PROTO((enum PrgErrNum , ...)); void ErrPrintf __PROTO((const char *fmt, ...)); extern TEXT LTX_EosPunc[], LTX_GenPunc[], LTX_SmallPunc[]; extern STRPTR PrgName; #endif /* CHKTEX_H */