blob: 1c8edcf9c4efecdd9edfc8608f7205a0a4147bf8 (
plain)
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
|
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (!0)
#endif
typedef struct scrap_node {
struct scrap_node *next;
int scrap;
} Scrap_Node;
typedef struct name {
char *spelling;
struct name *llink;
struct name *rlink;
Scrap_Node *defs;
Scrap_Node *uses;
int mark;
char tab_flag;
char indent_flag;
char debug_flag;
} Name;
int tex_flag; /* if FALSE, don't emit the .tex file */
int output_flag; /* if FALSE, don't emit the output files */
int compare_flag; /* if FALSE, overwrite without comparison */
char *command_name;
char *source_name; /* name of the current file */
int source_line; /* current line in the source file */
Name *file_names;
Name *macro_names;
Name *user_names;
void pass1();
void write_tex();
void write_files();
void source_open(); /* pass in the name of the source file */
int source_get(); /* no args; returns the next char or EOF */
void init_scraps();
int collect_scrap();
int write_scraps();
Name *collect_file_name();
Name *collect_macro_name();
Name *collect_scrap_name();
Name *name_add();
Name *prefix_add();
char *save_string();
void reverse_lists();
void *arena_getmem();
void arena_free();
void pass1(file_name)
char *file_name;
{
source_open(file_name);
init_scraps();
macro_names = NULL;
file_names = NULL;
user_names = NULL;
{
int c = source_get();
while (c != EOF) {
if (c == '@')
{
c = source_get();
switch (c) {
case 'O':
case 'o': {
Name *name = collect_file_name(); /* returns a pointer to the name entry */
int scrap = collect_scrap(); /* returns an index to the scrap */
{
Scrap_Node *def = (Scrap_Node *) arena_getmem(sizeof(Scrap_Node));
def->scrap = scrap;
def->next = name->defs;
name->defs = def;
}
}
break;
case 'D':
case 'd': {
Name *name = collect_macro_name();
int scrap = collect_scrap();
{
Scrap_Node *def = (Scrap_Node *) arena_getmem(sizeof(Scrap_Node));
def->scrap = scrap;
def->next = name->defs;
name->defs = def;
}
}
break;
case '@':
case 'u':
case 'm':
case 'f': /* ignore during this pass */
break;
default: fprintf(stderr,
"%s: unexpected @ sequence ignored (%s, line %d)\n",
command_name, source_name, source_line);
break;
}
}
c = source_get();
}
}
if (tex_flag)
search();
{
reverse_lists(file_names);
reverse_lists(macro_names);
reverse_lists(user_names);
}
}
|