Commit graph

631 commits

Author SHA1 Message Date
sin-ack 2e1bbcb0fa LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServer
This change unfortunately cannot be atomically made without a single
commit changing everything.

Most of the important changes are in LibIPC/Connection.cpp,
LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp.

The notable changes are:
- IPCCompiler now generates the decode and decode_message functions such
  that they take a Core::Stream::LocalSocket instead of the socket fd.
- IPC::Decoder now uses the receive_fd method of LocalSocket instead of
  doing system calls directly on the fd.
- IPC::ConnectionBase and related classes now use the Stream API
  functions.
- IPC::ServerConnection no longer constructs the socket itself; instead,
  a convenience macro, IPC_CLIENT_CONNECTION, is used in place of
  C_OBJECT and will generate a static try_create factory function for
  the ServerConnection subclass. The subclass is now responsible for
  passing the socket constructed in this function to its
  ServerConnection base; the socket is passed as the first argument to
  the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before
  any other arguments.
- The functionality regarding taking over sockets from SystemServer has
  been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket
  implementation of this functionality hasn't been deleted due to my
  intention of removing this class in the near future and to reduce
  noise on this (already quite noisy) PR.
2022-01-15 13:29:48 +03:30
Liav A 1716105e73 Tests: Unmap memory ranges on /dev/mem after testing mmap(2) 2022-01-14 19:42:11 +02:00
Ali Mohammad Pur 95b8c1745a AK: Make Variant::visit() prefer overloads accepting T const& over T&
This makes the following code behave as expected:

    Variant<int, String> x { some_string() };
    x.visit(
        [](String const&) {}, // Expectation is for this to be called
        [](auto&) {});
2022-01-14 11:35:40 +03:30
Ali Mohammad Pur 9de33629da AK+Everywhere: Make Variant::visit() respect the Variant's constness
...and fix all the instances of visit() taking non-const arguments.
2022-01-14 11:35:40 +03:30
Andreas Kling 4d0abf82ed Tests: Remove some temporary files when finished using them
Leaving files in /tmp uses memory, which accumulates over time if you do
something weird like leaving `run-tests` going all day long. :^)
2022-01-14 00:20:30 +01:00
sin-ack dbd25916a3 LibCore+Userland+Tests: Convert Stream APIs to construct on heap
As per previous discussion, it was decided that the Stream classes
should be constructed on the heap.

While I don't personally agree with this change, it does have the
benefit of avoiding Function object reconstructions due to the lambda
passed to Notifier pointing to a stale object reference. This also has
the benefit of not having to "box" objects for virtual usage, as the
objects come pre-boxed.

However, it means that we now hit the heap everytime we construct a
TCPSocket for instance, which might not be desirable.
2022-01-13 15:16:12 +03:30
kleines Filmröllchen 594bbbf020 Tests: Test FixedArray completely
Except for tangential accessors such as data(), there is no more feature
of FixedArray that is untested after this large expansion of its test
cases. These tests, with the help of the new NoAllocationGuard, also
test the allocation contract that was fixated in the last commit.

Hopefully this builds confidence in future Kernel uses of FixedArray
as well as its establishment in the real-time parts of the audio
subsystem. I'm excited :^)
2022-01-13 11:17:44 +01:00
kleines Filmröllchen 1d144ed6fc AK: Remove clear() from FixedArray and fixate its allocation guarantees
FixedArray always *almost* had the following allocation guarantees:
There is (possibly) one allocation in the constructor and one (or more)
deallocation(s) in the destructor. No other operation allocates or
deallocates. With this removal of the public clear() method, which
nobody except the test used anyways, those guarantees are now completely
true and furthermore fixated with an explanatory comment.
2022-01-13 11:17:44 +01:00
Timothy Flynn bdf02c21e1 LibUnicode: Swap the preferred order of standard time zone display names
Our generator is currently preferring the DST variant of the time zone
display names over the non-DST variant. LibTimeZone currently does not
have DST support, and operates in a mode that basically assumes DST does
not exist. Swap the display names for now just to be consistent until we
have DST support.

Note we will need to generate both of these variants and select the
appropriate one at runtime once we have DST support.
2022-01-12 15:43:12 +01:00
Timothy Flynn e2dfbe8f67 LibUnicode: Parse and generate long and short generic time zone names
This implements the CalendarPatternStyle::{Long,Short}Generic styles of
time zone name formatting.
2022-01-11 23:56:35 +01:00
Timothy Flynn d50f5e14f8 LibUnicode: Fall back to GMT offset when a time zone name is unavailable
The following table in TR-35 includes a web of fall back rules when the
requested time zone style is unavailable:
https://unicode.org/reports/tr35/tr35-dates.html#dfst-zone

Conveniently, the subset of styles supported by ECMA-402 (and therefore
LibUnicode) all either fall back to GMT offset or to a style that is
unsupported but itself falls back to GMT offset.
2022-01-11 23:56:35 +01:00
Timothy Flynn 8d35563f28 LibUnicode: Implement TR-35's localized GMT offset formatting
This adds an API to use LibTimeZone to convert a time zone such as
"America/New_York" to a GMT offset string like "GMT-5" (short form) or
"GMT-05:00" (long form).
2022-01-11 23:56:35 +01:00
Linus Groh 205d63c3f0 LibTimeZone: Operate in UTC-only mode when !ENABLE_TIME_ZONE_DATA
Instead of only having dummy functions that don't work with any input,
let's at least support one time zone: 'UTC'. This matches the basic
Temporal implementation for engines without ECMA-262, for example.
2022-01-11 22:17:39 +01:00
Andreas Kling a4b4b358ff AK+Kernel: Remove one_ref_left() footgun
This mechanism was unsafe to use in any multithreaded context, since
the hook function was invoked on a raw pointer *after* decrementing
the local ref count.

Since we don't use it for anything anymore, let's just get rid of it.
2022-01-11 01:12:16 +01:00
Timothy Flynn 09c0324880 LibTimeZone: Begin generating GMT offset rules for each time zone
This is a rather naive implementation, but serves as a first pass at
determining the GMT offset for a time zone at a particular point in
time. This implementation ignores DST (because we are not parsing any
RULE entries yet), and ignores any offset patterns of the form "Mon>4"
or "lastSun".
2022-01-11 00:36:45 +01:00
Timothy Flynn e9c42d0bc5 LibTimeZone: Add methods to canonicalize a time zone name 2022-01-11 00:36:45 +01:00
Timothy Flynn 1c2c98ac5d LibTimeZone: Add method to convert a time zone to a string 2022-01-11 00:36:45 +01:00
Timothy Flynn 14535fb67a LibTimeZone: Perform time-zone-from-string lookups case insensitively
Time zone names in the TZDB are defined to be case insensitive.
2022-01-11 00:36:45 +01:00
Timothy Flynn b493c2ca90 LibTimeZone: Add a unit test for generated time zone data 2022-01-11 00:36:45 +01:00
Timothy Flynn 3dccaa39d8 AK: Define a traits helper for case-insensitive StringView hashing
Currently, we define a CaseInsensitiveStringTraits structure for String.
Using this structure for StringView involves allocating a String from
that view, and a second string to convert that intermediate string to
lowercase.

