source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: simplify the code copying the macro name, and sync the
@ 2010-08-08 14:51 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2010-08-08 14:51 UTC (permalink / raw)
  To: source

Log Message:
-----------
simplify the code copying the macro name, and sync the
accompagnying comment between man_pmacro() and mdoc_pmacro();
ok'd by kristaps@ together with main.c rev. 1.102

Modified Files:
--------------
    mdocml:
        man.c
        mdoc.c

Revision Data
-------------
Index: man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -Lman.c -Lman.c -u -p -r1.85 -r1.86
--- man.c
+++ man.c
@@ -480,14 +480,14 @@ man_pmacro(struct man *m, int ln, char *
 
 	ppos = i;
 
-	/* Copy the first word into a nil-terminated buffer. */
-
-	for (j = 0; j < 4; j++, i++)
-		if ('\0' == (mac[j] = buf[i]))
-			break;
-		else if (' ' == buf[i])
-			break;
+	/*
+	 * Copy the first word into a nil-terminated buffer.
+	 * Stop copying when a tab, space, or eoln is encountered.
+	 */
 
+	j = 0;
+	while (j < 4 && '\0' != buf[i] && ' ' != buf[i] && '\t' != buf[i])
+		mac[j++] = buf[i++];
 	mac[j] = '\0';
 
 	if (j == 4 || j < 1) {
Index: mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v
retrieving revision 1.161
retrieving revision 1.162
diff -Lmdoc.c -Lmdoc.c -u -p -r1.161 -r1.162
--- mdoc.c
+++ mdoc.c
@@ -776,16 +776,13 @@ mdoc_pmacro(struct mdoc *m, int ln, char
 	sv = i;
 
 	/* 
-	 * Copy the first word into a nil-terminated buffer.  Stop
-	 * copying when a tab, space, or eoln is encountered.
+	 * Copy the first word into a nil-terminated buffer.
+	 * Stop copying when a tab, space, or eoln is encountered.
 	 */
 
-	for (j = 0; j < 4; j++, i++)
-		if ('\0' == (mac[j] = buf[i]))
-			break;
-		else if (' ' == buf[i] || '\t' == buf[i])
-			break;
-
+	j = 0;
+	while (j < 4 && '\0' != buf[i] && ' ' != buf[i] && '\t' != buf[i])
+		mac[j++] = buf[i++];
 	mac[j] = '\0';
 
 	if (j == 4 || j < 2) {
--
 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-08 14:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-08 14:51 mdocml: simplify the code copying the macro name, and sync the 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).