/* ARGSUSED */ int blk_imp(MACRO_PROT_ARGS) { int la; char *p; struct man_node *n; /* Close out prior scopes. */ if ( ! rew_scope(MAN_BODY, man, tok)) return(0); if ( ! rew_scope(MAN_BLOCK, man, tok)) return(0); /* Allocate new block & head scope. */ if ( ! man_block_alloc(man, line, ppos, tok)) return(0); if ( ! man_head_alloc(man, line, ppos, tok)) return(0); n = man->last; /* Add line arguments. */ for (;;) { la = *pos; if ( ! man_args(man, line, pos, buf, &p)) break; if ( ! man_word_alloc(man, line, la, p)) return(0); } /* Close out head and open body (unless MAN_SCOPE). */ if (MAN_SCOPED & man_macros[tok].flags) { /* If we're forcing scope (`TP'), keep it open. */ if (MAN_FSCOPED & man_macros[tok].flags) { man->flags |= MAN_BLINE; return(1); } else if (n == man->last) { man->flags |= MAN_BLINE; return(1); } } if ( ! rew_scope(MAN_HEAD, man, tok)) return(0); return(man_body_alloc(man, line, ppos, tok)); }
/* ARGSUSED */ int blk_exp(MACRO_PROT_ARGS) { struct man_node *n; int la; char *p; /* Close out prior implicit scopes. */ if ( ! rew_scope(MAN_BLOCK, man, tok)) return(0); if ( ! man_block_alloc(man, line, ppos, tok)) return(0); if ( ! man_head_alloc(man, line, ppos, tok)) return(0); for (;;) { la = *pos; if ( ! man_args(man, line, pos, buf, &p)) break; if ( ! man_word_alloc(man, line, la, p)) return(0); } assert(man); assert(tok != MAN_MAX); for (n = man->last; n; n = n->parent) { if (n->tok != tok) continue; assert(MAN_HEAD == n->type); man_unscope(man, n, MANDOCERR_MAX); break; } return(man_body_alloc(man, line, ppos, tok)); }
/* ARGSUSED */ int blk_exp(MACRO_PROT_ARGS) { int la; char *p; /* * Close out prior scopes. "Regular" explicit macros cannot be * nested, but we allow roff macros to be placed just about * anywhere. */ if ( ! rew_scope(MAN_BODY, m, tok)) return(0); if ( ! rew_scope(MAN_BLOCK, m, tok)) return(0); if ( ! man_block_alloc(m, line, ppos, tok)) return(0); if ( ! man_head_alloc(m, line, ppos, tok)) return(0); for (;;) { la = *pos; if ( ! man_args(m, line, pos, buf, &p)) break; if ( ! man_word_alloc(m, line, la, p)) return(0); } assert(m); assert(tok != MAN_MAX); if ( ! rew_scope(MAN_HEAD, m, tok)) return(0); return(man_body_alloc(m, line, ppos, tok)); }
static int man_ptext(struct man *man, int line, char *buf, int offs) { int i; /* Literal free-form text whitespace is preserved. */ if (MAN_LITERAL & man->flags) { if ( ! man_word_alloc(man, line, offs, buf + offs)) return(0); return(man_descope(man, line, offs)); } for (i = offs; ' ' == buf[i]; i++) /* Skip leading whitespace. */ ; /* * Blank lines are ignored right after headings * but add a single vertical space elsewhere. */ if ('\0' == buf[i]) { /* Allocate a blank entry. */ if (MAN_SH != man->last->tok && MAN_SS != man->last->tok) { if ( ! man_elem_alloc(man, line, offs, MAN_sp)) return(0); man->next = MAN_NEXT_SIBLING; } return(1); } /* * Warn if the last un-escaped character is whitespace. Then * strip away the remaining spaces (tabs stay!). */ i = (int)strlen(buf); assert(i); if (' ' == buf[i - 1] || '\t' == buf[i - 1]) { if (i > 1 && '\\' != buf[i - 2]) man_pmsg(man, line, i - 1, MANDOCERR_EOLNSPACE); for (--i; i && ' ' == buf[i]; i--) /* Spin back to non-space. */ ; /* Jump ahead of escaped whitespace. */ i += '\\' == buf[i] ? 2 : 1; buf[i] = '\0'; } if ( ! man_word_alloc(man, line, offs, buf + offs)) return(0); /* * End-of-sentence check. If the last character is an unescaped * EOS character, then flag the node as being the end of a * sentence. The front-end will know how to interpret this. */ assert(i); if (mandoc_eos(buf, (size_t)i, 0)) man->last->flags |= MAN_EOS; return(man_descope(man, line, offs)); }
static int man_ptext(struct man *m, int line, char *buf, int offs) { int i; /* Literal free-form text whitespace is preserved. */ if (MAN_LITERAL & m->flags) { if ( ! man_word_alloc(m, line, offs, buf + offs)) return(0); return(man_descope(m, line, offs)); } /* Pump blank lines directly into the backend. */ for (i = offs; ' ' == buf[i]; i++) /* Skip leading whitespace. */ ; if ('\0' == buf[i]) { /* Allocate a blank entry. */ if ( ! man_word_alloc(m, line, offs, "")) return(0); return(man_descope(m, line, offs)); } /* * Warn if the last un-escaped character is whitespace. Then * strip away the remaining spaces (tabs stay!). */ i = (int)strlen(buf); assert(i); if (' ' == buf[i - 1] || '\t' == buf[i - 1]) { if (i > 1 && '\\' != buf[i - 2]) man_pmsg(m, line, i - 1, MANDOCERR_EOLNSPACE); for (--i; i && ' ' == buf[i]; i--) /* Spin back to non-space. */ ; /* Jump ahead of escaped whitespace. */ i += '\\' == buf[i] ? 2 : 1; buf[i] = '\0'; } if ( ! man_word_alloc(m, line, offs, buf + offs)) return(0); /* * End-of-sentence check. If the last character is an unescaped * EOS character, then flag the node as being the end of a * sentence. The front-end will know how to interpret this. */ assert(i); if (mandoc_eos(buf, (size_t)i, 0)) m->last->flags |= MAN_EOS; return(man_descope(m, line, offs)); }
/* ARGSUSED */ int in_line_eoln(MACRO_PROT_ARGS) { int la; char *p; struct man_node *n; if ( ! man_elem_alloc(man, line, ppos, tok)) return(0); n = man->last; for (;;) { la = *pos; if ( ! man_args(man, line, pos, buf, &p)) break; if ( ! man_word_alloc(man, line, la, p)) return(0); } /* * Append MAN_EOS in case the last snipped argument * ends with a dot, e.g. `.IR syslog (3).' */ if (n != man->last && mandoc_eos(man->last->string, strlen(man->last->string))) man->last->flags |= MAN_EOS; /* * If no arguments are specified and this is MAN_SCOPED (i.e., * next-line scoped), then set our mode to indicate that we're * waiting for terms to load into our context. */ if (n == man->last && MAN_SCOPED & man_macros[tok].flags) { assert( ! (MAN_NSCOPED & man_macros[tok].flags)); man->flags |= MAN_ELINE; return(1); } /* Set ignorable context, if applicable. */ if (MAN_NSCOPED & man_macros[tok].flags) { assert( ! (MAN_SCOPED & man_macros[tok].flags)); man->flags |= MAN_ILINE; } assert(MAN_ROOT != man->last->type); man->next = MAN_NEXT_SIBLING; /* * Rewind our element scope. Note that when TH is pruned, we'll * be back at the root, so make sure that we don't clobber as * its sibling. */ for ( ; man->last; man->last = man->last->parent) { if (man->last == n) break; if (man->last->type == MAN_ROOT) break; if ( ! man_valid_post(man)) return(0); } assert(man->last); /* * Same here regarding whether we're back at the root. */ if (man->last->type != MAN_ROOT && ! man_valid_post(man)) return(0); return(1); }