diff -x '*.po' -x '*.gmo' -x '*.html' -x '*.info' -x '*.gz' -x version.texi -x '*.pot' -x texinfo2man.c -x stamp-vti -x '*.1' -x xx.x -Naur indent-2.2.9/ChangeLog indent-dpv/ChangeLog --- indent-2.2.9/ChangeLog 2002-12-16 11:31:10.000000000 -0500 +++ indent-dpv/ChangeLog 2004-04-01 06:24:48.000000000 -0500 @@ -1,3 +1,19 @@ +2004-03-31 Daniel P. Valentine + * args.c: Added new options -icb, -nicb, -bbbo, and -nbbbo, supporting the + indentation of closing braces and preferring a break before any binary + operator, with precendence. + * indent.c: Added optional calls to set_buf_break before a binary operator + and before a structure delimiter ('.' or "->"). Made the setting of + flushed_nl dependent on -hnl so that --ignore-newlines would work inside + search-braces. + * indent.h: Added same options to settings. + * io.h: added to the breakpoint enum for breaks before each binary + operator type. + * output.c: Added pre-operator breaks to the break-type case statement and + to the determination of break type. Fixed the handling of breaks in + nested parentheses so that a break between a one-byte identifier and an + lparen sets the target column to the offset rather than -1. (< became <=). + * parse.c: Added optional leaving-alone of indent upon closing a brace. 2002-12-16 gettextize * Makefile.am (SUBDIRS): Add intl, diff -x '*.po' -x '*.gmo' -x '*.html' -x '*.info' -x '*.gz' -x version.texi -x '*.pot' -x texinfo2man.c -x stamp-vti -x '*.1' -x xx.x -Naur indent-2.2.9/doc/indent.texinfo indent-dpv/doc/indent.texinfo --- indent-2.2.9/doc/indent.texinfo 2002-11-10 16:02:48.000000000 -0500 +++ indent-dpv/doc/indent.texinfo 2004-04-04 08:05:11.000000000 -0400 @@ -28,7 +28,7 @@ @c @vskip 0pt plus 1filll @c !BEGIN COPYING -Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. +Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 2004 Free Software Foundation, Inc. Copyright (C) 1995, 1996 Joseph Arceneaux. Copyright (C) 1999 Carlo Wood. Copyright (C) 2001 David Ingamells. @@ -65,6 +65,7 @@ @author Joseph Arceneaux @author Jim Kingdon @author David Ingamells address@hidden Daniel P. Valentine @c !END AUTHORS @page @vskip 0pt plus1filll @@ -348,9 +349,9 @@ @example @group --nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2 --ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -nprs -psl -saf -sai --saw -nsc -nsob +-nbad -bap -nbc -bbbo -bbo -bl -bli2 -bls -ncdb -nce -cp1 +-cs -di2 -ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -nprs -psl +-saf -sai -saw -nsc -nsob @end group @end example @@ -373,9 +374,9 @@ @example @group --nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 --cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs --nprs -npsl -saf -sai -saw -nsc -nsob -nss +-nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 +-cli0 -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 +-lp -npcs -nprs -npsl -saf -sai -saw -nsc -nsob -nss @end group @end example @@ -752,6 +753,24 @@ @end group @end example address@hidden -icb address@hidden --indent-closing-brace +Many people stop indenting when the enclosed text is done, and put +the closing brace at the same indentation as the line with the opening brace. +The @option{-icb} option allows you to leave the brace at the same indentation +level as the enclosed code. As a result, when you scan down the program, the +next thing that pops out at you is the next item after the block you are +skipping over, not the end of that block. @option{-icb} (with @option{-br}) +results in the following. + address@hidden address@hidden +if (x > 0) @{ + x--; + @} address@hidden group address@hidden example + @kindex -ce @kindex --cuddle-else @kindex -dce @@ -1270,11 +1289,15 @@ @kindex --break-before-boolean-operator @kindex -nbbo @kindex --break-after-boolean-operator address@hidden -bbbo address@hidden --break-before-binary-operator address@hidden -nbbbo address@hidden --break-after-binary-operator @kindex -hnl @kindex --honour-newlines @kindex -nhnl @kindex --ignore-newlines -Currently there are two options that allows one to interfere with the +Currently there are three options that allows one to interfere with the algorithm that determines where to break a line. The @option{-bbo} option causes GNU @command{indent} to prefer to break @@ -1304,6 +1327,54 @@ @end group @end example +The @option{-bbbo} option causes GNU @command{indent} to prefer to break +long lines before the other binary operators (@code{==}, @code{!=}, @code{<=}, address@hidden>=}, @code{>}, @code{<}, @code{<<}, @code{>>}, @code{|}, @code{&}, address@hidden, @code{/}, @code{%}, @code{+}, @code{-}, @code{^}, @code{.}, @code{->}, address@hidden, etc.). The @option{-nbbbo} option causes GNU @command{indent} not +have that preference. This has the effect of starting continuation lines with +an operator so as not to give the reader of code the impression that a new +line might be starting here. As mentioned in the GNU coding standards, it +is useful to use parentheses to ensure that subordinate operators are indented +further than those of hiegher precedence. + +For example, the default option @option{-bbbo} (together with address@hidden and @option{--ignore-newlines}) makes code +look like this: + address@hidden address@hidden + char *default_error + = "This error message is longer than fits on a line"; + + change_ratio + = ((last_year_amount == 0) + ? ((this_year_amount + - last_year_amount) / last_year_amount) + : INT_MAX); + address@hidden group address@hidden example + +Using the option @option{-nbbbo} will make it look like this: + address@hidden address@hidden + char *default_error = + "This error message is longer than fits on a line"; + + change_ratio = + ((last_year_amount == + 0) ? ((this_year_amount - + last_year_amount) / + last_year_amount) : INT_MAX); address@hidden group address@hidden example + +(Note that this comparison is slightly unflattering to -nbbbo because +the prioritization of breaks at @code{?} and @code{:} was only added +for the @option{-bbbo} option.) + The default @option{-hnl}, however, honours newlines in the input file by giving them the highest possible priority to break lines at. For example, when the input file looks like this: @@ -1497,6 +1568,11 @@ Force blank lines before block address@hidden @xref{Blank lines}. address@hidden -bbbo address@hidden --break-before-binary-operator +Prefer to break long lines before any binary address@hidden address@hidden long lines}. + @item -bbo @itemx --break-before-boolean-operator Prefer to break long lines before boolean address@hidden @@ -1635,6 +1711,11 @@ Set indentation level to @var{n} address@hidden @xref{Indentation}. address@hidden -icb address@hidden --indent-closing-brace +Print the closing brace before releasing the enclosed address@hidden address@hidden + @item address@hidden @itemx address@hidden Indent parameter types in old-style function @@ -1684,6 +1765,11 @@ @xref{Blank lines}. @end ignore address@hidden -nbbbo address@hidden --break-after-binary-operator +Prefer to break long lines after any binary address@hidden address@hidden long lines}. + @item -nbbo @itemx --break-after-boolean-operator Do not prefer to break long lines before boolean address@hidden @@ -1923,7 +2009,9 @@ \line{ --braces-after-if-line \leaderfill -bl\ \ } \line{ --brace-indent \leaderfill address@hidden \line{ --braces-after-struct-decl-line \leaderfill -bls\ \ } +\line{ --break-after-binary-operator \leaderfill -nbbbo\ \ } \line{ --break-after-boolean-operator \leaderfill -nbbo\ \ } +\line{ --break-before-binary-operator \leaderfill -bbbo\ \ } \line{ --break-before-boolean-operator \leaderfill -bbo\ \ } \line{ --break-function-decl-args \leaderfill -bfda} \line{ --break-function-decl-args-end \leaderfill -bfde} @@ -1956,6 +2044,7 @@ \line{ --honour-newlines \leaderfill -hnl\ \ } \line{ --ignore-newlines \leaderfill -nhnl\ \ } \line{ --ignore-profile \leaderfill -npro} +\line{ --indent-closing-brace \leaderfill -icb\ } \line{ --indent-level \leaderfill address@hidden \ } \line{ --k-and-r-style \leaderfill -kr\ \ } \line{ --leave-optional-blank-lines \leaderfill -nsob} @@ -2009,7 +2098,9 @@ --braces-after-struct-decl-line -bls --braces-on-if-line -br --braces-on-struct-decl-line -brs +--break-after-binary-operator -nbbbo --break-after-boolean-operator -nbbo +--break-before-binary-operator -bbbo --break-before-boolean-operator -bbo --break-function-decl-args -bfda --break-function-decl-args-end -bfde @@ -2041,6 +2132,7 @@ --ignore-newlines -nhnl --ignore-profile -npro --indent-level address@hidden +--indent-closing-brace -icb --k-and-r-style -kr --leave-optional-blank-lines -nsob --leave-preprocessor-space -lps diff -x '*.po' -x '*.gmo' -x '*.html' -x '*.info' -x '*.gz' -x version.texi -x '*.pot' -x texinfo2man.c -x stamp-vti -x '*.1' -x xx.x -Naur indent-2.2.9/src/args.c indent-dpv/src/args.c --- indent-2.2.9/src/args.c 2002-11-10 16:02:48.000000000 -0500 +++ indent-dpv/src/args.c 2004-04-02 06:29:07.000000000 -0500 @@ -53,7 +53,7 @@ "-npcs\0-nprs\0-npsl\0-sai\0-saf\0-saw\0-cs\0-nsc\0-nsob\0-nfca\0-cp33\0-nss\0" #define GNU_SETTINGS_STRING (int *) \ - "-nbad\0-bap\0-bbo\0-hnl\0-nbc\0-bl\0-bls\0-ncdb\0-cs\0-nce\0" \ + "-nbad\0-bap\0-bbbo\0-bbo\0-hnl\0-nbc\0-bl\0-bls\0-ncdb\0-cs\0-nce\0" \ "-di2\0-ndj\0-nfc1\0-i2\0-ip5\0-lp\0-pcs\0-nprs\0-psl\0-nsc\0-sai\0-saf\0-saw\0-nsob\0" \ "-bli2\0-cp1\0-nfca\0" @@ -92,6 +92,7 @@ static int exp_bad = 0; static int exp_bap = 0; static int exp_bbb = 0; +static int exp_bbbo = 0; static int exp_bbo = 0; static int exp_bc = 0; static int exp_bl = 0; @@ -121,6 +122,7 @@ static int exp_gnu = 0; static int exp_hnl = 0; static int exp_i = 0; +static int exp_icb = 0; static int exp_ip = 0; static int exp_kr = 0; static int exp_l = 0; @@ -230,6 +232,7 @@ {"npcs", PRO_BOOL, false, OFF, &settings.proc_calls_space, &exp_pcs}, {"nlps", PRO_BOOL, false, OFF, &settings.leave_preproc_space, &exp_lps}, {"nlp", PRO_BOOL, true, OFF, &settings.lineup_to_parens, &exp_lp}, + {"nicb", PRO_BOOL, false, OFF, &settings.indent_closing_brace, &exp_icb}, {"nip", PRO_SETTINGS, 0, ONOFF_NA, (int *) "-ip0", &exp_nip}, {"nhnl", PRO_BOOL, true, OFF, &settings.honour_newlines, &exp_hnl}, {"nfca", PRO_BOOL, true, OFF, &settings.format_comments, &exp_fca}, @@ -245,6 +248,7 @@ {"nbfde", PRO_BOOL, false, OFF, &settings.break_function_decl_args_end, &exp_bfde}, {"nbc", PRO_BOOL, true, ON, &settings.leave_comma, &exp_bc}, {"nbbo", PRO_BOOL, true, OFF, &settings.break_before_boolean_operator, &exp_bbo}, + {"nbbbo", PRO_BOOL, false, OFF, &settings.break_before_binary_operator, &exp_bbbo}, {"nbbb", PRO_BOOL, false, OFF, &settings.blanklines_before_blockcomments, &exp_bbb}, {"nbap", PRO_BOOL, false, OFF, &settings.blanklines_after_procs, &exp_bap}, {"nbadp", PRO_BOOL, false, OFF, &settings.blanklines_after_declarations_at_proctop, &exp_badp}, @@ -256,6 +260,7 @@ {"l", PRO_INT, DEFAULT_RIGHT_MARGIN, ONOFF_NA, &settings.max_col, &exp_l}, {"kr", PRO_SETTINGS, 0, ONOFF_NA, KR_SETTINGS_STRING, &exp_kr}, {"ip", PRO_INT, 4, ONOFF_NA, &settings.indent_parameters, &exp_ip}, + {"icb", PRO_BOOL, false, ON, &settings.indent_closing_brace, &exp_icb}, {"i", PRO_INT, 4, ONOFF_NA, &settings.ind_size, &exp_i}, {"hnl", PRO_BOOL, true, ON, &settings.honour_newlines, &exp_hnl}, {"h", PRO_FUNCTION, 0, ONOFF_NA, (int *) usage, &exp_version}, @@ -288,6 +293,7 @@ {"bfda", PRO_BOOL, false, ON, &settings.break_function_decl_args, &exp_bfda}, {"bfde", PRO_BOOL, false, ON, &settings.break_function_decl_args_end, &exp_bfde}, {"bc", PRO_BOOL, true, OFF, &settings.leave_comma, &exp_bc}, + {"bbbo", PRO_BOOL, false, ON, &settings.break_before_binary_operator, &exp_bbbo}, {"bbo", PRO_BOOL, true, ON, &settings.break_before_boolean_operator, &exp_bbo}, {"bbb", PRO_BOOL, false, ON, &settings.blanklines_before_blockcomments, &exp_bbb}, {"bap", PRO_BOOL, false, ON, &settings.blanklines_after_procs, &exp_bap}, @@ -344,6 +350,7 @@ {"nlps", PRO_BOOL, false, OFF, &settings.leave_preproc_space, &exp_lps}, {"nlp", PRO_BOOL, true, OFF, &settings.lineup_to_parens, &exp_lp}, {"nip", PRO_SETTINGS, 0, ONOFF_NA, (int *) "-ip0\0", &exp_nip}, + {"nicb", PRO_BOOL, false, OFF, &settings.indent_closing_brace, &exp_icb}, {"nhnl", PRO_BOOL, true, OFF, &settings.honour_newlines, &exp_hnl}, {"nfca", PRO_BOOL, false, OFF, &settings.format_comments, &exp_fca}, {"nfc1", PRO_BOOL, false, OFF, &settings.format_col1_comments, &exp_fc1}, @@ -357,6 +364,7 @@ {"nbfda", PRO_BOOL, false, OFF, &settings.break_function_decl_args, &exp_bfda}, {"nbfde", PRO_BOOL, false, OFF, &settings.break_function_decl_args_end, &exp_bfde}, {"nbc", PRO_BOOL, true, ON, &settings.leave_comma, &exp_bc}, + {"nbbbo", PRO_BOOL, true, OFF, &settings.break_before_binary_operator, &exp_bbbo}, {"nbbo", PRO_BOOL, true, OFF, &settings.break_before_boolean_operator, &exp_bbo}, {"nbbb", PRO_BOOL, false, OFF, &settings.blanklines_before_blockcomments, &exp_bbb}, {"nbap", PRO_BOOL, true, OFF, &settings.blanklines_after_procs, &exp_bap}, @@ -369,6 +377,7 @@ {"l", PRO_INT, DEFAULT_RIGHT_MARGIN, ONOFF_NA, &settings.max_col, &exp_l}, {"kr", PRO_SETTINGS, 0, ONOFF_NA, KR_SETTINGS_STRING, &exp_kr}, {"ip", PRO_INT, 5, ONOFF_NA, &settings.indent_parameters, &exp_ip}, + {"icb", PRO_BOOL, false, ON, &settings.indent_closing_brace, &exp_icb}, {"i", PRO_INT, 2, ONOFF_NA, &settings.ind_size, &exp_i}, {"hnl", PRO_BOOL, true, ON, &settings.honour_newlines, &exp_hnl}, {"h", PRO_FUNCTION, 0, ONOFF_NA, (int *) usage, &exp_version}, @@ -402,6 +411,7 @@ {"bfda", PRO_BOOL, false, ON, &settings.break_function_decl_args, &exp_bfda}, {"bfde", PRO_BOOL, false, ON, &settings.break_function_decl_args_end, &exp_bfde}, {"bc", PRO_BOOL, true, OFF, &settings.leave_comma, &exp_bc}, + {"bbbo", PRO_BOOL, true, ON, &settings.break_before_binary_operator, &exp_bbbo}, {"bbo", PRO_BOOL, true, ON, &settings.break_before_boolean_operator, &exp_bbo}, {"bbb", PRO_BOOL, false, ON, &settings.blanklines_before_blockcomments, &exp_bbb}, {"bap", PRO_BOOL, true, ON, &settings.blanklines_after_procs, &exp_bap}, @@ -460,6 +470,7 @@ {"no-space-after-for", "nsaf"}, {"no-space-after-casts", "ncs"}, {"no-parameter-indentation", "nip"}, + {"no-indent-closing-brace", "nicb"}, {"no-extra-expression-indentation", "neei"}, {"no-comment-delimiters-on-blank-lines", "ncdb"}, {"no-blank-lines-before-block-comments", "nbbb"}, @@ -480,6 +491,7 @@ {"k-and-r-style", "kr"}, {"indentation-level", "i"}, {"indent-level", "i"}, + {"indent-closing-brace", "icb"}, {"ignore-profile", "npro"}, {"ignore-newlines", "nhnl"}, {"honour-newlines", "hnl"}, @@ -517,6 +529,8 @@ {"break-function-decl-args-end", "bfde"}, {"break-before-boolean-operator", "bbo"}, {"break-after-boolean-operator", "nbbo"}, + {"break-before-binary-operator", "bbbo"}, + {"break-after-binary-operator", "nbbbo"}, {"braces-on-struct-decl-line", "brs"}, {"braces-on-func-def-line", "brf"}, {"braces-on-if-line", "br"}, diff -x '*.po' -x '*.gmo' -x '*.html' -x '*.info' -x '*.gz' -x version.texi -x '*.pot' -x texinfo2man.c -x stamp-vti -x '*.1' -x xx.x -Naur indent-2.2.9/src/indent.c indent-dpv/src/indent.c --- indent-2.2.9/src/indent.c 2002-10-28 15:00:56.000000000 -0500 +++ indent-dpv/src/indent.c 2004-04-02 05:58:05.000000000 -0500 @@ -709,7 +709,7 @@ if (parser_state_tos->want_blank || (e_code > s_code && *e_code != ' ')) { - set_buf_break (bb_binary_op, paren_target); + if (settings.break_before_binary_operator ) set_buf_break (bb_binary_op, paren_target); *e_code++ = ' '; *e_code = '\0'; /* null terminate code sect */ } @@ -760,6 +760,10 @@ set_buf_break (bb_question, paren_target); *e_code++ = ' '; } + else if (settings.break_before_binary_operator) + { + set_buf_break (bb_question, paren_target); + } else if (can_break) { set_buf_break (can_break, paren_target); @@ -806,6 +810,10 @@ set_buf_break (bb_colon, paren_target); *e_code++ = ' '; } + else if (settings.break_before_binary_operator) + { + set_buf_break (bb_colon, paren_target); + } else if (can_break) { set_buf_break (can_break, paren_target); @@ -889,7 +897,7 @@ *e_lab++ = ' '; *e_lab = '\0'; - /* parser_state_tos->pcas e will be used by dump_line to decide + /* parser_state_tos->pcase will be used by dump_line to decide * how to indent the label. force_nl will force a case n: to be * on a line by itself */ @@ -1599,6 +1607,8 @@ static void handle_token_struct_delim(void) { char * t_ptr; + + if (settings.break_before_binary_operator) set_buf_break (bb_struct_delim, paren_target); for (t_ptr = token; t_ptr < token_end; ++t_ptr) { check_code_size(); @@ -1607,7 +1617,8 @@ parser_state_tos->want_blank = false; /* dont put a blank after a * period */ - parser_state_tos->can_break = bb_struct_delim; + if (!settings.break_before_binary_operator) parser_state_tos->can_break = bb_struct_delim; + else parser_state_tos->can_break = bb_none; } /******************************************************************************/ @@ -2266,7 +2277,7 @@ { case newline: ++line_no; - *flushed_nl = true; + if (settings.honour_newlines) *flushed_nl = true; break; case form_feed: break; /* form feeds and newlines found here will be @@ -2475,7 +2486,7 @@ *type_code = lexi (); - if ( ( (*type_code == newline) && (just_saw_nl == true)) || + if ( ( (*type_code == newline) && (just_saw_nl == true) && settings.honour_newlines) || ( (*type_code == comment) && parser_state_tos->last_saw_nl && (parser_state_tos->last_token != sp_else))) { @@ -2568,6 +2579,7 @@ (type_code != struct_delim)) || ( (parser_state_tos->last_token == rparen) && (type_code != comma) && + (type_code !=newline) && (type_code != rparen) ) ) && (output_line_length () > settings.max_col)) { diff -x '*.po' -x '*.gmo' -x '*.html' -x '*.info' -x '*.gz' -x version.texi -x '*.pot' -x texinfo2man.c -x stamp-vti -x '*.1' -x xx.x -Naur indent-2.2.9/src/indent.h indent-dpv/src/indent.h --- indent-2.2.9/src/indent.h 2002-11-10 16:02:48.000000000 -0500 +++ indent-dpv/src/indent.h 2004-03-29 17:50:35.000000000 -0500 @@ -253,6 +253,13 @@ int btype_2; /* when true, brace should be on same line as if, while, etc */ int brace_indent; /* number of spaces to indent braces from the suround if, while, etc. in -bl * (bype_2 == 0) code */ +/* *** DPV Change begin *** */ + int indent_closing_brace; /* true if closing brace should have same indentation as enclosed text */ + int break_before_binary_operator; /* True when we prefer to break a long line + * before any binary operator rather than after. + * I interpret this as meeting the GNU coding standard. + */ +/* *** DPV Change begin *** */ int expect_output_file; /* Means "-o" was specified. */ } user_options_ty; diff -x '*.po' -x '*.gmo' -x '*.html' -x '*.info' -x '*.gz' -x version.texi -x '*.pot' -x texinfo2man.c -x stamp-vti -x '*.1' -x xx.x -Naur indent-2.2.9/src/io.h indent-dpv/src/io.h --- indent-2.2.9/src/io.h 2002-08-04 13:08:41.000000000 -0400 +++ indent-dpv/src/io.h 2004-03-24 05:40:08.000000000 -0500 @@ -58,7 +58,15 @@ bb_operator5, /* multiply, divide or modulo */ bb_operator6, /* add or subtract */ bb_doublecolon, - bb_cast + bb_cast, + bb_before_equal_sign, + bb_before_comparison, + bb_before_question, + bb_before_colon, + bb_before_operator2, /* member selection (bb_struct_delim `.' or `->') */ + bb_before_operator4, /* member selection (bb_struct_delim `.*' or `->*') */ + bb_before_operator5, /* multiply, divide or modulo */ + bb_before_operator6, /* add or subtract */ } bb_code_ty; extern char * cur_line; diff -x '*.po' -x '*.gmo' -x '*.html' -x '*.info' -x '*.gz' -x version.texi -x '*.pot' -x texinfo2man.c -x stamp-vti -x '*.1' -x xx.x -Naur indent-2.2.9/src/output.c indent-dpv/src/output.c --- indent-2.2.9/src/output.c 2002-12-12 12:36:49.000000000 -0500 +++ indent-dpv/src/output.c 2004-04-02 06:03:39.000000000 -0500 @@ -164,8 +164,11 @@ bb->priority -= 3; } break; + case bb_before_equal_sign: + if (settings.break_before_binary_operator) bb->priority += 4000; + break; case bb_after_equal_sign: - bb->priority += 4000; + if (!settings.break_before_binary_operator) bb->priority += 4000; break; case bb_attribute: bb->priority += 3000; @@ -173,23 +176,40 @@ case bb_comma: bb->priority += 2000; break; + case bb_before_comparison: + case bb_question: + case bb_colon: + if (settings.break_before_binary_operator) bb->priority += 1001; + break; case bb_comparisation: - bb->priority += 1000; + if (!settings.break_before_binary_operator) bb->priority += 1000; break; case bb_proc_call: bb->priority -= 1000; break; + case bb_before_operator6: + if (settings.break_before_binary_operator) bb->priority += 601; + break; case bb_operator6: - bb->priority += 600; + if (!settings.break_before_binary_operator) bb->priority += 600; + break; + case bb_before_operator5: + if (settings.break_before_binary_operator) bb->priority += 501; break; case bb_operator5: - bb->priority += 500; + if (!settings.break_before_binary_operator) bb->priority += 500; + break; + case bb_before_operator4: + if (settings.break_before_binary_operator) bb->priority += 401; break; case bb_operator4: - bb->priority += 400; + if (!settings.break_before_binary_operator) bb->priority += 400; + break; + case bb_before_operator2: + if (settings.break_before_binary_operator) bb->priority += 201; break; case bb_operator2: - bb->priority += 200; + if (!settings.break_before_binary_operator) bb->priority += 200; break; case bb_doublecolon: bb->priority += 100; @@ -352,6 +372,41 @@ { bb->priority_code = bb_before_boolean_binary_op; } + else if ( (code == bb_binary_op) && + ((*token == '=' && token_end - token == 1) + || (*token != '\0' && token[1] == '=' && token_end - token == 2 + && (*token == '%' + || *token == '^' + || *token == '&' + || *token == '*' + || *token == '-' + || *token == '+' + || *token == '/' + || *token == '|')))) + { + bb->priority_code = bb_before_equal_sign; + } + else if ( (code == bb_binary_op) && + ((*token == '>' && token_end - token == 1) + || (*token == '<' && token_end - token == 1) + || (*token != '\0' && token[1] == '=' && token_end - token == 2 + && (*token == '>' + || *token == '<' + || *token == '=' + || *token == '!')))) + { + bb->priority_code = bb_before_comparison; + } + else if ( (code == bb_binary_op) && token_end - token == 1 + && (*token == '*' || *token == '/' || *token == '%')) + { + bb->priority_code = bb_before_operator5; + } + else if ( (code == bb_binary_op) && token_end - token == 1 + && (*token == '+' || *token == '-' )) + { + bb->priority_code = bb_before_operator6; + } else if (e_code[-1] == ';') { bb->priority_code = bb_semicolon; @@ -359,17 +414,31 @@ else { bb->priority_code = code; - if (code == bb_struct_delim) /* . -> .* or ->* */ + if (code == bb_struct_delim && !settings.break_before_binary_operator) /* . -> .* or ->* */ { if (e_code[-1] == '*') { bb->priority_code = bb_operator4; } - else + else if (e_code[-1] == '.' || e_code[-1] == '>') { bb->priority_code = bb_operator2; } } + else if (code == bb_struct_delim && settings.break_before_binary_operator) /* . -> .* or ->* */ + { + if (token_end[-1] == '*' + && (*token == '.' + || *token == '-')) + { + bb->priority_code = bb_before_operator4; + } + else if (*token == '.' + || *token == '-') + { + bb->priority_code = bb_before_operator2; + } + } } } set_priority (bb); @@ -822,7 +891,7 @@ { if (parser_state_tos->paren_indents[i] >= 0) { - if (parser_state_tos->paren_indents[i] < ptr - s_code) + if (parser_state_tos->paren_indents[i] <= ptr - s_code) { parser_state_tos->paren_indents[i] = -(parser_state_tos->paren_indents[i] + target_col); diff -x '*.po' -x '*.gmo' -x '*.html' -x '*.info' -x '*.gz' -x version.texi -x '*.pot' -x texinfo2man.c -x stamp-vti -x '*.1' -x xx.x -Naur indent-2.2.9/src/parse.c indent-dpv/src/parse.c --- indent-2.2.9/src/parse.c 2002-08-04 13:08:41.000000000 -0400 +++ indent-dpv/src/parse.c 2004-03-24 02:20:27.000000000 -0500 @@ -417,7 +417,9 @@ if (parser_state_tos->p_stack[parser_state_tos->tos - 1] == lbrace) { parser_state_tos->i_l_follow = parser_state_tos->il[--parser_state_tos->tos]; - parser_state_tos->ind_level = parser_state_tos->i_l_follow; +/* *** DPV Change Start *** */ + if (!settings.indent_closing_brace) parser_state_tos->ind_level = parser_state_tos->i_l_follow; +/* *** DPV Change End *** */ parser_state_tos->p_stack[parser_state_tos->tos] = stmt; } else