version 1.50, 2015/04/29 00:13:26 |
version 1.51, 2017/06/15 13:48:42 |
|
|
#include <err.h> |
#include <err.h> |
#include <paths.h> |
#include <paths.h> |
#include <regex.h> |
#include <regex.h> |
|
#include <stdarg.h> |
#include <stddef.h> |
#include <stddef.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <stdint.h> |
#include <stdint.h> |
|
|
} |
} |
|
|
static char * |
static char * |
getstring() |
getstring(void) |
{ |
{ |
addchar('\0'); |
addchar('\0'); |
current = 0; |
current = 0; |
|
|
m4errx(1, "regular expression error in %s: %s.", source, errbuf); |
m4errx(1, "regular expression error in %s: %s.", source, errbuf); |
} |
} |
|
|
|
/* warnx() plus check to see if we need to change exit code or exit. |
|
* -E flag functionality. |
|
*/ |
|
void |
|
m4_warnx(const char *fmt, ...) |
|
{ |
|
va_list ap; |
|
|
|
va_start(ap, fmt); |
|
vwarnx(fmt, ap); |
|
va_end(ap); |
|
|
|
if (fatal_warns) |
|
exit(1); |
|
if (error_warns) |
|
exit_code = 1; |
|
} |
|
|
static void |
static void |
add_sub(int n, const char *string, regex_t *re, regmatch_t *pm) |
add_sub(int n, const char *string, regex_t *re, regmatch_t *pm) |
{ |
{ |
if (n > re->re_nsub) |
if (n > re->re_nsub) |
warnx("No subexpression %d", n); |
m4_warnx("No subexpression %d", n); |
/* Subexpressions that did not match are |
/* Subexpressions that did not match are |
* not an error. */ |
* not an error. */ |
else if (pm[n].rm_so != -1 && |
else if (pm[n].rm_so != -1 && |
|
|
dopatsubst(const char *argv[], int argc) |
dopatsubst(const char *argv[], int argc) |
{ |
{ |
if (argc <= 3) { |
if (argc <= 3) { |
warnx("Too few arguments to patsubst"); |
m4_warnx("Too few arguments to patsubst"); |
return; |
return; |
} |
} |
/* special case: empty regexp */ |
/* special case: empty regexp */ |
|
|
const char *source; |
const char *source; |
|
|
if (argc <= 3) { |
if (argc <= 3) { |
warnx("Too few arguments to regexp"); |
m4_warnx("Too few arguments to regexp"); |
return; |
return; |
} |
} |
/* special gnu case */ |
/* special gnu case */ |