sh-utils

hualin gao hualin_gao at yahoo.com
Sun Mar 11 09:19:28 PST 2001


delete line 181 to 313.
delete line 83 to 90;

I think you will be fine.

See the line number and contents below.
I am not familar with patch, if somwone can make a
patch, that's will be great.



Gao


 83	/* How many days come before each month (0-12). 
*/
    84	const unsigned short int __mon_yday[2][13] =
    85	  {
    86	    /* Normal years.  */
    87	    { 0, 31, 59, 90, 120, 151, 181, 212, 243,
273, 304, 334, 365 },
    88	    /* Leap years.  */
    89	    { 0, 31, 60, 91, 121, 152, 182, 213, 244,
274, 305, 335, 366 }
    90	  };




   181	/* Convert *TP to a time_t value, inverting
   182	   the monotonic and mostly-unit-linear
conversion function CONVERT.
   183	   Use *OFFSET to keep track of a guess at the
offset of the result,
   184	   compared to what the result would be for UTC
without leap seconds.
   185	   If *OFFSET's guess is correct, only one
CONVERT call is needed.  */
   186	time_t
   187	__mktime_internal (struct tm *tp,
   188			   struct tm *(*convert) (const time_t *,
struct tm *),
   189			   time_t *offset)
   190	{
   191	  time_t t, dt, t0, t1, t2;
   192	  struct tm tm;
       
   193	  /* The maximum number of probes (calls to
CONVERT) should be enough
   194	     to handle any combinations of time zone
rule changes, solar time,
   195	     leap seconds, and oscillations around a
spring-forward gap.
   196	     POSIX.1 prohibits leap seconds, but some
hosts have them anyway.  */
   197	  int remaining_probes = 6;
       
   198	  /* Time requested.  Copy it in case CONVERT
modifies *TP; this can
   199	     occur if TP is localtime's returned value
and CONVERT is localtime.  */
   200	  int sec = tp->tm_sec;
   201	  int min = tp->tm_min;
   202	  int hour = tp->tm_hour;
   203	  int mday = tp->tm_mday;
   204	  int mon = tp->tm_mon;
   205	  int year_requested = tp->tm_year;
   206	  int isdst = tp->tm_isdst;
       
   207	  /* Ensure that mon is in range, and set year
accordingly.  */
   208	  int mon_remainder = mon % 12;
   209	  int negative_mon_remainder = mon_remainder <
0;
   210	  int mon_years = mon / 12 -
negative_mon_remainder;
   211	  int year = year_requested + mon_years;
       
   212	  /* The other values need not be in range:
   213	     the remaining code handles minor overflows
correctly,
   214	     assuming int and time_t arithmetic wraps
around.
   215	     Major overflows are caught at the end.  */
       
   216	  /* Calculate day of year from year, month,
and day of month.
   217	     The result need not be in range.  */
   218	  int yday = ((__mon_yday[__isleap (year +
TM_YEAR_BASE)]
   219		       [mon_remainder + 12 *
negative_mon_remainder])
   220		      + mday - 1);
       
   221	  int sec_requested = sec;
   222	#if LEAP_SECONDS_POSSIBLE
   223	  /* Handle out-of-range seconds specially,
   224	     since ydhms_tm_diff assumes every minute
has 60 seconds.  */
   225	  if (sec < 0)
   226	    sec = 0;
   227	  if (59 < sec)
   228	    sec = 59;
   229	#endif
       
   230	  /* Invert CONVERT by probing.  First assume
the same offset as last time.
   231	     Then repeatedly use the error to improve
the guess.  */
       
   232	  tm.tm_year = EPOCH_YEAR - TM_YEAR_BASE;
   233	  tm.tm_yday = tm.tm_hour = tm.tm_min =
tm.tm_sec = 0;
   234	  t0 = ydhms_tm_diff (year, yday, hour, min,
sec, &tm);
       
   235	  for (t = t1 = t2 = t0 + *offset;
   236	       (dt = ydhms_tm_diff (year, yday, hour,
min, sec,
   237				    ranged_convert (convert, &t, &tm)));
   238	       t1 = t2, t2 = t, t += dt)
   239	    if (t == t1 && t != t2
   240		&& (isdst < 0 || tm.tm_isdst < 0
   241		    || (isdst != 0) != (tm.tm_isdst != 0)))
   242	      /* We can't possibly find a match, as we
are oscillating
   243		 between two values.  The requested time
probably falls
   244		 within a spring-forward gap of size DT. 
Follow the common
   245		 practice in this case, which is to return a
time that is DT
   246		 away from the requested time, preferring a
time whose
   247		 tm_isdst differs from the requested value. 
In practice,
   248		 this is more useful than returning -1.  */
   249	      break;
   250	    else if (--remaining_probes == 0)
   251	      return -1;
       
   252	  /* If we have a match, check whether
tm.tm_isdst has the requested
   253	     value, if any.  */
   254	  if (dt == 0 && isdst != tm.tm_isdst && 0 <=
isdst && 0 <= tm.tm_isdst)
   255	    {
   256	      /* tm.tm_isdst has the wrong value.  Look
for a neighboring
   257		 time with the right value, and use its UTC
offset.
   258		 Heuristic: probe the previous three calendar
quarters (approximately),
   259		 looking for the desired isdst.  This isn't
perfect,
   260		 but it's good enough in practice.  */
   261	      int quarter = 7889238; /* seconds per
average 1/4 Gregorian year */
   262	      int i;
       
   263	      /* If we're too close to the time_t
limit, look in future quarters.  */
   264	      if (t < TIME_T_MIN + 3 * quarter)
   265		quarter = -quarter;
       
   266	      for (i = 1; i <= 3; i++)
   267		{
   268		  time_t ot = t - i * quarter;
   269		  struct tm otm;
   270		  ranged_convert (convert, &ot, &otm);
   271		  if (otm.tm_isdst == isdst)
   272		    {
   273		      /* We found the desired tm_isdst.
   274			 Extrapolate back to the desired time.  */
   275		      t = ot + ydhms_tm_diff (year, yday,
hour, min, sec, &otm);
   276		      ranged_convert (convert, &t, &tm);
   277		      break;
   278		    }
   279		}
   280	    }
       
   281	  *offset = t - t0;
       
   282	#if LEAP_SECONDS_POSSIBLE
   283	  if (sec_requested != tm.tm_sec)
   284	    {
   285	      /* Adjust time to reflect the tm_sec
requested, not the normalized value.
   286		 Also, repair any damage from a false match
due to a leap second.  */
   287	      t += sec_requested - sec + (sec == 0 &&
tm.tm_sec == 60);
   288	      if (! (*convert) (&t, &tm))
   289		return -1;
   290	    }
   291	#endif
       
   292	  if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60
< 3)
   293	    {
   294	      /* time_t isn't large enough to rule out
overflows in ydhms_tm_diff,
   295		 so check for major overflows.  A gross check
suffices,
   296		 since if t has overflowed, it is off by a
multiple of
   297		 TIME_T_MAX - TIME_T_MIN + 1.  So ignore any
component of
   298		 the difference that is bounded by a small
value.  */
       
   299	      double dyear = (double) year_requested +
mon_years - tm.tm_year;
   300	      double dday = 366 * dyear + mday;
   301	      double dsec = 60 * (60 * (24 * dday +
hour) + min) + sec_requested;
       
   302	      /* On Irix4.0.5 cc, dividing TIME_T_MIN
by 3 does not produce
   303		 correct results, ie., it erroneously gives a
positive value
   304		 of 715827882.  Setting a variable first then
doing math on it
   305		 seems to work.  (ghazi at caip.rutgers.edu) */
       
   306	      const time_t time_t_max = TIME_T_MAX;
   307	      const time_t time_t_min = TIME_T_MIN;
       
   308	      if (time_t_max / 3 - time_t_min / 3 <
(dsec < 0 ? - dsec : dsec))
   309		return -1;
   310	    }
       
   311	  *tp = tm;
   312	  return t;
   313	}




