[cvs-annodex] commit (/annodex):
libannodex/trunk/src/libannodex/xtag.c
conrad
nobody at lists.annodex.net
Tue Feb 1 11:35:18 EST 2005
Update of /annodex (new revision 800)
Modified files:
libannodex/trunk/src/libannodex/xtag.c
Log Message:
add support for skipping processing directives and declarations (ticket: 1)
Modified: libannodex/trunk/src/libannodex/xtag.c
===================================================================
--- libannodex/trunk/src/libannodex/xtag.c 2005-02-01 00:00:45 UTC (rev 799)
+++ libannodex/trunk/src/libannodex/xtag.c 2005-02-01 00:35:16 UTC (rev 800)
@@ -106,6 +106,7 @@
#define X_EQUAL 1<<5
#define X_SLASH 1<<6
#define X_DASH 1<<7
+#define X_QUESTION 1<<8
static int
xtag_cin (char c, int char_class)
@@ -134,6 +135,9 @@
if (char_class & X_DASH)
if (c == '-') return TRUE;
+ if (char_class & X_QUESTION)
+ if (c == '?') return TRUE;
+
return FALSE;
}
@@ -193,6 +197,9 @@
parser->start = &s[i];
return TRUE;
}
+#ifdef DEBUG
+ else printf ("xtag: skipping '%c'\n", s[i]);
+#endif
}
return FALSE;
@@ -379,17 +386,45 @@
printf ("<%s ...\n", name);
#endif
- if (!strcmp (name, "!--")) {
+ /* Skip processing directives */
+ if (name[0] == '?') {
#ifdef DEBUG
- printf ("xtag: found comment\n");
+ printf ("xtag: processing directive\n");
#endif
- while (xtag_skip_to (parser, X_DASH)) {
+ while (parser->start < parser->end &&
+ xtag_skip_to (parser, X_QUESTION)) {
+ if (xtag_check_and_pass (parser, X_QUESTION) &&
+ xtag_check_and_pass (parser, X_CLOSETAG))
+ return xtag_parse_tag (parser);
+ }
+ /* Unterminated processing directive */
+ return NULL;
+
+ } else if (!strcmp (name, "!--")) {
+#ifdef DEBUG
+ printf ("xtag: comment\n");
+#endif
+ while (parser->start < parser->end &&
+ xtag_skip_to (parser, X_DASH)) {
if (xtag_check_and_pass (parser, X_DASH) &&
+ xtag_check_and_pass (parser, X_DASH) &&
xtag_check_and_pass (parser, X_CLOSETAG))
return xtag_parse_tag (parser);
}
/* Unterminated comment */
return NULL;
+
+ } else if (name[0] == '!') {
+#ifdef DEBUG
+ printf ("xtag: non-comment declaration\n");
+#endif
+ while (parser->start < parser->end &&
+ xtag_skip_to (parser, X_CLOSETAG)) {
+ if (xtag_check_and_pass (parser, X_CLOSETAG))
+ return xtag_parse_tag (parser);
+ }
+ /* Unterminated declaration */
+ return NULL;
}
tag = anx_malloc (sizeof (*tag));
--
conrad
More information about the cvs-annodex
mailing list