Closed Bug 442210 Opened 17 years ago Closed 17 years ago

eval() of regular expression string does not work on OS/2 -- "invalid flag after regular expression"

Categories

(Core :: JavaScript Engine, defect)

1.9.0 Branch
x86
OS/2
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: bugzilla.mozilla.org, Unassigned)

References

()

Details

The url javascript:eval('/test/') gives the error message "invalid flag after regular expression" in the error console. In windows, this works. javascript:eval(/test/) and javascript:new RegExp('test') work fine.
URL: javascript:eval('test')javascript:eval('/test/')
Yes, I can confirm that this is different behavior between the OS/2 version of Firefox 3 and the versions on Linux and Windows. The same goes for SeaMonkey, too. I didn't test with Firefox 2 or SeaMonkey 1.1.x, though. jms, did you? I looked through the JS code a bit but didn't find anything that would explain this difference. In particular, I didn't see any code branches that would exclude OS/2 and look relevant to this.
Assignee: nobody → general
Severity: major → normal
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Hardware: Other → PC
Version: 3.0 Branch → 1.9.0 Branch
I wonder if this another deficiency of our C-library, like bug 396798. Can someone of the JS gurus tell me where I should start looking in the code?
There's only one place in jsregexp.c at which JSMSG_BAD_FLAG is reported. Breaking there and figuring out how we get there would be instructive.
Note that there's also a place in jsscan.cpp that reports this error.
Oh, good eye mrbkap. Thanks!
javascript:eval('/test/ ') works fine (extra blank at end)
After scanning the string /test/, we come to line 1844 of jsscan.c: c = PeekChar(ts); if (JS7_ISLET(c)) { /* ((c) < 128 && isalpha(c)) */ tp->ptr = ts->linebuf.ptr - 1; js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR, JSMSG_BAD_REGEXP_FLAG); (void) GetChar(ts); goto error; } If there is a \0 now, we should not go into the if statement because the \0 fails the isalpha test. That means that the string is not null terminated or something is wrong with GetChar/UngetChar.
Well, what's c?
Summary: eval() of regular expression string does not work → eval() of regular expression string does not work -- "invalid flag after regular expression"
Summary: eval() of regular expression string does not work -- "invalid flag after regular expression" → eval() of regular expression string does not work on OS/2 -- "invalid flag after regular expression"
When running the javascript:eval('/test/') testcase I see that c is EOF, before and after the PeekChar() call that was quoted in comment 7.
This reminds me of broken Unix libc ports to odd systems. Since c is int, EOF is -1 (check this in your stdio.h). Then you need <ctype.h> to offset the attributes lookup table it uses for isspace, etc., by 1, so indexing by -1 is memory safe and gets the right (0) attrs for EOF. /be
Thanks, be. I think you nailed the problem. Will try to solve that with the guys who maintain our compiler and C library. (Now that you say that I also remembered to test with a GCC 3.2.2 compiled build and there this bug doesn't happen.)
OK, confirmed to be a bug outside the Mozilla sources. This is now tracked as a bug of the C-library at <http://svn.netlabs.org/libc/ticket/199>.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.