aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/tr/tr.c
Commit message (Collapse)AuthorAgeFilesLines
* tr: fix class handling in unicode worldBaptiste Daroussin2026-02-141-0/+34
| | | | | | | | toupper/tolower logic was only handled for CCLASS_TOUPPER and CCLASS_TOLOWER, add support for CCLASS ([:alpha:]) PR: 219900 MFC After: 1 week
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-8/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* usr.bin: Remove ancient SCCS tags.Warner Losh2023-11-271-3/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* Remove $FreeBSD$: two-line .c patternWarner Losh2023-08-161-3/+0
| | | | Remove /^#include\s+<sys/cdefs.h>.*$\n\s+__FBSDID\("\$FreeBSD\$"\);\n/
* Mark usage function as __dead2 in programs where it does not returnAlfonso Gregory2023-07-071-1/+1
| | | | | | | | In most cases, usage does not return, so mark them as __dead2. For the cases where they do return, they have not been marked __dead2. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/735
* Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.Mariusz Zaborski2018-06-191-1/+1
| | | | | | | No functional change intended. Notes: svn path=/head/; revision=335395
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Remove the duplicated code using Capsicum helpers.Mariusz Zaborski2016-10-071-21/+3
| | | | | | | | Reviewed by: cem, ed, bapt, emaste Differential Revision https://reviews.freebsd.org/D8140 Notes: svn path=/head/; revision=306813
* Move sys/capsicum.h includes after types.h or param.hConrad Meyer2016-09-191-1/+1
| | | | | | | | | | | This is not actually documented or even implied in style(9). Make the change to match convention. Someone should document this convention in style(9). Reported by: jhb Sponsored by: EMC Dell Isilon Notes: svn path=/head/; revision=305998
* tr(1): CapsicumifyConrad Meyer2016-09-191-0/+26
| | | | | | | | | | | | This is a straightforward single input, single output program for capsicum. Reviewed by: bapt Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D7928 Notes: svn path=/head/; revision=305982
* Optimize [Cc]flag case: don't repeatedly add the last character ofAndrey A. Chernov2016-07-141-3/+4
| | | | | | | string2 to squeeze cset when string2 reach its EOS state. Notes: svn path=/head/; revision=302827
* Back out non-collating [a-z] ranges (r302594).Andrey A. Chernov2016-07-141-5/+40
| | | | | | | | | | | Instead of changing the whole course to another POSIX-permitted way for consistency and uniformity I decide to completely ignore missing regex fucntionality and focus on fixing bugs in what we have now, too many small obstacles we have choicing other way, counting ports. Corresponding libc changes are backed out in r302824. Notes: svn path=/head/; revision=302825
* Fully back out r302594 case 2) since overflow may happens.Andrey A. Chernov2016-07-131-1/+1
| | | | Notes: svn path=/head/; revision=302711
* Undo r302599 and partially r302594 case 2):Andrey A. Chernov2016-07-121-1/+1
| | | | | | | | since WCHAR_MAX can be not a valid wchar value, it is easier to stay inside wint_t. Notes: svn path=/head/; revision=302616
* Cast WCHAR_MAX to wint_t, it can be unsigned on some systems.Andrey A. Chernov2016-07-111-1/+1
| | | | Notes: svn path=/head/; revision=302599
* 1) Following r302512 (remove collation support for [a-z]-ranges in libc)Andrey A. Chernov2016-07-111-41/+6
| | | | | | | | | | | | | | | | | remove collation support for a-z ranges here too. It was implemented for single byte locales only in any case. 2) Reduce [Cc]flag loop to WCHAR_MAX, WINT_MAX here includes WEOF which is not a character. 3) Optimize [Cc]flag case: don't repeatedly add the last character of string2 to squeeze cset when string2 reach its EOS state. 4) Reflect in the manpage that [=equiv=] is implemented for single byte locales only. Notes: svn path=/head/; revision=302594
* When copying the complement of the string loop to WINT_MAX as we are dealingAndrew Turner2013-01-221-1/+2
| | | | | | | | with a wint_t. WINT_MAX and WCHAR_MAX are the same on most architectures except ARM EABI where wint_t is signed and wchar_t is unsigned. Notes: svn path=/head/; revision=245767
* Add missing static keywords to tr(1)Ed Schouten2011-11-061-2/+2
| | | | Notes: svn path=/head/; revision=227188
* Remove the advertising clause from UCB copyrighted files in usr.bin. ThisJoel Dahl2010-12-111-4/+0
| | | | | | | | | | | | is in accordance with the information provided at ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change Also add $FreeBSD$ to a few files to keep svn happy. Discussed with: imp, rwatson Notes: svn path=/head/; revision=216370
* Revert most part of 200420 as requested, as more review and polish isXin LI2009-12-131-0/+4
| | | | | | | needed. Notes: svn path=/head/; revision=200462
* Remove unneeded header includes from usr.bin/ except contributed code.Xin LI2009-12-111-4/+0
| | | | | | | Tested with: make universe Notes: svn path=/head/; revision=200420
* Remove unused variables.Stefan Farfeleder2005-04-091-1/+1
| | | | Notes: svn path=/head/; revision=144840
* Report input errors instead of ignoring them.Tim J. Robbins2004-07-091-0/+8
| | | | Notes: svn path=/head/; revision=131855
* Add support for multibyte characters. The challenge here was to useTim J. Robbins2004-07-091-102/+116
| | | | | | | | | | | | | | | | | data structures that scale better with large character sets, instead of arrays indexed by character value: - Sets of characters to delete/squeeze are stored in a new "cset" structure, which is implemented as a splay tree of extents. This structure has the ability to store character classes (ala wctype(3)), but this is not currently fully utilized. - Mappings between characters are stored in a new "cmap" structure, which is also a splay tree. - The parser no longer builds arrays containing all the characters in a particular class; instead, next() determines them on-the-fly using nextwctype(3). Notes: svn path=/head/; revision=131846
* Special fix just forAndrey A. Chernov2003-08-041-0/+7
| | | | | | | | | | | tr -[cC]s '[:upper:]' '[:lower:]' case (or vice versa): chars taken from s2 can be different this time due to lack of complex upper/lower processing, so fill string2 again to not miss some. Notes: svn path=/head/; revision=118409
* Microoptimization of prev. patch: do strdup() only if (cflag || Cflag)Andrey A. Chernov2003-08-031-3/+5
| | | | Notes: svn path=/head/; revision=118400
* 1) Fix -C - it was broken since introduced, wrong array sortedAndrey A. Chernov2003-08-031-22/+17
| | | | | | | 2) Fix last (repeated) char after [:class:], it was \0 in original code Notes: svn path=/head/; revision=118399
* Remove charcoll() stabilization added in 1.16, it gains nothing but conflictsAndrey A. Chernov2003-08-031-5/+1
| | | | | | | with ranges. Notes: svn path=/head/; revision=118373
* This patch address two problems.Andrey A. Chernov2003-08-031-17/+54
| | | | | | | | | | | | | | | | | | | 1st one is relatively minor: according our own manpage, upper and lower classes must be sorted, but currently not. 2nd one is serious: tr '[:lower:]' '[:upper:]' (and vice versa) currently works only if upper and lower classes have exact the same number of elements. When it is not true, like for many ISO8859-x locales which have bigger amount of lowercase letters, tr may do nasty things. See this page http://www.opengroup.org/onlinepubs/007908799/xcu/tr.html for detailed description of desired tr behaviour in such cases. Notes: svn path=/head/; revision=118371
* ANSIify function definitions.David Malone2002-09-041-10/+3
| | | | | | | | | | | | Add some constness to avoid some warnings. Remove use register keyword. Deal with missing/unneeded extern/prototypes. Some minor type changes/casts to avoid warnings. Reviewed by: md5 Notes: svn path=/head/; revision=102944
* When translating and -C is specified, behave as if the complemented set wasTim J. Robbins2002-07-291-0/+26
| | | | | | | in the locale collating order as required by SUSv3. Notes: svn path=/head/; revision=100891
* When translating and the -c option is specified, handle the case where theTim J. Robbins2002-07-291-6/+11
| | | | | | | | second string argument is more than one character in length in the way required by SUSv3 (and the way GNU textutils and SVR4 do it). Notes: svn path=/head/; revision=100874
* Add the P1003.1-2001 -C option which complements the set of charactersTim J. Robbins2002-06-141-18/+37
| | | | | | | (not byte values) specified by the first string argument. Notes: svn path=/head/; revision=98214
* Implement support for equivalence classes ([=e=]) when the mapping isTim J. Robbins2002-06-141-1/+1
| | | | | | | one-to-one (SUSv3) Notes: svn path=/head/; revision=98210
* remove __PWarner Losh2002-03-221-2/+2
| | | | Notes: svn path=/head/; revision=92922
* properly handle zero length first string when doing -cAlfred Perlstein2002-03-021-0/+1
| | | | | | | | PR: 34663 MFC After: 3 days Notes: svn path=/head/; revision=91562
* WARNS=2 fixes, use __FBSDID(), kill register keyword.Mark Murray2001-12-111-9/+9
| | | | Notes: svn path=/head/; revision=87705
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Submitted by: Joachim Kuebart, thanks.Wolfgang Helbig1997-10-121-6/+9
| | | | | | | Add -u option to force unbuffered output Notes: svn path=/head/; revision=30322
* Use err(3) instead of local redefinition. Cosmetic in usage().Philippe Charnier1997-08-181-35/+12
| | | | Notes: svn path=/head/; revision=28368
* compare return value from getopt against -1 rather than EOF, per the finalWarner Losh1997-03-291-1/+1
| | | | | | | posix standard on the topic. Notes: svn path=/head/; revision=24360
* Merge from Lite2Peter Wemm1997-03-111-1/+4
| | | | Notes: svn path=/head/; revision=23693
* Fix broken charclass handlingAndrey A. Chernov1995-10-281-0/+3
| | | | | | | Add setlocale LC_CTYPE Notes: svn path=/head/; revision=11895
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-1/+1
| | | | Notes: svn path=/head/; revision=8874
* BSD 4.4 Lite Usr.bin SourcesRodney W. Grimes1994-05-271-0/+287
Notes: svn path=/cvs2svn/branches/CHRISTOS/; revision=1590