mandoc 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +7 -0
  3. data/COPYING +674 -0
  4. data/README.md +117 -0
  5. data/ext/mandoc/extconf.rb +59 -0
  6. data/ext/mandoc/rb_mandoc.c +548 -0
  7. data/ext/mandoc/rb_mandoc.h +22 -0
  8. data/lib/mandoc/version.rb +19 -0
  9. data/lib/mandoc.rb +26 -0
  10. data/mandoc-1.14.6/LICENSE +55 -0
  11. data/mandoc-1.14.6/arch.c +54 -0
  12. data/mandoc-1.14.6/att.c +49 -0
  13. data/mandoc-1.14.6/catman.c +260 -0
  14. data/mandoc-1.14.6/cgi.c +1279 -0
  15. data/mandoc-1.14.6/chars.c +507 -0
  16. data/mandoc-1.14.6/compat_err.c +103 -0
  17. data/mandoc-1.14.6/compat_fts.c +696 -0
  18. data/mandoc-1.14.6/compat_fts.h +106 -0
  19. data/mandoc-1.14.6/compat_getline.c +59 -0
  20. data/mandoc-1.14.6/compat_getsubopt.c +87 -0
  21. data/mandoc-1.14.6/compat_isblank.c +23 -0
  22. data/mandoc-1.14.6/compat_mkdtemp.c +50 -0
  23. data/mandoc-1.14.6/compat_mkstemps.c +63 -0
  24. data/mandoc-1.14.6/compat_ohash.c +330 -0
  25. data/mandoc-1.14.6/compat_ohash.h +72 -0
  26. data/mandoc-1.14.6/compat_progname.c +31 -0
  27. data/mandoc-1.14.6/compat_reallocarray.c +40 -0
  28. data/mandoc-1.14.6/compat_recallocarray.c +99 -0
  29. data/mandoc-1.14.6/compat_strcasestr.c +64 -0
  30. data/mandoc-1.14.6/compat_stringlist.c +135 -0
  31. data/mandoc-1.14.6/compat_stringlist.h +48 -0
  32. data/mandoc-1.14.6/compat_strlcat.c +57 -0
  33. data/mandoc-1.14.6/compat_strlcpy.c +52 -0
  34. data/mandoc-1.14.6/compat_strndup.c +42 -0
  35. data/mandoc-1.14.6/compat_strsep.c +70 -0
  36. data/mandoc-1.14.6/compat_strtonum.c +67 -0
  37. data/mandoc-1.14.6/compat_vasprintf.c +47 -0
  38. data/mandoc-1.14.6/config.h +52 -0
  39. data/mandoc-1.14.6/dba.c +508 -0
  40. data/mandoc-1.14.6/dba.h +50 -0
  41. data/mandoc-1.14.6/dba_array.c +190 -0
  42. data/mandoc-1.14.6/dba_array.h +47 -0
  43. data/mandoc-1.14.6/dba_read.c +74 -0
  44. data/mandoc-1.14.6/dba_write.c +127 -0
  45. data/mandoc-1.14.6/dba_write.h +30 -0
  46. data/mandoc-1.14.6/dbm.c +480 -0
  47. data/mandoc-1.14.6/dbm.h +68 -0
  48. data/mandoc-1.14.6/dbm_map.c +194 -0
  49. data/mandoc-1.14.6/dbm_map.h +29 -0
  50. data/mandoc-1.14.6/demandoc.c +260 -0
  51. data/mandoc-1.14.6/eqn.c +1132 -0
  52. data/mandoc-1.14.6/eqn.h +72 -0
  53. data/mandoc-1.14.6/eqn_html.c +246 -0
  54. data/mandoc-1.14.6/eqn_parse.h +48 -0
  55. data/mandoc-1.14.6/eqn_term.c +174 -0
  56. data/mandoc-1.14.6/html.c +1102 -0
  57. data/mandoc-1.14.6/html.h +142 -0
  58. data/mandoc-1.14.6/lib.c +35 -0
  59. data/mandoc-1.14.6/libman.h +42 -0
  60. data/mandoc-1.14.6/libmandoc.h +85 -0
  61. data/mandoc-1.14.6/libmdoc.h +87 -0
  62. data/mandoc-1.14.6/main.c +1375 -0
  63. data/mandoc-1.14.6/main.h +53 -0
  64. data/mandoc-1.14.6/man.c +345 -0
  65. data/mandoc-1.14.6/man.h +21 -0
  66. data/mandoc-1.14.6/man_html.c +640 -0
  67. data/mandoc-1.14.6/man_macro.c +470 -0
  68. data/mandoc-1.14.6/man_term.c +1143 -0
  69. data/mandoc-1.14.6/man_validate.c +660 -0
  70. data/mandoc-1.14.6/manconf.h +58 -0
  71. data/mandoc-1.14.6/mandoc.c +669 -0
  72. data/mandoc-1.14.6/mandoc.h +329 -0
  73. data/mandoc-1.14.6/mandoc_aux.c +118 -0
  74. data/mandoc-1.14.6/mandoc_aux.h +27 -0
  75. data/mandoc-1.14.6/mandoc_msg.c +375 -0
  76. data/mandoc-1.14.6/mandoc_ohash.c +65 -0
  77. data/mandoc-1.14.6/mandoc_ohash.h +23 -0
  78. data/mandoc-1.14.6/mandoc_parse.h +44 -0
  79. data/mandoc-1.14.6/mandoc_xr.c +123 -0
  80. data/mandoc-1.14.6/mandoc_xr.h +31 -0
  81. data/mandoc-1.14.6/mandocd.c +282 -0
  82. data/mandoc-1.14.6/mandocdb.c +2448 -0
  83. data/mandoc-1.14.6/manpath.c +363 -0
  84. data/mandoc-1.14.6/mansearch.c +851 -0
  85. data/mandoc-1.14.6/mansearch.h +118 -0
  86. data/mandoc-1.14.6/mdoc.c +433 -0
  87. data/mandoc-1.14.6/mdoc.h +158 -0
  88. data/mandoc-1.14.6/mdoc_argv.c +682 -0
  89. data/mandoc-1.14.6/mdoc_html.c +1762 -0
  90. data/mandoc-1.14.6/mdoc_macro.c +1600 -0
  91. data/mandoc-1.14.6/mdoc_man.c +1850 -0
  92. data/mandoc-1.14.6/mdoc_markdown.c +1610 -0
  93. data/mandoc-1.14.6/mdoc_state.c +256 -0
  94. data/mandoc-1.14.6/mdoc_term.c +1964 -0
  95. data/mandoc-1.14.6/mdoc_validate.c +3062 -0
  96. data/mandoc-1.14.6/msec.c +37 -0
  97. data/mandoc-1.14.6/out.c +544 -0
  98. data/mandoc-1.14.6/out.h +70 -0
  99. data/mandoc-1.14.6/preconv.c +179 -0
  100. data/mandoc-1.14.6/read.c +732 -0
  101. data/mandoc-1.14.6/roff.c +4390 -0
  102. data/mandoc-1.14.6/roff.h +561 -0
  103. data/mandoc-1.14.6/roff_html.c +119 -0
  104. data/mandoc-1.14.6/roff_int.h +94 -0
  105. data/mandoc-1.14.6/roff_term.c +266 -0
  106. data/mandoc-1.14.6/roff_validate.c +151 -0
  107. data/mandoc-1.14.6/soelim.c +182 -0
  108. data/mandoc-1.14.6/st.c +82 -0
  109. data/mandoc-1.14.6/tag.c +327 -0
  110. data/mandoc-1.14.6/tag.h +35 -0
  111. data/mandoc-1.14.6/tbl.c +183 -0
  112. data/mandoc-1.14.6/tbl.h +121 -0
  113. data/mandoc-1.14.6/tbl_data.c +323 -0
  114. data/mandoc-1.14.6/tbl_html.c +293 -0
  115. data/mandoc-1.14.6/tbl_int.h +47 -0
  116. data/mandoc-1.14.6/tbl_layout.c +376 -0
  117. data/mandoc-1.14.6/tbl_opts.c +173 -0
  118. data/mandoc-1.14.6/tbl_parse.h +30 -0
  119. data/mandoc-1.14.6/tbl_term.c +948 -0
  120. data/mandoc-1.14.6/term.c +1113 -0
  121. data/mandoc-1.14.6/term.h +158 -0
  122. data/mandoc-1.14.6/term_ascii.c +424 -0
  123. data/mandoc-1.14.6/term_ps.c +1362 -0
  124. data/mandoc-1.14.6/term_tab.c +130 -0
  125. data/mandoc-1.14.6/term_tag.c +227 -0
  126. data/mandoc-1.14.6/term_tag.h +34 -0
  127. data/mandoc-1.14.6/tree.c +536 -0
  128. metadata +170 -0
