/** * 12.2.4.41 */ static int h5_state_after_attribute_value_quoted_state(h5_state_t* hs) { char ch; TRACE(); if (hs->pos >= hs->len) { return 0; } ch = hs->s[hs->pos]; if (h5_is_white(ch)) { hs->pos += 1; return h5_state_before_attribute_name(hs); } else if (ch == CHAR_SLASH) { hs->pos += 1; return h5_state_self_closing_start_tag(hs); } else if (ch == CHAR_GT) { hs->token_start = hs->s + hs->pos; hs->token_len = 1; hs->token_type = TAG_NAME_CLOSE; hs->pos += 1; hs->state = h5_state_data; return 1; } else { return h5_state_before_attribute_name(hs); } }
static int h5_state_attribute_value_no_quote(h5_state_t* hs) { char ch; size_t pos; TRACE(); pos = hs->pos; while (pos < hs->len) { ch = hs->s[pos]; if (h5_is_white(ch)) { hs->token_type = ATTR_VALUE; hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; hs->pos = pos + 1; hs->state = h5_state_before_attribute_name; return 1; } else if (ch == CHAR_GT) { hs->token_type = ATTR_VALUE; hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; hs->pos = pos; hs->state = h5_state_tag_name_close; return 1; } pos += 1; } TRACE(); /* EOF */ hs->state = h5_state_eof; hs->token_start = hs->s + hs->pos; hs->token_len = hs->len - hs->pos; hs->token_type = ATTR_VALUE; return 1; }
/** * 12.2.4.10 */ static int h5_state_tag_name(h5_state_t* hs) { char ch; size_t pos; TRACE(); pos = hs->pos; while (pos < hs->len) { ch = hs->s[pos]; if (ch == 0) { /* special non-standard case */ /* allow nulls in tag name */ /* some old browsers apparently allow and ignore them */ pos += 1; } else if (h5_is_white(ch)) { hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; hs->token_type = TAG_NAME_OPEN; hs->pos = pos + 1; hs->state = h5_state_before_attribute_name; return 1; } else if (ch == CHAR_SLASH) { hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; hs->token_type = TAG_NAME_OPEN; hs->pos = pos + 1; hs->state = h5_state_self_closing_start_tag; return 1; } else if (ch == CHAR_GT) { hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; if (hs->is_close) { hs->pos = pos + 1; hs->is_close = 0; hs->token_type = TAG_CLOSE; hs->state = h5_state_data; } else { hs->pos = pos; hs->token_type = TAG_NAME_OPEN; hs->state = h5_state_tag_name_close; } return 1; } else { pos += 1; } } hs->token_start = hs->s + hs->pos; hs->token_len = hs->len - hs->pos; hs->token_type = TAG_NAME_OPEN; hs->state = h5_state_eof; return 1; }
static int h5_state_attribute_name(h5_state_t* hs) { char ch; size_t pos; TRACE(); pos = hs->pos + 1; while (pos < hs->len) { ch = hs->s[pos]; if (h5_is_white(ch)) { hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; hs->token_type = ATTR_NAME; hs->state = h5_state_after_attribute_name; hs->pos = pos + 1; return 1; } else if (ch == CHAR_SLASH) { hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; hs->token_type = ATTR_NAME; hs->state = h5_state_self_closing_start_tag; hs->pos = pos + 1; return 1; } else if (ch == CHAR_EQUALS) { hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; hs->token_type = ATTR_NAME; hs->state = h5_state_before_attribute_value; hs->pos = pos + 1; return 1; } else if (ch == CHAR_GT) { hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; hs->token_type = ATTR_NAME; hs->state = h5_state_tag_name_close; hs->pos = pos; return 1; } else { pos += 1; } } /* EOF */ hs->token_start = hs->s + hs->pos; hs->token_len = hs->len - hs->pos; hs->token_type = ATTR_NAME; hs->state = h5_state_eof; hs->pos = hs->len; return 1; }
/** * 12.2.4.10 */ static int h5_state_tag_name(h5_state_t* hs) { char ch; size_t pos; TRACE(); pos = hs->pos; while (pos < hs->len) { ch = hs->s[pos]; if (h5_is_white(ch)) { hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; hs->token_type = TAG_NAME_OPEN; hs->pos = pos + 1; hs->state = h5_state_before_attribute_name; return 1; } else if (ch == CHAR_SLASH) { hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; hs->token_type = TAG_NAME_OPEN; hs->pos = pos + 1; hs->state = h5_state_self_closing_start_tag; return 1; } else if (ch == CHAR_GT) { hs->token_start = hs->s + hs->pos; hs->token_len = pos - hs->pos; if (hs->is_close) { hs->pos = pos + 1; hs->is_close = 0; hs->token_type = TAG_CLOSE; hs->state = h5_state_data; } else { hs->pos = pos; hs->token_type = TAG_NAME_OPEN; hs->state = h5_state_tag_name_close; } return 1; } else { pos += 1; } } hs->token_start = hs->s + hs->pos; hs->token_len = hs->len - hs->pos; hs->token_type = TAG_NAME_OPEN; hs->state = h5_state_eof; return 1; }