This defines CaseInsensitiveStringViewTraits (and the underlying helper
case_insensitive_string_hash) to avoid allocations.
2022-01-11 00:36:45 +01:00
creator1creeper1 3c05261611 AK+Everywhere: Make FixedArray OOM-safe
FixedArray now doesn't expose any infallible constructors anymore.
Rather, it exposes fallible methods. Therefore, it can be used for
OOM-safe code.
This commit also converts the rest of the system to use the new API.
However, as an example, VMObject can't take advantage of this yet,
as we would have to endow VMObject with a fallible static
construction method, which would require a very fundamental change
to VMObject's whole inheritance hierarchy.
2022-01-08 22:54:05 +01:00
Simon Woertz d8013f9c3a Tests: Add test cases for #10702 and #10717
Add test cases for parsing an empty file and a truncated file.
2022-01-08 18:57:55 +01:00
Simon Woertz 07a557194c Tests: Add base structure for LibPDF unit tests
Add a unit test for each sample pdf file that currently exists in the
anon user's `~/Document/pdf` directory.
- linear.pdf
- non-linearized.pdf
- complex.pdf

Each test ensures that the pdf document is parsed and that the page
count is the expected one.
2022-01-08 18:57:55 +01:00
Liav A ca254699ec Kernel: Implement read functionality for MemoryDevice
So far we only had mmap(2) functionality on the /dev/mem device, but now
we can also do read(2) on it.

The test unit was updated to check we are doing it safely.
2022-01-08 13:21:16 +02:00
mjz19910 10ec98dd38 Everywhere: Fix spelling mistakes 2022-01-07 15:44:42 +01:00
Schlufi 55a7738837 AK: Use a full-period xorshift PRNG for double_hash
The previous implementation had some pretty short cycles and two fixed
points (1711463637 and 2389024350). If two keys hashed to one of these
values insertions and lookups would loop forever.
This version is based on a standard xorshift PRNG with period 2**32-1.
The all-zero state is usually forbidden, so we insert it into the cycle
at an arbitrary location.
2022-01-07 12:34:44 +01:00
mjz19910 3102d8e160 Everywhere: Fix many spelling errors 2022-01-07 10:56:59 +01:00
Guilherme Gonçalves f91d471843 LibSQL: Implement LIKE SQL expressions 2022-01-07 10:50:39 +03:30
Guilherme Gonçalves e957c078d5 LibSQL: Properly parse ESCAPE expressions
The evaluation order of method parameters is unspecified in C++, and
so we couldn't rely on parse_statement() being called before
parse_escape() when building a MatchExpression.

With this patch, we explicitly parse what we need in the right order,
before building the MatchExpression object.
2022-01-07 10:50:39 +03:30
Timothy Flynn 6d7d9dd324 LibUnicode: Do not assume time zones & meta zones have a 1-to-1 mapping
The generator parses metaZones.json to form a mapping of meta zones to
time zones (AKA "golden zone" in TR-35). This parser errantly assumed
this was a 1-to-1 mapping.
2022-01-06 22:28:01 +01:00
NHOrus f5025c5cb3 AK: Ensure negative predicate in TestHashMap could run unsuccessfully
As it was, negative predicate test for remove_all_matching was
run on empty hash map, and could not remove anything, so test always
returned true. By duplicating it in state where hash maps contains
elements, we make sure that negative predicate has something to
do nothing on.
2022-01-06 22:24:01 +01:00
Andreas Kling 8f5c1ef29c AK: Improve HashTable::remove_all_matching() test slightly
After removing some entries, we now also verify that the correct
entries remain in the table. :^)
2022-01-05 18:57:14 +01:00
Andreas Kling 558fb0a04a AK: Make Vector::remove_all_matching() return removal success
This matches the behavior of other remove_*_matching() functions.
2022-01-05 18:57:14 +01:00
Andreas Kling 5279a04c78 AK: Make Hash{Map,Table}::remove_all_matching() return removal success
These functions now return whether one or more entries were removed.
2022-01-05 18:57:14 +01:00
Andreas Kling 376e5ef912 AK: Add HashMap::remove_all_matching(predicate)
This removes all matching entries from a hash map in a single pass.
2022-01-05 18:57:14 +01:00
Andreas Kling 54cf42fac1 AK: Add HashTable::remove_all_matching(predicate)
This removes all matching entries from a table in a single pass.
2022-01-05 18:57:14 +01:00
Timothy Flynn ffb3ba3079 Tests: Link some tests directly against LibUnicodeData
These were missed in 565a880ce5.

This wasn't an issue because these tests don't pledge/unveil anything,
so they could happily dlopen() the library at runtime. But this is now
needed in order to migrate LibUnicode towards weak symbols instead.
2022-01-04 22:49:43 +00:00
Jelle Raaijmakers 8da0925d6d AK: Add mix 2022-01-04 17:48:28 +00:00
sin-ack db36bdfeb7 Tests: Add floor and ceil tests to test-math
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
2022-01-02 12:44:31 +03:30
Jesse Buhagiar 2de7f2021d LibC: Support X modifier for scanf
This was currently crashing Half-Life because it was a considered an
"Unknown" specifier. We can use the same case statement as the regular
hex format conversion (lower case 'x'), as the backend
to convert the number already supports upper/lower case input, hence
we get it for free :^)
2022-01-02 08:10:08 +02:00
Xavier Defrang 8b95423b50 LibCore: Add FilePermissionsMask
This class parses UNIX file permissions definitions in numeric (octal)
or symbolic (ugoa+rwx) format and can apply them on a given file mode.
2022-01-01 17:33:43 +00:00
Daniel Bertalan ad57289307 Tests/LibCore: Add regression test for the read_until_any_of OOB read 2022-01-01 14:44:02 +01:00
Linus Groh a6476ad61f test-wasm: Convert WebAssemblyModule::create() to ThrowCompletionOr
This exposed a missing exception check in parseWebAssemblyModule(),
which could throw but still return a normal completion (which currently
works as we check VM::exception() at the right point, but breaks when
moving everything to exceptions).
2021-12-31 15:01:16 +01:00
davidot 676554d3f8 LibJS: Convert resolve_binding() to ThrowCompletionOr
The spec has a note stating that resolve binding will always return a
reference whose [[ReferencedName]] field is name. However this is not
correct as the underlying method GetIdentifierReference may throw on
env.HasBinding(name) thus it can throw. However, there are some
scenarios where it cannot throw because the reference is known to exist
in that case we use MUST with a comment.
2021-12-30 15:29:33 +01:00
davidot 56c425eec1 LibJS: Detect invalid unicode and stop lexing at that point
Previously we might swallow invalid unicode point which would skip valid
ascii characters. This could be dangerous as we might skip a '"' thus
not closing a string where we should.
This might have been exploitable as it would not have been clear what
code gets executed when looking at a script.

