aboutsummaryrefslogtreecommitdiffstats
path: root/complex.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-17 15:51:55 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-17 15:51:55 +0000
commit8d05671d63b506f8e3db75db4db5631bc61d0fd2 (patch)
tree9f0e6a91fd4ae513c6f801d65071d55732e81c03 /complex.c
parent8f3882d0f8342f4fe91713ce5ba5c00adab299ac (diff)
downloadruby-8d05671d63b506f8e3db75db4db5631bc61d0fd2.tar.gz
* complex.c (read_comp): fixed handling of polar form.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/complex.c b/complex.c
index 5cebf96522..f887ebeda9 100644
--- a/complex.c
+++ b/complex.c
@@ -1668,16 +1668,24 @@ read_comp(const char **s, int strict,
}
if (**s == '@') {
+ int st;
+
(*s)++;
bb = *b;
- if (!read_rat(s, strict, b)) {
- num = rb_complex_raw2(num, ZERO);
+ if (!(isdigit((unsigned char)**s) ||
+ **s == '-' || **s == '+' ||
+ **s == '.')) {
+ *ret = rb_complex_raw2(num, ZERO);
return 0; /* e.g. "1@x" */
}
+ st = read_rat(s, strict, b);
**b = '\0';
num2 = str2num(bb);
*ret = rb_complex_polar(num, num2);
- return 1; /* e.g. "1@2" */
+ if (!st)
+ return 0; /* e.g. "1@2." */
+ else
+ return 1; /* e.g. "1@2" */
}
if (**s == '-' || **s == '+') {