From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Subject: [PATCH v2 9/9] diffcore-pickaxe: support case insensitive match on non-ascii Date: Wed, 8 Jul 2015 17:38:39 +0700 Message-ID: <1436351919-2520-10-git-send-email-pclouds@gmail.com> References: <1436186551-32544-1-git-send-email-pclouds@gmail.com> <1436351919-2520-1-git-send-email-pclouds@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: plamen.totev@abv.bg, l.s.r@web.de, Junio C Hamano , =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Wed Jul 08 12:39:08 2015 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZCmkn-0006zv-2D for gcvg-git-2@plane.gmane.org; Wed, 08 Jul 2015 12:39:01 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964873AbbGHKi7 convert rfc822-to-quoted-printable (ORCPT ); Wed, 8 Jul 2015 06:38:59 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:33986 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964821AbbGHKi4 (ORCPT ); Wed, 8 Jul 2015 06:38:56 -0400 Received: by pdbep18 with SMTP id ep18so143646464pdb.1 for ; Wed, 08 Jul 2015 03:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=TPD2epuHniu+1N/m4XcnD9PSNvY5L8UUvsXMzYZHb/Q=; b=u6Mk8KZoYNM1C1bE1wslyjQXM69ewT1w8JgbfeqEWINR93MXDrspyvCNj6qDlHxCcV Uu5xzkx0OCJGyPHZh2dUhfCCZoayW1l2RpjYd1wNBn3P9cTE0LQHEIl8yx6x6HdIzIDq IH+xtfWRS7iP1xu1TBhiCc3bBcYijhegumhHjT8L08+GOrJ251LsJA9PhRAr7qF0Wthi JsTz17MLmZ43P+bWTAs/04t1BUFu422hBKzq4ZGYP9GNkus7JjOGFqfraYd9S4PJTtPW kR6wRKXeLg/KM4cY/v6d9KTrLg7jhfhObL6KlP6NHs98qejhWFK7vUMAZ3YCfFaQd+9b bIew== X-Received: by 10.68.137.104 with SMTP id qh8mr1400347pbb.114.1436351935972; Wed, 08 Jul 2015 03:38:55 -0700 (PDT) Received: from lanh ([115.73.45.219]) by smtp.gmail.com with ESMTPSA id sk2sm2042991pbc.55.2015.07.08.03.38.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2015 03:38:55 -0700 (PDT) Received: by lanh (sSMTP sendmail emulation); Wed, 08 Jul 2015 17:39:41 +0700 X-Mailer: git-send-email 2.3.0.rc1.137.g477eb31 In-Reply-To: <1436351919-2520-1-git-send-email-pclouds@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Similar to the "grep -F -i" case, we can't use kws on icase search outside ascii range, quote we quote the string and pass it to regcomp as a basic regexp and let regex engine deal with case sensitivity. The new test is put in t7812 instead of t4209-log-pickaxe because lib-gettext.sh might cause problems elsewhere, probably.. Noticed-by: Plamen Totev Signed-off-by: Nguy=E1=BB=85n Th=C3=A1i Ng=E1=BB=8Dc Duy --- diffcore-pickaxe.c | 11 +++++++++++ t/t7812-grep-icase-non-ascii.sh | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c index 7a718fc..6946c15 100644 --- a/diffcore-pickaxe.c +++ b/diffcore-pickaxe.c @@ -7,6 +7,8 @@ #include "diffcore.h" #include "xdiff-interface.h" #include "kwset.h" +#include "commit.h" +#include "quote.h" =20 typedef int (*pickaxe_fn)(mmfile_t *one, mmfile_t *two, struct diff_options *o, @@ -212,6 +214,15 @@ void diffcore_pickaxe(struct diff_options *o) cflags |=3D REG_ICASE; err =3D regcomp(®ex, needle, cflags); regexp =3D ®ex; + } else if (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE) && + has_non_ascii(needle)) { + struct strbuf sb =3D STRBUF_INIT; + int cflags =3D REG_NEWLINE | REG_ICASE; + + basic_regex_quote_buf(&sb, needle); + err =3D regcomp(®ex, sb.buf, cflags); + strbuf_release(&sb); + regexp =3D ®ex; } else { kws =3D kwsalloc(DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE) ? tolower_trans_tbl : NULL); diff --git a/t/t7812-grep-icase-non-ascii.sh b/t/t7812-grep-icase-non-a= scii.sh index 1306cc0..20a39d0 100755 --- a/t/t7812-grep-icase-non-ascii.sh +++ b/t/t7812-grep-icase-non-ascii.sh @@ -48,4 +48,11 @@ test_expect_success GETTEXT_LOCALE 'grep string with= regex, with -F' ' test_cmp expect2 debug2 ' =20 +test_expect_success GETTEXT_LOCALE 'pickaxe -i on non-ascii' ' + git commit -m first && + git log --format=3D%f -i -S"TILRAUN: HALL=C3=93 HEIMUR!" >actual && + echo first >expected && + test_cmp expected actual +' + test_done --=20 2.3.0.rc1.137.g477eb31