Another approach to this would be simply replacing all invalid
characters with the replacement character (this is what v8 does). But
our lexer and parser are currently not set up for such a change.
2021-12-29 16:57:23 +01:00
Andreas Kling 5d55a42ded LibCore: Fix race conditions in TestLibCoreStream
It was possible for the "local_socket_read" and "local_socket_write"
tests to fail because we had exited the EventLoop before
BackgroundAction got around to invoking the completion callback.

The crash happened when trying to deferred_invoke() on the background
thread, calling Core::EventLoop::current() after said EventLoop had
returned from exec().

Fix this by not passing a completion callback, since we didn't need
one in the first place.
2021-12-28 01:02:35 +01:00
Sam Atkins 8600d89407 LibCore+Services: Make TCPServer propagate errors 2021-12-27 22:00:01 +01:00
Ali Mohammad Pur 1a35e27490 LibRegex: Make FailForks fail all forks up to the last save point
This makes negative lookarounds with more than one fork behave
correctly.
Fixes #11350.
2021-12-25 18:41:10 +01:00
Michel Hermier 4758dac218 AK: Make Disjoint*::is_empty() not call size
This is a raffinement of 49cbd4dcca.

Previously, the container was scanned to compute the size in the unhappy
path. Now, using `all_of` happy and unhappy path should be fast.
2021-12-24 05:55:34 -08:00
Michel Hermier 44a6d7968a Tests: Benchmark DisjointChunck::is_empty 2021-12-24 05:55:34 -08:00
Michel Hermier 682f89d5bc LibC: Allow multiple includes of <assert.h>
ISO C requires in section 7.2:
The assert macro is redefined according to the current state of NDEBUG
each time that <assert.h> is included.

Also add tests for `assert` multiple inclusion accordingly.
2021-12-23 17:53:46 -08:00
Xavier Defrang 9e97823ff8 AK: Add convert_to_uint_from_octal 2021-12-21 13:13:04 -08:00
davidot 154ed3994c LibRegex: Parse capture group names according to the ECMA262 spec 2021-12-21 14:04:23 +01:00
davidot 733a70671b LibRegex: Disallow duplicate named capture groups in ECMA262 parser 2021-12-21 14:04:23 +01:00
Liav A 5a649d0fd5 Kernel: Return EINVAL when specifying -1 for setuid and similar syscalls
For setreuid and setresuid syscalls, -1 means to set the current
uid/euid/gid/egid value, to be more convenient for programming.
However, for other syscalls where we pass only one argument, there's no
justification to specify -1.

This behavior is identical to how Linux handles the value -1, and is
influenced by the fact that the manual pages for the group of one
argument syscalls that handle ID operations is ambiguous about this
topic.
2021-12-20 11:32:16 +01:00
Michel Hermier 7a44c11378 LibTest: Add EXPECT_NO_CRASH 2021-12-19 14:22:06 -08:00
Michel Hermier 4c6e826c05 LibTest: Add EXPECT_CRASH_WITH_SIGNAL 2021-12-19 14:22:06 -08:00
Michel Hermier c22c1900c0 Tests: Add test for raise 2021-12-19 14:22:06 -08:00
Michel Hermier 0ec35d6d81 Tests: Add test for assert 2021-12-19 14:22:06 -08:00
Michel Hermier 181f759dc9 Tests: Add test for abort 2021-12-19 14:22:06 -08:00
Nick Johnson 548529ace4 AK: Add BuiltinWrappers.h
The goal of this file is to enable C++ overloaded functions for
standard builtin functions that we use. It contains fallback
implementations for systems that do not have the builtins available.
2021-12-18 23:36:08 +01:00
Andreas Kling a409b832fa AK: Make JsonValue::from_string("") return a null JsonValue
This unbreaks the /var/run/utmp system which starts out as an empty
string, and is then turned into an object by the first update.

This isn't necessarily the best way for this to work, but it's how
it used to work, so this just fixes the regression for now.
2021-12-16 22:48:17 +01:00
sin-ack 2341b0159a Tests: Implement tests for the Serenity Stream API 2021-12-16 22:21:35 +03:30
Ben Wiederhake 208d85e707 AK+Tests: Use less space in ErrorOr 2021-12-16 09:32:51 +01:00
Ali Mohammad Pur d2e51fafa9 LibRegex: Merge alternations based on blocks and not instructions
The instructions can have dependencies (e.g. Repeat), so only unify
equal blocks instead of consecutive instructions.
Fixes #11247.

Also adds the minimal test case(s) from that issue.
2021-12-15 19:36:45 +03:30
Sahan Fernando 2c43eaa50c LibCore: Add support for range-based for loops on LineIterators 2021-12-12 14:06:38 +03:30
Idan Horowitz 8d3faecd9b Tests: Add tests for sigwait/sigwaitinfo/sigtimedwait 2021-12-12 08:34:19 +02:00
Ben Wiederhake 18ae5ede88 LibCrypto+Tests: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Ben Wiederhake 768b70cc4d AK+Tests: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Sam Atkins 9e3a786a64 Tests: Cast unused smart-pointer return values to void 2021-12-05 15:31:03 +01:00
Jan de Visser c369626ac1 LibSQL: Gracefully react to unimplemented valid SQL
Fixes a crash that was caused by a syntax error which is difficult to
catch by the parser: usually identifiers are accepted in column lists,
but they are not in a list of column values to be inserted in an INSERT.

Fixed this by putting in a heuristic check; we probably need a better
way to do this.

Included tests for this case.

