Skip to content
Tcl Source Code History Of Ticket c9eb6b0ac01bb8ef
Login

History Of Ticket c9eb6b0ac01bb8ef

Artifacts Associated With Ticket c9eb6b0ac01bb8ef

  1. Ticket change [267e170a2e] (rid 144064) by anonymous on 2015-12-10 12:10:34:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      This is with fossil trunk on FreeBSD 10.2-RELEASE-p7 amd64.
      
      If TZ is not set in the environment, the ConvertLocalToUTCUsingC will fail the first time it is called. To avoid this, make sure TzsetIfNecessary() always calls tzset the first time.
      
      <verbatim>
      Index: generic/tclClock.c
      ==================================================================
      --- generic/tclClock.c
      +++ generic/tclClock.c
      @@ -2005,25 +2005,28 @@
       static void
       TzsetIfNecessary(void)
       {
           static char *tzWas = NULL;	/* Previous value of TZ, protected by
       				 * clockMutex. */
      +    static char first = 1;	/* First time? */
           const char *tzIsNow;	/* Current value of TZ */
       
           Tcl_MutexLock(&clockMutex);
           tzIsNow = getenv("TZ");
      -    if (tzIsNow != NULL && (tzWas == NULL || strcmp(tzIsNow, tzWas) != 0)) {
      +    int mod = 	((size_t)tzWas ^ (size_t)tzIsNow) || 
      +		((size_t)tzWas & (size_t)tzIsNow && strcmp(tzIsNow, tzWas) != 0);
      +    if (first || mod) {
      +	first = 0;
       	tzset();
       	if (tzWas != NULL) {
       	    ckfree(tzWas);
      +	    tzWas = NULL;
       	}
      -	tzWas = ckalloc(strlen(tzIsNow) + 1);
      -	strcpy(tzWas, tzIsNow);
      -    } else if (tzIsNow == NULL && tzWas != NULL) {
      -	tzset();
      -	ckfree(tzWas);
      -	tzWas = NULL;
      +	if (tzIsNow != NULL) {
      +	    tzWas = ckalloc(strlen(tzIsNow) + 1);
      +	    strcpy(tzWas, tzIsNow);
      +	}
           }
           Tcl_MutexUnlock(&clockMutex);
       }
       
       /*
      </verbatim>
      
      Using this test driver
      
      <verbatim>
      package require clock::iso8601
      
      proc doit {} {
          try {
              ::tcl::clock::ConvertLocalToUTC {
                  tzName :localtime
                  century 19 
                  yearOfCentury 94
                  month 11
                  dayOfMonth 5
                  era CE
                  year 1994
                  julianDay 2449662
                  secondOfDay 0
                  localSeconds 783993600} {} 2299161
          } on error msg {
              return "$msg\n[info errorstack]"
          }
      }
      
      puts [doit]
      puts [doit]
      
      </verbatim>
      
      I get this with a non-patched version of Tcl:
      
      <verbatim>
      time value too large/small to represent
      INNER {invokeStk1 ::tcl::clock::ConvertLocalToUTC {
                  tzName :localtime
                  century 19 
                  yearOfCentury 94
                  month 11
                  dayOfMonth 5
                  era CE
                  year 1994
                  julianDay 2449662
                  secondOfDay 0
                  localSeconds 783993600} {} 2299161} CALL doit
      tzName :localtime century 19 yearOfCentury 94 month 11 dayOfMonth 5 era CE year 1994 julianDay 2449662 secondOfDay 0 localSeconds 783993600 seconds 783993600
      </verbatim>
      
      And this with a patched version:
      
      <verbatim>
      tzName :localtime century 19 yearOfCentury 94 month 11 dayOfMonth 5 era CE year 1994 julianDay 2449662 secondOfDay 0 localSeconds 783993600 seconds 783993600
      tzName :localtime century 19 yearOfCentury 94 month 11 dayOfMonth 5 era CE year 1994 julianDay 2449662 secondOfDay 0 localSeconds 783993600 seconds 783993600
      
      </verbatim>
      
    5. foundin initialized to: "8.6"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "438e59f1f1c891b29d2528ed82d1e629cecc6336"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "06. Time Measurement"
    15. title initialized to:
      ConvertLocalToUTCUsingC fails the first time if TZ is not set
      
    16. type initialized to: "Bug"
  2. Ticket change [7358efa0f7] (rid 144925) by gahr on 2016-02-16 21:59:09:

    1. closedate changed to: "2457435.41608516"
    2. closer changed to: "gahr"
    3. icomment: "Fixed by checkin [38e14f6cc3]"
    4. login: "gahr"
    5. mimetype: "text/x-fossil-wiki"
    6. status changed to: "Closed"
    7. username: "gahr"