@@ -40,45 +40,6 @@ ctmbstr TY_(tidyLibraryVersion)(void)
40
40
* General Message Utility Functions
41
41
*********************************************************************/
42
42
43
- /* Updates document message counts and compares counts to options to
44
- ** see if message display should go forward.
45
- */
46
- static Bool UpdateCount ( TidyDocImpl * doc , TidyReportLevel level )
47
- {
48
- /* keep quiet after <ShowErrors> errors */
49
- Bool go = ( doc -> errors < cfg (doc , TidyShowErrors ) );
50
-
51
- switch ( level )
52
- {
53
- case TidyInfo :
54
- doc -> infoMessages ++ ;
55
- break ;
56
- case TidyWarning :
57
- doc -> warnings ++ ;
58
- break ;
59
- case TidyConfig :
60
- doc -> optionErrors ++ ;
61
- break ;
62
- case TidyAccess :
63
- doc -> accessErrors ++ ;
64
- break ;
65
- case TidyError :
66
- doc -> errors ++ ;
67
- break ;
68
- case TidyBadDocument :
69
- doc -> docErrors ++ ;
70
- break ;
71
- case TidyFatal :
72
- /* Ack! */
73
- break ;
74
- default :
75
- break ;
76
- }
77
-
78
- return go ;
79
- }
80
-
81
-
82
43
/* Returns the given node's tag as a string. */
83
44
static char * TagToString (Node * tag , char * buf , size_t count )
84
45
{
@@ -157,7 +118,7 @@ static ctmbstr HTMLVersion( TidyDocImpl* doc )
157
118
static void messageOut ( TidyMessageImpl * message )
158
119
{
159
120
TidyDocImpl * doc ;
160
- Bool go ;
121
+ Bool go = yes ;
161
122
162
123
if ( !message )
163
124
return ;
@@ -167,10 +128,38 @@ static void messageOut( TidyMessageImpl *message )
167
128
/* The filter has had a chance to suppress *any* message from output. */
168
129
go = message -> allowMessage ;
169
130
170
- /* Allow UpdateCount a chance to suppress further report messages. */
131
+ /* Update the count of each report type. */
132
+ switch ( message -> level )
133
+ {
134
+ case TidyInfo :
135
+ doc -> infoMessages ++ ;
136
+ break ;
137
+ case TidyWarning :
138
+ doc -> warnings ++ ;
139
+ break ;
140
+ case TidyConfig :
141
+ doc -> optionErrors ++ ;
142
+ break ;
143
+ case TidyAccess :
144
+ doc -> accessErrors ++ ;
145
+ break ;
146
+ case TidyError :
147
+ doc -> errors ++ ;
148
+ break ;
149
+ case TidyBadDocument :
150
+ doc -> docErrors ++ ;
151
+ break ;
152
+ case TidyFatal :
153
+ /* Ack! */
154
+ break ;
155
+ default :
156
+ break ;
157
+ }
158
+
159
+ /* Suppress report messages if we've already reached the reporting limit. */
171
160
if ( message -> level <= TidyFatal )
172
161
{
173
- go = go & UpdateCount ( doc , message -> level );
162
+ go = go & ( doc -> errors < cfg ( doc , TidyShowErrors ) );
174
163
}
175
164
176
165
/* If suppressing TidyInfo/TidyDialogueInfo on Reports, suppress them. */
@@ -229,7 +218,11 @@ static void messageOut( TidyMessageImpl *message )
229
218
230
219
/* Functions of this type will create new instances of TidyMessage specific to
231
220
** the type of report being emitted. Many messages share the same fomatter for
232
- ** messages, but new ones can be written as required.
221
+ ** messages, but new ones can be written as required. Please have a look at
222
+ ** the existing formatters in order to determine if an existing signature is
223
+ ** compatible with the report you wish to output before adding a new formatter.
224
+ ** In particular, if an existing formatter provides most of the local variables
225
+ ** required to populate your format string, try to use it.
233
226
*/
234
227
typedef TidyMessageImpl * (messageFormatter )(TidyDocImpl * doc , Node * element , Node * node , uint code , uint level , va_list args );
235
228
@@ -244,7 +237,7 @@ static messageFormatter formatStandardDynamic;
244
237
245
238
/* This structure ties together for each report Code the default
246
239
** TidyReportLevel, the Formatter to be used to construct the message, and the
247
- ** Next code to output, if applicable. Assuming an existing formatter can,
240
+ ** next code to output, if applicable. Assuming an existing formatter can,
248
241
** this it makes it simple to output new reports, or to change report level by
249
242
** modifying this array.
250
243
*/
@@ -485,14 +478,30 @@ static struct _dispatchTable {
485
478
*********************************************************************/
486
479
487
480
488
- /* Provides formatting for the Attribute-related reports. */
481
+ /* Provides formatting for the Attribute-related reports. This formatter
482
+ ** should be reserved for messages generated by Tidy's accessibility module,
483
+ ** even if the signature matches some unrelated report that you wish to
484
+ ** generate.
485
+ */
489
486
TidyMessageImpl * formatAccessReport (TidyDocImpl * doc , Node * element , Node * node , uint code , uint level , va_list args )
490
487
{
491
488
doc -> badAccess |= BA_WAI ;
492
- return TY_ (tidyMessageCreateWithNode )(doc , node , code , level );
489
+
490
+ /* Currently *all* cases are handled in the default, but maintain this
491
+ structure for possible future cases. */
492
+ switch (code )
493
+ {
494
+ default :
495
+ return TY_ (tidyMessageCreateWithNode )(doc , node , code , level );
496
+ }
497
+
498
+ return NULL ;
493
499
}
494
500
495
- /* Provides formatting for the Attribute-related reports. */
501
+ /* Provides formatting for the Attribute-related reports. This formatter
502
+ ** provides local variables that are used principally in the formats used for
503
+ ** the attribute related reports.
504
+ */
496
505
TidyMessageImpl * formatAttributeReport (TidyDocImpl * doc , Node * element , Node * node , uint code , uint level , va_list args )
497
506
{
498
507
AttVal * av = NULL ;
@@ -573,7 +582,8 @@ TidyMessageImpl *formatAttributeReport(TidyDocImpl* doc, Node *element, Node *no
573
582
574
583
575
584
/* Provides report formatting *and* additional status settings for Tidy's
576
- ** encoding reports.
585
+ ** encoding reports. Provides the local variables typically used for this type
586
+ ** of report.
577
587
** @todo: These status changes probably SHOULD be made in the calling code;
578
588
** however these states are captured to generate future output, which may be
579
589
** useful here in the long run.
@@ -633,6 +643,9 @@ TidyMessageImpl *formatEncodingReport(TidyDocImpl* doc, Node *element, Node *nod
633
643
** reports use the same basic data derived from the element and node, this
634
644
** formatter covers the vast majority of Tidy's report messages. Note that this
635
645
** formatter guarantees the values of TidyReportLevel in the dispatchTable[].
646
+ ** Some of the cases in this formatter start new contexts from the va_list
647
+ ** when the required data is simple. For complex local variable needs, it may
648
+ ** be preferred to write a new formatter.
636
649
*/
637
650
TidyMessageImpl * formatStandard (TidyDocImpl * doc , Node * element , Node * node , uint code , uint level , va_list args )
638
651
{
@@ -880,7 +893,9 @@ static void vReport(TidyDocImpl* doc, Node *element, Node *node, uint code, va_l
880
893
** possible, relevant data that can be reported. The only real drawbacks are
881
894
** having to pass NULL when some of the values aren't used, and the lack of
882
895
** type safety by using the variable arguments. To counter this some convenience
883
- ** report output functions exist, too.
896
+ ** report output functions exist, too. Any new reports you wish to create must
897
+ ** be able to use this function signature, although convenience functions should
898
+ ** be added to abstract the full fuction signature and to preserve type safety.
884
899
*/
885
900
void TY_ (Report )(TidyDocImpl * doc , Node * element , Node * node , uint code , ...)
886
901
{
@@ -894,7 +909,8 @@ void TY_(Report)(TidyDocImpl* doc, Node *element, Node *node, uint code, ...)
894
909
/*********************************************************************
895
910
* Convenience Reporting Functions
896
911
* Functions that don't require the full signature of TY_(Report),
897
- * and help protect type safety by avoiding variable arguments.
912
+ * and help protect type safety by avoiding variable arguments in the
913
+ * rest of Tidy's code.
898
914
*********************************************************************/
899
915
900
916
#if SUPPORT_ACCESSIBILITY_CHECKS
0 commit comments