File: expndflg.pl

package info (click to toggle)
norwegian 2.2-4
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 26,448 kB
  • sloc: perl: 2,695; makefile: 1,678; sh: 209
file content (57 lines) | stat: -rwxr-xr-x 1,594 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/perl
# Purpose: Expand list so that there is one line for each word/flag character 
#          combination, and remove combinations that would lead to redundancies
# Remarks: This script is reverse-engineered from old, slow and messy sed/awk
#          commands in Makefile for "ispell norsk"

foreach $fileName (@ARGV) {
    open(FILE, $fileName);

    chop($line=<FILE>);
    $line=~tr//-/ if($line);
    
    while($line) {
	chop($nextLine=<FILE>);
	$nextLine=~tr//-/ if($nextLine);

	$line=~s/(e(t\/.*T.*|r\/.*I.*))V/$1/;
	$line=~s/(e\/.*[TB].*)W/$1/;
	$line=~s/([^ei]um\/.*B.*)I/$1/;
	
	my($word, $flags)=split('/', $line);
	
	$flags=~s/^(.*[AB]|)E/$1/ if($nextLine=~m/^${word}er\/AI/);
	
	if(!$flags) {
	    # Note: Old sed scripts would print an extra ' ' after '/' in this
	    #       case; this may or may not be necessary
	    print($word, "/");
	    print("`") if($word=~m/zyzyzy$/);
	    print("\n");
	} else {
	    print($word, "/\n");
	    
	    # Note: The below 'm' operator will return a list of letters
	    #       in $flags, since a list if every possible match is returned
	    #       when using 'g' flag, and '.' matches any single character.
	    foreach $flag (($flags=~m/./g)) {
		print($word, "/");
		
		if(!($flag=~m/[a-s]/g)) {
		    foreach $prefix (($flags=~m/[a-s]/g)) {
			print($prefix);
		    }
		}
		print($flag, "\n");
	    }

	    if($flags=~m/[A-Zt-z]/ && !($word=~m/(re|er)$/)) {
		$nextLine=~s/(${word}e\/.*)R/$1/;
		$nextLine=~s/\/$//; # Remove separator if no flags are left
	    }
	}
	
        $line=$nextLine;
    }
    close(FILE);
}