Also introduced a new SQL Error code, `NotYetImplemented`, and return
that instead of crashing when encountering unimplemented SQL.
2021-12-04 20:49:22 +03:30
Jan de Visser 001949d77a LibSQL: Improve error handling
The handling of filesystem level errors was basically non-existing or
consisting of `VERIFY_NOT_REACHED` assertions. Addressed this by
* Adding `open` methods to `Heap` and `Database` which return errors.
* Changing the interface of methods of these classes and clients
downstream to propagate these errors.

The constructors of `Heap` and `Database` don't open the underlying
filesystem file anymore.

The SQL statement handlers return an `SQLErrorCode::InternalError`
error code if an error comes back from the lower levels. Note that some
of these errors are things like duplicate index entry errors that should
be caught before the SQL layer attempts to actually update the database.

Added tests to catch attempts to open weird or non-existent files as
databases.

Finally, in between me writing this patch and submitting the PR the
AK::Result<Foo, Bar> template got deprecated in favour of ErrorOr<Foo>.
This resulted in more busywork.
2021-12-04 20:49:22 +03:30
Idan Horowitz 246255527a Tests: Add a test to ensure sigaltstack() is working correctly 2021-12-01 21:44:11 +02:00
Timothy Flynn 7e6ad172a4 LibUnicode: Support code point names that apply to ranges of code points
For example, consider the following adjacent entries in UnicodeData.txt:

    3400;<CJK Ideograph Extension A, First>;Lo;0;L;;;;;N;;;;;
    4DBF;<CJK Ideograph Extension A, Last>;Lo;0;L;;;;;N;;;;;

Our current implementation would assign the display name "CJK Ideograph
Extension A" to code points U+3400 & U+4DBF, but not to the code points
in between. Not only should those code points be assigned a name, but
the Unicode spec also has formatting rules on what the names should be
(the names for these ranged code points are not as they appear in
UnicodeData.txt).

The spec also defines names for code point ranges that actually are
listed individually in UnicodeData.txt. For example:

    2F800;CJK COMPATIBILITY IDEOGRAPH-2F800;Lo;0;L;4E3D;;;;N;;;;;
    2F801;CJK COMPATIBILITY IDEOGRAPH-2F801;Lo;0;L;4E38;;;;N;;;;;
    2F802;CJK COMPATIBILITY IDEOGRAPH-2F802;Lo;0;L;4E41;;;;N;;;;;

Code points are only coalesced into a range if all fields after the name
are equivalent. Our parser will insert the range and its name formatting
pattern when it comes across the first code point in that range, then
ignore other code points in that range. This reduces the number of names
we generated by nearly 2,000.
2021-11-30 11:24:02 +01:00
Arne Elster cdaa179eeb LibCore: Fix relative seeking in IODevice
The recently introduced read buffer in IODevice broke relative seeking.
The amount of data in the buffer wouldn't get taken into account.
2021-11-30 10:51:10 +01:00
Hendiadyoin1 7a27ecc135 Tests: Add a simple LibGL render-test
At the moment we just check if we *can* render a simple triangle, we do
not yet actually test if the image is indeed the triangle we wanted.

This test also outputs the rendered image when GL_DEBUG is enabled to a
file called "picture.bmp" for manual verification.

Co-authored-by: sunverwerth <s.unverwerth@serenityos.org>
2021-11-29 23:17:05 +03:30
Brian Gianforcaro 95c0ec9afc Tests: Fix TestLibCoreArgsParser with add_positional_argument API change
Since we no longer populate a Vector<String> the lifetime of the strings
in all of these tests is now messed up, as the Vector<StringView> now
points to free'd memory.

We attempt to fix this for the unit tests, by saving the results in a
RAII type that should live as long as the test wants to validate some
output of the ArgParser.
2021-11-26 18:57:26 -08:00
Andreas Kling f1cc3d0fc4 Userland: Use Core::ArgsParser's Vector<StringView> API everywhere
...and remove the Vector<String> variant since there are no remaining
users of this API.
2021-11-26 23:27:57 +01:00
Andreas Kling 58fb3ebf66 LibCore+AK: Move MappedFile from AK to LibCore
MappedFile is strictly a userspace thing, so it doesn't belong in AK
(which is supposed to be user/kernel agnostic.)
2021-11-23 11:33:36 +01:00
Andreas Kling 5a79c69b02 LibGfx: Make ImageDecoderPlugin::frame() return ErrorOr<>
This is a first step towards better error propagation from image codecs.
2021-11-21 20:22:48 +01:00
Timothy Flynn 93ee922027 LibUnicode: Support locales-without-script aliases for ECMA-402
As noted by ECMA-402, if a supported locale contains all of a language,
script, and region subtag, then the implementation must also support the
locale without the script subtag. The most complicated example of this
is the zh-TW locale.

The list of locales in the CLDR database does not include zh-TW or its
maximized zh-Hant-TW variant. Instead, it inlcudes the zh-Hant locale.
However, zh-Hant-TW is listed in the default-content locale list in the
cldr-core package. This defines an alias from zh-Hant-TW to zh-Hant. We
must then also support the zh-Hant-TW alias without the script subtag:
zh-TW. This transitively maps zh-TW to zh-Hant, which is a case quite
heavily tested by test262.
2021-11-19 11:45:35 +01:00
Jelle Raaijmakers dfbdd035da AK: Implement acos<T> correctly
This is a naive implementation based on the symmetry with `asin`.

Before, I'm not really sure what we were doing, but it was returning
wildly incorrect results.
2021-11-18 21:10:30 +01:00
Ali Mohammad Pur 387df06385 LibRegex: Avoid rewriting a+ as a* as part of atomic rewriting
The initial `ForkStay` is only needed if the looping block has a
following block, if there's no following block or the following block
does not attempt to match anything, we should not insert the ForkStay,
otherwise we would be rewriting `a+` as `a*` by allowing the 'end' to be
executed.
Fixes #10952.
2021-11-18 09:09:22 +01:00
Andreas Kling 216e21a1fa AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk.
The end goal here is to propagate buffer allocation failures to the
caller, and allow the use of TRY() with formatting functions.
2021-11-17 00:21:13 +01:00
Andreas Kling 587f9af960 AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string
literal with returned errors.

This will allow us to use TRY() when working with JSON data.
2021-11-17 00:21:10 +01:00
Linus Groh 58c6a156bf LibCrypto: Fix subtracting two negative SignedBigIntegers
Currently, we get the following results

    -1 - -2 = -1
    -2 - -1 =  1

Correct would be:

    -1 - -2 =  1
    -2 - -1 = -1