@@ -0,0 +1,507 @@
1
+ /* $Id: chars.c,v 1.79 2020/02/13 16:18:29 schwarze Exp $ */
2
+ /*
3
+ * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4
+ * Copyright (c) 2011, 2014, 2015, 2017, 2018, 2020
5
+ * Ingo Schwarze <schwarze@openbsd.org>
6
+ *
7
+ * Permission to use, copy, modify, and distribute this software for any
8
+ * purpose with or without fee is hereby granted, provided that the above
9
+ * copyright notice and this permission notice appear in all copies.
10
+ *
11
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
+ */
19
+ #include "config.h"
20
+
21
+ #include <sys/types.h>
22
+
23
+ #include <assert.h>
24
+ #include <ctype.h>
25
+ #include <stddef.h>
26
+ #include <stdint.h>
27
+ #include <stdio.h>
28
+ #include <stdlib.h>
29
+ #include <string.h>
30
+
31
+ #include "mandoc.h"
32
+ #include "mandoc_aux.h"
33
+ #include "mandoc_ohash.h"
34
+ #include "libmandoc.h"
35
+
36
+ struct ln {
37
+ const char roffcode[16];
38
+ const char *ascii;
39
+ int unicode;
40
+ };
41
+
42
+ /* Special break control characters. */
43
+ static const char ascii_nbrsp[2] = { ASCII_NBRSP, '\0' };
44
+ static const char ascii_break[2] = { ASCII_BREAK, '\0' };
45
+
46
+ static struct ln lines[] = {
47
+
48
+ /* Spacing. */
49
+ { " ", ascii_nbrsp, 0x00a0 },
50
+ { "~", ascii_nbrsp, 0x00a0 },
51
+ { "0", ascii_nbrsp, 0x00a0 },
52
+ { ":", ascii_break, 0 },
53
+
54
+ /* Lines. */
55
+ { "ba", "|", 0x007c },
56
+ { "br", "|", 0x2502 },
57
+ { "ul", "_", 0x005f },
58
+ { "_", "_", 0x005f },
59
+ { "ru", "_", 0x005f },
60
+ { "rn", "-", 0x203e },
61
+ { "bb", "|", 0x00a6 },
62
+ { "sl", "/", 0x002f },
63
+ { "rs", "\\", 0x005c },
64
+
65
+ /* Text markers. */
66
+ { "ci", "O", 0x25cb },
67
+ { "bu", "+\bo", 0x2022 },
68
+ { "dd", "<**>", 0x2021 },
69
+ { "dg", "<*>", 0x2020 },
70
+ { "lz", "<>", 0x25ca },
71
+ { "sq", "[]", 0x25a1 },
72
+ { "ps", "<paragraph>", 0x00b6 },
73
+ { "sc", "<section>", 0x00a7 },
74
+ { "lh", "<=", 0x261c },
75
+ { "rh", "=>", 0x261e },
76
+ { "at", "@", 0x0040 },
77
+ { "sh", "#", 0x0023 },
78
+ { "CR", "<cr>", 0x21b5 },
79
+ { "OK", "\\/", 0x2713 },
80
+ { "CL", "C", 0x2663 },
81
+ { "SP", "S", 0x2660 },
82
+ { "HE", "H", 0x2665 },
83
+ { "DI", "D", 0x2666 },
84
+
85
+ /* Legal symbols. */
86
+ { "co", "(C)", 0x00a9 },
87
+ { "rg", "(R)", 0x00ae },
88
+ { "tm", "tm", 0x2122 },
89
+
90
+ /* Punctuation. */
91
+ { "em", "--", 0x2014 },
92
+ { "en", "-", 0x2013 },
93
+ { "hy", "-", 0x2010 },
94
+ { "e", "\\", 0x005c },
95
+ { ".", ".", 0x002e },
96
+ { "r!", "!", 0x00a1 },
97
+ { "r?", "?", 0x00bf },
98
+
99
+ /* Quotes. */
100
+ { "Bq", ",,", 0x201e },
101
+ { "bq", ",", 0x201a },
102
+ { "lq", "\"", 0x201c },
103
+ { "rq", "\"", 0x201d },
104
+ { "Lq", "\"", 0x201c },
105
+ { "Rq", "\"", 0x201d },
106
+ { "oq", "`", 0x2018 },
107
+ { "cq", "\'", 0x2019 },
108
+ { "aq", "\'", 0x0027 },
109
+ { "dq", "\"", 0x0022 },
110
+ { "Fo", "<<", 0x00ab },
111
+ { "Fc", ">>", 0x00bb },
112
+ { "fo", "<", 0x2039 },
113
+ { "fc", ">", 0x203a },
114
+
115
+ /* Brackets. */
116
+ { "lB", "[", 0x005b },
117
+ { "rB", "]", 0x005d },
118
+ { "lC", "{", 0x007b },
119
+ { "rC", "}", 0x007d },
120
+ { "la", "<", 0x27e8 },
121
+ { "ra", ">", 0x27e9 },
122
+ { "bv", "|", 0x23aa },
123
+ { "braceex", "|", 0x23aa },
124
+ { "bracketlefttp", "|", 0x23a1 },
125
+ { "bracketleftbt", "|", 0x23a3 },
126
+ { "bracketleftex", "|", 0x23a2 },
127
+ { "bracketrighttp", "|", 0x23a4 },
128
+ { "bracketrightbt", "|", 0x23a6 },
129
+ { "bracketrightex", "|", 0x23a5 },
130
+ { "lt", ",-", 0x23a7 },
131
+ { "bracelefttp", ",-", 0x23a7 },
132
+ { "lk", "{", 0x23a8 },
133
+ { "braceleftmid", "{", 0x23a8 },
134
+ { "lb", "`-", 0x23a9 },
135
+ { "braceleftbt", "`-", 0x23a9 },
136
+ { "braceleftex", "|", 0x23aa },
137
+ { "rt", "-.", 0x23ab },
138
+ { "bracerighttp", "-.", 0x23ab },
139
+ { "rk", "}", 0x23ac },
140
+ { "bracerightmid", "}", 0x23ac },
141
+ { "rb", "-\'", 0x23ad },
142
+ { "bracerightbt", "-\'", 0x23ad },
143
+ { "bracerightex", "|", 0x23aa },
144
+ { "parenlefttp", "/", 0x239b },
145
+ { "parenleftbt", "\\", 0x239d },
146
+ { "parenleftex", "|", 0x239c },
147
+ { "parenrighttp", "\\", 0x239e },
148
+ { "parenrightbt", "/", 0x23a0 },
149
+ { "parenrightex", "|", 0x239f },
150
+
151
+ /* Arrows and lines. */
152
+ { "<-", "<-", 0x2190 },
153
+ { "->", "->", 0x2192 },
154
+ { "<>", "<->", 0x2194 },
155
+ { "da", "|\bv", 0x2193 },
156
+ { "ua", "|\b^", 0x2191 },
157
+ { "va", "^v", 0x2195 },
158
+ { "lA", "<=", 0x21d0 },
159
+ { "rA", "=>", 0x21d2 },
160
+ { "hA", "<=>", 0x21d4 },
161
+ { "uA", "=\b^", 0x21d1 },
162
+ { "dA", "=\bv", 0x21d3 },
163
+ { "vA", "^=v", 0x21d5 },
164
+ { "an", "-", 0x23af },
165
+
166
+ /* Logic. */
167
+ { "AN", "^", 0x2227 },
168
+ { "OR", "v", 0x2228 },
169
+ { "no", "~", 0x00ac },
170
+ { "tno", "~", 0x00ac },
171
+ { "te", "<there\037exists>", 0x2203 },
172
+ { "fa", "<for\037all>", 0x2200 },
173
+ { "st", "<such\037that>", 0x220b },
174
+ { "tf", "<therefore>", 0x2234 },
175
+ { "3d", "<therefore>", 0x2234 },
176
+ { "or", "|", 0x007c },
177
+
178
+ /* Mathematicals. */
179
+ { "pl", "+", 0x002b },
180
+ { "mi", "-", 0x2212 },
181
+ { "-", "-", 0x002d },
182
+ { "-+", "-+", 0x2213 },
183
+ { "+-", "+-", 0x00b1 },
184
+ { "t+-", "+-", 0x00b1 },
185
+ { "pc", ".", 0x00b7 },
186
+ { "md", ".", 0x22c5 },
187
+ { "mu", "x", 0x00d7 },
188
+ { "tmu", "x", 0x00d7 },
189
+ { "c*", "O\bx", 0x2297 },
190
+ { "c+", "O\b+", 0x2295 },
191
+ { "di", "/", 0x00f7 },
192
+ { "tdi", "/", 0x00f7 },
193
+ { "f/", "/", 0x2044 },
194
+ { "**", "*", 0x2217 },
195
+ { "<=", "<=", 0x2264 },
196
+ { ">=", ">=", 0x2265 },
197
+ { "<<", "<<", 0x226a },
198
+ { ">>", ">>", 0x226b },
199
+ { "eq", "=", 0x003d },
200
+ { "!=", "!=", 0x2260 },
201
+ { "==", "==", 0x2261 },
202
+ { "ne", "!==", 0x2262 },
203
+ { "ap", "~", 0x223c },
204
+ { "|=", "-~", 0x2243 },
205
+ { "=~", "=~", 0x2245 },
206
+ { "~~", "~~", 0x2248 },
207
+ { "~=", "~=", 0x2248 },
208
+ { "pt", "<proportional\037to>", 0x221d },
209
+ { "es", "{}", 0x2205 },
210
+ { "mo", "<element\037of>", 0x2208 },
211
+ { "nm", "<not\037element\037of>", 0x2209 },
212
+ { "sb", "<proper\037subset>", 0x2282 },
213
+ { "nb", "<not\037subset>", 0x2284 },
214
+ { "sp", "<proper\037superset>", 0x2283 },
215
+ { "nc", "<not\037superset>", 0x2285 },
216
+ { "ib", "<subset\037or\037equal>", 0x2286 },
217
+ { "ip", "<superset\037or\037equal>", 0x2287 },
218
+ { "ca", "<intersection>", 0x2229 },
219
+ { "cu", "<union>", 0x222a },
220
+ { "/_", "<angle>", 0x2220 },
221
+ { "pp", "<perpendicular>", 0x22a5 },
222
+ { "is", "<integral>", 0x222b },
223
+ { "integral", "<integral>", 0x222b },
224
+ { "sum", "<sum>", 0x2211 },
225
+ { "product", "<product>", 0x220f },
226
+ { "coproduct", "<coproduct>", 0x2210 },
227
+ { "gr", "<nabla>", 0x2207 },
228
+ { "sr", "<sqrt>", 0x221a },
229
+ { "sqrt", "<sqrt>", 0x221a },
230
+ { "lc", "|~", 0x2308 },
231
+ { "rc", "~|", 0x2309 },
232
+ { "lf", "|_", 0x230a },
233
+ { "rf", "_|", 0x230b },
234
+ { "if", "<infinity>", 0x221e },
235
+ { "Ah", "<Aleph>", 0x2135 },
236
+ { "Im", "<Im>", 0x2111 },
237
+ { "Re", "<Re>", 0x211c },
238
+ { "wp", "p", 0x2118 },
239
+ { "pd", "<del>", 0x2202 },
240
+ { "-h", "/h", 0x210f },
241
+ { "hbar", "/h", 0x210f },
242
+ { "12", "1/2", 0x00bd },
243
+ { "14", "1/4", 0x00bc },
244
+ { "34", "3/4", 0x00be },
245
+ { "18", "1/8", 0x215B },
246
+ { "38", "3/8", 0x215C },
247
+ { "58", "5/8", 0x215D },
248
+ { "78", "7/8", 0x215E },
249
+ { "S1", "^1", 0x00B9 },
250
+ { "S2", "^2", 0x00B2 },
251
+ { "S3", "^3", 0x00B3 },
252
+
253
+ /* Ligatures. */
254
+ { "ff", "ff", 0xfb00 },
255
+ { "fi", "fi", 0xfb01 },
256
+ { "fl", "fl", 0xfb02 },
257
+ { "Fi", "ffi", 0xfb03 },
258
+ { "Fl", "ffl", 0xfb04 },
259
+ { "AE", "AE", 0x00c6 },
260
+ { "ae", "ae", 0x00e6 },
261
+ { "OE", "OE", 0x0152 },
262
+ { "oe", "oe", 0x0153 },
263
+ { "ss", "ss", 0x00df },
264
+ { "IJ", "IJ", 0x0132 },
265
+ { "ij", "ij", 0x0133 },
266
+
267
+ /* Accents. */
268
+ { "a\"", "\"", 0x02dd },
269
+ { "a-", "-", 0x00af },
270
+ { "a.", ".", 0x02d9 },
271
+ { "a^", "^", 0x005e },
272
+ { "aa", "\'", 0x00b4 },
273
+ { "\'", "\'", 0x00b4 },
274
+ { "ga", "`", 0x0060 },
275
+ { "`", "`", 0x0060 },
276
+ { "ab", "'\b`", 0x02d8 },
277
+ { "ac", ",", 0x00b8 },
278
+ { "ad", "\"", 0x00a8 },
279
+ { "ah", "v", 0x02c7 },
280
+ { "ao", "o", 0x02da },
281
+ { "a~", "~", 0x007e },
282
+ { "ho", ",", 0x02db },
283
+ { "ha", "^", 0x005e },
284
+ { "ti", "~", 0x007e },
285
+ { "u02DC", "~", 0x02dc },
286
+
287
+ /* Accented letters. */
288
+ { "'A", "'\bA", 0x00c1 },
289
+ { "'E", "'\bE", 0x00c9 },
290
+ { "'I", "'\bI", 0x00cd },
291
+ { "'O", "'\bO", 0x00d3 },
292
+ { "'U", "'\bU", 0x00da },
293
+ { "'Y", "'\bY", 0x00dd },
294
+ { "'a", "'\ba", 0x00e1 },
295
+ { "'e", "'\be", 0x00e9 },
296
+ { "'i", "'\bi", 0x00ed },
297
+ { "'o", "'\bo", 0x00f3 },
298
+ { "'u", "'\bu", 0x00fa },
299
+ { "'y", "'\by", 0x00fd },
300
+ { "`A", "`\bA", 0x00c0 },
301
+ { "`E", "`\bE", 0x00c8 },
302
+ { "`I", "`\bI", 0x00cc },
303
+ { "`O", "`\bO", 0x00d2 },
304
+ { "`U", "`\bU", 0x00d9 },
305
+ { "`a", "`\ba", 0x00e0 },
306
+ { "`e", "`\be", 0x00e8 },
307
+ { "`i", "`\bi", 0x00ec },
308
+ { "`o", "`\bo", 0x00f2 },
309
+ { "`u", "`\bu", 0x00f9 },
310
+ { "~A", "~\bA", 0x00c3 },
311
+ { "~N", "~\bN", 0x00d1 },
312
+ { "~O", "~\bO", 0x00d5 },
313
+ { "~a", "~\ba", 0x00e3 },
314
+ { "~n", "~\bn", 0x00f1 },
315
+ { "~o", "~\bo", 0x00f5 },
316
+ { ":A", "\"\bA", 0x00c4 },
317
+ { ":E", "\"\bE", 0x00cb },
318
+ { ":I", "\"\bI", 0x00cf },
319
+ { ":O", "\"\bO", 0x00d6 },
320
+ { ":U", "\"\bU", 0x00dc },
321
+ { ":a", "\"\ba", 0x00e4 },
322
+ { ":e", "\"\be", 0x00eb },
323
+ { ":i", "\"\bi", 0x00ef },
324
+ { ":o", "\"\bo", 0x00f6 },
325
+ { ":u", "\"\bu", 0x00fc },
326
+ { ":y", "\"\by", 0x00ff },
327
+ { "^A", "^\bA", 0x00c2 },
328
+ { "^E", "^\bE", 0x00ca },
329
+ { "^I", "^\bI", 0x00ce },
330
+ { "^O", "^\bO", 0x00d4 },
331
+ { "^U", "^\bU", 0x00db },
332
+ { "^a", "^\ba", 0x00e2 },
333
+ { "^e", "^\be", 0x00ea },
334
+ { "^i", "^\bi", 0x00ee },
335
+ { "^o", "^\bo", 0x00f4 },
336
+ { "^u", "^\bu", 0x00fb },
337
+ { ",C", ",\bC", 0x00c7 },
338
+ { ",c", ",\bc", 0x00e7 },
339
+ { "/L", "/\bL", 0x0141 },
340
+ { "/l", "/\bl", 0x0142 },
341
+ { "/O", "/\bO", 0x00d8 },
342
+ { "/o", "/\bo", 0x00f8 },
343
+ { "oA", "o\bA", 0x00c5 },
344
+ { "oa", "o\ba", 0x00e5 },
345
+
346
+ /* Special letters. */
347
+ { "-D", "Dh", 0x00d0 },
348
+ { "Sd", "dh", 0x00f0 },
349
+ { "TP", "Th", 0x00de },
350
+ { "Tp", "th", 0x00fe },
351
+ { ".i", "i", 0x0131 },
352
+ { ".j", "j", 0x0237 },
353
+
354
+ /* Currency. */
355
+ { "Do", "$", 0x0024 },
356
+ { "ct", "/\bc", 0x00a2 },
357
+ { "Eu", "EUR", 0x20ac },
358
+ { "eu", "EUR", 0x20ac },
359
+ { "Ye", "=\bY", 0x00a5 },
360
+ { "Po", "-\bL", 0x00a3 },
361
+ { "Cs", "o\bx", 0x00a4 },
362
+ { "Fn", ",\bf", 0x0192 },
363
+
364
+ /* Units. */
365
+ { "de", "<degree>", 0x00b0 },
366
+ { "%0", "<permille>", 0x2030 },
367
+ { "fm", "\'", 0x2032 },
368
+ { "sd", "''", 0x2033 },
369
+ { "mc", "<micro>", 0x00b5 },
370
+ { "Of", "_\ba", 0x00aa },
371
+ { "Om", "_\bo", 0x00ba },
372
+
373
+ /* Greek characters. */
374
+ { "*A", "A", 0x0391 },
375
+ { "*B", "B", 0x0392 },
376
+ { "*G", "<Gamma>", 0x0393 },
377
+ { "*D", "<Delta>", 0x0394 },
378
+ { "*E", "E", 0x0395 },
379
+ { "*Z", "Z", 0x0396 },
380
+ { "*Y", "H", 0x0397 },
381
+ { "*H", "<Theta>", 0x0398 },
382
+ { "*I", "I", 0x0399 },
383
+ { "*K", "K", 0x039a },
384
+ { "*L", "<Lambda>", 0x039b },
385
+ { "*M", "M", 0x039c },
386
+ { "*N", "N", 0x039d },
387
+ { "*C", "<Xi>", 0x039e },
388
+ { "*O", "O", 0x039f },
389
+ { "*P", "<Pi>", 0x03a0 },
390
+ { "*R", "P", 0x03a1 },
391
+ { "*S", "<Sigma>", 0x03a3 },
392
+ { "*T", "T", 0x03a4 },
393
+ { "*U", "Y", 0x03a5 },
394
+ { "*F", "<Phi>", 0x03a6 },
395
+ { "*X", "X", 0x03a7 },
396
+ { "*Q", "<Psi>", 0x03a8 },
397
+ { "*W", "<Omega>", 0x03a9 },
398
+ { "*a", "<alpha>", 0x03b1 },
399
+ { "*b", "<beta>", 0x03b2 },
400
+ { "*g", "<gamma>", 0x03b3 },
401
+ { "*d", "<delta>", 0x03b4 },
402
+ { "*e", "<epsilon>", 0x03b5 },
403
+ { "*z", "<zeta>", 0x03b6 },
404
+ { "*y", "<eta>", 0x03b7 },
405
+ { "*h", "<theta>", 0x03b8 },
406
+ { "*i", "<iota>", 0x03b9 },
407
+ { "*k", "<kappa>", 0x03ba },
408
+ { "*l", "<lambda>", 0x03bb },
409
+ { "*m", "<mu>", 0x03bc },
410
+ { "*n", "<nu>", 0x03bd },
411
+ { "*c", "<xi>", 0x03be },
412
+ { "*o", "o", 0x03bf },
413
+ { "*p", "<pi>", 0x03c0 },
414
+ { "*r", "<rho>", 0x03c1 },
415
+ { "*s", "<sigma>", 0x03c3 },
416
+ { "*t", "<tau>", 0x03c4 },
417
+ { "*u", "<upsilon>", 0x03c5 },
418
+ { "*f", "<phi>", 0x03d5 },
419
+ { "*x", "<chi>", 0x03c7 },
420
+ { "*q", "<psi>", 0x03c8 },
421
+ { "*w", "<omega>", 0x03c9 },
422
+ { "+h", "<theta>", 0x03d1 },
423
+ { "+f", "<phi>", 0x03c6 },
424
+ { "+p", "<pi>", 0x03d6 },
425
+ { "+e", "<epsilon>", 0x03f5 },
426
+ { "ts", "<sigma>", 0x03c2 },
427
+ };
428
+
429
+ static struct ohash mchars;
430
+
431
+
432
+ void
433
+ mchars_free(void)
434
+ {
435
+
436
+ ohash_delete(&mchars);
437
+ }
438
+
439
+ void
440
+ mchars_alloc(void)
441
+ {
442
+ size_t i;
443
+ unsigned int slot;
444
+
445
+ mandoc_ohash_init(&mchars, 9, offsetof(struct ln, roffcode));
446
+ for (i = 0; i < sizeof(lines)/sizeof(lines[0]); i++) {
447
+ slot = ohash_qlookup(&mchars, lines[i].roffcode);
448
+ assert(ohash_find(&mchars, slot) == NULL);
449
+ ohash_insert(&mchars, slot, lines + i);
450
+ }
451
+ }
452
+
453
+ int
454
+ mchars_spec2cp(const char *p, size_t sz)
455
+ {
456
+ const struct ln *ln;
457
+ const char *end;
458
+
459
+ end = p + sz;
460
+ ln = ohash_find(&mchars, ohash_qlookupi(&mchars, p, &end));
461
+ return ln != NULL ? ln->unicode : -1;
462
+ }
463
+
464
+ int
465
+ mchars_num2char(const char *p, size_t sz)
466
+ {
467
+ int i;
468
+
469
+ i = mandoc_strntoi(p, sz, 10);
470
+ return i >= 0 && i < 256 ? i : -1;
471
+ }
472
+
473
+ int
474
+ mchars_num2uc(const char *p, size_t sz)
475
+ {
476
+ int i;
477
+
478
+ i = mandoc_strntoi(p, sz, 16);
479
+ assert(i >= 0 && i <= 0x10FFFF);
480
+ return i;
481
+ }
482
+
483
+ const char *
484
+ mchars_spec2str(const char *p, size_t sz, size_t *rsz)
485
+ {
486
+ const struct ln *ln;
487
+ const char *end;
488
+
489
+ end = p + sz;
490
+ ln = ohash_find(&mchars, ohash_qlookupi(&mchars, p, &end));
491
+ if (ln == NULL)
492
+ return NULL;
493
+
494
+ *rsz = strlen(ln->ascii);
495
+ return ln->ascii;
496
+ }
497
+
498
+ const char *
499
+ mchars_uc2str(int uc)
500
+ {
501
+ size_t i;
502
+
503
+ for (i = 0; i < sizeof(lines)/sizeof(lines[0]); i++)
504
+ if (uc == lines[i].unicode)
505
+ return lines[i].ascii;
506
+ return "<?>";
507
+ }
@@ -0,0 +1,103 @@
1
+ /* $Id: compat_err.c,v 1.5 2020/06/15 01:37:14 schwarze Exp $ */
2
+ /*
3
+ * Copyright (c) 1993
4
+ * The Regents of the University of California. All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * 3. Neither the name of the University nor the names of its contributors
15
+ * may be used to endorse or promote products derived from this software
16
+ * without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
+ * SUCH DAMAGE.
29
+ */
30
+ #include "config.h"
31
+
32
+ #include <errno.h>
33
+ #include <stdarg.h>
34
+ #include <stdio.h>
35
+ #include <stdlib.h>
36
+ #include <string.h>
37
+
38
+ static void vwarni(const char *, va_list);
39
+ static void vwarnxi(const char *, va_list);
40
+
41
+ static void
42
+ vwarnxi(const char *fmt, va_list ap)
43
+ {
44
+ fprintf(stderr, "%s: ", getprogname());
45
+ if (fmt != NULL)
46
+ vfprintf(stderr, fmt, ap);
47
+ }
48
+
49
+ static void
50
+ vwarni(const char *fmt, va_list ap)
51
+ {
52
+ int sverrno;
53
+
54
+ sverrno = errno;
55
+ vwarnxi(fmt, ap);
56
+ if (fmt != NULL)
57
+ fputs(": ", stderr);
58
+ fprintf(stderr, "%s\n", strerror(sverrno));
59
+ }
60
+
61
+ void
62
+ err(int eval, const char *fmt, ...)
63
+ {
64
+ va_list ap;
65
+
66
+ va_start(ap, fmt);
67
+ vwarni(fmt, ap);
68
+ va_end(ap);
69
+ exit(eval);
70
+ }
71
+
72
+ void
73
+ errx(int eval, const char *fmt, ...)
74
+ {
75
+ va_list ap;
76
+
77
+ va_start(ap, fmt);
78
+ vwarnxi(fmt, ap);
79
+ va_end(ap);
80
+ fputc('\n', stderr);
81
+ exit(eval);
82
+ }
83
+
84
+ void
85
+ warn(const char *fmt, ...)
86
+ {
87
+ va_list ap;
88
+
89
+ va_start(ap, fmt);
90
+ vwarni(fmt, ap);
91
+ va_end(ap);
92
+ }
93
+
94
+ void
95
+ warnx(const char *fmt, ...)
96
+ {
97
+ va_list ap;
98
+
99
+ va_start(ap, fmt);
100
+ vwarnxi(fmt, ap);
101
+ va_end(ap);
102
+ fputc('\n', stderr);
103
+ }