From owner-svn-src-user@FreeBSD.ORG Sun Sep 11 20:11:00 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 C2543106564A; Sun, 11 Sep 2011 20:11:00 +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 A878D8FC12; Sun, 11 Sep 2011 20:11:00 +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 p8BKB013093854; Sun, 11 Sep 2011 20:11:00 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8BKB0E7093851; Sun, 11 Sep 2011 20:11:00 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109112011.p8BKB0E7093851@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 11 Sep 2011 20:11:00 +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: r225488 - in user/gabor/grep/trunk: . regex 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: Sun, 11 Sep 2011 20:11:00 -0000 Author: gabor Date: Sun Sep 11 20:11:00 2011 New Revision: 225488 URL: http://svn.freebsd.org/changeset/base/225488 Log: - Recover to WARNS=6 Modified: user/gabor/grep/trunk/Makefile user/gabor/grep/trunk/regex/tre-fastmatch.c Modified: user/gabor/grep/trunk/Makefile ============================================================================== --- user/gabor/grep/trunk/Makefile Sun Sep 11 19:55:49 2011 (r225487) +++ user/gabor/grep/trunk/Makefile Sun Sep 11 20:11:00 2011 (r225488) @@ -15,8 +15,6 @@ bsdgrep.1: grep.1 .endif SRCS= file.c grep.c queue.c util.c -WARNS=3 - # Extra files ported backported form some regex improvements .PATH: ${.CURDIR}/regex SRCS+= fastmatch.c hashtable.c tre-fastmatch.c xmalloc.c Modified: user/gabor/grep/trunk/regex/tre-fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/tre-fastmatch.c Sun Sep 11 19:55:49 2011 (r225487) +++ user/gabor/grep/trunk/regex/tre-fastmatch.c Sun Sep 11 20:11:00 2011 (r225488) @@ -149,7 +149,8 @@ static int fastcmp(const void *, const b bc = (r == HASH_OK) ? bc : fg->defBc; \ DPRINT(("tre_fast_match: mismatch on character %lc, " \ "BC %d, GS %d\n", \ - ((tre_char_t *)startptr)[mismatch + 1], bc, gs)); \ + ((const tre_char_t *)startptr)[mismatch + 1], \ + bc, gs)); \ break; \ default: \ if (!fg->hasdot) \ @@ -159,10 +160,11 @@ static int fastcmp(const void *, const b v = fg->len - 1 - mismatch; \ gs = fg->sbmGs[mismatch]; \ } \ - bc = fg->qsBc[((unsigned char *)str_byte)[j + fg->len]]; \ + bc = fg->qsBc[((const unsigned char *)str_byte)[j + fg->len]];\ DPRINT(("tre_fast_match: mismatch on character %c, " \ "BC %d, GS %d\n", \ - ((unsigned char *)startptr)[mismatch + 1], bc, gs)); \ + ((const unsigned char *)startptr)[mismatch + 1], \ + bc, gs)); \ } \ if (fg->hasdot) \ shift = bc; \ @@ -343,7 +345,7 @@ static int fastcmp(const void *, const b #define _CALC_BMGS(arr, pat, plen) \ { \ - int f, g; \ + int f = 0, g; \ \ int *suff = xmalloc(plen * sizeof(int)); \ if (suff == NULL) \ @@ -386,16 +388,12 @@ static int fastcmp(const void *, const b */ #define SAVE_PATTERN(src, srclen, dst, dstlen) \ dstlen = srclen; \ - if (dstlen == 0) \ - dst = TRE_CHAR(""); \ - else \ - { \ - dst = xmalloc((dstlen + 1) * sizeof(tre_char_t)); \ - if (dst == NULL) \ - return REG_ESPACE; \ - memcpy(dst, src, dstlen * sizeof(tre_char_t)); \ - dst[dstlen] = TRE_CHAR('\0'); \ - } + dst = xmalloc((dstlen + 1) * sizeof(tre_char_t)); \ + if (dst == NULL) \ + return REG_ESPACE; \ + if (dstlen > 0) \ + memcpy(dst, src, dstlen * sizeof(tre_char_t)); \ + dst[dstlen] = TRE_CHAR('\0'); /* * Initializes pattern compiling. @@ -411,8 +409,17 @@ static int fastcmp(const void *, const b if (n == 0) \ { \ fg->matchall = true; \ - fg->pattern = ""; \ - fg->wpattern = TRE_CHAR(""); \ + fg->pattern = xmalloc(1); \ + if (!fg->pattern) \ + return REG_ESPACE; \ + fg->pattern[0] = '\0'; \ + fg->wpattern = xmalloc(sizeof(tre_char_t)); \ + if (!fg->wpattern) \ + { \ + xfree(fg->pattern); \ + return REG_ESPACE; \ + } \ + fg->wpattern[0] = TRE_CHAR('\0'); \ DPRINT(("Matching every input\n")); \ return REG_OK; \ } \ @@ -614,7 +621,7 @@ badpat: STORE_MBS_PAT; if (fg->wescmap != NULL) { - bool escaped = false; + escaped = false; fg->escmap = xmalloc(fg->len * sizeof(bool)); if (!fg->escmap) @@ -724,9 +731,9 @@ badpat: */ int tre_match_fast(const fastmatch_t *fg, const void *data, size_t len, - tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags) + tre_str_type_t type, int nmatch __unused, regmatch_t pmatch[], int eflags) { - unsigned int j = 0, shift, u = 0, v; + unsigned int j = 0, shift, u = 0, v = 0; int ret = REG_NOMATCH; int mismatch; const char *str_byte = data;