home *** CD-ROM | disk | FTP | other *** search
/ pc.louisiana.edu/pub/unix/ / Louisiana_UNIX.tar / Louisiana_UNIX / xspread.sc.y2k.patch < prev    next >
Text File  |  1999-09-11  |  5KB  |  165 lines

  1. The following context diff allows xspread 2.1 to display a date value using
  2. four year digits, provided that the format has a precision value of 4, and
  3. the width value is sufficient to contain the result, e.g. f20,4,3
  4. Similar changes can be made to sc 6.21.
  5. -- James Dugal, jpd@usl.edu
  6. --------------------------------------------------------------------------
  7. *** format.c.orig    Fri Sep  3 19:51:31 1999
  8. --- format.c    Fri Sep  3 20:03:01 1999
  9. ***************
  10. *** 495,500 ****
  11. --- 495,501 ----
  12.    * David Fox - added a date format
  13.    * Philemon W. Johnson <pjohnson@itd.nrl.navy.mil>
  14.    * added exponent format, 19 July 92
  15. +  * 4-digit date added, when precision is set to 4: jpd@usl.edu
  16.    *
  17.    * This routine takes a value and formats it using fixed, scientific,
  18.    * engineering notation, date, or exponent (modulo 3).  The format command
  19. ***************
  20. *** 503,509 ****
  21.    *    0:   Fixed point (default)             0.00010
  22.    *    1:   Scientific                        1.00E-04
  23.    *    2:   Engineering                     100.00u
  24. !  *    3:   Date                              05/15/92
  25.    *    4:   Exponent, modulo 3              100.E-06
  26.    *
  27.    * The format command 'f' now uses three values.  The first two are the
  28. --- 504,510 ----
  29.    *    0:   Fixed point (default)             0.00010
  30.    *    1:   Scientific                        1.00E-04
  31.    *    2:   Engineering                     100.00u
  32. !  *    3:   Date                              15 May 92  or  15 May 1992
  33.    *    4:   Exponent, modulo 3              100.E-06
  34.    *
  35.    * The format command 'f' now uses three values.  The first two are the
  36. ***************
  37. *** 577,583 ****
  38.       case REFMTDATE:
  39.         {
  40.           int i;
  41. !         char *time;
  42.           long int secs;
  43.           /*
  44.            * sure hope that this is an 8 bit per character machine
  45. --- 578,584 ----
  46.       case REFMTDATE:
  47.         {
  48.           int i;
  49. !         char *temp_time;
  50.           long int secs;
  51.           /*
  52.            * sure hope that this is an 8 bit per character machine
  53. ***************
  54. *** 594,611 ****
  55.           else
  56.             {
  57.           secs = (time_t) val;
  58. !         time = ctime (&secs);
  59. !         buf[0] = time[8];
  60. !         buf[1] = time[9];
  61.           buf[2] = ' ';
  62. !         buf[3] = time[4];
  63. !         buf[4] = time[5];
  64. !         buf[5] = time[6];
  65.           buf[6] = ' ';
  66. !         buf[7] = time[22];
  67. !         buf[8] = time[23];
  68. !         for (i = 9; i < width; i++)
  69. !           buf[i] = ' ';
  70.           buf[i] = '\0';
  71.             }
  72.         }
  73. --- 595,617 ----
  74.           else
  75.             {
  76.           secs = (time_t) val;
  77. !         temp_time = ctime (&secs);
  78. !         buf[0] = temp_time[8];
  79. !         buf[1] = temp_time[9];
  80.           buf[2] = ' ';
  81. !         buf[3] = temp_time[4];
  82. !         buf[4] = temp_time[5];
  83. !         buf[5] = temp_time[6];
  84.           buf[6] = ' ';
  85. !         i = 7;
  86. !         if (lprecision == 4 && width > 10) {  /* use 4-digit year */
  87. !             buf[i++] = temp_time[20];
  88. !             buf[i++] = temp_time[21];
  89. !         }
  90. !         buf[i++] = temp_time[22];
  91. !         buf[i++] = temp_time[23];
  92. !         while(i < width)
  93. !           buf[i++] = ' ';
  94.           buf[i] = '\0';
  95.             }
  96.         }
  97. The following context diff allows xspread 2.1 to process dates > 1999
  98. (but < 2038) in the @dts function.  Similar changes could be made to sc 6.21.
  99. -- James Dugal, jpd@usl.edu
  100. ==========================================================================
  101. *** interp.c.orig    Mon Jun  1 09:38:50 1992
  102. --- interp.c    Fri Sep  3 19:35:16 1999
  103. ***************
  104. *** 481,490 ****
  105.       register int i;
  106.       register long jdate;
  107.   
  108. !     mdays[1] = 28 + (yr%4 == 0);
  109.   
  110.       if (mo < 1 || mo > 12 || day < 1 || day > mdays[--mo] ||
  111. !         yr > 1999 || yr < 1970) {
  112.       error("@dts: invalid argument");
  113.       cellerror = CELLERROR;
  114.       return(0.0);
  115. --- 481,490 ----
  116.       register int i;
  117.       register long jdate;
  118.   
  119. !     mdays[1] = 28 + (yr%4 == 0);      /* valid 1901 - 2099 */
  120.   
  121.       if (mo < 1 || mo > 12 || day < 1 || day > mdays[--mo] ||
  122. !         yr > 2037 || yr < 1970) {  /* Unix epoch=1970 overflows 32 bits in 2038 */
  123.       error("@dts: invalid argument");
  124.       cellerror = CELLERROR;
  125.       return(0.0);
  126. ***************
  127. *** 494,500 ****
  128.       for (i=0; i<mo; i++)
  129.           jdate += mdays[i];
  130.       for (i = 1970; i < yr; i++)
  131. !         jdate += 365 + (i%4 == 0);
  132.   
  133.       trial = jdate * sec_day; 
  134.   
  135. --- 494,500 ----
  136.       for (i=0; i<mo; i++)
  137.           jdate += mdays[i];
  138.       for (i = 1970; i < yr; i++)
  139. !         jdate += 365 + (i%4 == 0);   /* valid 1901 - 2099 */
  140.   
  141.       trial = jdate * sec_day; 
  142.   
  143. ***************
  144. *** 609,614 ****
  145. --- 609,627 ----
  146.   
  147.       if (!s1 && !s2)
  148.       return((double)1.0);
  149. + /* AJW@ansa.co.uk 20/4/94 start: treat NUL name ("") as nonexistent name */
  150. +     if (!s1 && !strlen(s2))
  151. +       { scxfree(s2);
  152. +     return((double)1.0);
  153. +       }
  154. +     if (!s2 && !strlen(s1))
  155. +       { scxfree(s1);
  156. +     return((double)1.0);
  157. +       }
  158. + /* AJW end */
  159.   
  160.       if (!s1 || !s2)
  161.       v = 0.0;
  162.