This was already attempted to be fixed in 7ed8970, but that change was
incorrect. This directly translates to LibJS BigInts having the same
incorrect behavior - it even was tested.
2021-11-16 10:06:53 +00:00
Tim Schumacher 8417c0fb1e Tests/LibRegex: Add tests for line end anchors in PosixBasic 2021-11-13 15:06:52 +03:30
Andreas Kling 09780ba7a9 Tests/LibGfx: Actually test image decoders in TestImageDecoder
We were passing raw Gfx::Bitmap objects into the various image decoders
instead of encoded image data. This made all of them fail, but the test
expectations were set up in a way that aligned with this outcome.

With this patch, we now test the codecs for real. Except ICO, since we
don't have an ICO file handy. That's a FIXME.
2021-11-11 11:20:58 +01:00
Andreas Kling 8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling a15ed8743d AK: Make ByteBuffer::try_* functions return ErrorOr<void>
Same as Vector, ByteBuffer now also signals allocation failure by
returning an ENOMEM Error instead of a bool, allowing us to use the
TRY() and MUST() patterns.
2021-11-10 21:58:58 +01:00
Andreas Kling 5f7d008791 AK+Everywhere: Stop including Vector.h from StringView.h
Preparation for using Error.h from Vector.h. This required moving some
things out of line.
2021-11-10 21:58:58 +01:00
Jan de Visser 3425730294 LibSQL: Implement table joins
This patch introduces table joins. It uses a pretty dumb algorithm-
starting with a singleton '__unity__' row consisting of a single boolean
value, a cartesian product of all tables in the 'FROM' clause is built.
This cartesian product is then filtered through the 'WHERE' clause,
again without any smarts just using brute force.

This patch required a bunch of busy work to allow for example the
ColumnNameExpression having to deal with multiple tables potentially
having columns with the same name.
2021-11-10 14:47:49 +01:00
Jan de Visser 1c50e9aadc LibSQL: Add current statement to the ExecutionContext
Because SQL is the craptastic language that it is, sometimes expressions
need to know details about the calling statement. For example the tables
in the 'FROM' clause may be needed to determine which columns are
referenced in 'WHERE' expressions. So the current statement is added
to the ExecutionContext and a new 'execute' overload on Statement is
created which takes the Database and the Statement and builds an
ExecutionContaxt from those.
2021-11-10 14:47:49 +01:00
Jan de Visser 7ea54db430 LibSQL: Add 'schema' and 'table' to TupleElementDescriptor
These are needed to distinguish columns from different tables with the
same column name in one and the same (joined) Tuple. Not quite happy
yet with this API; I think some sort of hierarchical structure would be
better but we'll burn that bridge when we get there :^)
2021-11-10 14:47:49 +01:00
Timothy Flynn 357c97dfa8 LibUnicode: Parse the CLDR's defaultContent.json locale list
This file contains the list of locales which default to their parent
locale's values. In the core CLDR dataset, these locales have their own
files, but they are empty (except for identity data). For example:

https://github.com/unicode-org/cldr/blob/main/common/main/en_US.xml

In the JSON export, these files are excluded, so we currently are not
recognizing these locales just by iterating the locale files.

This is a prerequisite for upgrading to CLDR version 40. One of these
default-content locales is the popular "en-US" locale, which defaults to
"en" values. We were previously inferring the existence of this locale
from the "en-US-POSIX" locale (many implementations, including ours,
strip variants such as POSIX). However, v40 removes the "en-US-POSIX"
locale entirely, meaning that without this change, we wouldn't know that
"en-US" exists (we would default to "en").

For more detail on this and other v40 changes, see:
https://cldr.unicode.org/index/downloads/cldr-40#h.nssoo2lq3cba
2021-11-09 20:44:52 +01:00
Andreas Kling a7f1f1c34b LibCore: Use ErrorOr<T> for Core::File::open() 2021-11-08 00:35:27 +01:00
Andreas Kling 0de33b3d6c LibGfx: Use ErrorOr<T> for Bitmap::try_create()
Another one that was used in a fajillion places.
2021-11-08 00:35:27 +01:00
Andreas Kling a54be656ae LibRegex: Don't push LibRegex's "Error" into the global namespace 2021-11-08 00:35:27 +01:00
Idan Horowitz 390a04a985 LibJS: Convert the GetValue AO to ThrowCompletionOr 2021-11-02 19:48:35 +01:00
Idan Horowitz d73b258874 LibJS: Convert reference deletion to ThrowCompletionOr 2021-11-02 19:48:35 +01:00
Ben Wiederhake f20a42e871 Kernel: Write test that crashes ProcFS 2021-10-31 18:44:12 +01:00
Idan Horowitz 10b93506ad Tests: Convert test-wasm functions to ThrowCompletionOr 2021-10-31 18:20:37 +02:00
Daniel Bertalan fed9cb5d2d AK+Tests: Fix formatting of infinity and NaN values
When I added this code in 1472f6d, I forgot to add tests for it. That's
why I didn't realize that the values were appended to the wrong
FormatBuilder object, so an empty string was returned instead of the
expected "nan"/"inf". This made debugging some FPU issues with the
ScummVM port significantly more difficult.
2021-10-31 12:15:34 +01:00
Ali Mohammad Pur ac856cb965 LibRegex: Don't ignore empty alternatives in append_alternation()
Doing so would cause patterns like `(a|)` to not match the empty string.
2021-10-29 15:57:59 +02:00
Liav A 8554952690 Kernel + WindowServer: Re-define the interface to framebuffer devices
We create a base class called GenericFramebufferDevice, which defines
all the virtual functions that must be implemented by a
FramebufferDevice. Then, we make the VirtIO FramebufferDevice and other
FramebufferDevice implementations inherit from it.
The most important consequence of rearranging the classes is that we now
have one IOCTL method, so all drivers should be committed to not
override the IOCTL method or make their own IOCTLs of FramebufferDevice.
All graphical IOCTLs are known to all FramebufferDevices, and it's up to
the specific implementation whether to support them or discard them (so
we require extensive usage of KResult and KResultOr, together with
virtual characteristic functions).
As a result, the interface is much cleaner and understandable to read.
2021-10-27 07:57:44 +03:00
Jan de Visser 7496f17620 LibSQL Tests: Add tests for SELECT ... WHERE ... 2021-10-25 12:59:42 +02:00
Jelle Raaijmakers a44978b9b0 LibC: Fix %n conversion specifier in scanf() format
Also add a test to prevent this from happening again. There were two
bugs:

* The number of bytes just after processing the last value was written,
  instead of the number of bytes after skipping remaining whitespace.
  Confirmed by testing against GNU's `scanf()` since the man page
  leaves something to be desired.

