[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-indent] Enhencement proposal for indent
From: |
VKrauseM |
Subject: |
[Bug-indent] Enhencement proposal for indent |
Date: |
Mon, 5 Aug 2002 12:28:50 +0200 |
Hi,
I recently installed the latest indent (2.2.8) to re-format a hole bunch of C
sources.
While being able to awesome set/reset most of the style things I was a little
disappointed that I could not easily set additional local flags (e.g. -T flag
for local
typedefs) beside the global ones from the ~/.indent.pro.
Therefore I took a little time and added some lines of code in args.c to create
a version to be able to specify additional profiles. (Those derived from my
sources during make with a little grep & sed glue :-) )
Since this might also be of interest for someone else I do attach the diffs.
Kind regards,
Michael.
#######################################################################################
#
# Changes/Enhancements in src/args.c
#
#######################################################################################
*** args.c Fri Aug 2 15:18:53 2002
--- args.c.org Fri Aug 2 09:36:33 2002
***************
*** 65,72 ****
PRO_KEY, /* -T switch */
PRO_SETTINGS, /* bundled set of settings */
PRO_PRSTRING, /* Print string and exit */
! PRO_FUNCTION, /* Call the associated function. */
! PRO_FUNC_ARG /* Call the associated function with the
given argument (char *). */
} profile_ty;
/* profile specials for booleans */
--- 65,71 ----
PRO_KEY, /* -T switch */
PRO_SETTINGS, /* bundled set of settings */
PRO_PRSTRING, /* Print string and exit */
! PRO_FUNCTION /* Call the associated function. */
} profile_ty;
/* profile specials for booleans */
***************
*** 147,153 ****
user_options_ty settings = {0};
static void usage (void);
- static void load_additional_options (char * prof_name);
/* N.B.: because of the way the table here is scanned, options whose names
* are substrings of other options must occur later; that is, with -lp vs -l,
--- 146,151 ----
***************
*** 247,253 ****
{"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},
- {"incl", PRO_FUNC_ARG, 0, ONOFF_NA, (int *)
load_additional_options, &exp_version},
{"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},
--- 245,250 ----
***************
*** 356,362 ****
{"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},
- {"incl", PRO_FUNC_ARG, 0, ONOFF_NA, (int *)
load_additional_options, &exp_version},
{"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},
--- 353,358 ----
***************
*** 462,468 ****
{"kernighan-and-ritchie-style", "kr"},
{"kernighan-and-ritchie", "kr"},
{"k-and-r-style", "kr"},
- {"include-profile", "incl"},
{"indentation-level", "i"},
{"indent-level", "i"},
{"ignore-profile", "npro"},
--- 458,463 ----
***************
*** 634,639 ****
--- 629,635 ----
int option_length = option_prefix (option);
int val = 0;
+
if (option_length > 0)
{
if (option_length == 1 && *option == '-')
***************
*** 795,821 ****
*p->p_obj = atoi (param_start);
break;
- case PRO_FUNC_ARG:
- {
- char *str;
-
- if (*param_start == 0)
- {
- if (!(param_start = param))
- {
- arg_missing(option);
- }
- else
- {
- val = 1;
- }
- }
- /* now invoke the target function with the parsed arg */
- ((void (*)()) p->p_obj) (param_start);
-
- }
- break;
-
default:
fprintf (stderr,
_("indent: set_option: internal error: p_type %d\n"),
--- 791,796 ----
***************
*** 1102,1122 ****
return fname;
}
-
- /*
- * Load additional options
- */
- void load_additional_options (char * prof_name)
- {
- FILE * f = NULL;
- char * fname = NULL;
-
- if (settings.verbose)
- printf("Loading additional profile '%s' ...\n", prof_name);
- if (prof_name) {
- if ((f = fopen (prof_name, "r"))) {
- scan_profile (f);
- (void) fclose (f);
- }
- }
- }
--- 1077,1079 ----
#######################################################################################
#
# Changes in doc/indent.texinfo
#
#######################################################################################
*** indent.texinfo Mon Aug 5 11:50:10 2002
--- indent.texinfo.org Mon Aug 5 11:50:10 2002
***************
*** 1573,1583 ****
Prefer to break long lines at the position of newlines in the address@hidden
@xref{Breaking long lines}.
- @item -incl
- @itemx --include-profile
- Load an additional profile (e.g. for local -T statements).
- (Load after '(.)indent.pro' but before subsequent cmd-args are parsed.)
-
@item address@hidden
@itemx address@hidden
Set indentation level to @var{n} address@hidden
--- 1573,1578 ----
______________________________________________________________________________
address@hidden - nur eine der witzigsten E-Mail-Adressen!
Interesse? Klicken! http://digitaledienste.web.de/MyAdress/?mc=021110
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-indent] Enhencement proposal for indent,
VKrauseM <=