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'.
Jim Meyering [Wed, 28 May 1997 11:42:29 +0000 (11:42 +0000)]
(read_filesystem_list): Add `|| defined (__OpenBSD__)'
to the NetBSD #if so OpenBSD also uses the f_fstypename member.
(fstype_to_string): Add `&& !defined (__OpenBSD__)' to the NetBSD #if
expression to exclude this function definition. OpenBSD 2.1 beta
doesn't need it. Patch from Hugh Daniel <hugh@ecotone.xanadu.com>
Jim Meyering [Mon, 26 May 1997 04:46:47 +0000 (04:46 +0000)]
(copy_internal): When preserving symlinks (--no-dereference) and the
destination file is a symlink, use stat (not xstat) to see if it points
back to the source. Reported by James <james@albion.glarp.com>.
Jim Meyering [Sun, 25 May 1997 21:23:15 +0000 (21:23 +0000)]
Remove global variable opt_human_readable.
(enum Output_units): Rename from output_size.
Rename size_* to Unit_*.
Add Unit_variable to correspond to --human-readable.
(convert_blocks): Remove now-unused definition.
(human_readable): Rename paramater n_bytes to n_blocks.
Adjust conversions to reflect fact that input is now number of
512-byte blocks, not bytes.
(print_size): New function.
(du_files): Use print_size instead of open coding it.
(count_entry): Always count in units of 512-byte blocks to delay.
This lets du accumulate totals corresponding to a terabyte before
overflowing 32-bit long int.
Use print_size instead of open coding it.
Jim Meyering [Sun, 25 May 1997 14:21:41 +0000 (14:21 +0000)]
(convert_blocks): Remove now-unnecessary #undef.
(du_files): Pass output_size unchanged to convert_blocks. No need
to test output_size for size_bytes, convert_blocks handles that
correctly.
(count_entry): Likewise.
Jim Meyering [Sun, 25 May 1997 14:11:50 +0000 (14:11 +0000)]
(main): Implement new --max-depth=N option.
Based on the idea and a patch from Torbjorn Lindgren.
(du_files): Likewise.
(count_entry): Likewise.
[AIX]: Remove unused #pragma alloca.