103 |
/* --- OUTPUT INITIALISATION --- */ |
/* --- OUTPUT INITIALISATION --- */ |
104 |
|
|
105 |
void |
void |
106 |
m4_output_init () |
m4_output_init (void) |
107 |
{ |
{ |
108 |
diversion_table = (struct diversion *) xmalloc (sizeof (struct diversion)); |
diversion_table = (struct diversion *) xmalloc (sizeof (struct diversion)); |
109 |
diversions = 1; |
diversions = 1; |
128 |
|
|
129 |
#include <fcntl.h> |
#include <fcntl.h> |
130 |
|
|
|
static int mkstemp M4_PARAMS((const char *tmpl)); |
|
|
|
|
131 |
static int |
static int |
132 |
mkstemp (tmpl) |
mkstemp (const char *tmpl) |
|
const char *tmpl; |
|
133 |
{ |
{ |
134 |
mktemp (tmpl); |
mktemp (tmpl); |
135 |
return open (tmpl, O_RDWR | O_TRUNC | O_CREAT, 0600); |
return open (tmpl, O_RDWR | O_TRUNC | O_CREAT, 0600); |
146 |
*/ |
*/ |
147 |
#include <fcntl.h> |
#include <fcntl.h> |
148 |
|
|
|
char *mktemp M4_PARAMS((char *tmpl)); |
|
|
int mkstemp M4_PARAMS((char *tmpl)); |
|
|
|
|
149 |
int |
int |
150 |
mkstemp (tmpl) |
mkstemp (char *tmpl) |
|
char *tmpl; |
|
151 |
{ |
{ |
152 |
char *xes; |
char *xes; |
153 |
pid_t pid; |
pid_t pid; |
184 |
} |
} |
185 |
|
|
186 |
char * |
char * |
187 |
mktemp (tmpl) |
mktemp (char *tmpl) |
|
char *tmpl; |
|
188 |
{ |
{ |
189 |
int fd; |
int fd; |
190 |
|
|
204 |
|
|
205 |
/* Implement tmpfile(3) for non-USG systems. */ |
/* Implement tmpfile(3) for non-USG systems. */ |
206 |
|
|
|
static FILE *tmpfile M4_PARAMS((void)); |
|
|
|
|
207 |
static FILE * |
static FILE * |
208 |
tmpfile () |
tmpfile (void) |
209 |
{ |
{ |
210 |
char buf[32]; |
char buf[32]; |
211 |
int fd; |
int fd; |
228 |
to be flushed to a newly created temporary file. This flushed buffer |
to be flushed to a newly created temporary file. This flushed buffer |
229 |
might well be the current one. */ |
might well be the current one. */ |
230 |
static void |
static void |
231 |
make_room_for (length) |
make_room_for (int length) |
|
int length; |
|
232 |
{ |
{ |
233 |
int wanted_size; |
int wanted_size; |
234 |
|
|
337 |
(output_unused--, *output_cursor++ = (Char)) |
(output_unused--, *output_cursor++ = (Char)) |
338 |
|
|
339 |
static void |
static void |
340 |
output_character_helper (character) |
output_character_helper (int character) |
|
int character; |
|
341 |
{ |
{ |
342 |
make_room_for (1); |
make_room_for (1); |
343 |
|
|
353 |
/* Output one TEXT having LENGTH characters, when it is known that it goes |
/* Output one TEXT having LENGTH characters, when it is known that it goes |
354 |
to a diversion file or an in-memory diversion buffer. */ |
to a diversion file or an in-memory diversion buffer. */ |
355 |
static void |
static void |
356 |
output_text (text, length) |
output_text (const char *text, int length) |
|
const char *text; |
|
|
int length; |
|
357 |
{ |
{ |
358 |
int count; |
int count; |
359 |
|
|
384 |
sync lines are output whenever a single input lines generates several |
sync lines are output whenever a single input lines generates several |
385 |
output lines, or when several input lines does not generate any output. */ |
output lines, or when several input lines does not generate any output. */ |
386 |
void |
void |
387 |
m4_shipout_text (obs, text, length) |
m4_shipout_text (struct obstack *obs, const char *text, int length) |
|
struct obstack *obs; |
|
|
const char *text; |
|
|
int length; |
|
388 |
{ |
{ |
389 |
static boolean start_of_output_line = TRUE; |
static boolean start_of_output_line = TRUE; |
390 |
char line[20]; |
char line[20]; |
466 |
start_of_output_line = TRUE; |
start_of_output_line = TRUE; |
467 |
} |
} |
468 |
} |
} |
469 |
|
|
470 |
/* Format an int VAL, and stuff it into an obstack OBS. Used for macros |
/* Format an int VAL, and stuff it into an obstack OBS. Used for macros |
471 |
expanding to numbers. */ |
expanding to numbers. */ |
472 |
void |
void |
479 |
} |
} |
480 |
|
|
481 |
void |
void |
482 |
m4_shipout_string (struct obstack *obs, const char *s, int len, boolean quoted) |
m4_shipout_string (struct obstack *obs, const char *s, int len, |
483 |
|
boolean quoted) |
484 |
{ |
{ |
485 |
if (s == NULL) |
if (s == NULL) |
486 |
s = ""; |
s = ""; |