From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 14:16:45 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 EB2B21065674; Fri, 12 Aug 2011 14:16:45 +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 D002C8FC13; Fri, 12 Aug 2011 14:16:45 +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 p7CEGjT6067104; Fri, 12 Aug 2011 14:16:45 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7CEGjZm067102; Fri, 12 Aug 2011 14:16:45 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108121416.p7CEGjZm067102@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 12 Aug 2011 14:16:45 +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: r224796 - 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: Fri, 12 Aug 2011 14:16:46 -0000 Author: gabor Date: Fri Aug 12 14:16:45 2011 New Revision: 224796 URL: http://svn.freebsd.org/changeset/base/224796 Log: - TRE-specific style changes 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 Fri Aug 12 14:07:18 2011 (r224795) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Aug 12 14:16:45 2011 (r224796) @@ -63,16 +63,14 @@ static int fastcmp(const void *, const v * SB strings. */ #define SKIP_CHARS(n) \ - do { \ - switch (type) \ - { \ - case STR_WIDE: \ - startptr = str_wide + n; \ - break; \ - default: \ - startptr = str_byte + n; \ - } \ - } while (0); \ + switch (type) \ + { \ + case STR_WIDE: \ + startptr = str_wide + n; \ + break; \ + default: \ + startptr = str_byte + n; \ + } /* * Converts the wide string pattern to SB/MB string and stores @@ -80,7 +78,7 @@ static int fastcmp(const void *, const v * converted string. */ #define STORE_MBS_PAT \ - do { \ + { \ size_t siz; \ \ siz = wcstombs(NULL, fg->wpattern, 0); \ @@ -92,7 +90,7 @@ static int fastcmp(const void *, const v return REG_ESPACE; \ wcstombs(fg->pattern, fg->wpattern, siz); \ fg->pattern[siz] = '\0'; \ - } while (0); \ + } \ /* * Compares the pattern to the input string at the position @@ -225,16 +223,16 @@ static int fastcmp(const void *, const v fg->qsBc_table = hashtable_init(fg->wlen * 4, sizeof(tre_char_t), \ sizeof(int)); \ for (unsigned int i = fg->hasdot + 1; i < fg->wlen; i++) \ - { \ - int k = fg->wlen - i; \ - hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ - if (fg->icase) \ - { \ - tre_char_t wc = iswlower(fg->wpattern[i]) ? \ - towupper(fg->wpattern[i]) : towlower(fg->wpattern[i]); \ - hashtable_put(fg->qsBc_table, &wc, &k); \ - } \ - } \ + { \ + int k = fg->wlen - i; \ + hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ + if (fg->icase) \ + { \ + tre_char_t wc = iswlower(fg->wpattern[i]) ? \ + towupper(fg->wpattern[i]) : towlower(fg->wpattern[i]); \ + hashtable_put(fg->qsBc_table, &wc, &k); \ + } \ + } /* * Fills in the good suffix table for SB/MB strings. @@ -386,41 +384,42 @@ tre_fastcomp(fastmatch_t *fg, const tre_ /* Remove end-of-line character ('$'). */ if ((n > 0) && (pat[n - 1] == TRE_CHAR('$'))) - { - fg->eol = true; - n--; - } + { + fg->eol = true; + n--; + } /* Remove beginning-of-line character ('^'). */ if (pat[0] == TRE_CHAR('^')) - { - fg->bol = true; - n--; - pat++; - } + { + fg->bol = true; + n--; + pat++; + } /* Handle word-boundary matching when GNU extensions are enabled */ if ((cflags & REG_GNU) && (n >= 14) && (memcmp(pat, TRE_CHAR("[[:<:]]"), 7 * sizeof(tre_char_t)) == 0) && (memcmp(pat + n - 7, TRE_CHAR("[[:>:]]"), 7 * sizeof(tre_char_t)) == 0)) - { - n -= 14; - pat += 7; - fg->word = true; - } + { + n -= 14; + pat += 7; + fg->word = true; + } /* Look for ways to cheat...er...avoid the full regex engine. */ - for (unsigned int i = 0; i < n; i++) { - /* Can still cheat? */ - if ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) || - (pat[i] == TRE_CHAR('_')) || (pat[i] == TRE_CHAR(',')) || - (pat[i] == TRE_CHAR('=')) || (pat[i] == TRE_CHAR('-')) || - (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/'))) + for (unsigned int i = 0; i < n; i++) + { + /* Can still cheat? */ + if ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) || + (pat[i] == TRE_CHAR('_')) || (pat[i] == TRE_CHAR(',')) || + (pat[i] == TRE_CHAR('=')) || (pat[i] == TRE_CHAR('-')) || + (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/'))) continue; - else if (pat[i] == TRE_CHAR('.')) - fg->hasdot = i; - else + else if (pat[i] == TRE_CHAR('.')) + fg->hasdot = i; + else return REG_BADPAT; } @@ -574,6 +573,5 @@ fastcmp(const void *pat, const void *dat ret = -(i + 1); break; } - return ret; }