zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Correct isident false positive.
@ 2011-01-16 12:05 Ricky Zhou
  2011-01-16 19:43 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Ricky Zhou @ 2011-01-16 12:05 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

I'm not familiar with with the precise definition of an identifier, so
somebody might want to double-check that this change (which assumes that
valid identifiers cannot start with a '[') is correct.  This fixes the
following crash:

printf %n '[0]'

---
 Src/params.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/Src/params.c b/Src/params.c
index 8510b92..ba6cd63 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1009,6 +1009,8 @@ isident(char *s)
      * definitely not a valid identifier.         */
     if (!*ss)
 	return 1;
+    if (s == ss)
+	return 0;
     if (*ss != '[')
 	return 0;
 
-- 
1.7.3.4


[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Correct isident false positive.
  2011-01-16 12:05 [PATCH] Correct isident false positive Ricky Zhou
@ 2011-01-16 19:43 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2011-01-16 19:43 UTC (permalink / raw)
  To: zsh-workers

On Sun, 16 Jan 2011 07:05:20 -0500
Ricky Zhou <ricky@rzhou.org> wrote:
> I'm not familiar with with the precise definition of an identifier, so
> somebody might want to double-check that this change (which assumes that
> valid identifiers cannot start with a '[') is correct.  This fixes the
> following crash:
> 
> printf %n '[0]'

Thanks, makes a lot of sense.  I'll add the regression test.

Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.52
diff -p -u -r1.52 D04parameter.ztst
--- Test/D04parameter.ztst	19 Dec 2010 17:42:10 -0000	1.52
+++ Test/D04parameter.ztst	16 Jan 2011 19:41:59 -0000
@@ -1401,3 +1401,7 @@
 >a
 >b
 >c
+
+   printf "%n" '[0]'
+1:Regression test for identifier test
+?(eval):1: not an identifier: [0]

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-16 20:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-16 12:05 [PATCH] Correct isident false positive Ricky Zhou
2011-01-16 19:43 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).