From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Re: :alnum: broken? Date: Wed, 26 Feb 2020 15:10:46 +0100 Message-ID: <03A37C4B-9FE8-4A25-9851-79BC8265455E@acm.org> References: <86wo8flqct.fsf@stephe-leake.org> <86sgj3ljf0.fsf@stephe-leake.org> <5fecc0e1-1ee2-5a89-9297-b0b9aa4a8e9c@cs.ucla.edu> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_5A81F77B-D7BA-4A4F-ADC8-BF65BC86D712" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="56615"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stephen Leake , emacs-devel To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Feb 26 15:11:37 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j6xPU-000EbB-OH for ged-emacs-devel@m.gmane-mx.org; Wed, 26 Feb 2020 15:11:36 +0100 Original-Received: from localhost ([::1]:44944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6xPT-0000Vy-OC for ged-emacs-devel@m.gmane-mx.org; Wed, 26 Feb 2020 09:11:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36691) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6xP0-00006A-68 for emacs-devel@gnu.org; Wed, 26 Feb 2020 09:11:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6xOy-0002Z4-2F for emacs-devel@gnu.org; Wed, 26 Feb 2020 09:11:06 -0500 Original-Received: from mail83c50.megamailservers.eu ([91.136.10.93]:33064 helo=mail18c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6xOx-0002RF-GA for emacs-devel@gnu.org; Wed, 26 Feb 2020 09:11:03 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1582726250; bh=jjnwb6UtTvxsUcWTGskXexr8KAesMw8kcaGZgeiMExo=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=iPXepyve+rjPmNT1qO2CfiWY/5T4LLxiEnWeEMHu7YI03lJHazhg4ES+FI1YWByG/ pm14yy24h9etT2f16WU+B1nozKY4PLkq4L5jNUaRyFREqVHsPAM6iFsVJc0FZzHh73 PVYQ8oOo4ORY4J6VNIcZT4zNsm5bbxUUdbgYmfno= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-6f4fe655.032-75-73746f71.bbcust.telenor.se [85.230.79.111]) (authenticated bits=0) by mail18c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 01QEAlGr018910; Wed, 26 Feb 2020 14:10:49 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A782F20.5E567C6A.005F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=dfr+Ikfe c=1 sm=1 tr=0 a=fHaj9vQUQVKQ4sUldAaXuQ==:117 a=fHaj9vQUQVKQ4sUldAaXuQ==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=M51BFTxLslgA:10 a=_Dz33N2ozAxsvj0iuKMA:9 a=CjuIK1q_8ugA:10 a=OLO0ecU_Wd_CE31ndnEA:9 a=B2y7HmGcmWMA:10 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 91.136.10.93 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:245073 Archived-At: --Apple-Mail=_5A81F77B-D7BA-4A4F-ADC8-BF65BC86D712 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I just made this very mistake while adding a new regexp-error checking = feature to xr. Needless to say I now am strongly in favour of turning it = into a hard error. Patch attached. It was written for master, but I would suggest it go in = emacs-27. The error message could be improved. For the benefit of = isearch-forward-regexp, it's probably a good idea if it doesn't start or = end in a square bracket. --Apple-Mail=_5A81F77B-D7BA-4A4F-ADC8-BF65BC86D712 Content-Disposition: attachment; filename=0001-Signal-an-error-for-the-regexp-alnum.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Signal-an-error-for-the-regexp-alnum.patch" Content-Transfer-Encoding: quoted-printable =46rom=20014a7a7dce5ae23b8a47dd68eaaef0a5cb985b46=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Wed,=2026=20Feb=202020=2014:46:01=20+0100=0A= Subject:=20[PATCH]=20Signal=20an=20error=20for=20the=20regexp=20= "[:alnum:]"=0A=0AOmitting=20the=20extra=20brackets=20is=20a=20common=20= mistake;=20see=20discussion=20at=0A= https://lists.gnu.org/archive/html/emacs-devel/2020-02/msg00215.html=0A=0A= *=20src/regex-emacs.c=20(reg_errcode_t,=20re_error_msgid):=20Add=20= REG_ECLASSBR.=0A(regex_compile):=20Check=20for=20the=20mistake.=0A*=20= test/src/regex-emacs-tests.el=20(regexp-invalid):=20Test.=0A*=20= etc/NEWS:=20Announce.=0A---=0A=20etc/NEWS=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20|=20=205=20+++++=0A=20src/regex-emacs.c=20= =20=20=20=20=20=20=20=20=20=20=20=20|=2021=20++++++++++++++++++++-=0A=20= test/src/regex-emacs-tests.el=20|=20=204=20++++=0A=203=20files=20= changed,=2029=20insertions(+),=201=20deletion(-)=0A=0Adiff=20--git=20= a/etc/NEWS=20b/etc/NEWS=0Aindex=2054aab1a5b6..404b4b9ebd=20100644=0A---=20= a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-190,6=20+190,11=20@@=20Emacs=20now=20= supports=20bignums=20so=20this=20old=20glitch=20is=20no=20longer=20= needed.=0A=20'previous-system-time-locale'=20have=20been=20removed,=20as=20= they=20were=20created=0A=20by=20mistake=20and=20were=20not=20useful=20to=20= Lisp=20code.=0A=20=0A+**=20The=20regexp=20mistake=20'[:digit:]'=20is=20= now=20an=20error.=0A+The=20correct=20syntax=20is=20'[[:digit:]]'.=20=20= Previously,=20forgetting=20the=20extra=0A+brackets=20silently=20resulted=20= in=20a=20regexp=20that=20did=20not=20at=20all=20work=20as=0A+intended.=0A= +=0A=20=0C=0A=20*=20Lisp=20Changes=20in=20Emacs=2028.1=0A=20=0Adiff=20= --git=20a/src/regex-emacs.c=20b/src/regex-emacs.c=0Aindex=20= 694431c95e..2648e1d6ae=20100644=0A---=20a/src/regex-emacs.c=0A+++=20= b/src/regex-emacs.c=0A@@=20-818,7=20+818,8=20@@=20print_double_string=20= (re_char=20*where,=20re_char=20*string1,=20ptrdiff_t=20size1,=0A=20=20=20= REG_ESIZE,=09=09/*=20Compiled=20pattern=20bigger=20than=202^16=20bytes.=20= =20*/=0A=20=20=20REG_ERPAREN,=09=09/*=20Unmatched=20)=20or=20\);=20not=20= returned=20from=20regcomp.=20=20*/=0A=20=20=20REG_ERANGEX,=09=09/*=20= Range=20striding=20over=20charsets.=20=20*/=0A-=20=20REG_ESIZEBR=20=20=20= =20=20=20=20=20=20=20=20/*=20n=20or=20m=20too=20big=20in=20\{n,m\}=20*/=0A= +=20=20REG_ESIZEBR,=20=20=20=20=20=20=20=20=20=20/*=20n=20or=20m=20too=20= big=20in=20\{n,m\}=20*/=0A+=20=20REG_ECLASSBR,=20=20=20=20=20=20=20=20=20= /*=20Missing=20[]=20around=20[:class:].=20=20*/=0A=20}=20reg_errcode_t;=0A= =20=0A=20static=20const=20char=20*re_error_msgid[]=20=3D=0A@@=20-842,6=20= +843,7=20@@=20print_double_string=20(re_char=20*where,=20re_char=20= *string1,=20ptrdiff_t=20size1,=0A=20=20=20=20[REG_ERPAREN]=20=3D=20= "Unmatched=20)=20or=20\\)",=0A=20=20=20=20[REG_ERANGEX=20]=20=3D=20= "Range=20striding=20over=20charsets",=0A=20=20=20=20[REG_ESIZEBR=20]=20=3D= =20"Invalid=20content=20of=20\\{\\}",=0A+=20=20=20[REG_ECLASSBR]=20=3D=20= "Class=20syntax=20is=20[[:digit:]],=20not=20[:digit:]",=0A=20=20=20};=0A=20= =0A=20/*=20For=20'regs_allocated'.=20=20*/=0A@@=20-2000,6=20+2002,23=20= @@=20regex_compile=20(re_char=20*pattern,=20ptrdiff_t=20size,=0A=20=0A=20= =09=20=20=20=20laststart=20=3D=20b;=0A=20=0A+=20=20=20=20=20=20=20=20=20=20= =20=20/*=20Check=20for=20the=20mistake=20of=20forgetting=20the=20extra=20= square=20brackets,=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20as=20= in=20"[:alpha:]".=20=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20if=20= (*p=20=3D=3D=20':')=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20{=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20re_char=20*q=20=3D=20p=20+=20= 1;=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20while=20(q=20!=3D=20= pend=20&&=20*q=20!=3D=20']')=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20{=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20if=20(*q=20=3D=3D=20':')=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20{=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20if=20(q=20+=201=20!=3D=20pend=20&&=20q[1]=20= =3D=3D=20']'=20&&=20q=20>=20p=20+=201)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20FREE_STACK_RETURN=20= (REG_ECLASSBR);=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20break;=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20}=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20q++;=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= }=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20}=0A+=0A=20=09=20=20=20=20= /*=20Test=20'*p=20=3D=3D=20'^'=20twice,=20instead=20of=20using=20an=20if=0A= =20=09=20=20=20=20=20=20=20statement,=20so=20we=20need=20only=20one=20= BUF_PUSH.=20=20*/=0A=20=09=20=20=20=20BUF_PUSH=20(*p=20=3D=3D=20'^'=20?=20= charset_not=20:=20charset);=0Adiff=20--git=20= a/test/src/regex-emacs-tests.el=20b/test/src/regex-emacs-tests.el=0A= index=20f9372e37b1..d268b97080=20100644=0A---=20= a/test/src/regex-emacs-tests.el=0A+++=20b/test/src/regex-emacs-tests.el=0A= @@=20-803,4=20+803,8=20@@=20regexp-multibyte-unibyte=0A=20=20=20= (should-not=20(string-match=20"=C3=A5"=20"\xe5"))=0A=20=20=20(should-not=20= (string-match=20"[=C3=A5]"=20"\xe5")))=0A=20=0A+(ert-deftest=20= regexp-invalid=20()=0A+=20=20(should-error=20(string-match=20"[:space:]"=20= "")=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20:type=20= 'invalid-regexp))=0A+=0A=20;;;=20regex-emacs-tests.el=20ends=20here=0A--=20= =0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_5A81F77B-D7BA-4A4F-ADC8-BF65BC86D712--