summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2012-12-08 19:50:20 +0000
committerBart Schaefer <barts@users.sourceforge.net>2012-12-08 19:50:20 +0000
commit431c22024d8af440ca4b79ce951896f3bcd0d7cc (patch)
treeb1537203e66121da529463e322dc0e4830b8a02a
parent968a7a2a51065ee39c647ab088f39a36dbba2ac7 (diff)
downloadzsh-431c22024d8af440ca4b79ce951896f3bcd0d7cc.tar.gz
zsh-431c22024d8af440ca4b79ce951896f3bcd0d7cc.tar.xz
zsh-431c22024d8af440ca4b79ce951896f3bcd0d7cc.zip
users/17445: fix handling of leading zeroes in floating point
-rw-r--r--ChangeLog9
-rw-r--r--Src/math.c3
-rw-r--r--Test/C01arith.ztst10
3 files changed, 19 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c81d4cf4c..f80e1a5c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-08  Bart Schaefer  <schaefer@zsh.org>
+
+	* users/17445: Src/math.c, Test/C01arith.ztst: fix handling of
+	leading zeroes in floating point.
+
 2012-11-20  Oliver Kiddle <opk@zsh.org>
 
 	* 30811: Completion/Linux/Command/_btrfs,
@@ -6,7 +11,7 @@
 
 2012-11-16  Vin Shelton  <acs@xemacs.org>
 
-	* Doc/Zsh/grammar.yo: users/16865: Added missing menu item for Errors.
+	* users/16865: Doc/Zsh/grammar.yo: Added missing menu item for Errors.
 
 2012-11-18  Bart Schaefer  <schaefer@zsh.org>
 
@@ -363,5 +368,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5765 $
+* $Revision: 1.5766 $
 *****************************************************
diff --git a/Src/math.c b/Src/math.c
index abc5f994e..e90d6a59a 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -447,7 +447,8 @@ lexconstant(void)
     if (*nptr == '-')
 	nptr++;
 
-    if (*nptr == '0')
+    if (*nptr == '0' &&
+	(memchr(nptr, '.', strlen(nptr)) == NULL))
     {
 	nptr++;
 	if (*nptr == 'x' || *nptr == 'X') {
diff --git a/Test/C01arith.ztst b/Test/C01arith.ztst
index e5845d37f..02d1519a4 100644
--- a/Test/C01arith.ztst
+++ b/Test/C01arith.ztst
@@ -152,6 +152,16 @@
 0:commas and parentheses, part 1
 >4
 
+  print $(( 07.5 ))
+  (setopt octalzeroes; print $(( 09.5 )))
+0:leading zero doesn't affect floating point
+>7.5
+>9.5
+
+  (setopt octalzeroes; print $(( 09 )))
+1:octalzeroes rejects invalid constants
+?(eval):1: bad math expression: operator expected at `9 '
+
   (setopt octalzeroes; print $(( 08#77 )))
 0:octalzeroes doesn't affect bases
 >63