From 737e3687d86b5d17e19ceb04ab947a35e1d6579c Mon Sep 17 00:00:00 2001 From: Arthur David Olson Date: Mon, 8 Sep 1986 16:14:04 -0400 Subject: [PATCH] deterministic abbreviation lookup SCCS-file: zic.c SCCS-SID: 2.9 --- zic.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/zic.c b/zic.c index 8de6879..71ac9a5 100644 --- a/zic.c +++ b/zic.c @@ -1120,15 +1120,21 @@ register struct lookup * table; if (word == NULL || table == NULL) return NULL; + /* + ** First check for exact match. + */ + for (lp = table; lp->l_word != NULL; ++lp) + if (ciequal(word, lp->l_word)) + return lp; + /* + ** Now check for unique inexact match. + */ foundlp = NULL; for (lp = table; lp->l_word != NULL; ++lp) - if (ciequal(word, lp->l_word)) /* "exact" match */ - return lp; - else if (!isabbr(word, lp->l_word)) - continue; - else if (foundlp == NULL) - foundlp = lp; - else return NULL; /* two inexact matches */ + if (isabbr(word, lp->l_word)) + if (foundlp == NULL) + foundlp = lp; + else return NULL; /* two inexact matches */ return foundlp; }