summaryrefslogtreecommitdiff
path: root/src/tr.c
AgeCommit message (Collapse)Author
2008-01-06Avoid tr case-conversion failure in some locales.Jim Meyering
* src/tr.c (skip_construct): New function. (main): When processing a pair of case-converting classes, don't iterate through the elements of each [:upper:] or [:lower:] class. Reported by Gerald Pfeifer in <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12218>. * tests/tr/Test.pm [tolower-F]: New test for the above fix. [upcase-xtra, dncase-xtra]: New tests, for a related code path. * NEWS: Mention the tr bug fix.
2007-10-21tr: do not reject an unmatched [:lower:] or [:upper:] in SET1.Jim Meyering
* NEWS: Mention this. * src/tr.c (get_next) [RE_CHAR_CLASS]: Don't skip the loop when processing [:lower:] and [:upper:]. (main): Require [:lower:] or [:upper:] in SET1 only when when one of those is specified in SET2. * tests/tr/Test.pm: Add tests for this fix. Reported by Per Starbäck. Signed-off-by: Jim Meyering <meyering@redhat.com>
2007-07-23Update all copyright notices to use the newer form.Jim Meyering
2007-07-13Warn about non-portable use of unescaped backslash at end of string,Jim Meyering
and treat it as if it were escaped. * src/tr.c (unquote): Considering that such usage would make GNU tr from coreutils-5.2.1 and earlier *fail*, the least we can do now is to warn about it. Solaris' tr ignores it. * NEWS: Mention this.
2007-07-10Change "version 2" to "version 3" in all copyright notices.Jim Meyering
2007-05-04tr -c: don't abort when translating with S2 larger than complement of S1Jim Meyering
* src/tr.c (main): Remove invalid assertion triggered by e.g., tr -c a '[b*256]'. There's nothing wrong with having Set2 larger than Set1. Reported by Guntram Blohm. * tests/tr/Test.pm (no-abort-1): Test for the above. * NEWS: Mention this bug fix. * THANKS: Add Guntram Blohm.
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-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-10-10* src/ls.c (quote_name): Use initializer rather than memset toPaul Eggert
initialize an object to zero. This is easier to read and is less likely to introduce an runtime error due to a mixup. It causes gcc -W to issue a warning, but you can work around this by appending -Wno-missing-field-initializers. * src/pathchk.c (portable_chars_only): Likewise. * src/shred.c (main): Likewise. * src/stty.c (main): Likewise. * src/tr.c (card_of_complement): Likewise. * src/wc.c (wc): Likewise.
2006-07-09(is_char_class_member): Don't assume that isprint etc. returnPaul Eggert
booleans (needed for pre-C99 hosts).
2005-07-11(main): Avoid setmode; use POSIX-specified routines instead.Paul Eggert
2005-06-18(unquote): Remove unnecessary `' quotes from a diagnostic.Jim Meyering
2005-06-16Rather than this: error (..., "...`%s'...", arg);Jim Meyering
do this: error (..., "...%s...", quote (arg));
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-14Update FSF postal mail address.Jim Meyering
2004-09-21Remove unused "case 0".Paul Eggert
2004-09-09(main): Don't reorder options.Paul Eggert
2004-07-30(to_uchar): Remove; now in system.h.Paul Eggert
(is_char_class_member): Use bool when appropriate.
2004-06-21(main): Standardize on the diagnostics given when someone givesJim Meyering
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.
2004-06-17(to_uchar): Rename function from `uchar'. The latterJim Meyering
would clash with a typedef in Tru64's <sys/types.h>. From Albert Chin.
2004-06-06fix typo in commentJim Meyering
2004-06-06(main): "tr -d a b" is now a fatal error even if POSIXLY_CORRECT is set.Jim Meyering
The POSIX SYNOPSIS does not allow this option combination.
2004-06-02(posix_pedantic): Remove; no longer needed sinceJim Meyering
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.
2004-05-31(set_initialize): Remove unnecessary initialization of the `in_set'Jim Meyering
buffer; that initialization triggered the same compiler bug as above.
2004-05-31tr cleanup, mostly having to do with integer type ranges.Jim Meyering
Remove all casts. Here are examples of the failures: $ echo a | tr a '[x*][y*2147483646][y*2147483646][y*4]' x $ echo abcd | tr abc '[b*\9]' bbbd $ echo abcd | tr abc '[b*0]' tr: invalid repeat count `0' in [c*n] construct $ echo abcd | tr -c '[a*65536]\n' '[b*]' tr: ../../coreutils-5.2.1/src/tr.c:1942: main: Assertion `get_next (s2, ((void *)0)) == -1 || truncate_set1' failed. Aborted (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-30Work around HPUX /bin/cc compiler bug.Jim Meyering
(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
2004-05-13(unquote, make_printable_str): Use e.g. '\a' rather than '\007',Jim Meyering
for portability to EBCDIC hosts.
2004-05-09(unquote): Use xcalloc rather than xmalloc andJim Meyering
a loop initializing the just-allocated memory to zero.
2004-01-22(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-05(spec_init): Fix typo in last change.Jim Meyering
2003-11-02(append_normal_char, append_range, append_char_class)Jim Meyering
(append_repeated_char, append_equiv_class, spec_init): Use more maintainable and usually-shorter `sizeof *var' rather than `sizeof EXPLICIT_TYPE'.
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-05Standardize on BUFSIZ as opposed to other macro names and values.Jim Meyering
(BUFSIZ) [!defined BUFSIZ]: Don't define. (IO_BUF_SIZE): Remove; replace all uses with sizeof io_buf. (io_buf): IO_BUF_SIZE -> BUFSIZ.
2003-07-23Don't include headers already included by system.h:Jim Meyering
Don't include closeout.h.
2003-07-23Don't include headers already included by system.h:Jim Meyering
Don't include errno.h.
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.
2002-10-08Rename local variable: chars_read -> bytes_readJim Meyering
2002-10-08(squeeze_filter, read_and_delete, read_and_xlate): Adapt to new safe_read ABI.Jim Meyering
2002-09-29(find_bracketed_repeat): Rearrange pointer/integerJim Meyering
expression to avoid warning from gcc.
2002-08-25(main): Close STDIN_FILENO rather than a literal `0'.Jim Meyering
2002-07-02(usage): Use the PACKAGE_BUGREPORT e-mail address, rather than hard-coding it.Jim Meyering
2002-04-15(usage): Give a verbose description of --squeeze-repeats,Jim Meyering
including the mention of SET1.
2002-02-11(unquote): Make comment a little clearer.Jim Meyering
2002-01-18tweak copyright lineJim Meyering
2002-01-18Fix tr so it no longer gets a failed assertion for [::] or [==].Jim Meyering
(xmemdup): Rename from `substr' and rewrite to take only pointer/length parameters. (build_spec_list): Update sole caller. Properly diagnose the invalid specs [::] and [==]. Pawel Prokop reported that `tr [::] _' elicits a failed assertion.
2001-12-03(usage): Don't split translatable strings in the middle of a sentence.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.