I found this problem after updating ldm to 6.15.0, though I think the bug
was introduced earlier.
Parsing maxAge in scour.conf does not work right when hours (and minutes)
are present. The faulty code is in function regexOps, file parser.c. The
following test code illustrates the issue (and provides a solution).
#include <assert.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
int main(int ac, char **av)
{
const char *pattern = "^([0-9]*)(-([0-9]{2})(:([0-9]{2}))?)?$";
const char *daysOld1 = "1-09:30";
const char *daysOld2 = "-09:30";
const char *daysOld3 = "-09";
regex_t regex;
regmatch_t group[8];
int status = regcomp(®ex, pattern, REG_EXTENDED);
assert(status == 0);
printf("regex.re_nsub = %d\n", regex.re_nsub);
int nmatch = regex.re_nsub + 1;
printf("nmatch = %d\n", nmatch);
const char *daysOld = daysOld1;
status = regexec(®ex, daysOld, nmatch, group, 0);
assert(status == 0);
int i;
for (i = 0; i < nmatch; i++) {
printf("rm_so = %d rm_eo = %d\n", group[i].rm_so, group[i].rm_eo);
if (group[i].rm_eo - group[i].rm_so > 0) {
char *end;
// long value = strtol(daysOld + group[i].rm_so, &end, 0);
long value = strtol(daysOld + group[i].rm_so, &end, 10);
printf("i = %d, value = %ld\n", i, value);
printf("substr = %s\n", daysOld + group[i].rm_so);
}
}
return 0;
}
/*
* Conclusions
* -----------
* "group" indices should be 1 (days), 3 (hours) and 5 (minutes), not 1, 2,
3
* "strtol" with base 0 won't convert "-09" correctly, see "man strtol".
Use base 10 instead
*/
Another thing: the man page for scour:
https://docs.unidata.ucar.edu/ldm/man/scour.html should be fixed. The
command
scour -v -l ~ldm/etc/scour.conf
causes scour to overwrite its configuration file. It happened to me
when I retyped the above without thinking.
George