Give all functions a formal prototype.
This makes the code C89 compliant, and removes all warnings on macOS.
This commit is contained in:
293
nuweb.w
293
nuweb.w
@@ -954,9 +954,7 @@ then handles any files listed on the command line.
|
|||||||
@o main.c -cc -d
|
@o main.c -cc -d
|
||||||
@{
|
@{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
int main(argc, argv)
|
int main(int argc, char** argv)
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
int arg = 1;
|
int arg = 1;
|
||||||
@<Interpret command-line arguments@>
|
@<Interpret command-line arguments@>
|
||||||
@@ -1399,7 +1397,7 @@ During the first pass, we scan the file, recording the definitions of
|
|||||||
each fragment and file and accumulating all the scraps.
|
each fragment and file and accumulating all the scraps.
|
||||||
|
|
||||||
@d Function pro...
|
@d Function pro...
|
||||||
@{extern void pass1();
|
@{extern void pass1(char *file_name);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
|
|
||||||
@@ -1413,8 +1411,7 @@ our data structures. Next, we seach all the scraps for references to
|
|||||||
the user-specified index entries. Finally, we must reverse all the
|
the user-specified index entries. Finally, we must reverse all the
|
||||||
cross-reference lists accumulated while scanning the scraps.
|
cross-reference lists accumulated while scanning the scraps.
|
||||||
@o pass1.c -cc -d
|
@o pass1.c -cc -d
|
||||||
@{void pass1(file_name)
|
@{void pass1(char *file_name)
|
||||||
char *file_name;
|
|
||||||
{
|
{
|
||||||
if (verbose_flag)
|
if (verbose_flag)
|
||||||
fprintf(stderr, "reading %s\n", file_name);
|
fprintf(stderr, "reading %s\n", file_name);
|
||||||
@@ -2034,30 +2031,33 @@ modify nuweb to work with a different typesetting system, this would
|
|||||||
be the place to look.
|
be the place to look.
|
||||||
|
|
||||||
@d Function...
|
@d Function...
|
||||||
@{extern void write_tex();
|
@{extern void write_tex(char *file_name, char *tex_name);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
We need a few local function declarations before we get into the body
|
We need a few local function declarations before we get into the body
|
||||||
of \verb|write_tex|.
|
of \verb|write_tex|.
|
||||||
|
|
||||||
@o latex.c -cc -d
|
@o latex.c -cc -d
|
||||||
@{static void copy_scrap(); /* formats the body of a scrap */
|
@{static void copy_scrap(FILE *file, int prefix, Name *name);
|
||||||
static void print_scrap_numbers(); /* formats a list of scrap numbers */
|
/* formats the body of a scrap */
|
||||||
static void format_entry(); /* formats an index entry */
|
static void print_scrap_numbers(FILE *tex_file, Scrap_Node *scraps);
|
||||||
static void format_file_entry(); /* formats a file index entry */
|
/* formats a list of scrap numbers */
|
||||||
static void format_user_entry();
|
static void format_entry(Name *name, FILE *tex_file, unsigned char sector);
|
||||||
static void write_arg();
|
/* formats an index entry */
|
||||||
static void write_literal();
|
static void format_file_entry(Name *name, FILE *tex_file);
|
||||||
static void write_ArglistElement();
|
/* formats a file index entry */
|
||||||
|
static void format_user_entry(Name *name, FILE *tex_file,
|
||||||
|
unsigned char sector);
|
||||||
|
static void write_arg(FILE *tex_file, char *p);
|
||||||
|
static void write_literal(FILE *tex_file, char *p, int mode);
|
||||||
|
static void write_ArglistElement(FILE *file, Arglist *args, char **params);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
|
|
||||||
The routine \verb|write_tex| takes two file names as parameters: the
|
The routine \verb|write_tex| takes two file names as parameters: the
|
||||||
name of the web source file and the name of the \verb|.tex| output file.
|
name of the web source file and the name of the \verb|.tex| output file.
|
||||||
@o latex.c -cc -d
|
@o latex.c -cc -d
|
||||||
@{void write_tex(file_name, tex_name)
|
@{void write_tex(char *file_name, char *tex_name)
|
||||||
char *file_name;
|
|
||||||
char *tex_name;
|
|
||||||
{
|
{
|
||||||
FILE *tex_file = fopen(tex_name, "w");
|
FILE *tex_file = fopen(tex_name, "w");
|
||||||
if (tex_file) {
|
if (tex_file) {
|
||||||
@@ -2495,9 +2495,7 @@ list.
|
|||||||
}@}
|
}@}
|
||||||
|
|
||||||
@o latex.c -cc -d
|
@o latex.c -cc -d
|
||||||
@{static void print_scrap_numbers(tex_file, scraps)
|
@{static void print_scrap_numbers(FILE *tex_file, Scrap_Node *scraps)
|
||||||
FILE *tex_file;
|
|
||||||
Scrap_Node *scraps;
|
|
||||||
{
|
{
|
||||||
int page;
|
int page;
|
||||||
fputs("\\NWlink{nuweb", tex_file);
|
fputs("\\NWlink{nuweb", tex_file);
|
||||||
@@ -2604,10 +2602,7 @@ command.
|
|||||||
@| write_literal @}
|
@| write_literal @}
|
||||||
|
|
||||||
@o latex.c -cc -d
|
@o latex.c -cc -d
|
||||||
@{static void copy_scrap(file, prefix, name)
|
@{static void copy_scrap(FILE *file, int prefix, Name *name)
|
||||||
FILE *file;
|
|
||||||
int prefix;
|
|
||||||
Name * name;
|
|
||||||
{
|
{
|
||||||
int indent = 0;
|
int indent = 0;
|
||||||
int c;
|
int c;
|
||||||
@@ -2929,9 +2924,7 @@ write_ArglistElement(FILE * file, Arglist * args, char ** params)
|
|||||||
}@}
|
}@}
|
||||||
|
|
||||||
@o latex.c -cc -d
|
@o latex.c -cc -d
|
||||||
@{static void format_file_entry(name, tex_file)
|
@{static void format_file_entry(Name *name, FILE *tex_file)
|
||||||
Name *name;
|
|
||||||
FILE *tex_file;
|
|
||||||
{
|
{
|
||||||
while (name) {
|
while (name) {
|
||||||
format_file_entry(name->llink, tex_file);
|
format_file_entry(name->llink, tex_file);
|
||||||
@@ -3002,10 +2995,7 @@ c = source_get();
|
|||||||
@| load_entry @}
|
@| load_entry @}
|
||||||
|
|
||||||
@o latex.c -cc -d
|
@o latex.c -cc -d
|
||||||
@{static void format_entry(name, tex_file, sector)
|
@{static void format_entry(Name *name, FILE *tex_file, unsigned char sector)
|
||||||
Name *name;
|
|
||||||
FILE *tex_file;
|
|
||||||
unsigned char sector;
|
|
||||||
{
|
{
|
||||||
Name ** nms = malloc(num_scraps()*sizeof(Name *));
|
Name ** nms = malloc(num_scraps()*sizeof(Name *));
|
||||||
int n = load_entry(name, nms, 0);
|
int n = load_entry(name, nms, 0);
|
||||||
@@ -3143,10 +3133,7 @@ for (j = 1; j < @2; j++)
|
|||||||
|
|
||||||
|
|
||||||
@o latex.c -cc -d
|
@o latex.c -cc -d
|
||||||
@{static void format_user_entry(name, tex_file, sector)
|
@{static void format_user_entry(Name *name, FILE *tex_file, unsigned char sector)
|
||||||
Name *name;
|
|
||||||
FILE *tex_file;
|
|
||||||
unsigned char sector;
|
|
||||||
{
|
{
|
||||||
while (name) {
|
while (name) {
|
||||||
format_user_entry(name->llink, tex_file, sector);
|
format_user_entry(name->llink, tex_file, sector);
|
||||||
@@ -3237,28 +3224,31 @@ copies most of the text from the source file straight into a
|
|||||||
cross-reference information is printed out.
|
cross-reference information is printed out.
|
||||||
|
|
||||||
@d Function...
|
@d Function...
|
||||||
@{extern void write_html();
|
@{extern void write_html(char *file_name, char *html_name);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
We need a few local function declarations before we get into the body
|
We need a few local function declarations before we get into the body
|
||||||
of \verb|write_html|.
|
of \verb|write_html|.
|
||||||
|
|
||||||
@o html.c
|
@o html.c
|
||||||
@{static void copy_scrap(); /* formats the body of a scrap */
|
@{static void copy_scrap(FILE *file, int prefix);
|
||||||
static void display_scrap_ref(); /* formats a scrap reference */
|
/* formats the body of a scrap */
|
||||||
static void display_scrap_numbers(); /* formats a list of scrap numbers */
|
static void display_scrap_ref(FILE *html_file, int num);
|
||||||
static void print_scrap_numbers(); /* pluralizes scrap formats list */
|
/* formats a scrap reference */
|
||||||
static void format_entry(); /* formats an index entry */
|
static void display_scrap_numbers(FILE *html_file, Scrap_Node *scraps);
|
||||||
static void format_user_entry();
|
/* formats a list of scrap numbers */
|
||||||
|
static void print_scrap_numbers(FILE *html_file, Scrap_Node *scraps);
|
||||||
|
/* pluralizes scrap formats list */
|
||||||
|
static void format_entry(Name *name, FILE *html_file, int file_flag);
|
||||||
|
/* formats an index entry */
|
||||||
|
static void format_user_entry(Name *name, FILE *html_file, int sector);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
|
|
||||||
The routine \verb|write_html| takes two file names as parameters: the
|
The routine \verb|write_html| takes two file names as parameters: the
|
||||||
name of the web source file and the name of the \verb|.tex| output file.
|
name of the web source file and the name of the \verb|.tex| output file.
|
||||||
@o html.c
|
@o html.c
|
||||||
@{void write_html(file_name, html_name)
|
@{void write_html(char *file_name, char *html_name)
|
||||||
char *file_name;
|
|
||||||
char *html_name;
|
|
||||||
{
|
{
|
||||||
FILE *html_file = fopen(html_name, "w");
|
FILE *html_file = fopen(html_name, "w");
|
||||||
FILE *tex_file = html_file;
|
FILE *tex_file = html_file;
|
||||||
@@ -3471,9 +3461,7 @@ end the paragraph.
|
|||||||
}@}
|
}@}
|
||||||
|
|
||||||
@o html.c
|
@o html.c
|
||||||
@{static void display_scrap_ref(html_file, num)
|
@{static void display_scrap_ref(FILE *html_file, int num)
|
||||||
FILE *html_file;
|
|
||||||
int num;
|
|
||||||
{
|
{
|
||||||
fputs("<a href=\"#nuweb", html_file);
|
fputs("<a href=\"#nuweb", html_file);
|
||||||
write_single_scrap_ref(html_file, num);
|
write_single_scrap_ref(html_file, num);
|
||||||
@@ -3484,9 +3472,7 @@ end the paragraph.
|
|||||||
@| display_scrap_ref @}
|
@| display_scrap_ref @}
|
||||||
|
|
||||||
@o html.c
|
@o html.c
|
||||||
@{static void display_scrap_numbers(html_file, scraps)
|
@{static void display_scrap_numbers(FILE *html_file, Scrap_Node *scraps)
|
||||||
FILE *html_file;
|
|
||||||
Scrap_Node *scraps;
|
|
||||||
{
|
{
|
||||||
display_scrap_ref(html_file, scraps->scrap);
|
display_scrap_ref(html_file, scraps->scrap);
|
||||||
scraps = scraps->next;
|
scraps = scraps->next;
|
||||||
@@ -3499,9 +3485,7 @@ end the paragraph.
|
|||||||
@| display_scrap_numbers @}
|
@| display_scrap_numbers @}
|
||||||
|
|
||||||
@o html.c
|
@o html.c
|
||||||
@{static void print_scrap_numbers(html_file, scraps)
|
@{static void print_scrap_numbers(FILE *html_file, Scrap_Node *scraps)
|
||||||
FILE *html_file;
|
|
||||||
Scrap_Node *scraps;
|
|
||||||
{
|
{
|
||||||
display_scrap_numbers(html_file, scraps);
|
display_scrap_numbers(html_file, scraps);
|
||||||
fputs(".\n", html_file);
|
fputs(".\n", html_file);
|
||||||
@@ -3514,9 +3498,7 @@ end the paragraph.
|
|||||||
We must translate HTML special keywords into entities in scraps.
|
We must translate HTML special keywords into entities in scraps.
|
||||||
|
|
||||||
@o html.c
|
@o html.c
|
||||||
@{static void copy_scrap(file, prefix)
|
@{static void copy_scrap(FILE *file, int prefix)
|
||||||
FILE *file;
|
|
||||||
int prefix;
|
|
||||||
{
|
{
|
||||||
int indent = 0;
|
int indent = 0;
|
||||||
int c = source_get();
|
int c = source_get();
|
||||||
@@ -3659,10 +3641,7 @@ pointed out any during the first pass.
|
|||||||
}@}
|
}@}
|
||||||
|
|
||||||
@o html.c
|
@o html.c
|
||||||
@{static void format_entry(name, html_file, file_flag)
|
@{static void format_entry(Name *name, FILE *html_file, int file_flag)
|
||||||
Name *name;
|
|
||||||
FILE *html_file;
|
|
||||||
int file_flag;
|
|
||||||
{
|
{
|
||||||
while (name) {
|
while (name) {
|
||||||
format_entry(name->llink, html_file, file_flag);
|
format_entry(name->llink, html_file, file_flag);
|
||||||
@@ -3731,10 +3710,7 @@ pointed out any during the first pass.
|
|||||||
|
|
||||||
|
|
||||||
@o html.c
|
@o html.c
|
||||||
@{static void format_user_entry(name, html_file, sector)
|
@{static void format_user_entry(Name *name, FILE *html_file, int sector)
|
||||||
Name *name;
|
|
||||||
FILE *html_file;
|
|
||||||
int sector;
|
|
||||||
{
|
{
|
||||||
while (name) {
|
while (name) {
|
||||||
format_user_entry(name->llink, html_file, sector);
|
format_user_entry(name->llink, html_file, sector);
|
||||||
@@ -3785,12 +3761,11 @@ pointed out any during the first pass.
|
|||||||
\section{Writing the Output Files} \label{output-files}
|
\section{Writing the Output Files} \label{output-files}
|
||||||
|
|
||||||
@d Function pro...
|
@d Function pro...
|
||||||
@{extern void write_files();
|
@{extern void write_files(Name *files);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
@o output.c -cc -d
|
@o output.c -cc -d
|
||||||
@{void write_files(files)
|
@{void write_files(Name *files)
|
||||||
Name *files;
|
|
||||||
{
|
{
|
||||||
while (files) {
|
while (files) {
|
||||||
write_files(files->llink);
|
write_files(files->llink);
|
||||||
@@ -3911,8 +3886,10 @@ if (0 != rename(temp_name, real_name)) {
|
|||||||
|
|
||||||
We need two routines to handle reading the source files.
|
We need two routines to handle reading the source files.
|
||||||
@d Function pro...
|
@d Function pro...
|
||||||
@{extern void source_open(); /* pass in the name of the source file */
|
@{extern void source_open(char *name);
|
||||||
extern int source_get(); /* no args; returns the next char or EOF */
|
/* pass in the name of the source file */
|
||||||
|
extern int source_get(void);
|
||||||
|
/* no args; returns the next char or EOF */
|
||||||
extern int source_last; /* what last source_get() returned. */
|
extern int source_last; /* what last source_get() returned. */
|
||||||
extern int source_peek; /* The next character to get */
|
extern int source_peek; /* The next character to get */
|
||||||
@}
|
@}
|
||||||
@@ -3961,7 +3938,7 @@ are defining.
|
|||||||
@{
|
@{
|
||||||
int source_peek;
|
int source_peek;
|
||||||
int source_last;
|
int source_last;
|
||||||
int source_get()
|
int source_get(void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
source_last = c = source_peek;
|
source_last = c = source_peek;
|
||||||
@@ -4127,8 +4104,7 @@ The routine \verb|source_open| takes a file name and tries to open the
|
|||||||
file. If unsuccessful, it complains and halts. Otherwise, it sets
|
file. If unsuccessful, it complains and halts. Otherwise, it sets
|
||||||
\verb|source_name|, \verb|source_line|, and \verb|double_at|.
|
\verb|source_name|, \verb|source_line|, and \verb|double_at|.
|
||||||
@o input.c -cc -d
|
@o input.c -cc -d
|
||||||
@{void source_open(name)
|
@{void source_open(char *name)
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
source_file = fopen(name, "r");
|
source_file = fopen(name, "r");
|
||||||
if (!source_file) {
|
if (!source_file) {
|
||||||
@@ -4185,7 +4161,7 @@ static ScrapEntry *SCRAP[SCRAP_SIZE];
|
|||||||
#define scrap_array(i) SCRAP[(i) >> SCRAP_SHIFT][(i) & SCRAP_MASK]
|
#define scrap_array(i) SCRAP[(i) >> SCRAP_SHIFT][(i) & SCRAP_MASK]
|
||||||
|
|
||||||
static int scraps;
|
static int scraps;
|
||||||
int num_scraps()
|
int num_scraps(void)
|
||||||
{
|
{
|
||||||
return scraps;
|
return scraps;
|
||||||
};
|
};
|
||||||
@@ -4194,17 +4170,22 @@ int num_scraps()
|
|||||||
|
|
||||||
|
|
||||||
@d Function pro...
|
@d Function pro...
|
||||||
@{extern void init_scraps();
|
@{extern void init_scraps(void);
|
||||||
extern int collect_scrap();
|
extern int collect_scrap(void);
|
||||||
extern int write_scraps();
|
extern int write_scraps(FILE *file, char *spelling, Scrap_Node *defs,
|
||||||
extern void write_scrap_ref();
|
int global_indent, char *indent_chars,
|
||||||
extern void write_single_scrap_ref();
|
char debug_flag, char tab_flag, char indent_flag,
|
||||||
extern int num_scraps();
|
unsigned char comment_flag, Arglist *inArgs,
|
||||||
|
char *inParams[9], Parameters parameters,
|
||||||
|
char *title);
|
||||||
|
extern void write_scrap_ref(FILE *file, int num, int first, int *page);
|
||||||
|
extern void write_single_scrap_ref(FILE *file, int num);
|
||||||
|
extern int num_scraps(void);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{void init_scraps()
|
@{void init_scraps(void)
|
||||||
{
|
{
|
||||||
scraps = 1;
|
scraps = 1;
|
||||||
SCRAP[0] = (ScrapEntry *) arena_getmem(SCRAP_SIZE * sizeof(ScrapEntry));
|
SCRAP[0] = (ScrapEntry *) arena_getmem(SCRAP_SIZE * sizeof(ScrapEntry));
|
||||||
@@ -4212,11 +4193,7 @@ extern int num_scraps();
|
|||||||
@| init_scraps @}
|
@| init_scraps @}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{void write_scrap_ref(file, num, first, page)
|
@{void write_scrap_ref(FILE *file, int num, int first, int *page)
|
||||||
FILE *file;
|
|
||||||
int num;
|
|
||||||
int first;
|
|
||||||
int *page;
|
|
||||||
{
|
{
|
||||||
if (scrap_array(num).page >= 0) {
|
if (scrap_array(num).page >= 0) {
|
||||||
if (first!=0)
|
if (first!=0)
|
||||||
@@ -4239,9 +4216,7 @@ extern int num_scraps();
|
|||||||
@| write_scrap_ref @}
|
@| write_scrap_ref @}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{void write_single_scrap_ref(file, num)
|
@{void write_single_scrap_ref(FILE *file, int num)
|
||||||
FILE *file;
|
|
||||||
int num;
|
|
||||||
{
|
{
|
||||||
int page;
|
int page;
|
||||||
write_scrap_ref(file, num, TRUE, &page);
|
write_scrap_ref(file, num, TRUE, &page);
|
||||||
@@ -4277,9 +4252,7 @@ extern int num_scraps();
|
|||||||
|
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{static void push(c, manager)
|
@{static void push(char c, Manager *manager)
|
||||||
char c;
|
|
||||||
Manager *manager;
|
|
||||||
{
|
{
|
||||||
Slab *scrap = manager->scrap;
|
Slab *scrap = manager->scrap;
|
||||||
int index = manager->index;
|
int index = manager->index;
|
||||||
@@ -4295,9 +4268,7 @@ extern int num_scraps();
|
|||||||
@| push @}
|
@| push @}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{static void pushs(s, manager)
|
@{static void pushs(char *s, Manager *manager)
|
||||||
char *s;
|
|
||||||
Manager *manager;
|
|
||||||
{
|
{
|
||||||
while (*s)
|
while (*s)
|
||||||
push(*s++, manager);
|
push(*s++, manager);
|
||||||
@@ -4305,7 +4276,7 @@ extern int num_scraps();
|
|||||||
@| pushs @}
|
@| pushs @}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{int collect_scrap()
|
@{int collect_scrap(void)
|
||||||
{
|
{
|
||||||
int current_scrap, lblseq = 0;
|
int current_scrap, lblseq = 0;
|
||||||
int depth = 1;
|
int depth = 1;
|
||||||
@@ -4530,8 +4501,7 @@ add_to_use(Name * name, int current_scrap)
|
|||||||
@{extern void add_to_use(Name * name, int current_scrap);
|
@{extern void add_to_use(Name * name, int current_scrap);
|
||||||
@}
|
@}
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{static char pop(manager)
|
@{static char pop(Manager *manager)
|
||||||
Manager *manager;
|
|
||||||
{
|
{
|
||||||
Slab *scrap = manager->scrap;
|
Slab *scrap = manager->scrap;
|
||||||
int index = manager->index;
|
int index = manager->index;
|
||||||
@@ -4547,9 +4517,7 @@ add_to_use(Name * name, int current_scrap)
|
|||||||
@| pop @}
|
@| pop @}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{static void backup(n, manager)
|
@{static void backup(int n, Manager *manager)
|
||||||
int n;
|
|
||||||
Manager *manager;
|
|
||||||
{
|
{
|
||||||
int index = manager->index;
|
int index = manager->index;
|
||||||
if (n > index
|
if (n > index
|
||||||
@@ -4604,7 +4572,7 @@ lookup(int n, Arglist * par, char * arg[9], Name **name, Arglist ** args)
|
|||||||
@| instance @}
|
@| instance @}
|
||||||
|
|
||||||
@d Function prototypes
|
@d Function prototypes
|
||||||
@{Arglist * instance();
|
@{extern Arglist *instance(Arglist *a, Arglist *par, char *arg[9], int *ch);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
@d Set up name, args and next
|
@d Set up name, args and next
|
||||||
@@ -4636,9 +4604,7 @@ a->args = args;
|
|||||||
a->next = next;@}
|
a->next = next;@}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{static Arglist *pop_scrap_name(manager, parameters)
|
@{static Arglist *pop_scrap_name(Manager *manager, Parameters *parameters)
|
||||||
Manager *manager;
|
|
||||||
Parameters *parameters;
|
|
||||||
{
|
{
|
||||||
char name[MAX_NAME_LEN];
|
char name[MAX_NAME_LEN];
|
||||||
char *p = name;
|
char *p = name;
|
||||||
@@ -4671,22 +4637,11 @@ a->next = next;@}
|
|||||||
}@}
|
}@}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{int write_scraps(file, spelling, defs, global_indent, indent_chars,
|
@{int write_scraps(FILE *file, char *spelling, Scrap_Node *defs,
|
||||||
debug_flag, tab_flag, indent_flag,
|
int global_indent, char *indent_chars, char debug_flag,
|
||||||
comment_flag, inArgs, inParams, parameters, title)
|
char tab_flag, char indent_flag,
|
||||||
FILE *file;
|
unsigned char comment_flag, Arglist *inArgs,
|
||||||
char * spelling;
|
char *inParams[9], Parameters parameters, char *title)
|
||||||
Scrap_Node *defs;
|
|
||||||
int global_indent;
|
|
||||||
char *indent_chars;
|
|
||||||
char debug_flag;
|
|
||||||
char tab_flag;
|
|
||||||
char indent_flag;
|
|
||||||
unsigned char comment_flag;
|
|
||||||
Arglist * inArgs;
|
|
||||||
char * inParams[9];
|
|
||||||
Parameters parameters;
|
|
||||||
char * title;
|
|
||||||
{
|
{
|
||||||
/* This is in file @f */
|
/* This is in file @f */
|
||||||
int indent = 0;
|
int indent = 0;
|
||||||
@@ -5026,12 +4981,11 @@ fputc('>', file);@}
|
|||||||
\subsection{Collecting Page Numbers}
|
\subsection{Collecting Page Numbers}
|
||||||
|
|
||||||
@d Function...
|
@d Function...
|
||||||
@{extern void collect_numbers();
|
@{extern void collect_numbers(char *aux_name);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{void collect_numbers(aux_name)
|
@{void collect_numbers(char *aux_name)
|
||||||
char *aux_name;
|
|
||||||
{
|
{
|
||||||
if (number_flag) {
|
if (number_flag) {
|
||||||
int i;
|
int i;
|
||||||
@@ -5159,21 +5113,19 @@ int scrap_ended_with;
|
|||||||
@}
|
@}
|
||||||
|
|
||||||
@d Function pro...
|
@d Function pro...
|
||||||
@{extern Name *collect_file_name();
|
@{extern Name *collect_file_name(void);
|
||||||
extern Name *collect_macro_name();
|
extern Name *collect_macro_name(void);
|
||||||
extern Arglist *collect_scrap_name();
|
extern Arglist *collect_scrap_name(int current_scrap);
|
||||||
extern Name *name_add();
|
extern Name *name_add(Name **rt, char *spelling, unsigned char sector);
|
||||||
extern Name *prefix_add();
|
extern Name *prefix_add(Name **rt, char *spelling, unsigned char sector);
|
||||||
extern char *save_string();
|
extern char *save_string(char *);
|
||||||
extern void reverse_lists();
|
extern void reverse_lists(Name *names);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
@o names.c -cc -d
|
@o names.c -cc -d
|
||||||
@{enum { LESS, GREATER, EQUAL, PREFIX, EXTENSION };
|
@{enum { LESS, GREATER, EQUAL, PREFIX, EXTENSION };
|
||||||
|
|
||||||
static int compare(x, y)
|
static int compare(char *x, char *y)
|
||||||
char *x;
|
|
||||||
char *y;
|
|
||||||
{
|
{
|
||||||
int len, result;
|
int len, result;
|
||||||
int xl = strlen(x);
|
int xl = strlen(x);
|
||||||
@@ -5200,8 +5152,7 @@ static int compare(x, y)
|
|||||||
|
|
||||||
|
|
||||||
@o names.c -cc -d
|
@o names.c -cc -d
|
||||||
@{char *save_string(s)
|
@{char *save_string(char *s)
|
||||||
char *s;
|
|
||||||
{
|
{
|
||||||
char *new = (char *) arena_getmem((strlen(s) + 1) * sizeof(char));
|
char *new = (char *) arena_getmem((strlen(s) + 1) * sizeof(char));
|
||||||
strcpy(new, s);
|
strcpy(new, s);
|
||||||
@@ -5210,14 +5161,12 @@ static int compare(x, y)
|
|||||||
@| save_string @}
|
@| save_string @}
|
||||||
|
|
||||||
@o names.c -cc -d
|
@o names.c -cc -d
|
||||||
@{static int ambiguous_prefix();
|
@{static int ambiguous_prefix(Name *node, char *spelling,
|
||||||
|
unsigned char sector);
|
||||||
|
|
||||||
static char * found_name = NULL;
|
static char * found_name = NULL;
|
||||||
|
|
||||||
Name *prefix_add(rt, spelling, sector)
|
Name *prefix_add(Name **rt, char *spelling, unsigned char sector)
|
||||||
Name **rt;
|
|
||||||
char *spelling;
|
|
||||||
unsigned char sector;
|
|
||||||
{
|
{
|
||||||
Name *node = *rt;
|
Name *node = *rt;
|
||||||
int cmp;
|
int cmp;
|
||||||
@@ -5264,10 +5213,7 @@ continue the search down {\em both\/} branches of the tree.
|
|||||||
}@}
|
}@}
|
||||||
|
|
||||||
@o names.c -cc -d
|
@o names.c -cc -d
|
||||||
@{static int ambiguous_prefix(node, spelling, sector)
|
@{static int ambiguous_prefix(Name *node, char *spelling, unsigned char sector)
|
||||||
Name *node;
|
|
||||||
char *spelling;
|
|
||||||
unsigned char sector;
|
|
||||||
{
|
{
|
||||||
while (node) {
|
while (node) {
|
||||||
switch (compare(node->spelling, spelling)) {
|
switch (compare(node->spelling, spelling)) {
|
||||||
@@ -5354,10 +5300,7 @@ them to be considered for the alphabetical ordering.
|
|||||||
@}
|
@}
|
||||||
|
|
||||||
@o names.c -cc -d
|
@o names.c -cc -d
|
||||||
@{Name *name_add(rt, spelling, sector)
|
@{Name *name_add(Name **rt, char *spelling, unsigned char sector)
|
||||||
Name **rt;
|
|
||||||
char *spelling;
|
|
||||||
unsigned char sector;
|
|
||||||
{
|
{
|
||||||
Name *node = *rt;
|
Name *node = *rt;
|
||||||
while (node) {
|
while (node) {
|
||||||
@@ -5417,7 +5360,7 @@ them to be considered for the alphabetical ordering.
|
|||||||
Name terminated by whitespace. Also check for ``per-file'' flags. Keep
|
Name terminated by whitespace. Also check for ``per-file'' flags. Keep
|
||||||
skipping white space until we reach scrap.
|
skipping white space until we reach scrap.
|
||||||
@o names.c -cc -d
|
@o names.c -cc -d
|
||||||
@{Name *collect_file_name()
|
@{Name *collect_file_name(void)
|
||||||
{
|
{
|
||||||
Name *new_name;
|
Name *new_name;
|
||||||
char name[MAX_NAME_LEN];
|
char name[MAX_NAME_LEN];
|
||||||
@@ -5500,7 +5443,7 @@ char * comment_end[4] = { "", " */", "", ""};
|
|||||||
|
|
||||||
Name terminated by \verb+\n+ or \verb+@@{+; but keep skipping until \verb+@@{+
|
Name terminated by \verb+\n+ or \verb+@@{+; but keep skipping until \verb+@@{+
|
||||||
@o names.c -cc -d
|
@o names.c -cc -d
|
||||||
@{Name *collect_macro_name()
|
@{Name *collect_macro_name(void)
|
||||||
{
|
{
|
||||||
char name[MAX_NAME_LEN];
|
char name[MAX_NAME_LEN];
|
||||||
char args[1000];
|
char args[1000];
|
||||||
@@ -5633,7 +5576,7 @@ while ((c = source_get()) != EOF) {
|
|||||||
}@}
|
}@}
|
||||||
|
|
||||||
@d Function prototypes
|
@d Function prototypes
|
||||||
@{extern Name *install_args();
|
@{extern Name *install_args(Name * name, int argc, char *arg[0]);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
@o names.c -cc -d
|
@o names.c -cc -d
|
||||||
@@ -5833,10 +5776,9 @@ tail = &(*tail)->next;
|
|||||||
@}
|
@}
|
||||||
|
|
||||||
@o names.c -cc -d
|
@o names.c -cc -d
|
||||||
@{static Scrap_Node *reverse(); /* a forward declaration */
|
@{static Scrap_Node *reverse(Scrap_Node *a); /* a forward declaration */
|
||||||
|
|
||||||
void reverse_lists(names)
|
void reverse_lists(Name *names)
|
||||||
Name *names;
|
|
||||||
{
|
{
|
||||||
while (names) {
|
while (names) {
|
||||||
reverse_lists(names->llink);
|
reverse_lists(names->llink);
|
||||||
@@ -5851,8 +5793,7 @@ Just for fun, here's a non-recursive version of the traditional list
|
|||||||
reversal code. Note that it reverses the list in place; that is, it
|
reversal code. Note that it reverses the list in place; that is, it
|
||||||
does no new allocations.
|
does no new allocations.
|
||||||
@o names.c -cc -d
|
@o names.c -cc -d
|
||||||
@{static Scrap_Node *reverse(a)
|
@{static Scrap_Node *reverse(Scrap_Node *a)
|
||||||
Scrap_Node *a;
|
|
||||||
{
|
{
|
||||||
if (a) {
|
if (a) {
|
||||||
Scrap_Node *b = a->next;
|
Scrap_Node *b = a->next;
|
||||||
@@ -5910,9 +5851,7 @@ static Goto_Node **depths;
|
|||||||
|
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{static Goto_Node *goto_lookup(c, g)
|
@{static Goto_Node *goto_lookup(char c, Goto_Node *g)
|
||||||
char c;
|
|
||||||
Goto_Node *g;
|
|
||||||
{
|
{
|
||||||
Move_Node *m = g->moves;
|
Move_Node *m = g->moves;
|
||||||
while (m && m->c != c)
|
while (m && m->c != c)
|
||||||
@@ -6058,14 +5997,14 @@ else if (m->prev)
|
|||||||
\subsection{Building the Automata}
|
\subsection{Building the Automata}
|
||||||
|
|
||||||
@d Function pro...
|
@d Function pro...
|
||||||
@{extern void search();
|
@{extern void search(void);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{static void build_gotos();
|
@{static void build_gotos(Name *tree);
|
||||||
static int reject_match();
|
static int reject_match(Name *name, char post, ArgManager *reader);
|
||||||
|
|
||||||
void search()
|
void search(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<128; i++)
|
for (i=0; i<128; i++)
|
||||||
@@ -6083,8 +6022,7 @@ void search()
|
|||||||
|
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{static void build_gotos(tree)
|
@{static void build_gotos(Name *tree)
|
||||||
Name *tree;
|
|
||||||
{
|
{
|
||||||
while (tree) {
|
while (tree) {
|
||||||
@<Extend goto graph with \verb|tree->spelling|@>
|
@<Extend goto graph with \verb|tree->spelling|@>
|
||||||
@@ -6261,8 +6199,8 @@ void search()
|
|||||||
|
|
||||||
@d Forward declarations for scraps.c
|
@d Forward declarations for scraps.c
|
||||||
@{
|
@{
|
||||||
static void add_uses();
|
static void add_uses(Uses **root, Name *name);
|
||||||
static int scrap_is_in();
|
static int scrap_is_in(Scrap_Node * list, int i);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@@ -6422,8 +6360,7 @@ For the present, we'll consider the mechanism an experiment.
|
|||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{#define sym_char(c) (isalnum(c) || (c) == '_')
|
@{#define sym_char(c) (isalnum(c) || (c) == '_')
|
||||||
|
|
||||||
static int op_char(c)
|
static int op_char(char c)
|
||||||
char c;
|
|
||||||
{
|
{
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '!': case '#': case '%': case '$': case '^':
|
case '!': case '#': case '%': case '$': case '^':
|
||||||
@@ -6437,10 +6374,7 @@ static int op_char(c)
|
|||||||
@| sym_char op_char @}
|
@| sym_char op_char @}
|
||||||
|
|
||||||
@o scraps.c -cc -d
|
@o scraps.c -cc -d
|
||||||
@{static int reject_match(name, post, reader)
|
@{static int reject_match(Name *name, char post, ArgManager *reader)
|
||||||
Name *name;
|
|
||||||
char post;
|
|
||||||
ArgManager *reader;
|
|
||||||
{
|
{
|
||||||
int len = strlen(name->spelling);
|
int len = strlen(name->spelling);
|
||||||
char first = name->spelling[0];
|
char first = name->spelling[0];
|
||||||
@@ -6569,8 +6503,8 @@ be allocated. When the storage is no longer required, the entire arena
|
|||||||
is freed with a single call to \verb|arena_free()|. Both operations
|
is freed with a single call to \verb|arena_free()|. Both operations
|
||||||
are quite fast.
|
are quite fast.
|
||||||
@d Function p...
|
@d Function p...
|
||||||
@{extern void *arena_getmem();
|
@{extern void *arena_getmem(size_t n);
|
||||||
extern void arena_free();
|
extern void arena_free(void);
|
||||||
@}
|
@}
|
||||||
|
|
||||||
|
|
||||||
@@ -6603,8 +6537,7 @@ that returned pointers are always aligned. We align to the nearest
|
|||||||
4-byte alignment restrictions too.
|
4-byte alignment restrictions too.
|
||||||
|
|
||||||
@o arena.c -cc -d
|
@o arena.c -cc -d
|
||||||
@{void *arena_getmem(n)
|
@{void *arena_getmem(size_t n)
|
||||||
size_t n;
|
|
||||||
{
|
{
|
||||||
char *q;
|
char *q;
|
||||||
char *p = arena->avail;
|
char *p = arena->avail;
|
||||||
@@ -6662,7 +6595,7 @@ need to allocate a new one.
|
|||||||
To free all the memory in the arena, we need only point \verb|arena|
|
To free all the memory in the arena, we need only point \verb|arena|
|
||||||
back to the first empty chunk.
|
back to the first empty chunk.
|
||||||
@o arena.c -cc -d
|
@o arena.c -cc -d
|
||||||
@{void arena_free()
|
@{void arena_free(void)
|
||||||
{
|
{
|
||||||
arena = &first;
|
arena = &first;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user