Commit Graph

4379 Commits

Author SHA1 Message Date
Jim Meyering 0a9f091665 Don't include "save-cwd.h". It's no longer used. 2004-05-11 16:14:11 +00:00
Jim Meyering 0837deb037 (AD_push): Don't use errno in diagnostic about `changed dev/ino'. 2004-05-10 14:27:45 +00:00
Jim Meyering 6e9bba3889 (unquote): Use xcalloc rather than xmalloc and
a loop initializing the just-allocated memory to zero.
2004-05-09 19:29:42 +00:00
Jim Meyering 2e83808dd6 Fix bug where "rm" gave up too easily, reported by Dan Jacobsen in
<http://mail.gnu.org/archive/html/bug-coreutils/2004-05/msg00013.html>.

(remove_entry): Check for errno values like ENOENT
that show the file cannot be directory, instead of for errno
values like EPERM that show the file might be a directory.  This
is necessary because, when a single unlink() call has multiple
reasons to fail, it can set errno to any of those reasons; it's
only the rare errno value like ENOENT that excludes all the other
possible reasons to fail even when the file is a directory.
(remove_cwd_entries): Don't attempt chdir if the file is known
to not be a directory.
(remove_dir): Use the same method that remove_cwd_entries uses
(for some reason they differed).  Don't assert that saved_errno
must be EPERM; it might be just about anything.
2004-05-08 12:49:22 +00:00
Jim Meyering 89bba9158d (main): Use xnmalloc, rather than xmalloc. 2004-05-06 14:51:20 +00:00
Jim Meyering e93ae52456 (main): Use xnmalloc, rather than xmalloc. 2004-05-06 14:50:17 +00:00
Jim Meyering 4d9d9f4d02 (list_entries_users): Use xnmalloc, rather than xmalloc. 2004-05-06 14:49:32 +00:00
Jim Meyering 433aacf5c6 (do_wipefd): Use xnmalloc, rather than xmalloc. 2004-05-06 14:48:07 +00:00
Jim Meyering 1c4154dbb0 (xgetgroups): Use variable name, rather than type name in computing buffer
size for xnmalloc.
2004-05-06 14:46:00 +00:00
Jim Meyering 76ef73f50a (xgetgroups): Use xnmalloc, rather than xmalloc.
Don't add `1' to the buffer size (it was to protect against malloc
implementations that fail to allocate a buffer of size zero).
That is no longer necessary, since we use a malloc wrapper
on such systems.
2004-05-06 14:43:31 +00:00
Jim Meyering 782b73c514 (main): Use xnmalloc, rather than xmalloc. 2004-05-06 14:24:50 +00:00
Jim Meyering 94c2794761 (elide_tail_bytes_pipe): Use xnmalloc, rather than xmalloc. 2004-05-06 14:24:16 +00:00
Jim Meyering 4de12cc012 (get_input_fstatus): Use xnmalloc, rather than xmalloc. 2004-05-06 14:23:08 +00:00
Jim Meyering 3145fdd1ed (show_disk, show_point): If several filesystems are
mounted on the same mount point, prefer the last one, not the first.
Problem reported by Christian Jones in
<http://mail.gnu.org/archive/html/bug-coreutils/2004-04/msg00200.html>.
(show_disk): Remove unused statp arg.  Return bool, not int.
(show_point): Rewrite to avoid gotos.  Use the same algorithm
for lofs and dummies for each pass through the mount table,
rather than subtly different algorithms (which are probably
inadvertent).
2004-05-04 07:26:33 +00:00
Jim Meyering 617884e704 . 2004-05-03 11:07:59 +00:00
Jim Meyering 83db4e147a When chown or chgrp is modifying the referent of a symlink,
use the chown(2) function, if possible.

