-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
+#include "amanda.h"
#include <regex.h>
-#include <assert.h>
#include "main.ih"
err = regcomp(&re, argv[optind++], copts);
if (err) {
- len = regerror(err, &re, erbuf, sizeof(erbuf));
+ len = regerror(err, &re, erbuf, SIZEOF(erbuf));
fprintf(stderr, "error %s, %d/%d `%s'\n",
- eprint(err), len, sizeof(erbuf), erbuf);
+ eprint(err), len, SIZEOF(erbuf), erbuf);
exit(status);
}
regprint(&re, stdout);
}
err = regexec(&re, argv[optind], (size_t)NS, subs, eopts);
if (err) {
- len = regerror(err, &re, erbuf, sizeof(erbuf));
+ len = regerror(err, &re, erbuf, SIZEOF(erbuf));
fprintf(stderr, "error %s, %d/%d `%s'\n",
- eprint(err), len, sizeof(erbuf), erbuf);
+ eprint(err), len, SIZEOF(erbuf), erbuf);
exit(status);
}
if (!(copts®_NOSUB)) {
char *bpname = "REG_BADPAT";
regex_t re;
- while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
+ while (fgets(inbuf, (int)sizeof(inbuf), in) != NULL) {
line++;
if (inbuf[0] == '#' || inbuf[0] == '\n')
continue; /* NOTE CONTINUE */
options('c', f[1]) &~ REG_EXTENDED);
}
- ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
+ ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, SIZEOF(erbuf));
if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) {
fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n",
erbuf, badpat);
erbuf, SHORT-1, badpat);
status = 1;
}
- ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
+ ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, SIZEOF(erbuf));
if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
erbuf, bpname);
status = 1;
}
re.re_endp = bpname;
- ne = regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
+ ne = regerror(REG_ATOI, &re, erbuf, SIZEOF(erbuf));
if (atoi(erbuf) != (int)REG_BADPAT) {
fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
erbuf, (long)REG_BADPAT);
char f0copy[1000];
char f2copy[1000];
- strncpy(f0copy, f0, sizeof(f0copy)-1);
- f0copy[sizeof(f0copy)-1] = '\0';
+ strncpy(f0copy, f0, SIZEOF(f0copy)-1);
+ f0copy[SIZEOF(f0copy)-1] = '\0';
re.re_endp = (opts®_PEND) ? f0copy + strlen(f0copy) : NULL;
fixstr(f0copy);
err = regcomp(&re, f0copy, opts);
if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
/* unexpected error or wrong error */
- len = regerror(err, &re, erbuf, sizeof(erbuf));
+ len = regerror(err, &re, erbuf, SIZEOF(erbuf));
fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
line, type, eprint(err), len,
- sizeof(erbuf), erbuf);
+ SIZEOF(erbuf), erbuf);
status = 1;
} else if (err == 0 && opt('C', f1)) {
/* unexpected success */
return;
}
- strncpy(f2copy, f2, sizeof(f2copy)-1);
- f2copy[sizeof(f2copy)-1] = '\0';
+ strncpy(f2copy, f2, SIZEOF(f2copy)-1);
+ f2copy[SIZEOF(f2copy)-1] = '\0';
fixstr(f2copy);
if (options('e', f1)®_STARTEND) {
if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
/* unexpected error or wrong error */
- len = regerror(err, &re, erbuf, sizeof(erbuf));
+ len = regerror(err, &re, erbuf, SIZEOF(erbuf));
fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
line, type, eprint(err), len,
- sizeof(erbuf), erbuf);
+ SIZEOF(erbuf), erbuf);
status = 1;
} else if (err != 0) {
/* nothing more to check */
(sub.rm_so != -1 && sub.rm_eo == -1) ||
(sub.rm_so != -1 && sub.rm_so < 0) ||
(sub.rm_eo != -1 && sub.rm_eo < 0) ) {
- snprintf(grump, sizeof(grump),
+ snprintf(grump, SIZEOF(grump),
"start %ld end %ld", (long)sub.rm_so,
(long)sub.rm_eo);
return(grump);
/* check for in range */
if (sub.rm_eo > strlen(str)) {
- snprintf(grump, sizeof(grump),
+ snprintf(grump, SIZEOF(grump),
"start %ld end %ld, past end of string",
(long)sub.rm_so, (long)sub.rm_eo);
return(grump);
/* check for not supposed to match */
if (should == NULL) {
- snprintf(grump, sizeof(grump), "matched `%.*s'", len, p);
+ snprintf(grump, SIZEOF(grump), "matched `%.*s'", len, p);
return(grump);
}
/* check for wrong match */
if (len != shlen || strncmp(p, should, (size_t)shlen) != 0) {
- snprintf(grump, sizeof(grump),
+ snprintf(grump, SIZEOF(grump),
"matched `%.*s' instead", len, p);
return(grump);
}
if (shlen == 0)
shlen = 1; /* force check for end-of-string */
if (strncmp(p, at, shlen) != 0) {
- snprintf(grump, sizeof(grump), "matched null at `%.20s'", p);
+ snprintf(grump, SIZEOF(grump), "matched null at `%.20s'", p);
return(grump);
}
return(NULL);
static char epbuf[100];
size_t len;
- len = regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
- assert(len <= sizeof(epbuf));
+ len = regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, SIZEOF(epbuf));
+ assert(len <= SIZEOF(epbuf));
return(epbuf);
}
size_t n;
regex_t re;
- snprintf(efbuf, sizeof(efbuf), "REG_%s", name);
- assert(strlen(efbuf) < sizeof(efbuf));
+ snprintf(efbuf, SIZEOF(efbuf), "REG_%s", name);
+ assert(strlen(efbuf) < SIZEOF(efbuf));
re.re_endp = efbuf;
- (void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
+ (void) regerror(REG_ATOI, &re, efbuf, SIZEOF(efbuf));
return(atoi(efbuf));
}