=================================================================== RCS file: /cvs/mandoc/mandoc.c,v retrieving revision 1.66 retrieving revision 1.69 diff -u -p -r1.66 -r1.69 --- mandoc/mandoc.c 2012/06/12 20:21:04 1.66 +++ mandoc/mandoc.c 2013/10/05 20:30:05 1.69 @@ -1,7 +1,7 @@ -/* $Id: mandoc.c,v 1.66 2012/06/12 20:21:04 kristaps Exp $ */ +/* $Id: mandoc.c,v 1.69 2013/10/05 20:30:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2011, 2012 Ingo Schwarze + * Copyright (c) 2011, 2012, 2013 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -40,7 +40,7 @@ static char *time2a(time_t); enum mandoc_esc -mandoc_escape(const char **end, const char **start, int *sz) +mandoc_escape(const char const **end, const char const **start, int *sz) { const char *local_start; int local_sz; @@ -296,13 +296,19 @@ mandoc_escape(const char **end, const char **start, in switch (gly) { case (ESCAPE_FONT): - /* - * Pretend that the constant-width font modes are the - * same as the regular font modes. - */ - if (2 == *sz && 'C' == **start) { - (*start)++; - (*sz)--; + if (2 == *sz) { + if ('C' == **start) { + /* + * Treat constant-width font modes + * just like regular font modes. + */ + (*start)++; + (*sz)--; + } else { + if ('B' == (*start)[0] && 'I' == (*start)[1]) + gly = ESCAPE_FONTBI; + break; + } } else if (1 != *sz) break; @@ -432,17 +438,35 @@ mandoc_getarg(struct mparse *parse, char **cpp, int ln pairs = 0; white = 0; for (cp = start; '\0' != *cp; cp++) { - /* Move left after quoted quotes and escaped backslashes. */ + + /* + * Move the following text left + * after quoted quotes and after "\\" and "\t". + */ if (pairs) cp[-pairs] = cp[0]; + if ('\\' == cp[0]) { - if ('\\' == cp[1]) { - /* Poor man's copy mode. */ + /* + * In copy mode, translate double to single + * backslashes and backslash-t to literal tabs. + */ + switch (cp[1]) { + case ('t'): + cp[0] = '\t'; + /* FALLTHROUGH */ + case ('\\'): pairs++; cp++; - } else if (0 == quoted && ' ' == cp[1]) + break; + case (' '): /* Skip escaped blanks. */ - cp++; + if (0 == quoted) + cp++; + break; + default: + break; + } } else if (0 == quoted) { if (' ' == cp[0]) { /* Unescaped blanks end unquoted args. */