Project/Real_code/gnu/coreutils-5.0/src/ls.c
static int
long_time_expected_width (void)
{
  static int width = -1;

  if (width < 0)
    {
      time_t epoch = 0;
      struct tm const *tm = localtime (&epoch);
      char const *fmt = long_time_format[0];
      char initbuf[100];
      char *buf = initbuf;
      size_t bufsize = sizeof initbuf;
      size_t len;

      for (;;)
	{
	  *buf = '\1';
	  len = nstrftime (buf, bufsize, fmt, tm, 0, 0);
	  if (len || ! *buf)
	    break;
	  buf = alloca (bufsize *= 2);
	}

      width = mbsnwidth (buf, len, 0);
      if (width < 0)
	width = 0;
    }

  return width;
}
/* Return the expected number of columns in a long-format time stamp,
   or zero if it cannot be calculated.  */
Return the expected number of columns in a long-format time stamp,
or zero if it cannot be calculated.
Return the expected number of columns in a long - format time stamp or zero if it cannot be calculated .
static int
long_time_expected_width (void)
{
  static int width = -1;
  if (width < 0)
    {
      time_t epoch = 0;
      struct tm const *tm = localtime (&epoch);
      char const *fmt = long_time_format[0];
      char initbuf[100];
      char *buf = initbuf;
      size_t bufsize = sizeof initbuf;
      size_t len;
      for (;;)
	{
	  *buf = '\1';
	  len = nstrftime (buf, bufsize, fmt, tm, 0, 0);
	  if (len || ! *buf)
	    break;
	  buf = alloca (bufsize *= 2);
	}
      width = mbsnwidth (buf, len, 0);
      if (width < 0)
	width = 0;
    }
  return width;
}
static int long_time_expected_width ( void ) { static int width = -1 ; if ( width < 0 ) { time_t epoch = 0 ; struct tm const * tm = localtime ( & epoch ) ; char const * fmt = long_time_format [ 0 ] ; char initbuf [ 100 ] ; char * buf = initbuf ; size_t bufsize = sizeof initbuf ; size_t len ; for ( ; ; ) { * buf = ' \1 ' ; len = nstrftime ( buf , bufsize , fmt , tm , 0 , 0 ) ; if ( len || ! * buf ) break ; buf = alloca ( bufsize *= 2 ) ; } width = mbsnwidth ( buf , len , 0 ) ; if ( width < 0 ) width = 0 ; } return width ; }
Return the expected number of columns in a long-format time stamp,
or zero if it cannot be calculated.
Return the expected number of columns in a long - format time stamp or zero if it cannot be calculated .