summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-16 15:53:40 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-16 15:53:40 +0000
commit4d7904c62bb867c44e90b8e9f7cdbb4b283abc44 (patch)
tree51a7b6061436a5551e4a58fa62fc839947bb49a4
parent8567ee21f1a7103a4d8d0b4c85dd3af31be4926e (diff)
indentdiff
-rw-r--r--contrib/lrn-indent.diff83
1 files changed, 83 insertions, 0 deletions
diff --git a/contrib/lrn-indent.diff b/contrib/lrn-indent.diff
new file mode 100644
index 000000000..8ba3b77cc
--- /dev/null
+++ b/contrib/lrn-indent.diff
@@ -0,0 +1,83 @@
+diff -u indent-2.2.11/src/args.c indent-2.2.11.my/src/args.c
+--- indent-2.2.11/src/args.c 2008-07-23 23:27:17 +0400
++++ indent-2.2.11.my/src/args.c 2011-08-16 14:07:30 +0400
+@@ -151,6 +151,7 @@
+ static int exp_cpp = 0;
+ static int exp_cs = 0;
+ static int exp_d = 0;
++static int exp_ddd = 0;
+ static int exp_bfda = 0;
+ static int exp_bfde = 0;
+ static int exp_di = 0;
+@@ -317,6 +318,8 @@
+ {"fca", PRO_BOOL, true, ON, &settings.format_comments, &exp_fca},
+ {"fc1", PRO_BOOL, true, ON, &settings.format_col1_comments, &exp_fc1},
+ {"eei", PRO_BOOL, false, ON, &settings.extra_expression_indent, &exp_eei},
++ {"ddd", PRO_BOOL, true, ON, &settings.diff_decls_and_defs, &exp_ddd},
++ {"nddd", PRO_BOOL, true, OFF, &settings.diff_decls_and_defs, &exp_ddd},
+ {"dj", PRO_BOOL, false, ON, &settings.ljust_decl, &exp_dj},
+ {"di", PRO_INT, 16, ONOFF_NA, &settings.decl_indent, &exp_di},
+ {"d", PRO_INT, 0, ONOFF_NA, &settings.unindent_displace, &exp_d},
+@@ -436,6 +439,8 @@
+ {"fca", PRO_BOOL, false, ON, &settings.format_comments, &exp_fca},
+ {"fc1", PRO_BOOL, false, ON, &settings.format_col1_comments, &exp_fc1},
+ {"eei", PRO_BOOL, false, ON, &settings.extra_expression_indent, &exp_eei},
++ {"ddd", PRO_BOOL, true, ON, &settings.diff_decls_and_defs, &exp_ddd},
++ {"nddd", PRO_BOOL, true, OFF, &settings.diff_decls_and_defs, &exp_ddd},
+ {"dj", PRO_BOOL, false, ON, &settings.ljust_decl, &exp_dj},
+ {"di", PRO_INT, 2, ONOFF_NA, &settings.decl_indent, &exp_di},
+ {"d", PRO_INT, 0, ONOFF_NA, &settings.unindent_displace, &exp_d},
+diff -u indent-2.2.11/src/handletoken.c indent-2.2.11.my/src/handletoken.c
+--- indent-2.2.11/src/handletoken.c 2009-02-15 14:20:42 +0300
++++ indent-2.2.11.my/src/handletoken.c 2011-08-16 14:18:28 +0400
+@@ -1642,6 +1642,11 @@
+ {
+ /* what ? */
+ }
++ if (parser_state_tos->in_parameter_declaration_prototype)
++ {
++ parser_state_tos->in_parameter_declaration_prototype = 0;
++ parser_state_tos->in_parameter_declaration = 0;
++ }
+ }
+
+ /**
+diff -u indent-2.2.11/src/indent.h indent-2.2.11.my/src/indent.h
+--- indent-2.2.11/src/indent.h 2009-10-11 23:15:34 +0400
++++ indent-2.2.11.my/src/indent.h 2011-08-16 14:19:37 +0400
+@@ -318,6 +318,11 @@
+ int brace_indent; /*!< number of spaces to indent braces from the suround if, while, etc. in -bl
+ * (bype_2 == 0) code */
+ int expect_output_file; /*!< Means "-o" was specified. */
++ int diff_decls_and_defs; /*!< Makes indent think that function prototypes are terminated by ';',
++ * without this option indent will not be able to tell a difference between
++ * int foo (); and int foo () {}
++ * This is the default.
++ */
+ } user_options_ty;
+
+ extern user_options_ty settings;
+@@ -430,6 +435,7 @@
+ * slightly different */
+ int in_stmt; /*!< set to 1 while in a stmt */
+ int in_parameter_declaration;
++ int in_parameter_declaration_prototype;
+ int ind_level; /*!< the current indentation level in spaces */
+ int ind_stmt; /*!< set to 1 if next line should have an extra
+ * indentation level because we are in the
+diff -u indent-2.2.11/src/lexi.c indent-2.2.11.my/src/lexi.c
+--- indent-2.2.11/src/lexi.c 2009-11-11 22:36:32 +0300
++++ indent-2.2.11.my/src/lexi.c 2011-08-16 14:14:28 +0400
+@@ -616,8 +616,11 @@
+ * I've added '=' to this list to keep from breaking
+ * a non-valid C macro from libc. -jla */
+
+- if (*tp != ';' && *tp != ',' && *tp != '(' && *tp != '=')
++ if ((*tp != ';' || !settings.diff_decls_and_defs) &&
++ *tp != ',' && *tp != '(' && *tp != '=')
+ {
++ if (*tp == ';')
++ parser_state_tos->in_parameter_declaration_prototype = 1;
+ parser_state_tos->in_parameter_declaration = 1;
+ }
+ }