Chris Van Nuys <[EMAIL PROTECTED]> writes:

> +   if (print_octal_mode)
> +       {
> +       sprintf(p, "[%4o] ", f->stat.st_mode & 07777);
> +        p += strlen (p);
> +       }

Jim already commented that we shouldn't use up an option letter for
this.  There's another portability issue: you cannot assume in general
that st_mode & 07777 will print the correct value.  This is because
POSIX does not guarantee that st_mode has the usual encoding.  It is
valid to have a POSIX implementation where S_IXOTH != 1, for example.
So, for portable code, you have to write a long expression like this:

  (f->stat.st_mode & S_IXOTH ? 1 : 0)
+ (f->stat.st_mode & S_IWOTH ? 2 : 0)
+ (f->stat.st_mode & S_IROTH ? 4 : 0)
+ ...

instead of writing "f->stat.st_mode & 07777".


_______________________________________________
Bug-coreutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to