Jim Meyering [Thu, 3 Jul 1997 12:16:41 +0000 (12:16 +0000)]
(apply_attributes): New function.
(copy_reg): Use apply_attributes instead of open-coding the pieces.
Now, failure to preserve file attributes does not cause mv to change
its exit status, and such failures elicit warning diagnostics. This
behavior is required by POSIX. Before, failure to preserve ownership
due to insufficient access was diagnosed only for root.
Prompted by a report from Bengt Martensson.
Jim Meyering [Wed, 2 Jul 1997 16:07:44 +0000 (16:07 +0000)]
(STRTOX): Convert function header in macro definition
to K&R-style. Otherwise, ansi2knr would fail to convert the function
definitions to K&R for old style compilers. From Kaveh Ghazi.
Jim Meyering [Tue, 1 Jul 1997 11:50:39 +0000 (11:50 +0000)]
(make_path): Reorder stat-then-mkdir-if-missing
calls so that mkdir is called first. Before make_path would first
`stat' a directory, then call mkdir if it didn't exist. But if
some other process created the directory between the stat & mkdir,
the mkdir would fail with EEXIST. Diagnosis and suggestion from
Greg McGary.
Jim Meyering [Tue, 1 Jul 1997 11:30:08 +0000 (11:30 +0000)]
[putenv]: Undefine before including system headers.
Otherwise, the declaration of *rpl_putenv* conflicts with the system
prototype on at least Irix5.3. From Marcus Daniels.
Jim Meyering [Sun, 29 Jun 1997 22:21:42 +0000 (22:21 +0000)]
(copy_reg): New parameter, SOURCE_STATS.
(do_move): Update caller.
(movefile): Take new boolean parameter, DEST_IS_DIR,
to save a stat per moved file when the destination is a directory.
(main): Call movefile with additional argument.
(strip_trailing_slashes_2): New function.
(movefile): Remove trailing slashes from dest. Otherwise, stat ("b/")
fails with ENOTDIR on systems including Linux w/libc 2.0.30.
Reproduce with `rm -rf a b; mkdir a; touch b; ./mv a b/'.
(do_move): Fix misleading comment.
Jim Meyering [Sun, 22 Jun 1997 19:52:24 +0000 (19:52 +0000)]
Use variable width columns when printing in multi-column mode.
(init_col_info): New function.
(print_current_files): Call init_col_info if format is
`many_per_line' or `horizontal'.
(print_many_per_line): Calculate optimum column widths.
(print_horizontal): Likewise.
From Ulrich Drepper.
Jim Meyering [Sun, 15 Jun 1997 13:34:47 +0000 (13:34 +0000)]
Rewrite using save-cwd.c and chdir to remove quadratic component of complexity.
Before, it processed O(n^2) directory name components via stat and mkdir.
Now it's O(n). This makes mkdir -p a lot more efficient when creating
directories with very many components. On a Linux 2.0.30 ext2fs filesystem
this command: mkdir -p `perl -e 'print "a/" x 500'` now runs in 0.77 seconds
(user+sys). Contrast that with the 9.5(!) seconds it took before.
Jim Meyering [Sat, 14 Jun 1997 17:31:40 +0000 (17:31 +0000)]
(cut_fields): Detect when the input is empty and handle
that special case. Before `cut -f1 </dev/null' would improperly
output a single newline. Reported by Phil Richards.
Jim Meyering [Wed, 11 Jun 1997 20:18:15 +0000 (20:18 +0000)]
(docolon): Test (re_buffer.re_nsub > 0) rather than
searching for `\(' to determine whether to return 0 or the empty
string. Before it would improperly return '' if the pattern
contained a substring like this: `\\('. From Karl Heuer.
For example, running expr c : '\\(' should print `0'.