diff options
Diffstat (limited to 'contrib/texinfo/info/man.c')
-rw-r--r-- | contrib/texinfo/info/man.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/contrib/texinfo/info/man.c b/contrib/texinfo/info/man.c index ee68cbb..1332cc5 100644 --- a/contrib/texinfo/info/man.c +++ b/contrib/texinfo/info/man.c @@ -1,7 +1,7 @@ /* man.c: How to read and format man files. - $Id: man.c,v 1.13 1999/07/05 20:43:23 karl Exp $ + $Id: man.c,v 1.16 2002/02/23 19:12:02 karl Exp $ - Copyright (C) 1995, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1995, 97, 98, 99, 2000 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -397,11 +397,36 @@ clean_manpage (manpage) newline_count--; } - if (manpage[i] == '\b' || manpage[i] == '\f') + /* A malformed man page could have a \b as its first character, + in which case decrementing j by 2 will cause us to write into + newpage[-1], smashing the hidden info stored there by malloc. */ + if (manpage[i] == '\b' || manpage[i] == '\f' && j > 0) j -= 2; + else if (!raw_escapes_p) + { + /* Remove the ANSI escape sequences for color, boldface, + underlining, and italics, generated by some versions of + Groff. */ + if (manpage[i] == '\033' && manpage[i + 1] == '[' + && isdigit (manpage[i + 2])) + { + if (isdigit (manpage[i + 3]) && manpage[i + 4] == 'm') + { + i += 4; + j--; + } + else if (manpage[i + 3] == 'm') + { + i += 3; + j--; + } + /* Else do nothing: it's some unknown escape sequence, + so let's leave it alone. */ + } + } } - newpage[j++] = '\0'; + newpage[j++] = 0; strcpy (manpage, newpage); free (newpage); |