version 1.177, 2018/08/17 20:33:37 |
version 1.179, 2018/08/25 12:33:03 |
|
|
#include "roff_int.h" |
#include "roff_int.h" |
#include "libman.h" |
#include "libman.h" |
|
|
static void man_descope(struct roff_man *, int, int); |
static void man_descope(struct roff_man *, int, int, char *); |
|
static char *man_hasc(char *); |
static int man_ptext(struct roff_man *, int, char *, int); |
static int man_ptext(struct roff_man *, int, char *, int); |
static int man_pmacro(struct roff_man *, int, char *, int); |
static int man_pmacro(struct roff_man *, int, char *, int); |
|
|
Line 52 man_parseln(struct roff_man *man, int ln, char *buf, i |
|
Line 53 man_parseln(struct roff_man *man, int ln, char *buf, i |
|
man_ptext(man, ln, buf, offs); |
man_ptext(man, ln, buf, offs); |
} |
} |
|
|
|
/* |
|
* If the string ends with \c, return a pointer to the backslash. |
|
* Otherwise, return NULL. |
|
*/ |
|
static char * |
|
man_hasc(char *start) |
|
{ |
|
char *cp, *ep; |
|
|
|
ep = strchr(start, '\0') - 2; |
|
if (ep < start || ep[0] != '\\' || ep[1] != 'c') |
|
return NULL; |
|
for (cp = ep; cp > start; cp--) |
|
if (cp[-1] != '\\') |
|
break; |
|
return (ep - cp) % 2 ? NULL : ep; |
|
} |
|
|
static void |
static void |
man_descope(struct roff_man *man, int line, int offs) |
man_descope(struct roff_man *man, int line, int offs, char *start) |
{ |
{ |
|
/* Trailing \c keeps next-line scope open. */ |
|
|
|
if (man_hasc(start) != NULL) |
|
return; |
|
|
/* |
/* |
* Co-ordinate what happens with having a next-line scope open: |
* Co-ordinate what happens with having a next-line scope open: |
* first close out the element scope (if applicable), then close |
* first close out the element scope (if applicable), then close |
|
|
man_ptext(struct roff_man *man, int line, char *buf, int offs) |
man_ptext(struct roff_man *man, int line, char *buf, int offs) |
{ |
{ |
int i; |
int i; |
const char *cp, *sp; |
|
char *ep; |
char *ep; |
|
|
/* Literal free-form text whitespace is preserved. */ |
/* Literal free-form text whitespace is preserved. */ |
|
|
if (man->flags & MAN_LITERAL) { |
if (man->flags & MAN_LITERAL) { |
roff_word_alloc(man, line, offs, buf + offs); |
roff_word_alloc(man, line, offs, buf + offs); |
man_descope(man, line, offs); |
man_descope(man, line, offs, buf + offs); |
return 1; |
return 1; |
} |
} |
|
|
Line 104 man_ptext(struct roff_man *man, int line, char *buf, i |
|
Line 127 man_ptext(struct roff_man *man, int line, char *buf, i |
|
} |
} |
if (man->last->tok == MAN_SH || man->last->tok == MAN_SS) |
if (man->last->tok == MAN_SH || man->last->tok == MAN_SS) |
return 1; |
return 1; |
switch (man->last->type) { |
if (man->last->type == ROFFT_TEXT && |
case ROFFT_TEXT: |
((ep = man_hasc(man->last->string)) != NULL)) { |
sp = man->last->string; |
|
cp = ep = strchr(sp, '\0') - 2; |
|
if (cp < sp || cp[0] != '\\' || cp[1] != 'c') |
|
break; |
|
while (cp > sp && cp[-1] == '\\') |
|
cp--; |
|
if ((ep - cp) % 2) |
|
break; |
|
*ep = '\0'; |
*ep = '\0'; |
return 1; |
return 1; |
default: |
|
break; |
|
} |
} |
roff_elem_alloc(man, line, offs, ROFF_sp); |
roff_elem_alloc(man, line, offs, ROFF_sp); |
man->next = ROFF_NEXT_SIBLING; |
man->next = ROFF_NEXT_SIBLING; |
Line 157 man_ptext(struct roff_man *man, int line, char *buf, i |
|
Line 170 man_ptext(struct roff_man *man, int line, char *buf, i |
|
if (mandoc_eos(buf, (size_t)i)) |
if (mandoc_eos(buf, (size_t)i)) |
man->last->flags |= NODE_EOS; |
man->last->flags |= NODE_EOS; |
|
|
man_descope(man, line, offs); |
man_descope(man, line, offs, buf + offs); |
return 1; |
return 1; |
} |
} |
|
|
Line 337 man_breakscope(struct roff_man *man, int tok) |
|
Line 350 man_breakscope(struct roff_man *man, int tok) |
|
roff_node_delete(man, n); |
roff_node_delete(man, n); |
man->flags &= ~MAN_BLINE; |
man->flags &= ~MAN_BLINE; |
} |
} |
} |
|
|
|
const struct mparse * |
|
man_mparse(const struct roff_man *man) |
|
{ |
|
|
|
assert(man && man->parse); |
|
return man->parse; |
|
} |
} |
|
|
void |
void |