Commit graph

21258 commits

Author SHA1 Message Date
Max Wipfli dd392dfa03 AK: Add member variables to the URL class
This adds the m_username, m_password, m_paths and m_cannot_be_a_base_url
member variables to the URL class. These are necessary for the upcoming
new URL parser.

The deprecated m_path variable shadows the m_paths variable if it is
non-null. This behavior will be removed once the old URL parser has been
removed.
2021-06-01 09:28:05 +02:00
Max Wipfli 0d41a7d39a AK: Remove URLParser
This removes URLParser, because its two exposed functions, urlencode()
and urldecode(), have been superseded by URL::percent_encode() and
URL::percent_decode(). This is in preparation for the introduction of a
new URL parser.
2021-06-01 09:28:05 +02:00
Max Wipfli a603e69599 AK+Everywhere: Replace usages of URLParser::urlencode() and urldecode()
This replaces all occurrences of those functions with the newly
implemented functions URL::percent_encode() and URL::percent_decode().
The old functions will be removed in a further commit.
2021-06-01 09:28:05 +02:00
Max Wipfli 2a6c9bc5f7 AK: Implement more conforming URL percent encode/decode mechanism
This adds a few new functions to percent encode/decode strings according
to the URL specification. The functions allow specifying a
PercentEncodeSet, which is defined by the specification. It will be used
to replace the current urlencode() and urldecode() functions in a
further commit.

This commit adds a few duplicate helper functions in the URL class, such
as is_digit() and is_ascii_digit(). This will be cleaned up as soon as
the upcoming new URL parser will replace the current one.
2021-06-01 09:28:05 +02:00
Max Wipfli 0e4f7aa8e8 AK: Add trim() method to String, StringView and StringUtils
The methods added make it possible to use the trim mechanism with
specified characters, unlike trim_whitespace(), which uses predefined
characters.
2021-06-01 09:28:05 +02:00
Max Wipfli 14506e8f5e AK: Implement Utf8CodepointIterator::peek(size_t)
This adds a peek method for Utf8CodepointIterator, which enables it to
be used in some parsing cases where peeking is necessary.

peek(0) is equivalent to operator*, expect that peek() does not contain
any assertions and will just return an empty Optional<u32>.

This also implements a test case for iterating UTF-8.
2021-06-01 09:28:05 +02:00
Max Wipfli 31f6ba0952 AK: Internally rename protocol to scheme in URL
This renames all references to protocol to scheme, which is the name
used by the URL standard (https://url.spec.whatwg.org/). Externally, all
methods referencing "protocol" were duplicated with "scheme". The old
methods still exist as compatibility.
2021-06-01 09:28:05 +02:00
Max Wipfli d6709ac87d AK: Omit unnecessary function parameter names in URL
This patch removes unnecessary function parameter names in declarations
of the URL class. It also changes parameter types from String to
StringView where applicable.
2021-06-01 09:28:05 +02:00
Andreas Kling d105747735 basename: Tidy up a little more
This looks a little nicer with a single outln() invocation. :^)
2021-06-01 09:13:17 +02:00
Andreas Kling 9388cf327f basename: Support suffix stripping
Allow passing an optional suffix argument to `basename` which is then
stripped from the resulting basename (unless the resulting basename is
identical to the suffix.)

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/basename.html
2021-06-01 09:05:15 +02:00
Andreas Kling 313e53dca0 LibCore: Add StringView overloads for Core::ArgsParser
These allow you to get StringView wrappers around on-stack string
arguments, which seems pretty nice. :^)
2021-06-01 09:02:43 +02:00
Andreas Kling dd9b8ee7ef Documentation: Add rule about "east const" to CodingStyle.md
Unfortunately we cannot enforce this with clang-format yet, as that
feature is not available. Until then, let's try to write new code
with this in mind, and convert old code as we go.
2021-06-01 08:55:47 +02:00
Gunnar Beutner 45117a4134 Hearts: Fix sorting for pick_low_points_high_value_card
Previously the function did not sort the hand at all which means we
wouldn't necessarily pick the card with the highest value.
2021-06-01 08:52:08 +02:00
Gunnar Beutner 63d3beb78c Hearts: Prefer to pass high value cards
Previously we'd prefer to pass high points cards. Instead we should
prefer to pass high value cards first.
2021-06-01 08:52:08 +02:00
Gunnar Beutner 8b9da08d5a Hearts: Pick better non-matching cards
When we don't have a matching card for the lead card rather than
always preferring to play hearts we should try to get rid of our
high value cards first if no other player has hearts cards higher
than what we have.
2021-06-01 08:52:08 +02:00
Gunnar Beutner 4a8d8da46c Hearts: Make debugging AI suggestions easier
When building Hearts with HEARTS_DEBUG we highlight the card the AI
would have picked. This makes comparing AI and human decisions easier.
2021-06-01 08:52:08 +02:00
Gunnar Beutner 2b2d992946 Hearts: Pick better cards when we're the third player
When we're the third player in a trick and we don't have a lower value
card we would previously pick a slightly higher value card. Instead
we should pick the highest value card unless there are points in the
current trick or the lead card is spades and the higher value card
we would've picked is higher than the queen and another player still
has the queen.

