File: no_vr_val.pm

package info (click to toggle)
octave2.1-forge 2006.03.17%2Bdfsg1-7
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 16,672 kB
  • ctags: 6,047
  • sloc: cpp: 49,610; ansic: 14,035; perl: 2,789; sh: 2,087; makefile: 1,560; lex: 1,219; tcl: 799; fortran: 422; objc: 202
file content (45 lines) | stat: -rw-r--r-- 811 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl -w -n

## Catches vr_val (x) transforms it into varargout(i++) = x;
## 

use OctRe;

BEGIN {
    $first = "vr_val_cnt = 1; ";

}

## Does necessary changes inplace on $_[0].
sub change_line {
    
    if ($_[0] !~ /^\s*\#/) {	# Don't do obvious comment lines

				# Change function declaration
	if ($_[0] =~ /$defun_rx/) {
	    $_[0] =~ s/\.\.\.(\s*\]\s*\=)/varargout$1/g;
	}
				# Change vr_val()

				# BTW, if 1st vr_val() occurs in a loop,
				# this will NOT WORK!

	if ($_[0] =~ 
	    s{vr_val\s*\(([^;]*)\)(\s*;)}
	    {"$first" . "varargout\{vr_val_cnt++\} = $1$2"}eg) {

	    $first = "";
	}
				# Did I miss anything?
	if ($_[0] =~ /vr_val\s*\(/) {
	    $_[0] .= "## TODO : Remove this vr_val\n";
	}

    }
    $first = "vr_val_cnt = 1; " if $. == 1;
}

sub comment_line {
    ""
}
1;