At Mon, 21 Jan 2013 11:47:40 +0900,
Hitoshi Mitake wrote:
> +
> +# forbid empty lines after break; line of switch statement
> +# e.g.
> +# +        break;
> +# +
> +# +    case XXX:
> +             if ($line =~ /\bbreak;/) {
> +                 my ($nlength, $nindent) = line_stats($line);
> +
> +                 my $ln = $linenr + 1;
> +                 while ($lines[$ln] =~ /^\+$/) { $ln++; }
> +                 my $sline = $lines[$ln];
> +
> +                 if ($sline =~ /\bcase/ ||  $sline =~ /\bdefault/) {

/\b(case|default)/ looks simpler.

> +                     my ($snlength, $snindent) = line_stats($sline);
> +                     if ($nindent - 8 == $snindent) {

($nindent > $snindent) looks better to catch more errors.

> +                         ERROR("NL_AFTER_BREAK_IN_SWITCH",
> +                               "don't insert empty lines after break; line 
> of switch statement" . $herecurr);

Add "\n" to the end of the second argument.

In addition, you patch allows the following.  Is it expected behavior?

+ switch (x) {
+ case A:
+       break;
+ default:
+       break; /* shouldn't this be an error? */
+ 
+ }

Thanks,

Kazutaka
-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to