summaryrefslogtreecommitdiffstats
path: root/usr.bin/printf
Commit message (Collapse)AuthorAgeFilesLines
* POSIX requires that non-existent or null arguments be treated as if aeadler2012-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
* sh: Prefer internal nextopt() to libc getopt().jilles2012-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.
* Remove trailing whitespace per mdoc lint warningeadler2012-03-291-1/+1
| | | | | | | Disussed with: gavin No objection from: doc Approved by: joel MFC after: 3 days
* Style cleanups for printf.pfg2012-01-121-18/+18
| | | | | | | PR: bin/152934 Approved by: jhb (mentor) Obtained from: Illumos MFC after: 2 weeks
* printf(1): Document that %c and precision for %b/%s use bytes, not chars.jilles2011-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.
* printf: Allow multibyte characters for '<char> form, avoid negative codes.jilles2011-05-282-7/+20
| | | | | | | | | | | | | 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.
* printf(1): Move non-bugs from the BUGS section to a new section CAVEATS.jilles2011-04-251-10/+10
|
* printf(1): Mention effect of '#' modifier on other conversions.jilles2011-04-251-5/+5
|
* printf: Note that this is used both as a normal program and a shell builtin.jilles2011-03-011-0/+4
|
* printf: Do not use sh memory functions in sh builtin.jilles2010-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.
* sh: Make warnings in the printf builtin non-fatal, like in the program.jilles2010-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.
* Revert r216423 per request from Jilles.delphij2010-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.
* When printf is being used as a sh(1) builtin, it can not calldelphij2010-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.
* We work on ctype's and not only on numbers so set LC_ALL instead ofdelphij2010-12-141-1/+1
| | | | | | | | LC_NUMERIC. PR: bin/152934 Submitted by: Pedro F. Giffuni <giffunip tutopia.com> Obtained from: Illumos
* IEEE Std 1003.1-2008, Section 1.4, Utility Description Defaults saysdelphij2010-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.
* Make use of EX_USAGE for usage().delphij2010-12-141-2/+4
|
* The only caller of mknum() provides a char instead of an int, so make itdelphij2010-12-131-2/+2
| | | | | | | | match the definition. PR: bin/152934 Submitted by: Pedro F. Giffuni <giffunip tutopia.com> Obtained from: Illumos
* Move locale.h include to the beginning header section as pointed out bydelphij2010-12-131-3/+2
| | | | | | style(9) Submitted by: Pedro F. Giffuni <giffunip tutopia.com>
* Remove the advertising clause from UCB copyrighted files in usr.bin. Thisjoel2010-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
* printf: Remove support for building as a csh builtin.jilles2010-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.
* sh: Add printf builtin.jilles2010-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.
* Note bug in trying to printf(1) things like: '-%s\n' "foo"obrien2010-09-091-0/+7
|
* printf(1): Clarify that \OOO produces a byte, different %b escape sequences.jilles2010-09-051-4/+10
| | | | | | | | Octal escape sequences are expanded to bytes, not characters, and multiple are required for a multibyte character. The valid escape sequences in %b strings are slightly different from the escape sequences in the format string.
* Build usr.bin/ with WARNS=6 by default.ed2010-01-021-1/+0
| | | | Also add some missing $FreeBSD$ to keep svn happy.
* POSIX says that octal escapes have the format \ddd in the format string,das2008-08-021-1/+2
| | | | | | | | | but \0ddd in a %b argument, with a length restriction of 3 octal digits in either case. This seems silly, but it needs to be right so it's possible to write an octal escape followed by an ordinary digit. Solaris printf(1) and GNU printf(1) also behave this way. Example: "printf '\0752'" now produces "=2" instead of garbage.
* Prefer {u,}intmax_t over the deprecated {u_,}quad_t.stefanf2005-08-051-17/+18
|
* Markup and wording fixes.ru2005-06-141-1/+1
| | | | Approved by: re (blanket)
* Sync program's usage() with manpage's SYNOPSIS.ru2005-05-211-1/+1
|
* Update the bugs section, null characters in the format string are now handled.stefanf2005-04-141-6/+4
|
* Handle null characters in the format string. A \0 in the argument passed to %bstefanf2005-04-141-7/+13
| | | | still results in trucation but this is be much harder to fix.
* No reason to write \a and \v as octal escape sequences.stefanf2005-04-141-2/+2
|
* Printf(1) is WARNS 6 clean.stefanf2005-04-141-0/+1
|
* - Move parts of the long main() function into a new function doformat().stefanf2005-04-141-153/+160
| | | | - Rewrite the loop in main() to be more understandable.
* Assign 0.0 to the variable passed to getfloating() if the argument is missing.stefanf2005-04-131-1/+3
| | | | MFC after: 1 week
* Replace buggy for-loops to skip certain character with strspn(). If *fmt wasstefanf2005-04-111-3/+3
| | | | | | | '\0' (eg in the invocation 'printf %'), the for-loop would miss the terminating null character. MFC after: 1 week
* Support the L modifier for floating-point values as an extension.das2005-03-212-6/+44
| | | | | | When L is omitted, double precision is used, so printf(1) gives reproducable results. When L is specified, long double precision is used, which may improve precision, depending on the machine.
* Added the EXIT STATUS section where appropriate.ru2005-01-171-1/+1
|
* Allow %' to be used as a format flag by printf(1). This makes itkeramida2004-09-241-1/+1
| | | | | | | | | | possible to print the thousands separator in the locale setups that have one, by something like this: $ env -i LC_NUMERIC=en_US.ISO8859-1 ./printf "%'0.2f\n" 12345 12,345.00 Reviewed by: das
* Fix a markup nit and a misplaced full stop in previous.tjr2004-07-031-2/+2
| | | | Noticed by: ru
* Document missing multibyte character support in utilities specifiedtjr2004-07-031-1/+6
| | | | by POSIX.
* Deal with double whitespace.ru2004-07-031-4/+4
|
* Mechanically kill hard sentence breaks.ru2004-07-021-7/+14
|
* s/latter/former/das2004-06-051-1/+1
|
* - Document the %a, %A, and %F format specifiers.das2004-06-051-3/+31
| | | | | - Document the way infinity and NaN are printed. - Un-document the non-existent %w specifier.
* Enable support for the %a, %A, and %F format specifiers.das2004-06-051-1/+4
|
* Make it possible for the %[eEfgG] formats to not result in an errorcperciva2004-03-071-1/+1
| | | | | | | | | | being reported by /usr/bin/printf. This bug has been around for 22 months... either nobody uses printf with floating-point values, or people are forgetting to check their return codes. Approved by: rwatson (mentor)
* ANSIify function definitions.dwmalone2002-09-041-25/+14
| | | | | | | | | 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
* Kill excessive whitespace between macro arguments.keramida2002-07-151-5/+5
|
* Fix duplicate % in %b format introduced in rev 1.22.tjr2002-06-191-5/+6
|
* Let printf(1) tell the difference between zero width/precision andtjr2002-06-191-7/+9
| | | | | | | | unspecified width/precision. PR: 39116 Submitted by: Egil Brendsdal <egilb@ife.no> MFC after: 1 week
OpenPOWER on IntegriCloud