Return-Path: X-Original-To: apmail-subversion-dev-archive@minotaur.apache.org Delivered-To: apmail-subversion-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DA38319B3A for ; Tue, 15 Mar 2016 00:08:39 +0000 (UTC) Received: (qmail 84460 invoked by uid 500); 15 Mar 2016 00:08:39 -0000 Delivered-To: apmail-subversion-dev-archive@subversion.apache.org Received: (qmail 84234 invoked by uid 500); 15 Mar 2016 00:08:39 -0000 Mailing-List: contact dev-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@subversion.apache.org Received: (qmail 84209 invoked by uid 99); 15 Mar 2016 00:08:39 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Mar 2016 00:08:39 +0000 Received: by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org, from userid 3316) id 10D911A0040; Tue, 15 Mar 2016 00:08:39 +0000 (UTC) Date: Tue, 15 Mar 2016 00:08:38 +0000 From: Daniel Shahaf To: dev@subversion.apache.org Cc: commits@subversion.apache.org, kotkov@apache.org Subject: 'svn log --search': forcing case sensitivity? (was: svn commit: r1731300 - in /subversion/trunk/subversion: include/private/svn_utf_private.h libsvn_repos/dump.c libsvn_subr/utf8proc.c svn/cl-log.h svn/log-cmd.c svn/svn.c tests/cmdline/log_tests.py tests/libsvn_subr/utf-test.c) Message-ID: <20160315000838.GA15477@tarsus.local2> References: <20160219221112.017573A0185@svn01-us-west.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20160219221112.017573A0185@svn01-us-west.apache.org> User-Agent: Mutt/1.5.23 (2014-03-12) kotkov@apache.org wrote on Fri, Feb 19, 2016 at 22:11:11 -0000: > Author: kotkov > Date: Fri Feb 19 22:11:11 2016 > New Revision: 1731300 > > URL: http://svn.apache.org/viewvc?rev=1731300&view=rev > Log: > Make svn log --search case-insensitive. > > Use utf8proc to do the normalization and locale-independent case folding > (UTF8PROC_CASEFOLD) for both the search pattern and the input strings. > > Related discussion is in http://svn.haxx.se/dev/archive-2013-04/0374.shtml > (Subject: "log --search test failures on trunk and 1.8.x"). > > +++ subversion/trunk/subversion/svn/log-cmd.c Fri Feb 19 22:11:11 2016 > @@ -38,6 +38,7 @@ > @@ -110,6 +111,24 @@ > +/* Return TRUE if STR matches PATTERN. Else, return FALSE. Assumes that > + * PATTERN is a UTF-8 string normalized to form C with case folding > + * applied. Use BUF for temporary allocations. */ > +static svn_boolean_t > +match(const char *pattern, const char *str, svn_membuf_t *buf) > +{ > + svn_error_t *err; > + > + err = svn_utf__normalize(&str, str, strlen(str), TRUE /* casefold */, buf); > + if (err) > + { > + /* Can't match invalid data. */ > + svn_error_clear(err); > + return FALSE; > + } > + > + return apr_fnmatch(pattern, str, 0) == APR_SUCCESS; Should there be a command-line flag to disable casefolding? E.g., to allow users to grep for identifiers (function/variable/file names) using their exact case? Do people who use 'log --search' need it to be case-sensitive? (I don't use 'log --search' often.) Even if casefolding is disabled, we should still apply Unicode normalization to form C. Cheers, Daniel P.S. This patch introduces a minor behaviour change: before this patch, the search pattern «foo[A-z]bar» would match the log message «foo_bar», whereas after this change it would not. (This is because the pattern is now casefolded between being passed to APR, and '_' is between 'A' and 'z' but not between 'A' and 'Z', when compared as C chars.) I doubt anyone will notice this behaviour change; I'm just mentioning it for completeness. > +}