version 1.26, 2001/11/16 23:50:40 |
version 1.27, 2002/04/26 16:15:16 |
|
|
* find the index of second str in the first str. |
* find the index of second str in the first str. |
*/ |
*/ |
ptrdiff_t |
ptrdiff_t |
indx(s1, s2) |
indx(const char *s1, const char *s2) |
const char *s1; |
|
const char *s2; |
|
{ |
{ |
char *t; |
char *t; |
|
|
|
|
* putback - push character back onto input |
* putback - push character back onto input |
*/ |
*/ |
void |
void |
putback(c) |
putback(int c) |
int c; |
|
{ |
{ |
if (c == EOF) |
if (c == EOF) |
return; |
return; |
|
|
* performance. |
* performance. |
*/ |
*/ |
void |
void |
pbstr(s) |
pbstr(const char *s) |
const char *s; |
|
{ |
{ |
size_t n; |
size_t n; |
|
|
|
|
* pbnum - convert number to string, push back on input. |
* pbnum - convert number to string, push back on input. |
*/ |
*/ |
void |
void |
pbnum(n) |
pbnum(int n) |
int n; |
|
{ |
{ |
int num; |
int num; |
|
|
|
|
* pbunsigned - convert unsigned long to string, push back on input. |
* pbunsigned - convert unsigned long to string, push back on input. |
*/ |
*/ |
void |
void |
pbunsigned(n) |
pbunsigned(unsigned long n) |
unsigned long n; |
|
{ |
{ |
do { |
do { |
putback(n % 10 + '0'); |
putback(n % 10 + '0'); |
|
|
* chrsave - put single char on string space |
* chrsave - put single char on string space |
*/ |
*/ |
void |
void |
chrsave(c) |
chrsave(int c) |
int c; |
|
{ |
{ |
if (ep >= endest) |
if (ep >= endest) |
enlarge_strspace(); |
enlarge_strspace(); |
|
|
* read in a diversion file, and dispose it. |
* read in a diversion file, and dispose it. |
*/ |
*/ |
void |
void |
getdiv(n) |
getdiv(int n) |
int n; |
|
{ |
{ |
int c; |
int c; |
|
|
|
|
} |
} |
|
|
void |
void |
onintr(signo) |
onintr(int signo) |
int signo; |
|
{ |
{ |
#define intrmessage "m4: interrupted.\n" |
#define intrmessage "m4: interrupted.\n" |
write(STDERR_FILENO, intrmessage, sizeof(intrmessage)-1); |
write(STDERR_FILENO, intrmessage, sizeof(intrmessage)-1); |
|
|
/* |
/* |
* resizedivs: allocate more diversion files */ |
* resizedivs: allocate more diversion files */ |
void |
void |
resizedivs(n) |
resizedivs(int n) |
int n; |
|
{ |
{ |
int i; |
int i; |
|
|
|
|
} |
} |
|
|
void * |
void * |
xalloc(n) |
xalloc(size_t n) |
size_t n; |
|
{ |
{ |
char *p = malloc(n); |
char *p = malloc(n); |
|
|
|
|
} |
} |
|
|
char * |
char * |
xstrdup(s) |
xstrdup(const char *s) |
const char *s; |
|
{ |
{ |
char *p = strdup(s); |
char *p = strdup(s); |
if (p == NULL) |
if (p == NULL) |
|
|
} |
} |
|
|
int |
int |
obtain_char(f) |
obtain_char(struct input_file *f) |
struct input_file *f; |
|
{ |
{ |
if (f->c == EOF) |
if (f->c == EOF) |
return EOF; |
return EOF; |
|
|
} |
} |
|
|
void |
void |
set_input(f, real, name) |
set_input(struct input_file *f, FILE *real, const char *name) |
struct input_file *f; |
|
FILE *real; |
|
const char *name; |
|
{ |
{ |
f->file = real; |
f->file = real; |
f->lineno = 1; |
f->lineno = 1; |
|
|
} |
} |
|
|
void |
void |
release_input(f) |
release_input(struct input_file *f) |
struct input_file *f; |
|
{ |
{ |
if (f->file != stdin) |
if (f->file != stdin) |
fclose(f->file); |
fclose(f->file); |
|
|
} |
} |
|
|
void |
void |
doprintlineno(f) |
doprintlineno(struct input_file *f) |
struct input_file *f; |
|
{ |
{ |
pbunsigned(f->lineno); |
pbunsigned(f->lineno); |
} |
} |
|
|
void |
void |
doprintfilename(f) |
doprintfilename(struct input_file *f) |
struct input_file *f; |
|
{ |
{ |
pbstr(rquote); |
pbstr(rquote); |
pbstr(f->name); |
pbstr(f->name); |
|
|
|
|
|
|
void |
void |
dump_buffer(f, m) |
dump_buffer(FILE *f, size_t m) |
FILE *f; |
|
size_t m; |
|
{ |
{ |
char *s; |
char *s; |
|
|