summaryrefslogtreecommitdiffstats
path: root/tderesources/groupwise/soap/fixup_groupwise.h.pl
blob: 938811179ea6db33eb0329492291e7e5dbe92ab0 (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
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl

use strict;

my $inplace;

if ( @ARGV == 1 && $ARGV[ 0 ] == "--inplace" ) {
  print "Substituting in place.\n";
  $inplace = 1;
}

my $fileIn = "groupwise.h";
my $fileOut = "$fileIn.fixed";
my $fileBack = "$fileIn.backup";

if ( !open IN, $fileIn ) {
  print STDERR "Unable to open '$fileIn'.\n";
  exit 1;
}

if ( !open OUT, ">$fileOut" ) {
  print STDERR "Unable to open '$fileOut'.\n";
  exit 1;
}

while ( <IN> ) {
  my $newline;

  if ( /^(.*)ns1__(\w+\s+0?;.*)$/ ) {
#    print;
    $newline = $1 . $2 . "\n";
#    print $newline;
    $_ = $newline;
  }

if ( 0 ) {
  if ( /(^\s+\S+\s+)ns1__(.*)/ ) {
    $newline = $1 . $2 . "\n";
    if ( !/enum/ && /element$/) {
#      print;
#      print $newline;
      $_ = $newline;
    }
  } elsif ( /(^\s+unsigned long\*\s+)ns1__(.*)/ ) {
    $newline = $1 . $2 . "\n";
#    print $newline;
    $_ = $newline;
  } elsif ( /(^\s+std\:\:\S+\s+\>.*)ns1__(.*)/ ) {
    $newline = $1 . $2 . "\n";
    $_ = $newline;
  }
}

  print OUT;
}

if ( $inplace ) {
  system( "mv $fileIn $fileBack" );
  system( "mv $fileOut $fileIn" );
}