source: lab.git/misc/findcombinable.pl @ 89fbc5d

trunk
Last change on this file since 89fbc5d was 89fbc5d, checked in by mitty <mitty@…>, 11 years ago

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@191 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

  • Property mode set to 100755
File size: 932 bytes
Line 
1#! /usr/bin/perl -w
2
3use strict;
4use warnings;
5use utf8;
6
7use Unicode::Normalize qw(NFC NFKC);
8
9my $top = shift @ARGV || exit;
10if (! -d $top) { exit; }
11
12checkdir($top);
13
14sub match {
15    my $str = shift @_;
16   
17    if ($str ne NFC($str)) {
18        return 1;
19    }
20    if ($str ne NFKC($str)) {
21        return 1;
22    }
23   
24    return '';
25}
26
27sub checkdir {
28    my $target = shift @_;
29   
30    print STDERR "checking '$target'\n";
31    opendir(my $dir, $target) || return $target;
32    my @entries = sort readdir($dir);
33    closedir($dir);
34   
35    my @dirs;
36    while (my $entry = shift @entries) {
37        next if ($entry =~ /^\.+$/);
38        if (match($entry)) {
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.