Skip to content
Tcl Source Code History Of Ticket 0b39decc76
Login

History Of Ticket 0b39decc76

Artifacts Associated With Ticket 0b39decc76

  1. Ticket change [aa8746b9b5] (rid 151411) by dexter1 on 2017-01-11 22:48:53:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      Challenge S server R4400 MIPS processor running IRIX 6.5.22m
      Built from 8.6.6 source with MIPSPro compiler 7.4.4 with vendor-patches applied.
      
      'make test' fails with:
      
      ==== clock-50.2 format / scan -2 as a local time FAILED
      ==== Contents of test case:
      
          if {[catch {
              clock scan  [clock format -2 -format %Y%m%d%H%M%S -timezone :localtime] 
       -format %Y%m%d%H%M%S -timezone :localtime
          } result]} {
              if { [regexp " too large" $result] } {
                  set result -2
              }
          }
          set result
      
      ---- Result was:
      -1
      ---- Result should have been (exact matching):
      -2
      ==== clock-50.2 FAILED
      
      This happens only when time conversions are issued with '-timezone :localtime' option in the 'clock scan' command. Omitting this option or substituting it with '-timezone :Europe/Amsterdam' will produce the correct result. This is because the mktime() routine is called only when :localtime is issued, in tclClock.c:899 to be exact.
      
      For completeness, in tcl this program shows the bug (expected -2, received -1):
      
      set c [clock format -2 -format %Y%m%d%H%M%S -timezone :localtime]
      puts [clock scan $c -format %Y%m%d%H%M%S -timezone :localtime]
      
      produces:
      
      cyane:~/tcltest> ../src/tcl8.6.6/unix/tcltest clock.tcl 
      -1
      
      IRIX libc function mktime() is old and breaks for pre-1970 tm structs: It will return -1 for all values before the epoch.
      On the other hand, localtime() accepts negative seconds and yields pre-epoch tm structs, so a conversion and back conversion yield different results for negative seconds. This test program demonstrates it:
      
      #include <stdio.h>
      #include <time.h>
      
      int main ()
      {
         time_t endseconds, startseconds = -2;
         endseconds = mktime( localtime( &startseconds ) );
         
         printf("conversion of seconds %d via localtime and mktime is %d\n",startsecon
      ds, endseconds);
      
         return(0);
      }
      
      produces:
      
      conversion of seconds -2 via localtime and mktime is -1
      
      I have substituted the mktime() function in IRIX libc with a mktime.c implementation pulled from netBSD source archive and this fixes the result in the C-example program.
      
      Adding a working mktime.c code in compat/ for IRIX builds with MIPSPro could work, or maybe re-route timezone calls with :localtime to a different function for IRIX.
      
    5. foundin initialized to: "8.6.6"
    6. is_private initialized to: "0"
    7. login: "dexter1"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "f6a32afcad2bdbc0e0c91beb6d44f2ddf022a09d"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "dexter1"
    14. subsystem initialized to: "06. Time Measurement"
    15. title initialized to:
      clock.test 50.2 fails for negative values in IRIX: broken mktime()
      
    16. type initialized to: "Bug"