Stas Bekman wrote:
Justin Erenkrantz wrote:
On Tue, Jan 29, 2002 at 12:45:16PM +0800, Stas Bekman wrote:
yes, but the documentation doesn't note this. Does this mean that any API that doesn't specify const, is free to change the data without saying so?
In theory, yes. But, it *should* be noted in the documentation as well. Please feel free to submit a patch to fix that. However, the real thing to do is to make it so that it doesn't need to modify the char* or make it copy when it sees the odd formats.
ok, it's tomorrow in my place :)
Do you think we still need to modify the docs, if now the function doesn't modify its date arg?
Index: srclib/apr-util/misc/apr_date.c
===================================================================
RCS file: /home/cvspublic/apr-util/misc/apr_date.c,v
retrieving revision 1.8
diff -u -r1.8 apr_date.c
--- srclib/apr-util/misc/apr_date.c 19 Jan 2002 12:40:03 -0000 1.8
+++ srclib/apr-util/misc/apr_date.c 29 Jan 2002 17:31:51 -0000
@@ -349,6 +349,7 @@
apr_time_t result;
int mint, mon;
char *monstr, *timstr, *gmtstr;
+ char dummy[8];
static const int months[12] =
{
('J' << 16) | ('a' << 8) | 'n', ('F' << 16) | ('e' << 8) | 'b',
@@ -473,7 +474,9 @@
ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); monstr = date + 3;
- timstr = date + 10;
+ strncpy(dummy, date + 10, 8);
+ timstr = dummy;
+
timstr[6] = '0';
timstr[7] = '0';
gmtstr = NULL;
@@ -488,7 +491,8 @@
ds.tm_mday = (date[0] - '0');monstr = date + 2; - timstr = date + 9; + strncpy(dummy, date + 9, 8); + timstr = dummy;
timstr[6] = '0';
timstr[7] = '0';
@@ -504,7 +508,8 @@
ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0');monstr = date + 3; - timstr = date + 9; + strncpy(dummy, date + 9, 8); + timstr = dummy;
timstr[0] = '0';
gmtstr = date + 18;
@@ -519,7 +524,8 @@
ds.tm_mday = (date[0] - '0');monstr = date + 2; - timstr = date + 8; + strncpy(dummy, date + 8, 8); + timstr = dummy;
timstr[0] = '0';
gmtstr = date + 17;_____________________________________________________________________ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://ticketmaster.com http://apacheweek.com http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
