-/* $Id: man.c,v 1.36 2009/08/21 13:18:32 kristaps Exp $ */
+/* $Id: man.c,v 1.41 2009/09/23 11:53:45 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/types.h>
+
#include <assert.h>
#include <ctype.h>
#include <stdarg.h>
"R", "B", "I", "IR",
"RI", "na", "i", "sp",
"nf", "fi", "r", "RE",
- "RS", "DT"
+ "RS", "DT", "UC"
};
const char * const *man_macronames = __man_macronames;
{
man_free1(man);
-
- if (man->htab)
- man_hash_free(man->htab);
free(man);
}
return(NULL);
}
+ man_hash_init();
+
p->data = data;
p->pflags = pflags;
(void)memcpy(&p->cb, cb, sizeof(struct man_cb));
-
- if (NULL == (p->htab = man_hash_alloc())) {
- free(p);
- return(NULL);
- }
return(p);
}
void
man_node_freelist(struct man_node *p)
{
+ struct man_node *n;
if (p->child)
man_node_freelist(p->child);
- if (p->next)
- man_node_freelist(p->next);
-
assert(0 == p->nchild);
+ n = p->next;
man_node_free(p);
+ if (n)
+ man_node_freelist(n);
}
break;
else if (' ' == buf[i])
break;
+
+ /* Check for invalid characters. */
+
+ if (isgraph((u_char)buf[i]))
+ continue;
+ return(man_perr(m, ln, i, WNPRINT));
}
mac[j] = 0;
return(1);
}
- if (MAN_MAX == (c = man_hash_find(m->htab, mac))) {
+ if (MAN_MAX == (c = man_hash_find(mac))) {
if ( ! (MAN_IGN_MACRO & m->pflags)) {
(void)man_perr(m, ln, ppos, WMACRO);
goto err;
if (m->flags & MAN_ELINE) {
n = m->last;
assert(NULL == n->child);
+ assert(0 == n->nchild);
if ( ! man_nwarn(m, n, WLNSCOPE))
return(0);
assert(n == n->prev->next);
n->prev->next = NULL;
m->last = n->prev;
+ m->next = MAN_NEXT_SIBLING;
} else {
assert(n == n->parent->child);
n->parent->child = NULL;
m->last = n->parent;
+ m->next = MAN_NEXT_CHILD;
}
man_node_free(n);