From 782e6e25eb7a311e35db1e16b59998bfc3033a8d Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Wed, 27 Jul 2011 13:42:27 +0000 Subject: Clean up roff_getstrn() function. --- roff.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'roff.c') diff --git a/roff.c b/roff.c index 129a90ef..68b5a423 100644 --- a/roff.c +++ b/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.156 2011/07/27 12:41:02 kristaps Exp $ */ +/* $Id: roff.c,v 1.157 2011/07/27 13:42:27 kristaps Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -1519,11 +1519,12 @@ roff_getstrn(const struct roff *r, const char *name, size_t len) { const struct roffstr *n; - n = r->first_string; - while (n && (strncmp(name, n->name, len) || '\0' != n->name[(int)len])) - n = n->next; + for (n = r->first_string; n; n = n->next) + if (0 == strncmp(name, n->name, len) && + '\0' == n->name[(int)len]) + return(n->string); - return(n ? n->string : NULL); + return(NULL); } static void -- cgit v1.2.3-56-ge451