mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
trivial changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
55915036a6
commit
7a1985a969
2 changed files with 22 additions and 18 deletions
23
complex.c
23
complex.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
complex.c: Coded by Tadayoshi Funaba 2008-2011
|
||||
complex.c: Coded by Tadayoshi Funaba 2008-2012
|
||||
|
||||
This implementation is based on Keiju Ishitsuka's Complex library
|
||||
which is written in ruby.
|
||||
|
@ -1626,10 +1626,8 @@ str2num(char *s)
|
|||
{
|
||||
if (strchr(s, '/'))
|
||||
return rb_cstr_to_rat(s, 0);
|
||||
if (strpbrk(s, ".eE")) {
|
||||
double d = rb_cstr_to_dbl(s, 0);
|
||||
return DBL2NUM(d);
|
||||
}
|
||||
if (strpbrk(s, ".eE"))
|
||||
return DBL2NUM(rb_cstr_to_dbl(s, 0));
|
||||
return rb_cstr_to_inum(s, 10, 0);
|
||||
}
|
||||
|
||||
|
@ -1715,6 +1713,13 @@ read_comp(const char **s, int strict,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
skip_ws(const char **s)
|
||||
{
|
||||
while (isspace((unsigned char)**s))
|
||||
(*s)++;
|
||||
}
|
||||
|
||||
static int
|
||||
parse_comp(const char *s, int strict,
|
||||
VALUE *num)
|
||||
|
@ -1724,14 +1729,10 @@ parse_comp(const char *s, int strict,
|
|||
buf = ALLOCA_N(char, strlen(s) + 1);
|
||||
b = buf;
|
||||
|
||||
while (isspace((unsigned char)*s))
|
||||
s++;
|
||||
|
||||
skip_ws(&s);
|
||||
if (!read_comp(&s, strict, num, &b))
|
||||
return 0;
|
||||
|
||||
while (isspace((unsigned char)*s))
|
||||
s++;
|
||||
skip_ws(&s);
|
||||
|
||||
if (strict)
|
||||
if (*s != '\0')
|
||||
|
|
17
rational.c
17
rational.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
rational.c: Coded by Tadayoshi Funaba 2008-2011
|
||||
rational.c: Coded by Tadayoshi Funaba 2008-2012
|
||||
|
||||
This implementation is based on Keiju Ishitsuka's Rational library
|
||||
which is written in ruby.
|
||||
|
@ -2093,18 +2093,21 @@ read_rat(const char **s, int strict,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
skip_ws(const char **s)
|
||||
{
|
||||
while (isspace((unsigned char)**s))
|
||||
(*s)++;
|
||||
}
|
||||
|
||||
static int
|
||||
parse_rat(const char *s, int strict,
|
||||
VALUE *num)
|
||||
{
|
||||
while (isspace((unsigned char)*s))
|
||||
s++;
|
||||
|
||||
skip_ws(&s);
|
||||
if (!read_rat(&s, strict, num))
|
||||
return 0;
|
||||
|
||||
while (isspace((unsigned char)*s))
|
||||
s++;
|
||||
skip_ws(&s);
|
||||
|
||||
if (strict)
|
||||
if (*s != '\0')
|
||||
|
|
Loading…
Add table
Reference in a new issue