diff options
author | tjr <tjr@FreeBSD.org> | 2004-08-12 05:37:46 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2004-08-12 05:37:46 +0000 |
commit | a20bc469ca40f5ef5bfdb2a722a731356c0b3c88 (patch) | |
tree | 620b3c07b0df596abf6d4b574472fb8ac785ecfa /contrib/gnu-sort | |
parent | c024cb1aa77683262f434d4fe6c2fea366a53162 (diff) | |
download | FreeBSD-src-a20bc469ca40f5ef5bfdb2a722a731356c0b3c88.zip FreeBSD-src-a20bc469ca40f5ef5bfdb2a722a731356c0b3c88.tar.gz |
Import of GNU sort from coreutils CVS (trimmed)
Diffstat (limited to 'contrib/gnu-sort')
32 files changed, 3383 insertions, 578 deletions
diff --git a/contrib/gnu-sort/ABOUT-NLS b/contrib/gnu-sort/ABOUT-NLS index b6f64a0..8ffb467 100644 --- a/contrib/gnu-sort/ABOUT-NLS +++ b/contrib/gnu-sort/ABOUT-NLS @@ -301,7 +301,7 @@ translation percentage of at least 50%. +-------------------------------------------+ am az be bg ca cs da de el en en_GB eo es 0 0 8 3 37 38 56 73 15 1 5 12 64 - + et fa fi fr ga gl he hr hu id is it ja +----------------------------------------+ a2ps | [] [] [] () | @@ -427,7 +427,7 @@ translation percentage of at least 50%. +----------------------------------------+ et fa fi fr ga gl he hr hu id is it ja 21 1 25 86 24 24 8 10 38 31 1 23 32 - + ko lg lt lv ms nb nl nn no pl pt pt_BR ro +-------------------------------------------+ a2ps | () [] [] () () [] [] | @@ -553,7 +553,7 @@ translation percentage of at least 50%. +-------------------------------------------+ ko lg lt lv ms nb nl nn no pl pt pt_BR ro 12 0 1 2 12 10 60 4 4 38 25 35 76 - + ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW +-------------------------------------------+ a2ps | [] [] [] [] [] | 16 @@ -714,4 +714,3 @@ developed inside the GNU project. Therefore the information given above applies also for every other Free Software Project. Contact `translation@iro.umontreal.ca' to make the `.pot' files available to the translation teams. - diff --git a/contrib/gnu-sort/AUTHORS b/contrib/gnu-sort/AUTHORS index 1aea6b4..4e8a5d4 100644 --- a/contrib/gnu-sort/AUTHORS +++ b/contrib/gnu-sort/AUTHORS @@ -51,7 +51,7 @@ pinky: Joseph Arceneaux, David MacKenzie, and Kaveh Ghazi pr: Pete TerMaat and Roland Huebner printenv: David MacKenzie and Richard Mlynarik printf: David MacKenzie -ptx: François Pinard +ptx: François Pinard pwd: Jim Meyering rm: Paul Rubin, David MacKenzie, Richard Stallman, and Jim Meyering rmdir: David MacKenzie diff --git a/contrib/gnu-sort/ChangeLog b/contrib/gnu-sort/ChangeLog index 7836f77..c027655 100644 --- a/contrib/gnu-sort/ChangeLog +++ b/contrib/gnu-sort/ChangeLog @@ -1,3 +1,2474 @@ +2004-08-11 Paul Eggert <eggert@cs.ucla.edu> + + * tests/install/basic-1: Test for the -d regression. + +2004-08-11 Dmitry V. Levin <ldv@altlinux.org> + + * src/install.c (main): Fix -d regression introduced with + --target-directory support at 2004-06-25. + +2004-08-11 Paul Eggert <eggert@cs.ucla.edu> + + * src/copy.c (copy_internal): When preserving links, unlink + a destination with link count greater than one. This is so + that commands like "cp -a" don't get confused when copying into + a destination that already contains many hard links. Problem + reported by Tim Waugh in: + http://lists.gnu.org/archive/html/bug-coreutils/2004-08/msg00053.html + +2004-08-10 Paul Eggert <eggert@cs.ucla.edu> + + Convert all files to UTF-8. + * tests/fmt/basic (8-bit-pfx): Use UTF-8, not Latin-1. + * tests/sort/Test.pm (16a): Likewise. + * tests/uniq/Test.pm (8): Likewise. + * tests/misc/printf-hex: Use ASCII, not Latin-1. + + * NEWS: Document "sort -o -" and "tee -" POSIX-conformance fixes. + * src/shred.c (usage): "-" is an operand, not an option. + * src/sort.c (die, xfopen, mergefps, first_same_file, merge): + A null file arg means standard output. + (main): "-o -" means to write to a file named "-", + not to standard output. + * src/tee.c (usage, tee): "tee -" writes to standard output, not + to a file named "-". + +2004-08-10 Dmitry V. Levin <ldv@altlinux.org> + + * src/install.c (change_timestamps): Fix int->bool conversion + bugs introduced on 2004-07-29. + +2004-08-09 Paul Eggert <eggert@cs.ucla.edu> + + * src/shred.c (wipename): Work even if the directory is writeable + and not readable. Prefer write access, since this should work + better with fdatasync. + + * src/csplit.c (xalloc_die): New function. + (main): Remove now-obsolete initialization of xalloc_fail_func. + + * src/md5sum.c: Adjust to sha->sha1 renaming. + +2004-08-08 Dmitry V. Levin <ldv@altlinux.org> + + Minor code cleanup. + * src/readlink.c (canonicalize_fname): Remove unneeded proxy function. + (can_mode): Make variable local. + +2004-08-07 Paul Eggert <eggert@cs.ucla.edu> + + * src/system.h (O_BINARY) [!O_BINARY && defined O_BINARY]: + Do not define, to avoid annoying compiler messages on QNX 6.3. + Problem reported by Johan in: + http://lists.gnu.org/archive/html/bug-coreutils/2004-08/msg00050.html + +2004-08-04 Paul Eggert <eggert@cs.ucla.edu> + + * src/system.h (PRIdMAX, PRIoMAX, PRIuMAX, PRIxMAX): + Define to a concatenation of string literals, not to an expression; + needed for concatenation contexts. + (INTMAX_MAX, INTMAX_MIN): New macros. + + * src/stat.c (print_stat): Don't assume st_ino / st_dev fits in + unsigned long; this isn't true for st_ino on Solaris 9. + +2004-08-03 Paul Eggert <eggert@cs.ucla.edu> + + * src/uname.c: Do not depend on HAVE_SYSCTL when deciding + whether to include files. Include <sys/param.h> if + HAVE_SYS_PARAM_H (not HAVE_SYSCTL). + (main) [defined __POWERPC__]: Add a kludge to work around a + Mac OS X bug, so that uname -p defaults to "powerpc" if + sysctl ((int[]) {CTL_HW, HW_MACHINE_ARCH}, 2, buffer, &bufsize, 0, 0) + fails. Problem reported by Petter Reinholdtsen in: + http://lists.gnu.org/archive/html/bug-gnu-utils/2003-02/msg00201.html + + * src/uniq.c (hard_LC_COLLATE, ignore_case, different, check_file, + main): Use bool for booleans. + (writeline, check_file): Use uintmax_t for line counts. + (check_file): Check for and report line number overflow, + when that matters. + * src/wc.c (iswspace, wc): Use to_uchar rather than a cast. + (print_lines, print_words, print_chars, print_bytes, print_linelength, + have_read_stdin, wc, wc_file, main): + Use bool for booleans. + (exit_status): Remove. + (wc, wc_file): Return bool status. All callers changed. + * src/who.c (scan_entries): 0 -> STDIN_FILENO. + * src/whoami.c (main): Print uids using unsigned long int, not + unsigned int. + + * src/unexpand.c: Int cleanup and minor reorganization to be more + like src/expand.c. + Include quote.h, xstrndup.h. + (TAB_STOP_SENTINEL): Increase from INT_MAX to INTMAX_MAX. + (convert_entire_line, have_read_stdin, parse_tabstops, next_file, + unexpand, main): + Use bool for booleans. + (tab_size, tab_list, add_tabstop, validate_tabstops, unexpand): + Use uintmax_t for column counts. + (first_free_tab, validate_tabstops, unexpand): Use size_t for sizes. + (add_tabstop, parse_tabstops, main): Don't reserve UINTMAX_MAX + as a tab stop. + (parse_tabstops): Don't use ISBLANK on possibly-signed char. + Detect overflow in tab stop string. + (next_file, main): Use EXIT_FAILURE/EXIT_SUCCESS instead of 1/0. + (unexpand): Concatenate input files the same way expand does. + + * src/touch.c (no_create, use_ref, posix_date, amtime_now, + touch, main): Use bool for booleans. + (main): Avoid integer overflow when given more than INT_MAX + options. + * src/tsort.c (struct item, n_strings): Use size_t for sizes. + (have_read_stdin, count_items, scan_zeros, detect_loop, + recurse_tree, walk_tree, tsort, main): + Use bool for booleans. + (exit_status): Remove. + (tsort): Return a success flag instead of storing into a global. + (main): Use it. + * src/tty.c (silent, main): Use bool for booleans. + (main): 0 -> STDIN_FILENO. + * src/uname.c (print_element): Use bool for booleans. + + * src/test.c (TRUE, FALSE, SHELL_BOOLEAN, TRUTH_OR, TRUTH_AND): + Remove. All uses replaced by C99 boolean primitives. + (TEST_TRUE, TEST_FALSE): New constants, for readability. + (test_unop, binop, unary_operator, binary_operator, two_arguments, + three_arguments, posixtest, expr, term, and, or, is_int, age_of, + one_argument, main): Use bool for booleans. + (advance, unary_advance): Now inline procedures rather than a macros. + (is_int): Renamed from isint, to avoid namespace clash with ctype.h. + (term, and, or): When it's easy, loop instead of recursing. + (term): Avoid integer overflow if there are INT_MAX-3 args (!). + (binary_operator, unary_operator): Simplify by systematically rewriting + true==FOO to FOO (where FOO is a boolean). + (unary_operator): Don't consider a file to be a regular file + merely because its mode&S_IFMT is zero. Just use S_ISREG. + Remove unnecessary casts. Remove ifdefs for things like + S_ISSOCK that are no longer needed, since stat-macros.h always + defines them now. + + * src/tac-pipe.c (buf_init_from_stdin, find_bol, tac_mem): + Use bool for booleans. + (buf_init_from_stdin, buf_free, find_bol, print_line): + Use size_t for sizes. + * src/tac.c (separator_ends_record, tac_seekable, tac_file, + tac_stdin, tac_stdin_to_mem, main): Use bool for booleans. + (match_length, G_buffer_size, tac_seekable, main): Use size_t for sizes. + (tac_seekable): Use ptrdiff_t for pointer subtraction. + Report an error if the result is out of range. + (tac_seekable, main): Check for integer overflow in buffer size + calculations. + (main): Remove unnecessary casts. + + * src/su.c (run_shell): Pass a new n_additional_args arg, so that + the callee doesn't have to count 'em. All callers changed. + Don't allocate more space for the arg vector than we'll need. + Use memcpy to copy the args rather than rolling our own loop. + Use size_t for sizes. + (fast_startup, simulate_login, change_environment, log_su, + correct_password, restricted_shell, main): Use bool for booleans. + (longopts): Don't assume change_environment is an int. + Use NULL, not 0, for pointers. + (xsetenv): New function, replacing xputenv and concat. + All callers changed. + (elements): Remove; no longer needed. + (log_su, correct_passwd, main): Prefer !x to x==NULL. + (log_su): 2 -> STDERR_FILENO. + (modify_environment, main): Don't assume that getenv's returned value + has an indefinite lifetime. + (modify_environment): Allocate a larger environ. + (main): Remove an impossible 'case 0'; if it happens now, it'll + get diagnosed. Don't assume getpwnam results outlive endpwent. + Check for null or empty pw_name, pw_dir and for null pw_passwd. + + * src/stty.c (VA_START): Remove. All callers now use va_start. + (_POSIX_VDISABLE): Remove unnecessary cast. + (struct control_info, visible): Use cc_t for control chars. + (struct control_info): Use size_t for sizes. + (recover_mode, set_mode, display_speed, display_window_size, + valid_options, main, display_changed): + Use bool for booleans. + (integer_arg): Return unsigned long int, not long int. + Accept new max arg; all callers changed, to specify a maximum + value for integer parameters instead of silently overflowing. + (wrap): Do not overrun the stack buffer if the output contains + more than 1024 bytes. Instead, malloc a buffer. + (main): Remove a "what is this?!?" FIXME. Nobody knows what it is. + Remove unnecessary casts. + (set_control_char): Allow int values only up to cc_t range. + (screen_columns): Don't reject INT_MAX. + (display_changed, display_all, display_speed, recover_mode): + Don't assume cc_t fits in int. + + * src/remove.h: Add copyright notice. + (struct rm_options): Use bool for booleans. + * src/rmdir.c (empty_paths, ignore_fail_on_non_empty, verbose, + errno_rmdir_non_empty, remove_parents, main): Likewise. + * src/sum.c (have_read_stdin, bsd_sum_file, sysv_sum_file, + main): Likewise. + (main): Don't dump core if invoked with argv[0]==NULL. + * src/tee.c (tee, append, ignore_interrupts, main, tee): + Use bool for booleans. + (tee): Use ssize_t for read returns. + + * src/ptx.c: Add a FIXME mentioning that there are many + unchecked integer overflows in this file. + (gnu_extensions, auto_reference, input_reference, right_reference, + ignore_case, initialize_regex, fix_output_parameters, + output_one_roff_line, output_one_text_line, output_one_dumb_line, main): + Use bool for booleans. + (SKIP_SOMETHING, compare_words, digest_break_file, + find_occurs_in_text, fix_output_parameters): + Use to_uchar instead of a caset. + (print_field): Rewrite to avoid cast. + + * src/printf.c (posixly_correct): Use bool for booleans. + (verify, main): Use EXIT_FAILURE/EXIT_SUCCESS instead of 1/0. + (STRTOX): Rewrite to avoid casts. + (print_esc_char): Arg is char, not int. + * src/readlink.c (canonicalize): Remove. All uses now merely inspect + can_mode. + (no_newline, verbose): Use bool for booleans. + (can_mode): Now of type int; use -1 to denote otherwise-uninitialized. + * src/shred.c (struct Options, main): Use bool for booleans. + (isaac_seed_data, fillpattern, wipefile): Rewrite to avoid casts. + * src/split.c (cwrite, bytes_split, lines_split, line_bytes_split): + Use bool for booleans. + * src/stat.c (G_fail): Remove. + (print_statfs): Print various gotta-be-nonnegative values using + unsigned long int, not long int or int. + (do_statfs, do_stat): Return a boolean success flag. + (do_stat, main): Use bool for booleans. + + * src/pr.c: Add a FIXME mentioning that there are many + unchecked integer overflows in this file. + (TRUE, FALSE): Remove. All uses replaced by true and false. + (struct COLUMN, read_line, print_page, print_stored, open_file, + skip_to_page, init_fps, parallel_files, align_empty_cols, + empty_line, FF_only, explicit_columns, extremities, keep_FF, + print_a_FF, print_a_header, use_form_feed, have_read_stdin, + print_across_flag, storing_columns, balance_columns, + truncate_lines, join_lines, untabify_input, failed_opens, + numbered_lines, skip_count, use_esc_sequence, use_cntrl_prefix, + double_space, ignore_failed_opens, use_col_separator, + pad_vertically, last_line, main, init_parameters, skip_read, + read_line, print_stored): + Use bool for booleans. + (struct COLUMN, char_to_clump, store_char, print_char): + Use char for chars. + (clump_buff, print_clump): Use char[], not int[], for an array whose + elements are always chars. + (first_last_page, main, getoptarg, balance, add_line_number, + char_to_uclump): Remove unnecessary casts. + (init_parameters): Allocate chars, not ints, for clump_buff. + (print_char): Use to_uchar before invoking ISPRINT. + (char_to_clump): Convert to unsigned char before invoking ISPRINT. + + * src/nohup.c (main): Use bool for booleans. + * src/paste.c (paste_parallel, paste_serial, main): Likewise. + * src/pathchk.c (validate-path, main, portable_chars_only): Likewise. + (portable_chars_only): Use to_uchar rather than a cast. + * src/printenv.c (main): Use bool for booleans. + Do not assume that the environ has at most one matching entry + for each option (integer overflow was possible otherwise). + + * src/od.c (FMT_BYTES_ALLOCATED): Now an enum, not a decimal + constant. Do not assume PRIdMAX etc. are strings of length 3 or + less. + (struct tspec): Use it. fmt_string is now an array, not + a pointer, as there's little point to the indirection here. + (struct tspec, flag_dump_strings, + traditional, flag_pseudo_start, limit_bytes_to_format, + abbreviate_duplicate_blocks, have_read_stdin, simple_strtoul, + decode_one_format, open_next_file, check_and_close, + decode_format_string, skip, write_block, read_char, read_block, + parse_old_offset, dump, dump_strings, main): + Use bool for booleans. + (struct tspec): Use void *, not char *, for generic pointers. + (bytes_to_oct_digits, bytes_to_signed_dec_digits, + bytes_to_unsigned_dec_digits, bytes_to_hex_digits): + Use char, not unsigned int, since char suffices. + (print_s_char, print_char, print_s_short, print_short, + print_int, print_long, print_long_long, print_float, + print_double, print_long_double): Rewrite to avoid casts. + These now take void * arguments, instead of char *. + Use the same body for all functions, except for the choice + of type. Assume C89 to simplify handling of signed char. + (dump_hexl_mode_trailer, print_named_ascii, print_ascii): + Rewrite to avoid casts. + (print_named_ascii, print_ascii): Now takes void *, not char *. + (decode_one_format): Use int for printf field widths, not + unsigned int. Pass void * to subsidiary printers, + not char *. Simplify handling of floating-point formats + by factoring out common code dealing with precision and field width. + (decode_format_string): Avoid need for temporary copy of + each decoded struct tspec. + (get_lcm): Remove unnecessary cast. + (main): Fix bug where more than INT_MAX failed decodes were ignored. + +2004-08-02 Paul Eggert <eggert@cs.ucla.edu> + + * src/nl.c (TRUE, FALSE): Remove; all uses changed to true, false. + (enum number_format): Remove. + (FORMAT_RIGHT_NOLZ, FORMAT_RIGHT_LZ, FORMAT_LEFT): Now strings, + not enum values. + (DEFAULT_SECTION_DELIMITERS): Now an array constant, not a macro. + (section_del): Now const. + (print_fmt): Remove. + (starting_line_number, page_incr, blank_join, line_no, + print_lineno, proc_text, main): + Use intmax_t for line numbers. + (reset_numbers, have_read_stdin, build_type_arg, nl_file, main): + Use bool for booleans. + (lineno_format): Now a string, not an enum value. + (build_print_fmt): Remove. All calls removed. This work is + now done within print_lineno. + (build_type_arg): Use size_t for sizes. + (print_lineno): Check for line number overflow. + (proc_text, main): Remove unnecessary cast. + + * src/ln.c (symbolic_link, interactive, remove_existing_files, + verbose, hard_dir_link, dereference_dest_dir_symlinks, + do_link, main): Use bool for booleans. + + * src/ls.c (struct fileinfo, file_interesting, + extract_dirs_from_files, color_symlink_as_referent, + FILE_OR_LINK_MODE, sort_reverse, print_owner, print_group, + numeric_ids, print_block_size, dired, print_with_color, + check_symlink_color, print_inode, recursive, immediate_dirs, + all_files, really_all_files, qmark_funny_chars, + print_dir_name, format_needs_stat, format_needs_type, visit_dir, + main, decode_switches, parse_ls_color, print_dir, file_interesting, + gobble_file, make_link_path, basename_is_dot_or_dotdot, + extract_dirs_from_files, print_long_format): + Use bool for booleans. + (dir_defaulted): Remove; no longer needed. + (main): Use int to count files, since it suffices for argv. + Rewrite to avoid need for dir_defaulted. + (main, print_dir, gobble_file, get_link_name, + xstrcoll): + Set exit status to EXIT_SUCCES/EXIT_FAILURE rather than 0/1. + (decode_switches): Put back check for ws.ws_col <= SIZE_MAX. + Remove unnecessary cast to int. Use int instead of unsigned + int to count from 0 to 1. + (get_funky_string, print_type_indicator): Use char for bytes, not int. + (make_link_path): Use NULL for null pointers. + (quote_name): Use to_uchar instead of cast. + + * src/id.c (use_name, main, print_user, xgetgroups, print_group_list, + print_full_info): Use bool for booleans. + (problems): Remove, replacing with.... + (ok): New var (inverted from old sense). + (print_user, print_group, print_full_info): + Print uids/gids with %lu, not %u. + (xgetgroups): Don't run out of memory if getgroups or getugroups + returns -1. + * src/setuidgid.c (main): Print uids/gids with %lu, not %ld. + + * src/factor.c (wheel_tab): Use unsigned char instead of unsigned + int, since it suffices. + (factor, print_factors): Use size_t for sizes. + (print_factors, do_stdin, main): Use bool for booleans. + * src/fold.c (TAB_WIDTH): New macro; use it instead of "8". + (fold_file, main): Use bool for booleans. + (fold_file, main): Use size_t for sizes. + (main): Allow -w options up to SIZE_MAX - TAB_WIDTH - 1, instead + of prohibiting widths greater than INT_MAX. + * src/head.c (presume_input_pipe, print_headers, have_read_stdin, + write_header, elide_tail_bytes_pipe, elide_tail_bytes_file, + elide_tail_lines_pipe, elide_tail_lines_seekable, + elide_tail_lines_file, head_bytes, head_lines, head, head_file, + string_to_integer, main): + Use bool for booleans. + (main): Rewrite to avoid cast. + + * src/csplit.c (struct line): Use size_t for sizes. + (main): Remove unnecessary cast. + * src/cut.c (cut_fields): Use to_uchar rather than a cast. + * src/cut.c (cut_file, main): Use bool for booleans. + * src/date.c (show_date, rfc_format, batch_convert, main): Likewise. + * src/env.c (main): Likewise. + * src/expr.c (nextarg): Likewise. + * src/env.c (main): Remove unused and nonstandard envp arg. + + * src/fmt.c (COST, MAXWORDS): Add a comment describing some of + fmt's arbitrary limits. + (TRUE, FALSE): Remove; all uses changed to (true, false). + (main): Use bool for booleans. + Limit maximum width to MAXCHARS / 2. Use xstrtoul, not xstrtol, + to parse width. + (copy_rest): Remove unnecessary cast. + (get_prefix): Rewrite to avoid cast. + (check_punctuation): Use char *, not unsigned char *; C89 requires + this. Avoid off-by-one buffer read overrun when line is empty. + (flush_paragraph): Don't assume wptr-parabuf is <= INT_MAX. + Remove unnecessary casts. + * tests/fmt/basic (wide-1, wide-2, bad-suffix): Adjust to above + changes. + + * src/expand.c (convert_entire_line, have_read_stdin, parse_tabstops, + next_file, expand, main): + Use bool for booleans. + (tab_size, tab_list, add_tabstop, parse_tabstops, validate_tabstops, + expand, main): + Use uintmax_t for column counts. + (add_tabstop): Don't reserve -1 (now UINTMAX_MAX) as a special value. + All callers changed. + (parse_tabstops): Don't pass a negative char to isblank. + Avoid memory leak with large tab stops. + (validate_tabstops, expand): Don't assume number of tab stops is + <= INT_MAX. + (next_file, main): Use EXIT_SUCCESS/EXIT_FAILURE rather than 0/1 when + storing values into exit_status. + (expand): Use same pattern as unexpand for reading chars. + Report an error when input line is too long, instead of silently + screwing up. Do not mishandle tab stops when backspacing left + over start of line. + + * src/dircolors.c (have_read_stdin, append_quoted, + dc_parse_stream, dc_parse_file, main): Use bool for booleans. + (dc_parse_stream): Use enum for state, rather than int. + Use ssize_t to store getline result. + + * src/dd.c (translation_needed, parse_integer, scanargs, + apply_translations, char_is_saved, swab_buffer, skip_via_lseek): + Use bool for booleans. + (translate_buffer): Use to_uchar rather than a cast. + (swab_buffer, copy_simple, copy_with_unblock): + Use size_t for sizes. + + * src/seq.c (equal_width, valid_format, main): Use bool for booleans. + * src/sleep.c (apply_suffix): Likewise. + * src/tail.c (struct File_spec, reopen_inaccessible_files, count_lines, + forever, from_start, print_headers, have_read_stdin, valid_file_spec, + write_header, file_lines, pipe_lines, pipe_bytes, recheck, + tail_forever, tail_bytes, tail_lines, tail, tail_file, + parse_obsolescent_option, parse_options, main): Likewise. + * src/sleep.c (apply_suffix): Invert sense of result. + Use int (not unsigned int) for multiplier, as this generates better + code with some compilers. Simplify code a bit. + * src/tail.c (struct File_spec, max_n_unchanged_stats_between_opens, + parse_options): Use uintmax_t, not unsigned int or unsigned long int, + for state counters. + (tail_bytes, tail_lines): Redo test of return value (-1, 0, 1) to + make it a bit clearer. + + * src/hostname.c: Include "xgethostname.h". + (xgethostname): Remove decl; xgethostname.h has it. + (sethostname) [!defined(HAVE_SETHOSTNAME) && defined(HAVE_SYSINFO) + && defined (HAVE_SYS_SYSTEMINFO_H) && defined(HAVE_LIMITS_H)]: Use + prototypes rather than K&R form. Assume any negative value from + sysinfo denotes failure, not just -1. + (main): Simplify use of sethostname. + + * src/pinky.c (include_idle, include_heading, include_fullname, + include_project, include_plan, include_home_and_shell, do_short_format, + include_where, main): Use bool for booleans. + (count_ampersands, create_fullname, scan_entries, short_pinky): + Use size_t for sizes. + (create_fullname): Check for overflow in size calculations. + (idle_string): Don't assume that the number of idle days + is less than 10**8 and/or INT_MAX/(24*60*60). + (main): No need to pass a non-NULL last arg to getopt_long. + * src/uptime.c (print_uptime, uptime): Use size_t for sizes. + (print_uptime): Remove unused local variable. + (main): No need to pass a non-NULL last arg to getopt_long. + * src/users.c (list_entries_users, users): Use size_t for sizes. + (list_entries_users): Use char for bytes. + (main): No need to pass a non-NULL last arg to getopt_long. + * src/who.c (do_lookup, short_list, short_output, include_idle, + include_heading, include_mesg, include_exit, need_boottime, + need_deadprocs, need_login, need_initspawn, need_clockchange, + need_runlevel, need_users, my_line_only, main): Use bool for booleans. + (print_runlevel): Use unsigned char for bytes. + (list_entries_who, scan_entries, who): Use size_t for sizes. + (main): No need to pass a non-NULL last arg to getopt_long. + + * src/install.c (isdir): Remove decl. + (install_file_to_path): Rely on make_path to fail if the destination + is not a directory, by passing preserve_existing==true to it. + Hence we no longer need to call isdir. + Free dest_dir immediately when it's no longer needed, rather than + waiting until the end of the function. + (copy_file): Don't bother calling isdir, as copy will do the + right thing if the destination is a directory. + + * src/du.c (fts_debug, opt_all, apparent_size, opt_count_all, + print_grand_total, opt_separate_dirs, hash_ins, process_file, main): + Use bool for booleans. + (max_depth): Now size_t, not int, to avoid an arbitrary limit + of INT_MAX on depth. + (G_fail): Remove: no longer needed, now that the relevant + functions return bool. + (process_file): Use return value to signal success rather than + setting a global. Remove first_call static var; not needed, since + we can look at n_alloc. Use size_t for depths. Remove FIXME + about size_t casts, as it's now fixed. Use xnrealloc rather + than the obsolescent XREALLOC. Don't bother to check whether + reallocation is needed unless level > prev_level. + (du_files): Invert sense of result, for consistency with + other coreutils code. All callers changed. + (main): Allow --max-depth values up to SIZE_MAX. + + * src/df.c (inode_format, show_all_fs, show_local_fs, + show_listed_fs, posix_format, require_sync, print_type, + selected_fstype, excluded_fstype, show_dev, show_point, main): + Use bool for booleans. + (df_readable, show_dev): Use UINTMAX_MAX instead of -1. + (show_dev, show_point, main): + Use EXIT_SUCCESS/EXIT_FAILURE instead of 0/1. + Don't assume disk name lengths are <= INT_MAX. + Rewrite pct calculation to avoid cast. + (show_point): Don't assume resolved length is <= SSIZE_MAX. + + * src/cut.c (hash_int) [!defined UINTPTR_MAX]: Use size_t + instead of uintptr_t. + * src/shred.c (UINT_MAX_32_BITS): Remove. + (word32): Remove. All uses changed to uint32_t. + (isaac_seed_data): Remove unnecessary cast. + * src/system.h (ptr_align): Use size_t; in practice, this is just as + good as uintptr_t in checking for alignments, and has fewer + configuration hassles. + + * src/Makefile.am (localedir.h): Make it readonly; this + undoes part of the 2004-07-27 patch. + +2004-07-30 Paul Eggert <eggert@cs.ucla.edu> + + * src/sort.c (UCHAR): Remove; all uses changed to to_uchar. + (IS_THOUSANDS_SEP): Use bool when appropriate. + (numcompare, main): Use char, not int, when the value is always a char. + (numcompare): Remove "register"; compilers are smart enough these days. + * src/system.h (errno, CHAR_BIT): Remove decls; + no longer needed now we assume C89 or better. + Include <inttypes.h> before <stdint.h>, as it's the + Autoconf-recommended pattern. + (to_uchar): New inline function, moved here from tr.c. + Use full names for int types, e.g. "long int" rather than "long". + * src/tr.c (to_uchar): Remove; now in system.h. + (is_char_class_member): Use bool when appropriate. + + * src/mkdir.c (create_parents, main): Use bool when appropriate. + (main): Use EXIT_SUCCESS/EXIT_FAILURE instead of 0/1. + +2004-07-29 Paul Eggert <eggert@cs.ucla.edu> + + * src/mkfifo.c (main): Use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1. + + * src/chmod.c (recurse, force_silent, process_file, process_files, + main): Use bool when appropriate. + * src/cksum.c (cksum, main): Likewise. + * src/comm.c (hard_LC_COLLATE, only_file_1, only_file_2, both, + compare_files, main): Likewise. + + * src/copy.h (struct cp_options): Likewise. + * src/copy.c (copy_internal, is_ancestor, copy_dir, copy_reg, + same_file_ok, seen_file, copy_internal, valid_options, copy): Likewise. + * src/cp-hash.h (remember_created): Likewise. + * src/cp-hash.c (remember_created): Likewise. + * src/cp.c (struct dir_attr, flag_path, remove_trailing_slashes, + re_protect, make_path_private, target_directory_operand, do_copy, + cp_option_init, decode_preserve_arg, main): Likewise. + * src/install.c (isdir, change_timestamps, change_attributes, + copy_file, install_file_to_path, install_file_in_dir, + install_file_in_file, strip_files, dir_arg, cp_option_init, main, + change_attributes, change_timestamps): Likewise. + * src/mv.c (remove_trailing_slashes, rm_option_init, + cp_option_init, do_move, movefile, main): Likewise. + * src/remove.c (right_justify), full_filename_, AD_pop_and_chdir, + AD_push, prompt, remove_dir): Likewise. + * src/rm.c (rm_option_init, main): Likewise. + + * src/remove.c (top_dir, pop_dir, full_filename_): + Use size_t for sizes. + * src/cp.c (target_directory_operand): Do not clear *NEW_DST if stat + succeeds. It's not necessary in that case, as *NEW_DST is always + false already. + (do_copy): Rewrite slightly to avoid need for "unreachable" comment. + (main): Use EXIT_SUCCESS, EXIT_FAILURE instead of 0, 1. + * src/rm.c (main): Likewise. + + md5sum, sha1sum integer cleanups. + + * src/checksum.h: Don't include config.h, sys/types.h, stdio.h: + not needed. + (ALG_UNSPECIFIED): Remove. + (ALG_MDT): Don't make it equal to CHAR_MAX + 1; this isn't necessary. + * src/md5.c: Don't include any files other than checksum.h. + * src/sha1sum.c: Likewise. + * src/md5sum.c (OPENOPTS, have_read_stdin, status_only, warn, + bsd_split_3, split_3, hex_digits, digest_file, digest_check, main): + Use bool when appropriate. + (digest_check): Increase limit of number of input lines to + UINTMAX_MAX from INT_MAX. Diagnose any overflows of this counter. + Use ngettext instead of hard-to-i18nize hardcoded stuff for plurals. + +2004-07-28 Paul Eggert <eggert@cs.ucla.edu> + + * src/cat.c (exit_status): Remove. Now done by passing a boolean + 'ok' flag around. + (simple_cat, cat): Return true if successful. All callers changed. + (simple_cat, cat, main): Use bool for booleans. + (simple_cat): Use size_t for sizes. + (cat, main): Use the same names for parameters that we use for + long options, to avoid confusion. This inverts the sense of the + show_tabs (formerly output_tabs) and number_nonblank + (formerly numbers_at_empty_lines) variables. + (main): Don't mess up (due to integer overflow) if we are given + INT_MAX - INT_MIN + 1 options. + [O_BINARY]: Don't invoke isatty unless the other options require it. + (main): When deciding whether to use simple_cat, don't worry + about binary option; it's irrelevant. + + * src/dcgen: Remove comments, trailing white space, and empty + lines from the output strings, to save space. + Use a narrower type like 'unsigned char' for line lengths, if + that will do. + Make the output variables static, not extern. + + * src/chgrp.c (parse_group): Require base 10 when parsing + groups as integers. + (main): int -> bool when appropriate. + * src/chown.c (main): Likewise. + * src/chown-core.c: Include inttostr.h. + (UINT_MAX_DECIMAL_DIGITS, uint_to_string): Remove. + (gid_to_name, uid_to_name): Use imaxtostr/umaxtostr + instead of uint_to_string). + (describe_change): Instead of an int flag, use a char * + auxiliary; this avoids the need for casts. + Assume free (NULL) works. + (change_file_owner): Return true/false, not 0/-1, since + we don't set errno. All callers changed. + Use bool when appropriate. + (chown_files): Likewise. + * src/chown-core.h (chown_files): Likewise. + + * tests/chown/basic: Test for proper handling of uids like + "010", which must be parsed as decimal. + + * tests/misc/pwd: Don't assume that Perl's getpwd agrees with our + pwd when there are multiple names for the working directory + (which can happen with an automounter, sigh). + + * src/Makefile.am ($(SCRIPTS)): Don't depend on Makefile; + this causes Solaris 8 'make' to refuse to build "groups". + (localedir.h): Don't depend on Makefile: this causes Solaris + 8 'make' to build localedir.h unnecessarily. The dependence + on Makefile is ineffective anyway, since $(localedir) might + change even if Makefile hasn't. + + * src/remove.c (remove_dir): If we can't save the state of the + working directory, pretend we started from "/", not ".". + This avoids a bug on hosts like Solaris that don't let you + remove the working directory. + +2004-07-27 Paul Eggert <eggert@cs.ucla.edu> + + * src/printf.c (strtiomax, strtoumax): Declare if not already + declared: this fixes a portability bug with Solaris 8 + GCC. + (STRTOX): Parenthesize use of macro arg as expression. + (vstrtoimax, vstrtoumax, vstrtold): Remove now-unnecessary + parentheses. + * configure.ac: Check for declaration of strtoumax, for + src/printf.c. + + * src/Makefile.am (cp_LDADD, ginstall_LDADD, mv_LDADD, + pathchk_LDADD, rm_LDADD, test_LDADD): New vars, for eaccess. + + * tests/readlink/can-e: Don't assume that we can remove the + working directory: this isn't possible under Solaris 8, say. + * tests/readlink/can-f: Likewise. + * tests/readlink/can-m: Likewise. + + * src/copy.c (copy_internal): find_backup_file_name no longer + returns NULL, so don't bother to check for this. + * src/cp.c (do_copy): Likewise. + * src/ln.c (do_link): Likewise. + +2004-07-25 Paul Eggert <eggert@cs.ucla.edu> + + * src/nice.c (GET_NICE_VALUE): Renamed from GET_PRIORITY. + All uses changed. + (NZERO): New macro, if system doesn't define it already. + (usage): Distinguish priorities from nice values. + Don't assume NZERO is 20. + (main): Use bool instead of int where appropriate. + If user specifies an adjustment out of range, always truncate it + to an inrange value instead of sometimes giving an error message + and sometimes not. + Do not assume that -1 is an error return from "nice" or + "getpriority", as it might be the current nice value minus NZERO. + If nice/setpriority fails with errno == EPERM, go ahead and run + the command anyway; POSIX requires this. + + * src/pathchk.c: Include euidaccess.h. + (dir_ok): Use euidaccess, not access. + * src/test.c (R_OK, W_OK, X_OK, FOK): Remove; system.h defines them. + (eaccess): Remove. All users changed to use euidaccess instead. + +2004-07-24 Paul Eggert <eggert@cs.ucla.edu> + + * src/uptime.c (print_uptime) [defined BOOT_MSG]: + Don't assume ut_line is null-terminated. + * src/who.c (print_line): New arguments USERLEN and LINELEN, + since USER and LINE might not be null terminated. All callers + changed. + +2004-07-23 Paul Eggert <eggert@cs.ucla.edu> + + Fix bug with "tail -f" reported by Rob Holland in + <http://lists.gnu.org/archive/html/bug-coreutils/2004-07/msg00054.html>. + Also, remove the undocumented and unsupported-since-2000 + --max-consecutive-size-changes options. Fix another related bug: + "tail" got confused if stdin, stdout, or stderr were closed. + Also, use output buffering even with "tail -f". + + * NEWS: Document this, plus yesterday's patch. + * doc/coreutils.texi (tail invocation): "size has remained the same" + -> "file has not changed", which is more accurate for fifos. + * src/tail.c: Include fcntl-safer.h. + (COPY_TO_EOF): Set to UINTMAX_MAX, not OFF_T_MAX (which was wrong). + (COPY_A_BUFFER): New macro. + (struct File_spec): New members mtime, mode, blocking. + Remove member n_consecutive_size_changes. + (DEFAULT_MAX_N_CONSECUTIVE_SIZE_CHANGES, + max_n_consecutive_size_changes_between_opens, + MAX_CONSECUTIVE_SIZE_CHANGES_OPTION): Remove. + (long_options, tail_forever, parse_options): + Remove (non-)support for --max-consecutive-size-changes. + (record_open_fd): New function. + (recheck, tail_file): Use it. Don't assume that stdin is open. + (dump_remainder): Add support for new COPY_A_BUFFER special value. + Treat errno==EAGAIN like EOF, since it might be a nonblocking read. + (recheck): New arg BLOCKING, specifying whether to use blocking reads. + All uses changed. + (n_live_files): Remove, replacing with... + (any_live_files): New function. All uses changed. + (tail_forever): Use nonblocking I/O unless we know that blocking I/O + is safe; this avoids some hangs when reading from a fifo. + Avoid invoking fstat or sleep when using blocking I/O. + Do not check for changes to size if the file is not a regular file, + as the size is undefined in that case. + Check for changes to mtime or mode, too; this works for non-regular + files. + (tail_forever, main): Redo fflush strategy to work even when input + is nonblocking. Don't use unbuffered output; just flush when needed. + +2004-07-22 Paul Eggert <eggert@cs.ucla.edu> + + * src/tail.c (main): Ignore -f if no file operand is specified + and standard input is a pipe. + * doc/coreutils.texi (tail invocation): Do not ignore -f for + all pipes, just for when standard input is a pipe and no + file operand is specified. + * tests/tail/Test.pm: Reinstate f-1 test, since we now pass. + Add a new commented-out f-2 test, which we still fail. + (test_vector): All f-* tests are special cases, not just f-1. + +2004-07-12 Paul Eggert <eggert@cs.ucla.edu> + + * src/uptime.c: Include c-strtod.h. + (print_uptime): Use c_strtod instead of setlocale and sscanf. + Use long int rather than int to count days (for 64-bit hosts), + and check for arithmetic overflow when converting double to time_t. + +2004-07-11 Paul Eggert <eggert@cs.ucla.edu> + + * src/printf.c (vstrtold): Renamed from vstrtod. + Now returns long double. All uses changed. + (print_direc): Use "L" length modifier when printing floating point + numbers, since we're now printing long double. + +2004-07-06 Paul Eggert <eggert@cs.ucla.edu> + + * Version 5.3.0. + + printf cleanup, to avoid undefined behavior, to add support for + formats that Bash supports, and to support wide integers like + Bash does. + + * NEWS: Document this. + * src/printf.c (UNSPECIFIED): Remove. All uses now replaced by + booleans, so that we don't reserve any values for precision or + width (like Bash). + (STRTOX): Use prototype, not K&R-style definition. + (vstrtoimax): Renamed from xstrtol (to avoid confusion with xstrtol + in ../lib), with type change to intmax_t. + All uses changed. + (vstrtoumax): Renamed from xstrtoul, with type change to uintmax_t. + All uses changed. + (vstrtod): Renamed from xstrtod. All uses changed. + (print_direc): Use boolean arg instead of special value to indicate + a missing precision or width. LENGTH no longer includes + length modifiers or conversion character. New arg CONVERSION + now specifies conversion character. + Use intmax_t-width formatting for integers (like Bash). + Add support for C99 %a, %A, %F (like Bash). + Add support for field width with %c (POSIX requires this). + Add a FIXME for lack of support for field width and precision + for %b. + Add support for '\'', '0' flags. + Check for invalid combinations of flags, field width, precision, + and conversion, to prevent use of undefined behavior. + Allow multiple length modifiers, for formats like "%lld" (like Bash). + Add support for C99 'j', 't', 'z' length modifiers (like Bash). + In error message, output entire invalid conversion specification, + instead of merely outputting % followed by the conversion char. + * tests/misc/printf: Add tests for the above. + +2004-04-03 Dmitry V. Levin <ldv@altlinux.org> + + Change "readlink -f" to be more compatible with prior implementations. + Add more canonicalize options, -e and -m. + Add comprehensive tests for all readlink modes. + + * m4/canonicalize.m4 (AC_FUNC_CANONICALIZE_FILE_NAME): + Do not add canonicalize.c here. + + * src/readlink.c (longopts): Add new options. + (usage): Document them. + (canonicalize_fname): New proxy function. + (main): Handle new options. + * doc/coreutils.texi (readlink invocation): Document new + "readlink -f" behaviour and new canonicalize options, -e and -m. + + * configure.ac (AC_CONFIG_FILES): Add tests/readlink/Makefile. + * tests/Makefile.am (SUBDIRS): Add readlink. + * tests/readlink/Makefile.am: New file. + * tests/readlink/{rl-1,can-e,can-f,can-m}: New readlink tests. + * tests/misc/Makefile.am (TESTS): Remove basic readlink test. + * tests/misc/readlink: Remove file. + +2004-07-04 Jim Meyering <jim@meyering.net> + + * src/copy.c (copy_internal): Add a FIXME comment. + +2004-07-02 Paul Eggert <eggert@cs.ucla.edu> + + * src/copy.c (copy_dir): Assume path_concat returns non-NULL. + * src/cp.c (do_copy): Likewise. + * src/mv.c (movefile): Likewise. + + * src/cp.c (make_path_private): 2nd arg is now size_t, not int, + to avoid problem when path_concat dir name is longer than 2 GiB (!). + + * src/nohup.c (main): Don't pass NULL first argument to path_concat. + This cleans up the semantics a bit, as we no longer try to open the + same file twice. + +2004-07-01 Paul Eggert <eggert@cs.ucla.edu> + + * NEWS: Add short names -t and -T for --target-directory + and --no-target-directory options, respectively. + + * src/cp.c (NO_TARGET_DIRECTORY_OPTION, TARGET_DIRECTORY_OPTION): + Remove. All uses changed to 'T' and 't', respectively. + * src/install.c, src/ln.c, src/mv.c: Likewise. + + * src/cp.c (long_opts, usage, do_copy, main): Add -t and -T as + aliases for --target-directory and --no-target-directory, + respectively. + * src/install.c (long_options, main, usage): Likewise. + * src/ln.c, src/mv.c: Likewise. + +2004-07-01 Jim Meyering <jim@meyering.net> + + * Makefile.maint (sc_file_system): New target. + (syntax-check-rules): Add it. + .x-sc_file_system: New file. + * Makefile.am (EXTRA_DIST): Add it. + + * man/sync.x: Use "file system" rather than "filesystem". + * man/stat.x, man/df.x: Likewise. + +2004-06-30 Paul Eggert <eggert@cs.ucla.edu> + + * src/df.c (usage, main): Output "file system" rather than + "filesystem". + * src/du.c (usage): Likewise. + * src/shred.c (usage): Likewise. + * src/stat.c (usage): Likewise. + * src/stat.c (long_options, usage): Rename "--filesystem" to + "--file-system". But keep the old name around, for compatibility + reasons. + +2004-06-29 Paul Eggert <eggert@cs.ucla.edu> + + Add support for --no-target-directory option. + + * NEWS: Document it. + * doc/coreutils.texi (Common options, Target directory, cp + invocation, install invocation, mv invocation, ln invocation): + Likewise. + (link invocation): Explain how to rewrite link using ln now + that we have --no-target-directory. + (ln invocation): Explain that --no-target-directory subsumes + --no-dereference. + (unlink invocation): Modify wording to match new wording in + link invocation. + + * src/cp.c (NO_TARGET_DIRECTORY_OPTION): New constant. + (long_opts, usage, do_copy, main): Add support for + --no-target-directory, + * src/install.c (NO_TARGET_DIRECTORY_OPTION, long_options, main, + usage): Likewise. + * src/ln.c (NO_TARGET_DIRECTORY_OPTION, long_options, usage, + main): Likewise. + * src/mv.c (NO_TARGET_DIRECTORY_OPTION, long_options, usage, + main): Likewise. + * src/mv.c (enum): Sort values. + +2004-06-29 Jim Meyering <jim@meyering.net> + + Don't let verbose-mode output from a subshell obscure actual differences. + * tests/rm/inaccessible: Turn off command-echoing just before + invoking subshell, then turn it back on if VERBOSE=yes afterward. + +2004-06-25 Paul Eggert <eggert@cs.ucla.edu> + + Add support for 'install --target-directory', an option + that has been documented for years but not implemented (!). + * doc/coreutils.texi (install invocation): Document + --target-directory in synopsis, too. + * src/install.c (TARGET_DIRECTORY_OPTION): New var. + (long_options, main, usage): Add --target-directory. + (target_directory_operand): New function, stolen from mv.c. + (main): Use it. Check for -d and --target-directory. + Alter wording of diagnostics to match other programs. + +2004-06-28 Jim Meyering <jim@meyering.net> + + * src/cp.c (usage): Fix copy+paste error in description of + --target-directory: s/move/copy/. From Paul Jarc. + +2004-06-27 Paul Eggert <eggert@cs.ucla.edu> + + Use more-consistent rules among cp, ln, and mv when dealing with + last operands that are (or look like) directories. + + * src/cp.c (target_directory_operand): New, nearly-common function, + It reports an error if the destination appears to be a directory + (e.g., because it has a trailing slash) but is not. + * src/ln.c, src/mv.c: Likewise. + * src/cp.c (do_copy): Use it. + * src/ln.c (main): Likewise. + * src/mv.c (main): Likewise. + + * src/cp.c (do_copy): Don't assume argc is positive. + Don't bother to lstat dest, since copy() will do that for us. + Use "const" to avoid the need for cast. + + * src/cp.c (do_copy): Don't output a usage message because of file + problems (e.g., an operand is not a directory). Use it only for + syntax. Standardize on "target %s is not a directory" for the + diagnostic. + * src/ln.c (main): Likewise. + * src/mv.c (main): Likewise. + + * src/cp.c (do_copy): Remove test for trailing slash, since + target_directory_operand now does this. + * src/ln.c (main): Likewise. + * src/mv.c (movefile): Likewise. + + * src/cp.c (main): Reject multiple target directories. + Check whether a specified target is a directory when parsing the + options, using stat. This gives more-accurate diagnostics. + * src/ln.c (main): Likewise. + + * src/ln.c (isdir): Remove decl; no longer needed. + * src/mv.c (isdir, lstat): Likewise. + + * src/ln.c (do_link): New arg dest_is_dir. All uses changed. + Don't check the destination ourself; rely on dest_is_dir. + This way we can avoid lstatting the destination in the + usual case, and in the worst case we lstat 1, not 3 times. + Don't bother to unlink unless link failed; this saves a syscall. + Remove unnecessary backup_succeeded flag; + it was identical to "dest_backup != NULL". + + * src/ln.c (main): Use int to count to argc, not unsigned int. + This handles negative operand counts. + * src/mv.c (main): Likewise. + + * src/mv.c (do_move): Don't call hash_init; expect the caller to + do it, for consistency with cp.c and ln.c. All callers changed. + (movefile): dest_is_dir parameter is now bool, not int. + (main): Standardize on "missing destination file operand after %s" + for the diagnostic, for consistency with cp.c. + + * tests/mv/diag: Don't assume "mv --target=nonexistentdir" + will complain about the arg count. + Adjust to new (briefer) diagnostics. + * tests/cp/fail-perm: Add a test to verify that we get the new + diagnostic when failing to copy through a symlink-to-inaccessible-dir. + +2004-06-27 Paul Eggert <eggert@cs.ucla.edu> + + Fix a bug: formerly, if d/x was a directory and x a file, "ln x + d/" incorrectly created a link d/x/x. It also saves some system + calls. + + * NEWS: Document the fix. + + * src/ln.c (main): Don't append basename to dest if this + results in an existing directory name. + * tests/ln/misc: See whether a trailing slash is followed too far. + +2004-06-26 Jim Meyering <jim@meyering.net> + + * src/printf.c (main): When given no arguments, print the standard + "missing operand\nTry printf --help..." message -- to be consistent. + +2004-06-26 Jim Meyering <jim@meyering.net> + + * src/mknod.c (main): Add \n at the end of message output via fprintf. + +2004-06-25 Jim Meyering <jim@meyering.net> + + * tests/ln/misc: Add test for ln subscript error. + +2004-06-23 Paul Eggert <eggert@cs.ucla.edu> + + * src/ln.c (do_link): Remove unnecessary call to lstat. + (main): Avoid subscript error when the destination is "". + +2004-06-23 Jim Meyering <jim@meyering.net> + + * tests/*: Replace all occurrences of `(exit N); exit' with + `(exit N); exit N'. Otherwise, those many tests could exit with + improper exit status when exiting via e.g., a trapped interrupt. + Thanks to a report from Bob Proulx. + +2004-06-22 Paul Eggert <eggert@cs.ucla.edu> + + * src/who.c (idle_string, print_user): New arg boottime, + specifying the most recent boot time. All uses changed. + (idle_string) Consider a line to be "old" if it hasn't been used + since the last boot time. Watch out for overflow when computing + times, and for times in the future. + (idle_string): Record latest boot time. + +2004-06-22 Jim Meyering <jim@meyering.net> + + * src/test.c (usage): Correct description of `-t FD'. The file + descriptor, FD, is no longer optional. Reported by Ton Nijkes. + +2004-06-21 Paul Eggert <eggert@cs.ucla.edu> + + The 2004-06-19 fix for who and pinky was incomplete, as ctime + has undefined behavior if the year precedes -999 or follows 9999. + Since we have to stop using ctime anyway, we might as well use + strftime and fix the FIXME, and support internationalized dates. + + * NEWS: Document the new behavior. + * src/who.c: Include "hard-locale.h". + (time_format, time_format_width): New vars. + (time_string, print_line): Use them. + (main): Set them. + (time_string): Use localtime + strftime instead of + ctime, to avoid problems with years before -999 or after 9999. + * src/pinky.c: Likewise. + +2004-06-21 Paul Eggert <eggert@cs.ucla.edu> + + Fix bug: GNU 'ls' didn't count columns correctly if user or group + names contained multibyte characters where the column count + differed from the byte count. This patch also corrects + some comments. + + * src/ls.c (format_user_or_group): New function, which counts + columns correctly. + (format_user, format_group): Use it. + (format_user_or_group_width): New function, which counts columns + correctly. + (format_user_width, format_group_width): Use it. + +2004-06-21 Jim Meyering <jim@meyering.net> + + * tests/priv-check: Quote "$PATH" in PATH=$PATH. + Suggestion from Andreas Schwab. + + * tests/priv-check: When running as root, be sure to propagate + PATH through to the process we exec as non-root. + Reported by michael@aplatform.com. + + * src/mknod.c (main): Don't segfault when calculating the + expected number of operands for `mknod NAME'. + +2004-06-20 Jim Meyering <jim@meyering.net> + + * src/dd.c (input_seek_errno): Declare file-scoped variable as static. + +2004-06-20 Paul Eggert <eggert@cs.ucla.edu> + + * src/basename.c (main): + Standardize on the diagnostics given when someone gives + too few operands ("missing operand after `xxx'") or + too many operands ("extra operand `xxx'"). + Include "quote.h" and/or "error.h" if it wasn't already being included. + * src/chgrp.c (main): Likewise. + * src/chmod.c (main): Likewise. + * src/chown.c (main): Likewise. + * src/chroot.c (main): Likewise. + * src/comm.c (main): Likewise. + * src/cp.c (do_copy): Likewise. + * src/csplit.c (main): Likewise. + * src/date.c (main): Likewise. + * src/dircolors.c (main): Likewise. + * src/dirname.c (main): Likewise. + * src/du.c (main): Likewise. + * src/expr.c (main): Likewise. + * src/hostid.c (main): Likewise. + * src/hostname.c (main): Likewise. + * src/id.c (main): Likewise. + * src/install.c (main): Likewise. + * src/join.c (add_file_name, main): Likewise. + * src/link.c (main): Likewise. + * src/ln.c (main): Likewise. + * src/logname.c (main): Likewise. + * src/md5sum.c (main): Likewise. + * src/mkdir.c (main): Likewise. + * src/mkfifo.c (main): Likewise. + * src/mknod.c (main): Likewise. + * src/mv.c (main): Likewise. + * src/nohup.c (main): Likewise. + * src/od.c (main): Likewise. + * src/pathchk.c (main): Likewise. + * src/ptx.c (main): Likewise. + * src/readlink.c (main): Likewise. + * src/rm.c (main): Likewise. + * src/rmdir.c (main): Likewise. + * src/seq.c (main): Likewise. + * src/setuidgid.c (main): Likewise. + * src/shred.c (main): Likewise. + * src/sleep.c (main): Likewise. + * src/sort.c (main): Likewise. + * src/split.c (main): Likewise. + * src/stat.c (main): Likewise. + * src/test.c (beyond, main): Likewise. + * src/touch.c (main): Likewise. + * src/tr.c (main): Likewise. + * src/tsort.c (main): Likewise. + * src/tty.c (main): Likewise. + * src/uname.c (main): Likewise. + * src/uniq.c (main): Likewise. + * src/unlink.c (main): Likewise. + * src/uptime.c (main): Likewise. + * src/users.c (main): Likewise. + * src/who.c (main): Likewise. + * src/whoami.c (main): Likewise. + + * tests/basename/basic: Adjust to new diagnostics. + * tests/du/files0-from: Likewise. + * tests/expr/basic: Likewise. + * tests/mv/diag: Likewise. + * tests/tsort/basic-1: Likewise. + +2004-06-20 Jim Meyering <jim@meyering.net> + + * src/ln.c: Remove declaration of yesno. + Instead, include yesno.h. + * src/copy.c: Likewise. + + * src/remove.c: Remove declaration of yesno. + Instead, include yesno.h. + (top_dir): Remove now-unnecessary cast of obstack_base. + (pop_dir): Likewise. + (full_filename_): Likewise. + +2004-06-19 Paul Eggert <eggert@cs.ucla.edu> + + Don't dump core if ctime returns NULL; this is possible on + hosts with 64-bit time_t and 32-bit int. + * src/who.c: Include "inttostr.h". + (time_string): If ctime fails, print the raw time as an integer + instead of dumping core. + * src/pinky.c: Likewise, as follows: + Include "inttostr.h". + (time_string): New function, copied from who.c. + (print_entry): Use it. + +2004-06-19 Paul Eggert <eggert@cs.ucla.edu> + + * src/who.c (print_line): Don't truncate user names at 8 bytes. + Problem reported by Guido Leenders in: + http://lists.gnu.org/archive/html/bug-coreutils/2004-06/msg00056.html + * NEWS: document this. + +2004-06-19 Jim Meyering <jim@meyering.net> + + * src/system.h (case_GETOPT_VERSION_CHAR): Switch back to + using GNU_PACKAGE (from PACKAGE) once again. This restores + `GNU' to the parenthesized package name in --version output. + Before, the first argument from AC_INIT, `GNU coreutils', would + be propagated to the PACKAGE variable. Now, `GNU ' is trimmed. + Reported by Richard Stallman. + +2004-06-17 Jim Meyering <jim@meyering.net> + + * src/tr.c (to_uchar): Rename function from `uchar'. The latter + would clash with a typedef in Tru64's <sys/types.h>. From Albert Chin. + +2004-06-15 Paul Eggert <eggert@cs.ucla.edu> + + * NEWS: Remove more special cases for POSIXLY_CORRECT when POSIX + allows the GNU behavior. "--" is now supported by chroot, hostid, + hosname, pwd, sync, yes. + * doc/coreutils.texi (yes invocation, false invocation, + true invocation): Document this. + * src/chroot.c (main): Handle "--". + * src/hostid.c (main): Likewise. + * src/hostname.c (main): Likewise. + * src/pwd.c (main): Likewise. + * src/sync.c (main): Likewise. + * src/yes.c (main): Likewise. + * src/true.c (main): Recognize --help and --version even if + POSIXLY_CORRECT is set. + * src/yes.c (main): Likewise. + +2004-06-09 Paul Eggert <eggert@cs.ucla.edu> + + * NEWS: Remove special cases for POSIXLY_CORRECT when POSIX allows + the GNU behavior. + * doc/coreutils.texi (pr invocation, unlink invocation): Document this. + * src/ls.c (decode_switches): Pay attention to TABSIZE even if + POSIXLY_CORRECT is set. POSIX reserves upper-case environment + variables to the implementation, so it's OK for ls to depend on + TABSIZE. + * src/pr.c: Include "hard-locale.h". + (main): When in a non-POSIX locale, ignore POSIXLY_CORRECT, since + POSIX specifies the behavior only in the POSIX locale. + * src/printf.c (print_esc): Support \x, \u, \U even if POSIXLY_CORRECT, + since POSIX says the behavior is unspecified here. + * src/tail.c (parse_obsolescent_option): Support multiple file operands + even if POSIXLY_CORRECT, since POSIX does not require a diagnostic. + * src/printf.c (main): Recognize --help, --version even if + POSIXLY_CORRECT. POSIX does not specify any options, but it + does not prohibit options either, so "printf" is like "expr" here. + * src/unlink.c (main): Likewise. + * tests/misc/printf: Adjust to the new semantics for \x if + POSIXLY_CORRECT. + +2004-06-14 Jim Meyering <jim@meyering.net> + + * tests/misc/pwd: New test, for fix of 2004-04-19. + * tests/misc/Makefile.am (TESTS): Add pwd. + (BUILD_SRC_DIR): Define BUILD_SRC_DIR. + + * src/copy.c: Remove declaration of euidaccess. + Instead, include "euidaccess.h". + +2004-06-13 Paul Eggert <eggert@cs.ucla.edu> + + * src/who.c (PIDSTR_DECL_AND_INIT): Don't assume pid_t fits in int. + (UT_ID) [!HAVE_STRUCT_XTMP_UT_ID]: Remove bogus comment, + as (sizeof "??") reliably returns 3. + (print_line): Guard against idle and pid being too long + (which is possible when printing headers). + (print_user): Allocate enough bytes for idlestr. Use IDLESTR_LEN. + Avoid unnecessary cast of sizeof to int. + (make_id_equals_comment): Do not assume that UT_ID returns + a string; it might return a non-null-terminated array. + Use strncat instead. It's not very often where strncat is + exactly what you want, but this is one of those rare cases. + +2004-06-11 Paul Eggert <eggert@cs.ucla.edu> + + * src/who.c (list_entries_who): Don't output a trailing space. + +2004-06-09 Jim Meyering <jim@meyering.net> + + * src/touch.c (usage): Improve wording in description of the + --time=WORD option. Reported by Dan Jacobson. + + * src/chown-core.c (change_file_owner): Change names of parameters + old_uid and old_gid to required_uid and required_gid respectively. + + * src/chmod.c (mode_changed): Return false, not 0, now that the + function returns `bool'. + +2004-06-08 Paul Eggert <eggert@cs.ucla.edu> + + Adjust chmod and chown to be similar if -c or -v are given. In + particular, a no-op chown is no longer reported as a change; this + reverts to previous behavior. Also, fix both commands so that -v + report failures even if the failure is not due to the chmod or + chown syscalls. + + * src/chmod.c (CH_NOT_APPLIED): New constant. + (describe_change): Handle it. + (process_file): Use it, if a symlink wasn't changed. + (mode_changed): Return bool, not int. Accept new argument + NEW_MODE; all callers changed. This lets us avoid statting the + file unless the new mode has unusual bits. + (process_file): Return -1 on error. With -v, report all errors + verbosely, not just some. + + * src/chown-core.c (change_file_owner): Return -1 on error, not + 1 sometimes and -1 on others. Our caller ORs together our results, + and (-1 | 1) == 0 on ones-complement hosts. + With -v report all errors verbosely, not just some. + Fix bug when chopt->root_dev_ino && !chopt->affect_symlink_referent: + file_stats wasn't set properly in that case. + + * tests/chgrp/basic: Adjust to above changes. + +2004-05-20 Paul Eggert <eggert@cs.ucla.edu> + + * tests/chgrp/basic: Test that chgrp -h does not fail on + symlinks, even on hosts where that's not supported. + Test that if -R is specified without -H or L, -h is assumed. + Test that chown() is not optimized away. + +2004-05-18 Paul Eggert <eggert@cs.ucla.edu> + + Several fixes to chgrp and chown for compatibility with POSIX and BSD: + + Check for incompatible options. When -R and --dereference are + both used, then either -H or -L must also be used. When -R and -h + are both used, then -P must be in effect. + + -H, -L, and -P have no effect unless -R is also specified. + If -P and -R are both specified, -h is assumed. + + Do not optimize away the chown() system call when the file's owner + and group already have the desired value. This optimization was + incorrect, as it failed to updated the last-changed time and reset + special permission bits, as POSIX requires. + + Do not report an error if the owner or group of a + recursively-encountered symbolic link cannot be updated because + the file system does not support it. + + * NEWS: Document the above. + + * src/chgrp.c (main): Check for incompatible options. -R --dereference + requires either -H or -L, and -R -h requires -P. If -H, specify + FTS_PHYSICAL as well as FTS_COMFOLLOW; this is faster. Make this + file as much like chown.c as possible. + * src/chown.c (main): Likewise. + + * src/chown-core.c (change_file_owner): Use ent->fts_statp only if + needed. Chown a directory only after chowning its children; this + avoids problems if the new directory ownership doesn't permit + access to the children. Dereference symlinks before doing + ROOT_DEV_INO_CHECK, not after, so that we catch symlinks to /. + Do not optimize away the chown() system call when the file's owner + and group already have the desired value. POSIX does not permit + this optimization. Rely on chown and lchown to do the right + thing with symlinks and/or -1 arguments, now that we have wrappers + to do this. Use ENOTSUPP not ENOSYS, and ignore all ENOTSUPP + errors, not just command-line errors. + (chown_files): Pass FTS_NOSTAT to xfts_open if we don't need file status. + + * src/system.h (ENOTSUP): Remove. + + * tests/chgrp/basic: Use chown --from to discover whether the + group changed, since chgrp now changes unconditionally. This + complicates the sed script a bit. Do not specify --dereference, + since it's the default (and we want to test this). Adjust output + to match the fact that chgrp no longer optimizes the case of + changing a file's group to the same value as before. + * tests/chgrp/posix-H: Do not attempt to combine -h and -H; these + options are incompatible, and their behavior is undefined with POSIX. + (changed, not_changed): Adjust to match the fact that -h is no longer + specified. Sort names. + * tests/chown/deref: Adjust error-diagnostic spelling to match new + behavior. + +2004-06-07 Paul Eggert <eggert@cs.ucla.edu> + + * src/uname.c (main): Fix typo introduced on 2003-05-10 that + prevented a diagnostic of any operands. + +2004-06-08 Jim Meyering <jim@meyering.net> + + * src/shred.c (direct_mode): Turn it on/off with directio, too. + +2004-06-07 Jim Meyering <jim@meyering.net> + + Enable direct-mode I/O (bypassing the buffer cache), if possible. + Prompted by a suggestion from Kalle Olavi Niemitalo + in http://bugs.debian.org/207035. + * src/shred.c (direct_mode): New function. + (do_wipefd): Turn on direct-mode I/O. + (dopass): If a file's first write fails with EINVAL, + turn off direct-mode I/O and retry the write. + +2004-06-05 Paul Eggert <eggert@cs.ucla.edu> + + * src/tr.c (main): "tr -d a b" is now a fatal error even if + POSIXLY_CORRECT is set. The POSIX SYNOPSIS does not allow this + option combination. + +2004-06-04 Paul Eggert <eggert@cs.ucla.edu> + + * src/shred.c (dopass): Don't subtract 1 from the offset after + a write error. Problem reported by Jon Peatfield in: + http://lists.gnu.org/archive/html/bug-coreutils/2004-06/msg00020.html + +2004-06-02 Paul Eggert <eggert@cs.ucla.edu> + + Fix bug reported by Buciuman Adrian in + <http://mail.gnu.org/archive/html/bug-coreutils/2003-08/msg00105.html> + where 'dd' created a file that was too large. The bug was that dd + assumed that the input file offset does not advance after a failed + read; but POSIX says that the input file offset is undefined after + a failed read. + + * src/dd.c (MAX_BLOCKSIZE): New macro. + (input_seekable, input_seek_errno, input_offset, + input_offset_overflow): New vars. + (scanargs): Reject block sizes greater than MAX_BLOCKSIZE. + (advance_input_offset): New function. + (skip_via_lseek): Set errno to zero when reporting our failure, + so that we don't report based on garbage errno. + (skip): If fdesc is standard input, advance the input offset. + Do not quit if reading, and if noerror was specified; + POSIX seems to require this. + If read fails on output file, report the earlier lseek failure + instead; this fixes a FIXME in dd_copy. + (advance_input_after_read_error): New function. + (dd_copy): Use it, instead of assuming that failed reads + do not advance the file pointer. Advance input offset + after nonfailed reads. Advance only a partial block if + the previous read (before the failed read) succeeded, and + do not generate an output block of zeros in this case. + (main): Determine initial input offset, seekability of input, + and error if it wasn't seekable. + +2004-06-02 Jim Meyering <jim@meyering.net> + + rm (without -f) could hang unnecessarily when attempting to + remove a symlink to a file on an off-line NFS-mounted partition. + Reported by David Howells in https://bugzilla.redhat.com/124699. + * src/remove.c (write_protected_non_symlink): New function. + Don't invoke euidaccess on symlinks. + (prompt): Use write_protected_non_symlink rather than using + euidaccess directly, being careful not to call lstat twice for a file. + + Fix a bug in how the --output-delimiter=D option works with + abutting byte or character ranges. Reported by David Krider in + http://lists.gnu.org/archive/html/bug-coreutils/2004-05/msg00132.html + * src/cut.c (print_kth): Remove special case for open-ended range. + (set_fields): Record the range start index for an interval even + when it abuts another interval on its low side. + Also record the range start index of the longest right-open-interval. + * tests/cut/Test.pm: Add tests of --output-delimiter=S with + abutting and overlapping byte ranges. + +2004-06-01 Paul Eggert <eggert@cs.ucla.edu> + + Some POSIX-conformance cleanups for tr. + + * src/tr.c (posix_pedantic): Remove; no longer needed since + we need to test this in just one place now. + (usage): Mention -C. + (unquote): Note that \055, \n, etc are escaped. + Do not worry about POSIXLY_CORRECT when warning about ambiguous + escape sequences. + \ at end of string stands for itself. + Do not diagnose invalid backslash escapes: POSIX says the behavior + is unspecified in this case, so we don't need to diagnose it. + (main): Add support for -C (currently an alias for -c). + Do not diagnose 'tr [:upper:] [:upper:], as POSIX does not require + a diagnostic here. + * tests/tr/Test.pm: New tests bs-055, bs-at-end, repeat-Compl. + Fix comment for range-a-a. + +2004-05-25 Paul Eggert <eggert@cs.ucla.edu> + + Improve the efficiency (and in one case, correctness) of code + that reads symlinks. + + * src/copy.c (copy_internal): Don't use alloca, as it can mess up + royally if the link length is long (e.g., GNU/Hurd). Use + xreadlink instead, it's safer. Don't bother to read the link if + it's the wrong size. Add a FIXME because this area is a bit murky + and undocumented. + * src/ls.c (get_link_name): Update use of xreadlink. + * src/readlink.c (main): Likewise. + * src/stat.c (print_stat): Likewise. + +2004-06-01 Jim Meyering <jim@meyering.net> + + * src/env.c (main): Prefer the notation `STREQ (a, b)' + over `!strcmp (a, b)'. + * src/sort.c (main, sort_buffer_size): Prefer the notation + `STREQ (a, b)' over `strcmp (a, b) == 0'. + * src/date.c (batch_convert): Likewise. + * src/expr.c (nextarg): Likewise. + * src/su.c (correct_password, restricted_shell, main): Likewise. + * src/ptx.c (swallow_file_in_memory, main): Likewise. + * src/test.c (binary_operator, and, or, main): Likewise. + +2004-05-13 Paul Eggert <eggert@cs.ucla.edu> + + * NEWS: echo compatibility cleanup. + * doc/coreutils.texi (echo invocation): Document the changes. + * src/echo.c (V9_ECHO): Remove; always enabled. + (DEFAULT_ECHO_TO_XPG): Renamed from V9_DEFAULT, so that + we use the same naming convention as bash. Now an enum, + not a macro. + (usage): Reword to mention -e/-E more accurately. + Mention \0NNN (the POSIX syntax) rather than \NNN (nonstandard). + (hextobin): New function. + (main): Use bool rather than int for local vars when appropriate. + Do not allow options if POSIXLY_CORRECT, unless we are using + BSD semantics and the first argument is "-n". + Don't pass unnecessary extra arg to parse_long_options. + do_v9 now defaults to DEFAULT_ECHO_TO_XPG, not to allow_options. + Do not look for options if !allow_options. + Use size_t rather than int when appropriate. + Open-code option test rather than using strrchr. + Use faster test for "-". + Avoid redundant argc test. + Add support for \x, for Bash compatibility. + Use e.g. '\a' rather than '\007', for portability to EBCDIC hosts. + When '\c' is encountered, stop printing immediately, as POSIX + requires. + Add support for \xhh syntax. + Add support for \0ooo syntax; POSIX requires this. + +2004-06-01 Jim Meyering <jim@meyering.net> + + * Use automake-1.8b. Regenerate dependent files. + +2004-05-31 Jim Meyering <jim@meyering.net> + + * tests/Makefile.am.in (TESTS_ENVIRONMENT): Define PATH to include + the build src/ directory -- at the front. + ($(srcdir)/$x-tests): Depend on Makefile.am. + Use $x as the program name, except when it would be `test' (test is + the sole program tested via mk-script that is also a shell built-in). + In that case, use the old ../../src/$x. + +2004-05-30 Jim Meyering <jim@meyering.net> + + Work around HPUX /bin/cc compiler bug that is exposed, now that + sets are arrays of type `bool'. More details here: + http://lists.gnu.org/archive/html/bug-gnulib/2004-05/msg00094.html + FIXME: verify that the above URL points to the right message + + * src/tr.c (card_of_complement): Use cleaner `sizeof in_set' + rather than `N_CHARS * sizeof(in_set[0])'. Using HPUX's /bin/cc + (aC++/ANSI C B3910B A.05.55 [Dec 04 2003]) on an ia64-hp-hpux11.22 + system, those two expressions are not the same (256 vs. 1024). + The effect of this problem was that `tr -c x y' would fail: + tr: when not truncating set1, string2 must be non-empty + (set_initialize): Remove unnecessary initialization of the `in_set' + buffer; that initialization triggered the same compiler bug as above. + +2004-05-29 Paul Eggert <eggert@cs.ucla.edu> + + tr cleanup, mostly having to do with integer type ranges. + Remove all casts. + + * tests/tr/Test.pm: Add a few tests for the below. Alas, most of + the test cases wouldn't be portable, or would take too much CPU + time, or both. + + * src/tr.c (N_CHARS, N_CHAR_CLASSES): Now an enum, not a macro. + This is safe since the code already assumes N_CHARS fits in int. + (Filter): Remove: we want to prototype everything. + (ORD, CHR): Remove. All uses removed. Some replaced with: + (uchar): New function. All places where a char must be converted + to an unsigned char are now done this way, not by ad-hoc methods. + (count): New type. Use it whenever counts or states are needed. + (BEGIN_STATE): Increase from INT_MAX - 1 (which was bogus, anyway, + since we used it in an unsigned int context) to UINTMAX_MAX - 1. + (REPEAT_COUNT_MAXIMUM): New macro. Use it in place of BEGIN_STATE + whenever appropriate. + (NOT_A_CHAR): Remove global macro; now a local enum. + (UL_LOWER, UL_UPPER, UL_NONE): No longer specify values, since + the rest of the code no longer depends on them. + (class_ok): Remove; all uses changed to use inline comparisons. + (RE_NO_TYPE): Remove; wasn't used or needed. + (struct List_element): normal_char and equiv_code are now unsigned + char, not int. + first_char, last_char, and the_repeated_char are now unsigned char, + not unsigned int. repeat_count is now count, not size_t. + All uses changed. + (struct Spec_list): state is now count, not unsigned int. + lengthis now count, not size_t. + n_indefinite_repeats is now size_t, not int. + has_equiv_class, has_char_class, and has_restricted_char_class + are now bool, not int. All uses changed. + (struct E_string): s is now char *, not unsigned char *. + escaped is now bool *, not int *. All uses changed. + (ES_MATCH): Remove macro, replacing with: + (es_match): New inline function. All uses changed. + (squeeze_repeats, complement, posix_pedantic, truncate_set1, + translating): Now bool, not int. + (io_buf): Now char array, not unsigned char. + (SET_TYPE): Remove. All uses replaced with bool. + (is_equiv_class_member, unquote, append_range, append_char_class, + append_equiv_class, find_closing_delim, star_digits_closebracket, + build_spec_list, parse_str, homogeneous_spec_list): + Now returns bool, not int. All uses changed. + (is_equiv_class_member): Now inline. + (is_equiv_class_member, is_char_class_member, make_printable_str, + append_normal_char, append_range, append_repeated_char, + get_s2_spec_stats): + Args are now of proper integer type. + (unquote, look_up_char_class, make_printable_str, + append_equiv_class, build_spec_list, squeeze_filter): + Avoid unsigned char *p; gently convert *p to unsigned char instead. + (unquote, get_spec_stats): Do not jump past declarations and then + use them; C doesn't allow this in portable programs. + (make_printable_str): Check for overflow in size calculations. + (xmemdup): Remove. All uses rewritten. + (find_bracketed_repeat): Args are now of proper pointer-to-integer + type. Do not reject [c*0]. Use xstrtoumax, not xstrtoul. + (find_bracketed_repeat, star_digits_closebracket): Check that the + digits are not escaped. + (build_spec_list): Don't bother to copy opnd_str; not needed. + (build_spec_list, get_next): Simplify internal logic a bit. + (card_of_complement): Fix bug due to char overflow. + (get_spec_stats): Don't assume len fits into int. + Check for integer overflow. Use abort() rather than assert(0). + (string2_extend): Fix subscript error: is_char_class_member (..., 255) + was being invoked. + (squeeze_filter): READER is never null now; simplify code. + READER arg now has a simpler type. Remove unnecessary casts. + (squeeze_filter, main): Calls to fwrite improperly checked result + against zero, rather than against requested size. + (plain_read): New function. + (read_and_delete, read_and_xlate): + Remove unused filter arg, and don't worry about hit_eof. + Simplify by using plain_read. + (set_initialize): Args are bool and bool *, not int and SET_TYPE *. + (main): Always pass a non-null procedure to squeeze_filter. + Rewrite so that class_ok isn't needed. + +2004-05-29 Paul Eggert <eggert@cs.ucla.edu> + + * src/shred.c (dosync): Ignore EBADF errors, as IRIX 6.5 + fdatasync reports EBADF when syncing (unwritable) directories. + Problem reported by Albert Chin-A-Young in: + http://lists.gnu.org/archive/html/bug-coreutils/2004-05/msg00165.html + +2004-05-29 Jim Meyering <jim@meyering.net> + + * tests/chown/deref: Fix typo: use ls -ldo, not ls -ldg. + Patch from Albert Chin. + + * src/ptx.c (text_buffer_maxend): Remove declaration of unused variable. + + * src/remove.c (push_dir): Merge declaration and adjacent assignment + into a single statement. + +2004-05-28 Jim Meyering <jim@meyering.net> + + * src/remove.c (AD_mark_helper): Eliminate an unnecessary comparison. + +2004-05-22 Jim Meyering <jim@meyering.net> + + rm -r would get a failed assertion when run from an inaccessible + directory and with two or more command line arguments including an + absolute-named directory followed by a relative-named directory. + + * src/remove.h (struct rm_options) [require_restore_cwd]: New member. + * src/remove.c (struct cwd_state): Define. + (AD_pop_and_chdir): Redesign interface so that a restore_cwd failure + can be detected by the caller. Instead of returning a malloc'd + directory name, communicate it to caller via a new parameter, and + return an indication of whether restore_cwd failed. Update caller. + Eliminate an unnecessary call to AC_stack_top. + (remove_dir): Change type of cwd_state parameter to `struct cwd_state' + so we can now communicate to caller whether/how functions like + restore_cwd have failed. Update caller. + (rm_1): Fail if we've failed to restore the working directory + and the name of the next file to remove is `.'-relative. + (rm): Fail if the require_restore_cwd flag is true and we've + failed to restore the working directory. + * src/mv.c (rm_option_init): Initialize new member, + x->require_restore_cwd. + * src/rm.c (rm_option_init): Likewise. + +2004-05-21 Jim Meyering <jim@meyering.net> + + * tests/rm/inaccessible: New test for the above fix. + * tests/rm/Makefile.am (TESTS): Add inaccessible. + + * src/remove.c (rm): Use free rather than XFREE. + (remove_dir): Use xmalloc, not XMALLOC. + (ds_init): Likewise. + +2004-05-20 Jim Meyering <jim@meyering.net> + + * Makefile.maint (sc_unmarked_diagnostics): Now that the unmarked + diagnostics in shred.c have been fixed, don't exempt shred.c from + this check. + + * src/shred.c: Use translatable diagnostics, e.g. + change "%s: remove" to _("%s: failed to remove") and + change "%s: close" to _("%s: failed to close"). + +2004-05-17 Paul Eggert <eggert@cs.ucla.edu> + + * src/shred.c (names): Bring back lower-case letters, "_", and + ".". But continue to omit +, =, %, @, #, as they're either + shell metacharacters (for some shells) or are not in some + character sets, or (in the case of '%') must be a + metacharacter somewhere. + +2004-05-16 Paul Eggert <eggert@cs.ucla.edu> + + * src/cut.c (cut_fields): Adjust to new signature of getndelim2. + +2004-05-17 Jim Meyering <jim@meyering.net> + + * src/shred.c (incname): Decrement `len' only once per loop iteration. + + chgrp and chown now dereference symlinks by default, per POSIX. + Reported by Michal Politowski as http://bugs.debian.org/249177. + + * src/chown-core.c (chopt_init): Affect each symlink referent by default. + * src/chown.c (usage): Update to reflect this. + * src/chgrp.c (usage): Likewise. + * NEWS: Describe the change. + Adapt tests accordingly. + * tests/chgrp/basic: Use -h where necessary to retain semantics. + * tests/chgrp/deref: Likewise. + * tests/chgrp/posix-H: Likewise. + +2004-05-15 Paul Eggert <eggert@cs.ucla.edu> + + In shred, check for errors from fdatasync more carefully. If + fdatasync fails with errno==EINVAL, it means this implementation + does not support synchronized I/O for this file. Do not report + this as an error, as (for example) AIX 5.2 fdatasync reports it + for raw disk devices. Problem reported by Albert Chin in + <http://mail.gnu.org/archive/html/bug-gnu-utils/2004-05/msg00028.html>. + + Check for write errors, though: the old code ignored them. + Improve error checking in a few other cases, too (e.g., close of a + directory). + + Also, change several 'int' values to 'bool', so that the error + checking is a bit clearer. Similarly, change unsigned values + to size_t where appropriate. + + * src/shred.c: Include "dirname.h". + (datasync) [!HAVE_FDATASYNC]: Remove. + (dosync): New function. + (dopass): Use it. Return 1 on write error, -1 on other error. + All callers changed. Report write error if dosync does. + (do_wipefd, wipefd, wipename, wipefile): Return bool (true/false), + not int (0/-1). All callers changed. Return false if there's a + write error. + (incname): Return bool (true/false), not int (0/1). Accept + size_t length, not unsigned. All callers changed. Do not + bother checking for non-digits; it can't happen. Replace + recursion with iteration. + (wipename): Use dir_name, base_name, etc. instead of assuming + Unix file names. Use size_t for length, not unsigned. + Report error if unlink or close fails. + (wipename, main): Use bool for booleans. + + (names): Use only digits and uppercase letters, for greater + portability. + +2004-05-16 Jim Meyering <jim@meyering.net> + + * tests/chown/deref: New test for the yesterday's change. + * tests/chown/Makefile.am (TESTS): Add deref. + +2004-05-15 Jim Meyering <jim@meyering.net> + + chown --dereference did nothing when the owner/group of a + symlink matched the desired owner/group. Reported by David Malone. + Also reported in 1999 as http://bugs.debian.org/39642. + + * src/chown-core.c (change_file_owner): When --dereference has + been specified, and when processing a symlink, stat it to get the + owner and group of the referent. + +2004-05-14 Jim Meyering <jim@meyering.net> + + * man/pwd.x, man/echo.x, man/printf.x: Fix typo: + s/supercede/supersede/ reported by Andrew Fabbro. + +2004-05-13 Paul Eggert <eggert@cs.ucla.edu> + + Improve performance of `sort -m' on large files, at the cost of + making some contrived examples unsafe. POSIX allows this + optimization. Performance problem reported by Jonathan Baker in + <http://mail.gnu.org/archive/html/bug-coreutils/2004-05/msg00071.html>. + + * src/sort.c (first_same_file): Do not treat input pipes + differently from other files. + * doc/coreutils.texi (sort invocation): Document that "sort -m -o F" + might write F before reading all the input. + * NEWS: Likewise. + +2004-05-12 Paul Eggert <eggert@cs.ucla.edu> + + * src/od.c (print_ascii, dump_strings): Use e.g. '\a' rather than + '\007', for portability to EBCDIC hosts. + * src/printf.c (print_esc_char): Likewise. + * src/tr.c (unquote, make_printable_str): Likewise. + +2004-05-12 Jim Meyering <jim@meyering.net> + + * src/remove.c (AD_pop_and_chdir): Move lstat-`.' into if-block + where the result is used. This avoids one unnecessary lstat call + per command line argument. + +2004-05-12 Paul Eggert <eggert@cs.ucla.edu> + + Don't assume that "make -C" works; Solaris "make" doesn't have -C. + + * src/Makefile.am (all_programs.list): New rule, copied from + man/Makefile.am and tests/Makefile.am, except that we use the + system tr rather than ./tr and we don't use tr -s. + * tests/Makefile.am (all_programs): Use it. + * man/Makefile.am (all_programs): Likewise. Renamed from programs, + for consistency. All uses changed. + +2004-05-11 Jim Meyering <jim@meyering.net> + + * tests/rm/unread3: New test, for the above fix and today's + lib/save-cwd.c improvement. + * tests/rm/Makefile.am (TESTS): Add unread3. + + * src/rm.c: Don't include "save-cwd.h". It's no longer used. + +2004-05-10 Jim Meyering <jim@meyering.net> + + * tests/install/trap: New file. Test for bug fix of 2004-04-18. + * tests/install/Makefile.am (TESTS): Add trap. + + * src/remove.c (AD_push): Don't use errno in diagnostic about + `changed dev/ino'. + + Remove these generated files from CVS. + * tests/cut/cut-tests, tests/date/date-tests, tests/join/join-tests: + * tests/ls/ls-tests, tests/pr/pr-tests, tests/tac/tac-tests: + * tests/tail/tail-tests, tests/test/test-tests, tests/tr/range-tests: + * tests/tr/tr-tests, tests/wc/wc-tests: + +2004-05-09 Jim Meyering <jim@meyering.net> + + * src/tr.c (unquote): Use xcalloc rather than xmalloc and + a loop initializing the just-allocated memory to zero. + +2004-05-08 Jim Meyering <jim@meyering.net> + + * tests/rm/no-give-up: New file; check for today's fix. + * tests/rm/Makefile.am (TESTS): Add no-give-up. + +2004-05-08 Paul Eggert <eggert@cs.ucla.edu> + + 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>. + + * src/remove.c (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-06 Jim Meyering <jim@meyering.net> + + * src/id.c (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. + + * src/wc.c (get_input_fstatus): Use xnmalloc, rather than xmalloc. + * src/head.c (elide_tail_bytes_pipe): Likewise. + * src/df.c (main): Likewise. + * src/shred.c (do_wipefd): Likewise. + * src/users.c (list_entries_users): Likewise. + * src/tail.c (main): Likewise. + * src/md5sum.c (main): Likewise. + +2004-04-29 Paul Eggert <eggert@cs.ucla.edu> + + * src/df.c (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-03 Jim Meyering <jim@meyering.net> + + * Makefile.am (EXTRA_DIST): Add m4/ChangeLog, now that we no longer + have m4/Makefile*. + +2004-05-01 Jim Meyering <jim@meyering.net> + + When chown or chgrp is modifying the referent of a symlink, + use the chown(2) function, if possible. + * src/chown-core.c (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. + + * src/chown-core.c (change_file_owner): Add a comment. + +2004-04-27 Jim Meyering <jim@meyering.net> + + * src/ptx.c: Make over 40 global extern variables `static'. + (syntax_table, re_syntax_table): Remove declarations of two unused + variables (they were exposed by the above change). + + * src/du.c (G_fail, opt_nul_terminate_output): Declare `static'. + * src/ln.c (backup_type): Likewise. + + * src/remove.c (rm): Add `extern' keyword. + * src/cp-hash.c (forget_created, remember_created) + (src_to_dest_lookup, remember_copied, hash_init, forget_all): Likewise. + * src/copy.c (dest_info_init, src_info_init, copy): Likewise. + * src/chown-core.c (chopt_init, chopt_free, gid_to_name) + (uid_to_name, chown_files): Likewise. + + * src/Makefile.am (sc_tight_scope): New rule. + * Makefile.maint (sc_tight_scope): New rule. + (syntax-check-rules): Add it. + +2004-04-26 Jim Meyering <jim@meyering.net> + + * Use automake-1.8.4. Regenerate dependent files. + + * src/sort.c (limfield): Make a comment clearer. + +2004-04-25 Paul Eggert <eggert@twinsun.com> + + 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. + + * doc/coreutils.texi (sort invocation): Mention -k earlier, so + that the options are in alphabetical order. Describe how -b works + more-accurately; this involves fixing some examples, too. Mention + what happens if the start field falls after an end field or after + a line end. Warn about using -k without -b, -g, -M, -n, or -t. + Add an example of how to sort IPv4 addresses and Apache Common + Log Format dates. Remove a duplicate example. + (Putting the tools together): Use separate options rather + than agglomerating them. + * src/sort.c (limfield): Use skipeblanks, not skipsblanks, to + decode whether to skip leading blanks. + (trailing_blanks): Remove. + (fillbuf, getmonth, keycompare): Don't trim trailing blanks. + + * tests/pr/Test.pm: Fix typo in env_default comment. + * tests/sort/Test.pm: Likewise. + (18c, 18d): Reverse the order of output lines, so that the + test cases conform to POSIX. + +2004-04-22 Paul Eggert <eggert@twinsun.com> + + 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. + + * src/ls.c (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-23 Jim Meyering <jim@meyering.net> + + Avoid segfault on systems for which SIZE_MAX != (size_t) -1. + * src/ls.c (quote_name): Use SIZE_MAX, not -1, in calls + of quotearg_buffer. Patch by Mikulas Patocka. + +2004-04-18 Paul Eggert <eggert@twinsun.com> + + tee ignored SIGPIPE, but POSIX doesn't allow this. + + * src/tee.c (main): Do not ignore SIGPIPE, as POSIX 1003.1-2001 + does not allow this. This undoes the 1996-10-24 patch. + +2004-04-18 Paul Eggert <eggert@twinsun.com> + + Signal-handling cleanup for coreutils. Here are the highlights: + + - csplit sometimes failed to remove files when interrupted. + - csplit didn't clean up if two signals arrived nearly simultaneously. + - install -s would infloop on System V if SIGCHLD was ignored. + - ls could incorrectly restore color if multiple signals + arrived nearly simultaneously. + + * src/csplit.c (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. + + * src/csplit.c (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. + * src/ls.c (main): Likewise. + * src/sort.c (main): Likewise. + + * src/csplit.c (interrupt_handler): + Use void, not (obsolete) RETSIGTYPE. + * src/shred.c (sigill_handler, isaac_seed_machdep): Likewise. + + * src/csplit.c (interrupt_handler) [defined SA_NOCLDSTOP]: + Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent. + * src/ls.c (sighandler) [defined SA_NOCLDSTOP]: Likewise. + * src/sort.c (sighandler) [defined SA_NOCLDSTOP]: Likewise. + * src/nohup.c (main) [!defined _POSIX_SOURCE]: Likewise, except + for SIG_IGN. + * src/tee.c (main) [!defined _POSIX_SOURCE]: Likewise. + + * src/install.c: 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. + + * src/ls.c (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-20 Jim Meyering <jim@meyering.net> + + * src/remove.c (is_empty_dir): Clarify comment. + + * man/help2man: Accept new option: --program-name=NAME, so that we + can override the one in --version output. This is needed solely + so that test.1 doesn't refer to `[' as the program name. + Reported by Benjamin Cutler as http://bugs.debian.org/205251. + * man/Makefile.am (.x.1): Use help2man's new --program-name option. + + * src/pwd.c: Don't include pathmax.h; system.h already does it. + + * src/cut.c (cut_fields): Free buffer upon getndelim2 failure. + +2004-04-19 Jim Meyering <jim@meyering.net> + + * src/shred.c (isaac_seed_start) [AVOID_USED_UNINITIALIZED_WARNINGS]: + Initialize a buffer to avoid warnings from tools like valgrind. + + * Makefile.maint (sc_trailing_blank): New rule. + (syntax-check-rules): Add it. + * .x-sc_trailing_blank: New file. + + Make pwd work even if the resulting name is so long that getcwd fails. + * src/pwd.c: (path_free, path_init, path_prepend): New functions. + (nth_parent, find_dir_entry, robust_getcwd): New functions. + (main): First try getcwd, then, upon failure, robust_getcwd. + +2004-04-18 Jim Meyering <jim@meyering.net> + + * src/who.c (print_user): Use xrealloc here, rather than + unchecked realloc. Remove anachronistic casts. + + * src/remove.c (full_filename_): Don't leak upon failed realloc. + + * src/system.h (readdir_ignoring_dot_and_dotdot): New inline function, + from remove.c. + * src/remove.c (readdir_ignoring_dotdirs): Move function to system.h, + renaming it. Update uses. + +2004-04-17 Jim Meyering <jim@meyering.net> + + * configure.ac: Depend on automake-1.8.3. + + * src/join.c (add_file_name): Declare function to be `static'. + (string_to_join_field): Likewise. + * src/remove.c (ds_init, ds_free): Likewise. + + * Makefile.maint (sc_prohibit_jm_in_m4): New rule. + (syntax-check-rules): Add to the list. + +2004-04-13 Paul Eggert <eggert@twinsun.com> + + Use page-aligned buffers whenever we bother to do I/O using buffer + sizes that are tailored for the files. + + * src/cat.c: Include getpagesize.h. + * src/copy.c: Likewise. + * src/shred.c: Likewise. + * src/split.c: Likewise. + * src/cat.c (main): Align I/O buffers to page boundaries. + * src/copy.c (copy_reg): Likewise. + * src/shred.c (dopass): Likewise. + * src/split.c (main): Likewise. + * src/dd.c (ROUND_UP_OFFSET, PTR_ALIGN): Remove. + All uses replaced by ptr_align. + * src/od.c (gcd, lcm): Remove; now in system.h. + * src/system.h (gcd, lcm, ptr_align): New functions, moved from od.c. + +2004-04-14 Jim Meyering <jim@meyering.net> + + Remove m4/Makefile.am: it's no longer needed, with newer automake + * configure.ac (AC_CONFIG_FILES): Remove m4/Makefile.in from the list. + * Makefile.am (SUBDIRS): Remove `m4' from the list. + +2004-04-13 Jim Meyering <jim@meyering.net> + + * configure.ac: Change `jm_' in AC_DEFINE'd names to `gl_'. + +2004-03-27 Paul Eggert <eggert@twinsun.com> + + * NEWS: cp -pu and mv -u (when copying) now take the destination + file system time stamp resolution into account. + * doc/coreutils.texi (mv invocation): Document this. + (cp invocation): Document -u (it was missing!) with new behavior. + + * src/copy.c: Include "utimecmp.h". + (copy_internal): Compare time stamps using utimecmp rather than + MTIME_CMP. + +2004-04-09 Jim Meyering <jim@meyering.net> + + * Makefile.maint (.re-list): New rule/file, to replace + hard-coded list of header file names. + (sc_system_h_headers): Use the new file. + Don't look for sys2.h anymore. + + * src/system.h: Include new "stat-macros.h" rather than hard-coding + all of its macro definitions -- the list was slightly out of date. + Suggestion from Dmitry V. Levin. + +2004-04-08 Paul Eggert <eggert@cs.ucla.edu> + + * NEWS: Remove noctty flag from dd. Suggested by Philippe Troin. + * doc/coreutils.texi (dd invocation): Likewise. + * src/shred.c (O_NOCTTY): Remove redundant decl. + * src/dd.c (flags, usage): Remove noctty flag. + (main): Always use O_NOCTTY when opening files. + +2004-04-08 Jim Meyering <jim@meyering.net> + + * src/dd.c (dd_copy): Mark two diagnostics for translations. + (set_fd_flags): Undo part of today's change: it's a little + cleaner -- and more efficient in the common case -- to go + ahead and OR in the -1 when fcntl fails. + + * Makefile.maint (sc_dd_max_sym_length): New target. + (syntax-check-rules): Add it. + + * src/md5sum.c (PROGRAM_NAME) [algorithm == ALG_SHA1]: + Correct spelling: s/shasum/sha1sum. Reported by Jesse Kornblum. + + * src/dd.c (set_fd_flags): Don't OR in -1 when fcntl fails. + Rename parameter, flags, to avoid shadowing global. + (LONGEST_SYMBOL): Tweak comment. + +2004-04-07 Paul Eggert <eggert@twinsun.com> + + * NEWS: New dd conv= symbols nocreat, excl, fdatasync, fsync, + and new dd options iflag= and oflag=. + * src/dd.c (usage): Likewise. + * src/Makefile.am (dd_LDADD, shred_LDADD): Add fdatasync's lib. + * src/dd.c (fdatasync) [!HAVE_FDATASYNC]: New macro. + (C_NOCREAT, C_EXCL, C_FDATASYNC, C_FSYNC): New macros. + (input_flags, output_flags): New vars. + (LONGEST_SYMBOL): New macro. + (struct symbol_value): Renamed from struct conversion. Members + symbol and value renamed from convname and conversion. The + symbol value is now an array instead of a pointer; this saves + a bit of space and time in practice. All uses changed. + (conversions): Add nocreat, excl, fdatasync, fsync. Now const. + (flags): New constant array. + (iflag_error_msgid, oflag_error_msgid): New constants. + (parse_symbols): Renamed from parse_conversion and generalized + to handle either conversion or flag symbols. + (scanargs): Adjust uses of parse_symbols accodingly. Add + support for iflag= and oflag=. Reject attempts to use + both excl and nocreat. + (set_fd_flags): New function. + (dd_copy): Just return X rather than calling quit (X), since our + caller invokes quit with the returned value. Add support for + fdatasync and fsync. + (main): Add support for iflag=, oflag=, and new conv= symbols. + * src/system.h (O_DIRECT, O_DSYNC, O_NDELAY, O_NOFOLLOW, + O_RSYNC, O_SYNC): Define to 0 if not already defined. + + * NEWS: Remove duplicate mention of BLOCKSIZE. + +2004-04-02 Andreas Schwab <schwab@suse.de> + + * src/stty.c: Add support for IUTF8 input flag. + +2004-04-06 Jim Meyering <jim@meyering.net> + + * src/system.h (makedev) [mkdev && !makedev]: Define in terms of mkdev. + Interix spells it `mkdev'. Reported by Mark Funkenhauser. + +2004-04-04 Jim Meyering <jim@meyering.net> + + A specified format is no longer automatically newline terminated. + If you want a newline at the end of your format, use `\n'. + * src/stat.c (print_it): Don't print a newline at the end of + every format. + (do_statfs): Add a newline at end of each default format string. + +2004-03-30 Paul Eggert <eggert@twinsun.com> + + * src/nohup.c (main): Adjust to new calling convention + for set_cloexec_flag. + +2004-03-31 Jim Meyering <jim@meyering.net> + + * tests/Fetish.pm (run_tests): Remove `.orig' file. + Remove debugging diagnostic. + + Specifying an invalid --width=N (-w) or --gap-size=N (-g) + would not elicit an error. + * src/ptx.c: Include "xstrtol.h" and "quotearg.h". + (main): Don't use atoi. Use xstrtoul instead. + +2004-03-30 Jim Meyering <jim@meyering.net> + + * Makefile.maint (sc_prohibit_atoi_atof): New rule. + (syntax-check-rules): Add it. + * .x-sc_prohibit_atoi_atof: New file. + +2004-03-29 Jim Meyering <jim@meyering.net> + + * tests/du/files0-from: Use new OUT_SUBST directive, so that this + test is not sensitive to system-dependent block size differences. + Prompted by a report of Solaris 8 differences from Paul Eggert. + + * tests/Fetish.pm: Accept new directives: OUT_SUBST, ERR_SUBST. + Rename `%tmp' to `%actual'. Reverse order of last two args to + _compare_files (to $actual, $expected) so as to match declaration. + +2004-03-28 Paul Eggert <eggert@twinsun.com> + + Fix some gotchas encountered when porting to Solaris 8, using + the Forte 6u2 compiler. + + * src/hostname.c [HAVE_SETHOSTNAME && !defined sethostname]: + Declare sethostname, since no Solaris header does it. + * src/who.c: Include "vasprintf.h", for asprintf. + +2004-03-28 Jim Meyering <jim@meyering.net> + + Minor optimization: + * src/du.c (process_file): Don't record dev/inode for directories. + + Under some circumstances, without -c, du would mistakenly count the + space of hard-linked files, not just the first one it encountered. + Reported by Anthony Thyssen. + * src/du.c (du_files): Don't ever clear the set of `seen' dev/inodes. + + * src/du.c: Rename global `print_totals' to `print_grand_total'. + + * src/du.c (main): Rearrange filtering loop to be a tiny bit + more efficient. + + * src/chown-core.c: Don't include savedir.h -- no longer needed. + * src/chmod.c: Likewise. + +2004-03-25 Jim Meyering <jim@meyering.net> + + * src/du.c (main): Remove now-unused declaration of `i'. + +2004-03-24 Paul Eggert <eggert@twinsun.com> + + * src/du.c (main): Filter out file names of length zero before + invoking fts, so that they don't cause fatal errors. + +2004-03-25 Jim Meyering <jim@meyering.net> + + * tests/du/files0-from (zero-len): Add a test for the above. + +2004-02-25 Paul Eggert <eggert@twinsun.com> + + * NEWS: New environment var BLOCKSIZE. + * lib/human.c (humblock): Support BLOCKSIZE as well as BLOCK_SIZE. + * tests/envvar-check: Test for it. Factor the code to simplify it. + +2004-03-23 Paul Eggert <eggert@twinsun.com> + + * NEWS: Shorten the du --files0-from announcement, and say + "NUL-terminated" rather than "NUL-separated". + * src/du.c (EXPECTED_BYTES_PER_FILE_NAME, DEFAULT_PROJECTED_N_FILES): + Remove: not used. + (usage): Say "NUL-terminated", not "NUL-separated". + (main): Check for I/O error when istream is closed. + Allow --files0-from=F even if F is empty; this specifies no files. + (du_files): Now that we allow the list of files to be empty, + handle that case. + * tests/du/files0-from: Adjust to above changes to src/du.c. + +2004-03-24 Jim Meyering <jim@meyering.net> + + * tests/tail-2/assert: Avoid race condition that could cause + spurious failure. Based on a patch from Andreas Schwab. + +2004-03-23 Jim Meyering <jim@meyering.net> + + * src/du.c (main): Free the hash table, too. + +2004-03-22 Jim Meyering <jim@meyering.net> + + * man/Makefile.am (.x.1): Remove --info-page= option, reverting + the change of 2004-01-22. I can no longer reproduce the problem + that prompted that change, and `info coreutils pr' would display the + `printing text' section of the manual, not the one on `pr invocation'. + + * tests/du/files0-from (nul-1, nul-2): Adjust expected diagnostics + to match corrected output. + + * src/du.c: Include "readtokens0.h" rather than "readtokens.h". + (main): Use readtoken0 functions rather than readtokens. + Don't use errno when diagnosing readtokens0 failure. + Fix off-by-one error in the token number reported in a diagnostic. + (du_files): Return bool, rather than int. + (main): Call readtokens0_free. + +2004-03-21 Jim Meyering <jim@meyering.net> + + * src/remove.c (ds_free): Plug a small leak. + + * tests/Fetish.pm: Fix typo in comment. + +2004-03-07 Jim Meyering <jim@meyering.net> + + * NEWS: du accepts a new option --files0-from=FILE, where FILE + contains a list of NUL-separated file names. + + * src/du.c: Include "readtokens.h". + (usage): Describe the new option, and adjust the `Usage': + with this option, no FILE may be specified on the command line. + (main): Handle the new option. + + * tests/du/files0-from: New tests, for the above. + * tests/du/Makefile.am (TESTS): Add files0-from. + + * src/factor.c (do_stdin): Reflect changes in use of readtoken. + * src/tsort.c (tsort): Likewise. + +2004-02-29 Paul Eggert <eggert@twinsun.com> + + * NEWS: Add support for a new notation @N to get_date to represent + the time stamp with numeric value N. Improve support for + fractional time stamps. date's -d and -f options now accept them. + Likewise for touch -t. date has a new option --iso-8601=ns. + + * doc/coreutils.texi (touch invocation): + Describe use of fractional seconds. + (date invocation, Options for date): Likewise. + * doc/getdate.texi (General date syntax, Time of day items): Likewise. + * doc/coreutils.texi (date invocation): Mention effect of LC_TIME. + (Options for date): Describe new --iso-8601=ns option. + + * doc/getdate.texi: Add copyright notice. Change getdate to + get_date when talking about the function name. + (Seconds since the Epoch): New section, containing the time_t + info moved from Date input formats section, along with new + info about the @ syntax. Mention negative time stamps, + fractional time stamps, and leap seconds. + (General date syntax): Modernize examples a bit to reflect new + features. + (General date syntax, Relative items in date strings): + Use ' rather than " to quote formats. + (Time of day items): Add an example with fractional seconds. + Describe fractional-second syntax. + + * src/Makefile.am (touch_LDADD): New macro, since `touch' now + needs clock_gettime. + + * src/date.c (enum Time_spec): New enum TIME_SPEC_NS. + (time_spec_string, time_spec, show_date): Support it. + (usage): Remove description of -ITIMESPEC, as it's obsolete and + confusing. Mention --iso-8601=ns. + (batch_convert): getline returns ssize_t, not int. + + * src/touch.c (newtime): Now an array of two timespecs, one + for access and one for modification. + (ref_stats): Remove. + (get_reldate): Use get_date's parameter profile. + (touch, main): Adjust to above changes. + (main): Work even if tm_year == INT_MAX (so long as long int is wider). + Use gettime instead of gettimeofday, for new get_date signature. + + * tests/date/Test.pm (test_vector): New tests epoch, ns-10, ns-max32, + ns-relative. + +2004-03-15 Jim Meyering <jim@meyering.net> + + * Makefile.maint (alpha beta major): `Make' the emit_upload_commands + target before updating $(prev_version_file). + + * tests/misc/date-sec: New file, to test for just-fixed bug in date. + See today's change in lib/getdate.y. + * tests/misc/Makefile.am (TESTS): Add date-sec. + +2004-03-14 Jim Meyering <jim@meyering.net> + + * announce-gen (print_changelog_deltas): Use `.sig' suffix for + signature files, not `.asc'. Reported by angico@yahoo.com. + +2004-03-13 Jim Meyering <jim@meyering.net> + + * src/cp.c (do_copy): Tweak wording in a diagnostic. + Suggestion from Karl Berry. + Include "quoatearg.h". + (do_copy): Use quotearg_colon (not quote) for diagnostics + that begin with `"%s:'. + + * src/nl.c (usage): Specify that nl uses _basic_ regular expressions. + Suggestion from Dan Jacobson. + 2004-03-12 Jim Meyering <jim@meyering.net> * Version 5.2.1. @@ -1487,7 +3958,7 @@ * src/factor.c (print_factors): Give a separate diagnostic for numbers that are too large, but otherwise valid. - Reported by Dániel Varga. + Reported by Dániel Varga. 2003-09-10 Jim Meyering <jim@meyering.net> @@ -3465,10 +5936,10 @@ * README: Refer new feature discussion to bug-coreutils@gnu.org, rather than bug-gnu-utils, now that the former is better known. - Suggestion from Göran Uddeborg. + Suggestion from Göran Uddeborg. * src/stat.c (usage): Capitalize consistently. - Reported by Göran Uddeborg. + Reported by Göran Uddeborg. * Makefile.maint (rel-files): Include $(signatures), so that those files are also copied into $(release_archive_dir). @@ -4287,7 +6758,7 @@ the empty string. (count_entry): When appending a file name component, account for the fact that the current path may end in `/'. - François Pinard reported that `du symlink-to-dir/' was not + François Pinard reported that `du symlink-to-dir/' was not equivalent to `du symlink-to-dir/.'. Now it is. * tests/du/trailing-slash: New file/test, for the above fix. * tests/du/Makefile.am (TESTS): Add trailing-slash. diff --git a/contrib/gnu-sort/NEWS b/contrib/gnu-sort/NEWS index 394a824d..31f459b 100644 --- a/contrib/gnu-sort/NEWS +++ b/contrib/gnu-sort/NEWS @@ -1,4 +1,190 @@ GNU coreutils NEWS -*- outline -*- + +* Major changes in release 5.3.0 (2004-03-17) [unstable] + +** Bug fixes + + rm (without -f) no longer hangs when attempting to remove a symlink + to a file on an off-line NFS-mounted partition. + + cut's --output-delimiter=D option works with abutting byte ranges. + + rm no longer gets a failed assertion under some unusual conditions. + + Several fixes to chgrp and chown for compatibility with POSIX and BSD: + + Do not affect symbolic links by default. + Now, operate on whatever a symbolic points to, instead. + To get the old behavior, use --no-dereference (-h). + + --dereference now works, even when the specified owner + and/or group match those of an affected symlink. + + Check for incompatible options. When -R and --dereference are + both used, then either -H or -L must also be used. When -R and -h + are both used, then -P must be in effect. + + -H, -L, and -P have no effect unless -R is also specified. + If -P and -R are both specified, -h is assumed. + + Do not optimize away the chown() system call when the file's owner + and group already have the desired value. This optimization was + incorrect, as it failed to update the last-changed time and reset + special permission bits, as POSIX requires. + + Do not report an error if the owner or group of a + recursively-encountered symbolic link cannot be updated because + the file system does not support it. + + md5sum and sha1sum now report an error when given so many input + lines that their line counter overflows, instead of silently + reporting incorrect results. + + rm no longer requires read access to the current directory. + + "sort -o -" now writes to a file named "-" instead of to standard + output; POSIX requires this. + + tail -f no longer mishandles pipes and fifos. With no operands, + tail now ignores -f if standard input is a pipe, as POSIX requires. + + For some types of errors (e.g., read-only file system, I/O error) + when first encountering a directory, `rm -r' would mistakenly fail + to remove files under that directory. + + If d/x is a directory and x a file, "ln x d/" now reports an error + instead of incorrectly creating a link to d/x/x. + + Fixes for "nice": + + If it fails to lower the nice value due to lack of permissions, + it goes ahead and runs the command anyway, as POSIX requires. + + It no longer incorrectly reports an error if the current nice + value happens to be -1. + + It no longer assumes that nice values range from -20 through 19. + + It now consistently adjusts out-of-range nice values to the + closest values in range; formerly it sometimes reported an error. + + ptx now diagnoses invalid values for its --width=N (-w) + and --gap-size=N (-g) options. + + tee now exits when it gets a SIGPIPE signal, as POSIX requires. + To get tee's old behavior, use the shell command "(trap '' PIPE; tee)". + Also, "tee -" now writes to standard output instead of to a file named "-". + + ls no longer segfaults on systems for which SIZE_MAX != (size_t) -1 + + echo now conforms to POSIX better. It supports the \0ooo syntax for + octal escapes, and \c now terminates printing immediately. If + POSIXLY_CORRECT is set and the first argument is not "-n", echo now + outputs all option-like arguments instead of treating them as options. + + printf has several changes: + + It now uses 'intmax_t' (not 'long int') to format integers, so it + can now format 64-bit integers on most modern hosts. + + On modern hosts it now supports the C99-inspired %a, %A, %F conversion + specs, the "'" and "0" flags, and the ll, j, t, and z length modifiers + (this is compatible with recent Bash versions). + + The printf command now rejects invalid conversion specifications + like %#d, instead of relying on undefined behavior in the underlying + printf function. + + who now prints user names in full instead of truncating them after 8 bytes. + +** New features + + For efficiency, `sort -m' no longer copies input to a temporary file + merely because the input happens to come from a pipe. As a result, + some relatively-contrived examples like `cat F | sort -m -o F - G' + are no longer safe, as `sort' might start writing F before `cat' is + done reading it. This problem cannot occur unless `-m' is used. + + When outside the default POSIX locale, the 'who' and 'pinky' + commands now output time stamps like "2004-06-21 13:09" instead of + the traditional "Jun 21 13:09". + + pwd now works even when run from a working directory whose name + is longer than PATH_MAX. + + cp, install, ln, and mv have a new --no-target-directory (-T) option, + and -t is now a short name for their --target-directory option. + + cp -pu and mv -u (when copying) now don't bother to update the + destination if the resulting time stamp would be no newer than the + preexisting time stamp. This saves work in the common case when + copying or moving multiple times to the same destination in a file + system with a coarse time stamp resolution. + + dd has new conversions for the conv= option: + + nocreat do not create the output file + excl fail if the output file already exists + fdatasync physically write output file data before finishing + fsync likewise, but also write metadata + + dd has new iflag= and oflag= options with the following flags: + + append append mode (makes sense for output file only) + direct use direct I/O for data + dsync use synchronized I/O for data + sync likewise, but also for metadata + nonblock use non-blocking I/O + nofollow do not follow symlinks + + stty now provides support (iutf8) for setting UTF-8 input mode. + + With stat, a specified format is no longer automatically newline terminated. + If you want a newline at the end of your output, append `\n' to the format + string. + + 'df', 'du', and 'ls' now take the default block size from the + BLOCKSIZE environment variable if the BLOCK_SIZE, DF_BLOCK_SIZE, + DU_BLOCK_SIZE, and LS_BLOCK_SIZE environment variables are not set. + Unlike the other variables, though, BLOCKSIZE does not affect + values like 'ls -l' sizes that are normally displayed as bytes. + This new behavior is for compatibility with BSD. + + du accepts a new option --files0-from=FILE, where FILE contains a + list of NUL-terminated file names. + + `date -d' and `touch -d' now accept integer counts of seconds since + 1970 when prefixed by `@'. For example, `@321' represents + 1970-01-01 00:05:21 UTC. + + `date -d', `date -f' and `touch -d' now handle fractional time + stamps like 2004-02-27 14:19:13.489392193. + + `date' has a new option --iso-8601=ns that outputs + nanosecond-resolution time stamps. + + echo -e '\xHH' now outputs a byte whose hexadecimal value is HH, + for compatibility with bash. + + In the following cases POSIX allows the default GNU behavior, + so when POSIXLY_CORRECT is set: + + false, printf, true, unlink, and yes all support --help and --option. + ls supports TABSIZE. + pr no longer depends on LC_TIME for the date format in non-POSIX locales. + printf supports \u, \U, \x. + tail supports two or more files when using the obsolete option syntax. + + The usual `--' operand is now supported by chroot, hostid, hostname, + pwd, sync, and yes. + + The stat option --filesystem has been renamed to --file-system, for + consistency with POSIX "file system" and with cp and du --one-file-system. + +** Removed features + + tail's undocumented --max-consecutive-size-changes option has been removed. + * Major changes in release 5.2.1 (2004-03-12) [stable] ** Bug fixes diff --git a/contrib/gnu-sort/README b/contrib/gnu-sort/README index 0de5305..df35be4 100644 --- a/contrib/gnu-sort/README +++ b/contrib/gnu-sort/README @@ -34,16 +34,16 @@ file shouldn't affect how it operates, so that people can get the behavior they want with whatever name they want. Special thanks to Paul Eggert, Brian Matthews, Bruce Evans, Karl Berry, -Kaveh Ghazi, and François Pinard for help with debugging and porting +Kaveh Ghazi, and François Pinard for help with debugging and porting these programs. Many thanks to all of the people who have taken the time to submit problem reports and fixes. All contributed changes are attributed in the ChangeLog file. And thanks to the following people who have provided accounts for portability testing on many different types of systems: Bob Proulx, -Christian Robert, François Pinard, Greg McGary, Harlan Stenn, +Christian Robert, François Pinard, Greg McGary, Harlan Stenn, Joel N. Weber, Mark D. Roth, Matt Schalit, Nelson H. F. Beebe, -Réjean Payette, Sam Tardieu. +Réjean Payette, Sam Tardieu. Thanks to Michael Stone for inflicting test releases of the fileutils on Debian's unstable distribution, and to all the kind folks who used diff --git a/contrib/gnu-sort/THANKS b/contrib/gnu-sort/THANKS index 4b8bfbd..44b7b02 100644 --- a/contrib/gnu-sort/THANKS +++ b/contrib/gnu-sort/THANKS @@ -3,7 +3,8 @@ textutils, and/or sh-utils packages). Some have reported problems, others have contributed improvements to the documentation, actual code, and even complete programs. Those contributions are described in the ChangeLog files. If your name has been left out, if you'd rather not be listed, -or if you'd prefer a different address be used, please let me know. +or if you'd prefer a different address be used, please send a note to +the bug-report mailing list (as seen on last line of e.g., cp --help). ??? kytek@cybercomm.net A Costa agcosta@gis.net @@ -32,11 +33,13 @@ Andrei Gaponenko andr@triumf.ca Andres Soolo andres@soolo.matti.ee Andrew Burgess aab@cichlid.com Andrew Dalke dalke@bioreason.com +Andrew Fabbro andrew@fabbro.org Andrew Pham andpha@us.ibm.com Andrew Tridgell tridge@samba.org Andrey Borzenkov arvidjaar@mail.ru Andries Brouwer Andries.Brouwer@cwi.nl Andy Longton alongton@metamark.com +Anthony Thyssen anthony@griffith.edu.au Antonio Rendas ajrendas@yahoo.com Ariel Faigon ariel@cthulhu.engr.sgi.com Arne H. Juul arnej@solan.unit.no @@ -51,6 +54,7 @@ Axel Kittenberger Anshil@gmx.net Bauke Jan Douma bjdouma@xs4all.nl Ben Elliston bje@air.net.au Ben Harris bjh21@netbsd.org +Benjamin Cutler cutlerbc@simla.colostate.edu Bengt Martensson bengt@mathematik.uni-Bremen.de Bernard Giroud bernard.giroud@creditlyonnais.ch Bernd Leibing bernd.leibing@rz.uni-ulm.de @@ -98,7 +102,7 @@ Dan Hagerty hag@gnu.ai.it.edu Dan Jacobson http://www.geocities.com/jidani Dan Pascu dan@services.iiruc.ro Daniel Bergstrom noa@melody.se -Dániel Varga danielv@axelero.hu +Dániel Varga danielv@axelero.hu Danny Levinson danny.levinson@overture.com Darren Salt ds@youmustbejoking.demon.co.uk Dave Beckett dajobe@dajobe.org @@ -107,6 +111,7 @@ David Eisner cradle@umd.edu David Flynn dav@chess.plus.com David Godfrey dave@delta.demon.co.uk David Luyer david_luyer@pacific.net.au +David Malone dwmalone@cnri.dit.ie Deepak Goel deego@gnufans.org Dennis Henriksen opus@flamingo.osrl.dk Dennis Smit ds@nerds-incorporated.org @@ -138,14 +143,14 @@ Felix Lee flee@teleport.com Ferdinand fw@scenic.mine.nu Fletcher Mattox fletcher@cs.utexas.edu Florin Iucha fiucha@hsys.mic.ro -François Pinard pinard@iro.umontreal.ca +François Pinard pinard@iro.umontreal.ca Frank Adler fadler@allesklar.de Frank T Lofaro ftlofaro@snooks.Egr.UNLV.EDU Fred Fish fnf@ninemoons.com -Frédéric L. W. Meunier 0@pervalidus.net +Frédéric L. W. Meunier 0@pervalidus.net Frederik Eaton frederik@caltech.edu Gabor Z. Papp gzp@gzp.org.hu -Gaël Quéri gqueri@mail.dotcom.fr +Gaël Quéri gqueri@mail.dotcom.fr Galen Hazelwood galenh@micron.net Gary Anderson ganderson@clark.net Gary V. Vaughan gary@gnu.org @@ -156,7 +161,7 @@ Geoff Odhner geoff@franklin.com Geoff Whale geoffw@cse.unsw.EDU.AU Gerhard Poul gpoul@gnu.org Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp -Göran Uddeborg goeran@uddeborg.pp.se +Göran Uddeborg goeran@uddeborg.pp.se GOTO Masanori gotom@debian.or.jp Greg Louis glouis@dynamicro.on.ca Greg McGary gkm@gnu.org @@ -164,6 +169,7 @@ Greg Schafer gschafer@zip.com.au Greg Troxel gdt@bbn.com Greg Wooledge gawooledge@sherwin.com Gregory Leblanc gleblanc@cu-portland.edu +Guido Leenders guido.leenders@invantive.com H. J. Lu hjl@valinux.com Hans Ginzel hans@matfyz.cz Hans Lermen lermen@fgan.de @@ -197,7 +203,8 @@ Jeff Sheinberg jeff@bsrd.net Jens Elkner elkner@imsgroup.de Jens Schmidt jms@jsds.hamburg.com Jerome Abela abela@hsc.fr -Jérôme Zago bug-coreutils-ml@agt-the-walker.net +Jérôme Zago bug-coreutils-ml@agt-the-walker.net +Jesse Kornblum kornblum@usna.edu Jesse Thilo jgt2@eecs.lehigh.edu Jie Xu xuj@iag.net Jim Blandy jimb@cyclic.com @@ -216,12 +223,13 @@ John Murphy jam@philabs.research.philips.com John Roll john@panic.harvard.edu John Salmon johns@mullet.anu.edu.au John Summerfield summer@OS2.ami.com.au +Jon Peatfield J.S.Peatfield@damtp.cam.ac.uk Joost van Baal joostvb@xs4all.nl Jorge Stolfi stolfi@ic.unicamp.br Joseph S. Myers jsm28@cam.ac.uk Juan F. Codagnone juam@arnet.com.ar Jungshik Shin jshin@pantheon.yale.edu -Jürgen Fluk louis@dachau.marco.de +Jürgen Fluk louis@dachau.marco.de Jurriaan thunder7@xs4all.nl jvogel jvogel@linkny.com Kai Henningsen kai@debian.org @@ -253,6 +261,7 @@ Maciej Kwapulinski pikpok@univ.gda.pl Manas Garg manas@cygsoft.com Manfred Hollstein manfred@s-direktnet.de Marc Boucher marc@mbsi.ca +Marc Haber mh+debian-bugs@zugschlus.de Marc Olzheim marcolz@stack.nl Marco Franzen Marco.Franzen@Thyron.com Marcus Brinkmann http://www.marcus-brinkmann.de @@ -260,6 +269,7 @@ Marcus Daniels marcus@ee.pdx.edu Mark A. Thomas thommark@access.digex.net Mark Conty Mark_Conty@cargill.com Mark D. Roth roth@uiuc.edu +Mark Funkenhauser mfunkenhauser@rogers.com Mark Harris mark@monitor.designacc.com Mark Hewitt mhewitt@armature.com Mark Hounschell markh@compro.net @@ -292,6 +302,7 @@ Matthias Urlichs smurf@noris.de Matti Aarnio matti.aarnio@zmailer.org Mattias Wadenstein maswan@acc.umu.se Meelis Roos mroos@tartu.cyber.ee +Michael michael@aplatform.com Michael ??? michael@roka.net Michael Bacarella mbac@netgraft.com> Michael Deutschmann michael@talamasca.ocis.net @@ -308,6 +319,7 @@ Michael Stutz stutz@dsl.org Michael van Elst mlelstv@dev.de.cw.net Michael Veksler mveksler@techunix.technion.ac.il Michail Litvak mci@owl.openwall.com +Michal Politowski mpol@charybda.icm.edu.pl Michal Svec msvec@suse.cz Michel Robitaille robitail@IRO.UMontreal.CA Michiel Bacchiani bacchian@raven.bu.edu @@ -315,6 +327,7 @@ Mike Castle dalgoda@ix.netcom.com Mike Coleman mkc@mathdogs.com Mike Jetzer mjetzer@mke.catalystwms.com Mikko Tuumanen m@sorvankyla.yok.utu.fi +Mikulas Patocka mikulas@artax.karlin.mff.cuni.cz Miles Bader miles@gnu.ai.mit.edu Minh Tran-Le tranle@intellicorp.com Morten Welinder terra@diku.dk @@ -331,7 +344,7 @@ Olatunji Oluwabukunmi Ruwase tjruwase@stanford.edu Olav Morkrid olav@funcom.com Ole Laursen olau@hardworking.dk Oliver Kiddle okiddle@yahoo.co.uk -Ørn E. Hansen oehansen@daimi.aau.dk +Ørn E. Hansen oehansen@daimi.aau.dk Oskar Liljeblad osk@hem.passagen.se Patrick Mauritz oxygene@studentenbude.ath.cx Paul Eggert eggert@twinsun.com @@ -361,7 +374,7 @@ Rainer Orth ro@TechFak.Uni-Bielefeld.DE Ralf W. Stephan stephan@tmt.de Ralph Loader loader@maths.ox.ac.uk Raul Miller moth@magenta.com -Raúl Núñez de Arenas Coronado raul@pleyades.net +Raúl Núñez de Arenas Coronado raul@pleyades.net Reuben Thomas rrt@sc3d.org Richard A Downing richard.downing@bcs.org.uk Richard Braakman dark@xs4all.nl @@ -376,7 +389,7 @@ Robert H. de Vries robert@and.nl Robert Millan zeratul2@wanadoo.es Rogier Wolff R.E.Wolff@BitWizard.nl Roland Huebner ro-huebner@gmx.de -Roland Turner raz@raz.cx +Roland Turner raz.tah.bet@raz.cx Ronald F. Guilmette rfg@netcom.com Ross Alexander r.alexander@auckland.ac.nz Ross Paterson rap@doc.ic.ac.uk @@ -392,7 +405,7 @@ Shing-Shong Shei shei@cs.indiana.edu Soeren Sonnenburg sonnenburg@informatik.hu-berlin.de Solar Designer solar@owl.openwall.com Stanislav Ievlev inger@altlinux.ru -Stéphane Chazelas Stephane_CHAZELAS@yahoo.fr +Stéphane Chazelas Stephane_CHAZELAS@yahoo.fr Stephen Depooter sbdep@myrealbox.com Stephen Eglen eglen@pcg.wustl.edu Stephen Gildea gildea@stop.mail-abuse.org @@ -419,6 +432,7 @@ Tom Haynes thomas@netapp.com Tom Quinn trq@dionysos.thphys.ox.ac.uk Tommi Kyntola tkyntola@cc.hut.fi Ton Hospel thospel@mail.dma.be +Ton Nijkes ton@murphy.nl Tony Kocurko akocurko@mun.ca Tony Leneis tony@plaza.ds.adp.com Tony Robinson ajr@eng.cam.ac.uk diff --git a/contrib/gnu-sort/TODO b/contrib/gnu-sort/TODO index b3a2fa3..82a74bf 100644 --- a/contrib/gnu-sort/TODO +++ b/contrib/gnu-sort/TODO @@ -47,10 +47,6 @@ seq: give better diagnostics for invalid formats: e.g. no or too many % directives seq: consider allowing format string to contain no %-directives -dd: consider adding an option to suppress `bytes/block read/written' -output to stderr. Suggested here: - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=165045 - m4: rename all macros that start with AC_ to start with another prefix resolve RH report on cp -a forwarded by Tim Waugh @@ -62,9 +58,6 @@ tail: don't use xlseek; it *exits*. add mktemp? Suggested by Nelson Beebe -Now that AC_FUNC_LSTAT and AC_FUNC_STAT are in autoconf, -remove m4/stat.m4 and m4/lstat.m4. - df: alignment problem of `Used' heading with e.g., -mP reported by Karl Berry @@ -136,9 +129,8 @@ Adapt these contribution guidelines for coreutils: Changes expected to go in, post-5.2.1: ====================================== - du and wc: add an option, --from0-file, to make them read NUL-delimited + wc: add an option, --files0-from [as for du] to make it read NUL-delimited file name arguments from a file. - [I now have a patch adding --from0-file for du] dd patch from Olivier Delhomme @@ -146,9 +138,6 @@ Changes expected to go in, post-5.2.1: Apply Bruno Haible's hostname changes - stat: no longer output trailing newline for user-supplied FORMATs - This will mean adding \n to default formats, internally. - test/mv/*: clean up $other_partition_tmpdir in all cases ls: when both -l and --dereference-command-line-symlink-to-dir are @@ -163,7 +152,20 @@ Changes expected to go in, post-5.2.1: Re-add a separate test for du's stack space usage (like the one removed from tests/rm/deep-1). + dd: consider adding an option to suppress `bytes/block read/written' + output to stderr. Suggested here: + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=165045 + Pending copyright papers: ------------------------ ls --color: Ed Avis' patch to suppress escape sequences for non-highlighted files + + getpwnam from Bruce Korb + + pb (progress bar) from Miika Pekkarinen + + Look into improving the performance of md5sum. + `openssl md5' is consistently about 30% faster than md5sum on an idle + AMD 2000-XP system with plenty of RAM and a 261 MB input file. + openssl's md5 implementation is in assembly, generated by a perl script. diff --git a/contrib/gnu-sort/lib/argmatch.c b/contrib/gnu-sort/lib/argmatch.c index 210689b..1a8ec2f 100644 --- a/contrib/gnu-sort/lib/argmatch.c +++ b/contrib/gnu-sort/lib/argmatch.c @@ -27,6 +27,7 @@ /* Specification. */ #include "argmatch.h" +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -79,14 +80,14 @@ argmatch_exit_fn argmatch_die = __argmatch_die; "no", "nope" -> 1 "y" is a valid argument, for `0', and "n" for `1'. */ -int +ptrdiff_t argmatch (const char *arg, const char *const *arglist, const char *vallist, size_t valsize) { - int i; /* Temporary index in ARGLIST. */ + size_t i; /* Temporary index in ARGLIST. */ size_t arglen; /* Length of ARG. */ - int matchind = -1; /* Index of first nonexact match. */ - int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */ + ptrdiff_t matchind = -1; /* Index of first nonexact match. */ + bool ambiguous = false; /* If true, multiple nonexact match(es). */ arglen = strlen (arg); @@ -110,7 +111,7 @@ argmatch (const char *arg, const char *const *arglist, { /* There is a real ambiguity, or we could not disambiguate. */ - ambiguous = 1; + ambiguous = true; } } } @@ -127,7 +128,7 @@ argmatch (const char *arg, const char *const *arglist, PROBLEM is the return value from argmatch. */ void -argmatch_invalid (const char *context, const char *value, int problem) +argmatch_invalid (const char *context, const char *value, ptrdiff_t problem) { char const *format = (problem == -1 ? _("invalid argument %s for %s") @@ -145,7 +146,7 @@ void argmatch_valid (const char *const *arglist, const char *vallist, size_t valsize) { - int i; + size_t i; const char *last_val = NULL; /* We try to put synonyms on the same line. The assumption is that @@ -171,13 +172,13 @@ argmatch_valid (const char *const *arglist, "--version-control", or "$VERSION_CONTROL" etc.). Upon failure, calls the (supposed never to return) function EXIT_FN. */ -int +ptrdiff_t __xargmatch_internal (const char *context, const char *arg, const char *const *arglist, const char *vallist, size_t valsize, argmatch_exit_fn exit_fn) { - int res = argmatch (arg, arglist, vallist, valsize); + ptrdiff_t res = argmatch (arg, arglist, vallist, valsize); if (res >= 0) /* Success. */ return res; @@ -197,7 +198,7 @@ argmatch_to_argument (const char *value, const char *const *arglist, const char *vallist, size_t valsize) { - int i; + size_t i; for (i = 0; arglist[i]; i++) if (!memcmp (value, vallist + valsize * i, valsize)) diff --git a/contrib/gnu-sort/lib/argmatch.h b/contrib/gnu-sort/lib/argmatch.h index e8bb23c..8952394 100644 --- a/contrib/gnu-sort/lib/argmatch.h +++ b/contrib/gnu-sort/lib/argmatch.h @@ -49,8 +49,8 @@ false ambiguities (i.e., different matches of ARG but corresponding to the same values in VALLIST). */ -int argmatch (char const *arg, char const *const *arglist, - char const *vallist, size_t valsize); +ptrdiff_t argmatch (char const *arg, char const *const *arglist, + char const *vallist, size_t valsize); # define ARGMATCH(Arg, Arglist, Vallist) \ argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist)) @@ -63,7 +63,8 @@ extern argmatch_exit_fn argmatch_die; /* Report on stderr why argmatch failed. Report correct values. */ -void argmatch_invalid (char const *context, char const *value, int problem); +void argmatch_invalid (char const *context, char const *value, + ptrdiff_t problem); /* Left for compatibility with the old name invalid_arg */ @@ -85,10 +86,10 @@ void argmatch_valid (char const *const *arglist, /* Same as argmatch, but upon failure, reports a explanation on the failure, and exits using the function EXIT_FN. */ -int __xargmatch_internal (char const *context, - char const *arg, char const *const *arglist, - char const *vallist, size_t valsize, - argmatch_exit_fn exit_fn); +ptrdiff_t __xargmatch_internal (char const *context, + char const *arg, char const *const *arglist, + char const *vallist, size_t valsize, + argmatch_exit_fn exit_fn); /* Programmer friendly interface to __xargmatch_internal. */ diff --git a/contrib/gnu-sort/lib/closeout.c b/contrib/gnu-sort/lib/closeout.c index a551d1a..3c7bed9 100644 --- a/contrib/gnu-sort/lib/closeout.c +++ b/contrib/gnu-sort/lib/closeout.c @@ -1,5 +1,7 @@ /* closeout.c - close standard output - Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,11 +24,7 @@ #include "closeout.h" #include <stdio.h> - #include <errno.h> -#ifndef errno -extern int errno; -#endif #include "gettext.h" #define _(msgid) gettext (msgid) diff --git a/contrib/gnu-sort/lib/closeout.h b/contrib/gnu-sort/lib/closeout.h index d27d760..1b715ee 100644 --- a/contrib/gnu-sort/lib/closeout.h +++ b/contrib/gnu-sort/lib/closeout.h @@ -1,6 +1,6 @@ /* Close standard output. - Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 2000, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,15 @@ #ifndef CLOSEOUT_H # define CLOSEOUT_H 1 +# ifdef __cplusplus +extern "C" { +# endif + void close_stdout_set_file_name (const char *file); void close_stdout (void); +# ifdef __cplusplus +} +# endif + #endif diff --git a/contrib/gnu-sort/lib/dup-safer.c b/contrib/gnu-sort/lib/dup-safer.c index f72fd84..408a1bd 100644 --- a/contrib/gnu-sort/lib/dup-safer.c +++ b/contrib/gnu-sort/lib/dup-safer.c @@ -1,5 +1,5 @@ /* Invoke dup, but avoid some glitches. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,9 +22,6 @@ #endif #include <errno.h> -#ifndef errno -extern int errno; -#endif #if HAVE_FCNTL_H # include <fcntl.h> diff --git a/contrib/gnu-sort/lib/error.c b/contrib/gnu-sort/lib/error.c index 1149235..5a5e126 100644 --- a/contrib/gnu-sort/lib/error.c +++ b/contrib/gnu-sort/lib/error.c @@ -1,5 +1,5 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000-2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1990-1998, 2000-2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify @@ -106,7 +106,7 @@ extern char *program_name; static void print_errno_message (int errnum) { - char const *s; + char const *s = NULL; #if defined HAVE_STRERROR_R || _LIBC char errbuf[1024]; @@ -115,15 +115,11 @@ print_errno_message (int errnum) # else if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) s = errbuf; - else - s = 0; # endif -#else - s = strerror (errnum); #endif #if !_LIBC - if (! s) + if (! s && ! (s = strerror (errnum))) s = _("Unknown system error"); #endif diff --git a/contrib/gnu-sort/lib/fopen-safer.c b/contrib/gnu-sort/lib/fopen-safer.c index 6825f9b..c5c97c8 100644 --- a/contrib/gnu-sort/lib/fopen-safer.c +++ b/contrib/gnu-sort/lib/fopen-safer.c @@ -1,5 +1,5 @@ /* Invoke fopen, but avoid some glitches. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,10 +31,6 @@ #endif #include <errno.h> -#ifndef errno -extern int errno; -#endif - #include <stdio.h> #include <stdio-safer.h> diff --git a/contrib/gnu-sort/lib/hard-locale.c b/contrib/gnu-sort/lib/hard-locale.c index 8c0ee8c..67a4144 100644 --- a/contrib/gnu-sort/lib/hard-locale.c +++ b/contrib/gnu-sort/lib/hard-locale.c @@ -1,6 +1,7 @@ /* hard-locale.c -- Determine whether a locale is hard. - Copyright (C) 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2002, 2003, 2004 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,23 +30,23 @@ #include <stdlib.h> #include <string.h> -/* Return nonzero if the current CATEGORY locale is hard, i.e. if you +/* Return true if the current CATEGORY locale is hard, i.e. if you can't get away with assuming traditional C or POSIX behavior. */ -int +bool hard_locale (int category) { #if ! HAVE_SETLOCALE - return 0; + return false; #else - int hard = 1; - char const *p = setlocale (category, 0); + bool hard = true; + char const *p = setlocale (category, NULL); if (p) { # if defined __GLIBC__ && 2 <= __GLIBC__ if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0) - hard = 0; + hard = false; # else char *locale = malloc (strlen (p) + 1); if (locale) @@ -59,7 +60,7 @@ hard_locale (int category) && strcmp (p, locale) == 0) || ((p = setlocale (category, "POSIX")) && strcmp (p, locale) == 0)) - hard = 0; + hard = false; /* Restore the caller's locale. */ setlocale (category, locale); diff --git a/contrib/gnu-sort/lib/hard-locale.h b/contrib/gnu-sort/lib/hard-locale.h index ddc15d0..010cb27 100644 --- a/contrib/gnu-sort/lib/hard-locale.h +++ b/contrib/gnu-sort/lib/hard-locale.h @@ -1,6 +1,6 @@ /* Determine whether a locale is hard. - Copyright (C) 1999, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ #ifndef HARD_LOCALE_H_ # define HARD_LOCALE_H_ 1 -int hard_locale (int); +# include <stdbool.h> + +bool hard_locale (int); #endif /* HARD_LOCALE_H_ */ diff --git a/contrib/gnu-sort/lib/human.c b/contrib/gnu-sort/lib/human.c index 36cfd73..f024c73 100644 --- a/contrib/gnu-sort/lib/human.c +++ b/contrib/gnu-sort/lib/human.c @@ -1,7 +1,7 @@ /* human.c -- print human readable file size - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free - Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -300,8 +300,8 @@ human_readable (uintmax_t n, char *buf, int opts, { do { - unsigned r10 = (amt % base) * 10 + tenths; - unsigned r2 = (r10 % base) * 2 + (rounding >> 1); + unsigned int r10 = (amt % base) * 10 + tenths; + unsigned int r2 = (r10 % base) * 2 + (rounding >> 1); amt /= base; tenths = r10 / base; rounding = (r2 < base @@ -428,7 +428,9 @@ humblock (char const *spec, uintmax_t *block_size, int *options) int i; int opts = 0; - if (! spec && ! (spec = getenv ("BLOCK_SIZE"))) + if (! spec + && ! (spec = getenv ("BLOCK_SIZE")) + && ! (spec = getenv ("BLOCKSIZE"))) *block_size = default_block_size (); else { diff --git a/contrib/gnu-sort/lib/human.h b/contrib/gnu-sort/lib/human.h index 604fec1..b67ba4e 100644 --- a/contrib/gnu-sort/lib/human.h +++ b/contrib/gnu-sort/lib/human.h @@ -1,7 +1,7 @@ /* human.h -- print human readable file size - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free - Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,12 +29,11 @@ # include <limits.h> # include <stdbool.h> -# if HAVE_INTTYPES_H -# include <inttypes.h> -# else -# if HAVE_STDINT_H -# include <stdint.h> -# endif +# if HAVE_STDINT_H +# include <stdint.h> +# endif +# if HAVE_UNISTD_H +# include <unistd.h> # endif /* A conservative bound on the maximum length of a human-readable string. diff --git a/contrib/gnu-sort/lib/inttostr.h b/contrib/gnu-sort/lib/inttostr.h index de2b164..6f2416b 100644 --- a/contrib/gnu-sort/lib/inttostr.h +++ b/contrib/gnu-sort/lib/inttostr.h @@ -1,6 +1,6 @@ /* inttostr.h -- convert integers to printable strings - Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,14 +25,12 @@ #if HAVE_INTTYPES_H # include <inttypes.h> #endif - -#if HAVE_LIMITS_H -# include <limits.h> -#endif -#ifndef CHAR_BIT -# define CHAR_BIT 8 +#if HAVE_STDINT_H +# include <stdint.h> #endif +#include <limits.h> + #if HAVE_SYS_TYPES_H # include <sys/types.h> #endif diff --git a/contrib/gnu-sort/lib/memcoll.c b/contrib/gnu-sort/lib/memcoll.c index 34ae767..e777e6a 100644 --- a/contrib/gnu-sort/lib/memcoll.c +++ b/contrib/gnu-sort/lib/memcoll.c @@ -1,5 +1,5 @@ /* Locale-specific memory comparison. - Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,10 +24,6 @@ #include "memcoll.h" #include <errno.h> -#ifndef errno -extern int errno; -#endif - #include <string.h> /* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according diff --git a/contrib/gnu-sort/lib/quotearg.c b/contrib/gnu-sort/lib/quotearg.c index c695646..64fa676 100644 --- a/contrib/gnu-sort/lib/quotearg.c +++ b/contrib/gnu-sort/lib/quotearg.c @@ -1,5 +1,7 @@ /* quotearg.c - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +30,7 @@ #include <ctype.h> #include <errno.h> #include <limits.h> +#include <stdbool.h> #include <stdlib.h> #include <string.h> @@ -174,7 +177,7 @@ gettext_quote (char const *msgid, enum quoting_style s) size of the output, not counting the terminating null. If BUFFERSIZE is too small to store the output string, return the value that would have been returned had BUFFERSIZE been large enough. - If ARGSIZE is -1, use the string length of the argument for ARGSIZE. + If ARGSIZE is SIZE_MAX, use the string length of the argument for ARGSIZE. This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG, ARGSIZE, O), except it uses QUOTING_STYLE instead of the quoting @@ -190,8 +193,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, size_t len = 0; char const *quote_string = 0; size_t quote_string_len = 0; - int backslash_escapes = 0; - int unibyte_locale = MB_CUR_MAX == 1; + bool backslash_escapes = false; + bool unibyte_locale = MB_CUR_MAX == 1; #define STORE(c) \ do \ @@ -206,13 +209,13 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, { case c_quoting_style: STORE ('"'); - backslash_escapes = 1; + backslash_escapes = true; quote_string = "\""; quote_string_len = 1; break; case escape_quoting_style: - backslash_escapes = 1; + backslash_escapes = true; break; case locale_quoting_style: @@ -237,7 +240,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, char const *right = gettext_quote (N_("'"), quoting_style); for (quote_string = left; *quote_string; quote_string++) STORE (*quote_string); - backslash_escapes = 1; + backslash_escapes = true; quote_string = right; quote_string_len = strlen (quote_string); } @@ -326,6 +329,10 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, } break; + case '{': case '}': /* sometimes special if isolated */ + if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1)) + break; + /* Fall through. */ case '#': case '~': if (i != 0) break; @@ -334,7 +341,9 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case '!': /* special in bash */ case '"': case '$': case '&': case '(': case ')': case '*': case ';': - case '<': case '>': case '[': + case '<': + case '=': /* sometimes special in 0th or (with "set -k") later args */ + case '>': case '[': case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */ case '`': case '|': /* A shell special character. In theory, '$' and '`' could @@ -364,7 +373,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case '%': case '+': case ',': case '-': case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': case ':': case '=': + case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': @@ -374,7 +383,6 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': - case '{': case '}': /* These characters don't cause problems, no matter what the quoting style is. They cannot start multibyte sequences. */ break; @@ -389,12 +397,12 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, /* Length of multibyte sequence found so far. */ size_t m; - int printable; + bool printable; if (unibyte_locale) { m = 1; - printable = isprint (c); + printable = isprint (c) != 0; } else { @@ -402,7 +410,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, memset (&mbstate, 0, sizeof mbstate); m = 0; - printable = 1; + printable = true; if (argsize == SIZE_MAX) argsize = strlen (arg); @@ -415,20 +423,36 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, break; else if (bytes == (size_t) -1) { - printable = 0; + printable = false; break; } else if (bytes == (size_t) -2) { - printable = 0; + printable = false; while (i + m < argsize && arg[i + m]) m++; break; } else { + /* Work around a bug with older shells that "see" a '\' + that is really the 2nd byte of a multibyte character. + In practice the problem is limited to ASCII + chars >= '@' that are shell special chars. */ + if ('[' == 0x5b && quoting_style == shell_quoting_style) + { + size_t j; + for (j = 1; j < bytes; j++) + switch (arg[i + m + j]) + { + case '[': case '\\': case '^': + case '`': case '|': + goto use_shell_always_quoting_style; + } + } + if (! iswprint (w)) - printable = 0; + printable = false; m += bytes; } } @@ -472,6 +496,9 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, STORE (c); } + if (i == 0 && quoting_style == shell_quoting_style) + goto use_shell_always_quoting_style; + if (quote_string) for (; *quote_string; quote_string++) STORE (*quote_string); @@ -492,7 +519,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, size of the output, not counting the terminating null. If BUFFERSIZE is too small to store the output string, return the value that would have been returned had BUFFERSIZE been large enough. - If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */ + If ARGSIZE is SIZE_MAX, use the string length of the argument for + ARGSIZE. */ size_t quotearg_buffer (char *buffer, size_t buffersize, char const *arg, size_t argsize, @@ -506,8 +534,23 @@ quotearg_buffer (char *buffer, size_t buffersize, return r; } +/* Like quotearg_buffer (..., ARG, ARGSIZE, O), except return newly + allocated storage containing the quoted string. */ +char * +quotearg_alloc (char const *arg, size_t argsize, + struct quoting_options const *o) +{ + int e = errno; + size_t bufsize = quotearg_buffer (0, 0, arg, argsize, o) + 1; + char *buf = xmalloc (bufsize); + quotearg_buffer (buf, bufsize, arg, argsize, o); + errno = e; + return buf; +} + /* Use storage slot N to return a quoted version of argument ARG. - ARG is of size ARGSIZE, but if that is -1, ARG is a null-terminated string. + ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a + null-terminated string. OPTIONS specifies the quoting options. The returned value points to static storage that can be reused by the next call to this function with the same value of N. diff --git a/contrib/gnu-sort/lib/quotearg.h b/contrib/gnu-sort/lib/quotearg.h index efc9331..14dc316 100644 --- a/contrib/gnu-sort/lib/quotearg.h +++ b/contrib/gnu-sort/lib/quotearg.h @@ -1,6 +1,6 @@ /* quotearg.h - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -27,13 +27,31 @@ /* Basic quoting styles. */ enum quoting_style { - literal_quoting_style, /* --quoting-style=literal */ - shell_quoting_style, /* --quoting-style=shell */ - shell_always_quoting_style, /* --quoting-style=shell-always */ - c_quoting_style, /* --quoting-style=c */ - escape_quoting_style, /* --quoting-style=escape */ - locale_quoting_style, /* --quoting-style=locale */ - clocale_quoting_style /* --quoting-style=clocale */ + /* Output names as-is (ls --quoting-style=literal). */ + literal_quoting_style, + + /* Quote names for the shell if they contain shell metacharacters + or would cause ambiguous output (ls --quoting-style=shell). */ + shell_quoting_style, + + /* Quote names for the shell, even if they would normally not + require quoting (ls --quoting-style=shell-always). */ + shell_always_quoting_style, + + /* Quote names as for a C language string (ls --quoting-style=c). */ + c_quoting_style, + + /* Like c_quoting_style except omit the surrounding double-quote + characters (ls --quoting-style=escape). */ + escape_quoting_style, + + /* Like clocale_quoting_style, but quote `like this' instead of + "like this" in the default C locale (ls --quoting-style=locale). */ + locale_quoting_style, + + /* Like c_quoting_style except use quotation marks appropriate for + the locale (ls --quoting-style=clocale). */ + clocale_quoting_style }; /* For now, --quoting-style=literal is the default, but this may change. */ @@ -81,6 +99,11 @@ size_t quotearg_buffer (char *buffer, size_t buffersize, char const *arg, size_t argsize, struct quoting_options const *o); +/* Like quotearg_buffer, except return the result in a newly allocated + buffer. It is the caller's responsibility to free the result. */ +char *quotearg_alloc (char const *arg, size_t argsize, + struct quoting_options const *o); + /* Use storage slot N to return a quoted version of the string ARG. Use the default quoting options. The returned value points to static storage that can be diff --git a/contrib/gnu-sort/lib/stat-macros.h b/contrib/gnu-sort/lib/stat-macros.h new file mode 100644 index 0000000..facbabb --- /dev/null +++ b/contrib/gnu-sort/lib/stat-macros.h @@ -0,0 +1,255 @@ +/* stat-related macros + + Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Paul Eggert and Jim Meyering. */ + +#ifndef STAT_MACROS_H +# define STAT_MACROS_H 1 + +# if ! defined S_ISREG && ! defined S_IFREG +# error "you must include <sys/stat.h> before including this file" +# endif + +# ifndef S_IFMT +# define S_IFMT 0170000 +# endif + +# if STAT_MACROS_BROKEN +# undef S_ISBLK +# undef S_ISCHR +# undef S_ISDIR +# undef S_ISDOOR +# undef S_ISFIFO +# undef S_ISLNK +# undef S_ISNAM +# undef S_ISMPB +# undef S_ISMPC +# undef S_ISNWK +# undef S_ISREG +# undef S_ISSOCK +# endif + + +# ifndef S_ISBLK +# ifdef S_IFBLK +# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +# else +# define S_ISBLK(m) 0 +# endif +# endif + +# ifndef S_ISCHR +# ifdef S_IFCHR +# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +# else +# define S_ISCHR(m) 0 +# endif +# endif + +# ifndef S_ISDIR +# ifdef S_IFDIR +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +# else +# define S_ISDIR(m) 0 +# endif +# endif + +# ifndef S_ISDOOR /* Solaris 2.5 and up */ +# ifdef S_IFDOOR +# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR) +# else +# define S_ISDOOR(m) 0 +# endif +# endif + +# ifndef S_ISFIFO +# ifdef S_IFIFO +# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +# else +# define S_ISFIFO(m) 0 +# endif +# endif + +# ifndef S_ISLNK +# ifdef S_IFLNK +# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +# else +# define S_ISLNK(m) 0 +# endif +# endif + +# ifndef S_ISMPB /* V7 */ +# ifdef S_IFMPB +# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) +# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) +# else +# define S_ISMPB(m) 0 +# define S_ISMPC(m) 0 +# endif +# endif + +# ifndef S_ISNAM /* Xenix */ +# ifdef S_IFNAM +# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) +# else +# define S_ISNAM(m) 0 +# endif +# endif + +# ifndef S_ISNWK /* HP/UX */ +# ifdef S_IFNWK +# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) +# else +# define S_ISNWK(m) 0 +# endif +# endif + +# ifndef S_ISREG +# ifdef S_IFREG +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +# else +# define S_ISREG(m) 0 +# endif +# endif + +# ifndef S_ISSOCK +# ifdef S_IFSOCK +# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +# else +# define S_ISSOCK(m) 0 +# endif +# endif + + +# ifndef S_TYPEISMQ +# define S_TYPEISMQ(p) 0 +# endif + +# ifndef S_TYPEISTMO +# define S_TYPEISTMO(p) 0 +# endif + + +# ifndef S_TYPEISSEM +# ifdef S_INSEM +# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM) +# else +# define S_TYPEISSEM(p) 0 +# endif +# endif + +# ifndef S_TYPEISSHM +# ifdef S_INSHD +# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD) +# else +# define S_TYPEISSHM(p) 0 +# endif +# endif + +/* contiguous */ +# ifndef S_ISCTG +# define S_ISCTG(p) 0 +# endif + +/* Cray DMF (data migration facility): off line, with data */ +# ifndef S_ISOFD +# define S_ISOFD(p) 0 +# endif + +/* Cray DMF (data migration facility): off line, with no data */ +# ifndef S_ISOFL +# define S_ISOFL(p) 0 +# endif + +/* If any of the following are undefined, + define them to their de facto standard values. */ +# if !S_ISUID +# define S_ISUID 04000 +# endif +# if !S_ISGID +# define S_ISGID 02000 +# endif + +/* S_ISVTX is a common extension to POSIX. */ +# ifndef S_ISVTX +# define S_ISVTX 01000 +# endif + +# if !S_IRUSR && S_IREAD +# define S_IRUSR S_IREAD +# endif +# if !S_IRUSR +# define S_IRUSR 00400 +# endif +# if !S_IRGRP +# define S_IRGRP (S_IRUSR >> 3) +# endif +# if !S_IROTH +# define S_IROTH (S_IRUSR >> 6) +# endif + +# if !S_IWUSR && S_IWRITE +# define S_IWUSR S_IWRITE +# endif +# if !S_IWUSR +# define S_IWUSR 00200 +# endif +# if !S_IWGRP +# define S_IWGRP (S_IWUSR >> 3) +# endif +# if !S_IWOTH +# define S_IWOTH (S_IWUSR >> 6) +# endif + +# if !S_IXUSR && S_IEXEC +# define S_IXUSR S_IEXEC +# endif +# if !S_IXUSR +# define S_IXUSR 00100 +# endif +# if !S_IXGRP +# define S_IXGRP (S_IXUSR >> 3) +# endif +# if !S_IXOTH +# define S_IXOTH (S_IXUSR >> 6) +# endif + +# if !S_IRWXU +# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) +# endif +# if !S_IRWXG +# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) +# endif +# if !S_IRWXO +# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) +# endif + +/* S_IXUGO is a common extension to POSIX. */ +# if !S_IXUGO +# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) +# endif + +# ifndef S_IRWXUGO +# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) +# endif + +/* All the mode bits that can be affected by chmod. */ +# define CHMOD_MODE_BITS \ + (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) + +#endif /* STAT_MACROS_H */ diff --git a/contrib/gnu-sort/lib/version-etc.c b/contrib/gnu-sort/lib/version-etc.c index 7523b08..fd71eff 100644 --- a/contrib/gnu-sort/lib/version-etc.c +++ b/contrib/gnu-sort/lib/version-etc.c @@ -46,7 +46,7 @@ version_etc_va (FILE *stream, const char *command_name, const char *package, const char *version, va_list authors) { - unsigned int n_authors; + size_t n_authors; /* Count the number of authors. */ { diff --git a/contrib/gnu-sort/lib/xalloc.h b/contrib/gnu-sort/lib/xalloc.h index 4b65858..d81f2a6 100644 --- a/contrib/gnu-sort/lib/xalloc.h +++ b/contrib/gnu-sort/lib/xalloc.h @@ -1,7 +1,7 @@ /* xalloc.h -- malloc with out-of-memory checking Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2003 Free Software Foundation, Inc. + 1999, 2000, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,12 @@ # include <stddef.h> + +# ifdef __cplusplus +extern "C" { +# endif + + # ifndef __attribute__ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ # define __attribute__(x) @@ -32,18 +38,9 @@ # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # endif -/* If this pointer is non-zero, run the specified function upon each - allocation failure. It is initialized to zero. */ -extern void (*xalloc_fail_func) (void); - -/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this - message is output. It is translated via gettext. - Its value is "memory exhausted". */ -extern char const xalloc_msg_memory_exhausted[]; - -/* This function is always triggered when memory is exhausted. It is - in charge of honoring the two previous items. It exits with status - exit_failure (defined in exitfail.h). This is the +/* This function is always triggered when memory is exhausted. + It must be defined by the application, either explicitly + or by using gnulib's xalloc-die module. This is the function to call when one wants the program to die because of a memory allocation failure. */ extern void xalloc_die (void) ATTRIBUTE_NORETURN; @@ -84,4 +81,10 @@ char *xstrdup (const char *str); # define XREALLOC(p, type, n) xnrealloc (p, n, sizeof (type)) # define XFREE(p) free (p) + +# ifdef __cplusplus +} +# endif + + #endif /* !XALLOC_H_ */ diff --git a/contrib/gnu-sort/lib/xmalloc.c b/contrib/gnu-sort/lib/xmalloc.c index 181006b..9b7a948 100644 --- a/contrib/gnu-sort/lib/xmalloc.c +++ b/contrib/gnu-sort/lib/xmalloc.c @@ -1,7 +1,7 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2003, - 1999, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, + 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,44 +26,10 @@ #include <stdlib.h> #include <string.h> -#include "gettext.h" -#define _(msgid) gettext (msgid) -#define N_(msgid) msgid - -#include "error.h" -#include "exitfail.h" - #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) #endif -#ifndef HAVE_MALLOC -"you must run the autoconf test for a GNU libc compatible malloc" -#endif - -#ifndef HAVE_REALLOC -"you must run the autoconf test for a GNU libc compatible realloc" -#endif - -/* If non NULL, call this function when memory is exhausted. */ -void (*xalloc_fail_func) (void) = 0; - -/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message - before exiting when memory is exhausted. Goes through gettext. */ -char const xalloc_msg_memory_exhausted[] = N_("memory exhausted"); - -void -xalloc_die (void) -{ - if (xalloc_fail_func) - (*xalloc_fail_func) (); - error (exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted)); - /* The `noreturn' cannot be given to error, since it may return if - its first argument is 0. To help compilers understand the - xalloc_die does terminate, call abort. */ - abort (); -} - /* Allocate an array of N objects, each with S bytes of memory, dynamically, with error checking. S must be nonzero. */ @@ -71,7 +37,7 @@ static inline void * xnmalloc_inline (size_t n, size_t s) { void *p; - if (xalloc_oversized (n, s) || ! (p = malloc (n * s))) + if (xalloc_oversized (n, s) || (! (p = malloc (n * s)) && n != 0)) xalloc_die (); return p; } @@ -96,7 +62,7 @@ xmalloc (size_t n) static inline void * xnrealloc_inline (void *p, size_t n, size_t s) { - if (xalloc_oversized (n, s) || ! (p = realloc (p, n * s))) + if (xalloc_oversized (n, s) || (! (p = realloc (p, n * s)) && n != 0)) xalloc_die (); return p; } @@ -239,7 +205,7 @@ xcalloc (size_t n, size_t s) void *p; /* Test for overflow, since some calloc implementations don't have proper overflow checks. */ - if (xalloc_oversized (n, s) || ! (p = calloc (n, s))) + if (xalloc_oversized (n, s) || (! (p = calloc (n, s)) && n != 0)) xalloc_die (); return p; } diff --git a/contrib/gnu-sort/lib/xmemcoll.c b/contrib/gnu-sort/lib/xmemcoll.c index 0e30aef..433d67f 100644 --- a/contrib/gnu-sort/lib/xmemcoll.c +++ b/contrib/gnu-sort/lib/xmemcoll.c @@ -1,5 +1,5 @@ /* Locale-specific memory comparison. - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,10 +22,6 @@ #endif #include <errno.h> -#ifndef errno -extern int errno; -#endif - #include <stdlib.h> #include "gettext.h" diff --git a/contrib/gnu-sort/lib/xstrtol.c b/contrib/gnu-sort/lib/xstrtol.c index d0aa0a9..906e4a1 100644 --- a/contrib/gnu-sort/lib/xstrtol.c +++ b/contrib/gnu-sort/lib/xstrtol.c @@ -1,6 +1,6 @@ /* A more useful interface to strtol. - Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003 Free + Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -37,15 +37,10 @@ #include <assert.h> #include <ctype.h> -#include <stdlib.h> -#include <string.h> - #include <errno.h> -#ifndef errno -extern int errno; -#endif - #include <limits.h> +#include <stdlib.h> +#include <string.h> /* The extra casts work around common compiler bugs. */ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) @@ -121,9 +116,10 @@ __xstrtol (const char *s, char **ptr, int strtol_base, if (! TYPE_SIGNED (__strtol_t)) { const char *q = s; - while (ISSPACE ((unsigned char) *q)) - ++q; - if (*q == '-') + unsigned char ch = *q; + while (ISSPACE (ch)) + ch = *++q; + if (ch == '-') return LONGINT_INVALID; } diff --git a/contrib/gnu-sort/lib/xstrtol.h b/contrib/gnu-sort/lib/xstrtol.h index 5765c88..0d6b984 100644 --- a/contrib/gnu-sort/lib/xstrtol.h +++ b/contrib/gnu-sort/lib/xstrtol.h @@ -22,13 +22,11 @@ # include "exitfail.h" -/* Get uintmax_t. */ # if HAVE_INTTYPES_H # include <inttypes.h> -# else -# if HAVE_STDINT_H -# include <stdint.h> -# endif +# endif +# if HAVE_STDINT_H +# include <stdint.h> # endif # ifndef _STRTOL_ERROR diff --git a/contrib/gnu-sort/lib/xstrtoumax.c b/contrib/gnu-sort/lib/xstrtoumax.c index a8858bf..8518ef0 100644 --- a/contrib/gnu-sort/lib/xstrtoumax.c +++ b/contrib/gnu-sort/lib/xstrtoumax.c @@ -1,5 +1,5 @@ /* xstrtoumax.c -- A more useful interface to strtoumax. - Copyright (C) 1999, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,11 +21,7 @@ # include <config.h> #endif -#if HAVE_INTTYPES_H -# include <inttypes.h> -#elif HAVE_STDINT_H -# include <stdint.h> -#endif +#include "xstrtol.h" #define __strtol strtoumax #define __strtol_t uintmax_t diff --git a/contrib/gnu-sort/src/sort.c b/contrib/gnu-sort/src/sort.c index b67582a..014beb7 100644 --- a/contrib/gnu-sort/src/sort.c +++ b/contrib/gnu-sort/src/sort.c @@ -19,7 +19,7 @@ The author may be reached (Email) at the address mike@gnu.ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. - Ørn E. Hansen added NLS support in 1997. */ + Ørn E. Hansen added NLS support in 1997. */ #include <config.h> @@ -34,6 +34,7 @@ #include "long-options.h" #include "physmem.h" #include "posixver.h" +#include "quote.h" #include "stdio-safer.h" #include "xmemcoll.h" #include "xstrtol.h" @@ -65,7 +66,6 @@ double strtod (); #endif #define UCHAR_LIM (UCHAR_MAX + 1) -#define UCHAR(c) ((unsigned char) (c)) #ifndef DEFAULT_TMPDIR # define DEFAULT_TMPDIR "/tmp" @@ -103,7 +103,7 @@ static bool hard_LC_TIME; #else # define decimal_point C_DECIMAL_POINT -# define IS_THOUSANDS_SEP(x) 0 +# define IS_THOUSANDS_SEP(x) false #endif @@ -148,8 +148,8 @@ struct keyfield size_t echar; /* Additional characters in field. */ bool const *ignore; /* Boolean array of characters to ignore. */ char const *translate; /* Translation applied to characters. */ - bool skipsblanks; /* Skip leading blanks at start. */ - bool skipeblanks; /* Skip trailing blanks at finish. */ + bool skipsblanks; /* Skip leading blanks when finding start. */ + bool skipeblanks; /* Skip leading blanks when finding end. */ bool numeric; /* Flag for numeric comparison. Handle strings of digits with optional decimal point, but no exponential notation. */ @@ -395,13 +395,14 @@ cleanup (void) unlink (node->name); } -/* Report MESSAGE for FILE, then clean up and exit. */ +/* Report MESSAGE for FILE, then clean up and exit. + If FILE is null, it represents standard output. */ static void die (char const *, char const *) ATTRIBUTE_NORETURN; static void die (char const *message, char const *file) { - error (0, errno, "%s: %s", message, file); + error (0, errno, "%s: %s", message, file ? file : _("standard output")); exit (SORT_FAILURE); } @@ -443,20 +444,22 @@ create_temp_file (FILE **pfp) return file; } +/* Return a stream for FILE, opened with mode HOW. A null FILE means + standard output; HOW should be "w". When opening for input, "-" + means standard input. To avoid confusion, do not return file + descriptors 0, 1, or 2. */ + static FILE * xfopen (const char *file, const char *how) { FILE *fp; - if (STREQ (file, "-")) + if (!file) + fp = stdout; + else if (STREQ (file, "-") && *how == 'r') { - if (*how == 'r') - { - have_read_stdin = true; - fp = stdin; - } - else - fp = stdout; + have_read_stdin = true; + fp = stdin; } else { @@ -565,7 +568,7 @@ inittables (void) monthtab[i].val = i + 1; for (j = 0; j < s_len; j++) - name[j] = fold_toupper[UCHAR (s[j])]; + name[j] = fold_toupper[to_uchar (s[j])]; name[j] = '\0'; } qsort ((void *) monthtab, MONTHS_PER_YEAR, @@ -708,7 +711,7 @@ sort_buffer_size (FILE *const *fps, int nfps, size_t worst_case; if ((i < nfps ? fstat (fileno (fps[i]), &st) - : strcmp (files[i], "-") == 0 ? fstat (STDIN_FILENO, &st) + : STREQ (files[i], "-") ? fstat (STDIN_FILENO, &st) : stat (files[i], &st)) != 0) die (_("stat failed"), files[i]); @@ -805,14 +808,14 @@ begfield (const struct line *line, const struct keyfield *key) else while (ptr < lim && sword--) { - while (ptr < lim && blanks[UCHAR (*ptr)]) + while (ptr < lim && blanks[to_uchar (*ptr)]) ++ptr; - while (ptr < lim && !blanks[UCHAR (*ptr)]) + while (ptr < lim && !blanks[to_uchar (*ptr)]) ++ptr; } if (key->skipsblanks) - while (ptr < lim && blanks[UCHAR (*ptr)]) + while (ptr < lim && blanks[to_uchar (*ptr)]) ++ptr; /* Advance PTR by SCHAR (if possible), but no further than LIM. */ @@ -853,9 +856,9 @@ limfield (const struct line *line, const struct keyfield *key) else while (ptr < lim && eword--) { - while (ptr < lim && blanks[UCHAR (*ptr)]) + while (ptr < lim && blanks[to_uchar (*ptr)]) ++ptr; - while (ptr < lim && !blanks[UCHAR (*ptr)]) + while (ptr < lim && !blanks[to_uchar (*ptr)]) ++ptr; } @@ -902,18 +905,19 @@ limfield (const struct line *line, const struct keyfield *key) { char *newlim; newlim = ptr; - while (newlim < lim && blanks[UCHAR (*newlim)]) + while (newlim < lim && blanks[to_uchar (*newlim)]) ++newlim; - while (newlim < lim && !blanks[UCHAR (*newlim)]) + while (newlim < lim && !blanks[to_uchar (*newlim)]) ++newlim; lim = newlim; } #endif - /* If we're skipping leading blanks, don't start counting characters - until after skipping past any leading blanks. */ - if (key->skipsblanks) - while (ptr < lim && blanks[UCHAR (*ptr)]) + /* If we're ignoring leading blanks when computing the End + of the field, don't start counting bytes until after skipping + past any leading blanks. */ + if (key->skipeblanks) + while (ptr < lim && blanks[to_uchar (*ptr)]) ++ptr; /* Advance PTR by ECHAR (if possible), but no further than LIM. */ @@ -926,17 +930,6 @@ limfield (const struct line *line, const struct keyfield *key) return ptr; } -/* Return the number of trailing blanks in FIELD, with LEN bytes. */ - -static size_t -trailing_blanks (char const *field, size_t len) -{ - size_t i; - for (i = len; 0 < i && blanks[UCHAR (field[i - 1])]; i--) - continue; - return len - i; -} - /* Fill BUF reading from FP, moving buf->left bytes from the end of buf->buf to the beginning first. If EOF is reached and the file wasn't terminated by a newline, supply one. Set up BUF's line @@ -1019,15 +1012,10 @@ fillbuf (struct buffer *buf, register FILE *fp, char const *file) else { if (key->skipsblanks) - while (blanks[UCHAR (*line_start)]) + while (blanks[to_uchar (*line_start)]) line_start++; line->keybeg = line_start; } - if (key->skipeblanks) - { - size_t keylen = line->keylim - line->keybeg; - line->keylim -= trailing_blanks (line->keybeg, keylen); - } } line_start = ptr; @@ -1125,15 +1113,18 @@ fraccompare (register const char *a, register const char *b) static int numcompare (register const char *a, register const char *b) { - register int tmpa, tmpb, tmp; - register size_t log_a, log_b; + char tmpa; + char tmpb; + int tmp; + size_t log_a; + size_t log_b; tmpa = *a; tmpb = *b; - while (blanks[UCHAR (tmpa)]) + while (blanks[to_uchar (tmpa)]) tmpa = *++a; - while (blanks[UCHAR (tmpb)]) + while (blanks[to_uchar (tmpb)]) tmpb = *++b; if (tmpa == NEGATION_SIGN) @@ -1300,7 +1291,7 @@ getmonth (const char *s, size_t len) register size_t i; register int lo = 0, hi = MONTHS_PER_YEAR, result; - while (len > 0 && blanks[UCHAR (*s)]) + while (len > 0 && blanks[to_uchar (*s)]) { ++s; --len; @@ -1311,8 +1302,7 @@ getmonth (const char *s, size_t len) month = alloca (len + 1); for (i = 0; i < len; ++i) - month[i] = fold_toupper[UCHAR (s[i])]; - len -= trailing_blanks (month, len); + month[i] = fold_toupper[to_uchar (s[i])]; month[len] = '\0'; do @@ -1358,12 +1348,6 @@ keycompare (const struct line *a, const struct line *b) size_t lena = lima <= texta ? 0 : lima - texta; size_t lenb = limb <= textb ? 0 : limb - textb; - if (key->skipeblanks) - { - lena -= trailing_blanks (texta, lena); - lenb -= trailing_blanks (textb, lenb); - } - /* Actually compare the fields. */ if (key->numeric | key->general_numeric) { @@ -1392,17 +1376,17 @@ keycompare (const struct line *a, const struct line *b) if (i < lena) { copy_a[new_len_a] = (translate - ? translate[UCHAR (texta[i])] + ? translate[to_uchar (texta[i])] : texta[i]); - if (!ignore || !ignore[UCHAR (texta[i])]) + if (!ignore || !ignore[to_uchar (texta[i])]) ++new_len_a; } if (i < lenb) { copy_b[new_len_b] = (translate - ? translate[UCHAR (textb[i])] + ? translate[to_uchar (textb[i])] : textb [i]); - if (!ignore || !ignore[UCHAR (textb[i])]) + if (!ignore || !ignore[to_uchar (textb[i])]) ++new_len_b; } } @@ -1423,13 +1407,13 @@ keycompare (const struct line *a, const struct line *b) { \ for (;;) \ { \ - while (texta < lima && ignore[UCHAR (*texta)]) \ + while (texta < lima && ignore[to_uchar (*texta)]) \ ++texta; \ - while (textb < limb && ignore[UCHAR (*textb)]) \ + while (textb < limb && ignore[to_uchar (*textb)]) \ ++textb; \ if (! (texta < lima && textb < limb)) \ break; \ - diff = UCHAR (A) - UCHAR (B); \ + diff = to_uchar (A) - to_uchar (B); \ if (diff) \ goto not_equal; \ ++texta; \ @@ -1441,8 +1425,8 @@ keycompare (const struct line *a, const struct line *b) while (0) if (translate) - CMP_WITH_IGNORE (translate[UCHAR (*texta)], - translate[UCHAR (*textb)]); + CMP_WITH_IGNORE (translate[to_uchar (*texta)], + translate[to_uchar (*textb)]); else CMP_WITH_IGNORE (*texta, *textb); } @@ -1456,8 +1440,8 @@ keycompare (const struct line *a, const struct line *b) { while (texta < lima && textb < limb) { - diff = (UCHAR (translate[UCHAR (*texta++)]) - - UCHAR (translate[UCHAR (*textb++)])); + diff = (to_uchar (translate[to_uchar (*texta++)]) + - to_uchar (translate[to_uchar (*textb++)])); if (diff) goto not_equal; } @@ -1491,9 +1475,9 @@ keycompare (const struct line *a, const struct line *b) texta = a->text, textb = b->text; if (key->skipsblanks) { - while (texta < lima && blanks[UCHAR (*texta)]) + while (texta < lima && blanks[to_uchar (*texta)]) ++texta; - while (textb < limb && blanks[UCHAR (*textb)]) + while (textb < limb && blanks[to_uchar (*textb)]) ++textb; } } @@ -1630,8 +1614,9 @@ check (char const *file_name) /* Merge lines from FILES onto OFP. NFILES cannot be greater than NMERGE. Close input and output files before returning. - OUTPUT_FILE gives the name of the output file; if OFP is NULL, the - output file has not been opened yet. */ + OUTPUT_FILE gives the name of the output file. If it is NULL, + the output file is standard output. If OFP is NULL, the output + file has not been opened yet (or written to, if standard output). */ static void mergefps (char **files, register int nfiles, @@ -1900,9 +1885,17 @@ sortlines_temp (struct line *lines, size_t nlines, struct line *temp) } /* Return the index of the first of NFILES FILES that is the same file - as OUTFILE. If none can be the same, return NFILES. Consider an - input pipe to be the same as OUTFILE, since the pipe might be the - output of a command like "cat OUTFILE". */ + as OUTFILE. If none can be the same, return NFILES. + + This test ensures that an otherwise-erroneous use like + "sort -m -o FILE ... FILE ..." copies FILE before writing to it. + It's not clear that POSIX requires this nicety. + Detect common error cases, but don't try to catch obscure cases like + "cat ... FILE ... | sort -m -o FILE" + where traditional "sort" doesn't copy the input and where + people should know that they're getting into trouble anyway. + Catching these obscure cases would slow down performance in + common cases. */ static int first_same_file (char * const *files, int nfiles, char const *outfile) @@ -1915,15 +1908,15 @@ first_same_file (char * const *files, int nfiles, char const *outfile) { bool standard_input = STREQ (files[i], "-"); - if (STREQ (outfile, files[i]) && ! standard_input) + if (outfile && STREQ (outfile, files[i]) && ! standard_input) return i; if (! got_outstat) { got_outstat = true; - if ((STREQ (outfile, "-") - ? fstat (STDOUT_FILENO, &outstat) - : stat (outfile, &outstat)) + if ((outfile + ? stat (outfile, &outstat) + : fstat (STDOUT_FILENO, &outstat)) != 0) return nfiles; } @@ -1932,7 +1925,7 @@ first_same_file (char * const *files, int nfiles, char const *outfile) ? fstat (STDIN_FILENO, &instat) : stat (files[i], &instat)) == 0) - && (S_ISFIFO (instat.st_mode) || SAME_INODE (instat, outstat))) + && SAME_INODE (instat, outstat)) return i; } @@ -1941,7 +1934,7 @@ first_same_file (char * const *files, int nfiles, char const *outfile) /* Merge NFILES FILES onto OUTPUT_FILE. However, merge at most MAX_MERGE input files directly onto OUTPUT_FILE. MAX_MERGE cannot - exceed NMERGE. */ + exceed NMERGE. A null OUTPUT_FILE stands for standard output. */ static void merge (char **files, int nfiles, int max_merge, char const *output_file) @@ -2133,19 +2126,7 @@ sighandler (int sig) cleanup (); -#ifdef SA_NOCLDSTOP - { - struct sigaction sigact; - - sigact.sa_handler = SIG_DFL; - sigemptyset (&sigact.sa_mask); - sigact.sa_flags = 0; - sigaction (sig, &sigact, NULL); - } -#else signal (sig, SIG_DFL); -#endif - raise (sig); } @@ -2224,12 +2205,7 @@ main (int argc, char **argv) ? COMMON_SHORT_OPTIONS "y::" : COMMON_SHORT_OPTIONS "y:"); char *minus = "-", **files; - char const *outfile = minus; - static int const sigs[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM }; - unsigned int nsigs = sizeof sigs / sizeof *sigs; -#ifdef SA_NOCLDSTOP - struct sigaction oldact, newact; -#endif + char const *outfile = NULL; initialize_main (&argc, &argv); program_name = argv[0]; @@ -2269,32 +2245,34 @@ main (int argc, char **argv) have_read_stdin = false; inittables (); -#ifdef SA_NOCLDSTOP { - unsigned int i; + int i; + static int const sig[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM }; + enum { nsigs = sizeof sig / sizeof sig[0] }; + +#ifdef SA_NOCLDSTOP + struct sigaction act; + sigemptyset (&caught_signals); for (i = 0; i < nsigs; i++) - sigaddset (&caught_signals, sigs[i]); - newact.sa_handler = sighandler; - newact.sa_mask = caught_signals; - newact.sa_flags = 0; - } -#endif + { + sigaction (sig[i], NULL, &act); + if (act.sa_handler != SIG_IGN) + sigaddset (&caught_signals, sig[i]); + } + + act.sa_handler = sighandler; + act.sa_mask = caught_signals; + act.sa_flags = 0; - { - unsigned int i; for (i = 0; i < nsigs; i++) - { - int sig = sigs[i]; -#ifdef SA_NOCLDSTOP - sigaction (sig, NULL, &oldact); - if (oldact.sa_handler != SIG_IGN) - sigaction (sig, &newact, NULL); + if (sigismember (&caught_signals, sig[i])) + sigaction (sig[i], &act, NULL); #else - if (signal (sig, SIG_IGN) != SIG_IGN) - signal (sig, sighandler); + for (i = 0; i < nsigs; i++) + if (signal (sig[i], SIG_IGN) != SIG_IGN) + signal (sig[i], sighandler); #endif - } } gkey.sword = gkey.eword = SIZE_MAX; @@ -2447,7 +2425,7 @@ main (int argc, char **argv) break; case 'o': - if (outfile != minus && strcmp (outfile, optarg) != 0) + if (outfile && !STREQ (outfile, optarg)) error (SORT_FAILURE, 0, _("multiple output files specified")); outfile = optarg; break; @@ -2462,12 +2440,12 @@ main (int argc, char **argv) case 't': { - int newtab = optarg[0]; + char newtab = optarg[0]; if (! newtab) error (SORT_FAILURE, 0, _("empty tab")); if (optarg[1]) { - if (strcmp (optarg, "\\0") == 0) + if (STREQ (optarg, "\\0")) newtab = '\0'; else { @@ -2550,8 +2528,11 @@ main (int argc, char **argv) if (checkonly) { if (nfiles > 1) - error (SORT_FAILURE, 0, _("extra operand `%s' not allowed with -c"), - files[1]); + { + error (0, 0, _("extra operand %s not allowed with -c"), + quote (files[1])); + usage (SORT_FAILURE); + } /* POSIX requires that sort return 1 IFF invoked with -c and the input is not properly sorted. */ diff --git a/contrib/gnu-sort/src/system.h b/contrib/gnu-sort/src/system.h index 6154843..3497969 100644 --- a/contrib/gnu-sort/src/system.h +++ b/contrib/gnu-sort/src/system.h @@ -92,6 +92,10 @@ you must include <sys/types.h> before including this file #endif #undef HAVE_MAJOR +#if ! defined makedev && defined mkdev +# define makedev(maj, min) mkdev (maj, min) +#endif + #if HAVE_UTIME_H # include <utime.h> #endif @@ -115,17 +119,11 @@ void *memrchr (const void *, int, size_t); #endif #include <errno.h> -#ifndef errno -extern int errno; -#endif /* Some systems don't define the following symbols. */ #ifndef ENOSYS # define ENOSYS (-1) #endif -#ifndef ENOTSUP -# define ENOTSUP (-1) -#endif #ifndef EISDIR # define EISDIR (-1) #endif @@ -193,6 +191,14 @@ initialize_exit_failure (int status) # define O_TEXT _O_TEXT #endif +#if !defined O_DIRECT +# define O_DIRECT 0 +#endif + +#if !defined O_DSYNC +# define O_DSYNC 0 +#endif + #if !defined O_NDELAY # define O_NDELAY 0 #endif @@ -205,6 +211,18 @@ initialize_exit_failure (int status) # define O_NOCTTY 0 #endif +#if !defined O_NOFOLLOW +# define O_NOFOLLOW 0 +#endif + +#if !defined O_RSYNC +# define O_RSYNC 0 +#endif + +#if !defined O_SYNC +# define O_SYNC 0 +#endif + #ifdef __BEOS__ /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */ # undef O_BINARY @@ -231,7 +249,9 @@ initialize_exit_failure (int status) # define SET_MODE(_f, _m) (void)0 # define SET_BINARY(f) (void)0 # define SET_BINARY2(f1,f2) (void)0 -# define O_BINARY 0 +# ifndef O_BINARY +# define O_BINARY 0 +# endif # define O_TEXT 0 #endif /* O_BINARY */ @@ -298,7 +318,7 @@ initialize_exit_failure (int status) ? (statbuf).st_blksize : DEV_BSIZE) # if defined hpux || defined __hpux__ || defined __hpux /* HP-UX counts st_blocks in 1024-byte units. - This loses when mixing HP-UX and BSD filesystems with NFS. */ + This loses when mixing HP-UX and BSD file systems with NFS. */ # define ST_NBLOCKSIZE 1024 # else /* !hpux */ # if defined _AIX && defined _I386 @@ -329,213 +349,7 @@ initialize_exit_failure (int status) # define initialize_main(ac, av) #endif -#ifndef S_IFMT -# define S_IFMT 0170000 -#endif - -#if STAT_MACROS_BROKEN -# undef S_ISBLK -# undef S_ISCHR -# undef S_ISDIR -# undef S_ISDOOR -# undef S_ISFIFO -# undef S_ISLNK -# undef S_ISNAM -# undef S_ISMPB -# undef S_ISMPC -# undef S_ISNWK -# undef S_ISREG -# undef S_ISSOCK -#endif - - -#ifndef S_ISBLK -# ifdef S_IFBLK -# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -# else -# define S_ISBLK(m) 0 -# endif -#endif - -#ifndef S_ISCHR -# ifdef S_IFCHR -# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -# else -# define S_ISCHR(m) 0 -# endif -#endif - -#ifndef S_ISDIR -# ifdef S_IFDIR -# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -# else -# define S_ISDIR(m) 0 -# endif -#endif - -#ifndef S_ISDOOR /* Solaris 2.5 and up */ -# ifdef S_IFDOOR -# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR) -# else -# define S_ISDOOR(m) 0 -# endif -#endif - -#ifndef S_ISFIFO -# ifdef S_IFIFO -# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -# else -# define S_ISFIFO(m) 0 -# endif -#endif - -#ifndef S_ISLNK -# ifdef S_IFLNK -# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -# else -# define S_ISLNK(m) 0 -# endif -#endif - -#ifndef S_ISMPB /* V7 */ -# ifdef S_IFMPB -# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) -# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) -# else -# define S_ISMPB(m) 0 -# define S_ISMPC(m) 0 -# endif -#endif - -#ifndef S_ISNAM /* Xenix */ -# ifdef S_IFNAM -# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) -# else -# define S_ISNAM(m) 0 -# endif -#endif - -#ifndef S_ISNWK /* HP/UX */ -# ifdef S_IFNWK -# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) -# else -# define S_ISNWK(m) 0 -# endif -#endif - -#ifndef S_ISREG -# ifdef S_IFREG -# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -# else -# define S_ISREG(m) 0 -# endif -#endif - -#ifndef S_ISSOCK -# ifdef S_IFSOCK -# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) -# else -# define S_ISSOCK(m) 0 -# endif -#endif - - -#ifndef S_TYPEISSEM -# ifdef S_INSEM -# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM) -# else -# define S_TYPEISSEM(p) 0 -# endif -#endif - -#ifndef S_TYPEISSHM -# ifdef S_INSHD -# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD) -# else -# define S_TYPEISSHM(p) 0 -# endif -#endif - -#ifndef S_TYPEISMQ -# define S_TYPEISMQ(p) 0 -#endif - - -/* If any of the following are undefined, - define them to their de facto standard values. */ -#if !S_ISUID -# define S_ISUID 04000 -#endif -#if !S_ISGID -# define S_ISGID 02000 -#endif - -/* S_ISVTX is a common extension to POSIX. */ -#ifndef S_ISVTX -# define S_ISVTX 01000 -#endif - -#if !S_IRUSR && S_IREAD -# define S_IRUSR S_IREAD -#endif -#if !S_IRUSR -# define S_IRUSR 00400 -#endif -#if !S_IRGRP -# define S_IRGRP (S_IRUSR >> 3) -#endif -#if !S_IROTH -# define S_IROTH (S_IRUSR >> 6) -#endif - -#if !S_IWUSR && S_IWRITE -# define S_IWUSR S_IWRITE -#endif -#if !S_IWUSR -# define S_IWUSR 00200 -#endif -#if !S_IWGRP -# define S_IWGRP (S_IWUSR >> 3) -#endif -#if !S_IWOTH -# define S_IWOTH (S_IWUSR >> 6) -#endif - -#if !S_IXUSR && S_IEXEC -# define S_IXUSR S_IEXEC -#endif -#if !S_IXUSR -# define S_IXUSR 00100 -#endif -#if !S_IXGRP -# define S_IXGRP (S_IXUSR >> 3) -#endif -#if !S_IXOTH -# define S_IXOTH (S_IXUSR >> 6) -#endif - -#if !S_IRWXU -# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) -#endif -#if !S_IRWXG -# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) -#endif -#if !S_IRWXO -# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) -#endif - -/* S_IXUGO is a common extension to POSIX. */ -#if !S_IXUGO -# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) -#endif - -#ifndef S_IRWXUGO -# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) -#endif - -/* All the mode bits that can be affected by chmod. */ -#define CHMOD_MODE_BITS \ - (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) +#include "stat-macros.h" #include "timespec.h" @@ -550,29 +364,35 @@ initialize_exit_failure (int status) # include <sys/exceptn.h> #endif +#if HAVE_INTTYPES_H +# include <inttypes.h> +#endif #if HAVE_STDINT_H # include <stdint.h> #endif -#if HAVE_INTTYPES_H -# include <inttypes.h> /* for the definition of UINTMAX_MAX */ +#if ULONG_MAX < ULLONG_MAX +# define LONGEST_MODIFIER "ll" +#else +# define LONGEST_MODIFIER "l" #endif - -#if !defined PRIdMAX || PRI_MACROS_BROKEN +#if PRI_MACROS_BROKEN # undef PRIdMAX -# define PRIdMAX (sizeof (uintmax_t) == sizeof (long) ? "ld" : "lld") -#endif -#if !defined PRIoMAX || PRI_MACROS_BROKEN # undef PRIoMAX -# define PRIoMAX (sizeof (uintmax_t) == sizeof (long) ? "lo" : "llo") -#endif -#if !defined PRIuMAX || PRI_MACROS_BROKEN # undef PRIuMAX -# define PRIuMAX (sizeof (uintmax_t) == sizeof (long) ? "lu" : "llu") -#endif -#if !defined PRIxMAX || PRI_MACROS_BROKEN # undef PRIxMAX -# define PRIxMAX (sizeof (uintmax_t) == sizeof (long) ? "lx" : "llx") +#endif +#ifndef PRIdMAX +# define PRIdMAX LONGEST_MODIFIER "d" +#endif +#ifndef PRIoMAX +# define PRIoMAX LONGEST_MODIFIER "o" +#endif +#ifndef PRIuMAX +# define PRIuMAX LONGEST_MODIFIER "u" +#endif +#ifndef PRIxMAX +# define PRIxMAX LONGEST_MODIFIER "x" #endif #include <ctype.h> @@ -642,7 +462,12 @@ initialize_exit_failure (int status) POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless it's important to use the locale's definition of `digit' even when the host does not conform to POSIX. */ -#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9) +#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) + +/* Convert a possibly-signed character to an unsigned character. This is + a bit safer than casting to unsigned char, since it catches some type + errors that the cast doesn't. */ +static inline unsigned char to_uchar (char ch) { return ch; } /* Take care of NLS matters. */ @@ -754,6 +579,18 @@ uid_t getuid (); (Basename[0] == '.' && (Basename[1] == '\0' \ || (Basename[1] == '.' && Basename[2] == '\0'))) +/* A wrapper for readdir so that callers don't see entries for `.' or `..'. */ +static inline struct dirent const * +readdir_ignoring_dot_and_dotdot (DIR *dirp) +{ + while (1) + { + struct dirent const *dp = readdir (dirp); + if (dp == NULL || ! DOT_OR_DOTDOT (dp->d_name)) + return dp; + } +} + #if SETVBUF_REVERSED # define SETVBUF(Stream, Buffer, Type, Size) \ setvbuf (Stream, Type, Buffer, Size) @@ -793,7 +630,7 @@ enum #define case_GETOPT_VERSION_CHAR(Program_name, Authors) \ case GETOPT_VERSION_CHAR: \ - version_etc (stdout, Program_name, PACKAGE, VERSION, Authors, \ + version_etc (stdout, Program_name, GNU_PACKAGE, VERSION, Authors, \ (char *) NULL); \ exit (EXIT_SUCCESS); \ break; @@ -806,10 +643,6 @@ enum # define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif -#ifndef CHAR_BIT -# define CHAR_BIT 8 -#endif - /* The extra casts work around common compiler bugs. */ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) /* The outer cast is needed to work around a bug in Cray C 5.0.3.0. @@ -859,16 +692,24 @@ enum # define INT_MIN TYPE_MINIMUM (int) #endif +#ifndef INTMAX_MAX +# define INTMAX_MAX TYPE_MAXIMUM (intmax_t) +#endif + +#ifndef INTMAX_MIN +# define INTMAX_MIN TYPE_MINIMUM (intmax_t) +#endif + #ifndef UINT_MAX # define UINT_MAX TYPE_MAXIMUM (unsigned int) #endif #ifndef LONG_MAX -# define LONG_MAX TYPE_MAXIMUM (long) +# define LONG_MAX TYPE_MAXIMUM (long int) #endif #ifndef ULONG_MAX -# define ULONG_MAX TYPE_MAXIMUM (unsigned long) +# define ULONG_MAX TYPE_MAXIMUM (unsigned long int) #endif #ifndef SIZE_MAX @@ -944,7 +785,47 @@ enum #endif #if ! HAVE_FSEEKO && ! defined fseeko -# define fseeko(s, o, w) ((o) == (long) (o) \ +# define fseeko(s, o, w) ((o) == (long int) (o) \ ? fseek (s, o, w) \ : (errno = EOVERFLOW, -1)) #endif + +/* Compute the greatest common divisor of U and V using Euclid's + algorithm. U and V must be nonzero. */ + +static inline size_t +gcd (size_t u, size_t v) +{ + do + { + size_t t = u % v; + u = v; + v = t; + } + while (v); + + return u; +} + +/* Compute the least common multiple of U and V. U and V must be + nonzero. There is no overflow checking, so callers should not + specify outlandish sizes. */ + +static inline size_t +lcm (size_t u, size_t v) +{ + return u * (v / gcd (u, v)); +} + +/* Return PTR, aligned upward to the next multiple of ALIGNMENT. + ALIGNMENT must be nonzero. The caller must arrange for ((char *) + PTR) through ((char *) PTR + ALIGNMENT - 1) to be addressable + locations. */ + +static inline void * +ptr_align (void *ptr, size_t alignment) +{ + char *p0 = ptr; + char *p1 = p0 + alignment - 1; + return p1 - (size_t) p1 % alignment; +} |