aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/printf
Commit message (Collapse)AuthorAgeFilesLines
* Add META_MODE support.Simon J. Gerraty2015-06-131-0/+18
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-081-2/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Merge sync of headSimon J. Gerraty2015-05-271-1/+0
| |\ | |/ |/| | | Notes: svn path=/projects/bmake/; revision=283595
| * Merge head from 7/28Simon J. Gerraty2014-08-195-12/+36
| |\ | | | | | | | | | Notes: svn path=/projects/bmake/; revision=270164
| * | Updated dependenciesSimon J. Gerraty2014-05-161-1/+0
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=266219
| * | Updated dependenciesSimon J. Gerraty2014-05-101-0/+2
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265802
| * | Merge from headSimon J. Gerraty2014-05-082-36/+103
| |\ \ | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265720
| * \ \ Merge headSimon J. Gerraty2014-04-2818-3/+112
| |\ \ \ | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265044
| * | | | Updated dependenciesSimon J. Gerraty2013-03-111-0/+1
| | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=248169
| * | | | Updated dependenciesSimon J. Gerraty2013-02-161-2/+0
| | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246868
| * | | | Sync with HEAD.David E. O'Brien2013-02-081-1/+1
| |\ \ \ \ | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246555
| * \ \ \ \ Sync from headSimon J. Gerraty2012-11-041-4/+10
| |\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=242545
| * | | | | | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.Marcel Moolenaar2012-08-221-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net> Notes: svn path=/projects/bmake/; revision=239572
* | | | | | | sh: Fix compiler warnings related to duplicate or missing declarations.Jilles Tjoelker2015-03-011-1/+0
| |_|_|_|_|/ |/| | | | | | | | | | | | | | | | | Notes: svn path=/head/; revision=279503
* | | | | | printf: Install tests/regress.missingpos1.out, fixing tests.Jilles Tjoelker2014-06-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/head/; revision=266948
* | | | | | Fix m2 regression test.Pedro F. Giffuni2014-05-311-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is not really a good test as the behaviour for /c is unspecified. For the record, ksh93 returns: $ printf "abc\n\cdef" abc ef$ Discussed with: Garret D'Amore (Illumos) Notes: svn path=/head/; revision=266912
* | | | | | Update number of tests.Pedro F. Giffuni2014-05-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suggested by: jmmv Notes: svn path=/head/; revision=266854
* | | | | | Minor style knit.Pedro F. Giffuni2014-05-291-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/head/; revision=266853
* | | | | | printf(1): add tests for warn about incomplete uses n$Pedro F. Giffuni2014-05-262-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Submitted by: jilles MFC after: 2 weeks Notes: svn path=/head/; revision=266691
* | | | | | printf(1): warn about incomplete uses n$Pedro F. Giffuni2014-05-261-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reviewed by: jilles Obtained from: Illumos MFC after: 2 weeks Notes: svn path=/head/; revision=266690
* | | | | | printf: Fix missing arguments for %u/%o/%x/%X after r265592.Jilles Tjoelker2014-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a numeric argument is missing, zero should be assumed, for signed as well as unsigned conversions. This fixes the 'zero' regression tests. r265592 erroneously reverted r244407. Notes: svn path=/head/; revision=265977
* | | | | | printf: fix regression after illumos merges.Pedro F. Giffuni2014-05-111-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "bltin/bltin.h" wrappers do not support exit() and attempting to call it will exit sh completely. Note that errx() is acceptable but will always return with status 2. Reported by: jilles (and the testing framework) Fix by: jilles Pointyhat: pfg Notes: svn path=/head/; revision=265885
* | | | | | prinf: replace use of alloca with variable length array.Pedro F. Giffuni2014-05-101-3/+1
| |_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use of alloca(3) is discouraged in FreeBSD. Using a VLA is simple and should be more portable. Requested by: jilles Notes: svn path=/head/; revision=265860
* | | | | Fix the incorrect handling of %b and \c in printf(1)Pedro F. Giffuni2014-05-081-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is required for POSIX compliance. Obtained from: Garrett D'Amore (Illumos) MFC after: 4 days Notes: svn path=/head/; revision=265706
* | | | | Add width and precision specifiers to printf(1) %n$.Pedro F. Giffuni2014-05-071-25/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This actually completes r264743 so that width and precision specifiers work properly with %n$. These keeps consistency with ksh93 and zsh. Requested by: jilles Obtained from: Garrett D'Amore (Illumos) MFC after: 4 days Notes: svn path=/head/; revision=265592
* | | | | Use src.opts.mk in preference to bsd.own.mk except where we need stuffWarner Losh2014-05-061-1/+1
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | from the latter. Notes: svn path=/head/; revision=265420
* | | | Add parameterized position handling to printf(1).Pedro F. Giffuni2014-04-212-1/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new %n$ option to change the order of the parameters as done in the ksh93 builtin printf (among others). For example: %printf '%2$1d %1$s\n' one 2 three 4 2 one 4 three The feature was written by Garret D'Amore under a BSD license for Nexenta/illumos. Reference: http://garrett.damore.org/2010/10/new-implementation-of-printf.html PR: bin/152934 Obtained from: Illumos MFC after: 2 weeks Notes: svn path=/head/; revision=264743
* | | | Minor style(9) cleanupsPedro F. Giffuni2014-04-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #define should be followed by a tab. MFC after: 3 days Notes: svn path=/head/; revision=264581
* | | | Migrate most of tools/regression/usr.bin/ to the new tests layout.Julio Merino2014-03-1616-0/+71
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm starting with the easy cases. The leftovers need to be looked at a bit more closely. Note that this change _does_ modify the code of the old tests. This is required in order to allow the code to locate the data files in the source directory instead of the current directory, because Kyua automatically changes the latter to a temporary directory. Also note that at least one test is known to be broken here. Actually, the test is not really broken: it's marked as a TODO but unfortunately Kyua's TAP parser currently does not understand that. Will have to be fixed separately. Notes: svn path=/head/; revision=263227
* | | POSIX requires that non-existent or null arguments be treated as if aEitan Adler2012-12-181-1/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | zero argument were supplied. Add a regression test to catch this case as well. PR: bin/174521 Submitted by: Daniel Shahaf <danielsh@elego.de> (pr) Submitted by: Mark Johnston <markjdb@gmail.com> (initial patch) Reviewed by: jilles Approved by: cperciva (implicit) MFC after: 3 weeks Notes: svn path=/head/; revision=244407
* | sh: Prefer internal nextopt() to libc getopt().Jilles Tjoelker2012-09-151-4/+10
|/ | | | | | | | | | | | This reduces code duplication and code size. /usr/bin/printf is not affected. Side effect: different error messages when certain builtins are passed invalid options. Notes: svn path=/head/; revision=240541
* Remove trailing whitespace per mdoc lint warningEitan Adler2012-03-291-1/+1
| | | | | | | | | | Disussed with: gavin No objection from: doc Approved by: joel MFC after: 3 days Notes: svn path=/head/; revision=233648
* Style cleanups for printf.Pedro F. Giffuni2012-01-121-18/+18
| | | | | | | | | | PR: bin/152934 Approved by: jhb (mentor) Obtained from: Illumos MFC after: 2 weeks Notes: svn path=/head/; revision=230027
* printf(1): Document that %c and precision for %b/%s use bytes, not chars.Jilles Tjoelker2011-05-281-6/+17
| | | | | | | | | | This means these features do not work as expected with multibyte characters. This perhaps less than ideal behaviour matches printf(3) and is specified by POSIX. Notes: svn path=/head/; revision=222421
* printf: Allow multibyte characters for '<char> form, avoid negative codes.Jilles Tjoelker2011-05-282-6/+19
| | | | | | | | | | | | | | | | Examples: LC_ALL=en_US.UTF-8 printf '%d\n' $(printf \'\\303\\244) LC_ALL=en_US.ISO8859-1 printf '%d\n' $(printf \'\\344) Both of these should print 228. Like some other shells, incomplete or invalid multibyte characters yield the value of the first byte without a warning. Note that there is no general way to go back from the character code to the character. Notes: svn path=/head/; revision=222418
* printf(1): Move non-bugs from the BUGS section to a new section CAVEATS.Jilles Tjoelker2011-04-251-10/+10
| | | | Notes: svn path=/head/; revision=221026
* printf(1): Mention effect of '#' modifier on other conversions.Jilles Tjoelker2011-04-251-5/+5
| | | | Notes: svn path=/head/; revision=221013
* printf: Note that this is used both as a normal program and a shell builtin.Jilles Tjoelker2011-03-011-0/+4
| | | | Notes: svn path=/head/; revision=219153
* printf: Do not use sh memory functions in sh builtin.Jilles Tjoelker2010-12-291-13/+0
| | | | | | | | | These functions throw exceptions if they fail, possibly causing memory leaks. The normal out-of-memory handling suffices. The INTOFF around almost all of printf prevents memory leaks due to SIGINT. Notes: svn path=/head/; revision=216809
* sh: Make warnings in the printf builtin non-fatal, like in the program.Jilles Tjoelker2010-12-201-17/+13
| | | | | | | | | | | The #define for warnx now behaves much like the libc function (except that it uses sh command name and output). Also, it now uses C99 __VA_ARGS__ so there is no need for three different macros for 0, 1 or 2 parameters. Notes: svn path=/head/; revision=216606
* Revert r216423 per request from Jilles.Xin LI2010-12-141-10/+10
| | | | | | | | | | The new behavior prevents us from being able to bail out explicitly on unknown options that we have not implemented. BASH for instance have introduced a '-v' for printf(1) builtin and it seems to be bad to pretend that we supported it and have a script break silently. Notes: svn path=/head/; revision=216447
* When printf is being used as a sh(1) builtin, it can not callXin LI2010-12-141-3/+1
| | | | | | | | | | exit(3) as pointed out by jilles@ so revert to using return(), also change the return value back to 1 as requested by bde@. This is logically a revert of revision 216422. Notes: svn path=/head/; revision=216439
* We work on ctype's and not only on numbers so set LC_ALL instead ofXin LI2010-12-141-1/+1
| | | | | | | | | | | LC_NUMERIC. PR: bin/152934 Submitted by: Pedro F. Giffuni <giffunip tutopia.com> Obtained from: Illumos Notes: svn path=/head/; revision=216424
* IEEE Std 1003.1-2008, Section 1.4, Utility Description Defaults saysXin LI2010-12-141-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | that when the options section is listed as "None", utility shall recognize "--" as a first argument to be discarded. This implementation is largely based on OpenBSD implementation but we do slightly differently: a) We skip argv[0] as the first step; b) We test whether the next argument is "--" and ignore it. With this change one will get: %printf usage: printf format [arguments ...] %printf -v -v%printf -- -v -v% %printf -- usage: printf format [arguments ...] Which matches the behavior observed on a Debian system but different from the Illumos change. Notes: svn path=/head/; revision=216423
* Make use of EX_USAGE for usage().Xin LI2010-12-141-2/+4
| | | | Notes: svn path=/head/; revision=216422
* The only caller of mknum() provides a char instead of an int, so make itXin LI2010-12-131-2/+2
| | | | | | | | | | | match the definition. PR: bin/152934 Submitted by: Pedro F. Giffuni <giffunip tutopia.com> Obtained from: Illumos Notes: svn path=/head/; revision=216418
* Move locale.h include to the beginning header section as pointed out byXin LI2010-12-131-3/+2
| | | | | | | | | style(9) Submitted by: Pedro F. Giffuni <giffunip tutopia.com> Notes: svn path=/head/; revision=216417
* Remove the advertising clause from UCB copyrighted files in usr.bin. ThisJoel Dahl2010-12-112-8/+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
* printf: Remove support for building as a csh builtin.Jilles Tjoelker2010-12-081-8/+2
| | | | | | | | | | | | | The #define BUILTIN was for building as a csh (not tcsh) builtin. Given that csh was replaced by tcsh years ago there is no point in keeping this. The #define SHELL is for building as an sh builtin and is in active use. This commit does not change the /bin/sh and /usr/bin/printf binaries. Notes: svn path=/head/; revision=216310
* sh: Add printf builtin.Jilles Tjoelker2010-11-192-7/+34
| | | | | | | | | | | | | | | | | | | | This was removed in 2001 but I think it is appropriate to add it back: * I do not want to encourage people to write fragile and non-portable echo commands by making printf much slower than echo. * Recent versions of Autoconf use it a lot. * Almost no software still wants to support systems that do not have printf(1) at all. * In many other shells printf is already a builtin. Side effect: printf is now always the builtin version (which behaves identically to /usr/bin/printf) and cannot be overridden via PATH (except via the undocumented %builtin mechanism). Code size increases about 5K on i386. Embedded folks might want to replace /usr/bin/printf with a hard link to /usr/bin/alias. Notes: svn path=/head/; revision=215520