source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Use the freshly improved roff_getname() function for the main
@ 2014-06-29 23:26 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-06-29 23:26 UTC (permalink / raw)
  To: source

Log Message:
-----------
Use the freshly improved roff_getname() function
for the main roff request parsing routine, roff_parse().

In request or macro invocations, escape sequences now terminate the
request or macro name; what follows is treated as arguments.  Besides,
the names of user-defined macros can now contain backslashes (eek!).

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.213
retrieving revision 1.214
diff -Lroff.c -Lroff.c -u -p -r1.213 -r1.214
--- roff.c
+++ roff.c
@@ -200,7 +200,8 @@ static	enum rofferr	 roff_line_ignore(RO
 static	enum rofferr	 roff_nr(ROFF_ARGS);
 static	void		 roff_openeqn(struct roff *, const char *,
 				int, int, const char *);
-static	enum rofft	 roff_parse(struct roff *, const char *, int *);
+static	enum rofft	 roff_parse(struct roff *, char *, int *,
+				int, int);
 static	enum rofferr	 roff_parsetext(char **, size_t *, int, int *);
 static	enum rofferr	 roff_res(struct roff *,
 				char **, size_t *, int, int);
@@ -764,7 +765,7 @@ roff_parseln(struct roff *r, int ln, cha
 	 * the compilers handle it.
 	 */
 
-	if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos)))
+	if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos, ln, ppos)))
 		return(ROFF_CONT);
 
 	assert(roffs[t].proc);
@@ -797,28 +798,26 @@ roff_endparse(struct roff *r)
  * form of ".foo xxx" in the usual way.
  */
 static enum rofft
-roff_parse(struct roff *r, const char *buf, int *pos)
+roff_parse(struct roff *r, char *buf, int *pos, int ln, int ppos)
 {
+	char		*cp;
 	const char	*mac;
 	size_t		 maclen;
 	enum rofft	 t;
 
-	if ('\0' == buf[*pos] || '"' == buf[*pos] ||
-	    '\t' == buf[*pos] || ' ' == buf[*pos])
-		return(ROFF_MAX);
+	cp = buf + *pos;
 
-	/* We stop the macro parse at an escape, tab, space, or nil. */
+	if ('\0' == *cp || '"' == *cp || '\t' == *cp || ' ' == *cp)
+		return(ROFF_MAX);
 
-	mac = buf + *pos;
-	maclen = strcspn(mac, " \\\t\0");
+	mac = cp;
+	maclen = roff_getname(r, &cp, ln, ppos);
 
 	t = (r->current_string = roff_getstrn(r, mac, maclen))
 	    ? ROFF_USERDEF : roffhash_find(mac, maclen);
 
-	*pos += (int)maclen;
-
-	while (buf[*pos] && ' ' == buf[*pos])
-		(*pos)++;
+	if (ROFF_MAX != t)
+		*pos = cp - buf;
 
 	return(t);
 }
@@ -996,7 +995,7 @@ roff_block_sub(ROFF_ARGS)
 				i++;
 
 			pos = i;
-			if (ROFF_MAX != roff_parse(r, *bufp, &pos))
+			if (ROFF_MAX != roff_parse(r, *bufp, &pos, ln, ppos))
 				return(ROFF_RERUN);
 			return(ROFF_IGN);
 		}
@@ -1007,7 +1006,7 @@ roff_block_sub(ROFF_ARGS)
 	 * pulling it out of the hashtable.
 	 */
 
-	t = roff_parse(r, *bufp, &pos);
+	t = roff_parse(r, *bufp, &pos, ln, ppos);
 
 	/*
 	 * Macros other than block-end are only significant
@@ -1042,7 +1041,7 @@ roff_cond_sub(ROFF_ARGS)
 
 	rr = r->last->rule;
 	roffnode_cleanscope(r);
-	t = roff_parse(r, *bufp, &pos);
+	t = roff_parse(r, *bufp, &pos, ln, ppos);
 
 	/*
 	 * Fully handle known macros when they are structurally
--
 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:[~2014-06-29 23:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-29 23:26 mdocml: Use the freshly improved roff_getname() function for the main schwarze

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).