annotate doc/interpreter/doccheck/spellcheck @ 26376:00f796120a6d stable

maint: Update copyright dates in all source files.
author John W. Eaton <jwe@octave.org>
date Wed, 02 Jan 2019 16:32:43 -0500
parents 6652d3823428
children b442ec6dda5c 6628a284d56d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
1 #!/usr/bin/perl -w
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
3 ## Copyright (C) 2010-2019 Rik Wehbring
22799
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
4 ##
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
5 ## This file is part of Octave.
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
6 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23221
diff changeset
7 ## Octave is free software: you can redistribute it and/or modify it
22799
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
8 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23221
diff changeset
9 ## the Free Software Foundation, either version 3 of the License, or
22799
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
10 ## (at your option) any later version.
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
11 ##
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
12 ## Octave is distributed in the hope that it will be useful, but
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
15 ## GNU General Public License for more details.
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
16 ##
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
17 ## You should have received a copy of the GNU General Public License
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
18 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23221
diff changeset
19 ## <https://www.gnu.org/licenses/>.
22799
592fa741e0aa add missing copyright notices (bug #49624)
John W. Eaton <jwe@octave.org>
parents: 22341
diff changeset
20
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
21 ################################################################################
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
22 # File : spellcheck
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
23 # Purpose: Spellcheck a single Texinfo file
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 10795
diff changeset
24 # written in Perl, rather than the shell, to be more portable to OS
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
25 # without good command lines such as Windows.
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
26 # Usage : spellcheck FILENAME.texi
22341
770fb2070e96 doc: Clean up tools used to check Texinfo documentation.
Rik <rik@octave.org>
parents: 19593
diff changeset
27 # Documentation: see README in doccheck directory
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
28 ################################################################################
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
29 use File::Temp ":POSIX";
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
30
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
31 # Initialize variables
22341
770fb2070e96 doc: Clean up tools used to check Texinfo documentation.
Rik <rik@octave.org>
parents: 19593
diff changeset
32 # Octave specific configuration file for aspell
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
33 $aspell_conf = './doccheck/aspell.conf';
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
34
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
35 ################################################################################
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
36 # Parse command line arguments
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
37 if (@ARGV != 1)
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
38 {
22341
770fb2070e96 doc: Clean up tools used to check Texinfo documentation.
Rik <rik@octave.org>
parents: 19593
diff changeset
39 die ("USAGE: spellcheck <filename.texi>\n",
770fb2070e96 doc: Clean up tools used to check Texinfo documentation.
Rik <rik@octave.org>
parents: 19593
diff changeset
40 " invoked from doc/interpreter directory\n");
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
41 }
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
42
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
43 ################################################################################
22341
770fb2070e96 doc: Clean up tools used to check Texinfo documentation.
Rik <rik@octave.org>
parents: 19593
diff changeset
44 # Run aspell with Octave-specific configuration file.
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
45 # Avoid use of pipes and use temporary files for portability
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
46 $fname = shift(@ARGV);
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
47 $tmp_fname = &tmpnam(); # from File::Temp
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
48 system ("aspell --conf=$aspell_conf list < $fname > $tmp_fname");
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
49
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
50 if ($?)
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
51 {
22341
770fb2070e96 doc: Clean up tools used to check Texinfo documentation.
Rik <rik@octave.org>
parents: 19593
diff changeset
52 unlink ($tmp_fname);
770fb2070e96 doc: Clean up tools used to check Texinfo documentation.
Rik <rik@octave.org>
parents: 19593
diff changeset
53 die ("aspell command unsuccesful. Cannot continue\n");
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
54 }
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
55
22341
770fb2070e96 doc: Clean up tools used to check Texinfo documentation.
Rik <rik@octave.org>
parents: 19593
diff changeset
56 open (FH, "<$tmp_fname")
770fb2070e96 doc: Clean up tools used to check Texinfo documentation.
Rik <rik@octave.org>
parents: 19593
diff changeset
57 or die "Unable to open misspelled words file: $tmp_fname\n";
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
58 while (<FH>) { $words{$_} = 1; }
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
59 close (FH);
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
60
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
61 # Print out sorted and uniquified list of misspelled words
10795
0306e572c686 Use case insensitive sort in spellcheck scripts.
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
62 print sort { uc($a) cmp uc ($b) } keys(%words);
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
63
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
64 ################################################################################
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
65 # Clean up temporary files
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
66 unlink ($tmp_fname) or die "Unable to delete temporary file: $tmp_fname\n";