summaryrefslogtreecommitdiff
path: root/src/ls.c
AgeCommit message (Collapse)Author
2004-11-19(usage): Clarified description of --no-group (-G),Jim Meyering
--human-readable (-h), --inode (-i), --size (-s), --time, and --time-style.
2004-11-19(usage): Clarify description of --author.Jim Meyering
Tweak indentation so that help2man creates better nroff.
2004-10-05(ignore_mode): Renamed from ignore, to avoid shadowingPaul Eggert
problems. All uses changed.
2004-10-05remove trailing blanks.Jim Meyering
2004-09-26Add "ls --hide".Paul Eggert
(file_ignored): Renamed from file_interesting, with inverted return value. Accept the file name, not a struct dirent *. All uses changed. Avoid the expense of calling fnmatch if the file is ignorable due to leading '.'. (all_files, really_all_files): Removed; replaced by: (ignore): New variable. All uses changed. (IGNORE_DEFAULT, IGNORE_DOT_AND_DOTDOT, IGNORE_MINIMAL, HIDE_OPTION): New constants. (hide_patterns): New variable. (long_options, decode_switches, file_ignored, usage): Add support for --hide. (patterns_match): New function. (usage): Replace "hide" with "ignore" in explanation, to avoid confusion.
2004-09-26Remove unused variable.Paul Eggert
2004-09-26(gobble_file, print_long_format): Don't assume thatPaul Eggert
human-readable output has a byte count equal to its column width; this isn't always true in locales where the radix character is not '.' or ','. (format_user_or_group): Revamp code to match the above fix; this avoids the (very faint) possibility of integer overflow.
2004-09-22(decode_switches): Don't compare a short valuePaul Eggert
to SIZE_MAX: GCC sometimes complains.
2004-09-21Remove unused "case 0".Paul Eggert
2004-08-03(struct fileinfo, file_interesting,Paul Eggert
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.
2004-06-22Fix bug: GNU 'ls' didn't count columns correctly if user or groupJim Meyering
names contained multibyte characters where the column count differed from the byte count. This patch also corrects some comments. (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-15(decode_switches): Pay attention to TABSIZE even if POSIXLY_CORRECTJim Meyering
is set. POSIX reserves upper-case environment variables to the implementation, so it's OK for ls to depend on TABSIZE.
2004-06-01(get_link_name): Update use of xreadlink.Jim Meyering
2004-04-24More signal-handling cleanup for ls.c. Do not allow signals toJim Meyering
happen between arbitrary output bytes, as the restore-default-color sequence can bollix up multibyte chars or color-change sequences in the ordinary output. Instead, process signals only between printing a file name and changing the color back to non_filename_text color. That way, if the signal handler changes the color (to the default), 'ls' will change it back when 'ls' continues (after being suspended). Also, do not bother with signal-handling unless stdout is a controlling terminal; this lets stdio buffer better when "ls --color" is piped or sent to a file. (sigprocmask, sigset_t) [!defined SA_NOCLDSTOP]: New macros. Do not include "full-write.h"; no longer needed. (tcgetpgrp) [! HAVE_TCGETPGRP]: New macro. (put_indicator_direct): Remove. All callers changed to use put_indicator. (caught_signals, interrupt_signal, stop_signal_count): New vars. (restore_default_color): Don't bother checking for put_indicator failure. (sighandler): Don't handle SIGTSTP; that's another handler now. Simply set interrupt_signal to the signal, then exit. (stophandler, process_signals): New functions. (main): Don't output any color changes until _after_ the signal handlers are set up. This fixes a race condition where 'ls' could be interrupted while initializing colors, and leaving the terminal in an undesirable state. Don't mess with signal-handling if standard output is not a controlling terminal. When exiting, restore the default color, then restore the default signal handling, then act on any signals that weren't acted on yet. Do not print //DIRED// etc. in colors; this avoids the need to catch signals when printing them. (print_name_with_quoting): Process signals just before switching color back to non_filename_text.
2004-04-23Avoid segfault on systems for which SIZE_MAX != (size_t) -1.Jim Meyering
(quote_name): Use SIZE_MAX, not -1, in calls of quotearg_buffer. Patch by Mikulas Patocka.
2004-04-21 - ls could incorrectly restore color if multiple signalsJim Meyering
arrived nearly simultaneously. (main): Rewrite signal-catching code to make it similar to other coreutils programs. When processing signals, block all signals that we catch, but do not block signals that we don't catch. Avoid problems with unsigned int warnings. (sighandler) [defined SA_NOCLDSTOP]: Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent. (sighandler) [!defined SA_NOCLDSTOP]: Reset signal handler to self, not to SIG_IGN, since SIGTSTP can be received more than once. (main): Use SA_RESTART, as that is simpler than checking for EINTR failures all over the place.
2004-02-02(TIMESPEC_NS): Remove definition.Jim Meyering
2004-01-21(usage): Use EXIT_SUCCESS, not 0, for clarity.Jim Meyering
(main): Don't assume EXIT_FAILURE == 1, as POSIX doesn't require it.
2003-12-24(length_of_file_names_and_frills):Jim Meyering
Remove forward decl; not needed. (print_file_name_and_frills, length_of_file_name_and_frills): With -m, don't output spaces before inum or size. (print_with_commas): Don't output space just before newline.
2003-12-18(format_user): Increment dired_pos via two statements,Jim Meyering
`dired_pos += width; dired_pos++;' rather than one, `dired_pos += width + 1;' since the latter could conceivably overflow. (format_group): Likewise.
2003-12-08(INODE_DIGITS, LOGIN_NAME_MAX, ID_LENGTH_MAX): Remove.Jim Meyering
(format_user_width, format_group_width, unsigned_file_size, format_group): New functions. (block_size_width): Renamed from block_size_size. (inode_number_width, nlink_width, owner_width, group_width, author_width, major_device_number_width, minor_device_number_width, file_size_width): New vars. (clear_files): Initialize them. (gobble_file): Set them. Don't ceiling block_size_width to 7. (print_long_file): Use them. (gobble_file): Use a new local variable 'f' to make the code smaller and more consistent with other functions. (format_user): Output to stdout, not to a buffer, so that we don't have to worry about buffer overrun. Update dired_pos. (print_long_file): Don't put owner, group, author into buffer; just print them directly. Don't assume link counts and major and minor numbers fit into unsigned long int. From Paul Eggert.
2003-11-12(extract_dirs_from_files): Avoid useless copy operations.Jim Meyering
This avoids a warning valgrind about memcpy with overlapping source and destination.
2003-10-25(dev_ino_hash): Adjust to reflectJim Meyering
type changes (unsigned int -> size_t) in hash.c.
2003-10-18Most .c files (AUTHORS): Revert the WRITTEN_BY/AUTHORS changeJim Meyering
of 2003-09-19. Now, AUTHORS is a comma-separated list of strings. Update the call to parse_long_options so that `AUTHORS, NULL' are the last parameters. * src/true.c (main): Append NULL to version_etc argument list. * src/sys2.h (case_GETOPT_VERSION_CHAR): Likewise.
2003-10-14(decode_switches) [TIOCGWINSZ]: Comment out theJim Meyering
warning-inducing test, ws.ws_col <= SIZE_MAX, since it was always true on Linux.
2003-10-14Fix to avoid a denial-of-service attack if the display width isJim Meyering
enormous. Also, clean up the code a bit by removing duplicate code. (init_column_info): Remove forward decl; no longer needed. (calculate_columns): New function, that contains code that used to be common to print_many_per_line and print_horizontal. (print_many_per_line, print_horizontal): Use it. (decode_switches): Set max_idx here, not in calculate_columns. (print_current_files): Don't call init_column_info; calculate_columns now does that. (init_column_info): Don't allocate a lot more space than is needed to represent the current set of files. Allocate all the new size_t cells in one call to xnmalloc, rather than a row at a time.
2003-10-13(init_column_info): Add another FIXME comment.Jim Meyering
2003-10-13(struct bin_str.len, length_of_file_name_and_frills, indent,Jim Meyering
nfiles, files_index, tabsize, line_length, struct column_info.line_len, struct column_info.col_arr[0], max_idx): Now size_t, not int. (get_funky_string): Return bool indicating success, instead of a negative count to indicate failure. Store number of columns through new parameter OUTPUT_COUNT; that way, they can never go negative. Change equals_end from int to bool. All uses changed. (struct column_info.valid_len): Now bool, not int. All uses changed. (dired_dump_obstack, get_funky_string, clear_files, extract_dirs_from_files, print_current_files, print_many_per_line, print_horizontal, init_column_info, put_indicator, length_of_file_name_and_frills, print_with_commas): Use size_t, not int, for local variables that count sizes. (decode_switches): Decode sizes using xstrtoul, not xstrtol. Check for TIOCGWINSZ returing negative values (or values greater than SIZE_MAX!). (visit_dir, main, parse_ls_color, queue_directory, add_ignore_pattern, init_column_info): Use xmalloc and xnmalloc, not XMALLOC. (gobble_file): Use xnrealloc, not XREALLOC. (print_color_indicator): Remove now-unnecessary cast to size_t.
2003-10-13(print_many_per_line): Add FIXME comment.Jim Meyering
2003-09-28Remove unnecessary casts of alloca, since now it's guaranteed to be (void *).Jim Meyering
2003-09-18(WRITTEN_BY): Rename from AUTHORS.Jim Meyering
Begin each WRITTEN_BY string with `Written by ' and end it with `.'. Mark each WRITTEN_BY string as translatable.
2003-09-18revert previous changeJim Meyering
2003-09-18Update AUTHORS definition to be a comma-separated list of strings and/or updateJim Meyering
the call to parse_long_options so that `AUTHORS, NULL' are the last parameters.
2003-07-27(sort_files): Put `volatile' in the right place.Jim Meyering
2003-07-26(sort_files): Make `func' volatile, so it can't beJim Meyering
clobbered by a `longjmp' into this function.
2003-07-23Don't include headers already included by system.h:Jim Meyering
Don't include stdlib.h.
2003-07-12It appears that the `#pragma alloca' included via "system.h" isJim Meyering
adequate, since join.c uses alloca, yet lacked an in-file #pragma. Remove `#pragma alloca'.
2003-06-17(main): Call initialize_main.Jim Meyering
2003-05-14(usage): Don't use `,' as the thousands separatorJim Meyering
in e.g. 1,000,000 and 1,048,576. Instead, do this: `SIZE may be ..., MB 1000*1000, M 1024*1024 and so on...'
2003-04-11Include <stdlib.h> unconditionally.Jim Meyering
2003-03-07(dired_dump_obstack): Use putchar, not fputs, to output a single character.Jim Meyering
2003-01-27(quote_name): Add fourth parameter, width, into which toJim Meyering
store the screen columns, and return the number of bytes instead. (print_dir): Pass NULL as fourth parameter of quote_name. (print_name_with_quoting): Likewise. (length_of_file_name_and_frills): Get the width from the fourth parameter of quote_name instead of return value.
2003-01-27(decode_switches): If `dired' is set withoutJim Meyering
`format == long_format', then silently reset dired. This doesn't change the behavior of ls (all prior uses of dired were protected by `&& format == long_format'), and lets us... (DIRED_INDENT): ... remove `format == long_format' conjunct. (PUSH_CURRENT_DIRED_POS): Likewise. (main): Likewise.
2003-01-18(Dereference_symlink) [DEREF_COMMAND_LINE_SYMLINK_TO_DIR]: New member.Jim Meyering
(enum) [DEREFERENCE_COMMAND_LINE_SYMLINK_TO_DIR_OPTION]: New member. (long_options): Add option --dereference-command-line-symlink-to-dir. (main): Make DEREF_COMMAND_LINE_SYMLINK_TO_DIR be the default, rather than DEREF_COMMAND_LINE_ARGUMENTS, when none of the -d, -F, -l options is specified. (decode_switches): Handle --dereference-command-line-symlink-to-dir. (gobble_file): Honor DEREF_COMMAND_LINE_SYMLINK_TO_DIR. Change --dereference-command-line (-H) to dereference *all* command line arguments, including broken symlinks.
2003-01-18Change ls -H back to the way it was yesterday, since this isJim Meyering
compatible with FreeBSD and the POSIX spec is confusing and somewhat contradictory. (DEREF_COMMAND_LINE_ARGUMENTS): Change name back from DEREF_COMMAND_LINE_SYMLINK_TO_DIR, updating all uses. (long_options): Change the long option name back. (usage): Change the usage back. (gobble_file): When -H is specified, dereference a top-level arg even if it points to a non-directory.
2003-01-15(gobble_file): Fall back on using lstat when required:Jim Meyering
when --dereference (-L) is not specified, and - when operating on a dangling symlink - when operating on command-line-symlink-to-directories This fixes numerous problems. Here are examples: - `ls dangling-symlink' would fail with `no such file...' Now it prints `dangling-symlink'. - `ls -i symlink' would mistakenly print the inode of the referent. Now it prints the inode of the symlink. Likewise for --size (-s). Based on a patch from Michael Stone. Reported by Deepak Goel as Debian bug #173793.
2003-01-15Rename ls's --dereference-command-line (-H)Jim Meyering
option to --dereference-command-line-symlink-to-dir. [enum Dereference_symlink] (DEREF_COMMAND_LINE_SYMLINK_TO_DIR): Rename from DEREF_COMMAND_LINE_ARGUMENTS. Update all uses. (long_options): Rename the option. (usage): Say that --dereference-... changes how ls treats only symlinks to directories specified on the command line.
2003-01-14(gobble_file): Fix a bug introduced in 4.5.4 that made itJim Meyering
so that ls --color would no longer highlight the names of files with the execute bit set when not specified on the command line. Patch by Michael Stone. Reported by Stephen Depooter as Debian bug 175135.
2003-01-03Include "dev-ino.h".Jim Meyering
[struct dev_ino]: Remove declaration.
2002-12-15Remove all uses of `PARAMS'.Jim Meyering