[vms/committed]: Fix vms date display

Tristan Gingold gingold@adacore.com
Mon Jun 27 08:24:00 GMT 2011


Hi,

In order to be displayed, the VMS date is converted to UNIX.  In some case this conversion can't be done and this is detected in vms_time_to_time_t.  Unfortunately this detection was too strong and rejected valid dates.

Committed on trunk.

Tristan.

bfd/
2011-06-27  Tristan Gingold  <gingold@adacore.com>

	* vms-misc.c (vms_time_to_time_t): Adjust overflow detection.
	Add comment.


cvs diff: Diffing bfd
Index: bfd/vms-misc.c
===================================================================
RCS file: /cvs/src/src/bfd/vms-misc.c,v
retrieving revision 1.38
diff -c -r1.38 vms-misc.c
*** bfd/vms-misc.c	3 Aug 2010 15:18:51 -0000	1.38
--- bfd/vms-misc.c	27 Jun 2011 08:18:30 -0000
***************
*** 530,536 ****
     -  100ns granularity
     -  epoch is Nov 17, 1858.
     Here has the constants and the routines used to convert VMS from/to UNIX time.
!    The conversion routines don't assume 64 bits arithmetic.  */
  
  /* UNIX time granularity for VMS, ie 1s / 100ns.  */
  #define VMS_TIME_FACTOR 10000000
--- 530,539 ----
     -  100ns granularity
     -  epoch is Nov 17, 1858.
     Here has the constants and the routines used to convert VMS from/to UNIX time.
!    The conversion routines don't assume 64 bits arithmetic.
! 
!    Here we assume that the definition of time_t is the UNIX one, ie integer
!    type, expressing seconds since the epoch.  */
  
  /* UNIX time granularity for VMS, ie 1s / 100ns.  */
  #define VMS_TIME_FACTOR 10000000
***************
*** 546,551 ****
--- 549,555 ----
    unsigned int tmp;
    unsigned int rlo;
    int i;
+   time_t res;
  
    /* First convert to seconds.  */
    tmp = hi % VMS_TIME_FACTOR;
***************
*** 562,575 ****
    lo = rlo;
  
    /* Return 0 in case of overflow.  */
!   if (lo > VMS_TIME_OFFSET && hi > 1)
      return 0;
  
    /* Return 0 in case of underflow.  */
!   if (lo < VMS_TIME_OFFSET)
      return 0;
  
!   return lo - VMS_TIME_OFFSET;
  }
  
  /* Convert a time_t to a VMS time.  */
--- 566,583 ----
    lo = rlo;
  
    /* Return 0 in case of overflow.  */
!   if (hi > 1
!       || (hi == 1 && lo >= VMS_TIME_OFFSET))
      return 0;
  
    /* Return 0 in case of underflow.  */
!   if (hi == 0 && lo < VMS_TIME_OFFSET)
      return 0;
  
!   res = lo - VMS_TIME_OFFSET;
!   if (res <= 0)
!     return 0;
!   return res;
  }
  
  /* Convert a time_t to a VMS time.  */



More information about the Binutils mailing list