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,135 @@
|
|
|
1
|
+
/* $Id: compat_stringlist.c,v 1.8 2020/06/15 21:48:09 schwarze Exp $ */
|
|
2
|
+
/* $NetBSD: stringlist.c,v 1.14 2015/05/21 01:29:13 christos Exp $ */
|
|
3
|
+
|
|
4
|
+
/*-
|
|
5
|
+
* Copyright (c) 1994, 1999 The NetBSD Foundation, Inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* This code is derived from software contributed to The NetBSD Foundation
|
|
9
|
+
* by Christos Zoulas.
|
|
10
|
+
*
|
|
11
|
+
* Redistribution and use in source and binary forms, with or without
|
|
12
|
+
* modification, are permitted provided that the following conditions
|
|
13
|
+
* are met:
|
|
14
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
15
|
+
* notice, this list of conditions and the following disclaimer.
|
|
16
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
17
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
18
|
+
* documentation and/or other materials provided with the distribution.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
21
|
+
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
22
|
+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
23
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
24
|
+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
25
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
26
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
27
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
28
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
29
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
30
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
*/
|
|
32
|
+
#include "config.h"
|
|
33
|
+
|
|
34
|
+
#include <stdlib.h>
|
|
35
|
+
#include <string.h>
|
|
36
|
+
#include "compat_stringlist.h"
|
|
37
|
+
|
|
38
|
+
#define _SL_CHUNKSIZE 20
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
* sl_init(): Initialize a string list
|
|
42
|
+
*/
|
|
43
|
+
StringList *
|
|
44
|
+
sl_init(void)
|
|
45
|
+
{
|
|
46
|
+
StringList *sl;
|
|
47
|
+
|
|
48
|
+
sl = malloc(sizeof(StringList));
|
|
49
|
+
if (sl == NULL)
|
|
50
|
+
return NULL;
|
|
51
|
+
|
|
52
|
+
sl->sl_cur = 0;
|
|
53
|
+
sl->sl_max = _SL_CHUNKSIZE;
|
|
54
|
+
sl->sl_str = reallocarray(NULL, sl->sl_max, sizeof(char *));
|
|
55
|
+
if (sl->sl_str == NULL) {
|
|
56
|
+
free(sl);
|
|
57
|
+
sl = NULL;
|
|
58
|
+
}
|
|
59
|
+
return sl;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
* sl_add(): Add an item to the string list
|
|
65
|
+
*/
|
|
66
|
+
int
|
|
67
|
+
sl_add(StringList *sl, char *name)
|
|
68
|
+
{
|
|
69
|
+
if (sl->sl_cur == sl->sl_max - 1) {
|
|
70
|
+
char **new;
|
|
71
|
+
|
|
72
|
+
new = reallocarray(sl->sl_str, (sl->sl_max + _SL_CHUNKSIZE),
|
|
73
|
+
sizeof(char *));
|
|
74
|
+
if (new == NULL)
|
|
75
|
+
return -1;
|
|
76
|
+
sl->sl_max += _SL_CHUNKSIZE;
|
|
77
|
+
sl->sl_str = new;
|
|
78
|
+
}
|
|
79
|
+
sl->sl_str[sl->sl_cur++] = name;
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
/*
|
|
85
|
+
* sl_free(): Free a stringlist
|
|
86
|
+
*/
|
|
87
|
+
void
|
|
88
|
+
sl_free(StringList *sl, int all)
|
|
89
|
+
{
|
|
90
|
+
size_t i;
|
|
91
|
+
|
|
92
|
+
if (sl == NULL)
|
|
93
|
+
return;
|
|
94
|
+
if (sl->sl_str) {
|
|
95
|
+
if (all)
|
|
96
|
+
for (i = 0; i < sl->sl_cur; i++)
|
|
97
|
+
free(sl->sl_str[i]);
|
|
98
|
+
free(sl->sl_str);
|
|
99
|
+
}
|
|
100
|
+
free(sl);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* sl_find(): Find a name in the string list
|
|
106
|
+
*/
|
|
107
|
+
char *
|
|
108
|
+
sl_find(StringList *sl, const char *name)
|
|
109
|
+
{
|
|
110
|
+
size_t i;
|
|
111
|
+
|
|
112
|
+
for (i = 0; i < sl->sl_cur; i++)
|
|
113
|
+
if (strcmp(sl->sl_str[i], name) == 0)
|
|
114
|
+
return sl->sl_str[i];
|
|
115
|
+
|
|
116
|
+
return NULL;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
int
|
|
120
|
+
sl_delete(StringList *sl, const char *name, int all)
|
|
121
|
+
{
|
|
122
|
+
size_t i, j;
|
|
123
|
+
|
|
124
|
+
for (i = 0; i < sl->sl_cur; i++)
|
|
125
|
+
if (strcmp(sl->sl_str[i], name) == 0) {
|
|
126
|
+
if (all)
|
|
127
|
+
free(sl->sl_str[i]);
|
|
128
|
+
for (j = i + 1; j < sl->sl_cur; j++)
|
|
129
|
+
sl->sl_str[j - 1] = sl->sl_str[j];
|
|
130
|
+
sl->sl_str[--sl->sl_cur] = NULL;
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
return -1;
|
|
134
|
+
}
|
|
135
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* $Id: compat_stringlist.h,v 1.5 2020/06/15 21:48:09 schwarze Exp $ */
|
|
2
|
+
/* $NetBSD: stringlist.h,v 1.7 2008/04/28 20:22:54 martin Exp $ */
|
|
3
|
+
|
|
4
|
+
/*-
|
|
5
|
+
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* This code is derived from software contributed to The NetBSD Foundation
|
|
9
|
+
* by Christos Zoulas.
|
|
10
|
+
*
|
|
11
|
+
* Redistribution and use in source and binary forms, with or without
|
|
12
|
+
* modification, are permitted provided that the following conditions
|
|
13
|
+
* are met:
|
|
14
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
15
|
+
* notice, this list of conditions and the following disclaimer.
|
|
16
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
17
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
18
|
+
* documentation and/or other materials provided with the distribution.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
21
|
+
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
22
|
+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
23
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
24
|
+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
25
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
26
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
27
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
28
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
29
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
30
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
#include <sys/types.h>
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
* Simple string list
|
|
37
|
+
*/
|
|
38
|
+
typedef struct _stringlist {
|
|
39
|
+
char **sl_str;
|
|
40
|
+
size_t sl_max;
|
|
41
|
+
size_t sl_cur;
|
|
42
|
+
} StringList;
|
|
43
|
+
|
|
44
|
+
StringList *sl_init(void);
|
|
45
|
+
int sl_add(StringList *, char *);
|
|
46
|
+
void sl_free(StringList *, int);
|
|
47
|
+
char *sl_find(StringList *, const char *);
|
|
48
|
+
int sl_delete(StringList *, const char *, int);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* $Id: compat_strlcat.c,v 1.6 2020/06/15 20:49:57 schwarze Exp $ */
|
|
2
|
+
/* $OpenBSD: strlcat.c,v 1.19 2019/01/25 00:19:25 millert Exp $ */
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 1998, 2015 Todd C. Miller <millert@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
|
+
#include <string.h>
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Appends src to string dst of size dsize (unlike strncat, dsize is the
|
|
26
|
+
* full size of dst, not space left). At most dsize-1 characters
|
|
27
|
+
* will be copied. Always NUL terminates (unless dsize <= strlen(dst)).
|
|
28
|
+
* Returns strlen(src) + MIN(dsize, strlen(initial dst)).
|
|
29
|
+
* If retval >= dsize, truncation occurred.
|
|
30
|
+
*/
|
|
31
|
+
size_t
|
|
32
|
+
strlcat(char *dst, const char *src, size_t dsize)
|
|
33
|
+
{
|
|
34
|
+
const char *odst = dst;
|
|
35
|
+
const char *osrc = src;
|
|
36
|
+
size_t n = dsize;
|
|
37
|
+
size_t dlen;
|
|
38
|
+
|
|
39
|
+
/* Find the end of dst and adjust bytes left but don't go past end. */
|
|
40
|
+
while (n-- != 0 && *dst != '\0')
|
|
41
|
+
dst++;
|
|
42
|
+
dlen = dst - odst;
|
|
43
|
+
n = dsize - dlen;
|
|
44
|
+
|
|
45
|
+
if (n-- == 0)
|
|
46
|
+
return(dlen + strlen(src));
|
|
47
|
+
while (*src != '\0') {
|
|
48
|
+
if (n != 0) {
|
|
49
|
+
*dst++ = *src;
|
|
50
|
+
n--;
|
|
51
|
+
}
|
|
52
|
+
src++;
|
|
53
|
+
}
|
|
54
|
+
*dst = '\0';
|
|
55
|
+
|
|
56
|
+
return(dlen + (src - osrc)); /* count does not include NUL */
|
|
57
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* $Id: compat_strlcpy.c,v 1.6 2020/06/15 20:49:57 schwarze Exp $ */
|
|
2
|
+
/* $OpenBSD: strlcpy.c,v 1.16 2019/01/25 00:19:25 millert Exp $ */
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 1998, 2015 Todd C. Miller <millert@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
|
+
#include <string.h>
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Copy string src to buffer dst of size dsize. At most dsize-1
|
|
26
|
+
* chars will be copied. Always NUL terminates (unless dsize == 0).
|
|
27
|
+
* Returns strlen(src); if retval >= dsize, truncation occurred.
|
|
28
|
+
*/
|
|
29
|
+
size_t
|
|
30
|
+
strlcpy(char *dst, const char *src, size_t dsize)
|
|
31
|
+
{
|
|
32
|
+
const char *osrc = src;
|
|
33
|
+
size_t nleft = dsize;
|
|
34
|
+
|
|
35
|
+
/* Copy as many bytes as will fit. */
|
|
36
|
+
if (nleft != 0) {
|
|
37
|
+
while (--nleft != 0) {
|
|
38
|
+
if ((*dst++ = *src++) == '\0')
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Not enough room in dst, add NUL and traverse rest of src. */
|
|
44
|
+
if (nleft == 0) {
|
|
45
|
+
if (dsize != 0)
|
|
46
|
+
*dst = '\0'; /* NUL-terminate dst */
|
|
47
|
+
while (*src++)
|
|
48
|
+
;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return(src - osrc - 1); /* count does not include NUL */
|
|
52
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* $Id: compat_strndup.c,v 1.3 2020/06/15 20:19:39 schwarze Exp $ */
|
|
2
|
+
/* $OpenBSD: strndup.c,v 1.3 2019/01/25 00:19:25 millert Exp $ */
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2010 Todd C. Miller <millert@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 <stdlib.h>
|
|
24
|
+
#include <string.h>
|
|
25
|
+
|
|
26
|
+
char *
|
|
27
|
+
strndup(const char *str, size_t maxlen)
|
|
28
|
+
{
|
|
29
|
+
char *copy;
|
|
30
|
+
size_t len;
|
|
31
|
+
|
|
32
|
+
for (len = 0; len < maxlen && str[len] != '\0'; len++)
|
|
33
|
+
continue;
|
|
34
|
+
|
|
35
|
+
copy = malloc(len + 1);
|
|
36
|
+
if (copy != NULL) {
|
|
37
|
+
(void)memcpy(copy, str, len);
|
|
38
|
+
copy[len] = '\0';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return copy;
|
|
42
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* $Id: compat_strsep.c,v 1.5 2020/06/15 01:37:15 schwarze Exp $ */
|
|
2
|
+
/* $OpenBSD: strsep.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */
|
|
3
|
+
|
|
4
|
+
/*-
|
|
5
|
+
* Copyright (c) 1990, 1993
|
|
6
|
+
* The Regents of the University of California. All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions
|
|
10
|
+
* are met:
|
|
11
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer.
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
|
16
|
+
* 3. Neither the name of the University nor the names of its contributors
|
|
17
|
+
* may be used to endorse or promote products derived from this software
|
|
18
|
+
* without specific prior written permission.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
21
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
23
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
26
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
27
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
28
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
29
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
30
|
+
* SUCH DAMAGE.
|
|
31
|
+
*/
|
|
32
|
+
#include "config.h"
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* Get next token from string *stringp, where tokens are possibly-empty
|
|
36
|
+
* strings separated by characters from delim.
|
|
37
|
+
*
|
|
38
|
+
* Writes NULs into the string at *stringp to end tokens.
|
|
39
|
+
* delim need not remain constant from call to call.
|
|
40
|
+
* On return, *stringp points past the last NUL written (if there might
|
|
41
|
+
* be further tokens), or is NULL (if there are definitely no more tokens).
|
|
42
|
+
*
|
|
43
|
+
* If *stringp is NULL, strsep returns NULL.
|
|
44
|
+
*/
|
|
45
|
+
char *
|
|
46
|
+
strsep(char **stringp, const char *delim)
|
|
47
|
+
{
|
|
48
|
+
char *s;
|
|
49
|
+
const char *spanp;
|
|
50
|
+
int c, sc;
|
|
51
|
+
char *tok;
|
|
52
|
+
|
|
53
|
+
if ((s = *stringp) == NULL)
|
|
54
|
+
return (NULL);
|
|
55
|
+
for (tok = s;;) {
|
|
56
|
+
c = *s++;
|
|
57
|
+
spanp = delim;
|
|
58
|
+
do {
|
|
59
|
+
if ((sc = *spanp++) == c) {
|
|
60
|
+
if (c == 0)
|
|
61
|
+
s = NULL;
|
|
62
|
+
else
|
|
63
|
+
s[-1] = 0;
|
|
64
|
+
*stringp = s;
|
|
65
|
+
return (tok);
|
|
66
|
+
}
|
|
67
|
+
} while (sc != 0);
|
|
68
|
+
}
|
|
69
|
+
/* NOTREACHED */
|
|
70
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* $Id: compat_strtonum.c,v 1.2 2020/06/15 01:37:15 schwarze Exp $ */
|
|
2
|
+
/* $OpenBSD: strtonum.c,v 1.8 2015/09/13 08:31:48 guenther Exp $ */
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2004 Ted Unangst and Todd Miller
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
9
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
10
|
+
* copyright notice and this permission notice appear in all copies.
|
|
11
|
+
*
|
|
12
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
13
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
14
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
15
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
16
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
17
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
18
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
+
*/
|
|
20
|
+
#include "config.h"
|
|
21
|
+
|
|
22
|
+
#include <errno.h>
|
|
23
|
+
#include <limits.h>
|
|
24
|
+
#include <stdlib.h>
|
|
25
|
+
|
|
26
|
+
#define INVALID 1
|
|
27
|
+
#define TOOSMALL 2
|
|
28
|
+
#define TOOLARGE 3
|
|
29
|
+
|
|
30
|
+
long long
|
|
31
|
+
strtonum(const char *numstr, long long minval, long long maxval,
|
|
32
|
+
const char **errstrp)
|
|
33
|
+
{
|
|
34
|
+
long long ll = 0;
|
|
35
|
+
int error = 0;
|
|
36
|
+
char *ep;
|
|
37
|
+
struct errval {
|
|
38
|
+
const char *errstr;
|
|
39
|
+
int err;
|
|
40
|
+
} ev[4] = {
|
|
41
|
+
{ NULL, 0 },
|
|
42
|
+
{ "invalid", EINVAL },
|
|
43
|
+
{ "too small", ERANGE },
|
|
44
|
+
{ "too large", ERANGE },
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
ev[0].err = errno;
|
|
48
|
+
errno = 0;
|
|
49
|
+
if (minval > maxval) {
|
|
50
|
+
error = INVALID;
|
|
51
|
+
} else {
|
|
52
|
+
ll = strtoll(numstr, &ep, 10);
|
|
53
|
+
if (numstr == ep || *ep != '\0')
|
|
54
|
+
error = INVALID;
|
|
55
|
+
else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)
|
|
56
|
+
error = TOOSMALL;
|
|
57
|
+
else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval)
|
|
58
|
+
error = TOOLARGE;
|
|
59
|
+
}
|
|
60
|
+
if (errstrp != NULL)
|
|
61
|
+
*errstrp = ev[error].errstr;
|
|
62
|
+
errno = ev[error].err;
|
|
63
|
+
if (error)
|
|
64
|
+
ll = 0;
|
|
65
|
+
|
|
66
|
+
return (ll);
|
|
67
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* $Id: compat_vasprintf.c,v 1.4 2020/06/15 01:37:15 schwarze Exp $ */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
6
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
* copyright notice and this permission notice appear in all copies.
|
|
8
|
+
*
|
|
9
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
*
|
|
17
|
+
* This fallback implementation is not efficient:
|
|
18
|
+
* It does the formatting twice.
|
|
19
|
+
* Short of fiddling with the unknown internals of the system's
|
|
20
|
+
* printf(3) or completely reimplementing printf(3), i can't think
|
|
21
|
+
* of another portable solution.
|
|
22
|
+
*/
|
|
23
|
+
#include "config.h"
|
|
24
|
+
|
|
25
|
+
#include <stdarg.h>
|
|
26
|
+
#include <stdio.h>
|
|
27
|
+
#include <stdlib.h>
|
|
28
|
+
|
|
29
|
+
int
|
|
30
|
+
vasprintf(char **ret, const char *format, va_list ap)
|
|
31
|
+
{
|
|
32
|
+
char buf[2];
|
|
33
|
+
va_list ap2;
|
|
34
|
+
int sz;
|
|
35
|
+
|
|
36
|
+
va_copy(ap2, ap);
|
|
37
|
+
sz = vsnprintf(buf, sizeof(buf), format, ap2);
|
|
38
|
+
va_end(ap2);
|
|
39
|
+
|
|
40
|
+
if (sz != -1 && (*ret = malloc(sz + 1)) != NULL) {
|
|
41
|
+
if (vsnprintf(*ret, sz + 1, format, ap) == sz)
|
|
42
|
+
return sz;
|
|
43
|
+
free(*ret);
|
|
44
|
+
}
|
|
45
|
+
*ret = NULL;
|
|
46
|
+
return -1;
|
|
47
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#ifdef __cplusplus
|
|
2
|
+
#error "Do not use C++. See the INSTALL file."
|
|
3
|
+
#endif
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#define MAN_CONF_FILE "/etc/man.conf"
|
|
7
|
+
#define MANPATH_BASE "/usr/share/man:/usr/X11R6/man"
|
|
8
|
+
#define MANPATH_DEFAULT "/usr/share/man:/usr/X11R6/man:/usr/local/man"
|
|
9
|
+
#define OSENUM MANDOC_OS_OPENBSD
|
|
10
|
+
#define UTF8_LOCALE "en_US.UTF-8"
|
|
11
|
+
|
|
12
|
+
#define HAVE_DIRENT_NAMLEN 1
|
|
13
|
+
#define HAVE_ENDIAN 1
|
|
14
|
+
#define HAVE_ERR 1
|
|
15
|
+
#define HAVE_FTS 1
|
|
16
|
+
#define HAVE_FTS_COMPARE_CONST 0
|
|
17
|
+
#define HAVE_GETLINE 1
|
|
18
|
+
#define HAVE_GETSUBOPT 1
|
|
19
|
+
#define HAVE_ISBLANK 1
|
|
20
|
+
#define HAVE_LESS_T 1
|
|
21
|
+
#define HAVE_MKDTEMP 1
|
|
22
|
+
#define HAVE_MKSTEMPS 1
|
|
23
|
+
#define HAVE_NTOHL 1
|
|
24
|
+
#define HAVE_PLEDGE 1
|
|
25
|
+
#define HAVE_PROGNAME 1
|
|
26
|
+
#define HAVE_REALLOCARRAY 1
|
|
27
|
+
#define HAVE_RECALLOCARRAY 1
|
|
28
|
+
#define HAVE_REWB_BSD 1
|
|
29
|
+
#define HAVE_REWB_SYSV 1
|
|
30
|
+
#define HAVE_SANDBOX_INIT 0
|
|
31
|
+
#define HAVE_STRCASESTR 1
|
|
32
|
+
#define HAVE_STRINGLIST 0
|
|
33
|
+
#define HAVE_STRLCAT 1
|
|
34
|
+
#define HAVE_STRLCPY 1
|
|
35
|
+
#define HAVE_STRNDUP 1
|
|
36
|
+
#define HAVE_STRPTIME 1
|
|
37
|
+
#define HAVE_STRSEP 1
|
|
38
|
+
#define HAVE_STRTONUM 1
|
|
39
|
+
#define HAVE_SYS_ENDIAN 1
|
|
40
|
+
#define HAVE_VASPRINTF 1
|
|
41
|
+
#define HAVE_WCHAR 1
|
|
42
|
+
#define HAVE_OHASH 1
|
|
43
|
+
#define NEED_XPG4_2 0
|
|
44
|
+
|
|
45
|
+
#define BINM_APROPOS "apropos"
|
|
46
|
+
#define BINM_CATMAN "catman"
|
|
47
|
+
#define BINM_MAKEWHATIS "makewhatis"
|
|
48
|
+
#define BINM_MAN "man"
|
|
49
|
+
#define BINM_SOELIM "soelim"
|
|
50
|
+
#define BINM_WHATIS "whatis"
|
|
51
|
+
#define BINM_PAGER "less"
|
|
52
|
+
|