summaryrefslogtreecommitdiff
path: root/src/cut.c
AgeCommit message (Collapse)Author
2008-08-04doc: correct and normalize --help output of several toolsBenno Schulenberg
* src/chroot.c (usage): Add "[ARG]" to synopsis. * src/cut.c (usage): Remove an inconsistent period in an option description. * src/du.c (usage): Remove superfluous argument after short option -X. Also remove inconsistent uppercase and final period. Use a single indent level for prettiness. * src/shred.c (usage): Normalize the synopsis. * src/stty.c (usage): Options -F and --file are alternatives, cannot both be used. * src/sum.c (usage): -r does not overrule -s; the last one counts. * src/uptime.c (usage): Remove inconsistent space from the synopsis. * src/users.c: Likewise.
2008-06-16remove redundant const directivesJim Meyering
In 1463824d8e7f72c31f1d803d7cfe2b608ccafc5c, I added some missing "const" directives, as well as some new, redundant ones. This removes the redundant ones. Pointed out by Eric Blake. * base64.c, cat.c, chcon.c, chgrp.c, chmod.c, chown.c, comm.c: * cp.c, csplit.c, cut.c, date.c, dd.c, df.c, dircolors.c, du.c: * env.c, expand.c, fmt.c, fold.c, groups.c, head.c, id.c: * install.c, join.c, kill.c, ln.c, ls.c, md5sum.c, mkdir.c: * mkfifo.c, mknod.c, mktemp.c, mv.c, nice.c, nl.c, od.c: * paste.c, pathchk.c, pinky.c, pr.c, ptx.c, readlink.c, rm.c: * rmdir.c, runcon.c, seq.c, shred.c, shuf.c, sort.c, split.c: * stat.c, stty.c, su.c, sum.c, tac.c, tail.c, tee.c, timeout.c: * touch.c, tr.c, truncate.c, tty.c, uname.c, unexpand.c, uniq.c: * wc.c, who.c: Remove redundant const directives. * maint.mk (sc_const_long_option): Don't require redundant "const".
2008-06-14add "const" attribute, where possibleJim Meyering
* maint.mk (sc_const_long_option): New rule. Enforce global change. * src/base64.c (long_options): Use "const" where possible. * src/cat.c (main): Likewise. * src/chcon.c (long_options): Likewise. * src/chgrp.c (long_options): Likewise. * src/chmod.c (long_options): Likewise. * src/chown.c (long_options): Likewise. * src/comm.c (long_options, OUTPUT_DELIMITER_OPTION): Likewise. * src/cp.c (long_opts): Likewise. * src/csplit.c (longopts): Likewise. * src/cut.c (longopts): Likewise. * src/date.c (long_options): Likewise. * src/dd.c (conversions, flags, statuses): Likewise. * src/df.c (long_options): Likewise. * src/dircolors.c (long_options): Likewise. * src/du.c (long_options): Likewise. * src/env.c (longopts): Likewise. * src/expand.c (longopts): Likewise. * src/fmt.c (long_options): Likewise. * src/fold.c (longopts): Likewise. * src/groups.c (longopts): Likewise. * src/head.c (long_options): Likewise. * src/id.c (longopts): Likewise. * src/install.c (long_options): Likewise. * src/join.c (longopts): Likewise. * src/kill.c (long_options): Likewise. * src/ln.c (long_options): Likewise. * src/ls.c (long_time_format, long_options, sort_functions): Likewise. * src/md5sum.c (long_options): Likewise. * src/mkdir.c (longopts): Likewise. * src/mkfifo.c (longopts): Likewise. * src/mknod.c (longopts): Likewise. * src/mktemp.c (longopts): Likewise. * src/mv.c (long_options): Likewise. * src/nice.c (longopts): Likewise. * src/nl.c (longopts): Likewise. * src/od.c (charname, long_options): Likewise. * src/paste.c (longopts): Likewise. * src/pathchk.c (longopts): Likewise. * src/pinky.c (longopts): Likewise. * src/pr.c (long_options): Likewise. * src/ptx.c (long_options): Likewise. * src/readlink.c (longopts): Likewise. * src/rm.c (long_opts): Likewise. * src/rmdir.c (longopts): Likewise. * src/runcon.c (long_options): Likewise. * src/seq.c (long_options): Likewise. * src/shred.c (long_opts): Likewise. * src/shuf.c (long_opts): Likewise. * src/sort.c (monthtab, long_options): Likewise. * src/split.c (longopts): Likewise. * src/stat.c (long_options): Likewise. * src/stty.c (mode_info, control_info, longopts, set_mode) Likewise. (set_control_char, speeds): Likewise. * src/su.c (longopts): Likewise. * src/sum.c (longopts): Likewise. * src/tac.c (longopts): Likewise. * src/tail.c (long_options): Likewise. * src/tee.c (long_options): Likewise. * src/timeout.c (long_options): Likewise. * src/touch.c (longopts): Likewise. * src/tr.c (long_options): Likewise. * src/truncate.c (longopts): Likewise. * src/tty.c (longopts): Likewise. * src/uname.c (uname_long_options, arch_long_options): Likewise. * src/unexpand.c (longopts): Likewise. * src/uniq.c (longopts): Likewise. * src/wc.c (longopts): Likewise. * src/who.c (longopts): Likewise.
2008-06-03use gnulib's progname moduleJim Meyering
* bootstrap.conf (gnulib_modules): Add progname. * src/*.c (program_name): Remove declaration. * (main): Call set_program_name rather than setting program_name. * src/nice.c (main): Cast program_name to "(char *)". * src/prog-fprintf.c: Include "system.h" * src/system.h: Include "progname.h". * maint.mk (sc_program_name): Adjust rule. Suggestion from Eric Blake.
2008-06-02declare program_name consistentlyJim Meyering
* src/base64.c: Likewise. * src/basename.c: Likewise. * src/cat.c: Likewise. * src/chcon.c: Likewise. * src/chgrp.c: Likewise. * src/chmod.c: Likewise. * src/chown.c: Likewise. * src/chroot.c: Likewise. * src/cksum.c: Likewise. * src/comm.c: Likewise. * src/cp.c: Likewise. * src/csplit.c: Likewise. * src/cut.c: Likewise. * src/date.c: Likewise. * src/dd.c: Likewise. * src/df.c: Likewise. * src/dircolors.c: Likewise. * src/dirname.c: Likewise. * src/du.c: Likewise. * src/echo.c: Likewise. * src/env.c: Likewise. * src/expand.c: Likewise. * src/expr.c: Likewise. * src/factor.c: Likewise. * src/fmt.c: Likewise. * src/fold.c: Likewise. * src/groups.c: Likewise. * src/head.c: Likewise. * src/hostid.c: Likewise. * src/hostname.c: Likewise. * src/id.c: Likewise. * src/install.c: Likewise. * src/join.c: Likewise. * src/kill.c: Likewise. * src/link.c: Likewise. * src/ln.c: Likewise. * src/logname.c: Likewise. * src/ls.c: Likewise. * src/md5sum.c: Likewise. * src/mkdir.c: Likewise. * src/mkfifo.c: Likewise. * src/mknod.c: Likewise. * src/mktemp.c: Likewise. * src/mv.c: Likewise. * src/nice.c: Likewise. * src/nl.c: Likewise. * src/nohup.c: Likewise. * src/od.c: Likewise. * src/paste.c: Likewise. * src/pathchk.c: Likewise. * src/pinky.c: Likewise. * src/pr.c: Likewise. * src/printenv.c: Likewise. * src/printf.c: Likewise. * src/ptx.c: Likewise. * src/pwd.c: Likewise. * src/readlink.c: Likewise. * src/rm.c: Likewise. * src/rmdir.c: Likewise. * src/runcon.c: Likewise. * src/seq.c: Likewise. * src/setuidgid.c: Likewise. * src/shuf.c: Likewise. * src/sleep.c: Likewise. * src/sort.c: Likewise. * src/split.c: Likewise. * src/stat.c: Likewise. * src/stty.c: Likewise. * src/su.c: Likewise. * src/sum.c: Likewise. * src/sync.c: Likewise. * src/tac.c: Likewise. * src/tail.c: Likewise. * src/tee.c: Likewise. * src/test.c: Likewise. * src/timeout.c: Likewise. * src/touch.c: Likewise. * src/tr.c: Likewise. * src/true.c: Likewise. * src/tsort.c: Likewise. * src/tty.c: Likewise. * src/uname.c: Likewise. * src/unexpand.c: Likewise. * src/uniq.c: Likewise. * src/unlink.c: Likewise. * src/uptime.c: Likewise. * src/users.c: Likewise. * src/wc.c: Likewise. * src/who.c: Likewise. * src/whoami.c: Likewise. * src/yes.c: Likewise.
2008-06-02spell author names consistentlyJim Meyering
* src/comm.c (AUTHORS): Use RMS' middle initial. * src/ls.c (AUTHORS): Likewise. * src/rm.c (AUTHORS): Likewise. * src/uniq.c (AUTHORS): Likewise. * src/cut.c (AUTHORS): Use David M. Ihnat's middle initial. * AUTHORS: Update to match. Reported by Michael Piefel.
2008-05-26convert 3-author programs to use proper_nameJim Meyering
g grep -E -l 'define AUTHORS "[^,]+", "[^,]+", "[^,]+"$'|xargs perl -pi -e \ 's/(define AUTHORS) ("[^,]+"), ("[^,]+"), ("[^,]+")$/$1 \\\n proper_name ($2), \\\n proper_name ($3), \\\n proper_name ($4)/'
2008-05-06avoid problems with sign-extended "char" operand to is* functionsJim Meyering
* src/cut.c (set_fields): Apply to_uchar to isblank operands. * src/uniq.c (find_field): Likewise. * src/seq.c (scan_arg): Likewise, for isspace. * tests/misc/uniq: New file. Test for the above, but only when isspace(0240). * tests/Makefile.am (TESTS): Add misc/uniq. * configure.ac: Use gt_LOCALE_FR. * tests/check.mk (TESTS_ENVIRONMENT): Propagate LOCALE_FR to scripts. * NEWS: Mention the bug fixes. Before this patch, on FreeBSD 6: $ printf 'x y z\nx \xa0 y z\n' > in $ LC_ALL=fr_FR.UTF-8 uniq -f2 in|tr ' ' . x.y.z x. .y.z With the patch: $ LC_ALL=fr_FR.UTF-8 uniq -f2 in|tr ' ' . x.y.z This also affected many other locales: for i in $(locale -a); do test $(LC_ALL=$i ./uniq -f1 in|wc -l) = $(LC_ALL=$i uniq -f1 in|wc -l) || echo $i ; done ... en_GB.ISO8859-1 en_GB.ISO8859-15 en_GB.UTF-8 en_IE.UTF-8 en_NZ.ISO8859-1 en_NZ.ISO8859-15 en_NZ.UTF-8 en_US.ISO8859-1 en_US.ISO8859-15 en_US.UTF-8 ...
2007-07-23Update all copyright notices to use the newer form.Jim Meyering
2007-07-10Change "version 2" to "version 3" in all copyright notices.Jim Meyering
2007-05-22cut: diagnose a range starting with 0 (-f 0-2) as invalid, andJim Meyering
give a better diagnostic for a field-number/offset of 0. * NEWS: Mention the fix. * src/cut.c (ADD_RANGE_PAIR): Add an explicit check for 0. Based on a patch from James Youngman. * tests/misc/cut: Add tests for the above.
2007-05-22"cut -f 2-0" now fails; before, it was equivalent to "cut -f 2-"Jim Meyering
Also, diagnose the '-' in "cut -f -" as an invalid range, rather than interpreting it as the unlimited range, "1-". * NEWS: Mention these changes. * src/cut.c (set_fields): Don't interpret an accumulator "value" of 0 as an unspecified range endpoint. Give better diagnostics. Adjust a comment so that it is true also for 64-bit size_t. * tests/cut/Test.pm: Add tests for the above.
2007-04-16* src/cut.c (usage): Adjust synopsis to show that an OPTION is required.Jim Meyering
Reported by Rudolf Kastl.
2007-03-28Help translators include translation team's web or email address.Jim Meyering
* src/system.h (emit_bug_reporting_address): New function. * src/base64.c: Use it rather than a literal printf. * src/basename.c, src/cat.c, src/chgrp.c, src/chmod.c: * src/chown.c, src/chroot.c, src/cksum.c, src/comm.c, src/cp.c: * src/csplit.c, src/cut.c, src/date.c, src/dd.c, src/df.c: * src/dircolors.c, src/dirname.c, src/du.c, src/echo.c, src/env.c: * src/expand.c, src/expr.c, src/factor.c, src/fmt.c, src/fold.c: * src/head.c, src/hostid.c, src/hostname.c, src/id.c, src/install.c: * src/join.c, src/kill.c, src/link.c, src/ln.c, src/logname.c: * src/ls.c, src/md5sum.c, src/mkdir.c, src/mkfifo.c, src/mknod.c: * src/mv.c, src/nice.c, src/nl.c, src/nohup.c, src/od.c: * src/paste.c, src/pathchk.c, src/pinky.c, src/pr.c, src/printenv.c: * src/printf.c, src/ptx.c, src/pwd.c, src/readlink.c, src/rm.c: * src/rmdir.c, src/seq.c, src/setuidgid.c, src/shred.c, src/shuf.c: * src/sleep.c, src/sort.c, src/split.c, src/stat.c, src/stty.c: * src/su.c, src/sum.c, src/sync.c, src/system.h, src/tac.c: * src/tail.c, src/tee.c, src/test.c, src/touch.c, src/tr.c: * src/true.c, src/tsort.c, src/tty.c, src/uname.c, src/unexpand.c: * src/uniq.c, src/unlink.c, src/uptime.c, src/users.c, src/wc.c: * src/who.c, src/whoami.c, src/yes.c: Likewise.
2006-12-20"cut -f 2- A B" no longer triggers a double-free bugJim Meyering
* src/cut.c (cut_fields): Set file-scoped global to NULL after freeing it. This avoids a double-free (and core dump on some systems) for this usage: "echo 1>a; echo 2>b; cut -f2- a b". Reported by James Hunt in <http://bugzilla.redhat.com/220312>. * NEWS: List this bug fix. * THANKS: Mention him. * tests/misc/cut: New file. * tests/misc/Makefile.am (TESTS): Add cut.
2006-11-27Improve the check for departures from C89, and fix the departuresPaul Eggert
I found. * Makefile.maint (my-distcheck): Also check for C89 compatibility as best we can with GCC. * src/stat.c (PRINTF_OPTION): Omit comma before } in enum declaration; C89 doesn't allow this. * src/dcgen: Don't generate string literals longer than what C89 requires support for. * src/cut.c (usage): Don't use string literals longer than what C89 requires support for. * src/date.c (usage): Likewise. * src/dd.c (usage): Likewise. * src/du.c (usage): Likewise. * src/ls.c (usage): Likewise. * src/od.c (usage): Likewise. * src/readlink.c (usage): Likewise. * src/seq.c (usage): Likewise. * src/shred.c (usage): Likewise.
2006-10-25* src/cat.c (infile): Add "const" to declaration.Jim Meyering
* src/csplit.c (prefix): Likewise. * src/printf.c (cfcc_msg): Likewise. * src/tail.c (valid_file_spec): Likewise. * src/cut.c (cut_file): Likewise, for a parameter. * src/expr.c (str_value): Likewise. * src/fold.c (fold_file): Likewise. * src/pr.c (init_header): Likewise. * src/dircolors.c (dc_parse_stream): Likewise, for a local. * src/tr.c (make_printable_str): Likewise. * src/nl.c (body_type, header_type, footer_type, current_type): (separator_str, build_type_arg, nl_file): Likewise, for many. * src/paste.c (main): Don't assign a read-only string to 'optarg'. * src/tac.c (separator, tac_seekable, copy_to_temp): Likewise.
2006-07-09Adjust to today's renaming changes in system.h.Paul Eggert
2005-08-12Cosmetic: use X2NREALLOC (only two arguments) rather than x2nrealloc (with ↵Jim Meyering
three).
2005-07-05Adjust to the change to DECIMAL_DIGIT_ACCUMULATE: its last arg is nowPaul Eggert
a type, not a value.
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-14Update FSF postal mail address.Jim Meyering
2005-03-28(longopts): Use NULL, not `0'.Jim Meyering
2005-03-25(set_fields): Update use of DECIMAL_DIGIT_ACCUMULATE.Jim Meyering
2005-03-17(set_fields): Use DECIMAL_DIGIT_ACCUMULATE macro inJim Meyering
place of nearly-equivalent code.
2005-03-06Remove `register' keyword.Jim Meyering
2004-12-04(complement, COMPLEMENT_OPTION): New.Jim Meyering
(longopts): Add --complement. (usage): Say not that -b, -c, and -f `print' fields, but rather that they `select' fields for printing. Describe the new --complement option. (mark_range_start): Extracted from set_fields. (print_kth): Support --complement. (compare_ranges): New function. (set_fields): Rewrite the part that populates range_start_ht, merging it with the part that populates printable_field. (main): Handle --complement. From Paolo Bonzini.
2004-11-16(usage): Improve documentation along the lines suggestedPaul Eggert
by Debian 5.2.1-2.
2004-09-21Remove unused "case 0".Paul Eggert
2004-08-03(cut_fields): Use to_uchar rather than a cast.Paul Eggert
(cut_file, main): Use bool for booleans.
2004-08-02(hash_int) [!defined UINTPTR_MAX]: Use size_t instead of uintptr_t.Paul Eggert
2004-06-02Fix a bug in how the --output-delimiter=D option works withJim Meyering
abutting byte or character ranges. Reported by David Krider in http://lists.gnu.org/archive/html/bug-coreutils/2004-05/msg00132.html (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.
2004-05-17(cut_fields): Adjust to new signature of getndelim2.Jim Meyering
2004-04-20(cut_fields): Free buffer upon getndelim2 failure.Jim Meyering
2004-01-21(usage): Use EXIT_SUCCESS, not 0, for clarity.Jim Meyering
(usage): Don't bother normalizing exit status since the arg is already the correct exit status now. (FATAL_ERROR, main): Exit with status EXIT_FAILURE, not 2, on errors.
2003-11-06Fix 'cut' problems with size_t overflow and unsigned int.Jim Meyering
More generally, resize integer variables to fit use more precisely. (ADD_RANGE_PAIR): Remove unnecessary parens. (struct range_pair): Make members to be of type size_t, not unsigned. (max_range_endpoint, eol_range_start): Now size_t, not unsigned. (suppress_non_delimited, output_delimiter_specified, have_read_stdin, print_kth, set_fields): Now bool, nt int. (delim): Now unsigned char, not int. (mark_printable_field, is_printable_field, is_range_start_index, set_fields, set_fields, cut_bytes, cut_fields): Use size_t, not unsigned, for field and byte counts. (hash_int): Use uintptr_t, not unsigned, for pointers converted to integers. This squeezes more info out of them. (set_fields, cut_bytes, cut_fields, main): Use bool, not int, for booleans. (set_fields): Allocate zeroed byte array with xzalloc, not xcalloc.
2003-11-04(ADD_RANGE_PAIR): Use x2nrealloc rather than xrealloc,Jim Meyering
to avoid potential overflow in pointer arithmetic. (set_fields): Use not `1', but rather `sizeof *printable_field' as second argument to xcalloc.
2003-10-25(hash_int): 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-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-08-07Include getndelim2.h rather than getdelim2.h.Jim Meyering
(cut_fields): Invoke getndelim2 rather than getdelim2.
2003-08-02(cut_fields): Don't read again after encountering EOF.Jim Meyering
E.g., `cut -f2' would do so.
2003-07-27(is_printable_field): Simplify bit arithmetic.Jim Meyering
2003-07-26Use only one bit per field/offset in array, not one `int'.Jim Meyering
(printable_field): Change type to `unsigned char'. (mark_printable_field, is_printable_field): New functions. Use them in place of all direct accesses of `printable_field'.
2003-07-26(set_fields): Detect overflow properly.Jim Meyering
2003-07-23Don't include headers already included by system.h:Jim Meyering
Don't include closeout.h.
2003-07-22tweak commentJim Meyering
2003-07-22(set_fields): Use xcalloc in place of xmalloc+memset.Jim Meyering