Annotation of 43BSDTahoe/new/B/src/bed/node.h, revision 1.1.1.1

1.1       root        1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
                      2: /* $Header: node.h,v 2.4 85/08/22 16:05:40 timo Exp $ */
                      3: 
                      4: /*
                      5:  * B editor -- Parse tree and Focus stack.
                      6:  */
                      7: 
                      8: /*
                      9:  * Assertion macro.
                     10:  *
                     11:  * This one differs from the one in #include <assert.h> in that it
                     12:  * is usable as an expression operand, e.g. up(ep) || Assert(No).
                     13:  * The function asserr() must unconditionally terminate the program.
                     14:  * If the accumulated __FILE__ data wastes too much of your data
                     15:  * space, omit them and change the code in asserr() that uses them.
                     16:  * You better trust your code then, because unless compiled with "-g"
                     17:  * it's difficult to dig the line number information from the core dump.
                     18:  *
                     19:  * There is also a variant called Abort() which is equivalent to Assert(No).
                     20:  */
                     21: 
                     22: #ifdef NDEBUG
                     23: #define Abort() abort() /* Always fail */
                     24: #define Assert(cond) 0 /* Dummy expression */
                     25: #else NDEBUG
                     26: #undef __FILE__
                     27: #define __FILE__ rcsid
                     28: #ifndef __LINE__
                     29: #define __LINE__ 0
                     30: #endif __LINE__
                     31: #define Abort() asserr(__FILE__, __LINE__)
                     32: #define Assert(cond) ((cond) || Abort())
                     33: #endif NDEBUG
                     34: 
                     35: typedef struct node *node;
                     36: typedef struct path *path;
                     37: typedef int markbits;
                     38: 
                     39: struct node {
                     40:        char    type;
                     41:        char    _unused;
                     42:        intlet  refcnt;
                     43:        intlet  len;
                     44:        markbits        n_marks;
                     45:        intlet  n_width;
                     46:        intlet  n_symbol;
                     47:        node    n_child[1];
                     48: };
                     49: 
                     50: struct path {
                     51:        char    type;
                     52:        char    _unused;
                     53:        intlet  refcnt;
                     54:        intlet  len;
                     55:        path    p_parent;
                     56:        node    p_tree;
                     57:        intlet  p_ichild;
                     58:        intlet  p_ycoord;
                     59:        intlet  p_xcoord;
                     60:        intlet  p_level;
                     61:        markbits        p_addmarks;
                     62:        markbits        p_delmarks;
                     63: };
                     64: 
                     65: 
                     66: #define Nnil ((node) NULL)
                     67: 
                     68: node newnode();
                     69: 
                     70: #ifndef NDEBUG
                     71: #define symbol(n) (Assert(Type(n)==Nod), (n)->n_symbol)
                     72: #define nchildren(n) (Assert(Type(n)==Nod), Length(n))
                     73: #define marks(n) (Assert(Type(n)==Nod), (n)->n_marks)
                     74: #define child(n, i) \
                     75:        (Assert(Type(n)==Nod && (i)>0 && (i)<=Length(n)), (n)->n_child[(i)-1])
                     76: #define lastchild(n) \
                     77:        (Assert(Type(n)==Nod && Length(n)>0), (n)->n_child[Length(n)-1])
                     78: #define firstchild(n) \
                     79:        (Assert(Type(n)==Nod && Length(n)>0), (n)->n_child[0])
                     80: #else NDEBUG
                     81: #define symbol(n) ((n)->n_symbol)
                     82: #define nchildren(n) (Length(n))
                     83: #define marks(n) ((n)->n_marks)
                     84: #define child(n, i) ((n)->n_child[(i)-1])
                     85: #define lastchild(n) ((n)->n_child[Length(n)-1])
                     86: #define firstchild(n) ((n)->n_child[0])
                     87: #endif NDEBUG
                     88: 
                     89: #define width(n) (Type(n)==Tex ? Length((value)(n)) : (n)->n_width)
                     90: #define marked(p, x) (marks(tree(p))&(x))
                     91: 
                     92: #define Pnil ((path) NULL)
                     93: 
                     94: path newpath();
                     95: 
                     96: #define parent(p) ((p)->p_parent)
                     97: #define tree(p) ((p)->p_tree)
                     98: #define ichild(p) ((p)->p_ichild)
                     99: 
                    100: #define Ycoord(p) ((p)->p_ycoord)
                    101: #define Xcoord(p) ((p)->p_xcoord)
                    102: #define Level(p) ((p)->p_level)
                    103: 
                    104: /* Procedure markpath(); */
                    105: /* Procedure unmkpath(); */
                    106: /* Procedure replace(); */
                    107: bool up();
                    108: bool downi();
                    109: 
                    110: #define down(n) downi(n, 1)
                    111: 
                    112: bool downrite();
                    113: bool left();
                    114: bool rite();
                    115: /* Procedure top(); */
                    116: bool nextnode();
                    117: /* Procedure firstleaf(); */
                    118: bool nextleaf();
                    119: bool prevnode();
                    120: /* Procedure lastleaf(); */
                    121: bool prevleaf();
                    122: bool nextmarked();
                    123: bool prevmarked();
                    124: 
                    125: /*
                    126:  * The following are routines for lint, but macros for CC.
                    127:  * This way lint can detect wrong arguments passed.
                    128:  */
                    129: 
                    130: #ifdef lint
                    131: 
                    132: node nodecopy();
                    133: noderelease();
                    134: nodeuniql();
                    135: 
                    136: path pathcopy();
                    137: pathrelease();
                    138: pathuniql();
                    139: 
                    140: #else
                    141: 
                    142: #define nodecopy(n) ((node)copy(n))
                    143: #define noderelease(n) release(n)
                    144: #define nodeuniql(pn) uniql(pn)
                    145: 
                    146: #define pathcopy(p) ((path)copy(p))
                    147: #define pathrelease(p) release(p)
                    148: #define pathuniql(pp) uniql(pp)
                    149: 
                    150: #endif
                    151: 
                    152: node grab_node();
                    153: path grab_path();

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.