From 0ce539688658d136200d6e00abbb9db7b7a7c363 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 8 Aug 2010 14:51:32 +0000 Subject: 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 --- mdoc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'mdoc.c') diff --git a/mdoc.c b/mdoc.c index afe80b48..d55b1120 100644 --- a/mdoc.c +++ b/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.161 2010/08/07 20:57:33 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.162 2010/08/08 14:51:32 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -776,16 +776,13 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) 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) { -- cgit v1.2.3-56-ge451