[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: submitting patch for coreutils package
From: |
Paul Eggert |
Subject: |
Re: submitting patch for coreutils package |
Date: |
15 Dec 2003 11:37:02 -0800 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Chris Van Nuys <address@hidden> 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".