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 |
/* $Id: bstack.c,v 1.1.1.1 1998/01/17 15:55:58 release Exp $ */
|
|
|
32 |
|
|
|
33 |
#ifndef lint
|
|
|
34 |
static char vcid[] = "$Id: bstack.c,v 1.1.1.1 1998/01/17 15:55:58 release Exp $";
|
|
|
35 |
#endif /* lint */
|
|
|
36 |
|
|
|
37 |
/*
|
|
|
38 |
$Log: bstack.c,v $
|
|
|
39 |
* Revision 1.1.1.1 1998/01/17 15:55:58 release
|
|
|
40 |
* First version to be checked into rolling release.
|
|
|
41 |
*
|
|
|
42 |
* Revision 1.2 1995/03/29 14:00:46 john
|
|
|
43 |
* Removed unneeded inclusion of malloc.h
|
|
|
44 |
*
|
|
|
45 |
* Revision 1.1.1.1 1995/03/23 10:39:09 john
|
|
|
46 |
* Entered into CVS
|
|
|
47 |
*
|
|
|
48 |
* Revision 1.3 1995/01/26 13:37:07 john
|
|
|
49 |
* Added missing declaration of free
|
|
|
50 |
*
|
|
|
51 |
* Revision 1.2 1995/01/12 15:15:53 john
|
|
|
52 |
* Added malloc.h header
|
|
|
53 |
*
|
|
|
54 |
*/
|
|
|
55 |
|
|
|
56 |
#include "config.h"
|
|
|
57 |
#include "xalloc.h"
|
|
|
58 |
#include "bstack.h"
|
|
|
59 |
|
|
|
60 |
void push
|
|
|
61 |
PROTO_N ( ( symval,strval,stack ) )
|
|
|
62 |
PROTO_T ( long symval X long strval X BSTACK *stack )
|
|
|
63 |
{
|
|
|
64 |
while (stack->nextspace!=0) {stack=stack->nextspace;}
|
|
|
65 |
if (stack->pos < STACKSIZE){
|
|
|
66 |
stack->symind[stack->pos]=symval;
|
|
|
67 |
stack->strind[stack->pos]=strval;
|
|
|
68 |
stack->pos+=1;
|
|
|
69 |
}
|
|
|
70 |
else{
|
|
|
71 |
stack->nextspace=(BSTACK*)xcalloc(1,sizeof(BSTACK));
|
|
|
72 |
stack->nextspace->symind[0]=symval;
|
|
|
73 |
stack->nextspace->strind[0]=strval;
|
|
|
74 |
stack->nextspace->pos=1;
|
|
|
75 |
}
|
|
|
76 |
return;
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
SYMSTR pop
|
|
|
81 |
PROTO_N ( ( stack ) )
|
|
|
82 |
PROTO_T ( BSTACK *stack )
|
|
|
83 |
{
|
|
|
84 |
SYMSTR retval;
|
|
|
85 |
BSTACK* oldstack=(BSTACK*)xcalloc(1,sizeof(BSTACK));
|
|
|
86 |
oldstack=stack;
|
|
|
87 |
while (stack->nextspace!=0){
|
|
|
88 |
oldstack=stack;
|
|
|
89 |
stack=stack->nextspace;
|
|
|
90 |
}
|
|
|
91 |
if (stack->pos==0){
|
|
|
92 |
stack=oldstack;
|
|
|
93 |
free(stack->nextspace);
|
|
|
94 |
retval.sym = stack->symind[STACKSIZE-1];
|
|
|
95 |
retval.str = stack->strind[STACKSIZE-1];
|
|
|
96 |
stack->nextspace = (BSTACK*)0;
|
|
|
97 |
stack->pos=STACKSIZE-1;
|
|
|
98 |
}
|
|
|
99 |
else{
|
|
|
100 |
retval.sym=stack->symind[stack->pos-1];
|
|
|
101 |
retval.str=stack->strind[stack->pos-1];
|
|
|
102 |
stack->pos-=1;
|
|
|
103 |
}
|
|
|
104 |
return retval;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|