extensions/spellcheck/locales/en-US/hunspell/dictionary-sources/dupe-dictionary.pl
author Nick Alexander <nalexander@mozilla.com>
Wed, 09 Jul 2014 08:22:13 -0700
changeset 193273 13d9e025fc86e727793af1d30dbee89993149cde
parent 189502 ca251a28d3ddae784436d28829fb019025f4b127
child 241794 7723b15ea695e321e6acda04beef9bc98728dd13
permissions -rw-r--r--
Bug 1033560 - Follow-up: Fix missed rename. a=bustage DONTBUILD because the feature is not enabled on TBPL.

#!/usr/bin/perl
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

#
# dupe-dictionary.pl
#
# This will find all duplicate words in a myspell/hunspell format .dic file.
# It ignores affix rules, so 'One/ADG' = 'One' = 'One/12'
#
# Returns error if dupes are found

use strict;
use warnings;

my %seen;
my $bad = 0;

print "Duplicated entries:\n";

while (<>) {
    my $key = (split /([\n\/])/)[0];
    if (($key ne "") && (exists $seen{$key})) {
        $seen{$key}++;
        print "$key\n";
	# print ord($key);
	$bad++;
    } else {
        $seen{$key} = 1;
    }
}

if ($bad == 0) {
    print "None!\n";
} else {
       die "Duplicates found!";
}