This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update the reference to the GitHub issue tracker
[metaconfig.git] / U / spellcheck-U
1 #!/usr/bin/perl
2
3 use 5.016;
4 use warnings;
5 use autodie;
6
7 use File::Find;
8
9 use Pod::Spell::CommonMistakes::WordList qw( _check_case _check_common );
10 use Text::Aspell;
11
12 my @u;
13 find (sub { m/\.U$/ && !-l && -s and push @u, $File::Find::name }, glob "*");
14
15 my %ignore = (
16     "modified/Oldconfig.U"      => {
17         "gnu"           => "GNU",               # output of uname
18         },
19     "perl/patchlevel.U"         => {
20         "subversion"    => "Subversion",        # perl's subversion, not svn
21         },
22     );
23 my %skip = map { m/^(\S+)/; lc $1 => 1 } <DATA>;
24 if (open my $fh, "<", "/pro/3gl/CPAN/perl-git/Porting/Glossary") {
25     while (<$fh>) {
26         m/^(\S+)\s+\(\S+\)\s*:\s*$/ and $skip{lc $1}++;
27         }
28     }
29 if (open my $fh, "<", "/pro/3gl/CPAN/perl-git/config_h.SH") {
30     while (<$fh>) {
31         m{^/\* ([A-Z_]+):$} and $skip{lc $1}++;
32         }
33     }
34
35 my $asp = Text::Aspell->new;
36
37 foreach my $u (sort @u) {
38     open my $fh, "<", $u;
39
40     my ($m) = ($u =~ m{([^/]+)\.U$});
41     $skip{lc $m}++;
42
43     my $n = 0;
44     while (<$fh>) {
45
46         my $loc = sprintf "%-27s %4d", $u, ++$n;
47
48         m{^(?| \?RCS:   \s+ (\w.*)
49              | \?C:     \s+ (\w.*)
50              | \?S:     \s+ (\w.*)
51              | \?INIT:: \s+ (\w.*)
52              | \?X:     \s* (\w.*)
53              | :        \s+ (\w.*)
54              )}x or
55         m{echo \s+ (?| "([^"]+)"
56                      | '([^']+)'
57                      )}x or next;
58
59         my $t = $1;
60         $t =~ s/\b( [Ww]as
61                   | [Dd]id
62                   | [Ii]s
63                   | [Cc]ould
64                   | [Ss]hould
65                   | [Dd]oes
66                   | [Nn]eed
67                   | [Aa]re
68                   ) n't
69                   \b/$1 not/gx;
70         $t =~ s{\b[fh]tt?ps?://\S+}{}g; # possible url
71         $t =~ s{<\S+\@\S+>}{}g;         # possible e-mail address
72         $t =~ s{<\S+\.h>}{}g;           # possibly header file reference
73         $t =~ s{"\S+\.h"}{}g;           # possibly header file reference
74
75         my @w = split m([!-#'-,./:-?[-^`{-~\s]+) => $t;
76
77         # CommonMistakes
78         my ($err, %seen);
79         $err = _check_case (\@w);
80         if (ref $err eq "HASH" && keys %$err) {
81             for (sort keys %$err) {
82                 exists $ignore{$u}{$_} and next;
83                 $seen{$_}++ and next;;
84                 printf "%s %-20s => %s\n", $loc, $_, $err->{$_};
85                 }
86             }
87
88         $err = _check_common (\@w);
89         if (ref $err eq "HASH" && keys %$err) {
90             for (sort keys %$err) {
91                 exists $ignore{$u}{$_} and next;
92                 $seen{$_}++ and next;;
93                 printf "%s %-20s => %s\n", $loc, $_, $err->{$_};
94                 }
95             }
96
97         # aspell
98         for (grep { !m/[-0-9_\$@%~]/ } @w) {
99             exists $ignore{$u}{$_} and next;
100             exists $skip{lc $_}    and next;
101             $asp->check ($_)       and next;
102             my @s = $asp->suggest ($_);
103             printf "%s %-20s => %s\n", $loc, $_, "(@s)";
104             }
105         }
106     }
107
108 __END__
109 abcdef
110 accessx
111 aintl
112 aix
113 alignedness
114 andreas
115 ansic
116 archlibs
117 arg
118 argc
119 args
120 argv
121 arrgh
122 asctime
123 asm
124 atof
125 attrlist
126 backquotes
127 backslashitis
128 backticks
129 basename
130 basenames
131 baz
132 bcopy
133 bene
134 bincompat
135 bitness
136 bourne
137 braindead
138 brand
139 bsd
140 bsdtypes
141 buf
142 buglet
143 builtin
144 calloc
145 canonicalize
146 castneg
147 catify
148 cbu
149 ccs
150 cd
151 cdpath
152 ceil
153 cflags
154 charvsprintf
155 chorusos
156 chown
157 cjk
158 clearenv
159 clib
160 closedir
161 cmd
162 cmdline
163 cmsghdr
164 cnt
165 conf
166 config
167 configpm
168 const
169 copysignl
170 cposix
171 css
172 csym
173 ctermid
174 cthreads
175 ctime
176 ctype
177 cygwin
178 datatype
179 dbm
180 dbminit
181 dec
182 denormalized
183 dev
184 dflt
185 dg
186 difftime
187 dir
188 dirent
189 dirfd
190 dirname
191 dirnames
192 dirstream
193 djgpp
194 dl
195 dld
196 dll
197 dlobj
198 dlopen
199 dlsym
200 doughera
201 dougherty
202 drepper
203 dst
204 dwhatever
205 dynaloader
206 dynix
207 eaccess
208 edu
209 elif
210 emx
211 emximp
212 endgrent
213 endhostent
214 endian
215 endif
216 endnetent
217 endprotoent
218 endpwent
219 endservent
220 endspent
221 enoent
222 enosys
223 enum
224 enums
225 env
226 eof
227 eofpipe
228 eom
229 eot
230 eqnchar
231 errno
232 errnolistc
233 esac
234 euid
235 eval
236 evals
237 exe
238 executables
239 extern
240 extliblist
241 extutils
242 fallthrough
243 fastread
244 faststdio
245 fchdir
246 fcntl
247 fd
248 fflush
249 fi
250 fielnames
251 fifos
252 filename
253 filenames
254 filesystem
255 filesystems
256 finitel
257 fiosnbio
258 firstkey
259 fixme
260 fn
261 fndelay
262 foo
263 fp
264 fpa
265 fpclass
266 fpclassify
267 fpclassl
268 fprintf
269 fread
270 freebsd
271 frexpl
272 fseek
273 fseeko
274 fsetpos
275 fstat
276 fstatfs
277 fstatvfs
278 fsync
279 ftell
280 ftello
281 furuseth
282 futimes
283 fwrite
284 gconvert
285 gcvt
286 gdbm
287 getaddrinfo
288 getc
289 getcwd
290 getdtablesize
291 getespwnam
292 getfile
293 getfsstat
294 getgid
295 getgrent
296 getgrgid
297 getgrnam
298 gethost
299 gethostbyaddr
300 gethostbyname
301 gethostent
302 gethostname
303 gethostxxx
304 getitimer
305 getlogin
306 getmnt
307 getmntent
308 getmntinfo
309 getnameinfo
310 getnet
311 getnetbyaddr
312 getnetbyname
313 getnetent
314 getnetxxx
315 getpagesize
316 getpgrp
317 getpos
318 getproto
319 getprotobyaddr
320 getprotobyname
321 getprotobynumber
322 getprotoent
323 getprotoxxx
324 getprpwnam
325 getpw
326 getpwent
327 getpwnam
328 getpwuid
329 getrlimit
330 getrusage
331 getsbyname
332 getsbyport
333 getserv
334 getservbyaddr
335 getservbyname
336 getservbyport
337 getservent
338 getservxxx
339 getspent
340 getspnam
341 getuid
342 getvar
343 gid
344 gids
345 glibc
346 gmtime
347 gnu
348 gnulibc
349 grp
350 hallvard
351 hardwire
352 hardwiring
353 hasmntopt
354 hdrs
355 hexadecimal
356 hietaniemi
357 hmb
358 hostname
359 hpux
360 html
361 htonl
362 htons
363 hup
364 hurd
365 iconv
366 ieeefp
367 ifdef
368 ifndef
369 ihdr
370 ilogbl
371 incpth
372 incpush
373 indices
374 inet
375 inhdr
376 init
377 initprog
378 inlibc
379 inode
380 inodes
381 installdirs
382 installlocalarch
383 installlocallib
384 installperl
385 ints
386 inttypes
387 iovec
388 ip
389 ipc
390 irix
391 is
392 isascii
393 isblank
394 isc
395 isdone
396 isfinite
397 isinf
398 isnan
399 isnanl
400 ivs
401 ix
402 jaeger
403 jarkko
404 jhi
405 joinable
406 keepalive
407 koenig
408 korn
409 k&r
410 lafayette
411 langinfo
412 lchmod
413 lchown
414 ldopts
415 lex
416 libexec
417 libexp
418 libm
419 libso
420 libsocks
421 libutil
422 llseek
423 loc
424 localarchexp
425 locallibexp
426 localtime
427 loclist
428 login
429 logname
430 longjmp
431 longlong
432 lookup
433 lookups
434 lorder
435 lseek
436 lst
437 lutimes
438 lvalue
439 machten
440 madvise
441 makedist
442 makefile
443 makefiles
444 makemaker
445 malloc
446 mandirstyle
447 manfredi
448 manoj
449 mansrc
450 memchr
451 memcmp
452 memcpy
453 memmove
454 merijn
455 metaconfig
456 metalint
457 mips
458 misconfigured
459 mk
460 mkdtemp
461 mkfifo
462 mknod
463 mkstemp
464 mkstemps
465 mktime
466 mman
467 mmap
468 mntent
469 modfl
470 monash
471 morebits
472 mpe
473 mprotect
474 mqueue
475 msg
476 msghdr
477 msvc
478 multiplatform
479 myconfig
480 myinit
481 myread
482 nan
483 nanosleep
484 nanq
485 nans
486 ndbm
487 ndir
488 netbsd
489 netdb
490 netdbtype
491 netinet
492 netinfo
493 netwide
494 neumann
495 nevermind
496 next
497 nextkey
498 nfs
499 nis
500 nlist
501 nofile
502 nonnull
503 nonxs
504 noreturn
505 nota
506 nrand
507 nsig
508 ntohl
509 ntohs
510 nvs
511 nwc
512 odbm
513 ok
514 okamoto
515 oldconfig
516 oldprefix
517 oldsocket
518 oldsyms
519 opcode
520 optdef
521 os
522 osf
523 oslevel
524 pagefull
525 pase
526 passwd
527 pathname
528 pathnames
529 pc
530 perldoc
531 perlio
532 perlmain
533 perly
534 pgrp
535 pid
536 pids
537 popen
538 posix
539 posixized
540 posthint
541 prctl
542 prefixvar
543 prepend
544 prepended
545 preprocess
546 preprocessor
547 printf
548 prot
549 pthread
550 pthreads
551 ptr
552 ptx
553 pvs
554 pwd
555 qgcvt
556 qnx
557 readdir
558 readv
559 realloc
560 realpath
561 realsilent
562 recompiles
563 recvmsg
564 redhat
565 reentr
566 resolv
567 ret
568 rp
569 rsrc
570 ruid
571 runtime
572 rusage
573 sahlbach
574 salzenberg
575 sbin
576 sbrk
577 scalbnl
578 scanf
579 sched
580 sco
581 sdbm
582 sem
583 semctl
584 semun
585 sendmsg
586 setgid
587 setgrent
588 sethostent
589 setitimer
590 setjmp
591 setlocale
592 setnetent
593 setpgrp
594 setpos
595 setproctitle
596 setprotoent
597 setpwent
598 setresgid
599 setresuid
600 setrgid
601 setrlimit
602 setservent
603 setsockopt
604 setspent
605 setuid
606 setvar
607 setvbuf
608 sfio
609 sgi
610 shlib
611 shm
612 shmat
613 sig
614 sigabrt
615 sigaction
616 sigarraysize
617 sigiot
618 siglongjmp
619 signbit
620 signedchar
621 signedness
622 sigprocmask
623 sigqueue
624 sigquit
625 sigrtmax
626 sigsetjmp
627 sigstksize
628 sigstksz
629 sigtimedwait
630 sigtyp
631 sigwait
632 sigwaitinfo
633 sigxxx
634 sigzero
635 sitecustomize
636 sitescriptdirexp
637 sizeof
638 skimo
639 sl
640 snprintf
641 sockaddr
642 sockatmark
643 socketpair
644 socklib
645 solaris
646 sony
647 sprintf
648 sqrtl
649 srand
650 srandom
651 src
652 srivastava
653 statfs
654 statvfs
655 stdarg
656 stdbool
657 stderr
658 stdin
659 stdlib
660 stdout
661 strerror
662 strftime
663 stringification
664 stringifies
665 strlcat
666 strlcpy
667 strlen
668 strptime
669 strtold
670 strtoll
671 strtoq
672 strtoul
673 strtoull
674 strtouq
675 struct
676 structs
677 su
678 subdirectories
679 subdirectory
680 subprocesses
681 subr
682 subshell
683 subversions
684 suid
685 sunmath
686 sunos
687 sunworks
688 superseed
689 symlink
690 symlinking
691 symlinks
692 sys
693 syscall
694 syscalls
695 sysctl
696 syslib
697 syslog
698 syspath
699 systemid
700 systype
701 sysv
702 targetdir
703 targetfrom
704 targethost
705 targetmkdir
706 targetrun
707 targetto
708 targetuser
709 tcp
710 telldir
711 thatlib
712 thislib
713 timegm
714 timestamp
715 timestamps
716 timeval
717 timevals
718 tm
719 tmp
720 tmpfile
721 tmpnam
722 tromey
723 tryh
724 trylist
725 tsort
726 ttyname
727 tye
728 typedef
729 typedefs
730 tzset
731 ualarm
732 ucb
733 uid
734 uids
735 uint
736 uio
737 uis
738 ulimit
739 ulrich
740 ultrix
741 undef
742 undefines
743 undefining
744 undetached
745 unicos
746 unistd
747 unix
748 unlink
749 unordered
750 unorderedl
751 unsetenv
752 unsplit
753 uppercased
754 usg
755 ushort
756 usleep
757 usr
758 ustat
759 util
760 utimes
761 utsname
762 uu
763 uvs
764 ux
765 varargs
766 variadic
767 varval
768 venix
769 verdoolaege
770 versa
771 versioned
772 versioning
773 vfork
774 vfs
775 voidsig
776 voidused
777 vos
778 vpath
779 vprintf
780 vsnprintf
781 vsprintf
782 whoami
783 wifexited
784 wifxxx
785 wildcard
786 wildcards
787 winfried
788 workshop
789 writeup
790 writev
791 xenix
792 xlc
793 xrun
794 xs
795 xscan
796 xvt
797 yp
798 ypmatch
799 zsh