tidy-ext 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/LICENSE +50 -0
- data/README +12 -0
- data/Rakefile +60 -0
- data/VERSION +1 -0
- data/ext/tidy/access.c +3310 -0
- data/ext/tidy/access.h +279 -0
- data/ext/tidy/alloc.c +107 -0
- data/ext/tidy/attrask.c +209 -0
- data/ext/tidy/attrdict.c +2398 -0
- data/ext/tidy/attrdict.h +122 -0
- data/ext/tidy/attrget.c +213 -0
- data/ext/tidy/attrs.c +1911 -0
- data/ext/tidy/attrs.h +374 -0
- data/ext/tidy/buffio.c +232 -0
- data/ext/tidy/buffio.h +118 -0
- data/ext/tidy/charsets.c +1032 -0
- data/ext/tidy/charsets.h +14 -0
- data/ext/tidy/clean.c +2674 -0
- data/ext/tidy/clean.h +87 -0
- data/ext/tidy/config.c +1746 -0
- data/ext/tidy/config.h +153 -0
- data/ext/tidy/entities.c +419 -0
- data/ext/tidy/entities.h +24 -0
- data/ext/tidy/extconf.rb +5 -0
- data/ext/tidy/fileio.c +106 -0
- data/ext/tidy/fileio.h +46 -0
- data/ext/tidy/forward.h +69 -0
- data/ext/tidy/iconvtc.c +105 -0
- data/ext/tidy/iconvtc.h +15 -0
- data/ext/tidy/istack.c +373 -0
- data/ext/tidy/lexer.c +3825 -0
- data/ext/tidy/lexer.h +617 -0
- data/ext/tidy/localize.c +1882 -0
- data/ext/tidy/mappedio.c +329 -0
- data/ext/tidy/mappedio.h +16 -0
- data/ext/tidy/message.h +207 -0
- data/ext/tidy/parser.c +4408 -0
- data/ext/tidy/parser.h +76 -0
- data/ext/tidy/platform.h +636 -0
- data/ext/tidy/pprint.c +2276 -0
- data/ext/tidy/pprint.h +93 -0
- data/ext/tidy/ruby-tidy.c +195 -0
- data/ext/tidy/streamio.c +1407 -0
- data/ext/tidy/streamio.h +222 -0
- data/ext/tidy/tagask.c +286 -0
- data/ext/tidy/tags.c +955 -0
- data/ext/tidy/tags.h +235 -0
- data/ext/tidy/tidy-int.h +129 -0
- data/ext/tidy/tidy.h +1097 -0
- data/ext/tidy/tidyenum.h +622 -0
- data/ext/tidy/tidylib.c +1751 -0
- data/ext/tidy/tmbstr.c +306 -0
- data/ext/tidy/tmbstr.h +92 -0
- data/ext/tidy/utf8.c +539 -0
- data/ext/tidy/utf8.h +52 -0
- data/ext/tidy/version.h +14 -0
- data/ext/tidy/win32tc.c +795 -0
- data/ext/tidy/win32tc.h +19 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/tidy/compat_spec.rb +44 -0
- data/spec/tidy/remote_uri_spec.rb +14 -0
- data/spec/tidy/test1.html +5 -0
- data/spec/tidy/tidy_spec.rb +34 -0
- metadata +125 -0
data/ext/tidy/attrs.h
ADDED
@@ -0,0 +1,374 @@
|
|
1
|
+
#ifndef __ATTRS_H__
|
2
|
+
#define __ATTRS_H__
|
3
|
+
|
4
|
+
/* attrs.h -- recognize HTML attributes
|
5
|
+
|
6
|
+
(c) 1998-2007 (W3C) MIT, ERCIM, Keio University
|
7
|
+
See tidy.h for the copyright notice.
|
8
|
+
|
9
|
+
CVS Info :
|
10
|
+
|
11
|
+
$Author: arnaud02 $
|
12
|
+
$Date: 2007/06/14 09:36:06 $
|
13
|
+
$Revision: 1.29 $
|
14
|
+
|
15
|
+
*/
|
16
|
+
|
17
|
+
#include "forward.h"
|
18
|
+
|
19
|
+
/* declaration for methods that check attribute values */
|
20
|
+
typedef void (AttrCheck)(TidyDocImpl* doc, Node *node, AttVal *attval);
|
21
|
+
|
22
|
+
struct _Attribute
|
23
|
+
{
|
24
|
+
TidyAttrId id;
|
25
|
+
tmbstr name;
|
26
|
+
unsigned versions;
|
27
|
+
AttrCheck* attrchk;
|
28
|
+
|
29
|
+
struct _Attribute* next;
|
30
|
+
};
|
31
|
+
|
32
|
+
|
33
|
+
/*
|
34
|
+
Anchor/Node linked list
|
35
|
+
*/
|
36
|
+
|
37
|
+
struct _Anchor
|
38
|
+
{
|
39
|
+
struct _Anchor *next;
|
40
|
+
Node *node;
|
41
|
+
char *name;
|
42
|
+
};
|
43
|
+
|
44
|
+
typedef struct _Anchor Anchor;
|
45
|
+
|
46
|
+
#if !defined(ATTRIBUTE_HASH_LOOKUP)
|
47
|
+
#define ATTRIBUTE_HASH_LOOKUP 1
|
48
|
+
#endif
|
49
|
+
|
50
|
+
#if ATTRIBUTE_HASH_LOOKUP
|
51
|
+
enum
|
52
|
+
{
|
53
|
+
ATTRIBUTE_HASH_SIZE=178u
|
54
|
+
};
|
55
|
+
|
56
|
+
struct _AttrHash
|
57
|
+
{
|
58
|
+
Attribute const* attr;
|
59
|
+
struct _AttrHash* next;
|
60
|
+
};
|
61
|
+
|
62
|
+
typedef struct _AttrHash AttrHash;
|
63
|
+
#endif
|
64
|
+
|
65
|
+
struct _TidyAttribImpl
|
66
|
+
{
|
67
|
+
/* anchor/node lookup */
|
68
|
+
Anchor* anchor_list;
|
69
|
+
|
70
|
+
/* Declared literal attributes */
|
71
|
+
Attribute* declared_attr_list;
|
72
|
+
|
73
|
+
#if ATTRIBUTE_HASH_LOOKUP
|
74
|
+
AttrHash* hashtab[ATTRIBUTE_HASH_SIZE];
|
75
|
+
#endif
|
76
|
+
};
|
77
|
+
|
78
|
+
typedef struct _TidyAttribImpl TidyAttribImpl;
|
79
|
+
|
80
|
+
#define XHTML_NAMESPACE "http://www.w3.org/1999/xhtml"
|
81
|
+
|
82
|
+
AttrCheck TY_(CheckUrl);
|
83
|
+
|
84
|
+
/* public method for finding attribute definition by name */
|
85
|
+
const Attribute* TY_(CheckAttribute)( TidyDocImpl* doc, Node *node, AttVal *attval );
|
86
|
+
|
87
|
+
const Attribute* TY_(FindAttribute)( TidyDocImpl* doc, AttVal *attval );
|
88
|
+
|
89
|
+
AttVal* TY_(GetAttrByName)( Node *node, ctmbstr name );
|
90
|
+
|
91
|
+
AttVal* TY_(AddAttribute)( TidyDocImpl* doc,
|
92
|
+
Node *node, ctmbstr name, ctmbstr value );
|
93
|
+
|
94
|
+
AttVal* TY_(RepairAttrValue)(TidyDocImpl* doc, Node* node, ctmbstr name, ctmbstr value);
|
95
|
+
|
96
|
+
Bool TY_(IsUrl)( TidyDocImpl* doc, ctmbstr attrname );
|
97
|
+
|
98
|
+
/* Bool IsBool( TidyDocImpl* doc, ctmbstr attrname ); */
|
99
|
+
|
100
|
+
Bool TY_(IsScript)( TidyDocImpl* doc, ctmbstr attrname );
|
101
|
+
|
102
|
+
/* may id or name serve as anchor? */
|
103
|
+
Bool TY_(IsAnchorElement)( TidyDocImpl* doc, Node* node );
|
104
|
+
|
105
|
+
/*
|
106
|
+
In CSS1, selectors can contain only the characters A-Z, 0-9, and
|
107
|
+
Unicode characters 161-255, plus dash (-); they cannot start with
|
108
|
+
a dash or a digit; they can also contain escaped characters and any
|
109
|
+
Unicode character as a numeric code (see next item).
|
110
|
+
|
111
|
+
The backslash followed by at most four hexadecimal digits (0..9A..F)
|
112
|
+
stands for the Unicode character with that number.
|
113
|
+
|
114
|
+
Any character except a hexadecimal digit can be escaped to remove its
|
115
|
+
special meaning, by putting a backslash in front.
|
116
|
+
|
117
|
+
#508936 - CSS class naming for -clean option
|
118
|
+
*/
|
119
|
+
Bool TY_(IsCSS1Selector)( ctmbstr buf );
|
120
|
+
|
121
|
+
Bool TY_(IsValidHTMLID)(ctmbstr id);
|
122
|
+
Bool TY_(IsValidXMLID)(ctmbstr id);
|
123
|
+
|
124
|
+
/* removes anchor for specific node */
|
125
|
+
void TY_(RemoveAnchorByNode)( TidyDocImpl* doc, Node *node );
|
126
|
+
|
127
|
+
/* free all anchors */
|
128
|
+
void TY_(FreeAnchors)( TidyDocImpl* doc );
|
129
|
+
|
130
|
+
|
131
|
+
/* public methods for inititializing/freeing attribute dictionary */
|
132
|
+
void TY_(InitAttrs)( TidyDocImpl* doc );
|
133
|
+
void TY_(FreeAttrTable)( TidyDocImpl* doc );
|
134
|
+
|
135
|
+
void TY_(AppendToClassAttr)( TidyDocImpl* doc, AttVal *classattr, ctmbstr classname );
|
136
|
+
/*
|
137
|
+
the same attribute name can't be used
|
138
|
+
more than once in each element
|
139
|
+
*/
|
140
|
+
void TY_(RepairDuplicateAttributes)( TidyDocImpl* doc, Node* node, Bool isXml );
|
141
|
+
void TY_(SortAttributes)(Node* node, TidyAttrSortStrategy strat);
|
142
|
+
|
143
|
+
Bool TY_(IsBoolAttribute)( AttVal* attval );
|
144
|
+
Bool TY_(attrIsEvent)( AttVal* attval );
|
145
|
+
|
146
|
+
AttVal* TY_(AttrGetById)( Node* node, TidyAttrId id );
|
147
|
+
|
148
|
+
uint TY_(NodeAttributeVersions)( Node* node, TidyAttrId id );
|
149
|
+
|
150
|
+
/* 0 == TidyAttr_UNKNOWN */
|
151
|
+
#define AttrId(av) ((av) && (av)->dict ? (av)->dict->id : TidyAttr_UNKNOWN)
|
152
|
+
#define AttrIsId(av, atid) ((av) && (av)->dict && ((av)->dict->id == atid))
|
153
|
+
|
154
|
+
#define AttrHasValue(attr) ((attr) && (attr)->value)
|
155
|
+
#define AttrValueIs(attr, val) (AttrHasValue(attr) && \
|
156
|
+
TY_(tmbstrcasecmp)((attr)->value, val) == 0)
|
157
|
+
#define AttrContains(attr, val) (AttrHasValue(attr) && \
|
158
|
+
TY_(tmbsubstr)((attr)->value, val) != NULL)
|
159
|
+
#define AttrVersions(attr) ((attr) && (attr)->dict ? (attr)->dict->versions : VERS_PROPRIETARY)
|
160
|
+
|
161
|
+
#define AttrsHaveSameId(a, b) (a && b && a->dict && b->dict && a->dict->id && \
|
162
|
+
b->dict->id && a->dict->id == b->dict->id)
|
163
|
+
|
164
|
+
#define attrIsABBR(av) AttrIsId( av, TidyAttr_ABBR )
|
165
|
+
#define attrIsACCEPT(av) AttrIsId( av, TidyAttr_ACCEPT )
|
166
|
+
#define attrIsACCEPT_CHARSET(av) AttrIsId( av, TidyAttr_ACCEPT_CHARSET )
|
167
|
+
#define attrIsACCESSKEY(av) AttrIsId( av, TidyAttr_ACCESSKEY )
|
168
|
+
#define attrIsACTION(av) AttrIsId( av, TidyAttr_ACTION )
|
169
|
+
#define attrIsADD_DATE(av) AttrIsId( av, TidyAttr_ADD_DATE )
|
170
|
+
#define attrIsALIGN(av) AttrIsId( av, TidyAttr_ALIGN )
|
171
|
+
#define attrIsALINK(av) AttrIsId( av, TidyAttr_ALINK )
|
172
|
+
#define attrIsALT(av) AttrIsId( av, TidyAttr_ALT )
|
173
|
+
#define attrIsARCHIVE(av) AttrIsId( av, TidyAttr_ARCHIVE )
|
174
|
+
#define attrIsAXIS(av) AttrIsId( av, TidyAttr_AXIS )
|
175
|
+
#define attrIsBACKGROUND(av) AttrIsId( av, TidyAttr_BACKGROUND )
|
176
|
+
#define attrIsBGCOLOR(av) AttrIsId( av, TidyAttr_BGCOLOR )
|
177
|
+
#define attrIsBGPROPERTIES(av) AttrIsId( av, TidyAttr_BGPROPERTIES )
|
178
|
+
#define attrIsBORDER(av) AttrIsId( av, TidyAttr_BORDER )
|
179
|
+
#define attrIsBORDERCOLOR(av) AttrIsId( av, TidyAttr_BORDERCOLOR )
|
180
|
+
#define attrIsBOTTOMMARGIN(av) AttrIsId( av, TidyAttr_BOTTOMMARGIN )
|
181
|
+
#define attrIsCELLPADDING(av) AttrIsId( av, TidyAttr_CELLPADDING )
|
182
|
+
#define attrIsCELLSPACING(av) AttrIsId( av, TidyAttr_CELLSPACING )
|
183
|
+
#define attrIsCHAR(av) AttrIsId( av, TidyAttr_CHAR )
|
184
|
+
#define attrIsCHAROFF(av) AttrIsId( av, TidyAttr_CHAROFF )
|
185
|
+
#define attrIsCHARSET(av) AttrIsId( av, TidyAttr_CHARSET )
|
186
|
+
#define attrIsCHECKED(av) AttrIsId( av, TidyAttr_CHECKED )
|
187
|
+
#define attrIsCITE(av) AttrIsId( av, TidyAttr_CITE )
|
188
|
+
#define attrIsCLASS(av) AttrIsId( av, TidyAttr_CLASS )
|
189
|
+
#define attrIsCLASSID(av) AttrIsId( av, TidyAttr_CLASSID )
|
190
|
+
#define attrIsCLEAR(av) AttrIsId( av, TidyAttr_CLEAR )
|
191
|
+
#define attrIsCODE(av) AttrIsId( av, TidyAttr_CODE )
|
192
|
+
#define attrIsCODEBASE(av) AttrIsId( av, TidyAttr_CODEBASE )
|
193
|
+
#define attrIsCODETYPE(av) AttrIsId( av, TidyAttr_CODETYPE )
|
194
|
+
#define attrIsCOLOR(av) AttrIsId( av, TidyAttr_COLOR )
|
195
|
+
#define attrIsCOLS(av) AttrIsId( av, TidyAttr_COLS )
|
196
|
+
#define attrIsCOLSPAN(av) AttrIsId( av, TidyAttr_COLSPAN )
|
197
|
+
#define attrIsCOMPACT(av) AttrIsId( av, TidyAttr_COMPACT )
|
198
|
+
#define attrIsCONTENT(av) AttrIsId( av, TidyAttr_CONTENT )
|
199
|
+
#define attrIsCOORDS(av) AttrIsId( av, TidyAttr_COORDS )
|
200
|
+
#define attrIsDATA(av) AttrIsId( av, TidyAttr_DATA )
|
201
|
+
#define attrIsDATAFLD(av) AttrIsId( av, TidyAttr_DATAFLD )
|
202
|
+
#define attrIsDATAFORMATAS(av) AttrIsId( av, TidyAttr_DATAFORMATAS )
|
203
|
+
#define attrIsDATAPAGESIZE(av) AttrIsId( av, TidyAttr_DATAPAGESIZE )
|
204
|
+
#define attrIsDATASRC(av) AttrIsId( av, TidyAttr_DATASRC )
|
205
|
+
#define attrIsDATETIME(av) AttrIsId( av, TidyAttr_DATETIME )
|
206
|
+
#define attrIsDECLARE(av) AttrIsId( av, TidyAttr_DECLARE )
|
207
|
+
#define attrIsDEFER(av) AttrIsId( av, TidyAttr_DEFER )
|
208
|
+
#define attrIsDIR(av) AttrIsId( av, TidyAttr_DIR )
|
209
|
+
#define attrIsDISABLED(av) AttrIsId( av, TidyAttr_DISABLED )
|
210
|
+
#define attrIsENCODING(av) AttrIsId( av, TidyAttr_ENCODING )
|
211
|
+
#define attrIsENCTYPE(av) AttrIsId( av, TidyAttr_ENCTYPE )
|
212
|
+
#define attrIsFACE(av) AttrIsId( av, TidyAttr_FACE )
|
213
|
+
#define attrIsFOR(av) AttrIsId( av, TidyAttr_FOR )
|
214
|
+
#define attrIsFRAME(av) AttrIsId( av, TidyAttr_FRAME )
|
215
|
+
#define attrIsFRAMEBORDER(av) AttrIsId( av, TidyAttr_FRAMEBORDER )
|
216
|
+
#define attrIsFRAMESPACING(av) AttrIsId( av, TidyAttr_FRAMESPACING )
|
217
|
+
#define attrIsGRIDX(av) AttrIsId( av, TidyAttr_GRIDX )
|
218
|
+
#define attrIsGRIDY(av) AttrIsId( av, TidyAttr_GRIDY )
|
219
|
+
#define attrIsHEADERS(av) AttrIsId( av, TidyAttr_HEADERS )
|
220
|
+
#define attrIsHEIGHT(av) AttrIsId( av, TidyAttr_HEIGHT )
|
221
|
+
#define attrIsHREF(av) AttrIsId( av, TidyAttr_HREF )
|
222
|
+
#define attrIsHREFLANG(av) AttrIsId( av, TidyAttr_HREFLANG )
|
223
|
+
#define attrIsHSPACE(av) AttrIsId( av, TidyAttr_HSPACE )
|
224
|
+
#define attrIsHTTP_EQUIV(av) AttrIsId( av, TidyAttr_HTTP_EQUIV )
|
225
|
+
#define attrIsID(av) AttrIsId( av, TidyAttr_ID )
|
226
|
+
#define attrIsISMAP(av) AttrIsId( av, TidyAttr_ISMAP )
|
227
|
+
#define attrIsLABEL(av) AttrIsId( av, TidyAttr_LABEL )
|
228
|
+
#define attrIsLANG(av) AttrIsId( av, TidyAttr_LANG )
|
229
|
+
#define attrIsLANGUAGE(av) AttrIsId( av, TidyAttr_LANGUAGE )
|
230
|
+
#define attrIsLAST_MODIFIED(av) AttrIsId( av, TidyAttr_LAST_MODIFIED )
|
231
|
+
#define attrIsLAST_VISIT(av) AttrIsId( av, TidyAttr_LAST_VISIT )
|
232
|
+
#define attrIsLEFTMARGIN(av) AttrIsId( av, TidyAttr_LEFTMARGIN )
|
233
|
+
#define attrIsLINK(av) AttrIsId( av, TidyAttr_LINK )
|
234
|
+
#define attrIsLONGDESC(av) AttrIsId( av, TidyAttr_LONGDESC )
|
235
|
+
#define attrIsLOWSRC(av) AttrIsId( av, TidyAttr_LOWSRC )
|
236
|
+
#define attrIsMARGINHEIGHT(av) AttrIsId( av, TidyAttr_MARGINHEIGHT )
|
237
|
+
#define attrIsMARGINWIDTH(av) AttrIsId( av, TidyAttr_MARGINWIDTH )
|
238
|
+
#define attrIsMAXLENGTH(av) AttrIsId( av, TidyAttr_MAXLENGTH )
|
239
|
+
#define attrIsMEDIA(av) AttrIsId( av, TidyAttr_MEDIA )
|
240
|
+
#define attrIsMETHOD(av) AttrIsId( av, TidyAttr_METHOD )
|
241
|
+
#define attrIsMULTIPLE(av) AttrIsId( av, TidyAttr_MULTIPLE )
|
242
|
+
#define attrIsNAME(av) AttrIsId( av, TidyAttr_NAME )
|
243
|
+
#define attrIsNOHREF(av) AttrIsId( av, TidyAttr_NOHREF )
|
244
|
+
#define attrIsNORESIZE(av) AttrIsId( av, TidyAttr_NORESIZE )
|
245
|
+
#define attrIsNOSHADE(av) AttrIsId( av, TidyAttr_NOSHADE )
|
246
|
+
#define attrIsNOWRAP(av) AttrIsId( av, TidyAttr_NOWRAP )
|
247
|
+
#define attrIsOBJECT(av) AttrIsId( av, TidyAttr_OBJECT )
|
248
|
+
#define attrIsOnAFTERUPDATE(av) AttrIsId( av, TidyAttr_OnAFTERUPDATE )
|
249
|
+
#define attrIsOnBEFOREUNLOAD(av) AttrIsId( av, TidyAttr_OnBEFOREUNLOAD )
|
250
|
+
#define attrIsOnBEFOREUPDATE(av) AttrIsId( av, TidyAttr_OnBEFOREUPDATE )
|
251
|
+
#define attrIsOnBLUR(av) AttrIsId( av, TidyAttr_OnBLUR )
|
252
|
+
#define attrIsOnCHANGE(av) AttrIsId( av, TidyAttr_OnCHANGE )
|
253
|
+
#define attrIsOnCLICK(av) AttrIsId( av, TidyAttr_OnCLICK )
|
254
|
+
#define attrIsOnDATAAVAILABLE(av) AttrIsId( av, TidyAttr_OnDATAAVAILABLE )
|
255
|
+
#define attrIsOnDATASETCHANGED(av) AttrIsId( av, TidyAttr_OnDATASETCHANGED )
|
256
|
+
#define attrIsOnDATASETCOMPLETE(av) AttrIsId( av, TidyAttr_OnDATASETCOMPLETE )
|
257
|
+
#define attrIsOnDBLCLICK(av) AttrIsId( av, TidyAttr_OnDBLCLICK )
|
258
|
+
#define attrIsOnERRORUPDATE(av) AttrIsId( av, TidyAttr_OnERRORUPDATE )
|
259
|
+
#define attrIsOnFOCUS(av) AttrIsId( av, TidyAttr_OnFOCUS )
|
260
|
+
#define attrIsOnKEYDOWN(av) AttrIsId( av, TidyAttr_OnKEYDOWN )
|
261
|
+
#define attrIsOnKEYPRESS(av) AttrIsId( av, TidyAttr_OnKEYPRESS )
|
262
|
+
#define attrIsOnKEYUP(av) AttrIsId( av, TidyAttr_OnKEYUP )
|
263
|
+
#define attrIsOnLOAD(av) AttrIsId( av, TidyAttr_OnLOAD )
|
264
|
+
#define attrIsOnMOUSEDOWN(av) AttrIsId( av, TidyAttr_OnMOUSEDOWN )
|
265
|
+
#define attrIsOnMOUSEMOVE(av) AttrIsId( av, TidyAttr_OnMOUSEMOVE )
|
266
|
+
#define attrIsOnMOUSEOUT(av) AttrIsId( av, TidyAttr_OnMOUSEOUT )
|
267
|
+
#define attrIsOnMOUSEOVER(av) AttrIsId( av, TidyAttr_OnMOUSEOVER )
|
268
|
+
#define attrIsOnMOUSEUP(av) AttrIsId( av, TidyAttr_OnMOUSEUP )
|
269
|
+
#define attrIsOnRESET(av) AttrIsId( av, TidyAttr_OnRESET )
|
270
|
+
#define attrIsOnROWENTER(av) AttrIsId( av, TidyAttr_OnROWENTER )
|
271
|
+
#define attrIsOnROWEXIT(av) AttrIsId( av, TidyAttr_OnROWEXIT )
|
272
|
+
#define attrIsOnSELECT(av) AttrIsId( av, TidyAttr_OnSELECT )
|
273
|
+
#define attrIsOnSUBMIT(av) AttrIsId( av, TidyAttr_OnSUBMIT )
|
274
|
+
#define attrIsOnUNLOAD(av) AttrIsId( av, TidyAttr_OnUNLOAD )
|
275
|
+
#define attrIsPROFILE(av) AttrIsId( av, TidyAttr_PROFILE )
|
276
|
+
#define attrIsPROMPT(av) AttrIsId( av, TidyAttr_PROMPT )
|
277
|
+
#define attrIsRBSPAN(av) AttrIsId( av, TidyAttr_RBSPAN )
|
278
|
+
#define attrIsREADONLY(av) AttrIsId( av, TidyAttr_READONLY )
|
279
|
+
#define attrIsREL(av) AttrIsId( av, TidyAttr_REL )
|
280
|
+
#define attrIsREV(av) AttrIsId( av, TidyAttr_REV )
|
281
|
+
#define attrIsRIGHTMARGIN(av) AttrIsId( av, TidyAttr_RIGHTMARGIN )
|
282
|
+
#define attrIsROWS(av) AttrIsId( av, TidyAttr_ROWS )
|
283
|
+
#define attrIsROWSPAN(av) AttrIsId( av, TidyAttr_ROWSPAN )
|
284
|
+
#define attrIsRULES(av) AttrIsId( av, TidyAttr_RULES )
|
285
|
+
#define attrIsSCHEME(av) AttrIsId( av, TidyAttr_SCHEME )
|
286
|
+
#define attrIsSCOPE(av) AttrIsId( av, TidyAttr_SCOPE )
|
287
|
+
#define attrIsSCROLLING(av) AttrIsId( av, TidyAttr_SCROLLING )
|
288
|
+
#define attrIsSELECTED(av) AttrIsId( av, TidyAttr_SELECTED )
|
289
|
+
#define attrIsSHAPE(av) AttrIsId( av, TidyAttr_SHAPE )
|
290
|
+
#define attrIsSHOWGRID(av) AttrIsId( av, TidyAttr_SHOWGRID )
|
291
|
+
#define attrIsSHOWGRIDX(av) AttrIsId( av, TidyAttr_SHOWGRIDX )
|
292
|
+
#define attrIsSHOWGRIDY(av) AttrIsId( av, TidyAttr_SHOWGRIDY )
|
293
|
+
#define attrIsSIZE(av) AttrIsId( av, TidyAttr_SIZE )
|
294
|
+
#define attrIsSPAN(av) AttrIsId( av, TidyAttr_SPAN )
|
295
|
+
#define attrIsSRC(av) AttrIsId( av, TidyAttr_SRC )
|
296
|
+
#define attrIsSTANDBY(av) AttrIsId( av, TidyAttr_STANDBY )
|
297
|
+
#define attrIsSTART(av) AttrIsId( av, TidyAttr_START )
|
298
|
+
#define attrIsSTYLE(av) AttrIsId( av, TidyAttr_STYLE )
|
299
|
+
#define attrIsSUMMARY(av) AttrIsId( av, TidyAttr_SUMMARY )
|
300
|
+
#define attrIsTABINDEX(av) AttrIsId( av, TidyAttr_TABINDEX )
|
301
|
+
#define attrIsTARGET(av) AttrIsId( av, TidyAttr_TARGET )
|
302
|
+
#define attrIsTEXT(av) AttrIsId( av, TidyAttr_TEXT )
|
303
|
+
#define attrIsTITLE(av) AttrIsId( av, TidyAttr_TITLE )
|
304
|
+
#define attrIsTOPMARGIN(av) AttrIsId( av, TidyAttr_TOPMARGIN )
|
305
|
+
#define attrIsTYPE(av) AttrIsId( av, TidyAttr_TYPE )
|
306
|
+
#define attrIsUSEMAP(av) AttrIsId( av, TidyAttr_USEMAP )
|
307
|
+
#define attrIsVALIGN(av) AttrIsId( av, TidyAttr_VALIGN )
|
308
|
+
#define attrIsVALUE(av) AttrIsId( av, TidyAttr_VALUE )
|
309
|
+
#define attrIsVALUETYPE(av) AttrIsId( av, TidyAttr_VALUETYPE )
|
310
|
+
#define attrIsVERSION(av) AttrIsId( av, TidyAttr_VERSION )
|
311
|
+
#define attrIsVLINK(av) AttrIsId( av, TidyAttr_VLINK )
|
312
|
+
#define attrIsVSPACE(av) AttrIsId( av, TidyAttr_VSPACE )
|
313
|
+
#define attrIsWIDTH(av) AttrIsId( av, TidyAttr_WIDTH )
|
314
|
+
#define attrIsWRAP(av) AttrIsId( av, TidyAttr_WRAP )
|
315
|
+
#define attrIsXMLNS(av) AttrIsId( av, TidyAttr_XMLNS )
|
316
|
+
#define attrIsXML_LANG(av) AttrIsId( av, TidyAttr_XML_LANG )
|
317
|
+
#define attrIsXML_SPACE(av) AttrIsId( av, TidyAttr_XML_SPACE )
|
318
|
+
|
319
|
+
|
320
|
+
/* Attribute Retrieval macros
|
321
|
+
*/
|
322
|
+
#define attrGetHREF( nod ) TY_(AttrGetById)( nod, TidyAttr_HREF )
|
323
|
+
#define attrGetSRC( nod ) TY_(AttrGetById)( nod, TidyAttr_SRC )
|
324
|
+
#define attrGetID( nod ) TY_(AttrGetById)( nod, TidyAttr_ID )
|
325
|
+
#define attrGetNAME( nod ) TY_(AttrGetById)( nod, TidyAttr_NAME )
|
326
|
+
#define attrGetSUMMARY( nod ) TY_(AttrGetById)( nod, TidyAttr_SUMMARY )
|
327
|
+
#define attrGetALT( nod ) TY_(AttrGetById)( nod, TidyAttr_ALT )
|
328
|
+
#define attrGetLONGDESC( nod ) TY_(AttrGetById)( nod, TidyAttr_LONGDESC )
|
329
|
+
#define attrGetUSEMAP( nod ) TY_(AttrGetById)( nod, TidyAttr_USEMAP )
|
330
|
+
#define attrGetISMAP( nod ) TY_(AttrGetById)( nod, TidyAttr_ISMAP )
|
331
|
+
#define attrGetLANGUAGE( nod ) TY_(AttrGetById)( nod, TidyAttr_LANGUAGE )
|
332
|
+
#define attrGetTYPE( nod ) TY_(AttrGetById)( nod, TidyAttr_TYPE )
|
333
|
+
#define attrGetVALUE( nod ) TY_(AttrGetById)( nod, TidyAttr_VALUE )
|
334
|
+
#define attrGetCONTENT( nod ) TY_(AttrGetById)( nod, TidyAttr_CONTENT )
|
335
|
+
#define attrGetTITLE( nod ) TY_(AttrGetById)( nod, TidyAttr_TITLE )
|
336
|
+
#define attrGetXMLNS( nod ) TY_(AttrGetById)( nod, TidyAttr_XMLNS )
|
337
|
+
#define attrGetDATAFLD( nod ) TY_(AttrGetById)( nod, TidyAttr_DATAFLD )
|
338
|
+
#define attrGetWIDTH( nod ) TY_(AttrGetById)( nod, TidyAttr_WIDTH )
|
339
|
+
#define attrGetHEIGHT( nod ) TY_(AttrGetById)( nod, TidyAttr_HEIGHT )
|
340
|
+
#define attrGetFOR( nod ) TY_(AttrGetById)( nod, TidyAttr_FOR )
|
341
|
+
#define attrGetSELECTED( nod ) TY_(AttrGetById)( nod, TidyAttr_SELECTED )
|
342
|
+
#define attrGetCHECKED( nod ) TY_(AttrGetById)( nod, TidyAttr_CHECKED )
|
343
|
+
#define attrGetLANG( nod ) TY_(AttrGetById)( nod, TidyAttr_LANG )
|
344
|
+
#define attrGetTARGET( nod ) TY_(AttrGetById)( nod, TidyAttr_TARGET )
|
345
|
+
#define attrGetHTTP_EQUIV( nod ) TY_(AttrGetById)( nod, TidyAttr_HTTP_EQUIV )
|
346
|
+
#define attrGetREL( nod ) TY_(AttrGetById)( nod, TidyAttr_REL )
|
347
|
+
|
348
|
+
#define attrGetOnMOUSEMOVE( nod ) TY_(AttrGetById)( nod, TidyAttr_OnMOUSEMOVE )
|
349
|
+
#define attrGetOnMOUSEDOWN( nod ) TY_(AttrGetById)( nod, TidyAttr_OnMOUSEDOWN )
|
350
|
+
#define attrGetOnMOUSEUP( nod ) TY_(AttrGetById)( nod, TidyAttr_OnMOUSEUP )
|
351
|
+
#define attrGetOnCLICK( nod ) TY_(AttrGetById)( nod, TidyAttr_OnCLICK )
|
352
|
+
#define attrGetOnMOUSEOVER( nod ) TY_(AttrGetById)( nod, TidyAttr_OnMOUSEOVER )
|
353
|
+
#define attrGetOnMOUSEOUT( nod ) TY_(AttrGetById)( nod, TidyAttr_OnMOUSEOUT )
|
354
|
+
#define attrGetOnKEYDOWN( nod ) TY_(AttrGetById)( nod, TidyAttr_OnKEYDOWN )
|
355
|
+
#define attrGetOnKEYUP( nod ) TY_(AttrGetById)( nod, TidyAttr_OnKEYUP )
|
356
|
+
#define attrGetOnKEYPRESS( nod ) TY_(AttrGetById)( nod, TidyAttr_OnKEYPRESS )
|
357
|
+
#define attrGetOnFOCUS( nod ) TY_(AttrGetById)( nod, TidyAttr_OnFOCUS )
|
358
|
+
#define attrGetOnBLUR( nod ) TY_(AttrGetById)( nod, TidyAttr_OnBLUR )
|
359
|
+
|
360
|
+
#define attrGetBGCOLOR( nod ) TY_(AttrGetById)( nod, TidyAttr_BGCOLOR )
|
361
|
+
|
362
|
+
#define attrGetLINK( nod ) TY_(AttrGetById)( nod, TidyAttr_LINK )
|
363
|
+
#define attrGetALINK( nod ) TY_(AttrGetById)( nod, TidyAttr_ALINK )
|
364
|
+
#define attrGetVLINK( nod ) TY_(AttrGetById)( nod, TidyAttr_VLINK )
|
365
|
+
|
366
|
+
#define attrGetTEXT( nod ) TY_(AttrGetById)( nod, TidyAttr_TEXT )
|
367
|
+
#define attrGetSTYLE( nod ) TY_(AttrGetById)( nod, TidyAttr_STYLE )
|
368
|
+
#define attrGetABBR( nod ) TY_(AttrGetById)( nod, TidyAttr_ABBR )
|
369
|
+
#define attrGetCOLSPAN( nod ) TY_(AttrGetById)( nod, TidyAttr_COLSPAN )
|
370
|
+
#define attrGetFONT( nod ) TY_(AttrGetById)( nod, TidyAttr_FONT )
|
371
|
+
#define attrGetBASEFONT( nod ) TY_(AttrGetById)( nod, TidyAttr_BASEFONT )
|
372
|
+
#define attrGetROWSPAN( nod ) TY_(AttrGetById)( nod, TidyAttr_ROWSPAN )
|
373
|
+
|
374
|
+
#endif /* __ATTRS_H__ */
|
data/ext/tidy/buffio.c
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
/* buffio.c -- Treat buffer as an I/O stream.
|
2
|
+
|
3
|
+
(c) 1998-2007 (W3C) MIT, ERCIM, Keio University
|
4
|
+
See tidy.h for the copyright notice.
|
5
|
+
|
6
|
+
CVS Info :
|
7
|
+
|
8
|
+
$Author: arnaud02 $
|
9
|
+
$Date: 2007/01/23 11:17:46 $
|
10
|
+
$Revision: 1.14 $
|
11
|
+
|
12
|
+
Requires buffer to automatically grow as bytes are added.
|
13
|
+
Must keep track of current read and write points.
|
14
|
+
|
15
|
+
*/
|
16
|
+
|
17
|
+
#include "tidy.h"
|
18
|
+
#include "buffio.h"
|
19
|
+
#include "forward.h"
|
20
|
+
|
21
|
+
/**************
|
22
|
+
TIDY
|
23
|
+
**************/
|
24
|
+
|
25
|
+
static int TIDY_CALL insrc_getByte( void* appData )
|
26
|
+
{
|
27
|
+
TidyBuffer* buf = (TidyBuffer*) appData;
|
28
|
+
return tidyBufGetByte( buf );
|
29
|
+
}
|
30
|
+
static Bool TIDY_CALL insrc_eof( void* appData )
|
31
|
+
{
|
32
|
+
TidyBuffer* buf = (TidyBuffer*) appData;
|
33
|
+
return tidyBufEndOfInput( buf );
|
34
|
+
}
|
35
|
+
static void TIDY_CALL insrc_ungetByte( void* appData, byte bv )
|
36
|
+
{
|
37
|
+
TidyBuffer* buf = (TidyBuffer*) appData;
|
38
|
+
tidyBufUngetByte( buf, bv );
|
39
|
+
}
|
40
|
+
|
41
|
+
void TIDY_CALL tidyInitInputBuffer( TidyInputSource* inp, TidyBuffer* buf )
|
42
|
+
{
|
43
|
+
inp->getByte = insrc_getByte;
|
44
|
+
inp->eof = insrc_eof;
|
45
|
+
inp->ungetByte = insrc_ungetByte;
|
46
|
+
inp->sourceData = buf;
|
47
|
+
}
|
48
|
+
|
49
|
+
static void TIDY_CALL outsink_putByte( void* appData, byte bv )
|
50
|
+
{
|
51
|
+
TidyBuffer* buf = (TidyBuffer*) appData;
|
52
|
+
tidyBufPutByte( buf, bv );
|
53
|
+
}
|
54
|
+
|
55
|
+
void TIDY_CALL tidyInitOutputBuffer( TidyOutputSink* outp, TidyBuffer* buf )
|
56
|
+
{
|
57
|
+
outp->putByte = outsink_putByte;
|
58
|
+
outp->sinkData = buf;
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
void TIDY_CALL tidyBufInit( TidyBuffer* buf )
|
63
|
+
{
|
64
|
+
assert( buf != NULL );
|
65
|
+
tidyBufInitWithAllocator( buf, NULL );
|
66
|
+
}
|
67
|
+
|
68
|
+
void TIDY_CALL tidyBufAlloc( TidyBuffer* buf, uint allocSize )
|
69
|
+
{
|
70
|
+
tidyBufAllocWithAllocator( buf, NULL, allocSize );
|
71
|
+
}
|
72
|
+
|
73
|
+
void TIDY_CALL tidyBufInitWithAllocator( TidyBuffer* buf,
|
74
|
+
TidyAllocator *allocator )
|
75
|
+
{
|
76
|
+
assert( buf != NULL );
|
77
|
+
TidyClearMemory( buf, sizeof(TidyBuffer) );
|
78
|
+
buf->allocator = allocator ? allocator : &TY_(g_default_allocator);
|
79
|
+
}
|
80
|
+
|
81
|
+
void TIDY_CALL tidyBufAllocWithAllocator( TidyBuffer* buf,
|
82
|
+
TidyAllocator *allocator,
|
83
|
+
uint allocSize )
|
84
|
+
{
|
85
|
+
tidyBufInitWithAllocator( buf, allocator );
|
86
|
+
tidyBufCheckAlloc( buf, allocSize, 0 );
|
87
|
+
buf->next = 0;
|
88
|
+
}
|
89
|
+
|
90
|
+
void TIDY_CALL tidyBufFree( TidyBuffer* buf )
|
91
|
+
{
|
92
|
+
assert( buf != NULL );
|
93
|
+
TidyFree( buf->allocator, buf->bp );
|
94
|
+
tidyBufInitWithAllocator( buf, buf->allocator );
|
95
|
+
}
|
96
|
+
|
97
|
+
void TIDY_CALL tidyBufClear( TidyBuffer* buf )
|
98
|
+
{
|
99
|
+
assert( buf != NULL );
|
100
|
+
if ( buf->bp )
|
101
|
+
{
|
102
|
+
TidyClearMemory( buf->bp, buf->allocated );
|
103
|
+
buf->size = 0;
|
104
|
+
}
|
105
|
+
buf->next = 0;
|
106
|
+
}
|
107
|
+
|
108
|
+
/* Many users do not call tidyBufInit() or tidyBufAlloc() or their allocator
|
109
|
+
counterparts. So by default, set the default allocator.
|
110
|
+
*/
|
111
|
+
static void setDefaultAllocator( TidyBuffer* buf )
|
112
|
+
{
|
113
|
+
buf->allocator = &TY_(g_default_allocator);
|
114
|
+
}
|
115
|
+
|
116
|
+
/* Avoid thrashing memory by doubling buffer size
|
117
|
+
** until larger than requested size.
|
118
|
+
buf->allocated is bigger than allocSize+1 so that a trailing null byte is
|
119
|
+
always available.
|
120
|
+
*/
|
121
|
+
void TIDY_CALL tidyBufCheckAlloc( TidyBuffer* buf, uint allocSize, uint chunkSize )
|
122
|
+
{
|
123
|
+
assert( buf != NULL );
|
124
|
+
|
125
|
+
if ( !buf->allocator )
|
126
|
+
setDefaultAllocator( buf );
|
127
|
+
|
128
|
+
if ( 0 == chunkSize )
|
129
|
+
chunkSize = 256;
|
130
|
+
if ( allocSize+1 > buf->allocated )
|
131
|
+
{
|
132
|
+
byte* bp;
|
133
|
+
uint allocAmt = chunkSize;
|
134
|
+
if ( buf->allocated > 0 )
|
135
|
+
allocAmt = buf->allocated;
|
136
|
+
while ( allocAmt < allocSize+1 )
|
137
|
+
allocAmt *= 2;
|
138
|
+
|
139
|
+
bp = (byte*)TidyRealloc( buf->allocator, buf->bp, allocAmt );
|
140
|
+
if ( bp != NULL )
|
141
|
+
{
|
142
|
+
TidyClearMemory( bp + buf->allocated, allocAmt - buf->allocated );
|
143
|
+
buf->bp = bp;
|
144
|
+
buf->allocated = allocAmt;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
/* Attach buffer to a chunk O' memory w/out allocation */
|
150
|
+
void TIDY_CALL tidyBufAttach( TidyBuffer* buf, byte* bp, uint size )
|
151
|
+
{
|
152
|
+
assert( buf != NULL );
|
153
|
+
buf->bp = bp;
|
154
|
+
buf->size = buf->allocated = size;
|
155
|
+
buf->next = 0;
|
156
|
+
if ( !buf->allocator )
|
157
|
+
setDefaultAllocator( buf );
|
158
|
+
}
|
159
|
+
|
160
|
+
/* Clear pointer to memory w/out deallocation */
|
161
|
+
void TIDY_CALL tidyBufDetach( TidyBuffer* buf )
|
162
|
+
{
|
163
|
+
tidyBufInitWithAllocator( buf, buf->allocator );
|
164
|
+
}
|
165
|
+
|
166
|
+
|
167
|
+
/**************
|
168
|
+
OUTPUT
|
169
|
+
**************/
|
170
|
+
|
171
|
+
void TIDY_CALL tidyBufAppend( TidyBuffer* buf, void* vp, uint size )
|
172
|
+
{
|
173
|
+
assert( buf != NULL );
|
174
|
+
if ( vp != NULL && size > 0 )
|
175
|
+
{
|
176
|
+
tidyBufCheckAlloc( buf, buf->size + size, 0 );
|
177
|
+
memcpy( buf->bp + buf->size, vp, size );
|
178
|
+
buf->size += size;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
void TIDY_CALL tidyBufPutByte( TidyBuffer* buf, byte bv )
|
183
|
+
{
|
184
|
+
assert( buf != NULL );
|
185
|
+
tidyBufCheckAlloc( buf, buf->size + 1, 0 );
|
186
|
+
buf->bp[ buf->size++ ] = bv;
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
int TIDY_CALL tidyBufPopByte( TidyBuffer* buf )
|
191
|
+
{
|
192
|
+
int bv = EOF;
|
193
|
+
assert( buf != NULL );
|
194
|
+
if ( buf->size > 0 )
|
195
|
+
bv = buf->bp[ --buf->size ];
|
196
|
+
return bv;
|
197
|
+
}
|
198
|
+
|
199
|
+
/**************
|
200
|
+
INPUT
|
201
|
+
**************/
|
202
|
+
|
203
|
+
int TIDY_CALL tidyBufGetByte( TidyBuffer* buf )
|
204
|
+
{
|
205
|
+
int bv = EOF;
|
206
|
+
if ( ! tidyBufEndOfInput(buf) )
|
207
|
+
bv = buf->bp[ buf->next++ ];
|
208
|
+
return bv;
|
209
|
+
}
|
210
|
+
|
211
|
+
Bool TIDY_CALL tidyBufEndOfInput( TidyBuffer* buf )
|
212
|
+
{
|
213
|
+
return ( buf->next >= buf->size );
|
214
|
+
}
|
215
|
+
|
216
|
+
void TIDY_CALL tidyBufUngetByte( TidyBuffer* buf, byte bv )
|
217
|
+
{
|
218
|
+
if ( buf->next > 0 )
|
219
|
+
{
|
220
|
+
--buf->next;
|
221
|
+
assert( bv == buf->bp[ buf->next ] );
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
/*
|
226
|
+
* local variables:
|
227
|
+
* mode: c
|
228
|
+
* indent-tabs-mode: nil
|
229
|
+
* c-basic-offset: 4
|
230
|
+
* eval: (c-set-offset 'substatement-open 0)
|
231
|
+
* end:
|
232
|
+
*/
|