[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-indent] Feature added
From: |
Peter Smith |
Subject: |
[Bug-indent] Feature added |
Date: |
Sat, 13 Sep 2003 17:50:03 -0700 |
I would like to submit a change I have made to indent. This is not a bug,
just a feature addition.
PROBLEM
There is no method for controlling the spacing between array names and the
indexing operation that follows. "indent" always formats array references
to cuddle the "[" right up against the name that precedes it. For example,
original code that looks like this:
my_array_reference [index_value]
is always output as
my_array_reference[index_value]
SOLUTION
I added another option, "saan". This allows adding a space between array
names and the "[" that follows. Following the already exisiting options
with names like "space-after-if", and "space-after-while", I called this
option "space-after-array-name". To make the fix more complete I also added
the complement and short forms.
As requested here are the diffs using diff -c. The original files are from
the 2.2.9 release and my version.
I hope you will be able to incorporate this addition into future versions of
"indent".
Thanks,
Peter.
---
diff -c ../indent-2.2.9/src/args.c src/args.c
*** ../indent-2.2.9/src/args.c Sun Nov 10 13:02:48 2002
--- src/args.c Sat Sep 13 17:42:28 2003
***************
*** 30,35 ****
--- 30,39 ----
* 2002-11-10 Cristalle Azundris Sabon <address@hidden>
* Added --preprocessor-indentation (ppi) if set, will indent
nested
* preprocessor-statements with n spaces per level. overrides
-lps.
+ * preprocessor-statements with n spaces per level. overrides
-lps.
+ * 2003-09-13 Peter Smith <address@hidden>
+ * Added --space-after-array-name. If set, adds a space
between an
+ * array name and "["
*/
/* Argument scanning and profile reading code. Default parameters are set
***************
*** 139,144 ****
--- 143,149 ----
static int exp_ppi = 0; /* force preprocessor indent at width... */
static int exp_sai = 0;
static int exp_saf = 0;
+ static int exp_saan = 0;
static int exp_saw = 0;
static int exp_sbi = 0;
static int exp_sc = 0;
***************
*** 193,198 ****
--- 198,205 ----
/* Settings for original defaults */
const pro_ty pro[] =
{
+ // p_name p_type p_default p_special
*p_obj, *p_explicit
+
{"version", PRO_PRSTRING, 0, ONOFF_NA, (int
*) VERSION, &exp_version},
{"v", PRO_BOOL, false, ON,
&settings.verbose, &exp_v},
{"ut", PRO_BOOL, true, ON,
&settings.use_tabs, &exp_ut},
***************
*** 205,210 ****
--- 212,218 ----
{"saw", PRO_BOOL, true, ON,
&settings.space_after_while, &exp_saw},
{"sai", PRO_BOOL, true, ON,
&settings.space_after_if, &exp_sai},
{"saf", PRO_BOOL, true, ON,
&settings.space_after_for, &exp_saf},
+ {"saan", PRO_BOOL, false, ON,
&settings.space_after_array_name, &exp_saan},
{"psl", PRO_BOOL, true, ON,
&settings.procnames_start_line, &exp_psl},
{"prs", PRO_BOOL, false, ON,
&settings.parentheses_space, &exp_prs},
#ifdef PRESERVE_MTIME
***************
*** 221,226 ****
--- 229,235 ----
{"nsaw", PRO_BOOL, true, OFF,
&settings.space_after_while, &exp_saw},
{"nsai", PRO_BOOL, true, OFF,
&settings.space_after_if, &exp_sai},
{"nsaf", PRO_BOOL, true, OFF,
&settings.space_after_for, &exp_saf},
+ {"nsaan", PRO_BOOL, false, OFF,
&settings.space_after_array_name, &exp_saan},
{"npsl", PRO_BOOL, true, OFF,
&settings.procnames_start_line, &exp_psl},
{"nprs", PRO_BOOL, false, OFF,
&settings.parentheses_space, &exp_prs},
{"npro", PRO_IGN, 0, ONOFF_NA, 0,
&exp_pro},
***************
*** 317,322 ****
--- 326,332 ----
{"saw", PRO_BOOL, true, ON,
&settings.space_after_while, &exp_saw},
{"sai", PRO_BOOL, true, ON,
&settings.space_after_if, &exp_sai},
{"saf", PRO_BOOL, true, ON,
&settings.space_after_for, &exp_saf},
+ {"saan", PRO_BOOL, false, ON,
&settings.space_after_array_name, &exp_saan},
{"psl", PRO_BOOL, true, ON,
&settings.procnames_start_line, &exp_psl},
{"prs", PRO_BOOL, false, ON,
&settings.parentheses_space, &exp_prs},
#ifdef PRESERVE_MTIME
***************
*** 334,339 ****
--- 344,350 ----
{"nsaw", PRO_BOOL, true, OFF,
&settings.space_after_while, &exp_saw},
{"nsai", PRO_BOOL, true, OFF,
&settings.space_after_if, &exp_sai},
{"nsaf", PRO_BOOL, true, OFF,
&settings.space_after_for, &exp_saf},
+ {"nsaan", PRO_BOOL, false, OFF,
&settings.space_after_array_name, &exp_saan},
{"npsl", PRO_BOOL, true, OFF,
&settings.procnames_start_line, &exp_psl},
{"nprs", PRO_BOOL, false, OFF,
&settings.parentheses_space, &exp_prs},
{"npro", PRO_IGN, 0, ONOFF_NA, 0,
&exp_pro},
***************
*** 439,444 ****
--- 450,456 ----
{"space-after-parentheses", "prs"},
{"space-after-if", "sai"},
{"space-after-for", "saf"},
+ {"space-after-array-name", "saan"},
{"space-after-cast", "cs"},
{"remove-preprocessor-space", "nlps"},
{"procnames-start-lines", "psl"},
***************
*** 458,463 ****
--- 470,476 ----
{"no-space-after-if", "nsai"},
{"no-space-after-function-call-names", "npcs"},
{"no-space-after-for", "nsaf"},
+ {"no-space-after-array-name", "nsaan"},
{"no-space-after-casts", "ncs"},
{"no-parameter-indentation", "nip"},
{"no-extra-expression-indentation", "neei"},
diff -c ../indent-2.2.9/src/indent.c src/indent.c
*** ../indent-2.2.9/src/indent.c Mon Oct 28 12:00:56 2002
--- src/indent.c Sat Sep 13 17:41:36 2003
***************
*** 25,30 ****
--- 25,33 ----
* 2002-08-05: Matthias <address@hidden> and Eric Lloyd
<address@hidden>
* Added support for -brf to place function opening brace
after function
* declaration.
+ * 2003-09-13 Peter Smith <address@hidden>
+ * Added --space-after-array-name. If set, adds a space
between an
+ * array name and "["
*/
#include "sys.h"
***************
*** 414,419 ****
--- 417,429 ----
parser_state_tos->paren_depth++;
if (parser_state_tos->want_blank &&
+ ((*token == '[') && settings.space_after_array_name))
+ {
+ set_buf_break (bb_proc_call, paren_target);
+ *e_code++ = ' ';
+ *e_code = '\0'; /* null terminate code sect */
+ }
+ else if (parser_state_tos->want_blank &&
(*token != '[') &&
( (parser_state_tos->last_token != ident) ||
settings.proc_calls_space ||
diff -c ../indent-2.2.9/src/indent.h src/indent.h
*** ../indent-2.2.9/src/indent.h Sun Nov 10 13:02:48 2002
--- src/indent.h Sat Sep 13 17:40:06 2003
***************
*** 22,27 ****
--- 22,30 ----
* 2002-11-10 Cristalle Azundris Sabon <address@hidden>
* Added --preprocessor-indentation (ppi) if set, will indent
nested
* preprocessor-statements with n spaces per level. overrides
-lps.
+ * 2003-09-13 Peter Smith <address@hidden>
+ * Added --space-after-array-name. If set, adds a space
between an
+ * array name and "["
*/
#ifndef INDENT_INDENT_H
***************
*** 194,199 ****
--- 197,203 ----
int space_after_while; /* Put a space after `while' */
int space_after_if; /* Put a space after `if' */
int space_after_for; /* Put a space after `for' */
+ int space_after_array_name; /* Put a space after an array name i.e.
"arrayname[n]" becomes "arrayname [n]" */
int procnames_start_line; /* if true, the names of procedures being
defined get placed in column 1 (ie. a
* newline is placed between the type of the
procedure and its name) */
int parentheses_space; /* If true, parentheses will look like: ( foo
) rather than (foo) */
_________________________________________________________________
Need more e-mail storage? Get 10MB with Hotmail Extra Storage.
http://join.msn.com/?PAGE=features/es
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-indent] Feature added,
Peter Smith <=