Ejemplo n.º 1
0
// Switch to new zone ("!zone" or "!zn"). Has to be re-entrant.
static enum eos_t PO_zone(void) {
	section_t	entry_values;// buffer for outer zone
	char*		new_title;
	bool		allocated;

	// remember everything about current structure
	entry_values = *Section_now;
	// set default values in case there is no valid title
	new_title = untitled;
	allocated = FALSE;
	// Check whether a zone title is given. If yes and it can be read,
	// get copy, remember pointer and remember to free it later on.
	if(BYTEFLAGS(GotByte) & CONTS_KEYWORD) {
		// Because we know of one character for sure,
		// there's no need to check the return value.
		Input_read_keyword();
		new_title = DynaBuf_get_copy(GlobalDynaBuf);
		allocated = TRUE;
	}
	// setup new section
	// section type is "subzone", just in case a block follows
	Section_new_zone(Section_now, "Subzone", new_title, allocated);
	if(Parse_optional_block()) {
		// Block has been parsed, so it was a SUBzone.
		Section_finalize(Section_now);// end inner zone
		*Section_now = entry_values;// restore entry values
	} else {
		// no block found, so it's a normal zone change
		Section_finalize(&entry_values);// end outer zone
		Section_now->type = type_zone;// change type to "zone"
	}
	return(ENSURE_EOS);
}
Ejemplo n.º 2
0
// Check whether GotByte is a dot.
// If not, store global zone value.
// If yes, store current zone value and read next byte.
// Then jump to Input_read_keyword(), which returns length of keyword.
int Input_read_zone_and_keyword(zone_t *zone) {
	SKIPSPACE();
	if(GotByte == '.') {
		GetByte();
		*zone = Section_now->zone;
	} else
		*zone = ZONE_GLOBAL;
	return(Input_read_keyword());
}