* The number of bytes was written to the wrong variable argument; i.e.
  the first argument was overwritten.
2021-10-24 22:43:27 -07:00
Jelle Raaijmakers 00f36fc5ae Tests: Print full 32-byte range of values in TestScanf
We are trying to show 8 u32 values, each of which needs at most 8
hexadecimal characters to be shown entirely.
2021-10-24 22:43:27 -07:00
Jelle Raaijmakers e71e9de61f Tests: Reword 'output' to 'return value' in TestScanf 2021-10-24 22:43:27 -07:00
Jelle Raaijmakers e3f17401cb Tests: Use correct argument count for value conformance in TestScanf 2021-10-24 22:43:27 -07:00
Tim Schumacher 65bcee3c62 Tests: Only test truthiness for iswctype 2021-10-24 22:40:11 -07:00
Tim Schumacher 9e3e4a692d Tests: Use proper comparison macros for wctype 2021-10-24 22:40:11 -07:00
Ben Wiederhake cb868cfa41 AK+Everywhere: Make Base64 decoding fallible 2021-10-23 19:16:40 +01:00
Ben Wiederhake 3bf1f7ae87 AK: Don't crash on invalid Base64 input
In the long-term, we should probably have a way to signal decoding
failure. For now, it should suffice to at least not crash. This is
particularly relevant because apparently this can be triggered while
parsing a PEM certificate, which happens during every TLS connection.

Found by OSS Fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38979
2021-10-23 19:16:40 +01:00
Tim Schumacher 79bcfa967b LibC: Fix up mblen 2021-10-22 13:28:56 -07:00
Tim Schumacher 8df6955838 LibC: Fix up mbtowc
One more proper implementation and one less FIXME.
2021-10-22 13:28:56 -07:00
Liav A cf0dbc9069 Tests: Add a unit test to ensure the /dev/mem device works correctly
To ensure everything works as expected, a unit test was added with
multiple scenarios.
This binary has to have the SetUID flag, and we also bind-mount the
/usr/Tests directory to allow running of SetUID binaries.
2021-10-22 13:13:00 +02:00
Tim Schumacher 89afd4d063 LibC: Implement mbsnrtowcs 2021-10-21 23:57:32 -07:00
Tim Schumacher 552ae77f0d LibC: Implement wcsnrtombs 2021-10-21 23:57:32 -07:00
Tim Schumacher e618602433 LibC: Implement mbrlen 2021-10-21 23:47:20 -07:00
Idan Horowitz 44555eb50a LibJS: Convert test-js/test-web/test-wasm to ThrowCompletionOr 2021-10-20 12:27:19 +01:00
Idan Horowitz 40eb3a39d4 LibJS: Rename define_native_function => define_old_native_function
This method will eventually be removed once all native functions are
converted to ThrowCompletionOr
2021-10-20 12:27:19 +01:00
Idan Horowitz 20163c0584 LibJS: Add ThrowCompletionOr versions of the JS native function macros
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and
JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all
native functions were converted to the new format.
2021-10-20 12:27:19 +01:00
Daniel Bertalan 48687c3fbb Tests: Remove Clang workaround from TestSourceLocation
Clang 13 now correctly handles `__builtin_FILE()` and
`-ffile-prefix-map` being specified together, so this test should fully
pass.
2021-10-17 17:09:58 +01:00
Daniel Bertalan 13e6d9d71a LibC: Implement wcslcpy 2021-10-17 17:09:58 +01:00
Idan Horowitz 1639ed7e0a LibJS: Convert to_double() to ThrowCompletionOr 2021-10-17 12:12:35 +01:00
Idan Horowitz df181809fd LibJS: Convert to_bigint_int64() to ThrowCompletionOr 2021-10-17 12:12:35 +01:00
Tim Schumacher 420bdccf0b LibC: Implement mbsrtowcs 2021-10-15 21:50:19 -07:00
Tim Schumacher b0babd062e LibC: Implement wcsrtombs 2021-10-15 21:50:19 -07:00
Daniel Bertalan c8367df746 LibC: Implement wcrtomb
This function converts a single wide character into its multibyte
representation (UTF-8 in our case). It is called from libc++'s
`std::basic_ostream<wchar_t>::flush`, which gets called at program exit
from a global destructor in order to flush `std::wcout`.
2021-10-15 21:50:19 -07:00
Tim Schumacher 4b423a5ec7 LibC: Implement twalk 2021-10-15 21:50:19 -07:00
Tim Schumacher 7448626bae LibC: Implement tfind and tsearch 2021-10-15 21:50:19 -07:00
Linus Groh 52976bfac6 LibJS: Convert to_object() to ThrowCompletionOr 2021-10-13 09:55:10 +01:00
Linus Groh 4d8912a92b LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
2021-10-13 09:55:10 +01:00
Ben Wiederhake 50ad294527 AK: Implement a way to resolve relative paths lexically 2021-10-10 15:18:55 -07:00
Nico Weber 96666f3209 Tests: Fix -Wunreachable-code warnings from clang 2021-10-08 23:33:46 +02:00
Andreas Kling fc36f830ae Tests: Disable LibThreading detach tests for now
These tests don't pass (at least not without KVM) at the moment,
so let's not run them on CI.
2021-10-06 19:21:35 +02:00
Junior Rantila 1552873275 Tests: Add LibThreading to CMakeLists.txt 2021-10-06 19:05:39 +02:00
Rodrigo Tobar 4b091a7cc2 LibELF: Fix dynamic linking of dlopen()-ed libs
Consider the situation where two shared libraries libA and libB, both
depending (as in having a NEEDED dtag) on libC. libA is first
dlopen()-ed, which produces libC to be mapped and linked. When libB is
dlopen()-ed the DynamicLinker would re-map and re-link libC though,
causing any previous references to its old location to be invalid. And
if libA's PLT has been patched to point to libC's symbols, then any
further invocations to libA will cause the code to jump to a virtual
address that isn't mapped anymore, therefore causing a crash. This
situation was reported in #10014, although the setup was more convolved
in the ticket.

This commit fixes the issue by distinguishing between a main program
loading being performed by Loader.so, and a dlopen() call. The main
difference between these two cases is that in the former the
s_globals_objects maps is always empty, while in the latter it might
already contain dependencies for the library being dlopen()-ed. Hence,
when collecting dependencies to map and link, dlopen() should skip those
that are present in the global map to avoid the issue described above.

With this patch the original issue seen in #10014 is gone, with all
python3 modules (so far) loading correctly.

