Commit 669adfcd authored by Daniel Veillard's avatar Daniel Veillard
Browse files

applied a patch from Charles Bozeman fixing a side effect in date handling

* test/schemas/date_0.xml xmlschemastypes.c: applied a patch from
  Charles Bozeman fixing a side effect in date handling
Daniel
parent 218ed39d
Sat May 29 21:35:52 CEST 2004 Daniel Veillard <daniel@veillard.com>
* test/schemas/date_0.xml xmlschemastypes.c: applied a patch from
Charles Bozeman fixing a side effect in date handling
Thu May 27 19:47:48 MDT 2004 John Fleck <jfleck@inkstain.net>
 
* doc/tutorial/xmltutorial.xml fix lack of cast in Xpath example
......
......@@ -217,7 +217,8 @@ pnode=pxmlDoc-&gt;children-&gt;children;</pre>
<p>Website: <a
href="http://pmade.org/pjones/software/xmlwrapp/">http://pmade.org/pjones/software/xmlwrapp/</a></p>
</li>
--></ul></li>
-->
</ul></li>
<li>How to validate a document a posteriori ?
<p>It is possible to validate documents which had not been validated at
initial parsing time or documents which have been built from scratch
......
This diff is collapsed.
......@@ -12,6 +12,7 @@
<date1>2000-05-18Z</date1>
<dt1>2000-05-18T00:00:00</dt1>
<dt2>2002-05-19T21:30:00.99</dt2>
<dt1>1969-12-31T23:00:01-01:00</dt1>
<hol>--01-01</hol>
<hol>--07-04</hol>
<hol>--12-25</hol>
......
......@@ -2607,6 +2607,26 @@ xmlSchemaCompareDurations(xmlSchemaValPtr x, xmlSchemaValPtr y)
#define FQUOTIENT_RANGE(a,low,high) (FQUOTIENT((a-low),(high-low)))
#define MODULO_RANGE(a,low,high) ((MODULO((a-low),(high-low)))+low)
/**
* xmlSchemaDupVal:
* @v: the #xmlSchemaValPtr value to duplicate
*
* Makes a copy of @v. The calling program is responsible for freeing
* the returned value.
*
* returns a pointer to a duplicated #xmlSchemaValPtr or NULL if error.
*/
static xmlSchemaValPtr
xmlSchemaDupVal (xmlSchemaValPtr v)
{
xmlSchemaValPtr ret = xmlSchemaNewValue(v->type);
if (ret == NULL)
return NULL;
memcpy(ret, v, sizeof(xmlSchemaVal));
return ret;
}
/**
* _xmlSchemaDateAdd:
* @dt: an #xmlSchemaValPtr
......@@ -2614,14 +2634,15 @@ xmlSchemaCompareDurations(xmlSchemaValPtr x, xmlSchemaValPtr y)
*
* Compute a new date/time from @dt and @dur. This function assumes @dt
* is either #XML_SCHEMAS_DATETIME, #XML_SCHEMAS_DATE, #XML_SCHEMAS_GYEARMONTH,
* or #XML_SCHEMAS_GYEAR.
* or #XML_SCHEMAS_GYEAR. The returned #xmlSchemaVal is the same type as
* @dt. The calling program is responsible for freeing the returned value.
*
* Returns date/time pointer or NULL.
* Returns a pointer to a new #xmlSchemaVal or NULL if error.
*/
static xmlSchemaValPtr
_xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur)
{
xmlSchemaValPtr ret;
xmlSchemaValPtr ret, tmp;
long carry, tempdays, temp;
xmlSchemaValDatePtr r, d;
xmlSchemaValDurationPtr u;
......@@ -2633,8 +2654,15 @@ _xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur)
if (ret == NULL)
return NULL;
/* make a copy so we don't alter the original value */
tmp = xmlSchemaDupVal(dt);
if (tmp == NULL) {
xmlSchemaFreeValue(ret);
return NULL;
}
r = &(ret->value.date);
d = &(dt->value.date);
d = &(tmp->value.date);
u = &(dur->value.dur);
/* normalization */
......@@ -2740,32 +2768,20 @@ _xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur)
}
}
return ret;
}
xmlSchemaFreeValue(tmp);
/**
* xmlSchemaDupVal:
* @v: value to duplicate
*
* returns a duplicated value.
*/
static xmlSchemaValPtr
xmlSchemaDupVal (xmlSchemaValPtr v)
{
xmlSchemaValPtr ret = xmlSchemaNewValue(v->type);
if (ret == NULL)
return ret;
memcpy(ret, v, sizeof(xmlSchemaVal));
return ret;
}
/**
* xmlSchemaDateNormalize:
* @dt: an #xmlSchemaValPtr
* @dt: an #xmlSchemaValPtr of a date/time type value.
* @offset: number of seconds to adjust @dt by.
*
* Normalize @dt to GMT time.
* Normalize @dt to GMT time. The @offset parameter is subtracted from
* the return value is a time-zone offset is present on @dt.
*
* Returns a normalized copy of @dt or NULL if error.
*/
static xmlSchemaValPtr
xmlSchemaDateNormalize (xmlSchemaValPtr dt, double offset)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment