S
songbird
I dislike the use of macros which hide
the meaning of the code, but some code I
work on does things like the following and I
don't want to stray too far from the original
version.
I tried both indent, and astyle and neither of
them understand macros enough to know what to do
with things like:
=====
# define when break; case
# define orwhen case
# define otherwise break; default
=====
so the result looks like:
=====
/* Get the options */
while (--argc > 0 && (*++argv)[0] == '-') {
while (*++(*argv)) {
switch (**argv) {
when 'a': full=2;
when 'i': init++;
when 'f': full=1;
when 'm': m = atoi(*argv+1); SKIPARG;
printf ("axe size %d.\n", m);
when 's': seed = atoi(*argv+1); SKIPARG;
printf ("Random seed %d.\n", m);
when 'v': version = atoi(*argv+1); SKIPARG;
printf ("version %d.\n", version);
otherwise: quit (1,
"Usage: axe [-if] [-msv<value>] [axed]\n");
}
}
}
=====
if there is a way to preprocess to expand the macros
without getting all the extra stuff that cpp includes
that could be done.
or if there are any other C code formatters/indenters
that do understand macros I'd be glad to hear of them.
thanks for any ideas,
songbird
the meaning of the code, but some code I
work on does things like the following and I
don't want to stray too far from the original
version.
I tried both indent, and astyle and neither of
them understand macros enough to know what to do
with things like:
=====
# define when break; case
# define orwhen case
# define otherwise break; default
=====
so the result looks like:
=====
/* Get the options */
while (--argc > 0 && (*++argv)[0] == '-') {
while (*++(*argv)) {
switch (**argv) {
when 'a': full=2;
when 'i': init++;
when 'f': full=1;
when 'm': m = atoi(*argv+1); SKIPARG;
printf ("axe size %d.\n", m);
when 's': seed = atoi(*argv+1); SKIPARG;
printf ("Random seed %d.\n", m);
when 'v': version = atoi(*argv+1); SKIPARG;
printf ("version %d.\n", version);
otherwise: quit (1,
"Usage: axe [-if] [-msv<value>] [axed]\n");
}
}
}
=====
if there is a way to preprocess to expand the macros
without getting all the extra stuff that cpp includes
that could be done.
or if there are any other C code formatters/indenters
that do understand macros I'd be glad to hear of them.
thanks for any ideas,
songbird