###############################################################################
#
# File:         fileutils-3.12.LS.3times.patch
# RCS:          $Header: $
# Description:  add NeXT like -v switch to gnu ls
# Author:       Christian Limpach <chris@nice.ch>
# Created:      Mon Apr  3 20:49:28 1995
# Modified:     Mon Apr  3 21:44:41 1995 (Christian Limpach) chris@nice.ch
# Language:     patch
# Package:      N/A
# Status:       Experimental (Do Not Distribute)
#
# (C) Copyright 1995, Christian Limpach, all rights reserved.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see ftp://nice.ethz.ch/users/chris/TERMS
# for details. This software comes with ABSOLUTELY NO WARRANTY.
#
###############################################################################

# patches for 3.9 by Marcel Waldvogel
# updated to 3.12
diff -rc /tmp/fileutils-3.12/man/ls.1 fileutils-3.12/man/ls.1
*** /tmp/fileutils-3.12/man/ls.1	Tue Apr 26 22:08:55 1994
--- fileutils-3.12/man/ls.1	Sun Apr  2 00:17:56 1995
***************
*** 187,192 ****
--- 187,208 ----
  .B COLUMNS
  is used if it is set; otherwise the default is 80.
  .TP
+ .I "\-3, \-\-three-times"
+ List all three times in a long format listing, making an entry three
+ lines long, one each for modification (labelled `mod'), inode change
+ (`ino') and access (`acc') time.
+ .TP
+ .I "\-v"
+ Give a very verbose output listing (almost) all information contained
+ in the inode. This is the same as the concatenation of the
+ .IR \-l ,
+ .IR \-s ,
+ .IR \-i ,
+ .IR \-F
+ and
+ .IR \-3
+ options.
+ .TP
  .I "\-T, \-\-tabsize cols"
  Assume that each tabstop is
  .I cols
diff -rc /tmp/fileutils-3.12/src/ls.c fileutils-3.12/src/ls.c
*** /tmp/fileutils-3.12/src/ls.c	Fri Nov  4 06:08:15 1994
--- fileutils-3.12/src/ls.c	Sun Apr  2 00:16:56 1995
***************
*** 276,281 ****
--- 276,285 ----
  
  static int print_block_size;
  
+ /* Nonzero means show all three times (only if long is also selected).  -3  */
+ 
+ static int three_times;
+ 
  /* Nonzero means show file sizes in kilobytes instead of blocks
     (the size of which is system-dependent).  -k */
  
***************
*** 421,426 ****
--- 425,431 ----
    {"sort", required_argument, 0, 10},
    {"tabsize", required_argument, 0, 'T'},
    {"time", required_argument, 0, 11},
+   {"three-times", no_argument, 0, '3'},
    {"help", no_argument, &show_help, 1},
    {"version", no_argument, &show_version, 1},
    {0, 0, 0, 0}
***************
*** 698,704 ****
    p = getenv ("TABSIZE");
    tabsize = p ? atoi (p) : 8;
  
!   while ((c = getopt_long (argc, argv, "abcdfgiklmnpqrstuw:xABCDFGI:LNQRST:UX1",
  			   long_options, (int *) 0)) != EOF)
      {
        switch (c)
--- 703,710 ----
    p = getenv ("TABSIZE");
    tabsize = p ? atoi (p) : 8;
  
!   while ((c = getopt_long (argc, argv,
!                            "abcdfgiklmnpqrstuvw:xABCDFGI:LNQRST:UX13",
  			   long_options, (int *) 0)) != EOF)
      {
        switch (c)
***************
*** 784,789 ****
--- 790,804 ----
  	  time_type = time_atime;
  	  break;
  
+ 	case 'v':
+ 	  /* Same as enabling -l, -i, -s, -F, and -3 */
+ 	  format = long_format;
+ 	  print_inode = 1;
+ 	  print_block_size = 1;
+ 	  three_times = 1;
+ 	  indicator_style = all;
+ 	  break;
+ 
  	case 'w':
  	  line_length = atoi (optarg);
  	  if (line_length < 1)
***************
*** 864,869 ****
--- 879,888 ----
  	  format = one_per_line;
  	  break;
  
+ 	case '3':
+ 	  three_times = 1;
+ 	  break;
+ 
  	case 10:		/* +sort */
  	  i = argmatch (optarg, sort_args);
  	  if (i < 0)
***************
*** 1516,1521 ****
--- 1535,1571 ----
      }
  }
  
