24 |
#include "m4.h" |
#include "m4.h" |
25 |
#include "m4private.h" |
#include "m4private.h" |
26 |
|
|
27 |
static int dumpdef_cmp M4_PARAMS((const VOID *s1, const VOID *s2)); |
static int dumpdef_cmp (const void *s1, const void *s2); |
28 |
|
|
29 |
/* The name this program was run with. */ |
/* The name this program was run with. */ |
30 |
M4_GLOBAL_DATA const char *program_name; |
M4_GLOBAL_DATA const char *program_name; |
80 |
M4_GLOBAL_DATA m4_string ecomm; |
M4_GLOBAL_DATA m4_string ecomm; |
81 |
|
|
82 |
|
|
|
|
|
83 |
/* Addressable function versions of the macros defined in m4private.h. |
/* Addressable function versions of the macros defined in m4private.h. |
84 |
Since they are functions the caller does not need access to the |
Since they are functions the caller does not need access to the |
85 |
internal data structure, so they are safe to export for use in |
internal data structure, so they are safe to export for use in |
177 |
/* Print ARGC arguments from the table ARGV to obstack OBS, separated by |
/* Print ARGC arguments from the table ARGV to obstack OBS, separated by |
178 |
SEP, and quoted by the current quotes, if QUOTED is TRUE. */ |
SEP, and quoted by the current quotes, if QUOTED is TRUE. */ |
179 |
void |
void |
180 |
m4_dump_args (obs, argc, argv, sep, quoted) |
m4_dump_args (struct obstack *obs, int argc, m4_token_data **argv, |
181 |
struct obstack *obs; |
const char *sep, boolean quoted) |
|
int argc; |
|
|
m4_token_data **argv; |
|
|
const char *sep; |
|
|
boolean quoted; |
|
182 |
{ |
{ |
183 |
int i; |
int i; |
184 |
size_t len = strlen (sep); |
size_t len = strlen (sep); |
188 |
if (i > 1) |
if (i > 1) |
189 |
obstack_grow (obs, sep, len); |
obstack_grow (obs, sep, len); |
190 |
|
|
191 |
m4_shipout_string(obs, M4_TOKEN_DATA_TEXT (argv[i]), 0, quoted); |
m4_shipout_string (obs, M4_TOKEN_DATA_TEXT (argv[i]), 0, quoted); |
192 |
} |
} |
193 |
} |
} |
194 |
|
|
236 |
|
|
237 |
/* qsort comparison routine, for sorting the table made in m4_dumpdef (). */ |
/* qsort comparison routine, for sorting the table made in m4_dumpdef (). */ |
238 |
static int |
static int |
239 |
dumpdef_cmp (s1, s2) |
dumpdef_cmp (const void *s1, const void *s2) |
|
const VOID *s1; |
|
|
const VOID *s2; |
|
240 |
{ |
{ |
241 |
return strcmp (SYMBOL_NAME (* (m4_symbol *const *) s1), |
return strcmp (SYMBOL_NAME (* (m4_symbol *const *) s1), |
242 |
SYMBOL_NAME (* (m4_symbol *const *) s2)); |
SYMBOL_NAME (* (m4_symbol *const *) s2)); |
245 |
/* The function dump_symbol () is for use by "dumpdef". It builds up a |
/* The function dump_symbol () is for use by "dumpdef". It builds up a |
246 |
table of all defined, un-shadowed, symbols. */ |
table of all defined, un-shadowed, symbols. */ |
247 |
void |
void |
248 |
m4_dump_symbol (symbol, data) |
m4_dump_symbol (m4_symbol *symbol, struct m4_dump_symbol_data *data) |
|
m4_symbol *symbol; |
|
|
struct m4_dump_symbol_data *data; |
|
249 |
{ |
{ |
250 |
if (!SYMBOL_SHADOWED (symbol) && SYMBOL_TYPE (symbol) != M4_TOKEN_VOID) |
if (!SYMBOL_SHADOWED (symbol) && SYMBOL_TYPE (symbol) != M4_TOKEN_VOID) |
251 |
{ |
{ |
258 |
/* If there are no arguments, build a sorted list of all defined, |
/* If there are no arguments, build a sorted list of all defined, |
259 |
un-shadowed, symbols, otherwise, only the specified symbols. */ |
un-shadowed, symbols, otherwise, only the specified symbols. */ |
260 |
void |
void |
261 |
m4_dump_symbols (data, argc, argv, complain) |
m4_dump_symbols (struct m4_dump_symbol_data *data, int argc, |
262 |
struct m4_dump_symbol_data *data; |
m4_token_data **argv, boolean complain) |
|
int argc; |
|
|
m4_token_data **argv; |
|
|
boolean complain; |
|
263 |
{ |
{ |
264 |
data->base = (m4_symbol **) obstack_base (data->obs); |
data->base = (m4_symbol **) obstack_base (data->obs); |
265 |
data->size = 0; |
data->size = 0; |