From owner-svn-src-user@FreeBSD.ORG Thu Jul 28 13:41:51 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4C03D106564A; Thu, 28 Jul 2011 13:41:51 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 23EC38FC0A; Thu, 28 Jul 2011 13:41:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6SDfpeN005821; Thu, 28 Jul 2011 13:41:51 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6SDfp3m005819; Thu, 28 Jul 2011 13:41:51 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107281341.p6SDfp3m005819@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 28 Jul 2011 13:41:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224479 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2011 13:41:51 -0000 Author: gabor Date: Thu Jul 28 13:41:50 2011 New Revision: 224479 URL: http://svn.freebsd.org/changeset/base/224479 Log: - Eliminate more code duplication with macros Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Jul 28 13:27:14 2011 (r224478) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Jul 28 13:41:50 2011 (r224479) @@ -161,6 +161,21 @@ static void revs(char *str, int len); * thi. 1 */ +#define FILL_ARRAY(pat, plen) \ + for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ + fg->qsBc[i] = plen - hasDot; \ + for (int i = hasDot + 1; i < plen; i++) \ + { \ + fg->qsBc[(unsigned)pat[i]] = plen - i; \ + if (fg->icase) \ + { \ + char c = islower(pat[i]) ? toupper(pat[i]) \ + : tolower(pat[i]); \ + fg->qsBc[(unsigned)c] = plen - i; \ + } \ + } + + #ifdef TRE_WCHAR #define FILL_QSBC \ /* Adjust the shift based on location of the last dot ('.'). */ \ @@ -181,32 +196,9 @@ static void revs(char *str, int len); } \ } \ \ - for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ - fg->qsBc[i] = fg->len - hasDot; \ - for (int i = hasDot + 1; i < fg->len; i++) \ - { \ - fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; \ - if (fg->icase) \ - { \ - char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ - : tolower(fg->pattern[i]); \ - fg->qsBc[(unsigned)c] = fg->len - i; \ - } \ - } + FILL_ARRAY(fg->pattern, fg->len); #else -#define FILL_QSBC \ - for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ - fg->qsBc[i] = fg->wlen - hasDot; \ - for (int i = hasDot + 1; i < fg->wlen; i++) \ - { \ - fg->qsBc[(unsigned)fg->wpattern[i]] = fg->wlen - i; \ - if (fg->icase) \ - { \ - char c = islower(fg->wpattern[i]) ? toupper(fg->wpattern[i]) \ - : tolower(fg->wpattern[i]); \ - fg->qsBc[(unsigned)c] = fg->len - i; \ - } \ - } +#define FILL_QSBC FILL_ARRAY(fg->wpattern, fg->wlen); #endif #define REVFUNC(name, argtype) \