Another bug report
Daniel Klein
dk0w at andrew.cmu.edu
Tue Apr 7 14:32:16 EDT 2009
I'm going to apologize in advance for all this email - I am adding a feature to ra, and am stumbling over these piecemeal. I will release the complete additions when they all work...
The -u flag is documented as "Print time values using UTC time format", but it appears that it really is "Print the time in seconds since the Epoch". Am I correct?
Also, there is a bug in the parsing of RA_TIME_FORMAT - the first character is assumed to be a '%', so that if I make my format 'Z%T', it prints 'EDT12:35:17'. Further, you cannot us '%%' to print a '%' (because strtok(3) can't handle adjacent separator tokens). I have fixed these and have appended a patch.
*** common/argus_util.c 2009/04/07 02:27:30 1.1
--- common/argus_util.c 2009/04/07 18:06:43
***************
*** 15791,15798 ****
strncpy(timeFormatBuf, parser->RaTimeFormat, 128);
! while ((ptr = strtok(tstr, "%")) != NULL) {
! switch (*ptr) {
case 'f': {
if (parser->pflag) {
while (isspace((int)buf[strlen(buf) - 1]))
--- 16408,16418 ----
strncpy(timeFormatBuf, parser->RaTimeFormat, 128);
! for (ptr=tstr; *ptr; ptr++) {
! if (*ptr != '%') {
! buf[strlen(buf)] = *ptr;
! } else
! switch (*++ptr) {
case 'f': {
if (parser->pflag) {
while (isspace((int)buf[strlen(buf) - 1]))
***************
*** 15803,15808 ****
--- 16423,16438 ----
}
break;
}
+ case '%': {
+ buf[strlen(buf)] = '%';
+ break;
+ }
+ case 'E': case 'O': {
+ char sbuf[8];
+ sprintf (sbuf, "%%%.2s", ptr++);
+ strftime (&buf[strlen(buf)], 64, sbuf, tm);
+ break;
+ }
case 'z': {
if (parser->ArgusPrintXml) {
char sbuf[16];
***************
*** 15822,15836 ****
sprintf(&buf[strlen(buf)], "%s", sbuf);
break;
}
}
default: {
char sbuf[8];
! sprintf (sbuf, "%%%s", ptr);
strftime (&buf[strlen(buf)], 64, sbuf, tm);
break;
}
}
- tstr = NULL;
}
if (tvp->tv_sec == 0) {
--- 16452,16466 ----
sprintf(&buf[strlen(buf)], "%s", sbuf);
break;
}
+ /* Fall through to default if %z and not parser->ArgusPrintXml */
}
default: {
char sbuf[8];
! sprintf (sbuf, "%%%c", *ptr);
strftime (&buf[strlen(buf)], 64, sbuf, tm);
break;
}
}
}
if (tvp->tv_sec == 0) {
More information about the argus
mailing list