Re: [xslt] Troubles with the EXSLT date extensions



> Doh! I implemented difference backwards. I should have been subtracting
y - x
> (like you did). This means that the seconds function is also wrong.
> However, I was trying to show that it is still possible for multiple items
in
> the duration object to have negative values which the format function will
not
> handle correctly (i.e. embedded '-' in the output string). See the new
patch for
> an example.

Aaaaaaa... aaa... may the Lord strike me awake, that embedded '-' has
escaped my attention. No, embedding a '-' is not an acceptable act, not for
a duration format function :-)

> I'll start making changes.

Eh? Does that mean you wish to fix the format function? Okay with me. I have
also done so, but yours is the baby :-)

I saw just after realising the existence of that embedded '-' that the
format function calls xmlXPathCastNumberToString(), and that means that it
may never pass it a negative argument. I then thought about ensuring that
all possible arguments to the XPath function are positive. You think this is
okay?

Ciao
Igor


RCS file: /cvs/gnome/libxslt/libexslt/date.c,v
retrieving revision 1.15
diff -c -r1.15 date.c
*** date.c      17 Sep 2002 16:13:44 -0000      1.15
--- date.c      18 Sep 2002 10:15:25 -0000
***************
*** 1058,1076 ****
      years  = (double)(dt->mon / 12);
      months = (double)(dt->mon % 12);

      if (secs < 0.0) {
          secs = -secs;
!         *cur++ = '-';
!     } else if (days < 0) {
          days = -days;
!         *cur++ = '-';
!     } else if (years < 0) {
          years = -years;
!         *cur++ = '-';
!     } else if (months < 0) {
          months = -months;
!         *cur++ = '-';
      }

      *cur++ = 'P';

--- 1058,1082 ----
      years  = (double)(dt->mon / 12);
      months = (double)(dt->mon % 12);

+     *cur = '\0';
      if (secs < 0.0) {
          secs = -secs;
!         *cur = '-';
!     }
!     if (days < 0) {
          days = -days;
!         *cur = '-';
!     }
!     if (years < 0) {
          years = -years;
!         *cur = '-';
!     }
!     if (months < 0) {
          months = -months;
!         *cur = '-';
      }
+     if (*cur == '-')
+       cur++;

      *cur++ = 'P';




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]