2 |
7u83 |
1 |
/*
|
|
|
2 |
Crown Copyright (c) 1997
|
|
|
3 |
|
|
|
4 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
5 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
6 |
acting through the Defence Evaluation and Research Agency
|
|
|
7 |
(DERA). It is made available to Recipients with a
|
|
|
8 |
royalty-free licence for its use, reproduction, transfer
|
|
|
9 |
to other parties and amendment for any purpose not excluding
|
|
|
10 |
product development provided that any such use et cetera
|
|
|
11 |
shall be deemed to be acceptance of the following conditions:-
|
|
|
12 |
|
|
|
13 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
14 |
reproduced upon any copies or amended versions of it;
|
|
|
15 |
|
|
|
16 |
(2) Any amended version of it shall be clearly marked to
|
|
|
17 |
show both the nature of and the organisation responsible
|
|
|
18 |
for the relevant amendment or amendments;
|
|
|
19 |
|
|
|
20 |
(3) Its onward transfer from a recipient to another
|
|
|
21 |
party shall be deemed to be that party's acceptance of
|
|
|
22 |
these conditions;
|
|
|
23 |
|
|
|
24 |
(4) DERA gives no warranty or assurance as to its
|
|
|
25 |
quality or suitability for any purpose and DERA accepts
|
|
|
26 |
no liability whatsoever in relation to any use to which
|
|
|
27 |
it may be put.
|
|
|
28 |
*/
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
/**********************************************************************
|
|
|
32 |
$Author: release $
|
|
|
33 |
$Date: 1998/01/17 15:56:05 $
|
|
|
34 |
$Revision: 1.1.1.1 $
|
|
|
35 |
$Log: bstack.c,v $
|
|
|
36 |
* Revision 1.1.1.1 1998/01/17 15:56:05 release
|
|
|
37 |
* First version to be checked into rolling release.
|
|
|
38 |
*
|
|
|
39 |
* Revision 1.2 1995/09/12 10:59:13 currie
|
|
|
40 |
* gcc pedanttry
|
|
|
41 |
*
|
|
|
42 |
* Revision 1.1 1995/04/13 09:08:06 currie
|
|
|
43 |
* Initial revision
|
|
|
44 |
*
|
|
|
45 |
***********************************************************************/
|
|
|
46 |
#include "config.h"
|
|
|
47 |
#include "xalloc.h"
|
|
|
48 |
#include "bstack.h"
|
|
|
49 |
|
|
|
50 |
void push
|
|
|
51 |
PROTO_N ( (symval, strval, stack) )
|
|
|
52 |
PROTO_T ( long symval X long strval X BSTACK *stack )
|
|
|
53 |
{
|
|
|
54 |
while (stack->nextspace!=0) {stack=stack->nextspace;}
|
|
|
55 |
if (stack->pos < STACKSIZE)
|
|
|
56 |
{stack->symind[stack->pos]=symval;
|
|
|
57 |
stack->strind[stack->pos]=strval;
|
|
|
58 |
stack->pos+=1;
|
|
|
59 |
}
|
|
|
60 |
else
|
|
|
61 |
{stack->nextspace=(BSTACK*)xcalloc(1,sizeof(BSTACK));
|
|
|
62 |
stack->nextspace->symind[0]=symval;
|
|
|
63 |
stack->nextspace->strind[0]=strval;
|
|
|
64 |
stack->nextspace->pos=1;
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
SYMSTR pop
|
|
|
70 |
PROTO_N ( (stack) )
|
|
|
71 |
PROTO_T ( BSTACK *stack )
|
|
|
72 |
{
|
|
|
73 |
SYMSTR retval;
|
|
|
74 |
BSTACK* oldstack=(BSTACK*)xcalloc(1,sizeof(BSTACK));
|
|
|
75 |
oldstack=stack;
|
|
|
76 |
while (stack->nextspace!=0)
|
|
|
77 |
{oldstack=stack;
|
|
|
78 |
stack=stack->nextspace;}
|
|
|
79 |
if (stack->pos==0)
|
|
|
80 |
{stack=oldstack;
|
|
|
81 |
xfree(stack->nextspace);
|
|
|
82 |
retval.sym = stack->symind[STACKSIZE-1];
|
|
|
83 |
retval.str = stack->strind[STACKSIZE-1];
|
|
|
84 |
stack->nextspace = (BSTACK*)0;
|
|
|
85 |
stack->pos=STACKSIZE-1;
|
|
|
86 |
}
|
|
|
87 |
else {retval.sym=stack->symind[stack->pos-1];
|
|
|
88 |
retval.str=stack->strind[stack->pos-1];
|
|
|
89 |
stack->pos-=1;
|
|
|
90 |
}
|
|
|
91 |
return retval;
|
|
|
92 |
}
|