src/tokeniser/tokeniser.c
hubbub_error hubbub_tokeniser_handle_tag_name(hubbub_tokeniser *tokeniser)
{
	hubbub_tag *ctag = &tokeniser->context.current_tag;

	size_t len;
	const uint8_t *cptr;
	parserutils_error error;
	uint8_t c;

	assert(tokeniser->context.pending > 0);
/*	assert(tokeniser->context.chars.ptr[0] == '<'); */
	assert(ctag->name.len > 0);
/*	assert(ctag->name.ptr); */

	error = parserutils_inputstream_peek(tokeniser->input, 
			tokeniser->context.pending, &cptr, &len);

	if (error != PARSERUTILS_OK) {
		if (error == PARSERUTILS_EOF) {
			tokeniser->state = STATE_DATA;
			return emit_current_tag(tokeniser);
		} else {
			return hubbub_error_from_parserutils_error(error);
		}
	}

	c = *cptr;

	if (c == '\t' || c == '\n' || c == '\f' || c == ' ' || c == '\r') {
		tokeniser->context.pending += len;
		tokeniser->state = STATE_BEFORE_ATTRIBUTE_NAME;
	} else if (c == '>') {
		tokeniser->context.pending += len;
		tokeniser->state = STATE_DATA;
		return emit_current_tag(tokeniser);
	} else if (c == '\0') {
		COLLECT(ctag->name, u_fffd, sizeof(u_fffd));
		tokeniser->context.pending += len;
	} else if (c == '/') {
		tokeniser->context.pending += len;
		tokeniser->state = STATE_SELF_CLOSING_START_TAG;
	} else if ('A' <= c && c <= 'Z') {
		uint8_t lc = (c + 0x20);
		COLLECT(ctag->name, &lc, len);
		tokeniser->context.pending += len;
	} else {
		COLLECT(ctag->name, cptr, len);
		tokeniser->context.pending += len;
	}

	return HUBBUB_OK;
}
/* this state expects tokeniser->context.current_tag to already have its
   first character set */
this state expects tokeniser->context.current_tag to already have its
first character set
this state expects tokeniser - > context . current_tag to already have its first character set
hubbub_error hubbub_tokeniser_handle_tag_name(hubbub_tokeniser *tokeniser)
{
	hubbub_tag *ctag = &tokeniser->context.current_tag;
	size_t len;
	const uint8_t *cptr;
	parserutils_error error;
	uint8_t c;
	assert(tokeniser->context.pending > 0);
	assert(ctag->name.len > 0);
	error = parserutils_inputstream_peek(tokeniser->input, 
			tokeniser->context.pending, &cptr, &len);
	if (error != PARSERUTILS_OK) {
		if (error == PARSERUTILS_EOF) {
			tokeniser->state = STATE_DATA;
			return emit_current_tag(tokeniser);
		} else {
			return hubbub_error_from_parserutils_error(error);
		}
	}
	c = *cptr;
	if (c == '\t' || c == '\n' || c == '\f' || c == ' ' || c == '\r') {
		tokeniser->context.pending += len;
		tokeniser->state = STATE_BEFORE_ATTRIBUTE_NAME;
	} else if (c == '>') {
		tokeniser->context.pending += len;
		tokeniser->state = STATE_DATA;
		return emit_current_tag(tokeniser);
	} else if (c == '\0') {
		COLLECT(ctag->name, u_fffd, sizeof(u_fffd));
		tokeniser->context.pending += len;
	} else if (c == '/') {
		tokeniser->context.pending += len;
		tokeniser->state = STATE_SELF_CLOSING_START_TAG;
	} else if ('A' <= c && c <= 'Z') {
		uint8_t lc = (c + 0x20);
		COLLECT(ctag->name, &lc, len);
		tokeniser->context.pending += len;
	} else {
		COLLECT(ctag->name, cptr, len);
		tokeniser->context.pending += len;
	}
	return HUBBUB_OK;
}
hubbub_error hubbub_tokeniser_handle_tag_name ( hubbub_tokeniser * tokeniser ) { hubbub_tag * ctag = & tokeniser -> context . current_tag ; size_t len ; const uint8_t * cptr ; parserutils_error error ; uint8_t c ; assert ( tokeniser -> context . pending > 0 ) ; assert ( ctag -> name . len > 0 ) ; error = parserutils_inputstream_peek ( tokeniser -> input , tokeniser -> context . pending , & cptr , & len ) ; if ( error != PARSERUTILS_OK ) { if ( error == PARSERUTILS_EOF ) { tokeniser -> state = STATE_DATA ; return emit_current_tag ( tokeniser ) ; } else { return hubbub_error_from_parserutils_error ( error ) ; } } c = * cptr ; if ( c == ' \t ' || c == ' \n ' || c == ' \f ' || c == ' ' || c == ' \r ' ) { tokeniser -> context . pending += len ; tokeniser -> state = STATE_BEFORE_ATTRIBUTE_NAME ; } else if ( c == ' ' ) { tokeniser -> context . pending += len ; tokeniser -> state = STATE_DATA ; return emit_current_tag ( tokeniser ) ; } else if ( c == ' \0 ' ) { COLLECT ( ctag -> name , u_fffd , sizeof ( u_fffd ) ) ; tokeniser -> context . pending += len ; } else if ( c == ' ' ) { tokeniser -> context . pending += len ; tokeniser -> state = STATE_SELF_CLOSING_START_TAG ; } else if ( ' ' <= c && c <= ' ' ) { uint8_t lc = ( c + 0x20 ) ; COLLECT ( ctag -> name , & lc , len ) ; tokeniser -> context . pending += len ; } else { COLLECT ( ctag -> name , cptr , len ) ; tokeniser -> context . pending += len ; } return HUBBUB_OK ; }
this state expects tokeniser->context.current_tag to already have its
first character set
this state expects tokeniser - > context . current_tag to already have its first character set
/*	assert(tokeniser->context.chars.ptr[0] == '<'); */ /*	assert(ctag->name.ptr); */