From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id o7OCmi8V012321 for ; Tue, 24 Aug 2010 08:48:44 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id o7OCmibx032444; Tue, 24 Aug 2010 08:48:44 -0400 (EDT) Date: Tue, 24 Aug 2010 08:48:44 -0400 (EDT) Message-Id: <201008241248.o7OCmibx032444@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Have the `ds' processor strip out `\\' as stipulated in groff.7. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Have the `ds' processor strip out `\\' as stipulated in groff.7. I only care because pod2man uses this construct. Modified Files: -------------- mdocml: roff.c Revision Data ------------- Index: roff.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v retrieving revision 1.98 retrieving revision 1.99 diff -Lroff.c -Lroff.c -u -p -r1.98 -r1.99 --- roff.c +++ roff.c @@ -136,6 +136,7 @@ static int roff_res(struct roff *, char **, size_t *, int); static void roff_setstr(struct roff *, const char *, const char *); +static char *roff_strdup(const char *); /* See roff_hash_find() */ @@ -1035,6 +1036,27 @@ roff_nr(ROFF_ARGS) } +static char * +roff_strdup(const char *name) +{ + char *namecopy, *sv; + + /* + * This isn't a nice simple mandoc_strdup() because we must + * handle roff's stupid double-escape rule. + */ + sv = namecopy = mandoc_malloc(strlen(name) + 1); + while (*name) { + if ('\\' == *name && '\\' == *(name + 1)) + name++; + *namecopy++ = *name++; + } + + *namecopy = '\0'; + return(sv); +} + + static void roff_setstr(struct roff *r, const char *name, const char *string) { @@ -1054,8 +1076,9 @@ roff_setstr(struct roff *r, const char * } else free(n->string); - ROFF_DEBUG("roff: new symbol: [%s] = [%s]\n", name, string); - n->string = string ? strdup(string) : NULL; + /* Don't use mandoc_strdup: clean out double-escapes. */ + n->string = string ? roff_strdup(string) : NULL; + ROFF_DEBUG("roff: new symbol: [%s] = [%s]\n", name, n->string); } -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv