kernel - support dummy reallocblks in devfs
[dragonfly.git] / contrib / groff / tmac / hyphenex.pl
blob7cc546634f7ddafa6800a68466b7488318a9359f
1 #! /usr/bin/env perl
4 # hyphenex.pl
6 # This small filter converts a hyphenation exception log article for
7 # TUGBoat to a real \hyphenation block.
9 # Written by Werner Lemberg <wl@gnu.org>.
11 # Version 1.2 (2007/11/16)
13 # Public domain.
16 # Usage:
18 # [perl] hyphenex.pl < tugboat-article > hyphenation-exceptions
20 # print header
21 print "% Hyphenation exceptions for US English,\n";
22 print "% based on hyphenation exception log articles in TUGboat.\n";
23 print "%\n";
24 print "% Copyright 2007 TeX Users Group.\n";
25 print "% You may freely use, modify and/or distribute this file.\n";
26 print "%\n";
27 print "% This is an automatically generated file. Do not edit!\n";
28 print "%\n";
29 print "% Please contact the TUGboat editorial staff <tugboat\@tug.org>\n";
30 print "% for corrections and omissions.\n";
31 print "\n";
32 print "\\hyphenation{\n";
34 while (<>) {
35 # retain only lines starting with \1 ... \6 or \tabalign
36 next if not (m/^\\[123456]/ || m/^\\tabalign/);
37 # remove final newline
38 chop;
39 # remove all TeX commands except \1 ... \6
40 s/\\[^123456\s{]+//g;
41 # remove all paired { ... }
42 1 while s/{(.*?)}/\1/g;
43 # skip lines which now have only whitespace before `&'
44 next if m/^\s*&/;
45 # remove comments
46 s/%.*//;
47 # remove trailing whitespace
48 s/\s*$//;
49 # remove trailing `*' (used as a marker in the document)
50 s/\*$//;
51 # split at whitespace
52 @field = split(' ');
53 if ($field[0] eq "\\1" || $field[0] eq "\\4") {
54 print " $field[2]\n";
56 elsif ($field[0] eq "\\2" || $field[0] eq "\\5") {
57 print " $field[2]\n";
58 # handle multiple suffixes separated by commata
59 @suffix_list = split(/,/, "$field[3]");
60 foreach $suffix (@suffix_list) {
61 print " $field[2]$suffix\n";
64 elsif ($field[0] eq "\\3" || $field[0] eq "\\6") {
65 # handle multiple suffixes separated by commata
66 @suffix_list = split(/,/, "$field[3],$field[4]");
67 foreach $suffix (@suffix_list) {
68 print " $field[2]$suffix\n";
71 else {
72 # for `&', split at `&' with trailing whitespace
73 @field = split(/&\s*/);
74 print " $field[1]\n";
78 # print trailer
79 print "}\n";
80 print "\n";
81 print "% EOF\n";