+ static char *
+ fill_time(timebuf, when)
+     char *timebuf;
+     time_t when;
+ {
+   strcpy (timebuf, ctime (&when));
+ 
+   if (full_time)
+     timebuf[24] = '\0';
+   else
+     {
+       if (current_time > when + 6L * 30L * 24L * 60L * 60L /* Old. */
+ 	  || current_time < when - 60L * 60L) /* In the future. */
+ 	{
+ 	  /* The file is fairly old or in the future.
+ 	     POSIX says the cutoff is 6 months old;
+ 	     approximate this by 6*30 days.
+ 	     Allow a 1 hour slop factor for what is considered "the future",
+ 	     to allow for NFS server/client clock disagreement.
+ 	     Show the year instead of the time of day.  */
+ 	  strcpy (timebuf + 11, timebuf + 19);
+ 	}
+       timebuf[16] = 0;
+     }
+   
+   if (full_time)
+     return timebuf;
+   else
+     return timebuf+4;
+ }
+ 
  static void
  print_long_format (f)
       struct fileinfo *f;
***************
*** 1531,1573 ****
    char bigbuf[7 * 20 + 10 + 24 + 9 + 1];
    char *p;
    time_t when;
  
    mode_string (f->stat.st_mode, modebuf);
    modebuf[10] = '\0';
  
!   switch (time_type)
!     {
!     case time_ctime:
!       when = f->stat.st_ctime;
!       break;
!     case time_mtime:
!       when = f->stat.st_mtime;
!       break;
!     case time_atime:
!       when = f->stat.st_atime;
!       break;
!     }
! 
!   strcpy (timebuf, ctime (&when));
! 
!   if (full_time)
!     timebuf[24] = '\0';
    else
      {
!       if (current_time > when + 6L * 30L * 24L * 60L * 60L /* Old. */
! 	  || current_time < when - 60L * 60L) /* In the future. */
! 	{
! 	  /* The file is fairly old or in the future.
! 	     POSIX says the cutoff is 6 months old;
! 	     approximate this by 6*30 days.
! 	     Allow a 1 hour slop factor for what is considered "the future",
! 	     to allow for NFS server/client clock disagreement.
! 	     Show the year instead of the time of day.  */
! 	  strcpy (timebuf + 11, timebuf + 19);
! 	}
!       timebuf[16] = 0;
      }
! 
    p = bigbuf;
  
    if (print_inode)
--- 1581,1609 ----
    char bigbuf[7 * 20 + 10 + 24 + 9 + 1];
    char *p;
    time_t when;
+   int len = 0;	/* indention to the mod field when printing three-times */
  
    mode_string (f->stat.st_mode, modebuf);
    modebuf[10] = '\0';
  
!   if (three_times)
!     when = f->stat.st_mtime;
    else
      {
!       switch (time_type)
!         {
!         case time_ctime:
!           when = f->stat.st_ctime;
!           break;
!         case time_mtime:
!           when = f->stat.st_mtime;
!           break;
!         case time_atime:
!           when = f->stat.st_atime;
!           break;
!         }
      }
!   
    p = bigbuf;
  
    if (print_inode)
***************
*** 1611,1617 ****
      sprintf (p, "%8lu ", (unsigned long) f->stat.st_size);
    p += strlen (p);
  
!   sprintf (p, "%s ", full_time ? timebuf : timebuf + 4);
    p += strlen (p);
  
    DIRED_INDENT ();
--- 1647,1660 ----
      sprintf (p, "%8lu ", (unsigned long) f->stat.st_size);
    p += strlen (p);
  
!   if (three_times)
!     {
!       len = p - bigbuf;
!       sprintf (p, "mod ");
!       p += strlen (p);
!     }
!   
!   sprintf (p, "%s ", fill_time(timebuf, when));
    p += strlen (p);
  
    DIRED_INDENT ();
***************
*** 1632,1637 ****
--- 1675,1693 ----
      }
    else if (indicator_style != none)
      print_type_indicator (f->stat.st_mode);
+ 
+   if (three_times)
+     {
+       /* terminate current line and print additional two lines */
+       putchar('\n');
+       indent(0, len);
+       DIRED_INDENT ();
+       printf("ino %s", fill_time(timebuf, f->stat.st_ctime));
+       putchar('\n');
+       indent(0, len);
+       DIRED_INDENT ();
+       printf("acc %s", fill_time(timebuf, f->stat.st_atime));
+     }
  }
  
  
***************
*** 2154,2159 ****
--- 2210,2216 ----
    -x                         list entries by lines instead of by columns\n\
    -X                         sort alphabetically by entry extension\n\
    -1                         list one file per line\n\
+   -3, --three-times          list all three times in a long format listing\n\
        --help                 display this help and exit\n\
        --version              output version information and exit\n\
  \n\