--- Super <supers at oceanfree.net> wrote:
> may i have 1 too ?
> thanks
> 
> regards
> soragan
> 
> 
> Brett Haydon wrote:
> 
> > Whoops, posted this to the wrong list first time
> round..
> >
> > -----Original Message-----
> > From: Brett Haydon [mailto:bbhaydon at bigpond.com]
> > Sent: Sunday, 11 March 2001 5:24 PM
> > To: alfs-discuss at linuxfromscratch.org
> > Subject: re:sh-utils
> >
> > err 'scuse my ignorance
> >
> > but could someone send me a copy of the changed
> mktime.c file
> > so I can compile sh-utils on lfs 2.4.4.
> > I tried removing the offending functions but don't
> appear to
> > have fixed the situation.
> >
> > As I understand it this is the error message
> others are getting
> > as well:
> >
> > date.c: In function `set_tz':
> > date.c:196: warning: passing arg 1 of `putenv'
> discards qualifiers from
> > pointer target type
> > /usr/lib/libc.a(mktime.o): In function
> `__mktime_internal':
> >
>
/home/flepied/RPM/BUILD/glibc-2.1.3/time/mktime.c:227:
> multiple definition
> > of `__mon_yday'
> >
>
../lib/libsu.a(mktime.o):/mnt/lfs/usr/src/lfs-packages/sh-utils-2.0/lib/mkti
> > me.c:119: first defined here
> > /usr/lib/libc.a(mktime.o): In function
> `__mktime_internal':
> >
>
/home/flepied/RPM/BUILD/glibc-2.1.3/time/mktime.c:227:
> multiple definition
> > of `__mktime_internal'
> >
>
../lib/libsu.a(mktime.o):/mnt/lfs/usr/src/lfs-packages/sh-utils-2.0/lib/mkti
> > me.c:227: first defined here
> > /usr/bin/ld: Warning: size of symbol
> `__mktime_internal' changed from 991 to
> > 2440 in mktime.o
> > collect2: ld returned 1 exit status
> > make[2]: *** [date] Error 1
> > make[1]: *** [all-recursive] Error 1
> > make: *** [all-recursive-am] Error 2
> >
> > Thanks in advance,
> >
> > Brett Haydon
> >
> > --
> > Unsubscribe: send email to
> lfs-discuss-request at linuxfromscratch.org
> > and put unsubscribe in the subject header of the
> message
> 
> 
> -- 
> Unsubscribe: send email to
> lfs-discuss-request at linuxfromscratch.org
> and put unsubscribe in the subject header of the
> message
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/

-- 
Unsubscribe: send email to lfs-discuss-request at linuxfromscratch.org
and put unsubscribe in the subject header of the message




More information about the lfs-dev mailing list