|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Behavior of $date->info method
Date: Jan 31 2003 4:31PM
On Fri, 2003-01-31 at 07:17, Eduard.Mostert@sybase.com wrote:
> Folks,
>
> I have stumbled across a strange behavior of the $date->info method. Am I
> missing something? I hope not. Anyway, when I use the method more than
> once, I get "more than I asked for" - literally. It seems that the buffer
> is not fully cleared for the new result set. Thus if the first output
> string is longer than the second output string, the second result will have
> the additional characters, from the first string, appended. For example,
> if you have dates that fall on a Wednesday and Tuesday, the results of
> $date-info(CS_DAYNAME) will be "Wednesday" and "Tuesdayay".
Yikes!
I can indeed reproduce this. Seems that cs_dt_info() doesn't null
terminate the strings (which I should have known!).
Patch below:
Index: CTlib.xs
===================================================================
RCS file: /usr/local/cvsroot/Sybase/CTlib/CTlib.xs,v
retrieving revision 1.55
diff -u -c -r1.55 CTlib.xs
*** CTlib.xs 31 Oct 2002 20:39:00 -0000 1.55
--- CTlib.xs 31 Jan 2003 16:27:59 -0000
***************
*** 7801,7808 ****
if(cs_dt_info(context, CS_GET, NULL, op, item,
buff, 32, &ret) != CS_SUCCEED)
warn("cs_dt_info failed");
! else
RETVAL = buff;
}
}
OUTPUT:
--- 7822,7831 ----
if(cs_dt_info(context, CS_GET, NULL, op, item,
buff, 32, &ret) != CS_SUCCEED)
warn("cs_dt_info failed");
! else {
! buff[ret] = 0;
RETVAL = buff;
+ }
}
}
OUTPUT:
Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler@peppler.org http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.mbay.net/~mpeppler/resume.html
|