The rationale is that we have to take the trick anyway so we might as
well get rid of our highest value card. If the trailing player has a
lower value card of the same type we take the trick but don't gain
any points. If they don't have a card of the same type it doesn't
matter whether we play a high value or low value card.
2021-06-01 08:52:08 +02:00
Gunnar Beutner 38f8a6aabb Hearts: Pick better lead cards
Previously the AI would prefer playing a lead card for which no other
player had a card with a higher value even though it also had a card
for which a higher value card was still in play.
2021-06-01 08:52:08 +02:00
Jelle Raaijmakers 40ddb734ee LibPthread: Correct error check in sem_post and sem_wait 2021-06-01 08:29:56 +02:00
Itamar 8f6b496fed LibGUI: Add a FIXME about race in AutocompleteBox::apply_suggestion() 2021-06-01 08:28:27 +02:00
Itamar 7c2941d4ea LibGUI: Check that AutocompleteBox's selection row is valid
Previously we didn't check that the selection's row index is in a valid
range before attempting to access its data via the model.

This could cause an out-of-bounds access to the model's Vector of
suggestions.

I think this should fix #7404, but I can't verify it does because
I wasn't able to reproduce it on my machine.
2021-06-01 08:28:27 +02:00
Jelle Raaijmakers 7a4445a1fe LibGUI/TreeView: Select parent on collapse
When collapsing a tree that contains the current selection, the parent
node becomes selected instead.
2021-06-01 08:22:51 +02:00
Idan Horowitz 67a5e9f018 LibJS: Add left shift & right shift operator support for BigIntegers
Based on https://tc39.es/ecma262/#sec-numeric-types-bigint-leftShift
(This commit also includes the matching tests)
2021-05-31 19:50:29 +01:00
Luke 4ee58d36c0 Kernel/ACPI: Sprinkle links to the specification all over
The latest version of the ACPI specification (6.4) now has a web
version, making it possible to link directly to the relevant sections
of the specification.

I added links to the stuff that was easy to find.

