* How to auto format source file to be EDK2 code style?
@ 2017-03-23 2:06 Guoheyi
2017-03-23 3:26 ` Kinney, Michael D
0 siblings, 1 reply; 2+ messages in thread
From: Guoheyi @ 2017-03-23 2:06 UTC (permalink / raw)
To: edk2-devel@lists.01.org
Hi folks,
A number of our existing source code files are in really bad format and I'm trying to find a quick way to re-style them. I found the tool called "astyle" almost meets edk2 code style with certain settings, except it will remove the indent before closing parenthesis ")" in a new line. E.g. it will change code like below:
@@ -116,7 +116,7 @@ EhciPciIoPollIo (
IN UINT64 Value,
IN UINT64 Delay,
OUT UINT64 *Result
- )
+)
Any suggestion?
And this is my "astyle" configuration:
#--indent-switches
--indent-cases
--indent-namespaces
--indent-preprocessor
--indent-col1-comments
--pad-oper
--pad-header
--add-brackets
#--pad-comma
--convert-tabs
--indent-classes
--style=1tbs
--indent=spaces=2
--min-conditional-indent=1
--max-instatement-indent=40
--align-pointer=name
--align-reference=name
--max-code-length=80
Thanks and regards,
Gary (Heyi Guo)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to auto format source file to be EDK2 code style?
2017-03-23 2:06 How to auto format source file to be EDK2 code style? Guoheyi
@ 2017-03-23 3:26 ` Kinney, Michael D
0 siblings, 0 replies; 2+ messages in thread
From: Kinney, Michael D @ 2017-03-23 3:26 UTC (permalink / raw)
To: Guoheyi, edk2-devel@lists.01.org, Kinney, Michael D
Gary,
I have experimented with Astyle too. The best set of flags I have found so far are:
--style=kr
--indent=spaces=2
--add-brackets
--lineend=windows
--indent-continuation=1
--indent-col1-comments
--pad-oper
--pad-comma
--pad-first-paren-out
--pad-header
--align-pointer=name
--convert-tabs
--max-code-length=120
This gets close, but there are minor issues with
1) Space around '*','&','~','&&','!' operators.
2) Indenting ');' at end of function declaration
3) Aligning arguments and return values in function header comment blocks
4) Aligning arguments in function declarations
5) Aligning local variable declarations.
Mike
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Guoheyi
> Sent: Wednesday, March 22, 2017 7:06 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] How to auto format source file to be EDK2 code style?
>
> Hi folks,
>
>
> A number of our existing source code files are in really bad format and I'm trying to
> find a quick way to re-style them. I found the tool called "astyle" almost meets edk2
> code style with certain settings, except it will remove the indent before closing
> parenthesis ")" in a new line. E.g. it will change code like below:
>
> @@ -116,7 +116,7 @@ EhciPciIoPollIo (
> IN UINT64 Value,
> IN UINT64 Delay,
> OUT UINT64 *Result
> - )
> +)
>
> Any suggestion?
>
> And this is my "astyle" configuration:
>
> #--indent-switches
> --indent-cases
> --indent-namespaces
> --indent-preprocessor
> --indent-col1-comments
>
>
> --pad-oper
>
> --pad-header
>
> --add-brackets
> #--pad-comma
>
> --convert-tabs
>
> --indent-classes
> --style=1tbs
> --indent=spaces=2
> --min-conditional-indent=1
> --max-instatement-indent=40
> --align-pointer=name
> --align-reference=name
> --max-code-length=80
>
> Thanks and regards,
>
> Gary (Heyi Guo)
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-23 3:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-23 2:06 How to auto format source file to be EDK2 code style? Guoheyi
2017-03-23 3:26 ` Kinney, Michael D
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox