summaryrefslogtreecommitdiff
path: root/src/cut.c
AgeCommit message (Collapse)Author
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
2003-07-22don't include stdboo.h. it's already included via system.hJim Meyering
2003-07-22(main) [lint]: Initialize spec_list_string to avoid warning.Jim Meyering
2003-07-22(set_fields): Mark all selected indices before trying toJim Meyering
determine range endpoints.
2003-07-22Begin to address this comment: What if someone wants toJim Meyering
extract the 1,000,000-th field of some huge input file? The first step is to rearrange things so that the values in the printable_field array are all 0/1 rather than 0/1/2. (RANGE_START_SENTINEL): Remove. Store range-start indices in a hash table, rather than overloading the `printable_field' array. (range_start_ht): New global. (hash_int, hash_compare_ints, is_range_start_index): New functions. (print_kth): Use is_range_start_index; don't test printable_field. (set_fields): Detect overflow. (set_fields): Insert each range-start index into range_start_ht. (main): Call set_fields only once, and only after output_delimiter_specified and (if required) range_start_ht have been defined.
2003-06-18Include "getdelim2.h", not "getstr.h".Jim Meyering
Reflect renaming: getstr -> getdelim2.
2003-06-17(main): Call initialize_main.Jim Meyering
2003-04-11Remove anachronistic casts of xmalloc,Jim Meyering
xrealloc, and xcalloc return values and of xrealloc's first argument.
2003-01-09When selecting ranges of byte offsets (as opposed to ranges of fields)Jim Meyering
and when --output-delimiter=STRING is specified, output STRING between ranges of selected bytes. (RANGE_START_SENTINEL): Define. (output_delimiter_specified): New global. (print_kth): Add parameter. Adjust all callers. (set_fields): Mark each range-start index with RANGE_START_SENTINEL. (cut_bytes): When requested, output STRING between ranges of selected bytes. (main): Make a diagnostic a little clearer. Based on a patch from Jan Nieuwenhuizen.
2003-01-09(set_fields): Make code agree with comment:Jim Meyering
Don't merge abutting ranges like 4- and 2-3. This makes no difference currently, but is required to support an upcoming change.
2003-01-07(set_fields): Fix typo in comment.Jim Meyering
2002-10-12(cut_fields): Add a temporary size_t variable, n_bytes, to avoid warnings.Jim Meyering
2002-07-02(usage): Use the PACKAGE_BUGREPORT e-mail address, rather than hard-coding it.Jim Meyering
2001-12-01Reflect renaming to, and new usage of these macros:Jim Meyering
HELP_OPTION_DESCRIPTION and VERSION_OPTION_DESCRIPTION.
2001-12-01(usage): Use new macros, EMIT_HELP_DESCRIPTION and EMIT_VERSION_DESCRIPTIONJim Meyering
instead of hard-coding --help and --version descriptions.
2001-11-23Factor out some common strings to make translation easier.Jim Meyering
Split usage strings so that --help and --version descriptions are alone in their own string. Likewise for the one that says: Mandatory arguments to long options are mandatory for short options too.
2001-11-11(usage): Split --help output into smaller pieces.Jim Meyering
Use fputs, not printf.
2001-11-04(usage): Say thatJim Meyering
``Mandatory arguments to long options are mandatory for short options too.\n\''
2001-08-13(AUTHORS): Mark string for translation, since it contains the English word ↵Jim Meyering
`and'.
2000-09-07(usage): Note that when using -f, lines with no delimiters are also printed.Jim Meyering
2000-09-07Remove obsolete comment block.Jim Meyering
2000-08-08(cut_fields): Invoke xalloc_die instead of printing our own message.Jim Meyering
(cut_fields): Check for I/O error as well as end-of-file.
2000-07-31(cut_fields): Use `virtual memory exhausted', not `Memory exhausted'.Jim Meyering
2000-07-01Change type of global, field_1_bufsize, from int to size_t.Jim Meyering
2000-06-21(getstr): Remove private (and out of date) version of this function.Jim Meyering
(cut_fields): Adjust caller to use the just-extended one in ../lib.
2000-05-20Arrange to call close_stdout upon exit. Don't close stdout explicitly.Jim Meyering
2000-01-21Correct copying notice to use GPL, per author's request.Jim Meyering
2000-01-08(OUTPUT_DELIMITER_OPTION): Define this and use it instead of `CHAR_MAX + n'.Jim Meyering
1999-09-02Remove xstrdup declaration.Jim Meyering
1999-04-04Standardize --help and --version processing.Jim Meyering
1999-04-03Use AUTHORS in place of string in parse_long_options call.Jim Meyering
1999-04-03Insert AUTHORS definition.Jim Meyering
1999-04-03Use PROGRAM_NAME in place of string in parse_long_options call.Jim Meyering
1999-04-03define PROGRAM_NAMEJim Meyering
1999-03-07(getstr): Change type of `delim' parameter from char to int.Jim Meyering
(cut_fields): Cast to `unsigned char' before comparing. (main): Cast to `unsigned char' before assigning.
1999-03-07(FATAL_ERROR): s/s/MessageJim Meyering