The spec can be found here: https://uefi.org/specs/ACPI/6.4/index.html
2021-05-31 19:06:46 +01:00
Nick Miller 10ba6f254c Kernel: Rename instances of IO port 0xe9 to BOCHS_DEBUG_PORT 2021-05-31 19:06:13 +01:00
Oleg Kosenkov 971523621c
Ports: Add opentyrian and opentyrian-data 2021-05-31 19:01:49 +01:00
Egor Ananyin ed89cd93aa Ports: Add Simon Tatham's Puzzle Collection 2021-05-31 18:44:56 +01:00
Liav A 10c747f2be Documentation: Add explanation about AHCI locking 2021-05-31 18:28:25 +01:00
Linus Groh 1f62aaa193 lsof: Replace copy with reference in a for loop 2021-05-31 18:03:54 +01:00
Linus Groh 304752fccb cal: Remove unused variable declarations 2021-05-31 18:02:48 +01:00
Linus Groh 1eb048bed0 Userland: Remove a bunch of unused includes
As reported by CLion.
2021-05-31 18:01:53 +01:00
Linus Groh 16d51d78c0 Userland: Avoid a bunch of JsonObject copies
JsonValue::as_object() returns a reference.
2021-05-31 17:59:02 +01:00
Linus Groh a6248101e2 SpaceAnalyzer: Replace fprintf(stderr) with warnln() 2021-05-31 17:44:01 +01:00
Linus Groh 8625f089bf Debugger: Replace printf() with outln() 2021-05-31 17:44:01 +01:00
Linus Groh 5e48769487 Applets/Network: Replace fprintf(stderr) with dbgln()
This is an applet, so we're not going to see its stderr anyway.
2021-05-31 17:44:01 +01:00
Linus Groh 3a7574de82 LibX86: Replace fprintf(stderr) with warnln() 2021-05-31 17:43:54 +01:00
Linus Groh ff914fabeb LibWeb/WrapperGenerator: Replace a fprintf() with warnln() 2021-05-31 17:43:54 +01:00
Linus Groh dac0554fa0 LibRegex: Replace fprintf()/printf() with warnln()/outln()/dbgln() 2021-05-31 17:43:54 +01:00
Linus Groh 81b7b2f49e LibHTTP: Replace fprintf(stderr) with warnln() 2021-05-31 17:43:54 +01:00
Linus Groh a4bd29828c LibGUI: Replace fprintf(stderr)/printf() with warnln()/dbgln() 2021-05-31 17:43:54 +01:00
Linus Groh 634db18809 LibGfx: Replace if constexpr (PNG_DEBUG) printf() with dbgln_if()
The debug console seems more appropriate than stdout here.
2021-05-31 17:43:54 +01:00
Linus Groh b5aaae7b40 LibGemini: Replace fprintf(stderr) with warnln() 2021-05-31 17:43:54 +01:00
Linus Groh 303358220b LibCore: Replace fprintf(stderr)/printf() with warnln()/out() 2021-05-31 17:43:54 +01:00
Linus Groh 1b81b63663 LibC: Replace fprintf(stderr) with warnln() 2021-05-31 17:43:54 +01:00
Linus Groh 028a337a6d AK: Add Formatter<unsigned char[Size]> 2021-05-31 17:43:54 +01:00
Sebastian Zaha 77044dd383
Kernel: Fix crash when switching to console 5 & 6
The changes in commit 20743e8 removed the s_max_virtual_consoles
constant and hardcoded the number of consoles to 4. But in
PS2KeyboardDevice the keyboard shortcuts for switching to consoles were
hardcoded to 6.

I reintroduced the constant and added it in both places.
2021-05-31 17:42:21 +01:00
Andrew Kaster b3746f9745 AK: Guard inline assembly with ARCH(I386) and provide alternative
For non-x86 targets, it's not very nice to define inline functions in
AK/Memory.h with asm volatile implementations. Guard this inline
assembly with ARCH(I386) and provide portable alternatives. Since we
always compile with optimizations, the hand-vectorized memset and
memcpy seem to be of dubious value, but we'll keep them here until
proven one way or another.

This should fix the Lagom build on native M1 macOS that was reported
on Discord the other day.
2021-05-31 17:29:09 +01:00
sin-ack a10ad24c76 LibGfx: Make JPGLoader iterate components deterministically
JPGLoader used to store component information in a HashTable, indexed
by the ID assigned by the JPEG file.  This was fine for most purposes,
however after f89e8fb7 this was revealed to be a flawed implementation
which causes non-deterministic iteration over components.

This issue was previously masked by a perfect storm of int_hash being
stable for the integer values 0, 1 and 2; and AK::HashTable having just
the right amount of buckets for the components to be ordered correctly
after being hashed with int_hash. However, after f89e8fb7,
malloc_good_size was used for determining the amount of space for
allocation; this caused the ordering of the components to change, and
images started showing up with the red and blue channels reversed. The
issue was finally determined to be inconsistent ordering after randomly
changing the order of the components caused Huffman decoding to fail.

This was the result of about 10 hours of hair-pulling and repeatedly
doing full rebuilds due to bisecting between commits that touched AK.
Gunnar, I like you, but please don't make me go through this again. :^)

Credits to Andrew Kaster, bgianf, CxByte and Gunnar for the debugging
help.
2021-05-31 17:26:11 +01:00
Luke 59cfc4a8db LibWeb: Rename "FrameHostElement" to "BrowsingContextContainer"
With the renaming of "Frame" to "BrowsingContext", this changes
"FrameHostElement" to "BrowsingContextContainer" to further
match the spec.

https://html.spec.whatwg.org/#browsing-context-container
2021-05-31 16:25:13 +02:00
Jesse Buhagiar 8298e406a4 LibGL: Use Texture Units in Rasterizer and Context
The Context and Software Rasterizer now gets the array of texture units
instead of a single texture object. _Technically_, we now support some
primitive form of multi-texturing, though I'm not entirely sure how well
it will work in its current state.
2021-05-31 14:59:47 +01:00