aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/indent/indent.c
Commit message (Collapse)AuthorAgeFilesLines
...
* indent(1): Consistently indent declarations.Pedro F. Giffuni2016-07-311-80/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a very visible issue that may be hidden by some indent.pro settings as in the example from FreeBSD's /usr/share. From Piotr's log: ____ To prevent losing tabs from indentation in declarations, FreeBSD indent's r125624 added code for the most common case when it's an identifier that is indented, but didn't do anything with the original code that did the same for any other cases. The other cases are: lparens (function pointer declaration), asterisks (pointer declaration), stray semicolons, and commas leading identifiers instead of trailing them. Use the code added in r125624 (and improved in later commits) to write a new function indent_declaration() and use it in all places that meant to indent declarations. In order to indent only once per line, reuse existing ps.dumped_decl_indent variable that was only used when formatting for troff (-troff) until now. ____ Reference: https://github.com/pstef/freebsd_indent/commit/ddd263db2a59978f43468989eff65299cf3ce7e1 Differential Revision: https://reviews.freebsd.org/D6966 (Partial) Submitted by: Piotr Stefaniak Notes: svn path=/head/; revision=303570
* Use nitems() from sys/param.h.Marcelo Araujo2016-07-301-1/+1
| | | | | | | | MFC after: 2 weeks. Sponsored by: gandi.net (BSD Day Taiwan) Notes: svn path=/head/; revision=303547
* indent(1): Yet more style issues.Pedro F. Giffuni2016-07-301-3/+3
| | | | | | | | | | | strchr(3) returns a pointer not a boolean. Attempt to make the style somewhat more ocnsistent with what indent had before recent changes. Pointed out by: bde Notes: svn path=/head/; revision=303525
* indent(1): Attempt to preserve some consistent style.Pedro F. Giffuni2016-07-291-4/+3
| | | | | | | | | | | Remove the excessive braces from r303485 and align the comments to the right as done in the rest of the code. This is not nice but there is no clear way to make it nice (and KNF). Pointed out by: bde Notes: svn path=/head/; revision=303523
* indent(1): Use NULL instead of zero for pointers.Pedro F. Giffuni2016-07-291-13/+13
| | | | Notes: svn path=/head/; revision=303502
* indent(1): fix struct termination detection.Pedro F. Giffuni2016-07-291-2/+4
| | | | | | | | | | Semicolons inside struct declarations don't end the declarations. Differential Revision: https://reviews.freebsd.org/D6966 (Partial) Obtained from: Piotr Stefaniak Notes: svn path=/head/; revision=303485
* indent(1): Fix breakage caused by single comment following "else".Pedro F. Giffuni2016-07-291-0/+2
| | | | | | | | | | | | indent(1) simply wasn't taught that "else" may be followed by a comment without any opening brace anywhere on the line, so it was very confused in such cases. Differential Revision: https://reviews.freebsd.org/D6966 (Partial) Obtained from: Piotr Stefaniak Notes: svn path=/head/; revision=303484
* indent(1): Avoid out of bound access of array codebuf.Pedro F. Giffuni2016-07-291-1/+3
| | | | | | | | | | dump_line() requires s_code to be a string, because it will call count_spaces(). Differential Revision: https://reviews.freebsd.org/D6966 (Partial) Obtained from: Piotr Stefaniak Notes: svn path=/head/; revision=303482
* indent: avoid calling write(2) with a negative second parameter.Pedro F. Giffuni2016-07-281-1/+1
| | | | | | | | | | negative_returns: n is passed to a parameter that cannot be negative. Fix a style issue while here. CID: 1008107 Notes: svn path=/head/; revision=303452
* Spelling fixes for usr.bin/Ulrich Spörlein2011-12-301-4/+4
| | | | Notes: svn path=/head/; revision=228992
* Use NULL instead of 0 when setting up pointer.Kevin Lo2010-08-101-8/+8
| | | | Notes: svn path=/head/; revision=211132
* indent(1): correctly handle case/label at the very start of a functionAndriy Gapon2010-03-311-1/+1
| | | | | | | | Obtained from: NetBSD (rev. 1.11 of indent.c) MFC after: 1 week Notes: svn path=/head/; revision=205988
* initialize variable (WARNS=6)Philippe Charnier2006-09-131-0/+1
| | | | Notes: svn path=/head/; revision=162264
* Declare find_err in indent_globs.h where the other shared variablesDavid Malone2005-11-131-2/+0
| | | | | | | live rather than listing it as an extern in indent.c. Notes: svn path=/head/; revision=152395
* Fix problems with non-8 space tabs. New options for functionJens Schweikhardt2004-06-271-9/+29
| | | | | | | | | | | | | | declarations with the opening brace on the same line as the declaration of arguments all spaces and no tabs (a feature which exists in GNU's indent). Man page update to follow RSN. PR: bin/67983 Submitted by: Chip Norkus <wd@teleri.net> Style guidance and bug for bug compatibility by: bde MFC after: 2 weeks Notes: svn path=/head/; revision=131184
* Added an option -ldi<N> to control indentation of local variable names.Bruce Evans2004-02-091-2/+14
| | | | | | | | | | | | | | | The default is to be backwards compatible and non-KNF (use the same indentation for locals as for globals; -ldi0 gives KNF indentation for locals (none)). The indentation for globals also applies to struct member names in local declatations. The indentation of variable names in multi-line declarations is broken in various ways and this commit gives some new variations. indent.1: Also clarified the description of -di<N>. Notes: svn path=/head/; revision=125633
* Only use tabs to indent variable names if the declaration indent isBruce Evans2004-02-091-8/+8
| | | | | | | | | | | nonzero (so that the 1-char indentation given by -di0 is never rendered by a tab). Removed garbage commented out code for setting the indentation of variable names. Notes: svn path=/head/; revision=125631
* Backed out a part of previous commit that wasn;t mentioned in the logBruce Evans2004-02-091-2/+1
| | | | | | | | message and wasn't quite ready (it avoided indenting the names of local variables). Notes: svn path=/head/; revision=125629
* Fixed tab lossage in indented variable names. The -diN option wasBruce Evans2004-02-091-6/+22
| | | | | | | | | | worse than useless because it caused things like mangling of "^int\tfoo" to "int foo" (this for N = 8). This quick fix breaks the invariant that characters between s_code and e_code have width 1, but nothing seems to depend on this. Notes: svn path=/head/; revision=125624
* err() on allocation failure. WARNS=9 compliantPhilippe Charnier2003-06-151-9/+19
| | | | | | | | use #if 0, #ifndef lint, #endif /* not lint */, #endif ordering when a message is provided, use errx() instead of err(). Notes: svn path=/head/; revision=116390
* Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,Jens Schweikhardt2003-01-011-3/+3
| | | | | | | especially in troff files. Notes: svn path=/head/; revision=108533
* SpellingPhilippe Charnier2002-10-161-3/+3
| | | | Notes: svn path=/head/; revision=105244
* Consistently use FBSDIDDavid E. O'Brien2002-06-301-2/+2
| | | | Notes: svn path=/head/; revision=99112
* Remove deprecated register qualifier.Juli Mallett2002-06-241-4/+4
| | | | Notes: svn path=/head/; revision=98771
* 1) Const enough things to avoid warnings.David Malone2002-03-301-8/+8
| | | | | | | | | | | 2) Cast ifdef_level to a size_t before comparing it to a ratio of size_ts. Ifdef_level should always be positive. 3) Complete prototype for chfont. 4) Cast some ptrdiff_ts to ints before using as a field width. 5) Avoid shadowing a local variable p with another local variable p. Notes: svn path=/head/; revision=93440
* Make this compile cleanly when warnings are enabled:Jens Schweikhardt2001-10-281-44/+38
| | | | | | | | | | | | | | | | | - ANSIfy function declarations - braces around initializers structs within structs - add parens in complicated expressions - disambiguate dangling elses - no more implicit int - make functions static where possible - use prototypes - don't use varargs hack for diag() Requested by: joerg MFC after: 2 weeks Notes: svn path=/head/; revision=85632
* Fix indent endless on garbage input (i.e., if it encountered EOF whileDavid E. O'Brien2001-02-271-1/+1
| | | | | | | | | waiting for a '}' nesting terminator) Obtained from: OpenBSD rev 1.8 Notes: svn path=/head/; revision=73175
* Preceed/preceeding are not english words. Use precede and preceding.Jeroen Ruigrok van der Werven2001-02-181-1/+1
| | | | Notes: svn path=/head/; revision=72645
* Don't abuse the SCCS `@(#)' for RCS.David E. O'Brien2000-12-251-1/+1
| | | | | | | Requested by: bde Notes: svn path=/head/; revision=70342
* Add or fix FreeBSD IDs.David E. O'Brien2000-12-091-1/+1
| | | | Notes: svn path=/head/; revision=69796
* "Implement -[n]fcb (formatting of block comments) and attempt to implementDavid E. O'Brien2000-12-091-2/+4
| | | | | | | | | | no-space=after-sizeof (not optional) and no-space-after 'struct foo *' (not optional). Without these, indent unKNFizes even more perfectly KNF code." Submitted by: bde Notes: svn path=/head/; revision=69795
* Don't call err() with no format string.Kris Kennaway2000-07-101-7/+7
| | | | Notes: svn path=/head/; revision=62894
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Clean up some ambiguous nested if/elses.Bill Fumerola1999-07-041-4/+4
| | | | Notes: svn path=/head/; revision=48566
* PR: 7583Peter Hawkins1998-10-181-4/+4
| | | | | | | | Submitted by: Dave Glowacki <dglo@SSEC.WISC.EDU> Support input via stdin if no input file name specified explicitly Notes: svn path=/head/; revision=40502
* Use err(3) instead of local redefinition. Add usage().Philippe Charnier1997-07-151-24/+25
| | | | Notes: svn path=/head/; revision=27419
* BSD 4.4 Lite Usr.bin SourcesRodney W. Grimes1994-05-271-0/+1181
Notes: svn path=/cvs2svn/branches/CHRISTOS/; revision=1590