-/* $Id: roff.c,v 1.285 2017/01/10 13:47:00 schwarze Exp $ */
+/* $Id: roff.c,v 1.289 2017/02/17 03:03:03 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
n->parent = man->last->parent;
break;
case ROFF_NEXT_CHILD:
+ if (man->last->child != NULL) {
+ n->next = man->last->child;
+ man->last->child->prev = n;
+ } else
+ man->last->last = n;
man->last->child = n;
n->parent = man->last;
- n->parent->last = n;
break;
default:
abort();
n = roff_node_alloc(man, line, pos, ROFFT_TEXT, TOKEN_NONE);
n->string = roff_strdup(man->roff, word);
roff_node_append(man, n);
- if (man->macroset == MACROSET_MDOC)
- n->flags |= NODE_VALID | NODE_ENDED;
- else
- n->flags |= NODE_VALID;
+ n->flags |= NODE_VALID | NODE_ENDED;
man->next = ROFF_NEXT_SIBLING;
}
n = roff_node_alloc(man, tbl->line, 0, ROFFT_TBL, TOKEN_NONE);
n->span = tbl;
roff_node_append(man, n);
- if (man->macroset == MACROSET_MDOC)
- n->flags |= NODE_VALID | NODE_ENDED;
- else
- n->flags |= NODE_VALID;
+ n->flags |= NODE_VALID | NODE_ENDED;
man->next = ROFF_NEXT_SIBLING;
}
return;
}
- /* Skip leading whitespace and escape sequences. */
+ /* Skip leading whitespace. */
- cp = n->string;
- while (*cp != '\0') {
- if ('\\' == *cp) {
+ for (cp = n->string; *cp != '\0'; cp++) {
+ if (cp[0] == '\\' && cp[1] != '\0' &&
+ strchr(" %&0^|~", cp[1]) != NULL)
cp++;
- mandoc_escape((const char **)&cp, NULL, NULL);
- } else if (isspace((unsigned char)*cp))
- cp++;
- else
+ else if ( ! isspace((unsigned char)*cp))
break;
}
+ /* Skip trailing backslash. */
+
+ sz = strlen(cp);
+ if (cp[sz - 1] == '\\')
+ sz--;
+
/* Skip trailing whitespace. */
- for (sz = strlen(cp); sz; sz--)
+ for (; sz; sz--)
if ( ! isspace((unsigned char)cp[sz-1]))
break;
ssz = 0;
while ('\0' != *p) {
- if ('\\' != *p && r->xtab && r->xtab[(int)*p].p) {
+ assert((unsigned int)*p < 128);
+ if ('\\' != *p && r->xtab && r->xtab[(unsigned int)*p].p) {
sz = r->xtab[(int)*p].sz;
res = mandoc_realloc(res, ssz + sz + 1);
memcpy(res + ssz, r->xtab[(int)*p].p, sz);