From owner-svn-src-user@FreeBSD.ORG Sun Dec 18 02:10:26 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 3B293106566B; Sun, 18 Dec 2011 02:10:26 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 10A8B8FC08; Sun, 18 Dec 2011 02:10:26 +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 pBI2APl7087264; Sun, 18 Dec 2011 02:10:25 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBI2APGH087263; Sun, 18 Dec 2011 02:10:25 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201112180210.pBI2APGH087263@svn.freebsd.org> From: Sean Bruno Date: Sun, 18 Dec 2011 02:10:25 +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: r228684 - user/sbruno/1394dev/mod_build 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, 18 Dec 2011 02:10:26 -0000 Author: sbruno Date: Sun Dec 18 02:10:25 2011 New Revision: 228684 URL: http://svn.freebsd.org/changeset/base/228684 Log: Via some prodding, branch the module build dir into there as well Suggested by: kan@ Added: - copied from r228683, head/sys/modules/firewire/ Directory Properties: user/sbruno/1394dev/mod_build/ (props changed) From owner-svn-src-user@FreeBSD.ORG Thu Dec 22 16:19: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 AA6EE106564A; Thu, 22 Dec 2011 16:19: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 99DA38FC08; Thu, 22 Dec 2011 16:19: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 pBMGJp3B024534; Thu, 22 Dec 2011 16:19:51 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBMGJp70024529; Thu, 22 Dec 2011 16:19:51 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201112221619.pBMGJp70024529@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 22 Dec 2011 16:19: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: r228806 - user/gabor/grep/trunk 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, 22 Dec 2011 16:19:51 -0000 Author: gabor Date: Thu Dec 22 16:19:51 2011 New Revision: 228806 URL: http://svn.freebsd.org/changeset/base/228806 Log: - Merge some recent changes from HEAD Modified: user/gabor/grep/trunk/Makefile user/gabor/grep/trunk/grep.c user/gabor/grep/trunk/grep.h user/gabor/grep/trunk/util.c Modified: user/gabor/grep/trunk/Makefile ============================================================================== --- user/gabor/grep/trunk/Makefile Thu Dec 22 16:16:12 2011 (r228805) +++ user/gabor/grep/trunk/Makefile Thu Dec 22 16:19:51 2011 (r228806) @@ -25,13 +25,7 @@ LINKS= ${BINDIR}/grep ${BINDIR}/egrep \ ${BINDIR}/grep ${BINDIR}/fgrep \ ${BINDIR}/grep ${BINDIR}/zgrep \ ${BINDIR}/grep ${BINDIR}/zegrep \ - ${BINDIR}/grep ${BINDIR}/zfgrep \ - ${BINDIR}/grep ${BINDIR}/xzgrep \ - ${BINDIR}/grep ${BINDIR}/xzegrep \ - ${BINDIR}/grep ${BINDIR}/xzfgrep \ - ${BINDIR}/grep ${BINDIR}/lzgrep \ - ${BINDIR}/grep ${BINDIR}/lzegrep \ - ${BINDIR}/grep ${BINDIR}/lzfgrep + ${BINDIR}/grep ${BINDIR}/zfgrep MLINKS= grep.1 egrep.1 \ grep.1 fgrep.1 \ @@ -46,6 +40,13 @@ MLINKS= grep.1 egrep.1 \ grep.1 lzfgrep.1 .endif +LINKS+= ${BINDIR}/${PROG} ${BINDIR}/xzgrep \ + ${BINDIR}/${PROG} ${BINDIR}/xzegrep \ + ${BINDIR}/${PROG} ${BINDIR}/xzfgrep \ + ${BINDIR}/${PROG} ${BINDIR}/lzgrep \ + ${BINDIR}/${PROG} ${BINDIR}/lzegrep \ + ${BINDIR}/${PROG} ${BINDIR}/lzfgrep + LDADD= -lz -llzma DPADD= ${LIBZ} ${LIBLZMA} @@ -53,12 +54,14 @@ DPADD= ${LIBZ} ${LIBLZMA} LDADD+= -lbz2 DPADD+= ${LIBBZ2} +.if ${MK_BSD_GREP} == "yes" LINKS+= ${BINDIR}/grep ${BINDIR}/bzgrep \ ${BINDIR}/grep ${BINDIR}/bzegrep \ ${BINDIR}/grep ${BINDIR}/bzfgrep MLINKS+= grep.1 bzgrep.1 \ grep.1 bzegrep.1 \ grep.1 bzfgrep.1 +.endif .else CFLAGS+= -DWITHOUT_BZIP2 .endif Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Thu Dec 22 16:16:12 2011 (r228805) +++ user/gabor/grep/trunk/grep.c Thu Dec 22 16:19:51 2011 (r228806) @@ -148,7 +148,7 @@ static inline const char *init_color(con bool first = true; /* flag whether we are processing the first match */ bool prev; /* flag whether or not the previous line matched */ int tail; /* lines left to print */ -bool notfound; /* file not found */ +bool file_err; /* file reading error */ /* * Prints usage information and returns 2. @@ -728,5 +728,5 @@ main(int argc, char *argv[]) /* Find out the correct return value according to the results and the command line option. */ - exit(c ? (notfound ? (qflag ? 0 : 2) : 0) : (notfound ? 2 : 1)); + exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1)); } Modified: user/gabor/grep/trunk/grep.h ============================================================================== --- user/gabor/grep/trunk/grep.h Thu Dec 22 16:16:12 2011 (r228805) +++ user/gabor/grep/trunk/grep.h Thu Dec 22 16:19:51 2011 (r228806) @@ -119,7 +119,7 @@ extern char *label; extern const char *color; extern int binbehave, devbehave, dirbehave, filebehave, grepbehave, linkbehave; -extern bool first, matchall, notfound, prev; +extern bool file_err, first, matchall, prev; extern int tail; extern unsigned int dpatterns, fpatterns, patterns; extern struct pat *pattern; Modified: user/gabor/grep/trunk/util.c ============================================================================== --- user/gabor/grep/trunk/util.c Thu Dec 22 16:16:12 2011 (r228805) +++ user/gabor/grep/trunk/util.c Thu Dec 22 16:19:51 2011 (r228806) @@ -130,7 +130,9 @@ grep_tree(char **argv) case FTS_DNR: /* FALLTHROUGH */ case FTS_ERR: - errx(2, "%s: %s", p->fts_path, strerror(p->fts_errno)); + file_err = true; + if(!sflag) + warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); break; case FTS_D: /* FALLTHROUGH */ @@ -193,10 +195,9 @@ procfile(const char *fn) f = grep_open(fn); } if (f == NULL) { + file_err = true; if (!sflag) warn("%s", fn); - if (errno == ENOENT) - notfound = true; return (0); } @@ -246,9 +247,9 @@ procfile(const char *fn) printf("%u\n", c); } if (lflag && !qflag && c != 0) - printf("%s\n", fn); + printf("%s%c", fn, nullflag ? 0 : '\n'); if (Lflag && !qflag && c == 0) - printf("%s\n", fn); + printf("%s%c", fn, nullflag ? 0 : '\n'); if (c && !cflag && !lflag && !Lflag && binbehave == BINFILE_BIN && f->binary && !qflag) printf(getstr(8), fn); @@ -440,13 +441,13 @@ printline(struct str *line, int sep, reg int i, n = 0; if (!hflag) { - if (nullflag == 0) + if (!nullflag) { fputs(line->file, stdout); - else { + ++n; + } else { printf("%s", line->file); putchar(0); } - ++n; } if (nflag) { if (n > 0) From owner-svn-src-user@FreeBSD.ORG Fri Dec 23 12:05:52 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 69D05106566C; Fri, 23 Dec 2011 12:05:52 +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 49FB28FC13; Fri, 23 Dec 2011 12:05:52 +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 pBNC5qxt064853; Fri, 23 Dec 2011 12:05:52 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBNC5qmv064849; Fri, 23 Dec 2011 12:05:52 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201112231205.pBNC5qmv064849@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 23 Dec 2011 12:05:52 +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: r228839 - 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, 23 Dec 2011 12:05:52 -0000 Author: gabor Date: Fri Dec 23 12:05:51 2011 New Revision: 228839 URL: http://svn.freebsd.org/changeset/base/228839 Log: - Some trivial fixes - Add more comments Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Fri Dec 23 09:09:42 2011 (r228838) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Fri Dec 23 12:05:51 2011 (r228839) @@ -250,9 +250,9 @@ tre_match(const tre_tnfa_t *tnfa, const n = pmatch[0].rm_eo; /* Intermediate heuristics */ - while (!((heur->heurs[i] == NULL) || - ((heur->type == HEUR_PREFIX_ARRAY) && - heur->heurs[i + 1] == NULL))) + while (!(heur->heurs[i] == NULL) && + ((heur->heurs[i + 1] != NULL) || + ((heur->heurs[i + 1] == NULL) && (heur->type == HEUR_PREFIX_ARRAY)))) { SEEK_TO(st + n); ret = tre_match_fast(heur->heurs[i], string, len - st - n, @@ -283,7 +283,7 @@ tre_match(const tre_tnfa_t *tnfa, const { size_t l = (heur->tlen == -1) ? len - st : heur->tlen; - if (l < len - st) + if (l > len - st) return REG_NOMATCH; SEEK_TO(st); ret = tre_match(tnfa, string, l, type, nmatch, Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Fri Dec 23 09:09:42 2011 (r228838) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Fri Dec 23 12:05:51 2011 (r228839) @@ -542,10 +542,8 @@ tre_compile_fast(fastmatch_t *fg, const case TRE_CHAR('{'): if (!(cflags & REG_EXTENDED) ^ escaped) STORE_CHAR; - else if (!(cflags & REG_EXTENDED) && (i == 0)) + else if (i == 0) STORE_CHAR; - else if ((cflags & REG_EXTENDED) && (i == 0)) - continue; else goto badpat; continue; Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Fri Dec 23 09:09:42 2011 (r228838) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Fri Dec 23 12:05:51 2011 (r228839) @@ -179,10 +179,8 @@ tre_compile_heur(heur_t *h, const tre_ch case TRE_CHAR('{'): if (escaped && (i == 1)) STORE_CHAR; - else if ((i == 0) && !(cflags & REG_EXTENDED)) + else if (i == 0) STORE_CHAR; - else if ((i == 0) && (cflags & REG_EXTENDED)) - continue; PARSE_UNIT('{', '}'); if (escaped ^ (cflags & REG_EXTENDED)) @@ -332,12 +330,14 @@ end_segment: else if (pos == 0) continue; + /* Too many fragments - should never happen but to be safe */ if (j == MAX_FRAGMENTS) { errcode = REG_BADPAT; goto err; } + /* Alloc space for fragment and copy it */ arr[j] = xmalloc((pos + 1) * sizeof(tre_char_t)); if (!arr[j]) { @@ -358,9 +358,16 @@ ok: h->tlen = tlen; + /* Look up maximum length fragment */ for (int i = 1; i < j; i++) m = (length[i] > length[m]) ? i : m; + /* + * If possible, store prefix, maximum internal fragment and suffix. + * If not possible, store prefix and either maximum internal fragment + * or suffix if it is the same. In the worst case, only prefix is + * stored. The closing element is always NULL. + */ for (int i = 0; i < MIN(3, j + 1); i++) { h->heurs[i] = xmalloc(sizeof(fastmatch_t)); @@ -380,12 +387,19 @@ ok: if (cflags & REG_NEWLINE) { + /* For REG_NEWLINE, only store longest fragment. */ ret = tre_compile_literal(h->heurs[0], arr[m], length[m], 0); CHECK_ERR h->type = HEUR_LONGEST; } else { + /* + * If possible, store prefix, maximum internal fragment and suffix. + * If not possible, store prefix and either maximum internal fragment + * or suffix if it is the same. In the worst case, only prefix is + * stored. The closing element is always NULL. + */ ret = tre_compile_literal(h->heurs[0], arr[0], length[0], 0); CHECK_ERR if (j == 1) From owner-svn-src-user@FreeBSD.ORG Fri Dec 23 13:20:52 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 5F8ED106564A; Fri, 23 Dec 2011 13:20:52 +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 2FBCA8FC15; Fri, 23 Dec 2011 13:20:52 +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 pBNDKqiO067192; Fri, 23 Dec 2011 13:20:52 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBNDKpWH067190; Fri, 23 Dec 2011 13:20:51 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201112231320.pBNDKpWH067190@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 23 Dec 2011 13:20: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: r228840 - user/gabor/tre-integration/lib/libc/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: Fri, 23 Dec 2011 13:20:52 -0000 Author: gabor Date: Fri Dec 23 13:20:51 2011 New Revision: 228840 URL: http://svn.freebsd.org/changeset/base/228840 Log: - Minor improvements and rewording Modified: user/gabor/tre-integration/lib/libc/regex/regex.3 Modified: user/gabor/tre-integration/lib/libc/regex/regex.3 ============================================================================== --- user/gabor/tre-integration/lib/libc/regex/regex.3 Fri Dec 23 12:05:51 2011 (r228839) +++ user/gabor/tre-integration/lib/libc/regex/regex.3 Fri Dec 23 13:20:51 2011 (r228840) @@ -33,7 +33,7 @@ .\" @(#)regex.3 8.4 (Berkeley) 3/20/94 .\" $FreeBSD$ .\" -.Dd September 24, 2011 +.Dd December 23, 2011 .Dt REGEX 3 .Os .Sh NAME @@ -109,8 +109,8 @@ function compiles a regular expression from a string into an internal form. The .Fn regncomp -function works in the very same way, -but takes another argument to specify the length of the pattern. +function works like the former but takes another argument to +specify the length of the pattern. This function can accept patterns containing NUL bytes. The .Fn regwcomp @@ -125,7 +125,7 @@ function matches the compiled regular ex and reports results. The .Fn regnexec -function works in the same way but takes another argument to specify +function works like the former but takes another argument to specify the length of the pattern, allowing NUL bytes in the input string. Additionally, @@ -207,12 +207,12 @@ Synonym for .It Dv REG_ICASE Compile for case insensitive matching. .It Dv REG_NOSUB -Compile for only reporting match or mismatch´with no regard to +Compile for only reporting match or mismatch with no regard to the matching offset. .It Dv REG_NEWLINE Compile for newline-sensitive matching. By default, newline is a completely ordinary character with no special -meaning in either regular expressins or strings. +meaning in either regular expressions or strings. With this flag, .Ql [^ bracket expressions and @@ -331,11 +331,11 @@ The string is considered to start at .Fa string + .Fa pmatch Ns [0]. Ns Va rm_so -and to have a terminating NUL character located at +(inclusive) and to end at .Fa string + .Fa pmatch Ns [0]. Ns Va rm_eo -(there need not actually be a NUL character at that location), +(exclusive), regardless of the value of .Fa nmatch . See below for the definition of @@ -350,6 +350,7 @@ does not imply affects only the location of the string, not how it is matched. .El +.Pp The function indicates a match by returning .Dv REG_OK , no match with @@ -359,7 +360,6 @@ if an error has occured during the execu See .Sx RETURN VALUES for a detailed description of error codes. -.El .Pp If .Dv REG_NOSUB @@ -489,7 +489,8 @@ using that .Fn regerror function may be able to supply a more detailed message using information from the -.Ft regex_t .) +.Ft regex_t . +) The .Fn regerror function From owner-svn-src-user@FreeBSD.ORG Fri Dec 23 14:39:31 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 92004106566C; Fri, 23 Dec 2011 14:39:31 +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 80B7E8FC08; Fri, 23 Dec 2011 14:39:31 +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 pBNEdVCc071005; Fri, 23 Dec 2011 14:39:31 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBNEdVI7071003; Fri, 23 Dec 2011 14:39:31 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201112231439.pBNEdVI7071003@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 23 Dec 2011 14:39:31 +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: r228842 - user/gabor/tre-integration/lib/libc/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: Fri, 23 Dec 2011 14:39:31 -0000 Author: gabor Date: Fri Dec 23 14:39:30 2011 New Revision: 228842 URL: http://svn.freebsd.org/changeset/base/228842 Log: - Minor rewording of some existing parts - Document some TRE-specific features Modified: user/gabor/tre-integration/lib/libc/regex/re_format.7 Modified: user/gabor/tre-integration/lib/libc/regex/re_format.7 ============================================================================== --- user/gabor/tre-integration/lib/libc/regex/re_format.7 Fri Dec 23 13:50:33 2011 (r228841) +++ user/gabor/tre-integration/lib/libc/regex/re_format.7 Fri Dec 23 14:39:30 2011 (r228842) @@ -37,7 +37,7 @@ .\" @(#)re_format.7 8.3 (Berkeley) 3/20/94 .\" $FreeBSD$ .\" -.Dd October 6, 2011 +.Dd December 23, 2011 .Dt RE_FORMAT 7 .Os .Sh NAME @@ -69,13 +69,13 @@ so this manual will describe the behavio instead of just reproducing the same iformation that is already available in the standard. .Pp -An extended regular expression is one or more non-empty +An extended regular expression is constructed from one or more non-empty .Em branches , separated by .Ql \&| . It matches anything that matches one of the branches. .Pp -A branch is one or more +A branch consists of one or more .Em pieces , concatenated. It matches a match for the first, followed by a match for the second, etc. @@ -284,7 +284,7 @@ The reverse, matching any character that class, the negation operator of bracket expressions may be used: .Ql [^[:class:]] . .Pp -In the event that a regular expression could match more than one +In the event that a regular expression could match more than one substring of a given string, the regular expression matches the one starting earliest in the string. If the regular expression could match more than one substring starting @@ -343,7 +343,77 @@ longer than 256 bytes, as an implementation can refuse to accept such regular expressions and remain POSIX-compliant. .Pp +As described before, +repetition operators and bounds are greedy by definition. +This implementation provides non-greedy operators and bounds that +are formed by adding an extra +.Ql \&? +after the repetition. +.No e.g. Ql a*? +will be non-greedy, +that is, +will match as few characters as possible. +.Pp +Another extension in this implementation is the set of non-standard +anchors: +.Bl -tag -width BBBB +.It Ql \e< +Beginning of a word +.It Ql \e> +End of a word +.It Ql \eb +Word boundary +.It Ql \eB +Non-word boundary +.It Ql \ed +Digit (equivalent to [[:digit:]]) +.It Ql \eD +Non-digit (equivalent to [^[:digit:]]) +.It Ql \es +Space (equivalent to [[:space:]]) +.It Ql \eS +Non-space (equivalent to [^[:space:]]) +.It Ql \ew +Word character (equivalent to [[:alnum]]) +.It Ql \eW +Non-word character (equivalent to [^[:alnum]]) +.El +.Pp +The literal characters can also be expressed with an extended notation +apart from real literals and escaped specials. +It is possible to specify 8\-bit hexadecimal encoded characters +.No e.g. \ex1B +or wide hexadecimal encoded characters +.No e.g. \ex{263a} . +With this notation, +every character can be included in a regular expression. +Some common non\-printable characters have an escaped shorthand, +as well: +.Bl -tag -width BBBB +.It Ql \ea +Bell character (ASCII code 7) +.It Ql \ee +Escape character (ASCII code 27) +.It Ql \ef +Form\-feed character (ASCII code 12) +.It Ql \en +Newline character (ASCII code 10) +.It Ql \er +Carriage return character (ASCII code 13) +.It Ql \et +Horizontal tab character (ASCII code 9) +.El +.Pp Basic regular expressions differ in several respects. +The delimiters for bounds are +.Ql \e{ +and +.Ql \e} , +with +.Ql \&{ +and +.Ql \&} +by themselves ordinary characters. .Ql \&| is an ordinary character and there is no equivalent for its functionality. @@ -352,23 +422,14 @@ and .Ql ?\& are ordinary characters, and their functionality can be expressed using bounds -.No ( Ql {1,} +.No ( Ql \e{1,\e} or -.Ql {0,1} +.Ql \e{0,1\e} respectively). Also note that .Ql x+ in extended regular expressions is equivalent to .Ql xx* . -The delimiters for bounds are -.Ql \e{ -and -.Ql \e} , -with -.Ql \&{ -and -.Ql \&} -by themselves ordinary characters. The parentheses for nested subexpressions are .Ql \e( and @@ -426,6 +487,8 @@ This manual was originally written by for an older implementation and later extended and tailored for TRE by .An Gabor Kovesdan . +The description of TRE\-specific extensions is based on the original +TRE documentation. The regex implementation comes from the TRE project and it was included first in .Fx 10-CURRENT.