aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/printf/printf.c
Commit message (Collapse)AuthorAgeFilesLines
* Sync program's usage() with manpage's SYNOPSIS.Ruslan Ermilov2005-05-211-1/+1
| | | | Notes: svn path=/head/; revision=146466
* Handle null characters in the format string. A \0 in the argument passed to %bStefan Farfeleder2005-04-141-7/+13
| | | | | | | still results in trucation but this is be much harder to fix. Notes: svn path=/head/; revision=145078
* No reason to write \a and \v as octal escape sequences.Stefan Farfeleder2005-04-141-2/+2
| | | | Notes: svn path=/head/; revision=145074
* - Move parts of the long main() function into a new function doformat().Stefan Farfeleder2005-04-141-152/+159
| | | | | | | - Rewrite the loop in main() to be more understandable. Notes: svn path=/head/; revision=145061
* Assign 0.0 to the variable passed to getfloating() if the argument is missing.Stefan Farfeleder2005-04-131-1/+3
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=145027
* Replace buggy for-loops to skip certain character with strspn(). If *fmt wasStefan Farfeleder2005-04-111-3/+3
| | | | | | | | | | '\0' (eg in the invocation 'printf %'), the for-loop would miss the terminating null character. MFC after: 1 week Notes: svn path=/head/; revision=144902
* Support the L modifier for floating-point values as an extension.David Schultz2005-03-211-6/+34
| | | | | | | | | 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. Notes: svn path=/head/; revision=143906
* Allow %' to be used as a format flag by printf(1). This makes itGiorgos Keramidas2004-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 Notes: svn path=/head/; revision=135751
* Enable support for the %a, %A, and %F format specifiers.David Schultz2004-06-051-1/+4
| | | | Notes: svn path=/head/; revision=130115
* Make it possible for the %[eEfgG] formats to not result in an errorColin Percival2004-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) Notes: svn path=/head/; revision=126729
* ANSIify function definitions.David Malone2002-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 Notes: svn path=/head/; revision=102944
* Fix duplicate % in %b format introduced in rev 1.22.Tim J. Robbins2002-06-191-5/+6
| | | | Notes: svn path=/head/; revision=98426
* Let printf(1) tell the difference between zero width/precision andTim J. Robbins2002-06-191-7/+9
| | | | | | | | | | | unspecified width/precision. PR: 39116 Submitted by: Egil Brendsdal <egilb@ife.no> MFC after: 1 week Notes: svn path=/head/; revision=98424
* Allow format strings containing "%%" to be reused.Tim J. Robbins2002-06-191-2/+2
| | | | | | | | | PR: 39116 Submitted by: Egil Brendsdal <egilb@ife.no> MFC after: 1 week Notes: svn path=/head/; revision=98420
* Allow `%' to be written out with an octal escape (\45 or \045).Tim J. Robbins2002-06-191-1/+5
| | | | | | | | | PR: 39116 Submitted by: Egil Brendsdal <egilb@ife.no> MFC after: 1 week Notes: svn path=/head/; revision=98419
* Handle numbers larger than QUAD_MAX for unsigned conversions correctly.Tim J. Robbins2002-04-251-50/+96
| | | | | | | | | | | Exit with nonzero status if a conversion failed. Play nice if used as a shell builtin (currently disabled). Submitted by: bde (partially) Approved by: mike Notes: svn path=/head/; revision=95409
* - printf shouldn't bail out if a conversion fails, it should just keepJuli Mallett2002-04-231-37/+66
| | | | | | | | | | | | | | | | | | processing them. - \c escape to immediately stop output (similar to echo's \c) - \0NNN should be allowed for octal character escapes (instead of just \NNN) - %b conversion, which is like %s but interprets \n \t etc. inside the string is missing. And I may not be any poet, but in lieu of an in-tree regression test: ref5% ./printf '%s%b%b%c%s%d\n' 'PR' '\0072' '\t' '3' '56' 0x10 PR: 35616 Submitted by: tjr MFC after: 1 week Notes: svn path=/head/; revision=95300
* remove __PWarner Losh2002-03-221-9/+9
| | | | Notes: svn path=/head/; revision=92921
* Warns cleanups.David Malone2001-12-031-5/+5
| | | | Notes: svn path=/head/; revision=87298
* Localize it (LC_NUMERIC)Andrey A. Chernov2001-02-101-0/+7
| | | | Notes: svn path=/head/; revision=72304
* Fix printf(1) for cases where a long string with no format specifiers isBen Smithurst2000-12-211-4/+16
| | | | | | | | | followed by a %d (probably others too) format specifier. Reviewed by: audit Notes: svn path=/head/; revision=70256
* When we have both a rcsid and sccsid, ifdef 0 the sccsid. ThisWarner Losh2000-09-041-0/+2
| | | | | | | | appears to be the standard FreeBSD way to do this. style(9) is silent about this, however. Notes: svn path=/head/; revision=65429
* Extend to deal with 64 bit numeric arguments.Stefan Eßer2000-07-101-14/+17
| | | | Notes: svn path=/head/; revision=62928
* Remove redundat extern declarationMartin Cracauer2000-04-201-1/+2
| | | | Notes: svn path=/head/; revision=59435
* Fixed warnx format errors in printf and csh, and snprintf format errorsBruce Evans1998-12-071-7/+11
| | | | | | | | | in sh, by using separate macros for the 1, 2 and 3-arg calls to warnx. (The 3-arg warnx macro in sh/bltin/bltin.h used to require bogus dummy args.) Notes: svn path=/head/; revision=41582
* Back out revision 1.10. It broke the build of sh, which compilesJohn Polstra1997-11-181-4/+5
| | | | | | | this file with warnx() defined as a macro. Notes: svn path=/head/; revision=31277
* Fix: too many arguments for format string in 4 calls to warnx().John Polstra1997-11-181-5/+4
| | | | Notes: svn path=/head/; revision=31224
* #include <unistd.h> for getopt(3) call.Steve Price1997-08-071-0/+1
| | | | Notes: svn path=/head/; revision=27966
* 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
* -Wall cleaning.Steve Price1996-12-141-2/+2
| | | | Notes: svn path=/head/; revision=20409
* Remove annoying -Wall warning.Steve Price1996-10-061-1/+1
| | | | Notes: svn path=/head/; revision=18732
* When used as a shell builtin, this program decoded a subset of argumentsPeter Wemm1996-10-011-4/+9
| | | | | | | | | | | | | | known to printf(3) and then used printf() to format it... The only problem what the #define printf out1fmt. The code was behaving differently when run as a shell builtin since out1fmt() isn't printf(3). Simple hack. Print to a buffer and fputs (also #defined for sh) the result. This should fix the printf builtin problem in PR#1673, rather than leaving the call commented out. (printf.o was being statically linked in anyway, we might as well use it) Notes: svn path=/head/; revision=18613
* Move out some of the shell builtin bogosity from printf's source toJoerg Wunsch1995-12-101-14/+1
| | | | | | | sh's builtin/bltin.h. Notes: svn path=/head/; revision=12730
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-2/+2
| | | | Notes: svn path=/head/; revision=8874
* Make the syntax checks for the format string more strict. The stringJoerg Wunsch1995-05-071-12/+19
| | | | | | | | | "%8*s" is no longer considered to be a valid format description. This closes PR bin/386. Notes: svn path=/head/; revision=8323
* BSD 4.4 Lite Usr.bin SourcesRodney W. Grimes1994-05-271-0/+410
Notes: svn path=/cvs2svn/branches/CHRISTOS/; revision=1590