Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0e0 not recognized as valid scientific notation by perl #404

Closed
p5pRT opened this issue Aug 20, 1999 · 5 comments
Closed

0e0 not recognized as valid scientific notation by perl #404

p5pRT opened this issue Aug 20, 1999 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 20, 1999

Migrated from rt.perl.org#1239 (status was 'resolved')

Searchable as RT1239$

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 1999

From allen@grumman.com

  $ perl -we '$a = 0e0'
  Bareword found where operator expected at -e line 1, near "0e0"
  (Missing operator before e0?)
  syntax error at -e line 1, next token ???
  Execution of -e aborted due to compilation errors.

Both with perl5.004_04 and perl5.005_60. Perhaps it is trying to parse it
as an octal number, but the error message does not seem to indicate that.

John.

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 1999

From [Unknown Contact. See original ticket]

This patch makes 0e0 scan as 'decimal' (thus as 0.0e0 would)
rather than as octal/hex/binary. Your line numbers WILL vary, as
this comes from an already-patched toke.c, but it will apply
properly despite the warnings from patch.

/spider

Inline Patch
--- toke.c.prev	Thu Aug 19 16:22:48 1999
+++ toke.c	Fri Aug 20 11:45:14 1999
@@ -6398,7 +6401,7 @@ Perl_scan_num(pTHX_ char *start)
 		s += 2;
 	    }
 	    /* check for a decimal in disguise */
-	    else if (s[1] == '.')
+	    else if (strchr(".Ee", s[1]))
 		goto decimal;
 	    /* so it must be octal */
 	    else

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 1999

From [Unknown Contact. See original ticket]

On Fri, 20 Aug 1999, Spider Boardman wrote​:

This patch makes 0e0 scan as 'decimal' (thus as 0.0e0 would)
rather than as octal/hex/binary. Your line numbers WILL vary, as
this comes from an already-patched toke.c, but it will apply
properly despite the warnings from patch.

[patch deleted]

Wow, that was fast. Talk about service! Thanks.

John.

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 1999

From [Unknown Contact. See original ticket]

On Fri, 20 Aug 1999, Spider Boardman wrote​:

This patch makes 0e0 scan as 'decimal' (thus as 0.0e0 would)
rather than as octal/hex/binary. Your line numbers WILL vary, as
this comes from an already-patched toke.c, but it will apply
properly despite the warnings from patch.

/spider

--- toke.c.prev Thu Aug 19 16​:22​:48 1999
+++ toke.c Fri Aug 20 11​:45​:14 1999
@​@​ -6398,7 +6401,7 @​@​ Perl_scan_num(pTHX_ char *start)
s += 2;
}
/* check for a decimal in disguise */
- else if (s[1] == '.')
+ else if (strchr(".Ee", s[1]))
goto decimal;
/* so it must be octal */
else

Thanks.

(Though perhaps we should use (s[1] == '.' || s[1] == 'e' || s[1] == 'E')
for speed, instead of calling strchr?)

John.

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 1999

From [Unknown Contact. See original ticket]

On Fri, 20 Aug 1999 12​:06​:46 -0400 (EDT), "John L. Allen" wrote (in part)​:

John> (Though perhaps we should use (s[1] == '.' || s[1] == 'e'
John> || s[1] == 'E') for speed, instead of calling strchr?)

With the compiler I'm using, it's not measurable (strchr is
inlined). You have raised a valid point, though. I'm inclined
to leave it up to the pumpkings for the various release streams
to decide. ;=}

/spider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant