bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fwd: Patch for fileutils to display extended user and group names]


From: Guy Fraser
Subject: [Fwd: Patch for fileutils to display extended user and group names]
Date: Mon, 02 Apr 2001 14:58:32 -0600

 
--- Begin Message --- Subject: Re: Patch for fileutils to display extended user and group names Date: Mon, 2 Apr 2001 07:07:05 -0500 User-agent: Mutt/1.3.15i
[ I am very sorry for the late response to this message.  Since we are a
  small non-profit, messages to this address often get backlogged, and we
  are always struggling to catch-up. ]

Guy Fraser <address@hidden> wrote:
> 
> I put some small changes into ls.c to enable a togglable option to
> allow user and group names to print with more than 8 characters.

Please send bug reports, enhancements, and enhancement requests for this
program to <address@hidden>
 
> I did this to allow scripts to work properly when the owner and/or
> group are longer than 8 characters. People keep creating them so
> I thought it would be a good idea to make a provision to allow
> them to be displayed when required.
> 
> The options :
> 
> short)        -E
> long) --extended
> 
> Here are a couple of examples
> 
> # /usr/local/bin/ls -lE /home
> total 52
> drwx------    2 abcdefghijklmnopqrstuvwxyz
> abcdefghijklmnopqrstuvwxyz     4096 Feb  6 18:55
> abcdefghijklmnopqrstuvwxyz
> drwx------    6 acdc     wheel        4096 Oct 18 19:44 acdc
> drwx------    2 xalapa22 wheel        4096 Jun  8  2000 xalapa22
> drwx------    7 incipid  incipid      4096 Jan 30 15:32 incipid
> drwx------    2 gordon_fleischer gordon_fleischer     4096 Feb  6 18:49
> gordon_fleischer
> 
> or can be untoggled
> 
> # /usr/local/bin/ls -lEE /home
> total 52
> drwx------    2 abcdefgh abcdefgh     4096 Feb  6 18:55
> abcdefghijklmnopqrstuvwxyz
> drwx------    6 acdc     wheel        4096 Oct 18 19:44 acdc
> drwx------    2 xalapa22 wheel        4096 Jun  8  2000 xalapa22
> drwx------    7 incipid  incipid      4096 Jan 30 15:32 incipid
> drwx------    2 gordon_f gordon_f     4096 Feb  6 18:49 gordon_fleischer
> 
> Guy
> 
> fileutils-4.0.38-ls-extended.patch
> ----cut
> here--------------------------------------------------------------------
> diff -ruN fileutils-4.0.38-dist/src/ls.c fileutils-4.0.38/src/ls.c
> --- fileutils-4.0.38-dist/src/ls.c    Sun Jan 28 14:42:59 2001
> +++ fileutils-4.0.38/src/ls.c Tue Feb  6 22:33:50 2001
> @@ -36,6 +36,9 @@
>     Flaherty <address@hidden> based on original patches by
>     Greg Lee <address@hidden>.  */
>  
> +/* Extended length user and group name support by Guy Fraser
> <address@hidden>.
> +   Short option -E and long option --extended toggle this feature. */
> +
>  #ifdef _AIX
>   #pragma alloca
>  #endif
> @@ -362,6 +365,11 @@
>  
>  static int files_index;
>  
> +/* Nonzero means display upto 16 characters for username and group. 
> -E  */
> +
> +static int extended;
> +#define EXTENDED_FMT "%-8s "
> +
>  /* When nonzero, in a color listing, color each symlink name according
> to the
>     type of file it points to.  Otherwise, color them according to the
> `ln'
>     directive in LS_COLORS.  Dangling (orphan) symlinks are treated
> specially,
> @@ -699,6 +707,7 @@
>    {"ignore-backups", no_argument, 0, 'B'},
>    {"classify", no_argument, 0, 'F'},
>    {"file-type", no_argument, 0, 'p'},
> +  {"extended", no_argument, 0, 'E'},
>    {"si", no_argument, 0, 'H'},
>    {"ignore", required_argument, 0, 'I'},
>    {"indicator-style", required_argument, 0, INDICATOR_STYLE_OPTION},
> @@ -1034,6 +1043,8 @@
>    all_files = 0;
>    really_all_files = 0;
>    ignore_patterns = 0;
> +  extended = 0;
> +
>  
>    /* FIXME: Shouldn't we complain on wrong values? */
>    if ((p = getenv ("QUOTING_STYLE"))
> @@ -1086,7 +1097,7 @@
>      }
>  
>    while ((c = getopt_long (argc, argv,
> -                        "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UX1",
> +                        "abcdfghiklmnopqrstuvw:xABCDEFGHI:LNQRST:UX1",
>                          long_options, NULL)) != -1)
>      {
>        switch (c)
> @@ -1221,6 +1232,10 @@
>         dired = 1;
>         break;
>  
> +     case 'E':
> +       extended = 1 - extended;
> +     break;
> +
>       case 'F':
>         indicator_style = classify;
>         break;
> @@ -2509,21 +2524,31 @@
>    p += strlen (p);
>  
>    user_name = (numeric_ids ? NULL : getuser (f->stat.st_uid));
> -  if (user_name)
> -    sprintf (p, "%-8.8s ", user_name);
> -  else
> -    sprintf (p, "%-8u ", (unsigned int) f->stat.st_uid);
> -  p += strlen (p);
> -
> -  if (!inhibit_group)
> -    {
> -      char *group_name = (numeric_ids ? NULL : getgroup
> (f->stat.st_gid));
> -      if (group_name)
> -     sprintf (p, "%-8.8s ", group_name);
> +    if (user_name)
> +      {
> +      if (!extended)
> +        sprintf (p, "%-8.8s ", user_name);
>        else
> -     sprintf (p, "%-8u ", (unsigned int) f->stat.st_gid);
> -      p += strlen (p);
> -    }
> +        sprintf (p, EXTENDED_FMT, user_name);
> +      }
> +    else
> +      sprintf (p, "%-8u ", (unsigned int) f->stat.st_uid);
> +    p += strlen (p);
> +
> +    if (!inhibit_group)
> +      {
> +     char *group_name = (numeric_ids ? NULL : getgroup (f->stat.st_gid));
> +     if (group_name)
> +       {
> +            if (!extended)
> +           sprintf (p, "%-8.8s ", group_name);
> +         else
> +           sprintf (p, EXTENDED_FMT, group_name);
> +       }
> +     else
> +       sprintf (p, "%-8u ", (unsigned int) f->stat.st_gid);
> +     p += strlen (p);
> +      }
>  
>    if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode))
>      sprintf (p, "%3u, %3u ", (unsigned) major (f->stat.st_rdev),
> @@ -3270,6 +3295,7 @@
>                                 types.  WHEN may be `never', `always',
> or `auto'\n\
>    -d, --directory            list directory entries instead of
> contents\n\
>    -D, --dired                generate output designed for Emacs' dired
> mode\n\
> +  -E, --extended             toggle display full length user and group
> names\n\
>    -f                         do not sort, enable -aU, disable -lst\n\
>    -F, --classify             append indicator (one of */=@|) to
> entries\n\
>        --format=WORD          across -x, commas -m, horizontal -x, long
> -l,\n\
> ----cut
> here--------------------------------------------------------------------

-- 
Bradley M. Kuhn, Vice President
Free Software Foundation     |  Phone: +1-617-542-5942
59 Temple Place, Suite 330   |  Fax:   +1-617-542-2652
Boston, MA 02111-1307  USA   |  Web:   http://www.gnu.org

Attachment: pgpmWxOpV0ZWY.pgp
Description: PGP signature


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]