[Top][All Lists]

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

very obscure problem, help needed

From: David Pirotte
Subject: very obscure problem, help needed
Date: Sat, 07 Oct 2000 15:27:14 +0200

Hello guilers,

I apologies in advance: due to multiple technologies involved, it is
not possible for me to build an example that people on this list can
just launch and see what happens to help me.

I just hope that some folks will take few minutes to see if they woud
have encounterred the same problem in the past and help me.

Here is my problem, involving the following S/W:

        postgres 7.0
        apache:         Server version: Apache/1.3.12 (Unix)
                        Server built:   Apr  6 2000 08:56:04
        an html browser (netscape)
        guile:  analyses its arguments,
                queries postgres,
                generates html code that it sends to netscape

Guile script summary:

        #!/usr/local/bin/guile -s

        ;; html/apache protocol request this
        (display "Content-Type: text/html\n\n")

        (use-modules (oop goops))
        (use-modules (alto date))
        (use-modules (alto strings))

        (setenv "PGDATESTYLE" "German")

        (define  (getenv "QUERY_STRING"))
        (define args-tokens (get-tokens call-args #\,))
        (define cha-ref (list-ref args-tokens 0))
        (define proj-name (list-ref args-tokens 1))

        (define html-input
          (let ((hi (read-line)))
            (if (eof-object? hi)
                (get-tokens hi #\&))))

        ... some class definition and so on

        (define pg-con
         (pg-connectdb (format #f "~A ~A ~A"

        ... all postgres queries I need, based on call-args and html-input
==>     ... calling my date engine (see below)

==>     ... html page generation

        ;; closing connection and result pointers
        (define pg-result '())
        (define pg-con '())

        ;; end of guile script


        whithin my guile code, I call a 'date engine' which, among other
        things, computes dates in future and dates in the passed, given a swivel
        date, week-end days in a week and bank-holidays

        for some totaly obscure reasons to me so far (2 days of investigations)
        if, whithin a loop, I call (date-in-future ...),

        ===> I get several "Content-Type: text/html" written as the beginning
             of my html pages, just as if the guile script was called several

                exactly 1 "Content-Type: text/html"     
                per call to date-in-future              

NOW:    if I momentaraly define date-in-future to always reply the same integer,
        just to try to understand what is going on, everything is fine!

                (define (date-in-future-1 res-dte w-dn nb-days we bh)
                   ;; this represents "18/09/2000", european dd/mm/yyyy


        so far, I can only deduce that the code, both date-in-future and 
        date-in-the-passed, which are just 'symetric' are the culprits!

        here is date-in-future code: 

                its too complicated to pass the all date engine software,
                but I checked that the function 'open-day?' itself refering
                to a 'binary-search' function are not involved (forcing them
                to temporarily always return #t)

        (define (date-in-future-1 res-dte w-dn nb-days we bh)
          (do ()
              ((= nb-days 0)
               (if (open-day? res-dte we bh w-dn)
                   (do ((res-dte (+ res-dte 1)
                                 (+ res-dte 1))
                        (w-dn (remainder (+ w-dn 1) 7)
                              (remainder (+ w-dn 1) 7)))
                       ((open-day? res-dte we bh w-dn)
            (if (open-day? res-dte we bh w-dn)
                (set! nb-days (- nb-days 1)))
           (set! res-dte (+ res-dte 1))
            (set! w-dn (remainder (+ w-dn 1) 7))

        (define (date-in-future sw-dte nb-days we bh . inc-sw-dte?)
          ;; CAUTION: the are 2 ways of computing this:
          ;;          - in x days, we will be ...
          ;;            (if monday, in 5 days ==> saturday
          ;;          - in terms of duration: what will be the day name in 
          ;;                                  counting from swivel-dte (and not 
1+ swivel-dte)
          (if (= nb-days 0)
             (if (null? inc-sw-dte?)
                  (date-in-future-1 sw-dte
                                    (day-nb-in-week sw-dte)
                  (date-in-future-1 sw-dte (day-nb-in-week sw-dte)
                                    (- nb-days 1)

I am lost, any idea??
Many thanks for those who will get to the end of the message and try
to help me,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]