You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucy.apache.org by "Marvin Humphrey (JIRA)" <ji...@apache.org> on 2011/04/11 06:11:05 UTC

[lucy-issues] [jira] [Commented] (LUCY-141) Auto-format C code using astyle

    [ https://issues.apache.org/jira/browse/LUCY-141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13018189#comment-13018189 ] 

Marvin Humphrey commented on LUCY-141:
--------------------------------------

Here are several patches which manually apply the style changes which will be
enforced by astyle.  It is clearer to proceed in stages than to just run
everything through astyle and commit as one massive blob.

Really these style changes begin with 4 commits which have already made it
into the repository:

{noformat}
------------------------------------------------------------------------
r1090693 | marvin | 2011-04-09 14:44:48 -0700 (Sat, 09 Apr 2011) | 1 line

Remove trailing whitespace from C89-style comments.
------------------------------------------------------------------------
r1090692 | marvin | 2011-04-09 14:44:20 -0700 (Sat, 09 Apr 2011) | 1 line

Remove trailing whitespace from double-slash comments.
------------------------------------------------------------------------
r1090680 | marvin | 2011-04-09 13:36:57 -0700 (Sat, 09 Apr 2011) | 1 line

Remove trailing whitespace within ALv2 header comments.
------------------------------------------------------------------------
r1090538 | marvin | 2011-04-09 00:36:35 -0700 (Sat, 09 Apr 2011) | 2 lines

Add brackets to all multi-line single-statement conditionals.
------------------------------------------------------------------------
{noformat}

Here is my local git log, including some changes pushed to our svn 
repository.

{noformat}
commit 1c8d55fdff30530dd61e8a1ae50b97b7b3803f57
Author: Marvin Humphrey <ma...@rectangular.com>
Date:   Sun Apr 10 12:26:20 2011 -0700

    Break after '=' operator, because astyle does not indent lines that start
    with '=' properly.

commit 38d5f0abb8e2fd1973cb2856d8e37eb9c05fc838
Author: Marvin Humphrey <ma...@rectangular.com>
Date:   Sun Apr 10 11:57:19 2011 -0700

    Break function body opening lines when they exceed 78 characters.

commit 4c83ce9003600cd7654aee2fd6ea788d21d4e518
Author: Marvin Humphrey <ma...@rectangular.com>
Date:   Sun Apr 10 11:21:46 2011 -0700

    Attach opening brackets for functions to end of the declaration line, rather
    than dedicate a full line to each opening bracket.

commit 5414b6f2c529ba588d49a6a96c90a0544213f42b
Author: Marvin Humphrey <ma...@rectangular.com>
Date:   Sat Apr 9 15:56:56 2011 -0700

    Adapt preprocessor macros for pre-ANSI style.

commit 44751cbe3942d520dd3c90f7f3a016ade45045a7
Author: Marvin Humphrey <ma...@rectangular.com>
Date:   Sat Apr 9 15:47:22 2011 -0700

    Remove trailing whitespace from C code.

commit 41355683ea0225092397468e1f51ee1f9465fb6e
Author: marvin <ma...@13f79535-47bb-0310-9956-ffa450edef68>
Date:   Sat Apr 9 21:44:48 2011 +0000

    Remove trailing whitespace from C89-style comments.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/lucy/trunk@1090693 13f79535-47bb-0310-9956-ffa450edef68

commit 891aebcf02e3f0302e88ed56fd366e7dcec79a18
Author: marvin <ma...@13f79535-47bb-0310-9956-ffa450edef68>
Date:   Sat Apr 9 21:44:20 2011 +0000

    Remove trailing whitespace from double-slash comments.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/lucy/trunk@1090692 13f79535-47bb-0310-9956-ffa450edef68

commit f57125f86fd88baf8d52cc4c45ea2a2c9cb6be59
Author: marvin <ma...@13f79535-47bb-0310-9956-ffa450edef68>
Date:   Sat Apr 9 20:36:57 2011 +0000

    Remove trailing whitespace within ALv2 header comments.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/lucy/trunk@1090680 13f79535-47bb-0310-9956-ffa450edef68

{noformat}


(In retrospect, I regret having begun these commits before the final style
questions were completely worked out.  Using git-svn as a Subversion client is
great for building multi-stage commits.)

The patch removing trailing whitespace from C code just does what astyle
was going to do.  The change is invisible unless you're viewing a diff.

The preprocessor change is necessary because astyle forces all preprocessor
macros into the first column.  This is old-fashioned and not necessary for any
modern compiler, but an alternative indentation style which accomodates 
astyle's quirk seems to suffice.

The two commits relating to brackets implement the astyle preference
--brackets=attach.

The commit changing where we break around the '=' operator is necessary
because astyle can't figure out that it needs to indent lines that begin with
'='.  As a former graphic designer I believe breaking before '=' is superior,
but oh well.


> Auto-format C code using astyle
> -------------------------------
>
>                 Key: LUCY-141
>                 URL: https://issues.apache.org/jira/browse/LUCY-141
>             Project: Lucy
>          Issue Type: Improvement
>            Reporter: Marvin Humphrey
>            Assignee: Marvin Humphrey
>            Priority: Minor
>             Fix For: 0.1-incubating
>
>         Attachments: 0003-Remove-trailing-whitespace-from-C-code.patch, 0004-Adapt-preprocessor-macros-for-pre-ANSI-style.patch, 0005-Attach-opening-brackets-for-functions-to-end-of-the-.patch, 0006-Break-function-body-opening-lines-when-they-exceed-7.patch, 0007-Break-after-operator-because-astyle-does-not-indent-.patch
>
>
> We should consider using the automatic code formatter astyle for 
> our C code.
> Dev list thread: http://s.apache.org/INC

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira