Re: [GSoC][PATCH] userdiff: add built-in pattern for golang

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 28, 2018 at 4:31 PM, Alban Gruin <alban.gruin@xxxxxxxxx> wrote:
>>> diff --git a/userdiff.c b/userdiff.c
>>> @@ -38,6 +38,15 @@ IPATTERN("fortran",
>>> +PATTERNS("golang",
>>> +        /* Functions */
>>> +        "^[ \t]*(func[ \t]*.*(\\{[ \t]*)?)\n"
>>
>> Why is the brace (and possible following whitespace) optional?
>> Considering that the language demands that the brace be on the same
>> line, I'd think the brace should be mandatory.
>
> I did this to support non-standard formatting. It's a niche case though,
> maybe we could only support the standard formatting and modify the doc
> to reflect this change.

As noted, unlike 'struct' and 'interface', the brace for a 'func'
_must_ appear on the same line; that's a requirement of the language.
Placing it on a line is not an option.

    % cat >foo.go<<\EOF
    package foo
    func foo() {
    }
    EOF
    % go build foo.go

Versus:

    % cat >bar.go<<\EOF
    package bar
    func bar()
    {
    }
    EOF
    % go build bar.go
    ./bar.go:2:6: missing function body
    ./bar.go:3:1: syntax error: unexpected semicolon or newline before {

So, the regex probably ought to be strict about expecting the brace on
the same line as 'func'.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux