forked from Macroassembler-AS/asl-releases
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asminclist.c
120 lines (101 loc) · 2.53 KB
/
asminclist.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* asminclist.c */
/*****************************************************************************/
/* AS-Portierung */
/* */
/* Verwaltung der Include-Verschachtelungsliste */
/* */
/* Historie: 16. 5.1996 Grundsteinlegung */
/* */
/*****************************************************************************/
#include "stdinc.h"
#include <string.h>
#include "strutil.h"
#include "chunks.h"
#include "nls.h"
#include "nlmessages.h"
#include "as.rsc"
#include "asmfnums.h"
#include "asmdef.h"
#include "asmsub.h"
#include "asminclist.h"
typedef void **PFileArray;
typedef struct sFileNode
{
Integer Name;
Integer Len;
struct sFileNode *Parent;
PFileArray Subs;
} TFileNode, *PFileNode;
static PFileNode Root,Curr;
void PushInclude(char *S)
{
PFileNode Neu;
Neu = (PFileNode) malloc(sizeof(TFileNode));
Neu->Name = GetFileNum(S);
Neu->Len = 0;
Neu->Subs = NULL;
Neu->Parent = Curr;
if (!Root)
Root = Neu;
if (!Curr)
Curr = Neu;
else
{
if (Curr->Len == 0)
Curr->Subs = (PFileArray) malloc(sizeof(void *));
else
Curr->Subs = (PFileArray) realloc(Curr->Subs, sizeof(void *) * (Curr->Len + 1));
Curr->Subs[Curr->Len++] = (void *)Neu;
Curr = Neu;
}
}
void PopInclude(void)
{
if (Curr)
Curr = Curr->Parent;
}
static void PrintIncludeList_PrintNode(PFileNode Node, int Indent)
{
int z;
String h;
ChkStack();
if (Node)
{
strmaxcpy(h,Blanks(Indent), 255);
strmaxcat(h,GetFileName(Node->Name), 255);
WrLstLine(h);
for (z = 0; z < Node->Len; z++)
PrintIncludeList_PrintNode(Node->Subs[z], Indent + 5);
}
}
void PrintIncludeList(void)
{
NewPage(ChapDepth, True);
WrLstLine(getmessage(Num_ListIncludeListHead1));
WrLstLine(getmessage(Num_ListIncludeListHead2));
WrLstLine("");
PrintIncludeList_PrintNode(Root, 0);
}
static void ClearIncludeList_ClearNode(PFileNode Node)
{
int z;
ChkStack();
if (Node)
{
for (z = 0; z < Node->Len; ClearIncludeList_ClearNode(Node->Subs[z++]));
if (Node->Len > 0)
free(Node->Subs);
free(Node);
}
}
void ClearIncludeList(void)
{
ClearIncludeList_ClearNode(Root);
Curr = NULL;
Root = NULL;
}
void asminclist_init(void)
{
Root = NULL;
Curr = NULL;
}