=================================================================== RCS file: /cvs/mandoc/roff.c,v retrieving revision 1.143 retrieving revision 1.144 diff -u -p -r1.143 -r1.144 --- mandoc/roff.c 2011/06/30 08:05:13 1.143 +++ mandoc/roff.c 2011/07/08 09:28:33 1.144 @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.143 2011/06/30 08:05:13 kristaps Exp $ */ +/* $Id: roff.c,v 1.144 2011/07/08 09:28:33 kristaps Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -596,11 +596,18 @@ roff_parse(struct roff *r, const char *buf, int *pos) size_t maclen; enum rofft t; - if ('\0' == buf[*pos] || '"' == buf[*pos]) + if ('\0' == buf[*pos] || '"' == buf[*pos] || + '\t' == buf[*pos] || ' ' == buf[*pos]) return(ROFF_MAX); + /* + * We stop the macro parse at an escape, tab, space, or nil. + * However, `\}' is also a valid macro, so make sure we don't + * clobber it by seeing the `\' as the end of token. + */ + mac = buf + *pos; - maclen = strcspn(mac, " \\\t\0"); + maclen = strcspn(mac + 1, " \\\t\0") + 1; t = (r->current_string = roff_getstrn(r, mac, maclen)) ? ROFF_USERDEF : roff_hash_find(mac, maclen); @@ -882,7 +889,22 @@ roff_cond_sub(ROFF_ARGS) ep++; if ('}' != *ep) continue; - *ep = '&'; + + /* + * Make the \} go away. + * This is a little haphazard, as it's not quite + * clear how nroff does this. + * If we're at the end of line, then just chop + * off the \} and resize the buffer. + * If we aren't, then conver it to spaces. + */ + + if ('\0' == *(ep + 1)) { + *--ep = '\0'; + *szp -= 2; + } else + *(ep - 1) = *ep = ' '; + roff_ccond(r, ROFF_ccond, bufp, szp, ln, pos, pos + 2, offs); break;