Another bug report

Carter Bullard carter at qosient.com
Mon Apr 13 18:51:33 EDT 2009


So on this one, you're right.  I think I'd prefer to re-implement this  
with
strsep(), to catch the "%%" case, but I'll slide in your code for now,  
as
its extremely hard to argue with something that works ;o)

Thanks again for all the excellent help!!!

Carter


On Apr 7, 2009, at 2:32 PM, Daniel Klein wrote:

> 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) {
>
>
>

Carter Bullard
CEO/President
QoSient, LLC
150 E 57th Street Suite 12D
New York, New York  10022

+1 212 588-9133 Phone
+1 212 588-9134 Fax






More information about the argus mailing list