Compare commits
9 Commits
1-compile-
...
ebed228492
Author | SHA1 | Date | |
---|---|---|---|
ebed228492 | |||
59b69355ef | |||
b51c8f7a6e | |||
88f1603b2d | |||
b993c46cce | |||
6d436f82a6 | |||
063fdca1ca | |||
cead310efc | |||
8dd1620936
|
33
.gitea/workflows/build-and-test.yaml
Normal file
33
.gitea/workflows/build-and-test.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
name: "BuildTest"
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: "Build and test"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Install build deps"
|
||||
run: |
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
sudo apt-get update
|
||||
sudo apt-get -y --no-install-recommends install build-essential \
|
||||
texlive-latex-base texlive-latex-recommended
|
||||
|
||||
- name: "Checkout repo"
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: "Bootstrap nuweb"
|
||||
run: make nuweb
|
||||
|
||||
- name: "Make nuweb.tex"
|
||||
run: make nuweb.tex nuwebdoc.tex
|
||||
|
||||
- name: "Build again"
|
||||
run: make nuweb
|
||||
|
||||
- name: "Run tests"
|
||||
run: make check
|
23
arena.c
23
arena.c
@@ -1,13 +1,20 @@
|
||||
|
||||
#line 938 "nuweb.w"
|
||||
#include "global.h"
|
||||
|
||||
#line 6512 "nuweb.w"
|
||||
typedef struct chunk {
|
||||
struct chunk *next;
|
||||
char *limit;
|
||||
char *avail;
|
||||
} Chunk;
|
||||
|
||||
#line 6526 "nuweb.w"
|
||||
static Chunk first = { NULL, NULL, NULL };
|
||||
static Chunk *arena = &first;
|
||||
void *arena_getmem(n)
|
||||
size_t n;
|
||||
|
||||
#line 6540 "nuweb.w"
|
||||
void *arena_getmem(size_t n)
|
||||
{
|
||||
char *q;
|
||||
char *p = arena->avail;
|
||||
@@ -18,6 +25,8 @@ void *arena_getmem(n)
|
||||
return p;
|
||||
}
|
||||
/* Find a new chunk of memory */
|
||||
|
||||
#line 6561 "nuweb.w"
|
||||
{
|
||||
Chunk *ap = arena;
|
||||
Chunk *np = ap->next;
|
||||
@@ -32,6 +41,8 @@ void *arena_getmem(n)
|
||||
np = ap->next;
|
||||
}
|
||||
/* Allocate a new chunk of memory */
|
||||
|
||||
#line 6581 "nuweb.w"
|
||||
{
|
||||
size_t m = n + 10000;
|
||||
np = (Chunk *) malloc(m);
|
||||
@@ -42,9 +53,15 @@ void *arena_getmem(n)
|
||||
arena = np;
|
||||
return sizeof(Chunk) + (char *) np;
|
||||
}
|
||||
#line 6574 "nuweb.w"
|
||||
|
||||
}
|
||||
#line 6550 "nuweb.w"
|
||||
|
||||
}
|
||||
void arena_free()
|
||||
|
||||
#line 6598 "nuweb.w"
|
||||
void arena_free(void)
|
||||
{
|
||||
arena = &first;
|
||||
}
|
||||
|
30
global.c
30
global.c
@@ -1,6 +1,10 @@
|
||||
|
||||
#line 944 "nuweb.w"
|
||||
#include "global.h"
|
||||
/* Operating System Dependencies */
|
||||
|
||||
#line 972 "nuweb.w"
|
||||
|
||||
#if defined(VMS)
|
||||
#define PATH_SEP(c) (c==']'||c==':')
|
||||
#define PATH_SEP_CHAR ""
|
||||
@@ -15,7 +19,11 @@
|
||||
#define DEFAULT_PATH "."
|
||||
#endif
|
||||
|
||||
#line 945 "nuweb.w"
|
||||
|
||||
/* Global variable definitions */
|
||||
|
||||
#line 1067 "nuweb.w"
|
||||
int tex_flag = TRUE;
|
||||
int html_flag = FALSE;
|
||||
int output_flag = TRUE;
|
||||
@@ -38,19 +46,39 @@ char * hyperoptions = "";
|
||||
int includepath_flag = FALSE; /* Do we have an include path? */
|
||||
struct incl * include_list = NULL;
|
||||
/* The list of include paths */
|
||||
|
||||
#line 1097 "nuweb.w"
|
||||
int nw_char='@';
|
||||
|
||||
#line 1108 "nuweb.w"
|
||||
char *command_name = NULL;
|
||||
|
||||
#line 1510 "nuweb.w"
|
||||
unsigned char current_sector = 1;
|
||||
unsigned char prev_sector = 1;
|
||||
|
||||
#line 1707 "nuweb.w"
|
||||
char blockBuff[6400];
|
||||
|
||||
#line 2422 "nuweb.w"
|
||||
int extra_scraps = 0;
|
||||
char *source_name = NULL;
|
||||
|
||||
#line 3906 "nuweb.w"
|
||||
char *source_name = NULL;
|
||||
int source_line = 0;
|
||||
|
||||
#line 4241 "nuweb.w"
|
||||
int already_warned = 0;
|
||||
|
||||
#line 5108 "nuweb.w"
|
||||
Name *file_names = NULL;
|
||||
Name *macro_names = NULL;
|
||||
Name *user_names = NULL;
|
||||
int scrap_name_has_parameters;
|
||||
int scrap_ended_with;
|
||||
|
||||
#line 946 "nuweb.w"
|
||||
|
||||
|
||||
#line 6478 "nuweb.w"
|
||||
label_node * label_tab = NULL;
|
||||
|
161
global.h
161
global.h
@@ -1,5 +1,9 @@
|
||||
|
||||
#line 826 "nuweb.w"
|
||||
/* Include files */
|
||||
|
||||
#line 835 "nuweb.w"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -7,7 +11,11 @@
|
||||
#include <signal.h>
|
||||
#include <locale.h>
|
||||
|
||||
#line 826 "nuweb.w"
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
#line 854 "nuweb.w"
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
@@ -15,12 +23,21 @@
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#line 1815 "nuweb.w"
|
||||
typedef int *Parameters;
|
||||
|
||||
#line 3784 "nuweb.w"
|
||||
|
||||
#define MAX_INDENT 500
|
||||
|
||||
#line 5074 "nuweb.w"
|
||||
typedef struct scrap_node {
|
||||
struct scrap_node *next;
|
||||
int scrap;
|
||||
char quoted;
|
||||
} Scrap_Node;
|
||||
|
||||
#line 5083 "nuweb.w"
|
||||
typedef struct name {
|
||||
char *spelling;
|
||||
struct name *llink;
|
||||
@@ -35,20 +52,30 @@ typedef struct name {
|
||||
unsigned char comment_flag;
|
||||
unsigned char sector;
|
||||
} Name;
|
||||
|
||||
#line 5536 "nuweb.w"
|
||||
#define ARG_CHR '\001'
|
||||
|
||||
#line 5596 "nuweb.w"
|
||||
typedef struct arglist
|
||||
{Name * name;
|
||||
struct arglist * args;
|
||||
struct arglist * next;
|
||||
} Arglist;
|
||||
|
||||
#line 5760 "nuweb.w"
|
||||
typedef struct embed {
|
||||
Scrap_Node * defs;
|
||||
Arglist * args;
|
||||
} Embed_Node;
|
||||
|
||||
#line 6240 "nuweb.w"
|
||||
typedef struct uses {
|
||||
struct uses *next;
|
||||
Name *defn;
|
||||
} Uses;
|
||||
|
||||
#line 6482 "nuweb.w"
|
||||
typedef struct l_node
|
||||
{
|
||||
struct l_node * left, * right;
|
||||
@@ -56,13 +83,21 @@ typedef struct l_node
|
||||
char name[1];
|
||||
} label_node;
|
||||
|
||||
#line 827 "nuweb.w"
|
||||
|
||||
/* Limits */
|
||||
|
||||
#line 864 "nuweb.w"
|
||||
|
||||
#ifndef MAX_NAME_LEN
|
||||
#define MAX_NAME_LEN 1024
|
||||
#endif
|
||||
|
||||
#line 828 "nuweb.w"
|
||||
|
||||
/* Global variable declarations */
|
||||
|
||||
#line 1036 "nuweb.w"
|
||||
extern int tex_flag; /* if FALSE, don't emit the documentation file */
|
||||
extern int html_flag; /* if TRUE, emit HTML instead of LaTeX scraps. */
|
||||
extern int output_flag; /* if FALSE, don't emit the output files */
|
||||
@@ -86,62 +121,135 @@ extern char * hyperoptions; /* The options to pass to the
|
||||
extern int includepath_flag; /* Do we have an include path? */
|
||||
extern struct incl{char * name; struct incl * next;} * include_list;
|
||||
/* The list of include paths */
|
||||
|
||||
#line 1094 "nuweb.w"
|
||||
extern int nw_char;
|
||||
|
||||
#line 1104 "nuweb.w"
|
||||
extern char *command_name;
|
||||
|
||||
#line 1505 "nuweb.w"
|
||||
extern unsigned char current_sector;
|
||||
extern unsigned char prev_sector;
|
||||
|
||||
#line 1703 "nuweb.w"
|
||||
extern char blockBuff[6400];
|
||||
|
||||
#line 2418 "nuweb.w"
|
||||
extern int extra_scraps;
|
||||
|
||||
#line 3901 "nuweb.w"
|
||||
extern char *source_name; /* name of the current file */
|
||||
extern int source_line; /* current line in the source file */
|
||||
|
||||
#line 4237 "nuweb.w"
|
||||
extern int already_warned;
|
||||
|
||||
#line 5100 "nuweb.w"
|
||||
extern Name *file_names;
|
||||
extern Name *macro_names;
|
||||
extern Name *user_names;
|
||||
extern int scrap_name_has_parameters;
|
||||
extern int scrap_ended_with;
|
||||
|
||||
#line 6491 "nuweb.w"
|
||||
extern label_node * label_tab;
|
||||
|
||||
#line 829 "nuweb.w"
|
||||
|
||||
/* Function prototypes */
|
||||
extern void pass1();
|
||||
extern void write_tex();
|
||||
|
||||
#line 1400 "nuweb.w"
|
||||
extern void pass1(char *file_name);
|
||||
|
||||
#line 2034 "nuweb.w"
|
||||
extern void write_tex(char *file_name, char *tex_name);
|
||||
|
||||
#line 2582 "nuweb.w"
|
||||
void initialise_delimit_scrap_array(void);
|
||||
|
||||
#line 2676 "nuweb.w"
|
||||
void update_delimit_scrap();
|
||||
|
||||
#line 3100 "nuweb.w"
|
||||
extern int has_sector(Name *, unsigned char);
|
||||
extern void write_html();
|
||||
extern void write_files();
|
||||
extern void source_open(); /* pass in the name of the source file */
|
||||
extern int source_get(); /* no args; returns the next char or EOF */
|
||||
|
||||
#line 3227 "nuweb.w"
|
||||
extern void write_html(char *file_name, char *html_name);
|
||||
|
||||
#line 3764 "nuweb.w"
|
||||
extern void write_files(Name *files);
|
||||
|
||||
#line 3889 "nuweb.w"
|
||||
extern void source_open(char *name);
|
||||
/* 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_peek; /* The next character to get */
|
||||
|
||||
#line 3964 "nuweb.w"
|
||||
extern void source_ungetc(int*);
|
||||
extern void init_scraps();
|
||||
extern int collect_scrap();
|
||||
extern int write_scraps();
|
||||
extern void write_scrap_ref();
|
||||
extern void write_single_scrap_ref();
|
||||
extern int num_scraps();
|
||||
|
||||
#line 4173 "nuweb.w"
|
||||
extern void init_scraps(void);
|
||||
extern int collect_scrap(void);
|
||||
extern int write_scraps(FILE *file, char *spelling, 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);
|
||||
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);
|
||||
|
||||
#line 4501 "nuweb.w"
|
||||
extern void add_to_use(Name * name, int current_scrap);
|
||||
Arglist * instance();
|
||||
extern void collect_numbers();
|
||||
extern Name *collect_file_name();
|
||||
extern Name *collect_macro_name();
|
||||
extern Arglist *collect_scrap_name();
|
||||
extern Name *name_add();
|
||||
extern Name *prefix_add();
|
||||
extern char *save_string();
|
||||
extern void reverse_lists();
|
||||
|
||||
#line 4575 "nuweb.w"
|
||||
extern Arglist *instance(Arglist *a, Arglist *par, char *arg[9], int *ch);
|
||||
|
||||
#line 4984 "nuweb.w"
|
||||
extern void collect_numbers(char *aux_name);
|
||||
|
||||
#line 5116 "nuweb.w"
|
||||
extern Name *collect_file_name(void);
|
||||
extern Name *collect_macro_name(void);
|
||||
extern Arglist *collect_scrap_name(int current_scrap);
|
||||
extern Name *name_add(Name **rt, char *spelling, unsigned char sector);
|
||||
extern Name *prefix_add(Name **rt, char *spelling, unsigned char sector);
|
||||
extern char *save_string(char *);
|
||||
extern void reverse_lists(Name *names);
|
||||
|
||||
#line 5260 "nuweb.w"
|
||||
extern int robs_strcmp(char*, char*);
|
||||
extern Name *install_args();
|
||||
extern void search();
|
||||
|
||||
#line 5579 "nuweb.w"
|
||||
extern Name *install_args(Name * name, int argc, char *arg[0]);
|
||||
|
||||
#line 6000 "nuweb.w"
|
||||
extern void search(void);
|
||||
|
||||
#line 6247 "nuweb.w"
|
||||
extern void format_uses_refs(FILE *, int);
|
||||
|
||||
#line 6302 "nuweb.w"
|
||||
extern void format_defs_refs(FILE *, int);
|
||||
|
||||
#line 6413 "nuweb.w"
|
||||
void write_label(char label_name[], FILE * file);
|
||||
extern void *arena_getmem();
|
||||
extern void arena_free();
|
||||
|
||||
#line 6506 "nuweb.w"
|
||||
extern void *arena_getmem(size_t n);
|
||||
extern void arena_free(void);
|
||||
|
||||
#line 830 "nuweb.w"
|
||||
|
||||
/* Operating System Dependencies */
|
||||
|
||||
#line 972 "nuweb.w"
|
||||
|
||||
#if defined(VMS)
|
||||
#define PATH_SEP(c) (c==']'||c==':')
|
||||
#define PATH_SEP_CHAR ""
|
||||
@@ -155,4 +263,5 @@ extern void arena_free();
|
||||
#define PATH_SEP_CHAR "/"
|
||||
#define DEFAULT_PATH "."
|
||||
#endif
|
||||
typedef int *Parameters;
|
||||
|
||||
#line 831 "nuweb.w"
|
||||
|
47
html.c
47
html.c
@@ -1,14 +1,17 @@
|
||||
#include "global.h"
|
||||
static int scraps = 1;
|
||||
static void copy_scrap(); /* formats the body of a scrap */
|
||||
static void display_scrap_ref(); /* formats a scrap reference */
|
||||
static void display_scrap_numbers(); /* formats a list of scrap numbers */
|
||||
static void print_scrap_numbers(); /* pluralizes scrap formats list */
|
||||
static void format_entry(); /* formats an index entry */
|
||||
static void format_user_entry();
|
||||
void write_html(file_name, html_name)
|
||||
char *file_name;
|
||||
char *html_name;
|
||||
static void copy_scrap(FILE *file, int prefix);
|
||||
/* formats the body of a scrap */
|
||||
static void display_scrap_ref(FILE *html_file, int num);
|
||||
/* formats a scrap reference */
|
||||
static void display_scrap_numbers(FILE *html_file, Scrap_Node *scraps);
|
||||
/* 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);
|
||||
void write_html(char *file_name, char *html_name)
|
||||
{
|
||||
FILE *html_file = fopen(html_name, "w");
|
||||
FILE *tex_file = html_file;
|
||||
@@ -183,9 +186,7 @@ void write_html(file_name, html_name)
|
||||
else
|
||||
fprintf(stderr, "%s: can't open %s\n", command_name, html_name);
|
||||
}
|
||||
static void display_scrap_ref(html_file, num)
|
||||
FILE *html_file;
|
||||
int num;
|
||||
static void display_scrap_ref(FILE *html_file, int num)
|
||||
{
|
||||
fputs("<a href=\"#nuweb", html_file);
|
||||
write_single_scrap_ref(html_file, num);
|
||||
@@ -193,9 +194,7 @@ static void display_scrap_ref(html_file, num)
|
||||
write_single_scrap_ref(html_file, num);
|
||||
fputs("</a>", html_file);
|
||||
}
|
||||
static void display_scrap_numbers(html_file, scraps)
|
||||
FILE *html_file;
|
||||
Scrap_Node *scraps;
|
||||
static void display_scrap_numbers(FILE *html_file, Scrap_Node *scraps)
|
||||
{
|
||||
display_scrap_ref(html_file, scraps->scrap);
|
||||
scraps = scraps->next;
|
||||
@@ -205,16 +204,12 @@ static void display_scrap_numbers(html_file, scraps)
|
||||
scraps = scraps->next;
|
||||
}
|
||||
}
|
||||
static void print_scrap_numbers(html_file, scraps)
|
||||
FILE *html_file;
|
||||
Scrap_Node *scraps;
|
||||
static void print_scrap_numbers(FILE *html_file, Scrap_Node *scraps)
|
||||
{
|
||||
display_scrap_numbers(html_file, scraps);
|
||||
fputs(".\n", html_file);
|
||||
}
|
||||
static void copy_scrap(file, prefix)
|
||||
FILE *file;
|
||||
int prefix;
|
||||
static void copy_scrap(FILE *file, int prefix)
|
||||
{
|
||||
int indent = 0;
|
||||
int c = source_get();
|
||||
@@ -353,10 +348,7 @@ static void copy_scrap(file, prefix)
|
||||
c = source_get();
|
||||
}
|
||||
}
|
||||
static void format_entry(name, html_file, file_flag)
|
||||
Name *name;
|
||||
FILE *html_file;
|
||||
int file_flag;
|
||||
static void format_entry(Name *name, FILE *html_file, int file_flag)
|
||||
{
|
||||
while (name) {
|
||||
format_entry(name->llink, html_file, file_flag);
|
||||
@@ -395,10 +387,7 @@ static void format_entry(name, html_file, file_flag)
|
||||
name = name->rlink;
|
||||
}
|
||||
}
|
||||
static void format_user_entry(name, html_file, sector)
|
||||
Name *name;
|
||||
FILE *html_file;
|
||||
int sector;
|
||||
static void format_user_entry(Name *name, FILE *html_file, int sector)
|
||||
{
|
||||
while (name) {
|
||||
format_user_entry(name->llink, html_file, sector);
|
||||
|
37
input.c
37
input.c
@@ -1,21 +1,31 @@
|
||||
|
||||
#line 919 "nuweb.w"
|
||||
#include "global.h"
|
||||
|
||||
#line 3914 "nuweb.w"
|
||||
static FILE *source_file; /* the current input file */
|
||||
static int double_at;
|
||||
static int include_depth;
|
||||
|
||||
#line 3921 "nuweb.w"
|
||||
static struct {
|
||||
FILE *file;
|
||||
char *name;
|
||||
int line;
|
||||
} stack[10];
|
||||
|
||||
#line 3938 "nuweb.w"
|
||||
|
||||
int source_peek;
|
||||
int source_last;
|
||||
int source_get()
|
||||
int source_get(void)
|
||||
{
|
||||
int c;
|
||||
source_last = c = source_peek;
|
||||
switch (c) {
|
||||
case EOF: {
|
||||
case EOF:
|
||||
#line 4088 "nuweb.w"
|
||||
{
|
||||
fclose(source_file);
|
||||
if (include_depth) {
|
||||
include_depth--;
|
||||
@@ -26,12 +36,16 @@ int source_get()
|
||||
c = source_get();
|
||||
}
|
||||
}
|
||||
#line 3946 "nuweb.w"
|
||||
|
||||
return c;
|
||||
case '\n': source_line++;
|
||||
default:
|
||||
if (c==nw_char)
|
||||
{
|
||||
/* Handle an ``at'' character */
|
||||
|
||||
#line 3985 "nuweb.w"
|
||||
{
|
||||
c = getc(source_file);
|
||||
if (double_at) {
|
||||
@@ -41,7 +55,9 @@ int source_get()
|
||||
}
|
||||
else
|
||||
switch (c) {
|
||||
case 'i': {
|
||||
case 'i':
|
||||
#line 4027 "nuweb.w"
|
||||
{
|
||||
char name[FILENAME_MAX];
|
||||
char fullname[FILENAME_MAX];
|
||||
struct incl * p = include_list;
|
||||
@@ -52,6 +68,8 @@ int source_get()
|
||||
exit(-1);
|
||||
}
|
||||
/* Collect include-file name */
|
||||
|
||||
#line 4067 "nuweb.w"
|
||||
{
|
||||
char *p = name;
|
||||
do
|
||||
@@ -68,6 +86,8 @@ int source_get()
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
#line 4037 "nuweb.w"
|
||||
|
||||
stack[include_depth].file = source_file;
|
||||
fullname[0] = '\0';
|
||||
for (;;) {
|
||||
@@ -95,6 +115,8 @@ int source_get()
|
||||
source_peek = getc(source_file);
|
||||
c = source_get();
|
||||
}
|
||||
#line 3994 "nuweb.w"
|
||||
|
||||
break;
|
||||
case '#': case 'f': case 'm': case 'u': case 'v':
|
||||
case 'd': case 'o': case 'D': case 'O': case 's':
|
||||
@@ -125,12 +147,16 @@ int source_get()
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
#line 3952 "nuweb.w"
|
||||
|
||||
return c;
|
||||
}
|
||||
source_peek = getc(source_file);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
#line 3969 "nuweb.w"
|
||||
void source_ungetc(int *c)
|
||||
{
|
||||
ungetc(source_peek, source_file);
|
||||
@@ -138,8 +164,9 @@ void source_ungetc(int *c)
|
||||
source_line--;
|
||||
source_peek=*c;
|
||||
}
|
||||
void source_open(name)
|
||||
char *name;
|
||||
|
||||
#line 4107 "nuweb.w"
|
||||
void source_open(char *name)
|
||||
{
|
||||
source_file = fopen(name, "r");
|
||||
if (!source_file) {
|
||||
|
413
latex.c
413
latex.c
@@ -1,17 +1,25 @@
|
||||
|
||||
#line 893 "nuweb.w"
|
||||
#include "global.h"
|
||||
static int scraps = 1;
|
||||
static void copy_scrap(); /* formats the body of a scrap */
|
||||
static void print_scrap_numbers(); /* formats a list of scrap numbers */
|
||||
static void format_entry(); /* formats an index entry */
|
||||
static void format_file_entry(); /* formats a file index entry */
|
||||
static void format_user_entry();
|
||||
static void write_arg();
|
||||
static void write_literal();
|
||||
static void write_ArglistElement();
|
||||
void write_tex(file_name, tex_name, sector)
|
||||
char *file_name;
|
||||
char *tex_name;
|
||||
unsigned char sector;
|
||||
|
||||
#line 2041 "nuweb.w"
|
||||
static void copy_scrap(FILE *file, int prefix, Name *name);
|
||||
/* formats the body of a scrap */
|
||||
static void print_scrap_numbers(FILE *tex_file, Scrap_Node *scraps);
|
||||
/* formats a list of scrap numbers */
|
||||
static void format_entry(Name *name, FILE *tex_file, unsigned char sector);
|
||||
/* formats an index entry */
|
||||
static void format_file_entry(Name *name, FILE *tex_file);
|
||||
/* 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);
|
||||
|
||||
#line 2060 "nuweb.w"
|
||||
void write_tex(char *file_name, char *tex_name)
|
||||
{
|
||||
FILE *tex_file = fopen(tex_name, "w");
|
||||
if (tex_file) {
|
||||
@@ -19,6 +27,8 @@ void write_tex(file_name, tex_name, sector)
|
||||
fprintf(stderr, "writing %s\n", tex_name);
|
||||
source_open(file_name);
|
||||
/* Write LaTeX limbo definitions */
|
||||
|
||||
#line 2084 "nuweb.w"
|
||||
if (hyperref_flag) {
|
||||
fputs("\\newcommand{\\NWtarget}[2]{\\hypertarget{#1}{#2}}\n", tex_file);
|
||||
fputs("\\newcommand{\\NWlink}[2]{\\hyperlink{#1}{#2}}\n", tex_file);
|
||||
@@ -42,11 +52,19 @@ void write_tex(file_name, tex_name, sector)
|
||||
if (hyperoptions[0] != '\0')
|
||||
{
|
||||
/* Write the hyperlink usage macro */
|
||||
|
||||
#line 2112 "nuweb.w"
|
||||
fprintf(tex_file, "\\usepackage[%s]{hyperref}", hyperoptions);
|
||||
#line 2106 "nuweb.w"
|
||||
|
||||
}
|
||||
fputs("}\n", tex_file);
|
||||
|
||||
#line 2067 "nuweb.w"
|
||||
|
||||
/* Copy \verb|source_file| into \verb|tex_file| */
|
||||
|
||||
#line 2119 "nuweb.w"
|
||||
{
|
||||
int inBlock = FALSE;
|
||||
int c = source_get();
|
||||
@@ -54,6 +72,8 @@ void write_tex(file_name, tex_name, sector)
|
||||
if (c == nw_char)
|
||||
{
|
||||
/* Interpret at-sequence */
|
||||
|
||||
#line 2135 "nuweb.w"
|
||||
{
|
||||
int big_definition = FALSE;
|
||||
c = source_get();
|
||||
@@ -64,18 +84,26 @@ void write_tex(file_name, tex_name, sector)
|
||||
update_delimit_scrap();
|
||||
break;
|
||||
case 'O': big_definition = TRUE;
|
||||
case 'o': {
|
||||
case 'o':
|
||||
#line 2259 "nuweb.w"
|
||||
{
|
||||
Name *name = collect_file_name();
|
||||
/* Begin the scrap environment */
|
||||
|
||||
#line 2346 "nuweb.w"
|
||||
{
|
||||
if (big_definition)
|
||||
{
|
||||
if (inBlock)
|
||||
{
|
||||
/* End block */
|
||||
|
||||
#line 2377 "nuweb.w"
|
||||
fputs("\\end{minipage}\\vspace{4ex}\n", tex_file);
|
||||
fputs("\\end{flushleft}\n", tex_file);
|
||||
inBlock = FALSE;
|
||||
#line 2351 "nuweb.w"
|
||||
|
||||
}
|
||||
fputs("\\begin{flushleft} \\small", tex_file);
|
||||
}
|
||||
@@ -84,17 +112,27 @@ void write_tex(file_name, tex_name, sector)
|
||||
if (inBlock)
|
||||
{
|
||||
/* Switch block */
|
||||
|
||||
#line 2374 "nuweb.w"
|
||||
fputs("\\par\\vspace{\\baselineskip}\n", tex_file);
|
||||
#line 2359 "nuweb.w"
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Start block */
|
||||
|
||||
#line 2370 "nuweb.w"
|
||||
fputs("\\begin{flushleft} \\small\n\\begin{minipage}{\\linewidth}", tex_file);
|
||||
inBlock = TRUE;
|
||||
#line 2363 "nuweb.w"
|
||||
|
||||
}
|
||||
}
|
||||
fprintf(tex_file, "\\label{scrap%d}\\raggedright\\small\n", scraps);
|
||||
}
|
||||
#line 2261 "nuweb.w"
|
||||
|
||||
fputs("\\NWtarget{nuweb", tex_file);
|
||||
write_single_scrap_ref(tex_file, scraps);
|
||||
fputs("}{} ", tex_file);
|
||||
@@ -102,13 +140,19 @@ void write_tex(file_name, tex_name, sector)
|
||||
write_single_scrap_ref(tex_file, scraps);
|
||||
fputs("}}$\\equiv$\n", tex_file);
|
||||
/* Fill in the middle of the scrap environment */
|
||||
|
||||
#line 2387 "nuweb.w"
|
||||
{
|
||||
fputs("\\vspace{-1ex}\n\\begin{list}{}{} \\item\n", tex_file);
|
||||
extra_scraps = 0;
|
||||
copy_scrap(tex_file, TRUE, name);
|
||||
fputs("{\\NWsep}\n\\end{list}\n", tex_file);
|
||||
}
|
||||
#line 2268 "nuweb.w"
|
||||
|
||||
/* Begin the cross-reference environment */
|
||||
|
||||
#line 2433 "nuweb.w"
|
||||
{
|
||||
fputs("\\vspace{-1.5ex}\n", tex_file);
|
||||
fputs("\\footnotesize\n", tex_file);
|
||||
@@ -116,8 +160,12 @@ void write_tex(file_name, tex_name, sector)
|
||||
tex_file);
|
||||
fputs("\\setlength{\\itemindent}{-\\leftmargin}}\n", tex_file);}
|
||||
|
||||
#line 2269 "nuweb.w"
|
||||
|
||||
if ( scrap_flag ) {
|
||||
/* Write file defs */
|
||||
|
||||
#line 2452 "nuweb.w"
|
||||
{
|
||||
if (name->defs) {
|
||||
if (name->defs->next) {
|
||||
@@ -130,15 +178,23 @@ void write_tex(file_name, tex_name, sector)
|
||||
name->spelling);
|
||||
}
|
||||
}
|
||||
#line 2271 "nuweb.w"
|
||||
|
||||
}
|
||||
format_defs_refs(tex_file, scraps);
|
||||
format_uses_refs(tex_file, scraps++);
|
||||
/* Finish the cross-reference environment */
|
||||
|
||||
#line 2446 "nuweb.w"
|
||||
{
|
||||
fputs("\n\\item{}", tex_file);
|
||||
fputs("\n\\end{list}\n", tex_file);
|
||||
}
|
||||
#line 2275 "nuweb.w"
|
||||
|
||||
/* Finish the scrap environment */
|
||||
|
||||
#line 2404 "nuweb.w"
|
||||
{
|
||||
scraps += extra_scraps;
|
||||
if (big_definition)
|
||||
@@ -146,32 +202,48 @@ void write_tex(file_name, tex_name, sector)
|
||||
else
|
||||
{
|
||||
/* End block */
|
||||
|
||||
#line 2377 "nuweb.w"
|
||||
fputs("\\end{minipage}\\vspace{4ex}\n", tex_file);
|
||||
fputs("\\end{flushleft}\n", tex_file);
|
||||
inBlock = FALSE;
|
||||
#line 2410 "nuweb.w"
|
||||
|
||||
}
|
||||
do
|
||||
c = source_get();
|
||||
while (isspace(c));
|
||||
}
|
||||
#line 2276 "nuweb.w"
|
||||
|
||||
}
|
||||
#line 2145 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'Q':
|
||||
case 'D': big_definition = TRUE;
|
||||
case 'q':
|
||||
case 'd': {
|
||||
case 'd':
|
||||
#line 2284 "nuweb.w"
|
||||
{
|
||||
Name *name = collect_macro_name();
|
||||
|
||||
/* Begin the scrap environment */
|
||||
|
||||
#line 2346 "nuweb.w"
|
||||
{
|
||||
if (big_definition)
|
||||
{
|
||||
if (inBlock)
|
||||
{
|
||||
/* End block */
|
||||
|
||||
#line 2377 "nuweb.w"
|
||||
fputs("\\end{minipage}\\vspace{4ex}\n", tex_file);
|
||||
fputs("\\end{flushleft}\n", tex_file);
|
||||
inBlock = FALSE;
|
||||
#line 2351 "nuweb.w"
|
||||
|
||||
}
|
||||
fputs("\\begin{flushleft} \\small", tex_file);
|
||||
}
|
||||
@@ -180,21 +252,33 @@ void write_tex(file_name, tex_name, sector)
|
||||
if (inBlock)
|
||||
{
|
||||
/* Switch block */
|
||||
|
||||
#line 2374 "nuweb.w"
|
||||
fputs("\\par\\vspace{\\baselineskip}\n", tex_file);
|
||||
#line 2359 "nuweb.w"
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Start block */
|
||||
|
||||
#line 2370 "nuweb.w"
|
||||
fputs("\\begin{flushleft} \\small\n\\begin{minipage}{\\linewidth}", tex_file);
|
||||
inBlock = TRUE;
|
||||
#line 2363 "nuweb.w"
|
||||
|
||||
}
|
||||
}
|
||||
fprintf(tex_file, "\\label{scrap%d}\\raggedright\\small\n", scraps);
|
||||
}
|
||||
#line 2287 "nuweb.w"
|
||||
|
||||
fputs("\\NWtarget{nuweb", tex_file);
|
||||
write_single_scrap_ref(tex_file, scraps);
|
||||
fputs("}{} $\\langle\\,${\\itshape ", tex_file);
|
||||
/* Write the macro's name */
|
||||
|
||||
#line 2306 "nuweb.w"
|
||||
{
|
||||
char * p = name->spelling;
|
||||
int i = 0;
|
||||
@@ -208,17 +292,25 @@ void write_tex(file_name, tex_name, sector)
|
||||
fputc(*p++, tex_file);
|
||||
}
|
||||
}
|
||||
#line 2291 "nuweb.w"
|
||||
|
||||
fputs("}\\nobreak\\ {\\footnotesize {", tex_file);
|
||||
write_single_scrap_ref(tex_file, scraps);
|
||||
fputs("}}$\\,\\rangle\\equiv$\n", tex_file);
|
||||
/* Fill in the middle of the scrap environment */
|
||||
|
||||
#line 2387 "nuweb.w"
|
||||
{
|
||||
fputs("\\vspace{-1ex}\n\\begin{list}{}{} \\item\n", tex_file);
|
||||
extra_scraps = 0;
|
||||
copy_scrap(tex_file, TRUE, name);
|
||||
fputs("{\\NWsep}\n\\end{list}\n", tex_file);
|
||||
}
|
||||
#line 2295 "nuweb.w"
|
||||
|
||||
/* Begin the cross-reference environment */
|
||||
|
||||
#line 2433 "nuweb.w"
|
||||
{
|
||||
fputs("\\vspace{-1.5ex}\n", tex_file);
|
||||
fputs("\\footnotesize\n", tex_file);
|
||||
@@ -226,14 +318,22 @@ void write_tex(file_name, tex_name, sector)
|
||||
tex_file);
|
||||
fputs("\\setlength{\\itemindent}{-\\leftmargin}}\n", tex_file);}
|
||||
|
||||
#line 2296 "nuweb.w"
|
||||
|
||||
/* Write macro defs */
|
||||
|
||||
#line 2466 "nuweb.w"
|
||||
{
|
||||
if (name->defs->next) {
|
||||
fputs("\\item \\NWtxtMacroDefBy\\ ", tex_file);
|
||||
print_scrap_numbers(tex_file, name->defs);
|
||||
}
|
||||
}
|
||||
#line 2297 "nuweb.w"
|
||||
|
||||
/* Write macro refs */
|
||||
|
||||
#line 2474 "nuweb.w"
|
||||
{
|
||||
if (name->uses) {
|
||||
if (name->uses->next) {
|
||||
@@ -256,14 +356,22 @@ void write_tex(file_name, tex_name, sector)
|
||||
command_name, name->spelling);
|
||||
}
|
||||
}
|
||||
#line 2298 "nuweb.w"
|
||||
|
||||
format_defs_refs(tex_file, scraps);
|
||||
format_uses_refs(tex_file, scraps++);
|
||||
/* Finish the cross-reference environment */
|
||||
|
||||
#line 2446 "nuweb.w"
|
||||
{
|
||||
fputs("\n\\item{}", tex_file);
|
||||
fputs("\n\\end{list}\n", tex_file);
|
||||
}
|
||||
#line 2301 "nuweb.w"
|
||||
|
||||
/* Finish the scrap environment */
|
||||
|
||||
#line 2404 "nuweb.w"
|
||||
{
|
||||
scraps += extra_scraps;
|
||||
if (big_definition)
|
||||
@@ -271,37 +379,59 @@ void write_tex(file_name, tex_name, sector)
|
||||
else
|
||||
{
|
||||
/* End block */
|
||||
|
||||
#line 2377 "nuweb.w"
|
||||
fputs("\\end{minipage}\\vspace{4ex}\n", tex_file);
|
||||
fputs("\\end{flushleft}\n", tex_file);
|
||||
inBlock = FALSE;
|
||||
#line 2410 "nuweb.w"
|
||||
|
||||
}
|
||||
do
|
||||
c = source_get();
|
||||
while (isspace(c));
|
||||
}
|
||||
#line 2302 "nuweb.w"
|
||||
|
||||
}
|
||||
#line 2150 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 's':
|
||||
/* Step to next sector */
|
||||
|
||||
#line 1493 "nuweb.w"
|
||||
|
||||
prev_sector += 1;
|
||||
current_sector = prev_sector;
|
||||
c = source_get();
|
||||
|
||||
#line 2153 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'S':
|
||||
/* Close the current sector */
|
||||
|
||||
#line 1500 "nuweb.w"
|
||||
current_sector = 1;
|
||||
c = source_get();
|
||||
|
||||
#line 2156 "nuweb.w"
|
||||
|
||||
break;
|
||||
case '{':
|
||||
case '[':
|
||||
case '(': copy_scrap(tex_file, FALSE, NULL);
|
||||
case '(':
|
||||
#line 2426 "nuweb.w"
|
||||
copy_scrap(tex_file, FALSE, NULL);
|
||||
c = source_get();
|
||||
|
||||
#line 2160 "nuweb.w"
|
||||
|
||||
break;
|
||||
case '<': {
|
||||
case '<':
|
||||
#line 2192 "nuweb.w"
|
||||
{
|
||||
Parameters local_parameters = 0;
|
||||
int changed;
|
||||
char indent_chars[MAX_INDENT];
|
||||
@@ -318,36 +448,66 @@ void write_tex(file_name, tex_name, sector)
|
||||
c = source_get();
|
||||
}
|
||||
|
||||
#line 2162 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'x': {
|
||||
case 'x':
|
||||
#line 2749 "nuweb.w"
|
||||
{
|
||||
/* Get label from */
|
||||
|
||||
#line 6398 "nuweb.w"
|
||||
char label_name[MAX_NAME_LEN];
|
||||
char * p = label_name;
|
||||
while (c = source_get(), c != nw_char) /* Here is 150a-01 */
|
||||
while (c =
|
||||
#line 2750 "nuweb.w"
|
||||
source_get(), c != nw_char) /* Here is 148c-01 */
|
||||
*p++ = c;
|
||||
*p = '\0';
|
||||
c = source_get();
|
||||
c =
|
||||
#line 2750 "nuweb.w"
|
||||
source_get();
|
||||
|
||||
write_label(label_name, tex_file);
|
||||
#line 2750 "nuweb.w"
|
||||
|
||||
write_label(label_name,
|
||||
#line 2164 "nuweb.w"
|
||||
tex_file);
|
||||
}
|
||||
#line 2164 "nuweb.w"
|
||||
|
||||
c = source_get();
|
||||
break;
|
||||
case 'c': if (inBlock)
|
||||
case 'c':
|
||||
#line 1785 "nuweb.w"
|
||||
if (inBlock)
|
||||
{
|
||||
/* End block */
|
||||
|
||||
#line 2377 "nuweb.w"
|
||||
fputs("\\end{minipage}\\vspace{4ex}\n", tex_file);
|
||||
fputs("\\end{flushleft}\n", tex_file);
|
||||
inBlock = FALSE;
|
||||
#line 1787 "nuweb.w"
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Start block */
|
||||
|
||||
#line 2370 "nuweb.w"
|
||||
fputs("\\begin{flushleft} \\small\n\\begin{minipage}{\\linewidth}", tex_file);
|
||||
inBlock = TRUE;
|
||||
#line 1791 "nuweb.w"
|
||||
|
||||
}
|
||||
#line 2167 "nuweb.w"
|
||||
|
||||
c = source_get();
|
||||
break;
|
||||
case 'f': {
|
||||
case 'f':
|
||||
#line 2915 "nuweb.w"
|
||||
{
|
||||
if (file_names) {
|
||||
fputs("\n{\\small\\begin{list}{}{\\setlength{\\itemsep}{-\\parsep}",
|
||||
tex_file);
|
||||
@@ -357,8 +517,12 @@ void write_tex(file_name, tex_name, sector)
|
||||
}
|
||||
c = source_get();
|
||||
}
|
||||
#line 2170 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'm': {
|
||||
case 'm':
|
||||
#line 2965 "nuweb.w"
|
||||
{
|
||||
unsigned char sector = current_sector;
|
||||
int c = source_get();
|
||||
if (c == '+')
|
||||
@@ -377,8 +541,12 @@ void write_tex(file_name, tex_name, sector)
|
||||
}
|
||||
c = source_get();
|
||||
|
||||
#line 2172 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'u': {
|
||||
case 'u':
|
||||
#line 3118 "nuweb.w"
|
||||
{
|
||||
unsigned char sector = current_sector;
|
||||
c = source_get();
|
||||
if (c == '+') {
|
||||
@@ -393,10 +561,16 @@ void write_tex(file_name, tex_name, sector)
|
||||
fputs("\\end{list}}", tex_file);
|
||||
}
|
||||
}
|
||||
#line 2174 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'v': fputs(version_string, tex_file);
|
||||
case 'v':
|
||||
#line 2187 "nuweb.w"
|
||||
fputs(version_string, tex_file);
|
||||
c = source_get();
|
||||
|
||||
#line 2176 "nuweb.w"
|
||||
|
||||
break;
|
||||
default:
|
||||
if (c==nw_char)
|
||||
@@ -405,6 +579,8 @@ void write_tex(file_name, tex_name, sector)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#line 2125 "nuweb.w"
|
||||
|
||||
}
|
||||
else {
|
||||
putc(c, tex_file);
|
||||
@@ -412,11 +588,15 @@ void write_tex(file_name, tex_name, sector)
|
||||
}
|
||||
}
|
||||
}
|
||||
#line 2068 "nuweb.w"
|
||||
|
||||
fclose(tex_file);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "%s: can't open %s\n", command_name, tex_name);
|
||||
}
|
||||
|
||||
#line 2321 "nuweb.w"
|
||||
static void write_arg(FILE * tex_file, char * p)
|
||||
{
|
||||
fputs("\\hbox{\\slshape\\sffamily ", tex_file);
|
||||
@@ -439,9 +619,9 @@ static void write_arg(FILE * tex_file, char * p)
|
||||
|
||||
fputs("\\/}", tex_file);
|
||||
}
|
||||
static void print_scrap_numbers(tex_file, scraps)
|
||||
FILE *tex_file;
|
||||
Scrap_Node *scraps;
|
||||
|
||||
#line 2498 "nuweb.w"
|
||||
static void print_scrap_numbers(FILE *tex_file, Scrap_Node *scraps)
|
||||
{
|
||||
int page;
|
||||
fputs("\\NWlink{nuweb", tex_file);
|
||||
@@ -460,6 +640,8 @@ static void print_scrap_numbers(tex_file, scraps)
|
||||
}
|
||||
fputs(".\n", tex_file);
|
||||
}
|
||||
|
||||
#line 2535 "nuweb.w"
|
||||
static char *orig_delimit_scrap[3][5] = {
|
||||
/* {} mode: begin, end, insert nw_char, prefix, suffix */
|
||||
{ "\\verb@", "@", "@{\\tt @}\\verb@", "\\mbox{}", "\\\\" },
|
||||
@@ -470,6 +652,8 @@ static char *orig_delimit_scrap[3][5] = {
|
||||
};
|
||||
|
||||
static char *delimit_scrap[3][5];
|
||||
|
||||
#line 2554 "nuweb.w"
|
||||
void initialise_delimit_scrap_array() {
|
||||
int i,j;
|
||||
for(i = 0; i < 3; i++) {
|
||||
@@ -495,7 +679,11 @@ void initialise_delimit_scrap_array() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#line 2586 "nuweb.w"
|
||||
int scrap_type = 0;
|
||||
|
||||
#line 2590 "nuweb.w"
|
||||
static void write_literal(FILE * tex_file, char * p, int mode)
|
||||
{
|
||||
fputs(delimit_scrap[mode][0], tex_file);
|
||||
@@ -508,10 +696,9 @@ static void write_literal(FILE * tex_file, char * p, int mode)
|
||||
}
|
||||
fputs(delimit_scrap[mode][1], tex_file);
|
||||
}
|
||||
static void copy_scrap(file, prefix, name)
|
||||
FILE *file;
|
||||
int prefix;
|
||||
Name * name;
|
||||
|
||||
#line 2605 "nuweb.w"
|
||||
static void copy_scrap(FILE *file, int prefix, Name *name)
|
||||
{
|
||||
int indent = 0;
|
||||
int c;
|
||||
@@ -531,7 +718,9 @@ static void copy_scrap(file, prefix, name)
|
||||
fputs(delimit_scrap[scrap_type][0], file);
|
||||
indent = 0;
|
||||
break;
|
||||
case '\t': {
|
||||
case '\t':
|
||||
#line 2680 "nuweb.w"
|
||||
{
|
||||
int delta = 8 - (indent % 8);
|
||||
indent += delta;
|
||||
while (delta > 0) {
|
||||
@@ -539,41 +728,69 @@ static void copy_scrap(file, prefix, name)
|
||||
delta--;
|
||||
}
|
||||
}
|
||||
#line 2625 "nuweb.w"
|
||||
|
||||
break;
|
||||
default:
|
||||
if (c==nw_char)
|
||||
{
|
||||
/* Check at-sequence for end-of-scrap */
|
||||
|
||||
#line 2690 "nuweb.w"
|
||||
{
|
||||
c = source_get();
|
||||
switch (c) {
|
||||
case 'c': {
|
||||
case 'c':
|
||||
#line 1714 "nuweb.w"
|
||||
{
|
||||
fputs(delimit_scrap[scrap_type][1],file);
|
||||
fprintf(file, "\\hbox{\\sffamily\\slshape (Comment)}");
|
||||
fputs(delimit_scrap[scrap_type][0], file);
|
||||
}
|
||||
|
||||
#line 2693 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'x': {
|
||||
case 'x':
|
||||
#line 2749 "nuweb.w"
|
||||
{
|
||||
/* Get label from */
|
||||
|
||||
#line 6398 "nuweb.w"
|
||||
char label_name[MAX_NAME_LEN];
|
||||
char * p = label_name;
|
||||
while (c = source_get(), c != nw_char) /* Here is 150a-01 */
|
||||
while (c =
|
||||
#line 2750 "nuweb.w"
|
||||
source_get(), c != nw_char) /* Here is 148c-01 */
|
||||
*p++ = c;
|
||||
*p = '\0';
|
||||
c = source_get();
|
||||
c =
|
||||
#line 2750 "nuweb.w"
|
||||
source_get();
|
||||
|
||||
write_label(label_name, file);
|
||||
#line 2750 "nuweb.w"
|
||||
|
||||
write_label(label_name,
|
||||
#line 2695 "nuweb.w"
|
||||
file);
|
||||
}
|
||||
#line 2695 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'v': fputs(version_string, file);
|
||||
case 'v':
|
||||
#line 2745 "nuweb.w"
|
||||
fputs(version_string, file);
|
||||
|
||||
#line 2697 "nuweb.w"
|
||||
|
||||
case 's':
|
||||
break;
|
||||
case '+':
|
||||
case '-':
|
||||
case '*':
|
||||
case '|': {
|
||||
case '|':
|
||||
#line 2758 "nuweb.w"
|
||||
{
|
||||
do {
|
||||
do
|
||||
c = source_get();
|
||||
@@ -581,12 +798,16 @@ static void copy_scrap(file, prefix, name)
|
||||
c = source_get();
|
||||
} while (c != '}' && c != ']' && c != ')' );
|
||||
}
|
||||
#line 2703 "nuweb.w"
|
||||
|
||||
case ',':
|
||||
case ')':
|
||||
case ']':
|
||||
case '}': fputs(delimit_scrap[scrap_type][1], file);
|
||||
return;
|
||||
case '<': {
|
||||
case '<':
|
||||
#line 2798 "nuweb.w"
|
||||
{
|
||||
Arglist *args = collect_scrap_name(-1);
|
||||
Name *name = args->name;
|
||||
char * p = name->spelling;
|
||||
@@ -616,6 +837,8 @@ static void copy_scrap(file, prefix, name)
|
||||
if (scrap_name_has_parameters) {
|
||||
/* Format macro parameters */
|
||||
|
||||
#line 1962 "nuweb.w"
|
||||
|
||||
char sep;
|
||||
|
||||
sep = '(';
|
||||
@@ -642,10 +865,14 @@ static void copy_scrap(file, prefix, name)
|
||||
c = source_get();
|
||||
}
|
||||
|
||||
#line 2826 "nuweb.w"
|
||||
|
||||
}
|
||||
fprintf(file, "{\\footnotesize ");
|
||||
if (name->defs)
|
||||
/* Write abbreviated definition list */
|
||||
|
||||
#line 2844 "nuweb.w"
|
||||
{
|
||||
Scrap_Node *p = name->defs;
|
||||
fputs("\\NWlink{nuweb", file);
|
||||
@@ -657,6 +884,8 @@ static void copy_scrap(file, prefix, name)
|
||||
if (p)
|
||||
fputs(", \\ldots\\ ", file);
|
||||
}
|
||||
#line 2830 "nuweb.w"
|
||||
|
||||
else {
|
||||
putc('?', file);
|
||||
fprintf(stderr, "%s: never defined <%s>\n",
|
||||
@@ -667,14 +896,22 @@ static void copy_scrap(file, prefix, name)
|
||||
fputs("}", file);
|
||||
fputs(delimit_scrap[scrap_type][0], file);
|
||||
}
|
||||
#line 2709 "nuweb.w"
|
||||
|
||||
break;
|
||||
case '%': {
|
||||
case '%':
|
||||
#line 2768 "nuweb.w"
|
||||
{
|
||||
do
|
||||
c = source_get();
|
||||
while (c != '\n');
|
||||
}
|
||||
#line 2711 "nuweb.w"
|
||||
|
||||
break;
|
||||
case '_': {
|
||||
case '_':
|
||||
#line 2777 "nuweb.w"
|
||||
{
|
||||
fputs(delimit_scrap[scrap_type][1],file);
|
||||
fprintf(file, "\\hbox{\\sffamily\\bfseries ");
|
||||
c = source_get();
|
||||
@@ -686,18 +923,28 @@ static void copy_scrap(file, prefix, name)
|
||||
fprintf(file, "}");
|
||||
fputs(delimit_scrap[scrap_type][0], file);
|
||||
}
|
||||
#line 2713 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 't': {
|
||||
case 't':
|
||||
#line 2791 "nuweb.w"
|
||||
{
|
||||
fputs(delimit_scrap[scrap_type][1],file);
|
||||
fprintf(file, "\\hbox{\\sffamily\\slshape fragment title}");
|
||||
fputs(delimit_scrap[scrap_type][0], file);
|
||||
}
|
||||
#line 2715 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'f': {
|
||||
case 'f':
|
||||
#line 2791 "nuweb.w"
|
||||
{
|
||||
fputs(delimit_scrap[scrap_type][1],file);
|
||||
fprintf(file, "\\hbox{\\sffamily\\slshape file name}");
|
||||
fputs(delimit_scrap[scrap_type][0], file);
|
||||
}
|
||||
#line 2717 "nuweb.w"
|
||||
|
||||
break;
|
||||
case '1': case '2': case '3':
|
||||
case '4': case '5': case '6':
|
||||
@@ -723,6 +970,8 @@ static void copy_scrap(file, prefix, name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#line 2630 "nuweb.w"
|
||||
|
||||
break;
|
||||
}
|
||||
putc(c, file);
|
||||
@@ -732,6 +981,8 @@ static void copy_scrap(file, prefix, name)
|
||||
c = source_get();
|
||||
}
|
||||
}
|
||||
|
||||
#line 2646 "nuweb.w"
|
||||
void update_delimit_scrap()
|
||||
{
|
||||
/* {}-mode begin */
|
||||
@@ -759,6 +1010,8 @@ void update_delimit_scrap()
|
||||
/* ()-mode insert nw_char */
|
||||
delimit_scrap[2][2][0] = nw_char;
|
||||
}
|
||||
|
||||
#line 2857 "nuweb.w"
|
||||
static void
|
||||
write_ArglistElement(FILE * file, Arglist * args, char ** params)
|
||||
{
|
||||
@@ -801,6 +1054,8 @@ write_ArglistElement(FILE * file, Arglist * args, char ** params)
|
||||
|
||||
/* Format macro parameters */
|
||||
|
||||
#line 1962 "nuweb.w"
|
||||
|
||||
char sep;
|
||||
|
||||
sep = '(';
|
||||
@@ -827,10 +1082,14 @@ write_ArglistElement(FILE * file, Arglist * args, char ** params)
|
||||
c = source_get();
|
||||
}
|
||||
|
||||
#line 2897 "nuweb.w"
|
||||
|
||||
}
|
||||
fprintf(file, "{\\footnotesize ");
|
||||
if (name->defs)
|
||||
/* Write abbreviated definition list */
|
||||
|
||||
#line 2844 "nuweb.w"
|
||||
{
|
||||
Scrap_Node *p = name->defs;
|
||||
fputs("\\NWlink{nuweb", file);
|
||||
@@ -842,6 +1101,8 @@ write_ArglistElement(FILE * file, Arglist * args, char ** params)
|
||||
if (p)
|
||||
fputs(", \\ldots\\ ", file);
|
||||
}
|
||||
#line 2901 "nuweb.w"
|
||||
|
||||
else {
|
||||
putc('?', file);
|
||||
fprintf(stderr, "%s: never defined <%s>\n",
|
||||
@@ -850,17 +1111,21 @@ write_ArglistElement(FILE * file, Arglist * args, char ** params)
|
||||
fputs("}$\\,\\rangle$", file);
|
||||
}
|
||||
}
|
||||
static void format_file_entry(name, tex_file)
|
||||
Name *name;
|
||||
FILE *tex_file;
|
||||
|
||||
#line 2927 "nuweb.w"
|
||||
static void format_file_entry(Name *name, FILE *tex_file)
|
||||
{
|
||||
while (name) {
|
||||
format_file_entry(name->llink, tex_file);
|
||||
/* Format a file index entry */
|
||||
|
||||
#line 2938 "nuweb.w"
|
||||
fputs("\\item ", tex_file);
|
||||
fprintf(tex_file, "\\verb%c\"%s\"%c ", nw_char, name->spelling, nw_char);
|
||||
/* Write file's defining scrap numbers */
|
||||
{
|
||||
|
||||
#line 2944 "nuweb.w"
|
||||
{
|
||||
Scrap_Node *p = name->defs;
|
||||
fputs("{\\footnotesize {\\NWtxtDefBy}", tex_file);
|
||||
if (p->next) {
|
||||
@@ -879,10 +1144,16 @@ static void format_file_entry(name, tex_file)
|
||||
}
|
||||
putc('}', tex_file);
|
||||
}
|
||||
#line 2940 "nuweb.w"
|
||||
|
||||
putc('\n', tex_file);
|
||||
#line 2931 "nuweb.w"
|
||||
|
||||
name = name->rlink;
|
||||
}
|
||||
}
|
||||
|
||||
#line 2986 "nuweb.w"
|
||||
static int load_entry(Name * name, Name ** nms, int n)
|
||||
{
|
||||
while (name) {
|
||||
@@ -892,16 +1163,17 @@ static int load_entry(Name * name, Name ** nms, int n)
|
||||
}
|
||||
return n;
|
||||
}
|
||||
static void format_entry(name, tex_file, sector)
|
||||
Name *name;
|
||||
FILE *tex_file;
|
||||
unsigned char sector;
|
||||
|
||||
#line 2998 "nuweb.w"
|
||||
static void format_entry(Name *name, FILE *tex_file, unsigned char sector)
|
||||
{
|
||||
Name ** nms = malloc(num_scraps()*sizeof(Name *));
|
||||
int n = load_entry(name, nms, 0);
|
||||
int i;
|
||||
|
||||
/* Sort 'nms' of size 'n' for <Rob's ordering> */
|
||||
|
||||
#line 3018 "nuweb.w"
|
||||
int j;
|
||||
for (j = 1; j < n; j++)
|
||||
{
|
||||
@@ -912,7 +1184,9 @@ static void format_entry(name, tex_file, sector)
|
||||
{
|
||||
Name * ki = nms[i];
|
||||
|
||||
if (robs_strcmp(ki->spelling, kj->spelling) < 0)
|
||||
if (
|
||||
#line 3015 "nuweb.w"
|
||||
robs_strcmp(ki->spelling, kj->spelling) < 0)
|
||||
break;
|
||||
nms[i + 1] = ki;
|
||||
i -= 1;
|
||||
@@ -920,15 +1194,21 @@ static void format_entry(name, tex_file, sector)
|
||||
nms[i + 1] = kj;
|
||||
}
|
||||
|
||||
#line 3004 "nuweb.w"
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
Name * name = nms[i];
|
||||
|
||||
/* Format an index entry */
|
||||
|
||||
#line 3038 "nuweb.w"
|
||||
if (name->sector == sector){
|
||||
fputs("\\item ", tex_file);
|
||||
fputs("$\\langle\\,$", tex_file);
|
||||
/* Write the macro's name */
|
||||
|
||||
#line 2306 "nuweb.w"
|
||||
{
|
||||
char * p = name->spelling;
|
||||
int i = 0;
|
||||
@@ -942,8 +1222,12 @@ static void format_entry(name, tex_file, sector)
|
||||
fputc(*p++, tex_file);
|
||||
}
|
||||
}
|
||||
#line 3041 "nuweb.w"
|
||||
|
||||
fputs("\\nobreak\\ {\\footnotesize ", tex_file);
|
||||
/* Write defining scrap numbers */
|
||||
|
||||
#line 3050 "nuweb.w"
|
||||
{
|
||||
Scrap_Node *p = name->defs;
|
||||
if (p) {
|
||||
@@ -966,8 +1250,12 @@ static void format_entry(name, tex_file, sector)
|
||||
else
|
||||
putc('?', tex_file);
|
||||
}
|
||||
#line 3043 "nuweb.w"
|
||||
|
||||
fputs("}$\\,\\rangle$ ", tex_file);
|
||||
/* Write referencing scrap numbers */
|
||||
|
||||
#line 3074 "nuweb.w"
|
||||
{
|
||||
Scrap_Node *p = name->uses;
|
||||
fputs("{\\footnotesize ", tex_file);
|
||||
@@ -992,10 +1280,16 @@ static void format_entry(name, tex_file, sector)
|
||||
fputs("{\\NWtxtNoRef}.", tex_file);
|
||||
putc('}', tex_file);
|
||||
}
|
||||
#line 3045 "nuweb.w"
|
||||
|
||||
putc('\n', tex_file);
|
||||
}
|
||||
#line 3009 "nuweb.w"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#line 3104 "nuweb.w"
|
||||
int has_sector(Name * name, unsigned char sector)
|
||||
{
|
||||
while(name) {
|
||||
@@ -1007,14 +1301,15 @@ int has_sector(Name * name, unsigned char sector)
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
static void format_user_entry(name, tex_file, sector)
|
||||
Name *name;
|
||||
FILE *tex_file;
|
||||
unsigned char sector;
|
||||
|
||||
#line 3136 "nuweb.w"
|
||||
static void format_user_entry(Name *name, FILE *tex_file, unsigned char sector)
|
||||
{
|
||||
while (name) {
|
||||
format_user_entry(name->llink, tex_file, sector);
|
||||
/* Format a user index entry */
|
||||
|
||||
#line 3148 "nuweb.w"
|
||||
if (name->sector == sector){
|
||||
Scrap_Node *uses = name->uses;
|
||||
if ( uses || dangling_flag ) {
|
||||
@@ -1081,6 +1376,8 @@ static void format_user_entry(name, tex_file, sector)
|
||||
fputs(".\n", tex_file);
|
||||
}
|
||||
}
|
||||
#line 3140 "nuweb.w"
|
||||
|
||||
name = name->rlink;
|
||||
}
|
||||
}
|
||||
|
60
main.c
60
main.c
@@ -1,17 +1,25 @@
|
||||
|
||||
#line 878 "nuweb.w"
|
||||
#include "global.h"
|
||||
|
||||
#line 955 "nuweb.w"
|
||||
|
||||
#include <stdlib.h>
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int arg = 1;
|
||||
/* Interpret command-line arguments */
|
||||
|
||||
#line 1113 "nuweb.w"
|
||||
command_name = argv[0];
|
||||
|
||||
#line 1119 "nuweb.w"
|
||||
while (arg < argc) {
|
||||
char *s = argv[arg];
|
||||
if (*s++ == '-') {
|
||||
/* Interpret the argument string \verb|s| */
|
||||
|
||||
#line 1139 "nuweb.w"
|
||||
{
|
||||
char c = *s++;
|
||||
while (c) {
|
||||
@@ -56,8 +64,12 @@ int main(argc, argv)
|
||||
}
|
||||
HasValue:;
|
||||
}
|
||||
#line 1122 "nuweb.w"
|
||||
|
||||
arg++;
|
||||
/* Perhaps get the prepend path */
|
||||
|
||||
#line 1186 "nuweb.w"
|
||||
if (prepend_flag)
|
||||
{
|
||||
if (*s == '\0')
|
||||
@@ -66,7 +78,11 @@ HasValue:;
|
||||
prepend_flag = FALSE;
|
||||
}
|
||||
|
||||
#line 1124 "nuweb.w"
|
||||
|
||||
/* Perhaps get the version info string */
|
||||
|
||||
#line 1214 "nuweb.w"
|
||||
if (version_info_flag)
|
||||
{
|
||||
if (*s == '\0')
|
||||
@@ -75,7 +91,11 @@ HasValue:;
|
||||
version_info_flag = FALSE;
|
||||
}
|
||||
|
||||
#line 1125 "nuweb.w"
|
||||
|
||||
/* Perhaps get the hyperref options */
|
||||
|
||||
#line 1224 "nuweb.w"
|
||||
if (hyperopt_flag)
|
||||
{
|
||||
if (*s == '\0')
|
||||
@@ -85,7 +105,11 @@ HasValue:;
|
||||
hyperref_flag = TRUE;
|
||||
}
|
||||
|
||||
#line 1126 "nuweb.w"
|
||||
|
||||
/* Perhaps add an include path */
|
||||
|
||||
#line 1196 "nuweb.w"
|
||||
if (includepath_flag)
|
||||
{
|
||||
struct incl * le
|
||||
@@ -102,11 +126,17 @@ HasValue:;
|
||||
includepath_flag = FALSE;
|
||||
}
|
||||
|
||||
#line 1127 "nuweb.w"
|
||||
|
||||
}
|
||||
else break;
|
||||
}
|
||||
#line 960 "nuweb.w"
|
||||
|
||||
/* Set locale information */
|
||||
|
||||
#line 1240 "nuweb.w"
|
||||
|
||||
{
|
||||
/* try to get locale information */
|
||||
char *s=getenv("LC_CTYPE");
|
||||
@@ -118,8 +148,12 @@ HasValue:;
|
||||
fprintf(stderr, "Setting locale failed\n");
|
||||
}
|
||||
|
||||
#line 961 "nuweb.w"
|
||||
|
||||
initialise_delimit_scrap_array();
|
||||
/* Process the remaining arguments (file names) */
|
||||
|
||||
#line 1259 "nuweb.w"
|
||||
{
|
||||
if (arg >= argc) {
|
||||
fprintf(stderr, "%s: expected a file name. ", command_name);
|
||||
@@ -128,11 +162,15 @@ HasValue:;
|
||||
}
|
||||
do {
|
||||
/* Handle the file name in \verb|argv[arg]| */
|
||||
|
||||
#line 1281 "nuweb.w"
|
||||
{
|
||||
char source_name[FILENAME_MAX];
|
||||
char tex_name[FILENAME_MAX];
|
||||
char aux_name[FILENAME_MAX];
|
||||
/* Build \verb|source_name| and \verb|tex_name| */
|
||||
|
||||
#line 1304 "nuweb.w"
|
||||
{
|
||||
char *p = argv[arg];
|
||||
char *q = source_name;
|
||||
@@ -150,6 +188,8 @@ HasValue:;
|
||||
c = *p++;
|
||||
}
|
||||
/* Add the source path to the include path list */
|
||||
|
||||
#line 1344 "nuweb.w"
|
||||
if (trim != source_name) {
|
||||
struct incl * le
|
||||
= (struct incl *)arena_getmem(sizeof(struct incl));
|
||||
@@ -165,6 +205,8 @@ HasValue:;
|
||||
*trim = sv;
|
||||
}
|
||||
|
||||
#line 1320 "nuweb.w"
|
||||
|
||||
*q = '\0';
|
||||
if (dot) {
|
||||
*dot = '\0'; /* produce HTML when the file extension is ".hw" */
|
||||
@@ -181,7 +223,11 @@ HasValue:;
|
||||
*q = '\0';
|
||||
}
|
||||
}
|
||||
#line 1285 "nuweb.w"
|
||||
|
||||
/* Process a file */
|
||||
|
||||
#line 1370 "nuweb.w"
|
||||
{
|
||||
pass1(source_name);
|
||||
current_sector = 1;
|
||||
@@ -191,7 +237,7 @@ HasValue:;
|
||||
int saved_number_flag = number_flag;
|
||||
number_flag = TRUE;
|
||||
collect_numbers(aux_name);
|
||||
write_html(source_name, tex_name, 0/*Dummy */);
|
||||
write_html(source_name, tex_name);
|
||||
number_flag = saved_number_flag;
|
||||
}
|
||||
else {
|
||||
@@ -203,9 +249,15 @@ HasValue:;
|
||||
write_files(file_names);
|
||||
arena_free();
|
||||
}
|
||||
#line 1286 "nuweb.w"
|
||||
|
||||
}
|
||||
#line 1266 "nuweb.w"
|
||||
|
||||
arg++;
|
||||
} while (arg < argc);
|
||||
}
|
||||
#line 963 "nuweb.w"
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
167
names.c
167
names.c
@@ -1,9 +1,11 @@
|
||||
|
||||
#line 932 "nuweb.w"
|
||||
#include "global.h"
|
||||
|
||||
#line 5126 "nuweb.w"
|
||||
enum { LESS, GREATER, EQUAL, PREFIX, EXTENSION };
|
||||
|
||||
static int compare(x, y)
|
||||
char *x;
|
||||
char *y;
|
||||
static int compare(char *x, char *y)
|
||||
{
|
||||
int len, result;
|
||||
int xl = strlen(x);
|
||||
@@ -26,21 +28,22 @@ static int compare(x, y)
|
||||
}
|
||||
else return EQUAL;
|
||||
}
|
||||
char *save_string(s)
|
||||
char *s;
|
||||
|
||||
#line 5155 "nuweb.w"
|
||||
char *save_string(char *s)
|
||||
{
|
||||
char *new = (char *) arena_getmem((strlen(s) + 1) * sizeof(char));
|
||||
strcpy(new, s);
|
||||
return new;
|
||||
}
|
||||
static int ambiguous_prefix();
|
||||
|
||||
#line 5164 "nuweb.w"
|
||||
static int ambiguous_prefix(Name *node, char *spelling,
|
||||
unsigned char sector);
|
||||
|
||||
static char * found_name = NULL;
|
||||
|
||||
Name *prefix_add(rt, spelling, sector)
|
||||
Name **rt;
|
||||
char *spelling;
|
||||
unsigned char sector;
|
||||
Name *prefix_add(Name **rt, char *spelling, unsigned char sector)
|
||||
{
|
||||
Name *node = *rt;
|
||||
int cmp;
|
||||
@@ -64,18 +67,24 @@ Name *prefix_add(rt, spelling, sector)
|
||||
if (cmp == EXTENSION)
|
||||
node->spelling = save_string(spelling);
|
||||
return node;
|
||||
case PREFIX: {
|
||||
case PREFIX:
|
||||
#line 5207 "nuweb.w"
|
||||
{
|
||||
if (ambiguous_prefix(node->llink, spelling, sector) ||
|
||||
ambiguous_prefix(node->rlink, spelling, sector))
|
||||
fprintf(stderr,
|
||||
"%s: ambiguous prefix %c<%s...%c> (%s, line %d)\n",
|
||||
command_name, nw_char, spelling, nw_char, source_name, source_line);
|
||||
}
|
||||
#line 5193 "nuweb.w"
|
||||
|
||||
return node;
|
||||
}
|
||||
node = *rt;
|
||||
}
|
||||
/* Create new name entry */
|
||||
|
||||
#line 5330 "nuweb.w"
|
||||
{
|
||||
node = (Name *) arena_getmem(sizeof(Name));
|
||||
if (found_name && robs_strcmp(found_name, spelling) == 0)
|
||||
@@ -104,11 +113,12 @@ Name *prefix_add(rt, spelling, sector)
|
||||
*rt = node;
|
||||
return node;
|
||||
}
|
||||
#line 5198 "nuweb.w"
|
||||
|
||||
}
|
||||
static int ambiguous_prefix(node, spelling, sector)
|
||||
Name *node;
|
||||
char *spelling;
|
||||
unsigned char sector;
|
||||
|
||||
#line 5216 "nuweb.w"
|
||||
static int ambiguous_prefix(Name *node, char *spelling, unsigned char sector)
|
||||
{
|
||||
while (node) {
|
||||
switch (compare(node->spelling, spelling)) {
|
||||
@@ -131,6 +141,8 @@ static int ambiguous_prefix(node, spelling, sector)
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#line 5264 "nuweb.w"
|
||||
int robs_strcmp(char* x, char* y)
|
||||
{
|
||||
int cmp = 0;
|
||||
@@ -138,13 +150,21 @@ int robs_strcmp(char* x, char* y)
|
||||
for (; *x && *y; x++, y++)
|
||||
{
|
||||
/* Skip invisibles on 'x' */
|
||||
|
||||
#line 5298 "nuweb.w"
|
||||
if (*x == '|')
|
||||
x++;
|
||||
|
||||
#line 5270 "nuweb.w"
|
||||
|
||||
/* Skip invisibles on 'y' */
|
||||
|
||||
#line 5298 "nuweb.w"
|
||||
if (*y == '|')
|
||||
y++;
|
||||
|
||||
#line 5271 "nuweb.w"
|
||||
|
||||
if (*x == *y)
|
||||
continue;
|
||||
if (islower(*x) && toupper(*x) == *y)
|
||||
@@ -165,10 +185,9 @@ int robs_strcmp(char* x, char* y)
|
||||
return -2;
|
||||
return cmp;
|
||||
}
|
||||
Name *name_add(rt, spelling, sector)
|
||||
Name **rt;
|
||||
char *spelling;
|
||||
unsigned char sector;
|
||||
|
||||
#line 5303 "nuweb.w"
|
||||
Name *name_add(Name **rt, char *spelling, unsigned char sector)
|
||||
{
|
||||
Name *node = *rt;
|
||||
while (node) {
|
||||
@@ -190,6 +209,8 @@ Name *name_add(rt, spelling, sector)
|
||||
node = *rt;
|
||||
}
|
||||
/* Create new name entry */
|
||||
|
||||
#line 5330 "nuweb.w"
|
||||
{
|
||||
node = (Name *) arena_getmem(sizeof(Name));
|
||||
if (found_name && robs_strcmp(found_name, spelling) == 0)
|
||||
@@ -218,8 +239,12 @@ Name *name_add(rt, spelling, sector)
|
||||
*rt = node;
|
||||
return node;
|
||||
}
|
||||
#line 5324 "nuweb.w"
|
||||
|
||||
}
|
||||
Name *collect_file_name()
|
||||
|
||||
#line 5363 "nuweb.w"
|
||||
Name *collect_file_name(void)
|
||||
{
|
||||
Name *new_name;
|
||||
char name[MAX_NAME_LEN];
|
||||
@@ -241,6 +266,8 @@ Name *collect_file_name()
|
||||
/* File names are always global. */
|
||||
new_name = name_add(&file_names, name, 0);
|
||||
/* Handle optional per-file flags */
|
||||
|
||||
#line 5396 "nuweb.w"
|
||||
{
|
||||
while (1) {
|
||||
while (isspace(c))
|
||||
@@ -255,7 +282,9 @@ Name *collect_file_name()
|
||||
break;
|
||||
case 'i': new_name->indent_flag = FALSE;
|
||||
break;
|
||||
case 'c': c = source_get();
|
||||
case 'c':
|
||||
#line 5425 "nuweb.w"
|
||||
c = source_get();
|
||||
if (c == 'c')
|
||||
new_name->comment_flag = 1;
|
||||
else if (c == '+')
|
||||
@@ -266,6 +295,8 @@ Name *collect_file_name()
|
||||
fprintf(stderr, "%s: Unrecognised comment flag (%s, %d)\n",
|
||||
command_name, source_name, source_line);
|
||||
|
||||
#line 5410 "nuweb.w"
|
||||
|
||||
break;
|
||||
default : fprintf(stderr, "%s: unexpected per-file flag (%s, %d)\n",
|
||||
command_name, source_name, source_line);
|
||||
@@ -277,6 +308,8 @@ Name *collect_file_name()
|
||||
else break;
|
||||
}
|
||||
}
|
||||
#line 5384 "nuweb.w"
|
||||
|
||||
c2 = source_get();
|
||||
if (c != nw_char || (c2 != '{' && c2 != '(' && c2 != '[')) {
|
||||
fprintf(stderr, "%s: expected %c{, %c[, or %c( after file name (%s, %d)\n",
|
||||
@@ -285,7 +318,9 @@ Name *collect_file_name()
|
||||
}
|
||||
return new_name;
|
||||
}
|
||||
Name *collect_macro_name()
|
||||
|
||||
#line 5446 "nuweb.w"
|
||||
Name *collect_macro_name(void)
|
||||
{
|
||||
char name[MAX_NAME_LEN];
|
||||
char args[1000];
|
||||
@@ -312,7 +347,9 @@ Name *collect_macro_name()
|
||||
c = source_get();
|
||||
while (c == ' ' || c == '\t');
|
||||
break;
|
||||
case '\n': {
|
||||
case '\n':
|
||||
#line 5564 "nuweb.w"
|
||||
{
|
||||
do
|
||||
c = source_get();
|
||||
while (isspace(c));
|
||||
@@ -323,6 +360,8 @@ Name *collect_macro_name()
|
||||
exit(-1);
|
||||
}
|
||||
/* Cleanup and install name */
|
||||
|
||||
#line 5547 "nuweb.w"
|
||||
{
|
||||
if (p > name && p[-1] == ' ')
|
||||
p--;
|
||||
@@ -338,18 +377,26 @@ Name *collect_macro_name()
|
||||
*p = '\0';
|
||||
node = prefix_add(¯o_names, name, sector);
|
||||
}
|
||||
#line 5574 "nuweb.w"
|
||||
|
||||
return install_args(node, argc, arg);
|
||||
}
|
||||
#line 5473 "nuweb.w"
|
||||
|
||||
default:
|
||||
if (c==nw_char)
|
||||
{
|
||||
/* Check for terminating at-sequence and return name */
|
||||
|
||||
#line 5494 "nuweb.w"
|
||||
{
|
||||
c = source_get();
|
||||
switch (c) {
|
||||
case '(':
|
||||
case '[':
|
||||
case '{': {
|
||||
case '{':
|
||||
#line 5547 "nuweb.w"
|
||||
{
|
||||
if (p > name && p[-1] == ' ')
|
||||
p--;
|
||||
if (p - name > 3 && p[-1] == '.' && p[-2] == '.' && p[-3] == '.') {
|
||||
@@ -364,18 +411,26 @@ Name *collect_macro_name()
|
||||
*p = '\0';
|
||||
node = prefix_add(¯o_names, name, sector);
|
||||
}
|
||||
#line 5499 "nuweb.w"
|
||||
|
||||
return install_args(node, argc, arg);
|
||||
case '\'': arg[argc] = argp;
|
||||
case '\'':
|
||||
#line 5517 "nuweb.w"
|
||||
arg[argc] = argp;
|
||||
while ((c = source_get()) != EOF) {
|
||||
if (c==nw_char) {
|
||||
c2 = source_get();
|
||||
if (c2=='\'') {
|
||||
/* Make this argument */
|
||||
|
||||
#line 5540 "nuweb.w"
|
||||
if (argc < 9) {
|
||||
*argp++ = '\000';
|
||||
argc += 1;
|
||||
}
|
||||
|
||||
#line 5522 "nuweb.w"
|
||||
|
||||
c = source_get();
|
||||
break;
|
||||
}
|
||||
@@ -387,6 +442,8 @@ Name *collect_macro_name()
|
||||
}
|
||||
*p++ = ARG_CHR;
|
||||
|
||||
#line 5501 "nuweb.w"
|
||||
|
||||
break;
|
||||
default:
|
||||
if (c==nw_char)
|
||||
@@ -400,6 +457,8 @@ Name *collect_macro_name()
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
#line 5477 "nuweb.w"
|
||||
|
||||
break;
|
||||
}
|
||||
*p++ = c;
|
||||
@@ -412,6 +471,8 @@ Name *collect_macro_name()
|
||||
exit(-1);
|
||||
return NULL; /* unreachable return to avoid warnings on some compilers */
|
||||
}
|
||||
|
||||
#line 5583 "nuweb.w"
|
||||
Name *install_args(Name * name, int argc, char *arg[9])
|
||||
{
|
||||
int i;
|
||||
@@ -422,6 +483,8 @@ Name *install_args(Name * name, int argc, char *arg[9])
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
#line 5604 "nuweb.w"
|
||||
Arglist * buildArglist(Name * name, Arglist * a)
|
||||
{
|
||||
Arglist * args = (Arglist *)arena_getmem(sizeof(Arglist));
|
||||
@@ -431,6 +494,8 @@ Arglist * buildArglist(Name * name, Arglist * a)
|
||||
args->name = name;
|
||||
return args;
|
||||
}
|
||||
|
||||
#line 5617 "nuweb.w"
|
||||
Arglist * collect_scrap_name(int current_scrap)
|
||||
{
|
||||
char name[MAX_NAME_LEN];
|
||||
@@ -459,6 +524,8 @@ Arglist * collect_scrap_name(int current_scrap)
|
||||
if (c==nw_char)
|
||||
{
|
||||
/* Look for end of scrap name and return */
|
||||
|
||||
#line 5666 "nuweb.w"
|
||||
{
|
||||
Name * node;
|
||||
|
||||
@@ -467,6 +534,8 @@ Arglist * collect_scrap_name(int current_scrap)
|
||||
|
||||
case '\'': {
|
||||
/* Add plain string argument */
|
||||
|
||||
#line 5723 "nuweb.w"
|
||||
char buff[MAX_NAME_LEN];
|
||||
char * s = buff;
|
||||
int c, c2;
|
||||
@@ -483,9 +552,15 @@ Arglist * collect_scrap_name(int current_scrap)
|
||||
}
|
||||
*s = '\000';
|
||||
/* Add buff to current arg list */
|
||||
*tail = buildArglist(NULL, (Arglist *)save_string(buff));
|
||||
|
||||
#line 5774 "nuweb.w"
|
||||
*tail = buildArglist(NULL, (Arglist *)save_string(buff));
|
||||
tail = &(*tail)->next;
|
||||
|
||||
#line 5738 "nuweb.w"
|
||||
|
||||
#line 5673 "nuweb.w"
|
||||
|
||||
}
|
||||
*p++ = ARG_CHR;
|
||||
c = source_get();
|
||||
@@ -494,20 +569,30 @@ Arglist * collect_scrap_name(int current_scrap)
|
||||
case '4': case '5': case '6':
|
||||
case '7': case '8': case '9': {
|
||||
/* Add a propagated argument */
|
||||
|
||||
#line 5744 "nuweb.w"
|
||||
char buff[3];
|
||||
buff[0] = ARG_CHR;
|
||||
buff[1] = c;
|
||||
buff[2] = '\000';
|
||||
/* Add buff to current arg list */
|
||||
*tail = buildArglist(NULL, (Arglist *)save_string(buff));
|
||||
|
||||
#line 5774 "nuweb.w"
|
||||
*tail = buildArglist(NULL, (Arglist *)save_string(buff));
|
||||
tail = &(*tail)->next;
|
||||
|
||||
#line 5748 "nuweb.w"
|
||||
|
||||
#line 5681 "nuweb.w"
|
||||
|
||||
}
|
||||
*p++ = ARG_CHR;
|
||||
c = source_get();
|
||||
break;
|
||||
case '{': {
|
||||
/* Add an inline scrap argument */
|
||||
|
||||
#line 5751 "nuweb.w"
|
||||
int s = collect_scrap();
|
||||
Scrap_Node * d = (Scrap_Node *)arena_getmem(sizeof(Scrap_Node));
|
||||
d->scrap = s;
|
||||
@@ -515,23 +600,31 @@ Arglist * collect_scrap_name(int current_scrap)
|
||||
d->next = NULL;
|
||||
*tail = buildArglist((Name *)1, (Arglist *)d);
|
||||
tail = &(*tail)->next;
|
||||
#line 5687 "nuweb.w"
|
||||
|
||||
}
|
||||
*p++ = ARG_CHR;
|
||||
c = source_get();
|
||||
break;
|
||||
case '<':
|
||||
/* Add macro call argument */
|
||||
|
||||
#line 5767 "nuweb.w"
|
||||
*tail = collect_scrap_name(current_scrap);
|
||||
if (current_scrap >= 0)
|
||||
add_to_use((*tail)->name, current_scrap);
|
||||
tail = &(*tail)->next;
|
||||
|
||||
#line 5693 "nuweb.w"
|
||||
|
||||
*p++ = ARG_CHR;
|
||||
c = source_get();
|
||||
break;
|
||||
case '(':
|
||||
scrap_name_has_parameters = 1;
|
||||
/* Cleanup and install name */
|
||||
|
||||
#line 5547 "nuweb.w"
|
||||
{
|
||||
if (p > name && p[-1] == ' ')
|
||||
p--;
|
||||
@@ -547,10 +640,14 @@ Arglist * collect_scrap_name(int current_scrap)
|
||||
*p = '\0';
|
||||
node = prefix_add(¯o_names, name, sector);
|
||||
}
|
||||
#line 5699 "nuweb.w"
|
||||
|
||||
return buildArglist(node, head);
|
||||
case '>':
|
||||
scrap_name_has_parameters = 0;
|
||||
/* Cleanup and install name */
|
||||
|
||||
#line 5547 "nuweb.w"
|
||||
{
|
||||
if (p > name && p[-1] == ' ')
|
||||
p--;
|
||||
@@ -566,6 +663,8 @@ Arglist * collect_scrap_name(int current_scrap)
|
||||
*p = '\0';
|
||||
node = prefix_add(¯o_names, name, sector);
|
||||
}
|
||||
#line 5703 "nuweb.w"
|
||||
|
||||
return buildArglist(node, head);
|
||||
|
||||
default:
|
||||
@@ -581,6 +680,8 @@ Arglist * collect_scrap_name(int current_scrap)
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
#line 5644 "nuweb.w"
|
||||
|
||||
break;
|
||||
}
|
||||
if (!isgraph(c)) {
|
||||
@@ -599,10 +700,11 @@ Arglist * collect_scrap_name(int current_scrap)
|
||||
exit(-1);
|
||||
return NULL; /* unreachable return to avoid warnings on some compilers */
|
||||
}
|
||||
static Scrap_Node *reverse(); /* a forward declaration */
|
||||
|
||||
void reverse_lists(names)
|
||||
Name *names;
|
||||
#line 5779 "nuweb.w"
|
||||
static Scrap_Node *reverse(Scrap_Node *a); /* a forward declaration */
|
||||
|
||||
void reverse_lists(Name *names)
|
||||
{
|
||||
while (names) {
|
||||
reverse_lists(names->llink);
|
||||
@@ -611,8 +713,9 @@ void reverse_lists(names)
|
||||
names = names->rlink;
|
||||
}
|
||||
}
|
||||
static Scrap_Node *reverse(a)
|
||||
Scrap_Node *a;
|
||||
|
||||
#line 5796 "nuweb.w"
|
||||
static Scrap_Node *reverse(Scrap_Node *a)
|
||||
{
|
||||
if (a) {
|
||||
Scrap_Node *b = a->next;
|
||||
|
301
nuweb.w
301
nuweb.w
@@ -954,9 +954,7 @@ then handles any files listed on the command line.
|
||||
@o main.c -cc -d
|
||||
@{
|
||||
#include <stdlib.h>
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int arg = 1;
|
||||
@<Interpret command-line arguments@>
|
||||
@@ -1378,7 +1376,7 @@ is forced when generating HTML.
|
||||
int saved_number_flag = number_flag;
|
||||
number_flag = TRUE;
|
||||
collect_numbers(aux_name);
|
||||
write_html(source_name, tex_name, 0/*Dummy */);
|
||||
write_html(source_name, tex_name);
|
||||
number_flag = saved_number_flag;
|
||||
}
|
||||
else {
|
||||
@@ -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.
|
||||
|
||||
@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
|
||||
cross-reference lists accumulated while scanning the scraps.
|
||||
@o pass1.c -cc -d
|
||||
@{void pass1(file_name)
|
||||
char *file_name;
|
||||
@{void pass1(char *file_name)
|
||||
{
|
||||
if (verbose_flag)
|
||||
fprintf(stderr, "reading %s\n", file_name);
|
||||
@@ -1814,7 +1811,7 @@ Fragment parameters were added on later in nuweb's development.
|
||||
There still is not, for example, an index of fragment parameters.
|
||||
We need a data type to keep track of fragment parameters.
|
||||
|
||||
@o global.h -cc -d
|
||||
@d Type decl...
|
||||
@{typedef int *Parameters;
|
||||
@| Parameters @}
|
||||
|
||||
@@ -2034,31 +2031,33 @@ modify nuweb to work with a different typesetting system, this would
|
||||
be the place to look.
|
||||
|
||||
@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
|
||||
of \verb|write_tex|.
|
||||
|
||||
@o latex.c -cc -d
|
||||
@{static void copy_scrap(); /* formats the body of a scrap */
|
||||
static void print_scrap_numbers(); /* formats a list of scrap numbers */
|
||||
static void format_entry(); /* formats an index entry */
|
||||
static void format_file_entry(); /* formats a file index entry */
|
||||
static void format_user_entry();
|
||||
static void write_arg();
|
||||
static void write_literal();
|
||||
static void write_ArglistElement();
|
||||
@{static void copy_scrap(FILE *file, int prefix, Name *name);
|
||||
/* formats the body of a scrap */
|
||||
static void print_scrap_numbers(FILE *tex_file, Scrap_Node *scraps);
|
||||
/* formats a list of scrap numbers */
|
||||
static void format_entry(Name *name, FILE *tex_file, unsigned char sector);
|
||||
/* formats an index entry */
|
||||
static void format_file_entry(Name *name, FILE *tex_file);
|
||||
/* 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
|
||||
name of the web source file and the name of the \verb|.tex| output file.
|
||||
@o latex.c -cc -d
|
||||
@{void write_tex(file_name, tex_name, sector)
|
||||
char *file_name;
|
||||
char *tex_name;
|
||||
unsigned char sector;
|
||||
@{void write_tex(char *file_name, char *tex_name)
|
||||
{
|
||||
FILE *tex_file = fopen(tex_name, "w");
|
||||
if (tex_file) {
|
||||
@@ -2496,9 +2495,7 @@ list.
|
||||
}@}
|
||||
|
||||
@o latex.c -cc -d
|
||||
@{static void print_scrap_numbers(tex_file, scraps)
|
||||
FILE *tex_file;
|
||||
Scrap_Node *scraps;
|
||||
@{static void print_scrap_numbers(FILE *tex_file, Scrap_Node *scraps)
|
||||
{
|
||||
int page;
|
||||
fputs("\\NWlink{nuweb", tex_file);
|
||||
@@ -2605,10 +2602,7 @@ command.
|
||||
@| write_literal @}
|
||||
|
||||
@o latex.c -cc -d
|
||||
@{static void copy_scrap(file, prefix, name)
|
||||
FILE *file;
|
||||
int prefix;
|
||||
Name * name;
|
||||
@{static void copy_scrap(FILE *file, int prefix, Name *name)
|
||||
{
|
||||
int indent = 0;
|
||||
int c;
|
||||
@@ -2930,9 +2924,7 @@ write_ArglistElement(FILE * file, Arglist * args, char ** params)
|
||||
}@}
|
||||
|
||||
@o latex.c -cc -d
|
||||
@{static void format_file_entry(name, tex_file)
|
||||
Name *name;
|
||||
FILE *tex_file;
|
||||
@{static void format_file_entry(Name *name, FILE *tex_file)
|
||||
{
|
||||
while (name) {
|
||||
format_file_entry(name->llink, tex_file);
|
||||
@@ -3003,10 +2995,7 @@ c = source_get();
|
||||
@| load_entry @}
|
||||
|
||||
@o latex.c -cc -d
|
||||
@{static void format_entry(name, tex_file, sector)
|
||||
Name *name;
|
||||
FILE *tex_file;
|
||||
unsigned char sector;
|
||||
@{static void format_entry(Name *name, FILE *tex_file, unsigned char sector)
|
||||
{
|
||||
Name ** nms = malloc(num_scraps()*sizeof(Name *));
|
||||
int n = load_entry(name, nms, 0);
|
||||
@@ -3144,10 +3133,7 @@ for (j = 1; j < @2; j++)
|
||||
|
||||
|
||||
@o latex.c -cc -d
|
||||
@{static void format_user_entry(name, tex_file, sector)
|
||||
Name *name;
|
||||
FILE *tex_file;
|
||||
unsigned char sector;
|
||||
@{static void format_user_entry(Name *name, FILE *tex_file, unsigned char sector)
|
||||
{
|
||||
while (name) {
|
||||
format_user_entry(name->llink, tex_file, sector);
|
||||
@@ -3238,28 +3224,31 @@ copies most of the text from the source file straight into a
|
||||
cross-reference information is printed out.
|
||||
|
||||
@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
|
||||
of \verb|write_html|.
|
||||
|
||||
@o html.c
|
||||
@{static void copy_scrap(); /* formats the body of a scrap */
|
||||
static void display_scrap_ref(); /* formats a scrap reference */
|
||||
static void display_scrap_numbers(); /* formats a list of scrap numbers */
|
||||
static void print_scrap_numbers(); /* pluralizes scrap formats list */
|
||||
static void format_entry(); /* formats an index entry */
|
||||
static void format_user_entry();
|
||||
@{static void copy_scrap(FILE *file, int prefix);
|
||||
/* formats the body of a scrap */
|
||||
static void display_scrap_ref(FILE *html_file, int num);
|
||||
/* formats a scrap reference */
|
||||
static void display_scrap_numbers(FILE *html_file, Scrap_Node *scraps);
|
||||
/* 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
|
||||
name of the web source file and the name of the \verb|.tex| output file.
|
||||
@o html.c
|
||||
@{void write_html(file_name, html_name)
|
||||
char *file_name;
|
||||
char *html_name;
|
||||
@{void write_html(char *file_name, char *html_name)
|
||||
{
|
||||
FILE *html_file = fopen(html_name, "w");
|
||||
FILE *tex_file = html_file;
|
||||
@@ -3472,9 +3461,7 @@ end the paragraph.
|
||||
}@}
|
||||
|
||||
@o html.c
|
||||
@{static void display_scrap_ref(html_file, num)
|
||||
FILE *html_file;
|
||||
int num;
|
||||
@{static void display_scrap_ref(FILE *html_file, int num)
|
||||
{
|
||||
fputs("<a href=\"#nuweb", html_file);
|
||||
write_single_scrap_ref(html_file, num);
|
||||
@@ -3485,9 +3472,7 @@ end the paragraph.
|
||||
@| display_scrap_ref @}
|
||||
|
||||
@o html.c
|
||||
@{static void display_scrap_numbers(html_file, scraps)
|
||||
FILE *html_file;
|
||||
Scrap_Node *scraps;
|
||||
@{static void display_scrap_numbers(FILE *html_file, Scrap_Node *scraps)
|
||||
{
|
||||
display_scrap_ref(html_file, scraps->scrap);
|
||||
scraps = scraps->next;
|
||||
@@ -3500,9 +3485,7 @@ end the paragraph.
|
||||
@| display_scrap_numbers @}
|
||||
|
||||
@o html.c
|
||||
@{static void print_scrap_numbers(html_file, scraps)
|
||||
FILE *html_file;
|
||||
Scrap_Node *scraps;
|
||||
@{static void print_scrap_numbers(FILE *html_file, Scrap_Node *scraps)
|
||||
{
|
||||
display_scrap_numbers(html_file, scraps);
|
||||
fputs(".\n", html_file);
|
||||
@@ -3515,9 +3498,7 @@ end the paragraph.
|
||||
We must translate HTML special keywords into entities in scraps.
|
||||
|
||||
@o html.c
|
||||
@{static void copy_scrap(file, prefix)
|
||||
FILE *file;
|
||||
int prefix;
|
||||
@{static void copy_scrap(FILE *file, int prefix)
|
||||
{
|
||||
int indent = 0;
|
||||
int c = source_get();
|
||||
@@ -3660,10 +3641,7 @@ pointed out any during the first pass.
|
||||
}@}
|
||||
|
||||
@o html.c
|
||||
@{static void format_entry(name, html_file, file_flag)
|
||||
Name *name;
|
||||
FILE *html_file;
|
||||
int file_flag;
|
||||
@{static void format_entry(Name *name, FILE *html_file, int file_flag)
|
||||
{
|
||||
while (name) {
|
||||
format_entry(name->llink, html_file, file_flag);
|
||||
@@ -3732,10 +3710,7 @@ pointed out any during the first pass.
|
||||
|
||||
|
||||
@o html.c
|
||||
@{static void format_user_entry(name, html_file, sector)
|
||||
Name *name;
|
||||
FILE *html_file;
|
||||
int sector;
|
||||
@{static void format_user_entry(Name *name, FILE *html_file, int sector)
|
||||
{
|
||||
while (name) {
|
||||
format_user_entry(name->llink, html_file, sector);
|
||||
@@ -3786,12 +3761,11 @@ pointed out any during the first pass.
|
||||
\section{Writing the Output Files} \label{output-files}
|
||||
|
||||
@d Function pro...
|
||||
@{extern void write_files();
|
||||
@{extern void write_files(Name *files);
|
||||
@}
|
||||
|
||||
@o output.c -cc -d
|
||||
@{void write_files(files)
|
||||
Name *files;
|
||||
@{void write_files(Name *files)
|
||||
{
|
||||
while (files) {
|
||||
write_files(files->llink);
|
||||
@@ -3912,8 +3886,10 @@ if (0 != rename(temp_name, real_name)) {
|
||||
|
||||
We need two routines to handle reading the source files.
|
||||
@d Function pro...
|
||||
@{extern void source_open(); /* pass in the name of the source file */
|
||||
extern int source_get(); /* no args; returns the next char or EOF */
|
||||
@{extern void source_open(char *name);
|
||||
/* 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_peek; /* The next character to get */
|
||||
@}
|
||||
@@ -3962,7 +3938,7 @@ are defining.
|
||||
@{
|
||||
int source_peek;
|
||||
int source_last;
|
||||
int source_get()
|
||||
int source_get(void)
|
||||
{
|
||||
int c;
|
||||
source_last = c = source_peek;
|
||||
@@ -4128,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
|
||||
\verb|source_name|, \verb|source_line|, and \verb|double_at|.
|
||||
@o input.c -cc -d
|
||||
@{void source_open(name)
|
||||
char *name;
|
||||
@{void source_open(char *name)
|
||||
{
|
||||
source_file = fopen(name, "r");
|
||||
if (!source_file) {
|
||||
@@ -4186,7 +4161,7 @@ static ScrapEntry *SCRAP[SCRAP_SIZE];
|
||||
#define scrap_array(i) SCRAP[(i) >> SCRAP_SHIFT][(i) & SCRAP_MASK]
|
||||
|
||||
static int scraps;
|
||||
int num_scraps()
|
||||
int num_scraps(void)
|
||||
{
|
||||
return scraps;
|
||||
};
|
||||
@@ -4195,17 +4170,22 @@ int num_scraps()
|
||||
|
||||
|
||||
@d Function pro...
|
||||
@{extern void init_scraps();
|
||||
extern int collect_scrap();
|
||||
extern int write_scraps();
|
||||
extern void write_scrap_ref();
|
||||
extern void write_single_scrap_ref();
|
||||
extern int num_scraps();
|
||||
@{extern void init_scraps(void);
|
||||
extern int collect_scrap(void);
|
||||
extern int write_scraps(FILE *file, char *spelling, 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);
|
||||
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
|
||||
@{void init_scraps()
|
||||
@{void init_scraps(void)
|
||||
{
|
||||
scraps = 1;
|
||||
SCRAP[0] = (ScrapEntry *) arena_getmem(SCRAP_SIZE * sizeof(ScrapEntry));
|
||||
@@ -4213,11 +4193,7 @@ extern int num_scraps();
|
||||
@| init_scraps @}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{void write_scrap_ref(file, num, first, page)
|
||||
FILE *file;
|
||||
int num;
|
||||
int first;
|
||||
int *page;
|
||||
@{void write_scrap_ref(FILE *file, int num, int first, int *page)
|
||||
{
|
||||
if (scrap_array(num).page >= 0) {
|
||||
if (first!=0)
|
||||
@@ -4240,9 +4216,7 @@ extern int num_scraps();
|
||||
@| write_scrap_ref @}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{void write_single_scrap_ref(file, num)
|
||||
FILE *file;
|
||||
int num;
|
||||
@{void write_single_scrap_ref(FILE *file, int num)
|
||||
{
|
||||
int page;
|
||||
write_scrap_ref(file, num, TRUE, &page);
|
||||
@@ -4278,9 +4252,7 @@ extern int num_scraps();
|
||||
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{static void push(c, manager)
|
||||
char c;
|
||||
Manager *manager;
|
||||
@{static void push(char c, Manager *manager)
|
||||
{
|
||||
Slab *scrap = manager->scrap;
|
||||
int index = manager->index;
|
||||
@@ -4296,9 +4268,7 @@ extern int num_scraps();
|
||||
@| push @}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{static void pushs(s, manager)
|
||||
char *s;
|
||||
Manager *manager;
|
||||
@{static void pushs(char *s, Manager *manager)
|
||||
{
|
||||
while (*s)
|
||||
push(*s++, manager);
|
||||
@@ -4306,7 +4276,7 @@ extern int num_scraps();
|
||||
@| pushs @}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{int collect_scrap()
|
||||
@{int collect_scrap(void)
|
||||
{
|
||||
int current_scrap, lblseq = 0;
|
||||
int depth = 1;
|
||||
@@ -4531,8 +4501,7 @@ add_to_use(Name * name, int current_scrap)
|
||||
@{extern void add_to_use(Name * name, int current_scrap);
|
||||
@}
|
||||
@o scraps.c -cc -d
|
||||
@{static char pop(manager)
|
||||
Manager *manager;
|
||||
@{static char pop(Manager *manager)
|
||||
{
|
||||
Slab *scrap = manager->scrap;
|
||||
int index = manager->index;
|
||||
@@ -4548,9 +4517,7 @@ add_to_use(Name * name, int current_scrap)
|
||||
@| pop @}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{static void backup(n, manager)
|
||||
int n;
|
||||
Manager *manager;
|
||||
@{static void backup(int n, Manager *manager)
|
||||
{
|
||||
int index = manager->index;
|
||||
if (n > index
|
||||
@@ -4605,7 +4572,7 @@ lookup(int n, Arglist * par, char * arg[9], Name **name, Arglist ** args)
|
||||
@| instance @}
|
||||
|
||||
@d Function prototypes
|
||||
@{Arglist * instance();
|
||||
@{extern Arglist *instance(Arglist *a, Arglist *par, char *arg[9], int *ch);
|
||||
@}
|
||||
|
||||
@d Set up name, args and next
|
||||
@@ -4637,9 +4604,7 @@ a->args = args;
|
||||
a->next = next;@}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{static Arglist *pop_scrap_name(manager, parameters)
|
||||
Manager *manager;
|
||||
Parameters *parameters;
|
||||
@{static Arglist *pop_scrap_name(Manager *manager, Parameters *parameters)
|
||||
{
|
||||
char name[MAX_NAME_LEN];
|
||||
char *p = name;
|
||||
@@ -4672,22 +4637,11 @@ a->next = next;@}
|
||||
}@}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{int write_scraps(file, spelling, defs, global_indent, indent_chars,
|
||||
debug_flag, tab_flag, indent_flag,
|
||||
comment_flag, inArgs, inParams, parameters, title)
|
||||
FILE *file;
|
||||
char * spelling;
|
||||
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;
|
||||
@{int write_scraps(FILE *file, char *spelling, 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 */
|
||||
int indent = 0;
|
||||
@@ -5000,7 +4954,8 @@ comment_ArglistElement(FILE * file, Arglist * args, int quote)
|
||||
@d Include an embedded scrap in comment
|
||||
@{Embed_Node * e = (Embed_Node *)q;
|
||||
fputc('{', file);
|
||||
write_scraps(file, "", e->defs, -1, "", 0, 0, 0, 0, e->args, 0, 1, "");
|
||||
write_scraps(file, "", e->defs, -1, "", 0, 0, 0, 0, e->args, 0,
|
||||
(Parameters)1, "");
|
||||
fputc('}', file);@}
|
||||
|
||||
@d Include a fragment use in comment
|
||||
@@ -5026,12 +4981,11 @@ fputc('>', file);@}
|
||||
\subsection{Collecting Page Numbers}
|
||||
|
||||
@d Function...
|
||||
@{extern void collect_numbers();
|
||||
@{extern void collect_numbers(char *aux_name);
|
||||
@}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{void collect_numbers(aux_name)
|
||||
char *aux_name;
|
||||
@{void collect_numbers(char *aux_name)
|
||||
{
|
||||
if (number_flag) {
|
||||
int i;
|
||||
@@ -5159,21 +5113,19 @@ int scrap_ended_with;
|
||||
@}
|
||||
|
||||
@d Function pro...
|
||||
@{extern Name *collect_file_name();
|
||||
extern Name *collect_macro_name();
|
||||
extern Arglist *collect_scrap_name();
|
||||
extern Name *name_add();
|
||||
extern Name *prefix_add();
|
||||
extern char *save_string();
|
||||
extern void reverse_lists();
|
||||
@{extern Name *collect_file_name(void);
|
||||
extern Name *collect_macro_name(void);
|
||||
extern Arglist *collect_scrap_name(int current_scrap);
|
||||
extern Name *name_add(Name **rt, char *spelling, unsigned char sector);
|
||||
extern Name *prefix_add(Name **rt, char *spelling, unsigned char sector);
|
||||
extern char *save_string(char *);
|
||||
extern void reverse_lists(Name *names);
|
||||
@}
|
||||
|
||||
@o names.c -cc -d
|
||||
@{enum { LESS, GREATER, EQUAL, PREFIX, EXTENSION };
|
||||
|
||||
static int compare(x, y)
|
||||
char *x;
|
||||
char *y;
|
||||
static int compare(char *x, char *y)
|
||||
{
|
||||
int len, result;
|
||||
int xl = strlen(x);
|
||||
@@ -5200,8 +5152,7 @@ static int compare(x, y)
|
||||
|
||||
|
||||
@o names.c -cc -d
|
||||
@{char *save_string(s)
|
||||
char *s;
|
||||
@{char *save_string(char *s)
|
||||
{
|
||||
char *new = (char *) arena_getmem((strlen(s) + 1) * sizeof(char));
|
||||
strcpy(new, s);
|
||||
@@ -5210,14 +5161,12 @@ static int compare(x, y)
|
||||
@| save_string @}
|
||||
|
||||
@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;
|
||||
|
||||
Name *prefix_add(rt, spelling, sector)
|
||||
Name **rt;
|
||||
char *spelling;
|
||||
unsigned char sector;
|
||||
Name *prefix_add(Name **rt, char *spelling, unsigned char sector)
|
||||
{
|
||||
Name *node = *rt;
|
||||
int cmp;
|
||||
@@ -5264,10 +5213,7 @@ continue the search down {\em both\/} branches of the tree.
|
||||
}@}
|
||||
|
||||
@o names.c -cc -d
|
||||
@{static int ambiguous_prefix(node, spelling, sector)
|
||||
Name *node;
|
||||
char *spelling;
|
||||
unsigned char sector;
|
||||
@{static int ambiguous_prefix(Name *node, char *spelling, unsigned char sector)
|
||||
{
|
||||
while (node) {
|
||||
switch (compare(node->spelling, spelling)) {
|
||||
@@ -5354,10 +5300,7 @@ them to be considered for the alphabetical ordering.
|
||||
@}
|
||||
|
||||
@o names.c -cc -d
|
||||
@{Name *name_add(rt, spelling, sector)
|
||||
Name **rt;
|
||||
char *spelling;
|
||||
unsigned char sector;
|
||||
@{Name *name_add(Name **rt, char *spelling, unsigned char sector)
|
||||
{
|
||||
Name *node = *rt;
|
||||
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
|
||||
skipping white space until we reach scrap.
|
||||
@o names.c -cc -d
|
||||
@{Name *collect_file_name()
|
||||
@{Name *collect_file_name(void)
|
||||
{
|
||||
Name *new_name;
|
||||
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+@@{+
|
||||
@o names.c -cc -d
|
||||
@{Name *collect_macro_name()
|
||||
@{Name *collect_macro_name(void)
|
||||
{
|
||||
char name[MAX_NAME_LEN];
|
||||
char args[1000];
|
||||
@@ -5633,7 +5576,7 @@ while ((c = source_get()) != EOF) {
|
||||
}@}
|
||||
|
||||
@d Function prototypes
|
||||
@{extern Name *install_args();
|
||||
@{extern Name *install_args(Name * name, int argc, char *arg[0]);
|
||||
@}
|
||||
|
||||
@o names.c -cc -d
|
||||
@@ -5833,10 +5776,9 @@ tail = &(*tail)->next;
|
||||
@}
|
||||
|
||||
@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)
|
||||
Name *names;
|
||||
void reverse_lists(Name *names)
|
||||
{
|
||||
while (names) {
|
||||
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
|
||||
does no new allocations.
|
||||
@o names.c -cc -d
|
||||
@{static Scrap_Node *reverse(a)
|
||||
Scrap_Node *a;
|
||||
@{static Scrap_Node *reverse(Scrap_Node *a)
|
||||
{
|
||||
if (a) {
|
||||
Scrap_Node *b = a->next;
|
||||
@@ -5910,9 +5851,7 @@ static Goto_Node **depths;
|
||||
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{static Goto_Node *goto_lookup(c, g)
|
||||
char c;
|
||||
Goto_Node *g;
|
||||
@{static Goto_Node *goto_lookup(char c, Goto_Node *g)
|
||||
{
|
||||
Move_Node *m = g->moves;
|
||||
while (m && m->c != c)
|
||||
@@ -6058,14 +5997,14 @@ else if (m->prev)
|
||||
\subsection{Building the Automata}
|
||||
|
||||
@d Function pro...
|
||||
@{extern void search();
|
||||
@{extern void search(void);
|
||||
@}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{static void build_gotos();
|
||||
static int reject_match();
|
||||
@{static void build_gotos(Name *tree);
|
||||
static int reject_match(Name *name, char post, ArgManager *reader);
|
||||
|
||||
void search()
|
||||
void search(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<128; i++)
|
||||
@@ -6083,8 +6022,7 @@ void search()
|
||||
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{static void build_gotos(tree)
|
||||
Name *tree;
|
||||
@{static void build_gotos(Name *tree)
|
||||
{
|
||||
while (tree) {
|
||||
@<Extend goto graph with \verb|tree->spelling|@>
|
||||
@@ -6261,8 +6199,8 @@ void search()
|
||||
|
||||
@d Forward declarations for scraps.c
|
||||
@{
|
||||
static void add_uses();
|
||||
static int scrap_is_in();
|
||||
static void add_uses(Uses **root, Name *name);
|
||||
static int scrap_is_in(Scrap_Node * list, int i);
|
||||
@}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@@ -6422,8 +6360,7 @@ For the present, we'll consider the mechanism an experiment.
|
||||
@o scraps.c -cc -d
|
||||
@{#define sym_char(c) (isalnum(c) || (c) == '_')
|
||||
|
||||
static int op_char(c)
|
||||
char c;
|
||||
static int op_char(char c)
|
||||
{
|
||||
switch (c) {
|
||||
case '!': case '#': case '%': case '$': case '^':
|
||||
@@ -6437,10 +6374,7 @@ static int op_char(c)
|
||||
@| sym_char op_char @}
|
||||
|
||||
@o scraps.c -cc -d
|
||||
@{static int reject_match(name, post, reader)
|
||||
Name *name;
|
||||
char post;
|
||||
ArgManager *reader;
|
||||
@{static int reject_match(Name *name, char post, ArgManager *reader)
|
||||
{
|
||||
int len = strlen(name->spelling);
|
||||
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
|
||||
are quite fast.
|
||||
@d Function p...
|
||||
@{extern void *arena_getmem();
|
||||
extern void arena_free();
|
||||
@{extern void *arena_getmem(size_t n);
|
||||
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.
|
||||
|
||||
@o arena.c -cc -d
|
||||
@{void *arena_getmem(n)
|
||||
size_t n;
|
||||
@{void *arena_getmem(size_t n)
|
||||
{
|
||||
char *q;
|
||||
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|
|
||||
back to the first empty chunk.
|
||||
@o arena.c -cc -d
|
||||
@{void arena_free()
|
||||
@{void arena_free(void)
|
||||
{
|
||||
arena = &first;
|
||||
}
|
||||
|
35
output.c
35
output.c
@@ -1,10 +1,15 @@
|
||||
|
||||
#line 908 "nuweb.w"
|
||||
#include "global.h"
|
||||
void write_files(files)
|
||||
Name *files;
|
||||
|
||||
#line 3768 "nuweb.w"
|
||||
void write_files(Name *files)
|
||||
{
|
||||
while (files) {
|
||||
write_files(files->llink);
|
||||
/* Write out \verb|files->spelling| */
|
||||
|
||||
#line 3789 "nuweb.w"
|
||||
{
|
||||
static char temp_name[FILENAME_MAX];
|
||||
static char real_name[FILENAME_MAX];
|
||||
@@ -14,6 +19,8 @@ void write_files(files)
|
||||
|
||||
/* Find a free temporary file */
|
||||
|
||||
#line 3809 "nuweb.w"
|
||||
|
||||
for( temp_name_count = 0; temp_name_count < 10000; temp_name_count++) {
|
||||
sprintf(temp_name,"%s%snw%06d", dirpath, path_sep, temp_name_count);
|
||||
#ifdef O_EXCL
|
||||
@@ -38,6 +45,8 @@ void write_files(files)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
#line 3796 "nuweb.w"
|
||||
|
||||
|
||||
sprintf(real_name, "%s%s%s", dirpath, path_sep, files->spelling);
|
||||
if (verbose_flag)
|
||||
@@ -49,8 +58,12 @@ void write_files(files)
|
||||
|
||||
/* Move the temporary file to the target, if required */
|
||||
|
||||
#line 3839 "nuweb.w"
|
||||
|
||||
if (compare_flag)
|
||||
/* Compare the temp file and the old file */
|
||||
|
||||
#line 3850 "nuweb.w"
|
||||
{
|
||||
FILE *old_file = fopen(real_name, "r");
|
||||
if (old_file) {
|
||||
@@ -68,34 +81,52 @@ void write_files(files)
|
||||
remove(real_name);
|
||||
/* Rename the temporary file to the target */
|
||||
|
||||
#line 3872 "nuweb.w"
|
||||
|
||||
if (0 != rename(temp_name, real_name)) {
|
||||
fprintf(stderr, "%s: can't rename output file to %s\n",
|
||||
command_name, real_name);
|
||||
}
|
||||
|
||||
#line 3865 "nuweb.w"
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
/* Rename the temporary file to the target */
|
||||
|
||||
#line 3872 "nuweb.w"
|
||||
|
||||
if (0 != rename(temp_name, real_name)) {
|
||||
fprintf(stderr, "%s: can't rename output file to %s\n",
|
||||
command_name, real_name);
|
||||
}
|
||||
|
||||
#line 3869 "nuweb.w"
|
||||
|
||||
}
|
||||
#line 3841 "nuweb.w"
|
||||
|
||||
else {
|
||||
remove(real_name);
|
||||
/* Rename the temporary file to the target */
|
||||
|
||||
#line 3872 "nuweb.w"
|
||||
|
||||
if (0 != rename(temp_name, real_name)) {
|
||||
fprintf(stderr, "%s: can't rename output file to %s\n",
|
||||
command_name, real_name);
|
||||
}
|
||||
|
||||
#line 3844 "nuweb.w"
|
||||
|
||||
}
|
||||
|
||||
#line 3806 "nuweb.w"
|
||||
|
||||
}
|
||||
#line 3772 "nuweb.w"
|
||||
|
||||
files = files->rlink;
|
||||
}
|
||||
}
|
||||
|
85
pass1.c
85
pass1.c
@@ -1,6 +1,9 @@
|
||||
|
||||
#line 885 "nuweb.w"
|
||||
#include "global.h"
|
||||
void pass1(file_name)
|
||||
char *file_name;
|
||||
|
||||
#line 1414 "nuweb.w"
|
||||
void pass1(char *file_name)
|
||||
{
|
||||
if (verbose_flag)
|
||||
fprintf(stderr, "reading %s\n", file_name);
|
||||
@@ -10,11 +13,15 @@ void pass1(file_name)
|
||||
file_names = NULL;
|
||||
user_names = NULL;
|
||||
/* Scan the source file, looking for at-sequences */
|
||||
|
||||
#line 1433 "nuweb.w"
|
||||
{
|
||||
int c = source_get();
|
||||
while (c != EOF) {
|
||||
if (c == nw_char)
|
||||
/* Scan at-sequence */
|
||||
|
||||
#line 1446 "nuweb.w"
|
||||
{
|
||||
char quoted = 0;
|
||||
|
||||
@@ -26,10 +33,14 @@ void pass1(file_name)
|
||||
update_delimit_scrap();
|
||||
break;
|
||||
case 'O':
|
||||
case 'o': {
|
||||
case 'o':
|
||||
#line 1524 "nuweb.w"
|
||||
{
|
||||
Name *name = collect_file_name(); /* returns a pointer to the name entry */
|
||||
int scrap = collect_scrap(); /* returns an index to the scrap */
|
||||
/* Add \verb|scrap| to \verb|name|'s definition list */
|
||||
|
||||
#line 1543 "nuweb.w"
|
||||
{
|
||||
Scrap_Node *def = (Scrap_Node *) arena_getmem(sizeof(Scrap_Node));
|
||||
def->scrap = scrap;
|
||||
@@ -37,15 +48,23 @@ void pass1(file_name)
|
||||
def->next = name->defs;
|
||||
name->defs = def;
|
||||
}
|
||||
#line 1527 "nuweb.w"
|
||||
|
||||
}
|
||||
#line 1457 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'Q':
|
||||
case 'q': quoted = 1;
|
||||
case 'D':
|
||||
case 'd': {
|
||||
case 'd':
|
||||
#line 1532 "nuweb.w"
|
||||
{
|
||||
Name *name = collect_macro_name();
|
||||
int scrap = collect_scrap();
|
||||
/* Add \verb|scrap| to \verb|name|'s definition list */
|
||||
|
||||
#line 1543 "nuweb.w"
|
||||
{
|
||||
Scrap_Node *def = (Scrap_Node *) arena_getmem(sizeof(Scrap_Node));
|
||||
def->scrap = scrap;
|
||||
@@ -53,26 +72,40 @@ void pass1(file_name)
|
||||
def->next = name->defs;
|
||||
name->defs = def;
|
||||
}
|
||||
#line 1535 "nuweb.w"
|
||||
|
||||
}
|
||||
#line 1462 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 's':
|
||||
/* Step to next sector */
|
||||
|
||||
#line 1493 "nuweb.w"
|
||||
|
||||
prev_sector += 1;
|
||||
current_sector = prev_sector;
|
||||
c = source_get();
|
||||
|
||||
#line 1465 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'S':
|
||||
/* Close the current sector */
|
||||
|
||||
#line 1500 "nuweb.w"
|
||||
current_sector = 1;
|
||||
c = source_get();
|
||||
|
||||
#line 1468 "nuweb.w"
|
||||
|
||||
break;
|
||||
case '<':
|
||||
case '(':
|
||||
case '[':
|
||||
case '{':
|
||||
#line 1552 "nuweb.w"
|
||||
|
||||
{
|
||||
int c;
|
||||
int depth = 1;
|
||||
@@ -80,6 +113,8 @@ void pass1(file_name)
|
||||
if (c == nw_char)
|
||||
/* Skip over at-sign or go to skipped */
|
||||
|
||||
#line 1569 "nuweb.w"
|
||||
|
||||
{
|
||||
c = source_get();
|
||||
switch (c) {
|
||||
@@ -107,6 +142,8 @@ void pass1(file_name)
|
||||
}
|
||||
}
|
||||
|
||||
#line 1558 "nuweb.w"
|
||||
|
||||
}
|
||||
fprintf(stderr, "%s: unexpected EOF in text at (%s, %d)\n",
|
||||
command_name, source_name, source_line);
|
||||
@@ -115,25 +152,37 @@ void pass1(file_name)
|
||||
skipped: ;
|
||||
}
|
||||
|
||||
#line 1473 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'c': {
|
||||
case 'c':
|
||||
#line 1600 "nuweb.w"
|
||||
{
|
||||
char * p = blockBuff;
|
||||
char * e = blockBuff + (sizeof(blockBuff)/sizeof(blockBuff[0])) - 1;
|
||||
|
||||
/* Skip whitespace */
|
||||
|
||||
#line 1618 "nuweb.w"
|
||||
while (source_peek == ' '
|
||||
|| source_peek == '\t'
|
||||
|| source_peek == '\n')
|
||||
(void)source_get();
|
||||
|
||||
#line 1604 "nuweb.w"
|
||||
|
||||
while (p < e)
|
||||
{
|
||||
/* Add one char to the block buffer */
|
||||
|
||||
#line 1625 "nuweb.w"
|
||||
int c = source_get();
|
||||
|
||||
if (c == nw_char)
|
||||
{
|
||||
/* Add an at character to the block or break */
|
||||
|
||||
#line 1643 "nuweb.w"
|
||||
int cc = source_peek;
|
||||
|
||||
if (cc == 'c')
|
||||
@@ -161,6 +210,8 @@ void pass1(file_name)
|
||||
*p++ = source_get();
|
||||
}
|
||||
|
||||
#line 1629 "nuweb.w"
|
||||
|
||||
}
|
||||
else if (c == EOF)
|
||||
{
|
||||
@@ -171,7 +222,11 @@ void pass1(file_name)
|
||||
{
|
||||
/* Add any other character to the block */
|
||||
|
||||
#line 1672 "nuweb.w"
|
||||
|
||||
/* Perhaps skip white-space */
|
||||
|
||||
#line 1678 "nuweb.w"
|
||||
if (c == ' ')
|
||||
{
|
||||
while (source_peek == ' ')
|
||||
@@ -189,22 +244,34 @@ void pass1(file_name)
|
||||
c = ' ';
|
||||
}
|
||||
|
||||
#line 1673 "nuweb.w"
|
||||
|
||||
*p++ = c;
|
||||
|
||||
#line 1638 "nuweb.w"
|
||||
|
||||
}
|
||||
|
||||
#line 1607 "nuweb.w"
|
||||
|
||||
}
|
||||
if (p == e)
|
||||
{
|
||||
/* Skip to the next nw-char */
|
||||
|
||||
#line 1697 "nuweb.w"
|
||||
int c;
|
||||
|
||||
while ((c = source_get()), c != nw_char && c != EOF)/* Skip */
|
||||
source_ungetc(&c);
|
||||
#line 1611 "nuweb.w"
|
||||
|
||||
}
|
||||
*p = '\000';
|
||||
}
|
||||
|
||||
#line 1475 "nuweb.w"
|
||||
|
||||
break;
|
||||
case 'x':
|
||||
case 'v':
|
||||
@@ -220,15 +287,23 @@ void pass1(file_name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#line 1437 "nuweb.w"
|
||||
|
||||
c = source_get();
|
||||
}
|
||||
}
|
||||
#line 1423 "nuweb.w"
|
||||
|
||||
if (tex_flag)
|
||||
search();
|
||||
/* Reverse cross-reference lists */
|
||||
|
||||
#line 1802 "nuweb.w"
|
||||
{
|
||||
reverse_lists(file_names);
|
||||
reverse_lists(macro_names);
|
||||
reverse_lists(user_names);
|
||||
}
|
||||
#line 1426 "nuweb.w"
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user