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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +7 -0
- data/COPYING +674 -0
- data/README.md +117 -0
- data/ext/mandoc/extconf.rb +59 -0
- data/ext/mandoc/rb_mandoc.c +548 -0
- data/ext/mandoc/rb_mandoc.h +22 -0
- data/lib/mandoc/version.rb +19 -0
- data/lib/mandoc.rb +26 -0
- data/mandoc-1.14.6/LICENSE +55 -0
- data/mandoc-1.14.6/arch.c +54 -0
- data/mandoc-1.14.6/att.c +49 -0
- data/mandoc-1.14.6/catman.c +260 -0
- data/mandoc-1.14.6/cgi.c +1279 -0
- data/mandoc-1.14.6/chars.c +507 -0
- data/mandoc-1.14.6/compat_err.c +103 -0
- data/mandoc-1.14.6/compat_fts.c +696 -0
- data/mandoc-1.14.6/compat_fts.h +106 -0
- data/mandoc-1.14.6/compat_getline.c +59 -0
- data/mandoc-1.14.6/compat_getsubopt.c +87 -0
- data/mandoc-1.14.6/compat_isblank.c +23 -0
- data/mandoc-1.14.6/compat_mkdtemp.c +50 -0
- data/mandoc-1.14.6/compat_mkstemps.c +63 -0
- data/mandoc-1.14.6/compat_ohash.c +330 -0
- data/mandoc-1.14.6/compat_ohash.h +72 -0
- data/mandoc-1.14.6/compat_progname.c +31 -0
- data/mandoc-1.14.6/compat_reallocarray.c +40 -0
- data/mandoc-1.14.6/compat_recallocarray.c +99 -0
- data/mandoc-1.14.6/compat_strcasestr.c +64 -0
- data/mandoc-1.14.6/compat_stringlist.c +135 -0
- data/mandoc-1.14.6/compat_stringlist.h +48 -0
- data/mandoc-1.14.6/compat_strlcat.c +57 -0
- data/mandoc-1.14.6/compat_strlcpy.c +52 -0
- data/mandoc-1.14.6/compat_strndup.c +42 -0
- data/mandoc-1.14.6/compat_strsep.c +70 -0
- data/mandoc-1.14.6/compat_strtonum.c +67 -0
- data/mandoc-1.14.6/compat_vasprintf.c +47 -0
- data/mandoc-1.14.6/config.h +52 -0
- data/mandoc-1.14.6/dba.c +508 -0
- data/mandoc-1.14.6/dba.h +50 -0
- data/mandoc-1.14.6/dba_array.c +190 -0
- data/mandoc-1.14.6/dba_array.h +47 -0
- data/mandoc-1.14.6/dba_read.c +74 -0
- data/mandoc-1.14.6/dba_write.c +127 -0
- data/mandoc-1.14.6/dba_write.h +30 -0
- data/mandoc-1.14.6/dbm.c +480 -0
- data/mandoc-1.14.6/dbm.h +68 -0
- data/mandoc-1.14.6/dbm_map.c +194 -0
- data/mandoc-1.14.6/dbm_map.h +29 -0
- data/mandoc-1.14.6/demandoc.c +260 -0
- data/mandoc-1.14.6/eqn.c +1132 -0
- data/mandoc-1.14.6/eqn.h +72 -0
- data/mandoc-1.14.6/eqn_html.c +246 -0
- data/mandoc-1.14.6/eqn_parse.h +48 -0
- data/mandoc-1.14.6/eqn_term.c +174 -0
- data/mandoc-1.14.6/html.c +1102 -0
- data/mandoc-1.14.6/html.h +142 -0
- data/mandoc-1.14.6/lib.c +35 -0
- data/mandoc-1.14.6/libman.h +42 -0
- data/mandoc-1.14.6/libmandoc.h +85 -0
- data/mandoc-1.14.6/libmdoc.h +87 -0
- data/mandoc-1.14.6/main.c +1375 -0
- data/mandoc-1.14.6/main.h +53 -0
- data/mandoc-1.14.6/man.c +345 -0
- data/mandoc-1.14.6/man.h +21 -0
- data/mandoc-1.14.6/man_html.c +640 -0
- data/mandoc-1.14.6/man_macro.c +470 -0
- data/mandoc-1.14.6/man_term.c +1143 -0
- data/mandoc-1.14.6/man_validate.c +660 -0
- data/mandoc-1.14.6/manconf.h +58 -0
- data/mandoc-1.14.6/mandoc.c +669 -0
- data/mandoc-1.14.6/mandoc.h +329 -0
- data/mandoc-1.14.6/mandoc_aux.c +118 -0
- data/mandoc-1.14.6/mandoc_aux.h +27 -0
- data/mandoc-1.14.6/mandoc_msg.c +375 -0
- data/mandoc-1.14.6/mandoc_ohash.c +65 -0
- data/mandoc-1.14.6/mandoc_ohash.h +23 -0
- data/mandoc-1.14.6/mandoc_parse.h +44 -0
- data/mandoc-1.14.6/mandoc_xr.c +123 -0
- data/mandoc-1.14.6/mandoc_xr.h +31 -0
- data/mandoc-1.14.6/mandocd.c +282 -0
- data/mandoc-1.14.6/mandocdb.c +2448 -0
- data/mandoc-1.14.6/manpath.c +363 -0
- data/mandoc-1.14.6/mansearch.c +851 -0
- data/mandoc-1.14.6/mansearch.h +118 -0
- data/mandoc-1.14.6/mdoc.c +433 -0
- data/mandoc-1.14.6/mdoc.h +158 -0
- data/mandoc-1.14.6/mdoc_argv.c +682 -0
- data/mandoc-1.14.6/mdoc_html.c +1762 -0
- data/mandoc-1.14.6/mdoc_macro.c +1600 -0
- data/mandoc-1.14.6/mdoc_man.c +1850 -0
- data/mandoc-1.14.6/mdoc_markdown.c +1610 -0
- data/mandoc-1.14.6/mdoc_state.c +256 -0
- data/mandoc-1.14.6/mdoc_term.c +1964 -0
- data/mandoc-1.14.6/mdoc_validate.c +3062 -0
- data/mandoc-1.14.6/msec.c +37 -0
- data/mandoc-1.14.6/out.c +544 -0
- data/mandoc-1.14.6/out.h +70 -0
- data/mandoc-1.14.6/preconv.c +179 -0
- data/mandoc-1.14.6/read.c +732 -0
- data/mandoc-1.14.6/roff.c +4390 -0
- data/mandoc-1.14.6/roff.h +561 -0
- data/mandoc-1.14.6/roff_html.c +119 -0
- data/mandoc-1.14.6/roff_int.h +94 -0
- data/mandoc-1.14.6/roff_term.c +266 -0
- data/mandoc-1.14.6/roff_validate.c +151 -0
- data/mandoc-1.14.6/soelim.c +182 -0
- data/mandoc-1.14.6/st.c +82 -0
- data/mandoc-1.14.6/tag.c +327 -0
- data/mandoc-1.14.6/tag.h +35 -0
- data/mandoc-1.14.6/tbl.c +183 -0
- data/mandoc-1.14.6/tbl.h +121 -0
- data/mandoc-1.14.6/tbl_data.c +323 -0
- data/mandoc-1.14.6/tbl_html.c +293 -0
- data/mandoc-1.14.6/tbl_int.h +47 -0
- data/mandoc-1.14.6/tbl_layout.c +376 -0
- data/mandoc-1.14.6/tbl_opts.c +173 -0
- data/mandoc-1.14.6/tbl_parse.h +30 -0
- data/mandoc-1.14.6/tbl_term.c +948 -0
- data/mandoc-1.14.6/term.c +1113 -0
- data/mandoc-1.14.6/term.h +158 -0
- data/mandoc-1.14.6/term_ascii.c +424 -0
- data/mandoc-1.14.6/term_ps.c +1362 -0
- data/mandoc-1.14.6/term_tab.c +130 -0
- data/mandoc-1.14.6/term_tag.c +227 -0
- data/mandoc-1.14.6/term_tag.h +34 -0
- data/mandoc-1.14.6/tree.c +536 -0
- metadata +170 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/* $Id: tbl_opts.c,v 1.24 2018/12/14 05:18:03 schwarze Exp $ */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
|
|
4
|
+
* Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
|
|
5
|
+
*
|
|
6
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
7
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
8
|
+
* copyright notice and this permission notice appear in all copies.
|
|
9
|
+
*
|
|
10
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
11
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
12
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
13
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
14
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
15
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
16
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
17
|
+
*/
|
|
18
|
+
#include "config.h"
|
|
19
|
+
|
|
20
|
+
#include <sys/types.h>
|
|
21
|
+
|
|
22
|
+
#include <ctype.h>
|
|
23
|
+
#include <stdio.h>
|
|
24
|
+
#include <stdlib.h>
|
|
25
|
+
#include <string.h>
|
|
26
|
+
|
|
27
|
+
#include "mandoc.h"
|
|
28
|
+
#include "tbl.h"
|
|
29
|
+
#include "libmandoc.h"
|
|
30
|
+
#include "tbl_int.h"
|
|
31
|
+
|
|
32
|
+
#define KEY_DPOINT 0
|
|
33
|
+
#define KEY_DELIM 1
|
|
34
|
+
#define KEY_LINESIZE 2
|
|
35
|
+
#define KEY_TAB 3
|
|
36
|
+
|
|
37
|
+
struct tbl_phrase {
|
|
38
|
+
const char *name;
|
|
39
|
+
int key;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
static const struct tbl_phrase keys[] = {
|
|
43
|
+
{"decimalpoint", 0},
|
|
44
|
+
{"delim", 0},
|
|
45
|
+
{"linesize", 0},
|
|
46
|
+
{"tab", 0},
|
|
47
|
+
{"allbox", TBL_OPT_ALLBOX | TBL_OPT_BOX},
|
|
48
|
+
{"box", TBL_OPT_BOX},
|
|
49
|
+
{"frame", TBL_OPT_BOX},
|
|
50
|
+
{"center", TBL_OPT_CENTRE},
|
|
51
|
+
{"centre", TBL_OPT_CENTRE},
|
|
52
|
+
{"doublebox", TBL_OPT_DBOX},
|
|
53
|
+
{"doubleframe", TBL_OPT_DBOX},
|
|
54
|
+
{"expand", TBL_OPT_EXPAND},
|
|
55
|
+
{"nokeep", TBL_OPT_NOKEEP},
|
|
56
|
+
{"nospaces", TBL_OPT_NOSPACE},
|
|
57
|
+
{"nowarn", TBL_OPT_NOWARN},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
#define KEY_MAXKEYS ((int)(sizeof(keys)/sizeof(keys[0])))
|
|
61
|
+
|
|
62
|
+
static void arg(struct tbl_node *, int, const char *, int *, int);
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
static void
|
|
66
|
+
arg(struct tbl_node *tbl, int ln, const char *p, int *pos, int key)
|
|
67
|
+
{
|
|
68
|
+
int len, want;
|
|
69
|
+
|
|
70
|
+
while (p[*pos] == ' ' || p[*pos] == '\t')
|
|
71
|
+
(*pos)++;
|
|
72
|
+
|
|
73
|
+
/* Arguments are enclosed in parentheses. */
|
|
74
|
+
|
|
75
|
+
len = 0;
|
|
76
|
+
if (p[*pos] == '(') {
|
|
77
|
+
(*pos)++;
|
|
78
|
+
while (p[*pos + len] != ')')
|
|
79
|
+
len++;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
switch (key) {
|
|
83
|
+
case KEY_DELIM:
|
|
84
|
+
mandoc_msg(MANDOCERR_TBLOPT_EQN,
|
|
85
|
+
ln, *pos, "%.*s", len, p + *pos);
|
|
86
|
+
want = 2;
|
|
87
|
+
break;
|
|
88
|
+
case KEY_TAB:
|
|
89
|
+
want = 1;
|
|
90
|
+
if (len == want)
|
|
91
|
+
tbl->opts.tab = p[*pos];
|
|
92
|
+
break;
|
|
93
|
+
case KEY_LINESIZE:
|
|
94
|
+
want = 0;
|
|
95
|
+
break;
|
|
96
|
+
case KEY_DPOINT:
|
|
97
|
+
want = 1;
|
|
98
|
+
if (len == want)
|
|
99
|
+
tbl->opts.decimal = p[*pos];
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
abort();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (len == 0)
|
|
106
|
+
mandoc_msg(MANDOCERR_TBLOPT_NOARG, ln, *pos,
|
|
107
|
+
"%s", keys[key].name);
|
|
108
|
+
else if (want && len != want)
|
|
109
|
+
mandoc_msg(MANDOCERR_TBLOPT_ARGSZ, ln, *pos,
|
|
110
|
+
"%s want %d have %d", keys[key].name, want, len);
|
|
111
|
+
|
|
112
|
+
*pos += len;
|
|
113
|
+
if (p[*pos] == ')')
|
|
114
|
+
(*pos)++;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* Parse one line of options up to the semicolon.
|
|
119
|
+
* Each option can be preceded by blanks and/or commas,
|
|
120
|
+
* and some options are followed by arguments.
|
|
121
|
+
*/
|
|
122
|
+
void
|
|
123
|
+
tbl_option(struct tbl_node *tbl, int ln, const char *p, int *offs)
|
|
124
|
+
{
|
|
125
|
+
int i, pos, len;
|
|
126
|
+
|
|
127
|
+
pos = *offs;
|
|
128
|
+
for (;;) {
|
|
129
|
+
while (p[pos] == ' ' || p[pos] == '\t' || p[pos] == ',')
|
|
130
|
+
pos++;
|
|
131
|
+
|
|
132
|
+
if (p[pos] == ';') {
|
|
133
|
+
*offs = pos + 1;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* Parse one option name. */
|
|
138
|
+
|
|
139
|
+
len = 0;
|
|
140
|
+
while (isalpha((unsigned char)p[pos + len]))
|
|
141
|
+
len++;
|
|
142
|
+
|
|
143
|
+
if (len == 0) {
|
|
144
|
+
mandoc_msg(MANDOCERR_TBLOPT_ALPHA,
|
|
145
|
+
ln, pos, "%c", p[pos]);
|
|
146
|
+
pos++;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* Look up the option name. */
|
|
151
|
+
|
|
152
|
+
i = 0;
|
|
153
|
+
while (i < KEY_MAXKEYS &&
|
|
154
|
+
(strncasecmp(p + pos, keys[i].name, len) ||
|
|
155
|
+
keys[i].name[len] != '\0'))
|
|
156
|
+
i++;
|
|
157
|
+
|
|
158
|
+
if (i == KEY_MAXKEYS) {
|
|
159
|
+
mandoc_msg(MANDOCERR_TBLOPT_BAD,
|
|
160
|
+
ln, pos, "%.*s", len, p + pos);
|
|
161
|
+
pos += len;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* Handle the option. */
|
|
166
|
+
|
|
167
|
+
pos += len;
|
|
168
|
+
if (keys[i].key)
|
|
169
|
+
tbl->opts.opts |= keys[i].key;
|
|
170
|
+
else
|
|
171
|
+
arg(tbl, ln, p, &pos, i);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* $Id: tbl_parse.h,v 1.2 2018/12/14 06:33:14 schwarze Exp $ */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
|
|
4
|
+
* Copyright (c) 2011, 2017 Ingo Schwarze <schwarze@openbsd.org>
|
|
5
|
+
*
|
|
6
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
7
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
8
|
+
* copyright notice and this permission notice appear in all copies.
|
|
9
|
+
*
|
|
10
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
|
|
11
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
12
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
|
13
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
14
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
15
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
16
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
17
|
+
*
|
|
18
|
+
* External interface of the tbl(7) parser.
|
|
19
|
+
* For use in the roff(7) and tbl(7) parsers only.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
struct tbl_node;
|
|
23
|
+
struct tbl_span;
|
|
24
|
+
|
|
25
|
+
struct tbl_node *tbl_alloc(int, int, struct tbl_node *);
|
|
26
|
+
int tbl_end(struct tbl_node *, int);
|
|
27
|
+
void tbl_free(struct tbl_node *);
|
|
28
|
+
void tbl_read(struct tbl_node *, int, const char *, int);
|
|
29
|
+
void tbl_restart(int, int, struct tbl_node *);
|
|
30
|
+
struct tbl_span *tbl_span(struct tbl_node *);
|