lrn-indent.diff 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. diff -u indent-2.2.11/src/args.c indent-2.2.11.my/src/args.c
  2. --- indent-2.2.11/src/args.c 2008-07-23 23:27:17 +0400
  3. +++ indent-2.2.11.my/src/args.c 2011-08-16 14:07:30 +0400
  4. @@ -151,6 +151,7 @@
  5. static int exp_cpp = 0;
  6. static int exp_cs = 0;
  7. static int exp_d = 0;
  8. +static int exp_ddd = 0;
  9. static int exp_bfda = 0;
  10. static int exp_bfde = 0;
  11. static int exp_di = 0;
  12. @@ -317,6 +318,8 @@
  13. {"fca", PRO_BOOL, true, ON, &settings.format_comments, &exp_fca},
  14. {"fc1", PRO_BOOL, true, ON, &settings.format_col1_comments, &exp_fc1},
  15. {"eei", PRO_BOOL, false, ON, &settings.extra_expression_indent, &exp_eei},
  16. + {"ddd", PRO_BOOL, true, ON, &settings.diff_decls_and_defs, &exp_ddd},
  17. + {"nddd", PRO_BOOL, true, OFF, &settings.diff_decls_and_defs, &exp_ddd},
  18. {"dj", PRO_BOOL, false, ON, &settings.ljust_decl, &exp_dj},
  19. {"di", PRO_INT, 16, ONOFF_NA, &settings.decl_indent, &exp_di},
  20. {"d", PRO_INT, 0, ONOFF_NA, &settings.unindent_displace, &exp_d},
  21. @@ -436,6 +439,8 @@
  22. {"fca", PRO_BOOL, false, ON, &settings.format_comments, &exp_fca},
  23. {"fc1", PRO_BOOL, false, ON, &settings.format_col1_comments, &exp_fc1},
  24. {"eei", PRO_BOOL, false, ON, &settings.extra_expression_indent, &exp_eei},
  25. + {"ddd", PRO_BOOL, true, ON, &settings.diff_decls_and_defs, &exp_ddd},
  26. + {"nddd", PRO_BOOL, true, OFF, &settings.diff_decls_and_defs, &exp_ddd},
  27. {"dj", PRO_BOOL, false, ON, &settings.ljust_decl, &exp_dj},
  28. {"di", PRO_INT, 2, ONOFF_NA, &settings.decl_indent, &exp_di},
  29. {"d", PRO_INT, 0, ONOFF_NA, &settings.unindent_displace, &exp_d},
  30. diff -u indent-2.2.11/src/handletoken.c indent-2.2.11.my/src/handletoken.c
  31. --- indent-2.2.11/src/handletoken.c 2009-02-15 14:20:42 +0300
  32. +++ indent-2.2.11.my/src/handletoken.c 2011-08-16 14:18:28 +0400
  33. @@ -1642,6 +1642,11 @@
  34. {
  35. /* what ? */
  36. }
  37. + if (parser_state_tos->in_parameter_declaration_prototype)
  38. + {
  39. + parser_state_tos->in_parameter_declaration_prototype = 0;
  40. + parser_state_tos->in_parameter_declaration = 0;
  41. + }
  42. }
  43. /**
  44. diff -u indent-2.2.11/src/indent.h indent-2.2.11.my/src/indent.h
  45. --- indent-2.2.11/src/indent.h 2009-10-11 23:15:34 +0400
  46. +++ indent-2.2.11.my/src/indent.h 2011-08-16 14:19:37 +0400
  47. @@ -318,6 +318,11 @@
  48. int brace_indent; /*!< number of spaces to indent braces from the suround if, while, etc. in -bl
  49. * (bype_2 == 0) code */
  50. int expect_output_file; /*!< Means "-o" was specified. */
  51. + int diff_decls_and_defs; /*!< Makes indent think that function prototypes are terminated by ';',
  52. + * without this option indent will not be able to tell a difference between
  53. + * int foo (); and int foo () {}
  54. + * This is the default.
  55. + */
  56. } user_options_ty;
  57. extern user_options_ty settings;
  58. @@ -430,6 +435,7 @@
  59. * slightly different */
  60. int in_stmt; /*!< set to 1 while in a stmt */
  61. int in_parameter_declaration;
  62. + int in_parameter_declaration_prototype;
  63. int ind_level; /*!< the current indentation level in spaces */
  64. int ind_stmt; /*!< set to 1 if next line should have an extra
  65. * indentation level because we are in the
  66. diff -u indent-2.2.11/src/lexi.c indent-2.2.11.my/src/lexi.c
  67. --- indent-2.2.11/src/lexi.c 2009-11-11 22:36:32 +0300
  68. +++ indent-2.2.11.my/src/lexi.c 2011-08-16 14:14:28 +0400
  69. @@ -616,8 +616,11 @@
  70. * I've added '=' to this list to keep from breaking
  71. * a non-valid C macro from libc. -jla */
  72. - if (*tp != ';' && *tp != ',' && *tp != '(' && *tp != '=')
  73. + if ((*tp != ';' || !settings.diff_decls_and_defs) &&
  74. + *tp != ',' && *tp != '(' && *tp != '=')
  75. {
  76. + if (*tp == ';')
  77. + parser_state_tos->in_parameter_declaration_prototype = 1;
  78. parser_state_tos->in_parameter_declaration = 1;
  79. }
  80. }