Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
1.9 KiB

  1. # Dictionary manipulation
  2. sub loadDictionaries {
  3. my $n = "style.dic";
  4. my $words = 0;
  5. if (!open(DIC, "$n")) {
  6. my $fn = $0;
  7. $fn =~ s/\\[^\\]*$/\\$n/;
  8. if (!open(DIC, $fn)) {
  9. print "Can't find dictionary file \"$n\"\n";
  10. return;
  11. }
  12. }
  13. my $dicname="";
  14. print "Loading dictionaries...\n";
  15. while (<DIC>) {
  16. chop;
  17. my $c = substr($_,0,1);
  18. # Ignore blank lines
  19. next if !$_ || ($c eq " ");
  20. # Match new dictionary name
  21. if ($c eq "*") {
  22. $dicname = substr($_,2);
  23. push (@dictionaries, $dicname);
  24. next;
  25. }
  26. # Asssume it's a word; add it to the current dictionary
  27. $words++;
  28. eval "\$dic_$dicname"."{\$_}=1";
  29. eval "push (\@dic_$dicname, \$_)";
  30. }
  31. close(DIC);
  32. print "Dictionaries loaded - $words words\n";
  33. }
  34. sub writeDictionaries {
  35. my $n = "style.dic";
  36. if (!open(DIC, ">$n")) {
  37. print "Can't write dictionary file \"$n\"\n";
  38. return;
  39. }
  40. my $first = 1;
  41. foreach $dicname (@dictionaries) {
  42. print DIC "\n* $dicname\n\n";
  43. print "$dicname:\n";
  44. my @d;
  45. eval "\@d = \@dic_$dicname";
  46. foreach (sort @d) {
  47. print DIC "$_\n";
  48. }
  49. }
  50. close(DIC);
  51. }
  52. sub writeSpellingErrors {
  53. my (@categories) = @_;
  54. my @d;
  55. open(ERRORS, ">spelling.err");
  56. foreach $n (@categories) {
  57. eval "\@d = \@errors_$n;";
  58. if ($#d >= 0) {
  59. print ERRORS "\n* $n\n\n";
  60. }
  61. my $lastword = "";
  62. foreach (sort @d) {
  63. next if $_ eq $lastword;
  64. $lastword = $_;
  65. print ERRORS "$_\n";
  66. }
  67. }
  68. close(ERRORS);
  69. };
  70. 1;