Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Mar 2016 17:38:58 +0800
From:      Julian Elischer <julian@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Code Formatter for STYLE(9)?
Message-ID:  <56F50732.2040703@freebsd.org>
In-Reply-To: <56F506A3.80203@freebsd.org>
References:  <56F3EBB1.1060603@embedded-brains.de> <56F3FFB3.6070801@FreeBSD.org> <1fc0f5efcc94822f7f5ca9bbcb850faf@gahr.ch> <56F48322.9030208@FreeBSD.org> <56F506A3.80203@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 25/03/2016 5:36 PM, Julian Elischer wrote:
> On 25/03/2016 8:15 AM, Bryan Drewery wrote:
>> On 3/24/2016 9:24 AM, Pietro Cerutti wrote:
>>> On 2016-03-24 15:54, Matthew Seaman wrote:
>>>> On 2016/03/24 13:29, Sebastian Huber wrote:
>>>>> Hello,
>>>>>
>>>>> is there a ready to use C code formatter available that honours
>>>>> STYLE(9)? I tried clang-format, but it knows only LLVM, Google,
>>>>> Chromium, Mozilla by default. The GNU indent --original seems to 
>>>>> produce
>>>>> nothing usable. Same problem with astyle --style=bsd.
>
> there was an indent() config that was quite close.

I'm talking abut hte indnet in freebsd /usr/bin

>>>> pkg uses uncrustify with this config file:
>>>>
>>>> https://github.com/freebsd/pkg/blob/master/freebsd.cfg
>>>>
>>>> It's approximately what style(9) describes but doesn't cover 
>>>> things like
>>>> sorting include files and I don't think it was updated in 
>>>> response to
>>>> the recent change allowing { brackets } around certain single-line
>>>> statements.
>>> It looks like it does: https://github.com/freebsd/pkg/commit/1bc61a4
>>>
>> It's not quite right. It is adding {} to single-line if statements in
>> some code.
>>
>>>   static __inline struct filemon *
>>>   filemon_acquire(struct filemon *filemon)
>>>   {
>>> -
>>> -       if (filemon != NULL)
>>> +       if (filemon != NULL) {
>>>                  refcount_acquire(&filemon->refcnt);
>>> +       }
>>>          return (filemon);
>>>   }
>> It's also not aware of our (silly?) blank line with no declarations 
>> rule:
>>
>>>   static __inline void
>>>   filemon_drop(struct filemon *filemon)
>>>   {
>>> -
>>>          sx_xunlock(&filemon->lock);
>>>          filemon_release(filemon);
>>>   }
>> And wrapping multiple conditions:
>>
>>> -       if (p->p_filemon != NULL && p != curproc)
>>> +       if ((p->p_filemon != NULL) && (p != curproc)) {
>>>                  return (EBUSY);
>>> +       }
>> It's also not respecting the wrap rule of tabs + 4 spaces.
>>
>> It's also adding random blank lines before functions and macros.
>>
>> It found a useless 'return;' at least.
>>
>
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to 
> "freebsd-hackers-unsubscribe@freebsd.org"
>




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56F50732.2040703>