Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge remote-tracking branch 'origin2/master'
[simgrid.git] / src / smpi / fixsrc.pl
1 #!/usr/bin/env perl
2
3 # Copyright (c) 2011, 2014. The SimGrid Team.
4 # All rights reserved.
5
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
8
9 # Add include for mandatory header file
10 print "#include <smpi_cocci.h>\n";
11
12 # FIXME: here we make the assumption that people don't do things like put
13 # multiple statements on the same line after a declaration, but separated by
14 # semicolons. It's a reasonable assumption for the time being, but technically
15 # it could cause problems for some code.
16
17 OUTER: while ($line = <STDIN>) {
18     if ($line =~ /SMPI_VARINIT/) {
19         do {
20             chomp $line;         # kill carriage return
21             $line =~ s/\s+/ /g;  # remove excessive whitespace added by spatch
22             while ($line =~ s/(SMPI_VARINIT[A-Z0-9_]*?\(.*?\))//) {
23                 print "$1\n";
24             } 
25
26             # if varinit continues on to next line
27             if ($line =~ /SMPI_VARINIT/) {
28                 # should only happen for bad code...
29                 if (!($nextline = <STDIN>)) {
30                     last OUTER;
31                 }
32                 $line .= $nextline;
33
34             }
35         } while ($line =~ /SMPI_VARINIT/);
36     } else {
37         print $line;
38     }
39 }