How to align function declaration using uncrustify?

I'm trying to replicate the GNU coding standard using uncrustify. My program has the following function declarations,

static void connect_to_server_cb1 (GObject      *source_object,
                                   GAsyncResult *result,
                                   gpointer      user_data);

static gboolean connect_to_server_cb2 (GObject     *source_object,
                                   GAsyncResult *result,
                                   gpointer      user_data);

static void connect_to_server_cb3 (GObject      *source_object,
                                   GAsyncResult *result,
                                   gpointer      user_data);

I'm expecting output as follows,

static void     connect_to_server_cb1 (GObject      *source_object,
                                       GAsyncResult *result,
                                       gpointer      user_data);

static gboolean connect_to_server_cb2 (GObject      *source_object,
                                       GAsyncResult *result,
                                       gpointer      user_data);

static void     connect_to_server_cb3 (GObject      *source_object,
                                       GAsyncResult *result,
                                       gpointer      user_data);

Which config option I should try to achive this?

Answers

I'm not sure that uncrustify can do exactly what you want. You could try to post-process the output with the gcu-lineup-parameters program from GNOME C Utils, which Nautilus already uses for example. The Nautilus source tree contains a run-uncrustify.sh script which does this for each file:

# Aligning prototypes is not working yet, so avoid headers
"$UNCRUSTIFY" -c "$DATA/uncrustify.cfg" --no-backup "$FILE"
"$DATA/lineup-parameters" "$FILE" > "$FILE.temp" && mv "$FILE.temp" "$FILE"

This should work if you only want to process the .c files, but the comment suggests that aligning prototypes in headers is more difficult.

Posted on by Sam Thursfield