96 |
#endif |
#endif |
97 |
|
|
98 |
|
|
99 |
static void include (int argc, m4_symbol_value **argv, |
static void include (m4 *context, int argc, m4_symbol_value **argv, |
100 |
boolean silent); |
boolean silent); |
101 |
static void * set_trace (m4_hash *hash, const void *ignored, |
static void * set_trace_CB (m4_symtab *symtab, const char *ignored, |
102 |
void *symbol, void *userdata); |
m4_symbol *symbol, void *userdata); |
103 |
static const char *ntoa (number value, int radix); |
static const char *ntoa (number value, int radix); |
104 |
static void numb_obstack (struct obstack *obs, const number value, |
static void numb_obstack (struct obstack *obs, const number value, |
105 |
const int radix, int min); |
const int radix, int min); |
132 |
if (handle) |
if (handle) |
133 |
if (lt_dlmakeresident (handle) != 0) |
if (lt_dlmakeresident (handle) != 0) |
134 |
{ |
{ |
135 |
M4ERROR ((warning_status, 0, |
M4ERROR ((m4_get_warning_status_opt (context), 0, |
136 |
_("Warning: cannot make module `%s' resident: %s"), |
_("Warning: cannot make module `%s' resident: %s"), |
137 |
m4_get_module_name (handle), lt_dlerror ())); |
m4_get_module_name (handle), lt_dlerror ())); |
138 |
} |
} |
168 |
M4BUILTIN_HANDLER (undefine) |
M4BUILTIN_HANDLER (undefine) |
169 |
{ |
{ |
170 |
if (!m4_symbol_lookup (M4SYMTAB, M4ARG (1))) |
if (!m4_symbol_lookup (M4SYMTAB, M4ARG (1))) |
171 |
M4WARN ((warning_status, 0, |
M4WARN ((m4_get_warning_status_opt (context), 0, |
172 |
_("Warning: %s: undefined name: %s"), M4ARG (0), M4ARG (1))); |
_("Warning: %s: undefined name: %s"), M4ARG (0), M4ARG (1))); |
173 |
else |
else |
174 |
m4_symbol_delete (M4SYMTAB, M4ARG (1)); |
m4_symbol_delete (M4SYMTAB, M4ARG (1)); |
192 |
M4BUILTIN_HANDLER (popdef) |
M4BUILTIN_HANDLER (popdef) |
193 |
{ |
{ |
194 |
if (!m4_symbol_lookup (M4SYMTAB, M4ARG (1))) |
if (!m4_symbol_lookup (M4SYMTAB, M4ARG (1))) |
195 |
M4WARN ((warning_status, 0, |
M4WARN ((m4_get_warning_status_opt (context), 0, |
196 |
_("Warning: %s: undefined name: %s"), M4ARG (0), M4ARG (1))); |
_("Warning: %s: undefined name: %s"), M4ARG (0), M4ARG (1))); |
197 |
else |
else |
198 |
m4_symbol_popdef (M4SYMTAB, M4ARG (1)); |
m4_symbol_popdef (M4SYMTAB, M4ARG (1)); |
231 |
if (argc == 2) |
if (argc == 2) |
232 |
return; |
return; |
233 |
|
|
234 |
if (m4_bad_argc (argc, argv, 4, -1)) |
if (m4_bad_argc (context, argc, argv, 4, -1)) |
235 |
return; |
return; |
236 |
else |
else |
237 |
/* Diagnose excess arguments if 5, 8, 11, etc., actual arguments. */ |
/* Diagnose excess arguments if 5, 8, 11, etc., actual arguments. */ |
238 |
m4_bad_argc ((argc + 2) % 3, argv, -1, 1); |
m4_bad_argc (context, (argc + 2) % 3, argv, -1, 1); |
239 |
|
|
240 |
argv++; |
argv++; |
241 |
argc--; |
argc--; |
284 |
|
|
285 |
if (m4_is_symbol_text (symbol)) |
if (m4_is_symbol_text (symbol)) |
286 |
{ |
{ |
287 |
if (debug_level & M4_DEBUG_TRACE_QUOTE) |
if (m4_get_debug_level_opt (context) & M4_DEBUG_TRACE_QUOTE) |
288 |
fprintf (stderr, "%s%s%s\n", |
fprintf (stderr, "%s%s%s\n", |
289 |
lquote.string, m4_get_symbol_text (symbol), |
lquote.string, m4_get_symbol_text (symbol), |
290 |
rquote.string); |
rquote.string); |
315 |
symbol = m4_symbol_lookup (M4SYMTAB, M4ARG (1)); |
symbol = m4_symbol_lookup (M4SYMTAB, M4ARG (1)); |
316 |
if (symbol == NULL) |
if (symbol == NULL) |
317 |
{ |
{ |
318 |
M4WARN ((warning_status, 0, |
M4WARN ((m4_get_warning_status_opt (context), 0, |
319 |
_("Warning: %s: undefined name: %s"), M4ARG (0), M4ARG (1))); |
_("Warning: %s: undefined name: %s"), M4ARG (0), M4ARG (1))); |
320 |
return; |
return; |
321 |
} |
} |
348 |
{ |
{ |
349 |
int value; |
int value; |
350 |
|
|
351 |
if (!m4_numeric_arg (argc, argv, 1, &value)) |
if (!m4_numeric_arg (context, argc, argv, 1, &value)) |
352 |
return; |
return; |
353 |
|
|
354 |
m4_shipout_int (obs, value + 1); |
m4_shipout_int (obs, value + 1); |
358 |
{ |
{ |
359 |
int value; |
int value; |
360 |
|
|
361 |
if (!m4_numeric_arg (argc, argv, 1, &value)) |
if (!m4_numeric_arg (context, argc, argv, 1, &value)) |
362 |
return; |
return; |
363 |
|
|
364 |
m4_shipout_int (obs, value - 1); |
m4_shipout_int (obs, value - 1); |
374 |
{ |
{ |
375 |
int i = 0; |
int i = 0; |
376 |
|
|
377 |
if (argc == 2 && !m4_numeric_arg (argc, argv, 1, &i)) |
if (argc == 2 && !m4_numeric_arg (context, argc, argv, 1, &i)) |
378 |
return; |
return; |
379 |
|
|
380 |
m4_make_diversion (i); |
m4_make_diversion (i); |
401 |
{ |
{ |
402 |
if (sscanf (M4ARG (1), "%d", &i) == 1) |
if (sscanf (M4ARG (1), "%d", &i) == 1) |
403 |
m4_insert_diversion (i); |
m4_insert_diversion (i); |
404 |
else if (no_gnu_extensions) |
else if (m4_get_no_gnu_extensions_opt (context)) |
405 |
m4_numeric_arg (argc, argv, 1, &i); |
m4_numeric_arg (context, argc, argv, 1, &i); |
406 |
else |
else |
407 |
{ |
{ |
408 |
FILE *fp = m4_path_search (M4ARG (1), (char **) NULL); |
FILE *fp = m4_path_search (context, M4ARG (1), (char **) NULL); |
409 |
if (fp != NULL) |
if (fp != NULL) |
410 |
{ |
{ |
411 |
m4_insert_file (fp); |
m4_insert_file (fp); |
412 |
fclose (fp); |
fclose (fp); |
413 |
} |
} |
414 |
else |
else |
415 |
M4ERROR ((warning_status, errno, |
M4ERROR ((m4_get_warning_status_opt (context), errno, |
416 |
_("Cannot undivert %s"), M4ARG (1))); |
_("Cannot undivert %s"), M4ARG (1))); |
417 |
} |
} |
418 |
} |
} |
427 |
lives in input.c. */ |
lives in input.c. */ |
428 |
M4BUILTIN_HANDLER (dnl) |
M4BUILTIN_HANDLER (dnl) |
429 |
{ |
{ |
430 |
m4_skip_line (); |
m4_skip_line (context); |
431 |
} |
} |
432 |
|
|
433 |
/* Shift all argument one to the left, discarding the first argument. Each |
/* Shift all argument one to the left, discarding the first argument. Each |
462 |
/* Generic include function. Include the file given by the first argument, |
/* Generic include function. Include the file given by the first argument, |
463 |
if it exists. Complain about inaccesible files iff SILENT is FALSE. */ |
if it exists. Complain about inaccesible files iff SILENT is FALSE. */ |
464 |
static void |
static void |
465 |
include (int argc, m4_symbol_value **argv, boolean silent) |
include (m4 *context, int argc, m4_symbol_value **argv, boolean silent) |
466 |
{ |
{ |
467 |
FILE *fp; |
FILE *fp; |
468 |
char *name = NULL; |
char *name = NULL; |
469 |
|
|
470 |
fp = m4_path_search (M4ARG (1), &name); |
fp = m4_path_search (context, M4ARG (1), &name); |
471 |
if (fp == NULL) |
if (fp == NULL) |
472 |
{ |
{ |
473 |
if (!silent) |
if (!silent) |
474 |
M4ERROR ((warning_status, errno, |
M4ERROR ((m4_get_warning_status_opt (context), errno, |
475 |
_("Cannot open %s"), M4ARG (1))); |
_("Cannot open %s"), M4ARG (1))); |
476 |
return; |
return; |
477 |
} |
} |
478 |
|
|
479 |
m4_push_file (fp, name); |
m4_push_file (context, fp, name); |
480 |
xfree (name); |
xfree (name); |
481 |
} |
} |
482 |
|
|
483 |
/* Include a file, complaining in case of errors. */ |
/* Include a file, complaining in case of errors. */ |
484 |
M4BUILTIN_HANDLER (include) |
M4BUILTIN_HANDLER (include) |
485 |
{ |
{ |
486 |
include (argc, argv, FALSE); |
include (context, argc, argv, FALSE); |
487 |
} |
} |
488 |
|
|
489 |
/* Include a file, ignoring errors. */ |
/* Include a file, ignoring errors. */ |
490 |
M4BUILTIN_HANDLER (sinclude) |
M4BUILTIN_HANDLER (sinclude) |
491 |
{ |
{ |
492 |
include (argc, argv, TRUE); |
include (context, argc, argv, TRUE); |
493 |
} |
} |
494 |
|
|
495 |
|
|
522 |
{ |
{ |
523 |
int exit_code = 0; |
int exit_code = 0; |
524 |
|
|
525 |
if (argc == 2 && !m4_numeric_arg (argc, argv, 1, &exit_code)) |
if (argc == 2 && !m4_numeric_arg (context, argc, argv, 1, &exit_code)) |
526 |
exit_code = 0; |
exit_code = 0; |
527 |
|
|
528 |
/* Ensure any module exit callbacks are executed. */ |
/* Ensure any module exit callbacks are executed. */ |
536 |
version only the first. */ |
version only the first. */ |
537 |
M4BUILTIN_HANDLER (m4wrap) |
M4BUILTIN_HANDLER (m4wrap) |
538 |
{ |
{ |
539 |
if (no_gnu_extensions) |
if (m4_get_no_gnu_extensions_opt (context)) |
540 |
m4_shipout_string (obs, M4ARG (1), 0, FALSE); |
m4_shipout_string (obs, M4ARG (1), 0, FALSE); |
541 |
else |
else |
542 |
m4_dump_args (obs, argc, argv, " ", FALSE); |
m4_dump_args (obs, argc, argv, " ", FALSE); |
552 |
tracing of a macro. It disables tracing if DATA is NULL, otherwise it |
tracing of a macro. It disables tracing if DATA is NULL, otherwise it |
553 |
enable tracing. */ |
enable tracing. */ |
554 |
static void * |
static void * |
555 |
set_trace (m4_hash *hash, const void *ignored, void *symbol, |
set_trace_CB (m4_symtab *hash, const char *ignored, m4_symbol *symbol, |
556 |
void *userdata) |
void *userdata) |
557 |
{ |
{ |
558 |
m4_set_symbol_traced ((m4_symbol *) symbol, (boolean) (userdata != NULL)); |
m4_set_symbol_traced (symbol, (boolean) (userdata != NULL)); |
559 |
return NULL; |
return NULL; |
560 |
} |
} |
561 |
|
|
564 |
int i; |
int i; |
565 |
|
|
566 |
if (argc == 1) |
if (argc == 1) |
567 |
m4_symtab_apply (M4SYMTAB, set_trace, (void *) obs); |
m4_symtab_apply (M4SYMTAB, set_trace_CB, (void *) obs); |
568 |
else |
else |
569 |
for (i = 1; i < argc; i++) |
for (i = 1; i < argc; i++) |
570 |
{ |
{ |
571 |
const char *name = M4ARG (i); |
const char *name = M4ARG (i); |
572 |
m4_symbol *symbol = m4_symbol_lookup (M4SYMTAB, name); |
m4_symbol *symbol = m4_symbol_lookup (M4SYMTAB, name); |
573 |
if (symbol != NULL) |
if (symbol != NULL) |
574 |
set_trace (NULL, NULL, symbol, (char *) obs); |
set_trace_CB (NULL, NULL, symbol, (char *) obs); |
575 |
else |
else |
576 |
M4WARN ((warning_status, 0, |
M4WARN ((m4_get_warning_status_opt (context), 0, |
577 |
_("Warning: %s: undefined name: %s"), M4ARG (0), name)); |
_("Warning: %s: undefined name: %s"), M4ARG (0), name)); |
578 |
} |
} |
579 |
} |
} |
584 |
int i; |
int i; |
585 |
|
|
586 |
if (argc == 1) |
if (argc == 1) |
587 |
m4_symtab_apply (M4SYMTAB, set_trace, NULL); |
m4_symtab_apply (M4SYMTAB, set_trace_CB, NULL); |
588 |
else |
else |
589 |
for (i = 1; i < argc; i++) |
for (i = 1; i < argc; i++) |
590 |
{ |
{ |
591 |
const char *name = M4ARG (i); |
const char *name = M4ARG (i); |
592 |
m4_symbol *symbol = m4_symbol_lookup (M4SYMTAB, name); |
m4_symbol *symbol = m4_symbol_lookup (M4SYMTAB, name); |
593 |
if (symbol != NULL) |
if (symbol != NULL) |
594 |
set_trace (NULL, NULL, symbol, NULL); |
set_trace_CB (NULL, NULL, symbol, NULL); |
595 |
else |
else |
596 |
M4WARN ((warning_status, 0, |
M4WARN ((m4_get_warning_status_opt (context), 0, |
597 |
_("Warning: %s: undefined name: %s"), M4ARG (0), name)); |
_("Warning: %s: undefined name: %s"), M4ARG (0), name)); |
598 |
} |
} |
599 |
} |
} |
640 |
int start, length, avail; |
int start, length, avail; |
641 |
|
|
642 |
length = avail = strlen (M4ARG (1)); |
length = avail = strlen (M4ARG (1)); |
643 |
if (!m4_numeric_arg (argc, argv, 2, &start)) |
if (!m4_numeric_arg (context, argc, argv, 2, &start)) |
644 |
return; |
return; |
645 |
|
|
646 |
if (argc == 4 && !m4_numeric_arg (argc, argv, 3, &length)) |
if (argc == 4 && !m4_numeric_arg (context, argc, argv, 3, &length)) |
647 |
return; |
return; |
648 |
|
|
649 |
if (start < 0 || length <= 0 || start >= avail) |
if (start < 0 || length <= 0 || start >= avail) |
738 |
#define numb_lior(x,y) ((x) = ((x) || (y))) |
#define numb_lior(x,y) ((x) = ((x) || (y))) |
739 |
#define numb_land(x,y) ((x) = ((x) && (y))) |
#define numb_land(x,y) ((x) = ((x) && (y))) |
740 |
|
|
741 |
#define numb_not(x) (*(x) = int2numb(~numb2int(*(x)))) |
#define numb_not(c,x) (*(x) = int2numb(~numb2int(*(x)))) |
742 |
#define numb_eor(x,y) (*(x) = int2numb(numb2int(*(x)) ^ numb2int(*(y)))) |
#define numb_eor(c,x,y) (*(x) = int2numb(numb2int(*(x)) ^ numb2int(*(y)))) |
743 |
#define numb_ior(x,y) (*(x) = int2numb(numb2int(*(x)) | numb2int(*(y)))) |
#define numb_ior(c,x,y) (*(x) = int2numb(numb2int(*(x)) | numb2int(*(y)))) |
744 |
#define numb_and(x,y) (*(x) = int2numb(numb2int(*(x)) & numb2int(*(y)))) |
#define numb_and(c,x,y) (*(x) = int2numb(numb2int(*(x)) & numb2int(*(y)))) |
745 |
|
|
746 |
#define numb_plus(x,y) ((x) = ((x) + (y))) |
#define numb_plus(x,y) ((x) = ((x) + (y))) |
747 |
#define numb_minus(x,y) ((x) = ((x) - (y))) |
#define numb_minus(x,y) ((x) = ((x) - (y))) |
750 |
#define numb_times(x,y) ((x) = ((x) * (y))) |
#define numb_times(x,y) ((x) = ((x) * (y))) |
751 |
#define numb_ratio(x,y) ((x) = ((x) / ((y)))) |
#define numb_ratio(x,y) ((x) = ((x) / ((y)))) |
752 |
#define numb_divide(x,y) (*(x) = (*(x) / (*(y)))) |
#define numb_divide(x,y) (*(x) = (*(x) / (*(y)))) |
753 |
#define numb_modulo(x,y) (*(x) = (*(x) % *(y))) |
#define numb_modulo(c,x,y) (*(x) = (*(x) % *(y))) |
754 |
#define numb_invert(x) ((x) = 1 / (x)) |
#define numb_invert(x) ((x) = 1 / (x)) |
755 |
|
|
756 |
#define numb_lshift(x,y) (*(x) = (*(x) << *(y))) |
#define numb_lshift(c,x,y) (*(x) = (*(x) << *(y))) |
757 |
#define numb_rshift(x,y) (*(x) = (*(x) >> *(y))) |
#define numb_rshift(c,x,y) (*(x) = (*(x) >> *(y))) |
758 |
|
|
759 |
|
|
760 |
/* The function ntoa () converts VALUE to a signed ascii representation in |
/* The function ntoa () converts VALUE to a signed ascii representation in |