(change_file_owner): Don't hard-code the
open/fchown/close kludge here.  Use `chown' instead.
The chown function works just fine on conforming systems.
Other systems now go through the new chown wrapper that
resorts to the old kludge.
2004-05-01 14:33:41 +00:00
Jim Meyering 27b510575d (change_file_owner): Add a comment. 2004-05-01 06:48:55 +00:00
Jim Meyering 70b9c50903 . 2004-04-29 16:03:21 +00:00
Jim Meyering 173f088735 . 2004-04-27 19:01:00 +00:00
Jim Meyering 372762d891 (syntax_table, re_syntax_table): Remove declarations of two unused
variables (they were exposed by the above change).
2004-04-27 18:39:21 +00:00
Jim Meyering 335b993492 Make over 40 global extern variables `static'. 2004-04-27 18:37:14 +00:00
Jim Meyering ee5d9d5b14 (sc_tight_scope): Also check for global variables, (BSS section). 2004-04-27 17:03:58 +00:00
Jim Meyering 3353acdf8f Rename to sc_tight_scope. 2004-04-27 16:57:23 +00:00
Jim Meyering 72e9f1ce4b (backup_type): Declare `static'. 2004-04-27 16:36:03 +00:00
Jim Meyering ec38270d8e (opt_nul_terminate_output): Declare `static'. 2004-04-27 16:34:47 +00:00
Jim Meyering b480c61d5e (G_fail): Declare `static'. 2004-04-27 16:32:43 +00:00
Jim Meyering a84b7ad221 (forget_created, remember_created)
(src_to_dest_lookup, remember_copied, hash_init, forget_all):
Add `extern' keyword.
2004-04-27 15:02:11 +00:00
Jim Meyering 68c7c2d2fa (dest_info_init, src_info_init, copy): Add `extern' keyword. 2004-04-27 15:01:31 +00:00
Jim Meyering 03f9a376a4 (chopt_init, chopt_free, gid_to_name, uid_to_name, chown_files):
Add `extern' keyword.
2004-04-27 15:01:12 +00:00
Jim Meyering b34611fd0f (rm): Add `extern' keyword. 2004-04-27 15:00:32 +00:00
Jim Meyering 37989d195a . 2004-04-27 14:57:48 +00:00
Jim Meyering 36968546e5 (sc_src_functions_have_static_scope): New rule. 2004-04-27 14:57:33 +00:00
Jim Meyering 53080d0a85 . 2004-04-26 16:31:14 +00:00
Jim Meyering 30ea278e1b (limfield): Make a comment clearer. 2004-04-26 15:37:33 +00:00
Jim Meyering 41cc9a718a Fix POSIX-conformance bug: "sort -k 3,3.5b" is supposed to skip
leading blanks when computing the location of the field end;
it is not supposed to skip trailing blanks.  Solaris 8 "sort"
does conform to POSIX.  Also fix the documentation to clarify
this and related issues.

(limfield): Use skipeblanks, not skipsblanks, to
decode whether to skip leading blanks.
(trailing_blanks): Remove.
(fillbuf, getmonth, keycompare): Don't trim trailing blanks.
2004-04-26 15:31:13 +00:00
Jim Meyering 48d44f4301 . 2004-04-24 08:09:52 +00:00
Jim Meyering adc30a8396 More signal-handling cleanup for ls.c. Do not allow signals to
happen between arbitrary output bytes, as the
restore-default-color sequence can bollix up multibyte chars or
color-change sequences in the ordinary output.  Instead, process
signals only between printing a file name and changing the color
back to non_filename_text color.  That way, if the signal handler
changes the color (to the default), 'ls' will change it back when
'ls' continues (after being suspended).

Also, do not bother with signal-handling unless stdout is a
controlling terminal; this lets stdio buffer better when "ls
--color" is piped or sent to a file.

(sigprocmask, sigset_t) [!defined SA_NOCLDSTOP]: New macros.
Do not include "full-write.h"; no longer needed.
(tcgetpgrp) [! HAVE_TCGETPGRP]: New macro.
(put_indicator_direct): Remove.  All callers changed to use
put_indicator.
(caught_signals, interrupt_signal, stop_signal_count): New vars.
(restore_default_color): Don't bother checking for put_indicator
failure.
(sighandler): Don't handle SIGTSTP; that's another handler now.
Simply set interrupt_signal to the signal, then exit.
(stophandler, process_signals): New functions.
(main): Don't output any color changes until _after_ the signal
handlers are set up.  This fixes a race condition where 'ls'
could be interrupted while initializing colors, and leaving the
terminal in an undesirable state.
Don't mess with signal-handling if standard output is not a
controlling terminal.
When exiting, restore the default color, then restore the
default signal handling, then act on any signals that weren't
acted on yet.
Do not print //DIRED// etc. in colors; this avoids the need
to catch signals when printing them.
(print_name_with_quoting): Process signals just before switching
color back to non_filename_text.
2004-04-24 08:03:15 +00:00
Jim Meyering e356a9a6ea Avoid segfault on systems for which SIZE_MAX != (size_t) -1.
(quote_name): Use SIZE_MAX, not -1, in calls of quotearg_buffer.
Patch by Mikulas Patocka.
2004-04-23 17:32:25 +00:00
Jim Meyering ed4778772c (main): Do not ignore SIGPIPE, as POSIX 1003.1-2001
does not allow this.  This undoes the 1996-10-24 patch.
2004-04-21 14:26:09 +00:00
Jim Meyering 8ab60c41be - csplit sometimes failed to remove files when interrupted.
- csplit didn't clean up if two signals arrived nearly simultaneously.

(sigprocmask, sigset_t) [!defined SA_NOCLDSTOP]: Define.
(filename_space, prefix, suffix, digits, files_created, remove_files): Now volatile.
(caught_signals): New var.
(cleanup): Block signals while deleting all files.
(cleanup_fatal, handle_line_error, regexp_error):
Mark with ATTRIBUTE_NORETURN.
(create_output_file, close_output_file, interrupt_handler):
Block signals while changing the number of output files,
to fix some race conditions.
(delete_all_files): Do nothing if remove_files is zero.
Clear files_created.
(main): Don't mess with signals until after argument processing is done.

(main): Rewrite signal-catching code to make it
similar to other coreutils programs.  When processing signals,
block all signals that we catch, but do not block signals that we
don't catch.  Avoid problems with unsigned int warnings.

(interrupt_handler): Use void, not (obsolete) RETSIGTYPE.

(interrupt_handler) [defined SA_NOCLDSTOP]:
Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent.
2004-04-21 12:57:33 +00:00
Jim Meyering eae1b7f862 - ls could incorrectly restore color if multiple signals
arrived nearly simultaneously.

(main): Rewrite signal-catching code to make it
similar to other coreutils programs.  When processing signals,
block all signals that we catch, but do not block signals that we
don't catch.  Avoid problems with unsigned int warnings.

(sighandler) [defined SA_NOCLDSTOP]:
Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent.

(sighandler) [!defined SA_NOCLDSTOP]: Reset signal
handler to self, not to SIG_IGN, since SIGTSTP can be received more than once.
(main): Use SA_RESTART, as that is simpler than checking for EINTR
failures all over the place.
2004-04-21 12:51:27 +00:00
Jim Meyering 4441496397 install -s failed on System V if SIGCHLD was ignored.
Include <signal.h>.
(main) [defined SIGCHLD]: Set SIGCHLD handler to the default,
if -s is given, since System V fork+wait does not work if SIGCHLD
is ignored.
2004-04-21 12:25:18 +00:00
Jim Meyering f4e0a51788 (is_empty_dir): Clarify comment. 2004-04-20 18:13:43 +00:00
Jim Meyering d432ccecc8 (main) [!defined _POSIX_SOURCE]:
Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent.
2004-04-20 15:10:07 +00:00
Jim Meyering 7b6892c3df (main): Rewrite signal-catching code to make it
similar to other coreutils programs.  When processing signals,
block all signals that we catch, but do not block signals that we
don't catch.  Avoid problems with unsigned int warnings.

(sighandler) [defined SA_NOCLDSTOP]:
Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent.
2004-04-20 15:08:57 +00:00
Jim Meyering 31ef15a49f (sigill_handler, isaac_seed_machdep): Use void, not (obsolete) RETSIGTYPE. 2004-04-20 15:05:40 +00:00
Jim Meyering bb5a8d159c (main) [!defined _POSIX_SOURCE]:
Use simpler "signal (sig, SIG_IGN)" rather than sigaction equivalent.
2004-04-20 10:44:42 +00:00
Jim Meyering 3d286f8c91 . 2004-04-20 10:18:48 +00:00
Jim Meyering d3cb92f9b8 Don't include pathmax.h; system.h already does it. 2004-04-20 09:34:43 +00:00
Jim Meyering 50469e2c80 . 2004-04-20 09:21:30 +00:00