-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ClangFormat to pre-commit #8015
Conversation
b2e3859
to
1b1c825
Compare
for more information, see https://pre-commit.ci
#ifdef HAVE_RAQM_SYSTEM | ||
#include <raqm.h> | ||
#else | ||
#include "thirdparty/raqm/raqm.h" | ||
#ifdef HAVE_FRIBIDI_SYSTEM | ||
#include <fribidi.h> | ||
#else | ||
#include "thirdparty/fribidi-shim/fribidi.h" | ||
#include <hb.h> | ||
#endif | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks technically correct, but also I'm pretty sure the previous indentation was intentional for readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a clang setting to change this, https://stackoverflow.com/a/66004745, but I don't think the effect of the alternative settings on other files looks good.
@@ -719,7 +727,7 @@ bounding_box_and_anchors(FT_Face face, const char *anchor, int horizontal_dir, G | |||
static PyObject * | |||
font_getsize(FontObject *self, PyObject *args) { | |||
int width, height, x_offset, y_offset; | |||
int load_flags; /* FreeType load_flags parameter */ | |||
int load_flags; /* FreeType load_flags parameter */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we lose the indentation with the other variable comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/python-pillow/Pillow/pull/8015/files#r1582006590 for a possible solution.
A lot of these changes don't really improve readability, imo. |
for more information, see https://pre-commit.ci
int load_flags; /* FreeType load_flags parameter */ | ||
int error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int load_flags; /* FreeType load_flags parameter */ | |
int error; | |
int error; | |
int load_flags; /* FreeType load_flags parameter */ |
If the indentation is a concern, then this could be a solution - by grouping load_flags
with the other commented lines, the indentation is kept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or can we now declare on first use, a few lines below?
- load_flags = FT_LOAD_DEFAULT;
+ /* FreeType load_flags parameter */
+ int load_flags = FT_LOAD_DEFAULT;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, every variable in this function is declared at the top at the moment, and I think the consistency of that is good.
I'm happy just leaving it as it currently is in this PR.
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
Currently in Python when a function declaration is split across multiple lines, the closing parenthesis is on the same level as the Lines 3484 to 3488 in c250a44
However with this change in C the closing parenthesis is on the same line as the last argument. static int
decode_bcn(
Imaging im,
ImagingCodecState state,
const UINT8 *src,
int bytes,
int N,
int C,
char *pixel_format) { It's the same with function calls as well. It looks like this is changed with |
From what I can see, this is the style of C that is already in place. For the example you've cited, here how it is in main. Pillow/src/libImaging/BcnDecode.c Lines 827 to 829 in 58a4797
Here are some other examples. Lines 250 to 257 in 58a4797
Lines 404 to 412 in 58a4797
Unless I've missed something in looking at the changes here, this PR isn't even moving any closing brackets from a newline onto the same line as the last argument - it's just making the existing style slightly more apparent because it's splitting up some long lines. I'm not opposed to changing the style for its own sake, I just don't think the current state of this PR affects what you're describing. |
Ah, yeah that does seem to be the case. I didn't find any instances of Line 220 in 58a4797
Line 238 in 58a4797
Pillow/src/libImaging/TiffDecode.c Line 713 in 58a4797
I would prefer the other format, but that could be a separate change. |
Follow on from #4493 / #4770.
As reminded by #8011 (comment) we didn't add this to pre-commit/CI at the time. Let's add it now.
Update the others at the same time.