Skripte zum Abgleich mit externen Wortlisten.
[wortliste.git] / skripte / validate.lua
blob418e78a8ccfbd85ee60a97a112895175ec5bc661
1 -- -*- coding: utf-8 -*-
3 --[[
5 Copyright 2012, 2013 Stephan Hennig
7 This program is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation, either version 3 of the License, or (at your
10 option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program. If not, see <http://www.gnu.org/licenses/>.
20 --]]
23 -- Lese Konfigurationdaten aus.
24 local path_dirsep, path_sep, path_subst = string.match(package.config, "(.-)\n(.-)\n(.-)\n")
25 -- Erweitere Modulsuchpfad.
26 package.path = package.path
27 .. path_sep .. "lua" .. path_dirsep .. path_subst .. ".lua"
28 .. path_sep .. "skripte" .. path_dirsep .. "lua" .. path_dirsep .. path_subst .. ".lua"
30 -- Lade Module aus Lua-Pfad.
31 local hrecords = require("helper_records")
33 -- Lade Module aus TEXMF-Baum.
34 kpse.set_program_name('luatex')
35 local alt_getopt = require("alt_getopt")
38 -- Erkläre zulässige Optionen.
39 local long_opts = {
40 help = "h",
41 statistics = "s",
43 local opt = alt_getopt.get_opts(arg, "hs", long_opts)
46 -- Option --help
47 if opt.h then
48 print([[
49 Aufruf: texlua validate.lua [OPTIONEN]
50 Dieses Skript prüft eine Wortliste auf Wohlgeformtheit. Die Wortliste
51 wird von der Standardeingabe gelesen.
52 -h, --help print help
53 -s, --statistics output record statistics
56 os.exit()
57 end
60 -- Lese Ausnahmeliste.
61 local fname = "wortliste.ausnahmen"
62 fname = hrecords.read_exception_file(fname)
63 print("Verwende Ausnahmeliste " .. fname)
66 -- Prüfe Wortliste auf Standardeingabe.
67 local count = hrecords.validate_file(io.stdin)
70 -- Ausgabe.
71 if opt.s then
72 hrecords.output_record_statistics(count)
73 end
74 print("gesamt ", count.total)
75 print("ungültig ", count.invalid)
78 -- Ende mit Fehlerkode?
79 if count.invalid > 0 then os.exit(1) end