File: m_f.pl

package info (click to toggle)
moxftp 2.2-18.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,160 kB
  • ctags: 3,837
  • sloc: ansic: 43,420; makefile: 353; perl: 262; sh: 192
file content (58 lines) | stat: -rwxr-xr-x 1,232 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
46
47
48
49
50
51
52
53
54
55
56
57
58
open(output, ">fb_rs.c");
print output "#include \"defs.h\"\n\n";
do make("MOTIF",        "Mftp.ad");
do make("XAW"  ,        "Xftp.ad");
do make("OPENWINDOW"  , "Oftp.ad");

sub fix {
    local($string) = @_[0];
    if ( $string =~ /\\n\\$/) {
       $string = substr($string, 0, length($string) - 3) . "\\\\n\\";
    }

    if ($string =~ /\\ /) {
        $string =~ s/\\ /\\\\ /g;
    }
    if ($string =~ /\"/) {
        $string =~ s/\"/\\\"/g;
    }
    $string;
}

sub make {
    local($type, $file) = @_;
    print output "#if defined($type)\n";
    open(input, $file);

    print output "String fallback_resources[] = {\n";
    while (<input>) {
	chop;
	if (/^;/) { next; }
	if (/(\S\S*:)(.*)/) {
	    $p1 = $1;
	    undef(@p2);
	    if ($2) {
	        $p2 = do fix($2);
 	    }
	    if ($2) { push(@p2, $p2); }
	    if (/\\$/) {
	    	while(<input>) {
		    chop;
		    $p2 = do fix($_);
		    push(@p2, $p2);
		    if (!/\\$/) { last;}
		}
	    }
	    if (@p2 == 0 ) { next; }
	    print output "\"$p1";
	    $item = shift(@p2);
	    print output "$item";
	    foreach $item (@p2) {
	    	print output "\n$item";
	    }
	    print output "\\n\",\n";
	}
    }
    print output "NULL,\n};\n";
    print output "#endif\n";
}