OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall Root: /e/openpkg/cvs Email: [EMAIL PROTECTED] Module: openpkg-re Date: 05-Apr-2003 21:24:50 Branch: HEAD Handle: 2003040520244900 Modified files: openpkg-re speclint.pl Log: flush some pending changes Summary: Revision Changes Path 1.7 +83 -2 openpkg-re/speclint.pl ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-re/speclint.pl ============================================================================ $ cvs diff -u -r1.6 -r1.7 speclint.pl --- openpkg-re/speclint.pl 24 Mar 2003 20:12:48 -0000 1.6 +++ openpkg-re/speclint.pl 5 Apr 2003 19:24:49 -0000 1.7 @@ -103,6 +103,7 @@ header section preproc + script )); my @checks = (); if ($check eq 'all') { @@ -200,7 +201,26 @@ $done = ''; $this = ''; $todo = $spec; while ($todo =~ m/[ \t]+\r?\n/s) { $done .= $`; $this = $&; $todo = $'; - &lint_warning($file, $done, $this, "trailing whitespace (expected none)"); + if ($done eq '' or $done =~ m|\n$|s) { + &lint_warning($file, $done, $this, "whitespace on empty line (expected none)"); + } + else { + &lint_warning($file, $done, $this, "trailing whitespace (expected none)"); + } + } + + # check for bogus line continuations + $done = ''; $this = ''; $todo = $spec; + while ($todo =~ m/\\[ \t]*\r?\n(?=[ \t]*\r?\n)/s) { + $done .= $`; $this = $&; $todo = $'; + &lint_warning($file, $done, $this, "bogus line continuation for following empty line"); + } + + # check for leading whitespaces befor line continuations + $done = ''; $this = ''; $todo = $spec; + while ($todo =~ m/[ \t]{2,}\\[ \t]*\r?\n/s) { + $done .= $`; $this = $&; $todo = $'; + &lint_warning($file, $done, $this, "multiple leading whitespace before line continuation"); } } @@ -476,6 +496,67 @@ } } - # FIXME: check correct nesting, too. + # check correct if/endif nesting + my @stack = (); + $done = ''; $this = ''; $todo = $spec; + while ($todo =~ m/^(%(?:if|else|endif|define|undefine|option)).*$/m) { + $done .= $`; $this = $&; $todo = $'; + my $directive = $1; + if ($directive eq '%if') { + push(@stack, &lines($done . $this)); + } + elsif ($directive eq '%endif') { + if (@stack == 0) { + &lint_error($file, $done, $this, "found \%endif without corresponding opening \%if"); + last; + } + pop(@stack); + } + } + my $line; + while (defined($line = pop(@stack))) { + &lint_error($file, undef, undef, "\%if at line $line never closed by \%endif"); + } +} + +## _________________________________________________________________ +## +## CHECK "script": shell scripts +## _________________________________________________________________ +## + +sub check_script { + my ($file, $spec) = @_; + + my $done = ''; my $this = ''; my $todo = $spec; + while ($todo =~ m/\n(%(?:description|prep|build|install|files|clean|pre|post|preun|postun))([^\n]*)\n(.*?\n)(?=%(?:description|prep|build|install|files|clean|pre|post|preun|postun)|$)/s) { + $done .= $`; $this = $&; $todo = $'; + my ($section, $args, $script) = ($1, $2, $3); + + &check_script_common($file, $section, $args, $script); + + if ($section eq 'description') { + } + elsif ($section eq 'prep') { + } + elsif ($section eq 'build') { + } + elsif ($section eq 'install') { + } + elsif ($section eq 'files') { + } + elsif ($section eq 'pre') { + } + elsif ($section eq 'post') { + } + elsif ($section eq 'preun') { + } + elsif ($section eq 'postun') { + } + } +} + +sub check_script_common { + my ($file, $section, $args, $script) = @_; } @@ . ______________________________________________________________________ The OpenPKG Project www.openpkg.org CVS Repository Commit List [EMAIL PROTECTED]