Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABtNtWGRTs=dbtPD7-3OypwogcZe-=OqPHFTGG8RjkspexPH-A@mail.gmail.com>
Date: Mon, 27 Jul 2015 20:39:31 +0800
From: Kai Zhao <loverszhao@...il.com>
To: john-dev@...ts.openwall.com
Subject: Re: Coding Style

On Mon, Jul 27, 2015 at 5:20 PM, magnum <john.magnum@...hmail.com> wrote:
>
> On 2015-07-27 07:33, Kai Zhao wrote:
>>
>>   A new version of CodingStyle based on john developers' advice. You can
>> find it in the attachment.
>
>
> So, do we have indent(1) settings for this? You mentioned this line:

indent(1) is GNU indent ?

$ indent -version
GNU indent 2.2.11

> indent -kr -i8 -ts8 -nlp -ci4 -nbbo -ncs -l80 -lc80 -bad -il0 test.c
>
> I think it should be -i4 -ts4.

Yes, it should be -i4 -ts4.

> Does that handle most things we mention now?

Yes, it handle most things. But indent does some breakages.

> Does it alter anything significant that we don't mention?

Here are breakages by indent:

indent -kr -i4 -ts4 -nlp -ci4 -nbbo -ncs -l80 -lc80 -bad -il0  source_file

1. Align with tabs.

void *memmem(const void *haystack, size_t haystack_len,
.............const void *needle, size_t needle_len)
{
->      haystack_ = (char*)haystack;
->      needle_ = (char*)needle;
->      last = haystack_+(haystack_len - needle_len + 1);
->      for (; haystack_ < last; ++haystack_)
->      {
->      ->      if (hash == hay_hash &&
->      ->      ....*haystack_ == *needle_ &&
->      ->      ....!memcmp (haystack_, needle_, needle_len))
->      ->      ->      return haystack_;

->      ->      hay_hash += *(haystack_+needle_len);
->      }

->      return NULL;
}

After indented:

void *memmem(const void *haystack, size_t haystack_len,
-> const void *needle, size_t needle_len)
{
-> haystack_ = (char *)haystack;
-> needle_ = (char *)needle;
-> last = haystack_ + (haystack_len - needle_len + 1);
-> for (; haystack_ < last; ++haystack_) {
-> -> if (hash == hay_hash &&
-> -> -> *haystack_ == *needle_ && !memcmp(haystack_, needle_, needle_len))
-> -> -> return haystack_;

-> -> hay_hash += *(haystack_ + needle_len);
-> }

-> return NULL;
}

2. It does not ease multiple indentation levels in for(), while()

        for(;;;)
        if(condition) {
                ...
        }

->

        for(;;;)
                if(condition) {
                        ...
                }

3. It does not do well on closing brace when "do {} while();"

        do {
                do_something();
        } while(condition);

->
        do {
                do_something();
        } while(condition);

Indent does not change.

        do {
                do_something();
        }
        while(condition);

->
        do {
                do_something();
        }
        while(condition);

Indent does not change.


There are other breakages I have described before:

http://www.openwall.com/lists/john-dev/2015/06/22/6


Thanks,

Kai

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.