Re: [xslt] libexslt duration



Sorry about the warnings, my compiler didn't flag them. Here is a patch that hopefully
fixes them. Also here is the test files for duration functions.

Daniel Veillard wrote:

> On Wed, Apr 24, 2002 at 11:19:02PM -0600, Charles Bozeman wrote:
> > Daniel,
>
>   Hi Charlie,
>
> > This (rather large) patch adds duration routines to the date exslt
> > extensions. There are only 3 date-time routines that are yet to be
> > implemented (format-date, parse-date, and sum), but I don't know if I
> > will have to time to write them. I will package up the duration specific
> > test scripts and send them later.
> > This code might be of some use in the xml schema types you are
> > implementing. Let me know if I can be of assistance.
>
>   Okay, first I applied the patch, I just got a few warnings:
> -------------
> ../libxslt/xsltconfig.h:76:1: warning: "WITH_DEBUGGER" redefined
> ../config.h:12:1: warning: this is the location of the previous definition
> In file included from date.c:28:
> ../config.h:12:1: warning: "WITH_DEBUGGER" redefined
> ../libxslt/xsltconfig.h:76:1: warning: this is the location of the previous definition
> ------------
>   those are related to the recent changes w.r.t. WITH_DEBUGGER I need to track
> them down, they are just annoying.
>
> -------------
> date.c: In function `exsltDateParseDuration':
> date.c:950: warning: comparison between signed and unsigned
> date.c:964: warning: declaration of `mult' shadows previous local
> date.c:970: warning: comparison between signed and unsigned
> date.c:974: warning: comparison between signed and unsigned
> -------------
>
>   Those are tied to your code, doesn't sounds a big deal, but ...
>
>   Now considering Schemas, YES, I will need help on the datatype parts,
> it's being inserted as part of libxml2, the module is xmlschemastypes.c
> it is for the moment really basic, just the strict minimum necessary to
> not get errors on the few tests cases I have used so far. For example
> at the date level it handles only the date lexical space checking and doesn't
> map it into a value, nor have the routines associated to the canonical
> representations nor support for all the associated datatypes like time,
> duration, etc ... It would definitely make sense to keep the core routines
> in libxml2 export them and have them used by the Schemas code if compiled in
> and by libexslt on top of it too.
>
>   But so far doing it at the libexslt level is fine as long as only
> XSLT related entry points are made public, so that at some point those
> can be migrated in the underlying lib.
>
>   thanks !
>
> Daniel
>
> --
> Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
> veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
> http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt@gnome.org
> http://mail.gnome.org/mailman/listinfo/xslt
Index: date.c
===================================================================
RCS file: /cvs/gnome/libxslt/libexslt/date.c,v
retrieving revision 1.12
diff -c -r1.12 date.c
*** date.c	2002/04/25 06:19:42	1.12
--- date.c	2002/04/26 02:17:56
***************
*** 919,928 ****
   */
  static exsltDateValPtr
  exsltDateParseDuration (const xmlChar *duration) {
!     const xmlChar *cur     = duration;
      exsltDateValPtr dur;
      int isneg = 0;
!     int seq   = 0;
  
      if (duration == NULL)
  	return NULL;
--- 919,928 ----
   */
  static exsltDateValPtr
  exsltDateParseDuration (const xmlChar *duration) {
!     const xmlChar  *cur = duration;
      exsltDateValPtr dur;
      int isneg = 0;
!     unsigned int seq = 0;
  
      if (duration == NULL)
  	return NULL;
***************
*** 944,950 ****
          double         num;
          int            num_type = 0;  /* -1 = invalid, 0 = int, 1 = floating */
          const xmlChar  desig[] = {'Y', 'M', 'D', 'H', 'M', 'S'};
!         const double   mult[]  = { 0.0, 0.0, 86400.0, 3600.0, 60.0, 1.0, 0.0};
  
          /* input string should be empty or invalid date/time item */
          if (seq >= sizeof(desig))
--- 944,950 ----
          double         num;
          int            num_type = 0;  /* -1 = invalid, 0 = int, 1 = floating */
          const xmlChar  desig[] = {'Y', 'M', 'D', 'H', 'M', 'S'};
!         const double   multi[] = { 0.0, 0.0, 86400.0, 3600.0, 60.0, 1.0, 0.0};
  
          /* input string should be empty or invalid date/time item */
          if (seq >= sizeof(desig))
***************
*** 971,977 ****
              if (*cur == desig[seq]) {
  
                  /* verify numeric type; only seconds can be float */
!                 if ((num_type != 0) && (seq < (sizeof(desig-1))))
                      goto error;
  
                  switch (seq) {
--- 971,977 ----
              if (*cur == desig[seq]) {
  
                  /* verify numeric type; only seconds can be float */
!                 if ((num_type != 0) && (seq < (sizeof(desig)-1)))
                      goto error;
  
                  switch (seq) {
***************
*** 983,989 ****
                          break;
                      default:
                          /* convert to seconds using multiplier */
!                         dur->value.dur.sec += num * mult[seq];
                          seq++;
                          break;
                  }
--- 983,989 ----
                          break;
                      default:
                          /* convert to seconds using multiplier */
!                         dur->value.dur.sec += num * multi[seq];
                          seq++;
                          break;
                  }

date.tgz



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