summaryrefslogtreecommitdiffstats
path: root/runtime/compiler/fortran_g77.vim
blob: 744ce6a334e8928898de0d6bf2214e53895077df (plain)
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
40
41
42
43
44
45
46
47
48
" Vim compiler file
" Compiler:     g77 (GNU Fortran)
" Maintainer:   Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
" Last Change:  $Date: 2004/06/13 18:17:36 $
" $Revision: 1.1 $

if exists("current_compiler")
  finish
endif
let current_compiler = "fortran_g77"

if exists(":CompilerSet") != 2		" older Vim always used :setlocal
  command -nargs=* CompilerSet setlocal <args>
endif

let s:cpo_save = &cpo
set cpo-=C

" Note: The errorformat assumes GNU make

" sample multiline errors (besides gcc backend one-liners):
" gev.f:14:
"	   parameter UPLO = 'Upper-triangle'
"	   ^
" Unsupported VXT statement at (^)
" gev.f:6:
"	   integer	   desca( * ), descb( * )
"			   1
" gev.f:19: (continued):
"	   end subroutine
"	   2
" Invalid declaration of or reference to symbol `desca' at (2) [initially seen at (1)]

CompilerSet errorformat=
	\%Omake:\ %r,
	\%f:%l:\ warning:\ %m,
	\%A%f:%l:\ (continued):,
	\%W%f:%l:\ warning:,
	\%A%f:%l:\ ,
	\%-C\ \ \ %p%*[0123456789^]%.%#,
	\%-C\ \ \ %.%#,
	\%D%*\\a[%*\\d]:\ Entering\ directory\ `%f',
	\%X%*\\a[%*\\d]:\ Leaving\ directory\ `%f',
	\%DMaking\ %*\\a\ in\ %f,
	\%Z%m

let &cpo = s:cpo_save
unlet s:cpo_save
0] =~ /^-/) { if ($ARGV[0] eq "-r") { $remove = 1; shift; } else { usage(); } } } foreach my $file (@ARGV) { open(my $f, '<', $file) or die "Cannot open $file: $!.\n"; my %includedfiles = (); my @file_lines = (); while (<$f>) { if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) { ++$includedfiles{$1}; } push(@file_lines, $_); } close($f); if (!$remove) { foreach my $filename (keys %includedfiles) { if ($includedfiles{$filename} > 1) { print "$file: $filename is included more than once.\n"; } } next; } open($f, '>', $file) or die("Cannot write to $file: $!"); my $dups = 0; foreach (@file_lines) { if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) { foreach my $filename (keys %includedfiles) { if ($1 eq $filename) { if ($includedfiles{$filename} > 1) { $includedfiles{$filename}--; $dups++; } else { print {$f} $_; } } } } else { print {$f} $_; } } if ($dups > 0) { print "$file: removed $dups duplicate includes\n"; } close($f); }