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 2/5] compat/wildmatch: remove static variable force_lower_case Date: Wed, 26 Sep 2012 18:25:38 +0700 Message-ID: <1348658741-8146-3-git-send-email-pclouds@gmail.com> References: <1348658741-8146-1-git-send-email-pclouds@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: 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 Sep 26 13:34:33 2012 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 1TGpsq-0005fK-Bo for gcvg-git-2@plane.gmane.org; Wed, 26 Sep 2012 13:34:29 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755189Ab2IZLeT convert rfc822-to-quoted-printable (ORCPT ); Wed, 26 Sep 2012 07:34:19 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:55406 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755064Ab2IZLeS (ORCPT ); Wed, 26 Sep 2012 07:34:18 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so1747509pbb.19 for ; Wed, 26 Sep 2012 04:34:18 -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:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=do2uYgdDorBGWuXxUEPAEjWQ+VRhcuBJ3mHby8uC+po=; b=s9mMhaEFrwT+XAdw2UeKS98fTIu5VQa7Y33SFIDWZ5hqT8HxJkLE9YO54OX1lTxNWR dFXxBGu7TvrO/z8WzbIbfDSXsKqL/LWu6XqBWM/VSUaTAc2rcFMP+B4GMIM7a8HRXiv+ bw7iVtnsE+FcZhiqDMwnB5f+w/olkuYEC2HxSN78ZnQVOkBa+1Q/X5m5H99gNujuSnlX hC8V2Do8wHNvNNYhwAEUh4jtf0owWKqPY9Ertk/TTfvwKkTYBkkXUebaunHyQcmy33YK YauvPZ6t8uqX/k5PZyC4ZgG1QSWB4ceIV6HN48vdGlAY5DpdOohw5WSP5SHWxxqt9BPR ws6w== Received: by 10.66.85.167 with SMTP id i7mr511205paz.8.1348659258318; Wed, 26 Sep 2012 04:34:18 -0700 (PDT) Received: from pclouds@gmail.com ([115.74.51.2]) by mx.google.com with ESMTPS id nv2sm793667pbc.44.2012.09.26.04.34.15 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Sep 2012 04:34:17 -0700 (PDT) Received: by pclouds@gmail.com (sSMTP sendmail emulation); Wed, 26 Sep 2012 18:27:32 +0700 X-Mailer: git-send-email 1.7.12.1.406.g6ab07c4 In-Reply-To: <1348658741-8146-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: One place less to worry about thread safety Signed-off-by: Nguy=E1=BB=85n Th=C3=A1i Ng=E1=BB=8Dc Duy Signed-off-by: Junio C Hamano --- wildmatch.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/wildmatch.c b/wildmatch.c index f3a1731..e824eb2 100644 --- a/wildmatch.c +++ b/wildmatch.c @@ -57,11 +57,10 @@ int wildmatch_iteration_count; #endif =20 -static int force_lower_case =3D 0; - /* Match pattern "p" against the a virtually-joined string consisting * of "text" and any strings in array "a". */ -static int dowild(const uchar *p, const uchar *text, const uchar*const= *a) +static int dowild(const uchar *p, const uchar *text, + const uchar*const *a, int force_lower_case) { uchar p_ch; =20 @@ -121,7 +120,7 @@ static int dowild(const uchar *p, const uchar *text= , const uchar*const *a) t_ch =3D *text; continue; } - if ((matched =3D dowild(p, text, a)) !=3D FALSE) { + if ((matched =3D dowild(p, text, a, force_lower_case)) !=3D FALSE) { if (!special || matched !=3D ABORT_TO_STARSTAR) return matched; } else if (!special && t_ch =3D=3D '/') @@ -291,7 +290,7 @@ int wildmatch(const char *pattern, const char *text= ) #ifdef WILD_TEST_ITERATIONS wildmatch_iteration_count =3D 0; #endif - return dowild((const uchar*)pattern, (const uchar*)text, nomore) =3D= =3D TRUE; + return dowild((const uchar*)pattern, (const uchar*)text, nomore, 0= ) =3D=3D TRUE; } =20 /* Match the "pattern" against the forced-to-lower-case "text" string.= */ @@ -302,9 +301,7 @@ int iwildmatch(const char *pattern, const char *tex= t) #ifdef WILD_TEST_ITERATIONS wildmatch_iteration_count =3D 0; #endif - force_lower_case =3D 1; - ret =3D dowild((const uchar*)pattern, (const uchar*)text, nomore) = =3D=3D TRUE; - force_lower_case =3D 0; + ret =3D dowild((const uchar*)pattern, (const uchar*)text, nomore, = 1) =3D=3D TRUE; return ret; } =20 @@ -331,7 +328,7 @@ int wildmatch_array(const char *pattern, const char= *const *texts, int where) if (!text) return FALSE; =20 - if ((matched =3D dowild(p, text, a)) !=3D TRUE && where < 0 + if ((matched =3D dowild(p, text, a, 0)) !=3D TRUE && where < 0 && matched !=3D ABORT_ALL) { while (1) { if (*text =3D=3D '\0') { @@ -339,7 +336,7 @@ int wildmatch_array(const char *pattern, const char= *const *texts, int where) return FALSE; continue; } - if (*text++ =3D=3D '/' && (matched =3D dowild(p, text, a)) !=3D F= ALSE + if (*text++ =3D=3D '/' && (matched =3D dowild(p, text, a, 0)) !=3D= FALSE && matched !=3D ABORT_TO_STARSTAR) break; } --=20 1.7.12.1.406.g6ab07c4