source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Have the `ds' processor strip out `\\' as stipulated in groff.7.
@ 2010-08-24 12:48 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-08-24 12:48 UTC (permalink / raw)
  To: source

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-24 12:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-24 12:48 mdocml: Have the `ds' processor strip out `\\' as stipulated in groff.7 kristaps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).