1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1986-2009 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
19 ***********************************************************************/
25 * preprocessor context switch
28 * (0,0) free current context 0
29 * (0,1) save current context current
30 * (p,0) free context p 0
31 * (p,1) make p current context previous
37 ppcontext(void* context
, int flags
)
39 struct ppcontext
* np
= (struct ppcontext
*)context
;
44 if (!(op
= pp
.context
)) op
= pp
.context
= newof(0, struct ppcontext
, 1, 0);
45 memcpy(op
, _PP_CONTEXT_BASE_
, sizeof(struct ppcontext
));
49 if (!(op
= np
)) op
= (struct ppcontext
*)_PP_CONTEXT_BASE_
;
50 if (op
->filtab
) hashfree(op
->filtab
);
51 if (op
->prdtab
) hashfree(op
->prdtab
);
52 if (op
->symtab
) hashfree(op
->symtab
);
53 if (op
->date
) free(op
->date
);
54 if (op
->time
) free(op
->time
);
60 memzero(op
, sizeof(struct ppcontext
));
63 if (np
) memcpy(_PP_CONTEXT_BASE_
, np
, sizeof(struct ppcontext
));