It's standard behaviour to map a whole class of matched objects
to the last element of a given simple set2 instead of just passing
it through.
Also, error out more strictly when the user gives us bogus sets.
tr(1) always used to be a saddening part of sbase, which was
inherently broken and crufted.
But to be fair, the POSIX-standard doesn't make it very simple.
Given the current version was unfixable and broken by design, I
sat down and rewrote tr(1) very close to the concept of set theory
and the POSIX-standard with a few exceptions:
- UTF-8: not allowed in POSIX, but in my opinion a must. This
finally allows you to work with UTF-8 streams without
problems or unexpected behaviour.
- Equivalence classes: Left out, even GNU coreutils ignore them
and depending on LC_COLLATE, which sucks.
- Character classes: No experiments or environment-variable-trickery.
Just plain definitions derived from the POSIX-
standard, working as expected.
I tested this thoroughly, but expect problems to show up in some
way given the wide range of input this program has to handle.
The only thing left on the TODO is to add support for literal
expressions ('\n', '\t', '\001', ...) and probably rethinking
the way [_*n] is unnecessarily restricted to string2.
1) No limit on number of months (removed MONTHMAX)
2) Strings printed to stdout rather than copied to an internal buffer
3) Rewritten date calculation algorithms
The list is getting too long. Leave the maintainers at the top
and add a section of authors/contributors below the license statement.
Helps maintain the license at the top of the file.
Consider the following code:
pw = getpwuid(uid);
if (!pw) {
if (errno)
...
else
...
}
If the entry was not found then as per POSIX errno is not set
because that is not considered to be a failing condition. errno
is only set if an internal error occurred.
If errno happened to be non-zero before the getpwuid() call
because of a previous error then we'll report a bogus error.
In this case, we have to set errno to zero before the call to
getpwuid().
However in ls(1) we only really care if the password entry was found
and we do not report any errors so setting errno to 0 is not necessary.
There's no point free-ing memory when the kernel can do it for us.
Just reuse the already allocated memory to hold lines.
Thanks Truls Becken for pointing this out.
The -d option is a GNU extension and is equivalent to its "-P
--preserve=links" options.
Since we don't implement the --preserve=links functionality anyway (it
means preserve hard links between files), just call it -P, which is
specified by POSIX.
Additionally, there is no need to check for cp_Pflag again before
copying the symlink itself because the only way the mode in the stat
will indicate a symlink is if we used lstat (which we only do if -P is
specified).