summaryrefslogtreecommitdiff
path: root/support/chktex/FindErrs.h
blob: df38559ba36259f3b1ae851aae7b8c7af713e0c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
 *  ChkTeX, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *  Contact the author at:
 *              Jens Berger
 *              Spektrumvn. 4
 *              N-0666 Oslo
 *              Norway
 *              E-mail: <jensthi@ifi.uio.no>
 *
 *
 */

#ifndef FINDERRS_H
#define FINDERRS_H
#include "ChkTeX.h"


#undef ERRMSGS
#undef MSG

#define ERRMSGS \
 MSG(emMinFault, etErr, iuOK, ctNone,\
     INTERNFAULT)\
 MSG(emSpaceTerm, etWarn, iuOK, ctOutMath,\
     "Command terminated with space.")\
 MSG(emNBSpace, etWarn, iuOK, ctNone,\
     "Non-breaking space (`~') should have been used.")\
 MSG(emEnclosePar, etWarn, iuOK, ctInMath,\
     "You should enclose the previous parenthesis with `{}\'.")\
 MSG(emItInNoIt, etWarn, iuOK, ctNone,\
     "Italic correction (`\\/') found in non-italic buffer.")\
 MSG(emItDup, etWarn, iuOK, ctNone,\
     "Italic correction (`\\/') found more than once.")\
 MSG(emNoItFound, etWarn, iuOK, ctNone,\
     "No italic correction (`\\/') found.")\
 MSG(emAccent, etWarn, iuOK, ctNone,\
     "Accent command `%s' needs use of `\\%c%s'.")\
 MSG(emWrongDash, etWarn, iuOK, ctOutMath,\
     "Wrong length of dash may have been used.")\
 MSG(emExpectC, etWarn, iuOK, ctNone,\
     "`%s' expected, found `%s'.")\
 MSG(emSoloC, etWarn, iuOK, ctNone,\
     "Solo `%s' found.")\
 MSG(emEllipsis, etWarn, iuOK, ctNone,\
     "You should use %s to achieve an ellipsis.")\
 MSG(emInterWord, etWarn, iuOK, ctOutMath,\
     "Interword spacing (`\\ ') should perhaps be used.")\
 MSG(emInterSent, etWarn, iuOK, ctOutMath,\
     "Intersentence spacing (`\\@') should perhaps be used.")\
 MSG(emNoArgFound, etErr, iuOK, ctNone,\
     "Could not find argument for command.")\
 MSG(emNoMatchC, etWarn, iuOK, ctOutMath,\
     "No match found for `%s'.")\
 MSG(emMathStillOn, etWarn, iuOK, ctNone,\
     "Mathmode still on at end of LaTeX file.")\
 MSG(emNoMatchCC, etWarn, iuOK, ctNone,\
     "Number of `%c' doesn't match the number of `%c'!")\
 MSG(emUseQuoteLiga, etWarn, iuOK, ctNone,\
     "Use either `` or '' as an alternative to `\"'.")\
 MSG(emUseOtherQuote, etWarn, iuNotSys, ctNone,\
     "Use \"'\" (ASCII 39) instead  of \"\xB4\" (ASCII 180).")\
 MSG(emUserWarn, etWarn, iuOK, ctNone,\
     "User-specified pattern found: %s.")\
 MSG(emNotIntended, etWarn, iuNotSys, ctNone,\
     "This command might not be intended.")\
 MSG(emComment, etMsg, iuNotSys, ctNone,\
     "Comment displayed.")\
 MSG(emThreeQuotes, etWarn, iuOK, ctNone,\
     "Either %c\\,%c%c or %c%c\\,%c will look better.")\
 MSG(emFalsePage, etWarn, iuOK, ctOutMath,\
     "Delete this space to maintain correct pagereferences.")\
 MSG(emEmbrace, etWarn, iuOK, ctInMath,\
     "You might wish to put this between a pair of `{}'")\
 MSG(emSpacePunct, etWarn, iuOK, ctOutMath,\
     "You ought to remove spaces in front of punctuation.")\
 MSG(emNoCmdExec, etWarn, iuOK, ctNone,\
     "Could not execute LaTeX command.")\
 MSG(emItPunct, etWarn, iuOK, ctNone,\
     "Don't use \\/ in front of small punctuation.")\
 MSG(emUseTimes, etWarn, iuOK, ctNone,\
     "$\\times$ may look prettier here.")\
 MSG(emMultiSpace, etWarn, iuNotSys, ctOutMath,\
     "Multiple spaces detected in input.")\
 MSG(emIgnoreText, etWarn, iuOK, ctNone,\
    "This text may be ignored.")\
 MSG(emBeginQ, etWarn, iuOK, ctOutMath,\
   "Use ` to begin quotation, not '.")\
 MSG(emEndQ, etWarn, iuOK, ctOutMath,\
   "Use ' to end quotation, not `.")\
 MSG(emQuoteMix, etWarn, iuOK, ctNone,\
     "Don't mix quotes.")\
 MSG(emWordCommand, etWarn, iuOK, ctInMath,\
     "You should perhaps use `\\%s' instead.")\
 MSG(emSpaceParen, etWarn, iuOK, ctOutMath,\
     "You should put a space %s parenthesis.")\
 MSG(emNoSpaceParen, etWarn, iuOK, ctOutMath,\
     "You should avoid spaces %s parenthesis.")\
 MSG(emQuoteStyle, etWarn, iuOK, ctOutMath,\
     "You should not use punctuation %s quotes.")\
 MSG(emDblSpace, etWarn, iuOK, ctOutMath,\
     "Double space found.")\
 MSG(emPunctMath, etWarn, iuOK, ctNone,\
     "You should put punctuation %s math mode.")\
 MSG(emTeXPrim, etWarn, iuNotSys, ctNone,\
     "You ought to not use primitive TeX in LaTeX code.")\
 MSG(emRemPSSpace, etWarn, iuOK, ctOutMath,\
     "You should remove spaces in front of `%s'") \
 MSG(emNoCharMean, etWarn, iuOK, ctNone,\
     "`%s' is normally not followed by `%c'.")\
 MSG(emUserWarnRegex, etWarn, iuOK, ctNone,\
     "User Regex: %.*s.") \
 MSG(emDisplayMath, etWarn, iuOK, ctOutMath,\
     "Use \\[ ... \\] instead of $$ ... $$.")\
 MSG(emInlineMath, etWarn, iuNotSys, ctOutMath,\
     "Use \\( ... \\) instead of $ ... $.")

#undef MSG
#define MSG(num, type, inuse, ctxt, text) num,

enum ErrNum
{
    ERRMSGS emMaxFault
};
#undef MSG

enum Context
{
    ctNone = 0x00,
    ctInMath = 0x01,
    ctOutMath = 0x02,
    ctInHead = 0x04,
    ctOutHead = 0x08
};

struct ErrMsg
{
    enum ErrNum Number;
    enum
    {
        etMsg,
        etWarn,
        etErr
    } Type;

    enum
    {
        iuNotSys,
        iuNotUser,
        iuOK
    } InUse;

    /* Requirements posed upon environment */
    enum Context Context;

    const char *Message;
};

enum ItState
{
    itOff,
    itOn,
    itCorrected
};


enum DotLevel
{
    dtUnknown = 0x0,
    dtCDots = 0x1,
    dtLDots = 0x2,
    dtDots = 0x4
};

extern struct ErrMsg LaTeXMsgs[emMaxFault + 1];

extern char *OutputFormat;

int CheckSilentRegex(void);
int FindErr(const char *, const unsigned long);
void PrintError(const char *, const char *, const long, const long,
                const long, const enum ErrNum, ...);
void PrintStatus(unsigned long Lines);

#endif /* FINDERRS */