$ cat test.cpp
int* X(int* i, int *);
I want this to be converted to:
int* X(int *i, int*);
So I use this configuration:
$ cat test.cfg
sp_after_ptr_star = remove
sp_before_ptr_star = force
sp_before_unnamed_ptr_star = remove
$ uncrustify -c test.cfg test.cpp
Output suffix: .uncrustify
Parsing: test.cpp as language CPP
$ cat test.cpp.uncrustify
int*X(int *i, int*);
I.e. the spaces around the stars for the arguments become what I want, but the space between the star and the function name disappears. Is there some additional setting that can be used to avoid this?
Logged In: YES
user_id=1376119
Originator: NO
Grab r1366 or later and try 'sp_after_ptr_star_func = force'.
Ben
Logged In: YES
user_id=1009278
Originator: YES
Thanks, this works for this particular case, but...
You should really have the sp_before_ptr_star_func as well (not everyone will be happy with it always being the same as sp_before_unnamed_ptr_star, and the star is not really "unnamed" in this case since it names the type of the return type of the function, so sp_before_ptr_star_func should fall back to sp_before_ptr_star if not set - not to sp_before_unnamed_ptr_star).
And, as always - any *_ptr_star_* option should have the corresponding *_byref_* option as well.
I added sp_before_ptr_star_func, sp_after_byref_func, and sp_before_byref_func.
Would you please give them a try?
Thanks,
Ben
Thank you very much for your swift reply. You are a role model for the rest of us when it comes to fast implementations of feature requests.
Your latest version works well, except for a little glitch. It does not work for methods.
I.e. this works (function):
int *X(int* i, int *);
But this fails (class method):
int *Aclass::X(int* i, int *);
I think the XXX_func options should apply here as well. They are applied to the prototype in the class definition, so this works:
class Aclass {
int *X(int* i, int *);
}
I changed the code to try a different approach in r1371.
It now checks the parent type instead of the next token type.
Please give it a try.
Ben
Current svn snapshot works. Thanks.