A unit test reproducing a simplified issue is also included in this
commit. The unit test includes the building of two dynamic libraries A
and B with both depending on libline.so (and B also depending on A); the
test then dlopen()s libA, invokes one its function, then does the same
with libB.
2021-10-06 12:33:21 +02:00
Mahmoud Mandour 0e5b2c923d LibSQL: Add an INSERT without column names test
This adds a passing test of an insert statement that contains no column
names and assumes full tuple input
2021-10-04 15:51:48 +02:00
Mahmoud Mandour 235573f7ba LibSQL: Test INSERT statement with wrong number of values 2021-10-04 15:51:48 +02:00
Mahmoud Mandour 4df85840c3 LibSQL: Test INSERT statement with wrong data types 2021-10-04 15:51:48 +02:00
Mahmoud Mandour 6065383e05 LibSQL: Check NoError individually in execution tests
This enables tests to check that a statement is erroneous, we could not
do so by only calling `execute()` since it asserted that no errors
occurred.
2021-10-04 15:51:48 +02:00
Tim Schumacher 7af7fc8c16 Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
Ali Mohammad Pur 8f722302d9 LibRegex: Use a match table for character classes
Generate a sorted, compressed series of ranges in a match table for
character classes, and use a binary search to find the matches.
This is about a 3-4x speedup for character class match performance. :^)
2021-10-03 19:16:36 +02:00
davidot ac2c3a73b1 LibJS: Add a specific test for invalid unicode characters in the lexer
Also fixes that it tried to make substrings past the end of the source
if we overran the source length.
2021-10-03 17:42:05 +02:00
Tim Schumacher 4302e7ac26 Tests: Add tests for mbrtowc 2021-10-03 11:13:50 +00:00
Tim Schumacher 67a579aab0 AK: Add a basic formatter for wchar_t 2021-10-03 11:13:50 +00:00
Tim Schumacher e7f99edefa Tests: Add a test for mbsinit 2021-10-03 11:13:50 +00:00
Tim Schumacher 05b283f552 LibC: Implement wmemmove 2021-10-03 05:28:51 +00:00
Tim Schumacher fa1208edfd LibC: Implement wmemset 2021-10-03 05:28:51 +00:00
Tim Schumacher 485c0ef691 LibC: Implement wmemcpy 2021-10-03 05:28:51 +00:00
Tim Schumacher 0ca1df4dc6 LibC: Implement wmemchr 2021-10-03 05:28:51 +00:00
Tim Schumacher 5ac2e84264 LibC: Implement wcsstr 2021-10-03 05:28:51 +00:00
Tim Schumacher 1b078f87b7 LibC: Implement wcspbrk 2021-10-03 05:28:51 +00:00
Liav A 4974727dbb Kernel: Move x86 IO instructions code into the x86 specific folder 2021-10-01 12:27:20 +02:00
Nico Weber 841a5fe81b Tests: Fix typos 2021-10-01 01:33:43 +01:00
davidot ce3f29a135 LibJS + test-js: Get results from the global object directly
This is as the spec would require you to do it and necessary for changes
to come in the following commits.
2021-09-30 08:16:32 +01:00
Rodrigo Tobar a8fae3d2c8 LibPthread: Add first test cases for RWlock 2021-09-28 18:36:20 +03:30
Andreas Kling f67648f872 LibWeb: Rename HTMLDocumentParser => HTMLParser 2021-09-25 23:36:43 +02:00
Ben Wiederhake 743470c8f2 AK: Introduce ability to default-initialize a Variant
I noticed that Variant<Empty, …> is a somewhat common pattern while
working on #10080, and this will simplify a few use-cases. :^)
2021-09-21 04:22:52 +04:30
Ali Mohammad Pur 436693c0c9 LibTLS: Use a setter for on_tls_ready_to_write with some more smarts
The callback should be called as soon as the connection is established,
and if we actually set the callback when it already is, we expect it to
be called immediately.
2021-09-19 21:10:23 +04:30
thankyouverycool 41ce6d0cd0 Tests: Conform font tests to new font format 2021-09-19 00:58:59 +02:00
Andreas Kling 1be4cbd639 AK: Make Utf8View constructors inline and remove C string constructor
Using StringView instead of C strings is basically always preferable.
The only reason to use a C string is because you are calling a C API.
2021-09-18 19:54:24 +02:00
Tim Schumacher b8c756a53a LibC: Primitively implement wcscoll
At the moment, sorting like LC_COLLATE=C would do is better than
nothing.
2021-09-18 02:57:56 +00:00
Tim Schumacher 42031f026a LibC: Implement towctrans 2021-09-17 22:59:51 +00:00
Tim Schumacher 8c7b566629 LibC: Implement iswctype 2021-09-17 22:59:51 +00:00
Tim Schumacher ff0ab8b9a9 LibC: Implement wctrans 2021-09-17 22:59:51 +00:00
Tim Schumacher 7b17230d7a LibC: Implement wctype 2021-09-17 22:59:51 +00:00
Ben Wiederhake 5f0f0ac413 crash: Don't test for qemu-unsupported feature
See #10042 for details. In short: qemu doesn't seem to implement that
feature, therefore the test correctly fails. However, that does not help
us, so we skip that test.
2021-09-16 20:51:24 +00:00
Ben Wiederhake c680ef0a09 crash: Run automatically during CI 2021-09-16 20:51:24 +00:00
Andrew Kaster 6e7cc40b18 Meta: Add Meta/CMake to the CMAKE_MODULE_PATH for Serenity and Lagom
This makes it so we don't need to specify the full path to all the
helper scripts we include() from different places in the codebase and
feels a lot cleaner.
2021-09-15 19:04:52 +04:30
Ali Mohammad Pur 741886a4c4 LibRegex: Make the optimizer understand references and capture groups
Otherwise the fork in patterns like `(1+)\1` would be (incorrectly)
optimized away.
2021-09-15 15:52:28 +04:30
Andreas Kling 0a09eaf3a1 LibJS+LibTest: Use JS::Script and JS::SourceTextModule in test-js
Instead of creating a Parser and Lexer manually in test-js, we now
use either JS::Script::parse() or JS::SourceTextModule::parse()
to load tests.
2021-09-14 21:41:51 +02:00
Ali Mohammad Pur ccb53c64e9 AK: Add an abstraction over multiple disjoint buffers
DisjointChunks<T> provides a nice interface over multiple sequential
Vector<T>'s, allowing the user to iterate over/index into/slice from
said buffers as if they were a single contiguous buffer.
To work with views on such objects, DisjointSpans<T> is provided, which
has the same behaviour but does not own the underlying objects.
2021-09-14 21:33:15 +04:30
Idan Horowitz d6cfa34667 AK: Make URL::m_port an Optional<u16>, Expose raw port getter
Our current way of signalling a missing port with m_port == 0 was
lacking, as 0 is a valid port number in URLs.
2021-09-14 00:14:45 +02:00
Ali Mohammad Pur 246ab432ff LibRegex: Add a basic optimization pass
This currently tries to convert forking loops to atomic groups, and
unify the left side of alternations.
2021-09-13 14:38:53 +04:30
Timothy Flynn 470262c8ab LibJS: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Timothy Flynn c59b97043e LibWeb: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Idan Horowitz 6704961c82 AK: Replace the mutable String::replace API with an immutable version
This removes the awkward String::replace API which was the only String
API which mutated the String and replaces it with a new immutable
version that returns a new String with the replacements applied. This
also fixes a couple of UAFs that were caused by the use of this API.

