dawnbeen / c_formatter_42

C language formatter for 42 norminette
GNU General Public License v3.0
176 stars 18 forks source link

Align formatter breaks max column length #9

Closed cacharle closed 2 years ago

cacharle commented 3 years ago

clang-format only puts one space between prototype return type and the rest of the prototype.

So the correctly formatted:

// alignment     --->   |

t_tok_lst               *tok_lst_new(enum e_tok tag, char *content);
t_tok_lst               *tok_lst_new_until(
                            enum e_tok tag, char *content, size_t n);
t_tok_lst               *tok_lst_push_front(
                            t_tok_lst **tokens, t_tok_lst *pushed);
t_tok_lst               *tok_lst_uncons(t_tok_lst **tokens);

becomes after clang-format:

// alignment     --->   |

t_tok_lst *tok_lst_new(enum e_tok tag, char *content);
t_tok_lst *tok_lst_new_until(enum e_tok tag, char *content, size_t n);
t_tok_lst *tok_lst_push_front(t_tok_lst **tokens, t_tok_lst *pushed);
t_tok_lst *tok_lst_uncons(t_tok_lst **tokens);

The align formatter puts the correct alignment but breaks the maximum column.

// alignment     --->   |

t_tok_lst               *tok_lst_new(enum e_tok tag, char *content);
t_tok_lst               *tok_lst_new_until(enum e_tok tag, char *content, size_t n);
t_tok_lst               *tok_lst_push_front(t_tok_lst **tokens, t_tok_lst *pushed);
t_tok_lst               *tok_lst_uncons(t_tok_lst **tokens);

The 2nd and 3rd prototypes lines are >80 characters.

keyhr commented 2 years ago

Fixed in f2a81a3fdc8f2b535a2768c6aa942aefc50fa679.