[BACK]Return to rules.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / docbook2mdoc

File: [cvsweb.bsd.lv] / docbook2mdoc / Attic / rules.c (download)

Revision 1.26, Fri Mar 22 15:38:09 2019 UTC (5 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.25: +0 -1331 lines

Delete the isparent() validation function.

The DocBook language is totally ill-designed, a gigantic accretion
of arbitrary elements without any kind of discernible design or
cohesion, with an absurdly large number of arbitrary and pointless
rules of what is allowed to nest inside which other elements.
So attempting to validate DocBook input against the totally crazy
specification makes no sense whatsoever, and even less so because
we are certainly not encouraging anybody to write new or maintain
existing DocBook documents.  The whole point of having a DocBook
parser is to be able to parse legacy documents and convert them to
a sane language, so it is utterly irrelevant whether the input is
considered valid or invalid by some idiotic standard.

This deletion allows substantial simplification of the code
and will massively speed up development in the future.

Kristaps@ says that i can move forward with development without
asking for individual OKs.

#include <stdlib.h>

#include "extern.h"

int
isattrkey(enum nodeid node, enum attrkey key)
{

	switch (key) {
	case (ATTRKEY_CHOICE):
		switch (node) {
		case (NODE_ARG):
		case (NODE_GROUP):
			return(1);
		default:
			break;
		}
		return(0);
	case (ATTRKEY_OPEN):
	case (ATTRKEY_CLOSE):
		return(node == NODE_MML_MFENCED);
	case (ATTRKEY_ID):
		/* Common to all. */
		return(1);
	case (ATTRKEY_REP):
		switch (node) {
		case (NODE_ARG):
		case (NODE_GROUP):
			return(1);
		default:
			break;
		}
		return(0);
	default:
		break;
	}
	abort();
	return(0);
}

int
isattrval(enum attrkey key, enum attrval val)
{

	switch (val) {
	case (ATTRVAL_OPT):
	case (ATTRVAL_PLAIN):
	case (ATTRVAL_REQ):
		return(key == ATTRKEY_CHOICE);
	case (ATTRVAL_REPEAT):
	case (ATTRVAL_NOREPEAT):
		return(key == ATTRKEY_REP);
	default:
		break;
	}
	abort();
	return(0);
}