Commit Graph

586 Commits

Author SHA1 Message Date
Tor Andersson
43c844510b Issue #84: Separate Makefile targets.
Don't automatically build static library when building the shell
or the shared library.
2019-02-25 11:57:40 +01:00
Tor Andersson
9f40dfb032 Take DESTDIR into account when creating pkg-config file.
Also only create the file when installing.
2019-02-12 12:19:26 +01:00
Tor Andersson
5f556004a2 Fix bugs in Number.prototype.toFixed and toExponential.
toPrecision does not behave correctly: it doesn't pad the number with
trailing zeroes to reach the desired precision.
2019-02-08 15:25:35 +01:00
Tor Andersson
28643e6afb Bug 697891: Parse all JSON string escapes. 2019-01-23 12:53:25 +01:00
Tor Andersson
bd9920c571 Handle null/undefined in OP_NEXTITER rather than creating empty iterator.
Only create an iterator for coercible types in OP_ITERATOR, and then
detect the lack of a real iterator in OP_NEXTITER.
Thus we don't need to allocate and push an empty iterator object for
these cases.
2019-01-07 13:28:22 +01:00
Tor Andersson
7be32a0f5f Bug 700441: Handle null and undefined expressions in for-in statement. 2019-01-04 10:58:30 +01:00
Tor Andersson
7f50591861 Bug 700429: Limit size of input regular expression program.
The size of the parsed syntax list could overflow. Allowing it to be
bigger than the compiled program makes no sense, so use the same size
limit when parsing as when compiling.
2019-01-02 16:05:24 +01:00
Tor Andersson
93447649b5 Make data tables in utftype.c const. 2018-11-26 10:40:22 +01:00
Tor Andersson
fcf0e3ebd7 Tweak numeric overflow check in regexp count parser. 2018-11-26 10:40:22 +01:00
Tor Andersson
245a6f97e6 Fix 700090, 700094, 700095: Iterate through lists in AST analysis passes. 2018-11-05 16:00:13 +01:00
Tor Andersson
81d5b30acc Initialize random seed for Math.random(). 2018-10-26 14:57:56 +02:00
Sebastian Rasmussen
7448a82448 Fix gcc compiler warnings about switch fallthroughs. 1.0.5 2018-09-11 12:47:31 +02:00
Tor Andersson
d4655ae888 Show system error message in js_loadfile. 2018-09-04 11:27:34 +02:00
Avi Halachmi (:avih)
924649a69e mujs shell: Add compile function.
The new compile function compiles a source code string as a script and
returns a callable object. The optional 'filename' argument is used to
format error messages and stack traces.
2018-09-04 11:27:34 +02:00
Tor Andersson
84858c335e mujs shell: Make the load function behave like in the SpiderMonkey shell. 2018-09-04 11:27:34 +02:00
Tor Andersson
a2b62c028e Avoid clashing with system getopt. 2018-09-04 11:26:56 +02:00
Tor Andersson
dcb3f03e90 Inherit strictness from invoking function in eval. 2018-09-03 16:10:02 +02:00
Tor Andersson
2c0c6c94ca Use getopt command line argument processing.
Pass script arguments to script as global variable scriptArgs.
2018-09-03 15:30:30 +02:00
Tor Andersson
643d428894 Default mujs shell to non-strict mode.
Pass "-s" as the first argument to start the shell in strict mode.
2018-08-29 13:01:04 +02:00
Tor Andersson
3430d9a06d Return null instead of throwing an error when readline hits EOF. 2018-08-27 12:59:00 +02:00
Sebastian Rasmussen
c86267d8b2 Fix issue 66: Stack overflow when compiling long regexp sequences.
The syntax tree for long chains of Cat nodes leaned leftwards, which
made the compile() step potentially run out of stack. If we build the
Cat tree leaning right, we can use an iterative loop instead of
recursion.
1.0.4
2018-07-30 15:35:39 +02:00
Tor Andersson
5c1300b015 Fix 699559: Off-by-one comparison in regexp parser. 2018-07-26 23:44:15 +02:00
Tor Andersson
b4297c0dec Fix 699557: Pause garbage collector during Ap_sort.
The temporary array we use for sorting cannot be seen by the GC, and that
violates the constraint that all js_Value values must always be reachable
from the stack or global environment.

