source: lab/trunk/misc/findcombinable.pl @ 188

Last change on this file since 188 was 188, checked in by mitty, 11 years ago
  • change function name to reuse code easily
  • Property svn:executable set to *
File size: 954 bytes
Line 
1#! /usr/bin/perl -w
2
3use strict;
4use warnings;
5use utf8;
6use encoding 'utf-8';
7
8use Unicode::Normalize qw(NFC NFKC);
9
10my $top = shift @ARGV || exit;
11if (! -d $top) { exit; }
12
13checkdir($top);
14
15sub match {
16    my $str = shift @_;
17   
18    if ($str ne NFC($str)) {
19        return 1;
20    }
21    if ($str ne NFKC($str)) {
22        return 1;
23    }
24   
25    return '';
26}
27
28sub checkdir {
29    my $target = shift @_;
30   
31    print STDERR "checking '$target'\n";
32    opendir(my $dir, $target) || return $target;
33    my @entries = sort readdir($dir);
34    closedir($dir);
35   
36    my @dirs;
37    while (my $entry = shift @entries) {
38        next if ($entry =~ /^\.+$/);
39        if (match($entry)) {
40            print "'$target/$entry' can be composed\n";
41            next;
42        }
43        if (-d "$target/$entry") {
44            push @dirs, $entry;
45            next;
46        }
47    }
48   
49    while (my $entry = pop @dirs) {
50        checkdir("$target/$entry");
51    }
52}
Note: See TracBrowser for help on using the repository browser.