diff options
author | schweikh <schweikh@FreeBSD.org> | 2001-10-28 18:35:32 +0000 |
---|---|---|
committer | schweikh <schweikh@FreeBSD.org> | 2001-10-28 18:35:32 +0000 |
commit | ff38fb0e7374ef63944abf0515667857eaa6d61d (patch) | |
tree | 6313506ef1f3566b1b2f1a39f9d191e935e0f8bf /usr.bin/indent/args.c | |
parent | 9b2eb27d345f3db1323f41df8b2ca6995de7e001 (diff) | |
download | FreeBSD-src-ff38fb0e7374ef63944abf0515667857eaa6d61d.zip FreeBSD-src-ff38fb0e7374ef63944abf0515667857eaa6d61d.tar.gz |
Make this compile cleanly when warnings are enabled:
- 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
Diffstat (limited to 'usr.bin/indent/args.c')
-rw-r--r-- | usr.bin/indent/args.c | 157 |
1 files changed, 80 insertions, 77 deletions
diff --git a/usr.bin/indent/args.c b/usr.bin/indent/args.c index 2e6821f..3693e1e 100644 --- a/usr.bin/indent/args.c +++ b/usr.bin/indent/args.c @@ -52,6 +52,7 @@ static const char rcsid[] = #include <stdlib.h> #include <string.h> #include "indent_globs.h" +#include "indent.h" /* profile types */ #define PRO_SPECIAL 1 /* special case */ @@ -69,6 +70,8 @@ static const char rcsid[] = #define STDIN 3 /* use stdin */ #define KEY 4 /* type (keyword) */ +static void scan_profile(FILE *); + char *option_source = "?"; /* @@ -85,80 +88,81 @@ struct pro { int *p_obj; /* the associated variable */ } pro[] = { - "T", PRO_SPECIAL, 0, KEY, 0, - "bacc", PRO_BOOL, false, ON, &blanklines_around_conditional_compilation, - "badp", PRO_BOOL, false, ON, &blanklines_after_declarations_at_proctop, - "bad", PRO_BOOL, false, ON, &blanklines_after_declarations, - "bap", PRO_BOOL, false, ON, &blanklines_after_procs, - "bbb", PRO_BOOL, false, ON, &blanklines_before_blockcomments, - "bc", PRO_BOOL, true, OFF, &ps.leave_comma, - "bl", PRO_BOOL, true, OFF, &btype_2, - "br", PRO_BOOL, true, ON, &btype_2, - "bs", PRO_BOOL, false, ON, &Bill_Shannon, - "cdb", PRO_BOOL, true, ON, &comment_delimiter_on_blankline, - "cd", PRO_INT, 0, 0, &ps.decl_com_ind, - "ce", PRO_BOOL, true, ON, &cuddle_else, - "ci", PRO_INT, 0, 0, &continuation_indent, - "cli", PRO_SPECIAL, 0, CLI, 0, - "c", PRO_INT, 33, 0, &ps.com_ind, - "di", PRO_INT, 16, 0, &ps.decl_indent, - "dj", PRO_BOOL, false, ON, &ps.ljust_decl, - "d", PRO_INT, 0, 0, &ps.unindent_displace, - "eei", PRO_BOOL, false, ON, &extra_expression_indent, - "ei", PRO_BOOL, true, ON, &ps.else_if, - "fbc", PRO_FONT, 0, 0, (int *) &blkcomf, - "fbx", PRO_FONT, 0, 0, (int *) &boxcomf, - "fb", PRO_FONT, 0, 0, (int *) &bodyf, - "fc1", PRO_BOOL, true, ON, &format_col1_comments, - "fcb", PRO_BOOL, true, ON, &format_block_comments, - "fc", PRO_FONT, 0, 0, (int *) &scomf, - "fk", PRO_FONT, 0, 0, (int *) &keywordf, - "fs", PRO_FONT, 0, 0, (int *) &stringf, - "ip", PRO_BOOL, true, ON, &ps.indent_parameters, - "i", PRO_INT, 8, 0, &ps.ind_size, - "lc", PRO_INT, 0, 0, &block_comment_max_col, - "lp", PRO_BOOL, true, ON, &lineup_to_parens, - "l", PRO_INT, 78, 0, &max_col, - "nbacc", PRO_BOOL, false, OFF, &blanklines_around_conditional_compilation, - "nbadp", PRO_BOOL, false, OFF, &blanklines_after_declarations_at_proctop, - "nbad", PRO_BOOL, false, OFF, &blanklines_after_declarations, - "nbap", PRO_BOOL, false, OFF, &blanklines_after_procs, - "nbbb", PRO_BOOL, false, OFF, &blanklines_before_blockcomments, - "nbc", PRO_BOOL, true, ON, &ps.leave_comma, - "nbs", PRO_BOOL, false, OFF, &Bill_Shannon, - "ncdb", PRO_BOOL, true, OFF, &comment_delimiter_on_blankline, - "nce", PRO_BOOL, true, OFF, &cuddle_else, - "ndj", PRO_BOOL, false, OFF, &ps.ljust_decl, - "neei", PRO_BOOL, false, OFF, &extra_expression_indent, - "nei", PRO_BOOL, true, OFF, &ps.else_if, - "nfc1", PRO_BOOL, true, OFF, &format_col1_comments, - "nfcb", PRO_BOOL, true, OFF, &format_block_comments, - "nip", PRO_BOOL, true, OFF, &ps.indent_parameters, - "nlp", PRO_BOOL, true, OFF, &lineup_to_parens, - "npcs", PRO_BOOL, false, OFF, &proc_calls_space, - "npro", PRO_SPECIAL, 0, IGN, 0, - "npsl", PRO_BOOL, true, OFF, &procnames_start_line, - "nps", PRO_BOOL, false, OFF, &pointer_as_binop, - "nsc", PRO_BOOL, true, OFF, &star_comment_cont, - "nsob", PRO_BOOL, false, OFF, &swallow_optional_blanklines, - "nv", PRO_BOOL, false, OFF, &verbose, - "pcs", PRO_BOOL, false, ON, &proc_calls_space, - "psl", PRO_BOOL, true, ON, &procnames_start_line, - "ps", PRO_BOOL, false, ON, &pointer_as_binop, - "sc", PRO_BOOL, true, ON, &star_comment_cont, - "sob", PRO_BOOL, false, ON, &swallow_optional_blanklines, - "st", PRO_SPECIAL, 0, STDIN, 0, - "troff", PRO_BOOL, false, ON, &troff, - "v", PRO_BOOL, false, ON, &verbose, + {"T", PRO_SPECIAL, 0, KEY, 0}, + {"bacc", PRO_BOOL, false, ON, &blanklines_around_conditional_compilation}, + {"badp", PRO_BOOL, false, ON, &blanklines_after_declarations_at_proctop}, + {"bad", PRO_BOOL, false, ON, &blanklines_after_declarations}, + {"bap", PRO_BOOL, false, ON, &blanklines_after_procs}, + {"bbb", PRO_BOOL, false, ON, &blanklines_before_blockcomments}, + {"bc", PRO_BOOL, true, OFF, &ps.leave_comma}, + {"bl", PRO_BOOL, true, OFF, &btype_2}, + {"br", PRO_BOOL, true, ON, &btype_2}, + {"bs", PRO_BOOL, false, ON, &Bill_Shannon}, + {"cdb", PRO_BOOL, true, ON, &comment_delimiter_on_blankline}, + {"cd", PRO_INT, 0, 0, &ps.decl_com_ind}, + {"ce", PRO_BOOL, true, ON, &cuddle_else}, + {"ci", PRO_INT, 0, 0, &continuation_indent}, + {"cli", PRO_SPECIAL, 0, CLI, 0}, + {"c", PRO_INT, 33, 0, &ps.com_ind}, + {"di", PRO_INT, 16, 0, &ps.decl_indent}, + {"dj", PRO_BOOL, false, ON, &ps.ljust_decl}, + {"d", PRO_INT, 0, 0, &ps.unindent_displace}, + {"eei", PRO_BOOL, false, ON, &extra_expression_indent}, + {"ei", PRO_BOOL, true, ON, &ps.else_if}, + {"fbc", PRO_FONT, 0, 0, (int *) &blkcomf}, + {"fbx", PRO_FONT, 0, 0, (int *) &boxcomf}, + {"fb", PRO_FONT, 0, 0, (int *) &bodyf}, + {"fc1", PRO_BOOL, true, ON, &format_col1_comments}, + {"fcb", PRO_BOOL, true, ON, &format_block_comments}, + {"fc", PRO_FONT, 0, 0, (int *) &scomf}, + {"fk", PRO_FONT, 0, 0, (int *) &keywordf}, + {"fs", PRO_FONT, 0, 0, (int *) &stringf}, + {"ip", PRO_BOOL, true, ON, &ps.indent_parameters}, + {"i", PRO_INT, 8, 0, &ps.ind_size}, + {"lc", PRO_INT, 0, 0, &block_comment_max_col}, + {"lp", PRO_BOOL, true, ON, &lineup_to_parens}, + {"l", PRO_INT, 78, 0, &max_col}, + {"nbacc", PRO_BOOL, false, OFF, &blanklines_around_conditional_compilation}, + {"nbadp", PRO_BOOL, false, OFF, &blanklines_after_declarations_at_proctop}, + {"nbad", PRO_BOOL, false, OFF, &blanklines_after_declarations}, + {"nbap", PRO_BOOL, false, OFF, &blanklines_after_procs}, + {"nbbb", PRO_BOOL, false, OFF, &blanklines_before_blockcomments}, + {"nbc", PRO_BOOL, true, ON, &ps.leave_comma}, + {"nbs", PRO_BOOL, false, OFF, &Bill_Shannon}, + {"ncdb", PRO_BOOL, true, OFF, &comment_delimiter_on_blankline}, + {"nce", PRO_BOOL, true, OFF, &cuddle_else}, + {"ndj", PRO_BOOL, false, OFF, &ps.ljust_decl}, + {"neei", PRO_BOOL, false, OFF, &extra_expression_indent}, + {"nei", PRO_BOOL, true, OFF, &ps.else_if}, + {"nfc1", PRO_BOOL, true, OFF, &format_col1_comments}, + {"nfcb", PRO_BOOL, true, OFF, &format_block_comments}, + {"nip", PRO_BOOL, true, OFF, &ps.indent_parameters}, + {"nlp", PRO_BOOL, true, OFF, &lineup_to_parens}, + {"npcs", PRO_BOOL, false, OFF, &proc_calls_space}, + {"npro", PRO_SPECIAL, 0, IGN, 0}, + {"npsl", PRO_BOOL, true, OFF, &procnames_start_line}, + {"nps", PRO_BOOL, false, OFF, &pointer_as_binop}, + {"nsc", PRO_BOOL, true, OFF, &star_comment_cont}, + {"nsob", PRO_BOOL, false, OFF, &swallow_optional_blanklines}, + {"nv", PRO_BOOL, false, OFF, &verbose}, + {"pcs", PRO_BOOL, false, ON, &proc_calls_space}, + {"psl", PRO_BOOL, true, ON, &procnames_start_line}, + {"ps", PRO_BOOL, false, ON, &pointer_as_binop}, + {"sc", PRO_BOOL, true, ON, &star_comment_cont}, + {"sob", PRO_BOOL, false, ON, &swallow_optional_blanklines}, + {"st", PRO_SPECIAL, 0, STDIN, 0}, + {"troff", PRO_BOOL, false, ON, &troff}, + {"v", PRO_BOOL, false, ON, &verbose}, /* whew! */ - 0, 0, 0, 0, 0 + {0, 0, 0, 0, 0} }; /* * set_profile reads $HOME/.indent.pro and ./.indent.pro and handles arguments * given in these files. */ -set_profile() +void +set_profile(void) { register FILE *f; char fname[BUFSIZ]; @@ -176,8 +180,8 @@ set_profile() option_source = "Command line"; } -scan_profile(f) - register FILE *f; +static void +scan_profile(register FILE *f) { register int i; register char *p; @@ -196,11 +200,10 @@ scan_profile(f) } } -char *param_start; +char *param_start; -eqin(s1, s2) - register char *s1; - register char *s2; +static int +eqin(char *s1, char *s2) { while (*s1) { if (*s1++ != *s2++) @@ -213,7 +216,8 @@ eqin(s1, s2) /* * Set the defaults. */ -set_defaults() +void +set_defaults(void) { register struct pro *p; @@ -227,11 +231,10 @@ set_defaults() *p->p_obj = p->p_default; } -set_option(arg) - register char *arg; +void +set_option(char *arg) { register struct pro *p; - extern double atof(); arg++; /* ignore leading "-" */ for (p = pro; p->p_name; p++) |