File: checkc.pl

package info (click to toggle)
emboss 6.6.0%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 571,584 kB
  • sloc: ansic: 460,579; java: 29,383; perl: 13,573; sh: 12,753; makefile: 3,294; csh: 706; asm: 351; xml: 239; pascal: 237; modula3: 8
file content (39 lines) | stat: -rwxr-xr-x 1,001 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl -w

$showline=0;
if ($#ARGV > 1) {$showline = 1}
$i=0;
while (<>) {
  $i++;
  chomp;
  $len = length($_);
  if (/\s$/) {
    print STDERR "Trailing space line: $i\n";
   if ($showline) {print STDERR "$_"}
    s/\s+$//;
  }
  if (/[*][*][*]$/) {
    if ($len != 79) {
      print STDERR "Comment line $len not 79 bytes, line: $i\n";
      if ($showline) {print STDERR "$_"}
      $_ = substr("$_******************************************************************************",0,79);
      print STDOUT "$_\n";
      next;
    }
  }
  if (/^[*][*][*][*]+[\/]$/) {
    if ($len != 79) {
     print STDERR "Comment end $len not 79 bytes, line: $i\n";
      if ($showline) {print STDERR "$_"}
     print STDOUT "******************************************************************************/\n";
      next;
    }
  }
  if ($len > 79) {
    print STDERR "+++ Too long ($len) line: $i\n";
    if ($showline) {print STDERR "$_"}
    print STDOUT "$_\n";
    next;
  }
  print STDOUT "$_\n";
}