Temporarily turning off the GC will let us use the temporary array for
fast sorting using qsort(), without tripping over this violation.
2018-07-25 12:00:33 +02:00
Tor Andersson
40b73014d9 Fix 699549: Integer overflow in Array.prototype.sort().
Check size calculation for overflow before allocating memory buffer.
2018-07-23 11:30:22 +02:00
Konstantin Baladurin
dbc0931a5c Fix Date.prototype.setHours 2018-07-19 12:21:43 +02:00
Tor Andersson
bd2470847c Fix logic in Object.isFrozen to comply with spec. 2018-07-16 13:28:04 +02:00
Tor Andersson
49271d3cf2 Add js_iserror function. 2018-07-03 12:00:57 +02:00
Tor Andersson
222772f6bb Remove -ffunction-sections and -fdata-sections compile flags.
They're only of minor benefit. Simpler build systems are better.
2018-06-15 15:22:54 +02:00
Tor Andersson
ceac1b57d9 Allow enabling or disabling readline support by setting HAVE_READLINE. 2018-06-15 15:05:38 +02:00
Tor Andersson
2be672cd30 Fix makefile to remove warning from 'ar' invocation. 2018-06-08 13:52:12 +02:00
Tor Andersson
3f6b06a358 Avoid type punning with unions.
Use memcpy, which is guaranteed to be safe under all compiler flags.
2018-06-08 13:51:10 +02:00
Tor Andersson
34cb61711f Fix 699383: Sorting arrays with zero or negative length. 2018-05-29 14:29:16 +02:00
Tor Andersson
cbdf814ee2 Handle undefined and unset array slots separately in Array.prototype.sort. 2018-05-15 13:51:24 +02:00
Tor Andersson
caabe08cb1 Use qsort to sort arrays. 2018-05-15 13:22:04 +02:00
Tor Andersson
b0e3f5e80d Add readline support to mujs shell. 2018-05-08 13:15:39 +02:00
Tor Andersson
22430de3a9 Fix creation of empty regular expressions.
Handle empty regular expressions in RegExp compiler asserts.

Also turn them into /(?:)/ on the JS side, so they can be printed
back as valid JS syntax where // is a comment, not a regular expression.
2018-05-03 10:45:34 +02:00
Tor Andersson
833f82ca95 Fix issue #65: Uninitialized name in Function.prototype function. 2018-05-03 10:38:55 +02:00
Tor Andersson
b46ee8d829 Add more js_tryxxx conversion functions. 2018-04-27 16:59:35 +02:00
Tor Andersson
780b14b5b7 Fix bug in Ap_sort where tostring values were put back into the array. 2018-04-27 11:11:50 +02:00
Tor Andersson
57b698f0b2 Return null if String.prototype.match with a global regex finds no matches. 2018-04-26 13:30:13 +02:00
Tor Andersson
9d72b07e0b Don't forget to zero-terminate string buffer in Fp_toString. 2018-04-24 15:46:03 +02:00
Tor Andersson
d04cbf3cc7 Add pretty-printing command line tool. 2018-04-23 18:24:31 +02:00
Tor Andersson
25821e6d74 Fix 698920: Guard jsdtoa from integer overflow wreaking havoc. 1.0.3 2018-01-24 16:55:49 +01:00
Tor Andersson
4d45a96e57 Guard binary expressions from too much recursion. 2018-01-24 16:27:16 +01:00
Tor Andersson
8df3dcd8c1 Add XCFLAGS to the CFLAGS in the Makefile.
Supports adding custom compiler flags without editing the Makefile.
2018-01-24 14:44:14 +01:00
Tor Andersson
e25c83d6b5 Fix issue #62: Handle 'this' binding consistently in REPL.
The promotion of 'this' to the global object happens in the interpreter
on the OP_THIS instruction, depending on the current strictness. Don't
push the global object in eval_print in main.c.
2018-01-23 16:19:29 +01:00
Tor Andersson
66cf4ccd82 Fix issue #61: Silence misleading indentation warning.
Add NULL check to pexpi to simplify call sites.
2018-01-22 13:37:09 +01:00
Tor Andersson
849fb89be7 Add recursion overflow check when parsing unary expressions.
Add a recursion counter when we jump to the same grammar clause.
2018-01-15 13:08:31 +01:00
Tor Andersson
228719d087 Remove mention of broken web site. 2018-01-05 14:22:15 +01:00
Tor Andersson
2cb57c6e71 Fix issue #56: MacOS X not detected as a Unix for gettimeofday().
Add ifdef check for __APPLE__ since MacOS X doesn't define __unix__.
1.0.2
2017-12-11 14:15:01 +01:00