DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T o

⟦d70281baf⟧ TextFile

    Length: 3623 (0xe27)
    Types: TextFile
    Names: »or_std2or.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« 
        └─⟦e5a54fb17⟧ 
            └─⟦this⟧ »pp-5.0/Lib/or/or_std2or.c« 

TextFile

/* or_std2or.c: convert standard or representation to tree */

# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Lib/or/RCS/or_std2or.c,v 5.0 90/09/20 16:08:46 pp Exp Locker: pp $";
# endif

/*
 * $Header: /cs/research/pp/hubris/pp-beta/Lib/or/RCS/or_std2or.c,v 5.0 90/09/20 16:08:46 pp Exp Locker: pp $
 *
 * $Log:	or_std2or.c,v $
 * Revision 5.0  90/09/20  16:08:46  pp
 * rcsforce : 5.0 public release
 * 
 */



#include "or.h"
#include "util.h"

extern char     or_error[];
/*
Input standard to form orname
*/

OR_ptr or_std2or (str)
char            *str;
{
    OR_ptr      tree,
		or;
    char        keybuf[LINESIZE],
		valbuf[LINESIZE],
		tbuf[LINESIZE],
		*p,
		*r;
    int         ortype,
		firstpn;

    PP_DBG (("or_util.c/or_std2or (%s)", str));

    if (str == NULLCP)
	return NULLOR;

    tree = NULLOR;

    if (str[0] == '/') {
	/*
	No implicit PN
	*/
	firstpn = FALSE;
	p = &str[1];
    }
    else {
	firstpn = TRUE;
	p = str;
    }

    for (; *p != '\0';) {
	r = keybuf;
	for (; *p != '\0';) {
		switch (*p) {
		case '=':
			if (firstpn) {
				sprintf(or_error, "Bad PN syntax '%s'", str);
				PP_LOG (LLOG_EXCEPTIONS,
				   ("or_util.c/or_std2or: Bad PN syntax '%s'",
				   str));
				return NULLOR;
			}
			p++;
			break;
		case '/':
			if (!firstpn) {
				PP_LOG (LLOG_EXCEPTIONS,
				   ("or_util.c/or_std2or: Bad AV Syntax '%s'",
				   str));
				sprintf(or_error, "Bad AV Syntax '%s'", str);
				or_free (tree);
				return NULLOR;
			}
			p++;
			break;
		case '$':
			p++;
		default:
			*r++ = *p++;
			continue;
		}
		break;
	}

	*r = '\0';

	if (firstpn) {
		tree = or_buildpn (keybuf);
		if (*p == '\0')
			return (tree);
		firstpn = FALSE;
		continue;
	}

	if (*p == '\0') {
		if (keybuf[0] == '\0')
			return (tree);
		sprintf(or_error, "Prematurely terminated OR '%s'", str);
		PP_LOG (LLOG_EXCEPTIONS,
		       ("or_util.c/or_std2or: Prematurely termianted OR '%s'",
		       str));
		or_free (tree);
		return NULLOR;
	}

	r = valbuf;

	for (; *p != '\0';) {
		switch (*p) {
		case '=':
			PP_LOG (LLOG_EXCEPTIONS,
				("or_util.c/or_std2or: Bad AV syntax '%s'",
				str));
			sprintf(or_error, "Bad AV syntax '%s'",str);
			or_free (tree);
			return NULLOR;
		case '/':
			break;
		case '$':
			p++;
		default:
			*r++ = *p++;
			continue;
		}
		break;
	}

	*r = '\0';

	if (*p++ != '/') {
		PP_LOG (LLOG_EXCEPTIONS,
		  ("or_util.c/or_std2or: Prematurely ended OR - no slash '%s'",
		  str));
		sprintf(or_error, "Prematurely ended OR - no slash '%s'", str);
		or_free (tree);
		return NULLOR;
	}

	PP_DBG ((
	       "or_util.c/or_std2or: Component '%s' = '%s'", keybuf, valbuf));

	/*
	Process string from BACK to  optimise or-add
	*/

	ortype = or_name2type (keybuf);

	if (ortype != NOTOK) {
		or = or_new (ortype, NULLCP, valbuf);
		if ((tree = or_add (tree, or, TRUE)) == NULLOR)
			return NULLOR;
		continue;
	}

	if (lexequ (keybuf, "pn") == 0) {
		tree = or_buildpn (valbuf);
		continue;
	}

	(void) strncpy (tbuf, keybuf, 3);
	tbuf[3] = '\0';

	if ((strlen (keybuf) > 2) && lexequ (tbuf, "dd.") == 0) {
		or = or_new (OR_DD, &keybuf[3], valbuf);
		if ((tree = or_add (tree, or, TRUE)) == NULLOR)
			return NULLOR;
		continue;
	}

	/*
	Might need new table if this becomes assymetrical
	*/

	if (or_ddvalid_chk (keybuf, &tbuf[0]) == OK) {
		or = or_new (OR_DD, tbuf, valbuf);
		if ((tree = or_add (tree, or, TRUE)) == NULLOR)
			return NULLOR;
		continue;
	}

	PP_LOG (LLOG_EXCEPTIONS,
		("or_util/or_std2or: Unknown Key '%s'", keybuf));
	sprintf(or_error, "Unknown Key '%s'", keybuf);
	or_free (tree);
	return NULLOR;
    }

    return tree;
}