projects
/
lab.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
utils::get gives hashref tree from API
[lab.git]
/
misc
/
findcombinable.pl
diff --git
a/misc/findcombinable.pl
b/misc/findcombinable.pl
index
b6e62a9
..
667d6bd
100755
(executable)
--- a/
misc/findcombinable.pl
+++ b/
misc/findcombinable.pl
@@
-3,23
+3,23
@@
use strict;
use warnings;
use utf8;
use strict;
use warnings;
use utf8;
-use encoding 'utf-8';
-use Unicode::Normalize qw(NFC NFKC);
+use Encode;
+use Unicode::Normalize qw(NFC);
my $top = shift @ARGV || exit;
if (! -d $top) { exit; }
my $top = shift @ARGV || exit;
if (! -d $top) { exit; }
+my $utf8 = find_encoding("utf8");
+
checkdir($top);
sub match {
my $str = shift @_;
checkdir($top);
sub match {
my $str = shift @_;
+ $str = $utf8->decode($str);
if ($str ne NFC($str)) {
if ($str ne NFC($str)) {
- return 1;
- }
- if ($str ne NFKC($str)) {
- return 1;
+ return $utf8->encode(NFC($str));
}
return '';
}
return '';
@@
-28,16
+28,15
@@
sub match {
sub checkdir {
my $target = shift @_;
sub checkdir {
my $target = shift @_;
- print STDERR "checking '$target'\n";
+ print STDERR "# checking '$target'\n";
opendir(my $dir, $target) || return $target;
opendir(my $dir, $target) || return $target;
- my @entries = sort readdir($dir);
+ my @entries = sort grep { !m/^(\.|\.\.)$/g } readdir($dir);
closedir($dir);
my @dirs;
while (my $entry = shift @entries) {
closedir($dir);
my @dirs;
while (my $entry = shift @entries) {
- next if ($entry =~ /^\.+$/);
- if (match($entry)) {
- print "'$target/$entry' can be composed\n";
+ if (my $composed = match($entry)) {
+ print "'$target/$entry' can be composed to '$composed'\n";
next;
}
if (-d "$target/$entry") {
next;
}
if (-d "$target/$entry") {