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

Last change on this file since 194 was 194, checked in by mitty, 11 years ago
  • remove needless export of NFKC
  • change order of decode() and remove needless binmode
  • Property svn:executable set to *
File size: 941 bytes
RevLine 
[187]1#! /usr/bin/perl -w
2
3use strict;
4use warnings;
5use utf8;
6
[192]7use Encode;
[194]8use Unicode::Normalize qw(NFC);
[187]9
10my $top = shift @ARGV || exit;
11if (! -d $top) { exit; }
12
[192]13my $utf8 = find_encoding("utf8");
14
[187]15checkdir($top);
16
[188]17sub match {
[187]18    my $str = shift @_;
19   
[194]20    $str = $utf8->decode($str);
[187]21    if ($str ne NFC($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;
[193]33    my @entries = sort grep { !m/^(\.|\.\.)$/g } readdir($dir);
[187]34    closedir($dir);
35   
36    my @dirs;
37    while (my $entry = shift @entries) {
[188]38        if (match($entry)) {
[187]39            print "'$target/$entry' can be composed\n";
40            next;
41        }
42        if (-d "$target/$entry") {
43            push @dirs, $entry;
44            next;
45        }
46    }
47   
48    while (my $entry = pop @dirs) {
49        checkdir("$target/$entry");
50    }
51}
Note: See TracBrowser for help on using the repository browser.