As an optimization an equivalent StringView::replace API was also added
to remove an unnecessary String allocations in the format of:
`String { view }.replace(...);`
2021-09-11 20:36:43 +03:00
Ben Wiederhake 2e4ec891da Everywhere: Fix format-vulnerabilities
Command used:
grep -Pirn '(out|warn)ln\((?!["\)]|format,|stderr,|stdout,|output, ")' \
     AK Kernel/ Tests/ Userland/
(Plus some manual reviewing.)

Let's pick ArgsParser as an example:
    outln(file, m_general_help);
This will fail at runtime if the general help happens to contain braces.

Even if this transformation turns out to be unnecessary in a place or
two, this way the code is "more obviously" correct.
2021-09-11 15:16:26 +01:00
Brian Gianforcaro a4efaa7b47 Tests/Kernel: Fix test after off-by-one fix in Memory::is_user_range()
Commit 890c647e0f fixed an off-by-one bug, so the mapping of the page
at the very end of the user address space now works correctly.

This change adjusts the test so cover the corner cases the original
version was designed too.validate.
2021-09-11 04:15:16 +00:00
Ali Mohammad Pur 14c8373eb0 AK+Kernel: Reduce the number of template parameters of IntrusiveRBTree
This makes the user-facing type only take the node member pointer, and
lets the compiler figure out the other needed types from that.
2021-09-10 18:05:46 +03:00
Ali Mohammad Pur 5a0cdb15b0 AK+Everywhere: Reduce the number of template parameters of IntrusiveList
This makes the user-facing type only take the node member pointer, and
lets the compiler figure out the other needed types from that.
2021-09-10 18:05:46 +03:00
Timothy Flynn 4f2bcebe74 LibUnicode+LibJS: Store locale keyword values as a single string
Previously, LibUnicode would store the values of a keyword as a Vector.
For example, the locale "en-u-ca-abc-def" would have its keyword "ca"
stored as {"abc, "def"}. Then, canonicalization would occur on each of
the elements in that Vector.

This is incorrect because, for example, the keyword value "true" should
only be dropped if that is the entire value. That is, the canonical form
of "en-u-kb-true" is "en-u-kb", but "en-u-kb-abc-true" does not change
for canonicalization. However, we would canonicalize that locale as
"en-u-kb-abc".
2021-09-08 21:08:48 +01:00
Idan Horowitz cb9720baab AK: Set IntrusiveRBTree Node key on insertion instead of construction
This makes the API look much nicer.
2021-09-08 19:17:07 +03:00
Idan Horowitz 1db9250766 AK: Make IntrusiveRedBlackTree capable of holding non-raw pointers
This is completely based on e4412f1f59
and will allow us to convert some AK::HashMap users in the kernel.
2021-09-08 19:17:07 +03:00
davidot 43b17f27a3 test-js: Add a mark_as_garbage method to force GC to collect that object
This should fix the flaky tests of test-js.
It also fixes the tests when running with the -g flag since the values
will not be garbage collected too soon.
2021-09-08 08:53:02 +01:00
Ali Mohammad Pur 7fefb8148b LibRegex: Use the correct capture group index in ERE bytecode generation
Otherwise the left and right capture instructions wouldn't point to the
same capture group if there was another nested group there.
2021-09-07 20:01:58 +02:00
Andreas Kling 6ad427993a Everywhere: Behaviour => Behavior 2021-09-07 13:53:14 +02:00
Timothy Flynn 50158abaf1 LibUnicode: Implement locale-aware BEFORE_DOT special casing
Note that the algorithm in the Unicode spec is for checking that a code
point precedes U+0307, but the special casing condition NotBeforeDot is
interested in the inverse of this rule.
2021-09-06 15:24:27 +01:00
Timothy Flynn 436faf9fd9 LibUnicode: Implement locale-aware MORE_ABOVE special casing 2021-09-06 15:24:27 +01:00
Timothy Flynn 1427ebc622 LibUnicode: Implement locale-aware AFTER_SOFT_DOTTED special casing 2021-09-06 15:24:27 +01:00
Timothy Flynn 0053d48c41 LibUnicode: Implement locale-aware AFTER_I special casing 2021-09-06 15:24:27 +01:00
Ali Mohammad Pur 63523d3836 Tests/LibRegex: Decrease the size of the fork chain test 2021-09-06 13:51:30 +04:30
Ali Mohammad Pur abbe9da255 LibRegex: Make infinite repetitions short-circuit on empty matches
This makes (addmittedly weird) patterns like `(a*)*` work correctly
without going into an infinite fork loop.
2021-09-06 13:51:30 +04:30
Ali Mohammad Pur 97e97bccab Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
Ali Mohammad Pur 3a9f00c59b Everywhere: Use OOM-safe ByteBuffer APIs where possible
If we can easily communicate failure, let's avoid asserting and report
failure instead.
2021-09-06 01:53:26 +02:00
Brian Gianforcaro 782e7834c3 Tests: Reduce the execution time of the LibC TestQSort test
Executing 100 times vs 10 times doesn't increase test coverage
substantial, this API is stable and more iterations is just a
waste of time.

Without KVM this test is a clear outlier in runtime during CI:

```
START  LibC/TestQsort (106/172)
PASS   LibC/TestQsort (41.233692s)
```
2021-09-05 22:17:28 +02:00
Andreas Kling 7dda773426 AK: Add rvalue-ref qualifiers for Optional's value() and value_or()
This avoids a value copy when calling value() or value_or() on a
temporary Optional. This is very common when using the HashMap::get()
API like this:

    auto value = hash_map.get(key).value_or(fallback_value);
2021-09-04 03:02:08 +02:00