]>
git.cameronkatri.com Git - mandoc.git/blob - mandoc.c
1 /* $Id: mandoc.c,v 1.5 2009/10/30 05:58:38 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
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.
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.
17 #include <sys/types.h>
25 #include "libmandoc.h"
28 mandoc_special(const char *p
)
69 if (0 == *++p
|| ! isgraph((u_char
)*p
))
73 if (0 == *++p
|| ! isgraph((u_char
)*p
))
77 if (0 == *++p
|| ! isgraph((u_char
)*p
))
81 for (c
= 3, p
++; *p
&& ']' != *p
; p
++, c
++)
82 if ( ! isgraph((u_char
)*p
))
84 return(*p
== ']' ? c
: 0);
90 if (0 == *++p
|| ! isgraph((u_char
)*p
))
92 if (0 == *++p
|| ! isgraph((u_char
)*p
))
101 for (c
= 3, p
++; *p
&& ']' != *p
; p
++, c
++)
102 if ( ! isgraph((u_char
)*p
))
105 return(*p
== ']' ? c
: 0);
110 mandoc_calloc(size_t num
, size_t size
)
114 ptr
= calloc(num
, size
);
116 fprintf(stderr
, "memory exhausted\n");
125 mandoc_malloc(size_t size
)
131 fprintf(stderr
, "memory exhausted\n");
140 mandoc_realloc(void *ptr
, size_t size
)
143 ptr
= realloc(ptr
, size
);
145 fprintf(stderr
, "memory exhausted\n");
154 mandoc_strdup(const char *ptr
)
160 fprintf(stderr
, "memory exhausted\n");