version 1.19, 1999/11/17 14:57:21 |
version 1.20, 1999/11/17 15:34:13 |
|
|
#include "extern.h" |
#include "extern.h" |
#include "pathnames.h" |
#include "pathnames.h" |
|
|
|
static void dodefn __P((const char *)); |
|
static void dopushdef __P((const char *, const char *)); |
|
static void dodump __P((const char *[], int)); |
|
static void doifelse __P((const char *[], int)); |
|
static int doincl __P((const char *)); |
|
static int dopaste __P((const char *)); |
|
static void dochq __P((const char *[], int)); |
|
static void dochc __P((const char *[], int)); |
|
static void dodiv __P((int)); |
|
static void doundiv __P((const char *[], int)); |
|
static void dosub __P((const char *[], int)); |
|
static void map __P((char *, const char *, const char *, const char *)); |
/* |
/* |
* eval - evaluate built-in macros. |
* eval - evaluate built-in macros. |
* argc - number of elements in argv. |
* argc - number of elements in argv. |
|
|
|
|
void |
void |
eval(argv, argc, td) |
eval(argv, argc, td) |
char *argv[]; |
const char *argv[]; |
int argc; |
int argc; |
int td; |
int td; |
{ |
{ |
|
|
*/ |
*/ |
if (argc > 2) { |
if (argc > 2) { |
int fd; |
int fd; |
|
char *temp; |
|
|
|
temp = xstrdup(argv[2]); |
|
|
fd = mkstemp(argv[2]); |
fd = mkstemp(temp); |
if (fd == -1) |
if (fd == -1) |
err(1, "couldn't make temp file %s", argv[2]); |
err(1, "couldn't make temp file %s", argv[2]); |
close(fd); |
close(fd); |
pbstr(argv[2]); |
pbstr(temp); |
|
free(temp); |
} |
} |
break; |
break; |
|
|
|
|
*/ |
*/ |
void |
void |
expand(argv, argc) |
expand(argv, argc) |
char *argv[]; |
const char *argv[]; |
int argc; |
int argc; |
{ |
{ |
char *t; |
const char *t; |
char *p; |
const char *p; |
int n; |
int n; |
int argno; |
int argno; |
|
|
|
|
*/ |
*/ |
void |
void |
dodefine(name, defn) |
dodefine(name, defn) |
char *name; |
const char *name; |
char *defn; |
const char *defn; |
{ |
{ |
ndptr p; |
ndptr p; |
|
|
|
|
* dodefn - push back a quoted definition of |
* dodefn - push back a quoted definition of |
* the given name. |
* the given name. |
*/ |
*/ |
void |
static void |
dodefn(name) |
dodefn(name) |
char *name; |
const char *name; |
{ |
{ |
ndptr p; |
ndptr p; |
|
|
|
|
* hash bucket, it hides a previous definition from |
* hash bucket, it hides a previous definition from |
* lookup. |
* lookup. |
*/ |
*/ |
void |
static void |
dopushdef(name, defn) |
dopushdef(name, defn) |
char *name; |
const char *name; |
char *defn; |
const char *defn; |
{ |
{ |
ndptr p; |
ndptr p; |
|
|
|
|
* table to stderr. If nothing is specified, the entire |
* table to stderr. If nothing is specified, the entire |
* hash table is dumped. |
* hash table is dumped. |
*/ |
*/ |
void |
static void |
dodump(argv, argc) |
dodump(argv, argc) |
char *argv[]; |
const char *argv[]; |
int argc; |
int argc; |
{ |
{ |
int n; |
int n; |
|
|
/* |
/* |
* doifelse - select one of two alternatives - loop. |
* doifelse - select one of two alternatives - loop. |
*/ |
*/ |
void |
static void |
doifelse(argv, argc) |
doifelse(argv, argc) |
char *argv[]; |
const char *argv[]; |
int argc; |
int argc; |
{ |
{ |
cycle { |
cycle { |
|
|
/* |
/* |
* doinclude - include a given file. |
* doinclude - include a given file. |
*/ |
*/ |
int |
static int |
doincl(ifile) |
doincl(ifile) |
char *ifile; |
const char *ifile; |
{ |
{ |
if (ilevel + 1 == MAXINP) |
if (ilevel + 1 == MAXINP) |
errx(1, "too many include files."); |
errx(1, "too many include files."); |
|
|
* dopaste - include a given file without any |
* dopaste - include a given file without any |
* macro processing. |
* macro processing. |
*/ |
*/ |
int |
static int |
dopaste(pfile) |
dopaste(pfile) |
char *pfile; |
const char *pfile; |
{ |
{ |
FILE *pf; |
FILE *pf; |
int c; |
int c; |
|
|
/* |
/* |
* dochq - change quote characters |
* dochq - change quote characters |
*/ |
*/ |
void |
static void |
dochq(argv, argc) |
dochq(argv, argc) |
char *argv[]; |
const char *argv[]; |
int argc; |
int argc; |
{ |
{ |
if (argc > 2) { |
if (argc > 2) { |
|
|
/* |
/* |
* dochc - change comment characters |
* dochc - change comment characters |
*/ |
*/ |
void |
static void |
dochc(argv, argc) |
dochc(argv, argc) |
char *argv[]; |
const char *argv[]; |
int argc; |
int argc; |
{ |
{ |
if (argc > 2) { |
if (argc > 2) { |
|
|
/* |
/* |
* dodivert - divert the output to a temporary file |
* dodivert - divert the output to a temporary file |
*/ |
*/ |
void |
static void |
dodiv(n) |
dodiv(n) |
int n; |
int n; |
{ |
{ |
|
|
* doundivert - undivert a specified output, or all |
* doundivert - undivert a specified output, or all |
* other outputs, in numerical order. |
* other outputs, in numerical order. |
*/ |
*/ |
void |
static void |
doundiv(argv, argc) |
doundiv(argv, argc) |
char *argv[]; |
const char *argv[]; |
int argc; |
int argc; |
{ |
{ |
int ind; |
int ind; |
|
|
/* |
/* |
* dosub - select substring |
* dosub - select substring |
*/ |
*/ |
void |
static void |
dosub(argv, argc) |
dosub(argv, argc) |
char *argv[]; |
const char *argv[]; |
int argc; |
int argc; |
{ |
{ |
char *ap, *fc, *k; |
const char *ap, *fc, *k; |
int nc; |
int nc; |
|
|
if (argc < 5) |
if (argc < 5) |
|
|
* about 5 times faster than any algorithm that makes multiple passes over |
* about 5 times faster than any algorithm that makes multiple passes over |
* destination string. |
* destination string. |
*/ |
*/ |
void |
static void |
map(dest, src, from, to) |
map(dest, src, from, to) |
char *dest; |
char *dest; |
char *src; |
const char *src; |
char *from; |
const char *from; |
char *to; |
const char *to; |
{ |
{ |
char *tmp; |
const char *tmp; |
unsigned char sch, dch; |
unsigned char sch, dch; |
static unsigned char mapvec[256] = { |
static unsigned char mapvec[256] = { |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |