Commit graph

5008 commits

Author SHA1 Message Date
Ali Mohammad Pur
09cf1040ef LibJS/Tests: Catch exceptions in describe() itself
Otherwise exceptions thrown in that state would simply terminate the
test.
2021-06-04 16:07:42 +04:30
Jelle Raaijmakers
e483de93ce LibC: Define MSG_OOB 2021-06-04 10:39:41 +02:00
Jelle Raaijmakers
7f4a1bc11e LibC: Implement execle() 2021-06-04 10:39:41 +02:00
Jelle Raaijmakers
0e990a4be8 LibC: Implement mblen() 2021-06-04 10:39:41 +02:00
Jelle Raaijmakers
496988de47 LibC: Add POSIX timer constants 2021-06-04 10:39:41 +02:00
Daniel Bertalan
99a79a364a LibVT: Fix underlines incorrectly rendering in red
Previously, `href` attributes weren't checked for not being empty when
drawing their underlines. This caused any underline to be treated as an
active `href`, hence the red color.
2021-06-04 09:02:43 +01:00
Daniel Bertalan
53099b216c LibVT: Implement bright color support
Previously, we only used bright colors when the bold attribute was set.
We now have the option to set it via escape sequences. We also needed to
make the bold text behavior optional, as some color schemes do weird
things with it. For example, Solarized uses it for various shades of
gray, so bold green would turn into a light shade of gray.

The following new escape sequences are supported:
- `CSI 90;m` to `CSI 97;m`: set bright foreground color
- `CSI 100;m` to `CSI 107;m`: set bright background color
2021-06-04 09:02:43 +01:00
Daniel Bertalan
acbd1d14d0 LibVT+Terminal: Add color scheme support
This commit introduces color scheme support to Terminal. These are found
in `/res/terminal_colors` and the default color scheme can be set in
`~/.config/Terminal.ini`. Furthermore, a combo box is added for
setting the color scheme at runtime.

The previously used default color scheme has been added to
`/res/terminal-colors/Default.ini`.

To make the implementation more compatible with other color schemes,
`TerminalWidget` now supports overriding the default foreground and
background colors.
2021-06-04 09:02:43 +01:00
Daniel Bertalan
99033876ec LibVT+Kernel: Create Color class
Previously, we converted colors to their RGB values immediately when
they were set. This meant that their semantic meaning was lost, we could
not tell a precise RGB value apart from a named/indexed color.

The new way of storing colors will allow us to retain this information,
so we can change a color scheme on the fly, and previously emitted text
will also be affected.
2021-06-04 09:02:43 +01:00
Max Wipfli
054c742d17 LibWeb: Remove Utf8View usage and try avoiding StringBuilder in TextNode
This patch completely reworks TextNode::compute_text_for_rendering(). It
removes the unnecessary usage of Utf8View to find spaces in a String.
Furthermore, it adds a couple fast return paths for common but trivial
cases such as empty, single-character and whitespace-less strings.

For the HTML spec bookmarks, around two thirds of all function calls
(which amounts to around 10'000) use the fast paths and thus avoid
allocating a StringBuilder just to build a copy of the already present
String.
2021-06-04 09:39:07 +02:00
Gunnar Beutner
19c4e74f70 Taskbar: Allow creating menus for sub-categories
This change allows creating sub-categories in app files, e.g. with
Category=Games/Puzzles.
2021-06-04 09:38:25 +02:00
Linus Groh
1828607606 LibTest: Add --json flag to JS test runner
This will not show the colorful human-readable file results and final
test results summary but instead output a JSON blob containing all test
information, which can then be processed by other programs easily.
2021-06-04 08:32:56 +01:00
DhruvMaroo
6c3d601e87 Profiler: Show the duration of the time interval chosen 2021-06-04 09:30:22 +02:00
Gunnar Beutner
6093236424 LibCards: Don't draw the first card smaller than the others 2021-06-04 09:20:21 +02:00
brapru
7843287d89 LibLine: Actually cancel the search editor on Ctl-C
When the search editor calls on really_quit_event_loop to cancel the
search, the command loaded in m_buffer would actually execute because
really_quit_event_loop sends a new line character and then afterwards
clears the buffer.

By using end_search prior to exiting the event loop, this patch will
appropriately clear the buffer, not execute any commands, and
preserve the original loaded buffer after returning from a canceled
search.
2021-06-04 11:00:24 +04:30
Matthew Jones
1748591570 Solitaire: Fixes undo feature from incorrect merge conflict resolution 2021-06-04 00:15:25 +02:00
Andreas Kling
bfffdd37f0 LibCpp: Revert change to strace.cpp AST test from bf8fd4c
Since the purpose of this file is just to verify the AST generated,
we can leave it alone.
2021-06-04 00:03:25 +02:00
David Isaksson
fe03630716 LibCards: Draw cards with rounded card corners
closes #7412
2021-06-03 22:58:14 +02:00
Andreas Kling
bf8fd4c193 Everywhere: Remove accidental '\n' from various outln() invocations
Also convert outln(stderr, ...) to warnln(...)
2021-06-03 22:50:21 +02:00
Marcus Nilsson
5a8cc85328 LibGUI/FileIconProvider: Return s_file_icon when stat() fails
Previously when using icon_for_path(), without specifying t_mode, on an
anonymous file it would return an empty Icon causing problems down the
line. Instead return the s_file_icon when stat fails.
2021-06-03 17:43:20 +01:00
Gunnar Beutner
bc174b0fd0 Utilities: Make sure columns for ps are properly aligned
This updates ps so that it calculates the ideal column width instead
of relying on hard-coded values. Previously the STATE column was too
small to fit the state for "FinalizerTask".
2021-06-03 17:53:59 +02:00
NonStandardModel
5bbca2fa8b
KeyboardMapper: Fix crash upon loading an invalid JSON file
This fixes #7699.
It would be nice to also show a GUI alert informing about the failure,
but I will leave that for the future.
2021-06-03 16:19:07 +01:00
DexesTTP
e01f1c949f AK: Do not VERIFY on invalid code point bytes in UTF8View
The previous behavior was to always VERIFY that the UTF-8 bytes were
valid when iterating over the code points of an UTF8View. This change
makes it so we instead output the 0xFFFD 'REPLACEMENT CHARACTER'
code point when encountering invalid bytes, and keep iterating the
view after skipping one byte.

Leaving the decision to the consumer would break symmetry with the
UTF32View API, which would in turn require heavy refactoring and/or
code duplication in generic code such as the one found in
Gfx::Painter and the Shell.

To make it easier for the consumers to detect the original bytes, we
provide a new method on the iterator that returns a Span over the
data that has been decoded. This method is immediately used in the
TextNode::compute_text_for_rendering method, which previously did
this in a ad-hoc waay.

This also add tests for the new behavior in TestUtf8.cpp, as well
as reinforcements to the existing tests to check if the underlying
bytes match up with their expected values.
2021-06-03 18:28:27 +04:30
Gunnar Beutner
32ee195d62 LibJS: Avoid allocations in the Exception constructor 2021-06-03 14:47:15 +01:00
Gunnar Beutner
8b449214af LibJS: Optimize insertion order in the Exception constructor
By inserting the stack frames in the correct order we can improve the
runtime for the test-js test suite by about 20%.
2021-06-03 14:47:15 +01:00
Max Wipfli
bc8d16ad28 Everywhere: Replace ctype.h to avoid narrowing conversions
This replaces ctype.h with CharacterType.h everywhere I could find
issues with narrowing conversions. While using it will probably make
sense almost everywhere in the future, the most critical places should
have been addressed.
2021-06-03 13:31:46 +02:00
Brian Gianforcaro
d0dbb014a0 WindowServer: Switch Window to IntrusiveList from InlineLinkedList
Another small step towards unifying IntrusiveList / InlineLinkedList.
2021-06-03 13:27:40 +02:00
Brian Gianforcaro
e37f39d980 LibC: Switch ChunkedBlock to IntrusiveList from InlineLinkedList 2021-06-03 13:27:40 +02:00
Gunnar Beutner
48da8a568d
AK: Remove unused JsonValue <=> IPv4Address conversion code
This removes code that isn't used anywhere.
2021-06-03 11:56:32 +01:00
Brian Gianforcaro
06df26da67 LibGUI: Hide TextEditor dbgln spew under TEXTEDITOR_DEBUG 2021-06-03 11:21:38 +01:00
Brian Gianforcaro
c2d556be3d TextEditor: Remove unused header includes 2021-06-03 11:21:38 +01:00
Matthew B. Jones
ecaae2d10f
Solitaire: Add keys for drawing and moving cards to foundation stacks
Also shifts logic of starting game length timer into function
`start_timer_if_necessary`, so it can be called from original
mouse event handler and new `auto_move_eligible_cards_to_stacks`
2021-06-03 08:43:28 +01:00
Matthew B. Jones
e7cfa9bf8e
LibGUI: Properly wrap multiple lines in IconView search highlighting 2021-06-03 08:32:31 +01:00
Timothy Flynn
a870eac0eb LibSQL: Report a syntax error for unsupported LIMIT clause syntax
Rather than aborting when a LIMIT clause of the form 'LIMIT expr, expr'
is encountered, fail the parser with a syntax error. This will be nicer
for the user and fixes the following fuzzer bug:
https://crbug.com/oss-fuzz/34837
2021-06-03 08:30:13 +02:00
Matthew Jones
0ff09d4f74 WindowServer: Add sanity checks to create_window IPC 2021-06-03 08:27:57 +02:00
Matthew Jones
ef92493aba LibGUI: ComboBox now goes upwards when running out of room to render 2021-06-03 08:24:18 +02:00
Matthew Jones
36a1162eb8 LibGUI: ComboBox now correctly sizes height in relation to taskbar 2021-06-03 08:23:45 +02:00
Matthew Jones
6c520fab87 LibGUI: Desktop.h should get actual value from TaskbarWindow.h 2021-06-03 08:23:45 +02:00
Matthew Jones
b0682a73ee WindowServer: Position popup menu with offset of 1 pixel 2021-06-03 08:21:01 +02:00
Matthew B. Jones
ab4f4ddc3c
Solitaire: Add undo functionality 2021-06-03 01:16:49 +01:00
Gunnar Beutner
9444272ba0 Profiler: Remove m_deepest_stack_depth
This isn't used anymore so let's remove it entirely.
2021-06-03 01:16:32 +01:00
Gunnar Beutner
a607f13fc7 Profiler: Use sequential serial numbers for profiling events
Previously Profiler was using timestamps to distinguish processes.
However it is possible that separate processes with the same PID exist
at the exact same timestamp (e.g. for execve). This changes Profiler
to use unique serial numbers for each event instead.
2021-06-03 01:16:32 +01:00
Matthew Jones
af72b5ec82 LibGUI: Show pressed state for Space and Return key events
Also allows the user to press Esc while the button is being pressed
to cancel the button action.
2021-06-03 00:33:26 +01:00
BrandonKi
0d1481be7d LibWasm: Use builtins for clz, ctz, and popcnt 2021-06-03 03:45:06 +04:30
BrandonKi
e53df2ca9d LibWasm: Implement rotr and rotl 2021-06-03 03:45:06 +04:30
Matthew Jones
ea4116f5bd LibGUI+LibGfx+WindowServer: Sanity check window size dimensions
Previous to this commit, if a `Window` wanted to set its width or height
greater than `INT16_MAX` (32768), both the application owning the Window
and the WindowServer would crash.

The root of this issue is that `size_would_overflow` check in `Bitmap`
has checks for `INT16_MAX`, and `Window.cpp:786` that is called by
`Gfx::Bitmap::create_with_anonymous_buffer` would get null back, then
causing a chain of events resulting in crashes.

Crashes can still occur but with `VERIFY` and `did_misbehave` the
causes of the crash can be more readily identified.
2021-06-02 23:59:57 +01:00
Marcus Nilsson
3931b292b0 HackStudio: Make locator lose focus on close
Make locator lose focus when pressing escape or by clicking in the
editor area.
2021-06-02 23:15:52 +01:00
Marcus Nilsson
b43dad1741 HackStudio: Remove unused includes 2021-06-02 23:15:52 +01:00
Marcus Nilsson
8d3539a1c4 HackStudio: Close locator on exit 2021-06-02 23:15:52 +01:00
Matthew B. Jones
3ad7a1e944
Hearts: Play the first valid card (left-to-right) when pressing space 2021-06-02 23:07:12 +01:00
Matthew Jones
f0e9fd09b4 LibGUI: Tooltip no longer exceeds screen width, now truncates 2021-06-02 22:50:51 +01:00
Linus Groh
d1d1f4f251 LibJS: Remove declarations of some TODO()'d BigInt and Promise functions
In hindsight declaring these prematurely wasn't the greatest idea - that
just makes any script checking for their existence believe they'll work,
and what follows next is a crash of the js or WebContent process. If we
omit the declarations, a polyfill can be provided instead.

This also affects the test262, which tests these - instead of reporting
a bunch of assertion crash errors, we should simply report test failure
for 'not a function', which in turn makes it easier to spot any actual
bugs causing crashes.
2021-06-02 21:06:21 +01:00
Linus Groh
163d776df6 LibJS: Replace iterator hint string argument with an enum
There's no reason at all for this to be a string or to accept arbitrary
values - just because it's displayed as strings in the spec doesn't mean
we have to do the same :^)
2021-06-02 20:52:46 +01:00
Linus Groh
a5903ac4b6 LibRegex: Hide stray dbgln() behind REGEX_DEBUG 2021-06-02 18:31:43 +01:00
Matthew Jones
123848f0c1 LibGUI: Fixes Widget->set_visible(false) still maintains focus bug
When setting a Widget->set_visible(false), if that Widget->has_focus()
it will continue to have focus, even though it's not visible to the user
anymore.

Now calling Widget->set_visible(false) will remove focus from the Widget
if it had focus, and the Window will give focus back to the Widget
that had it previously, if there was one.
2021-06-02 18:22:05 +02:00
Matthew Jones
9720261540 TextEditor/GMLPlayground: Don't close app if user aborts save on exit 2021-06-02 18:15:19 +02:00
NonStandardModel
a7d3709e1c KeyboardMapper: Add default path to keymaps 2021-06-02 18:10:06 +02:00
Gunnar Beutner
9e3fb73169 LibC: Use memory_order_acquire instead of memory_order_acq_rel
Acquire ordering should be sufficient for pthread_mutex_lock
and pthread_mutex_trylock.
2021-06-02 18:09:32 +02:00
Gunnar Beutner
90f4c9e44c LibC: Fix race condition in pthread_mutex_unlock()
This ensures the store to mutex->lock doesn't get re-ordered before
the store to mutex->owner which could otherwise result in a locked
owner-less mutex if another thread tries to acquire the lock at
the same time.
2021-06-02 18:09:32 +02:00
Gunnar Beutner
5ca1d4289b LibC: Remove reinterpret_cast in pthread_mutex_{try,}lock 2021-06-02 18:09:32 +02:00
Marcus Nilsson
11fa3e4f92 Terminal/LibGUI::TextEditor: Add shift+return to search forwards
This adds support for shift+return key combo in single line TextEditor
fields. Used in this case for searching backwards/forwards in the
Terminal find window.
2021-06-02 18:08:56 +02:00
Marcus Nilsson
9550564767 Terminal: Remove unused includes 2021-06-02 18:08:56 +02:00
Marcus Nilsson
734bd9841a Terminal: Close find & settings windows on application exit
Since the find & settings windows are not children of the main window,
they stayed open after exiting the application.
2021-06-02 18:08:56 +02:00
Gunnar Beutner
b5778675a5 WindowServer: Use RefPtr instead of raw pointers
Now that we have static initializers and destructors we can use
RefPtr here.
2021-06-02 18:08:11 +02:00
Marco Cutecchia
ea03b43fff PixelPaint: Update Image.{cpp, h} to use east const 2021-06-02 18:07:14 +02:00
Marco Cutecchia
76adac103e PixelPaint: Support opening more image file formats
Previously we could only open .pp files, now we can open all formats
supported by Gfx::Bitmap::load_from_file
2021-06-02 18:07:14 +02:00
Ali Mohammad Pur
ea7ba34a31 AK+LibWasm+LibJS: Disallow Variant.has() on types that aren't contained
Checking for this (and get()'ing it) is always invalid, so let's just
disallow it.
This also finds two bugs where the code is checking for types that can
never actually be in the variant (which was actually a refactor
artifact).
2021-06-02 18:02:47 +02:00
Filip Kania
33cdc59dff Utilities: Add support for relative paths in open command 2021-06-02 17:34:27 +04:30
Ali Mohammad Pur
b15a5d6ada LibWasm: Ensure that value signs are preserved when casting
Also makes normal arithmetic operations more spec-compliant by actually
ignoring overflow on them.
2021-06-02 16:09:16 +04:30
Ali Mohammad Pur
02b3238c41 LibWasm: Parse the "extend" set of instructions 2021-06-02 16:09:16 +04:30
Ali Mohammad Pur
9a1853c388 LibWasm: Don't execute the last instruction in the frame after return 2021-06-02 16:09:16 +04:30
Ali Mohammad Pur
b250a6ae7e wasm: Add a way to create dummy function exports
This should allow running modules with their imports stubbed out
in wasm, to debug them.
2021-06-02 16:09:16 +04:30
Ali Mohammad Pur
56bf80251c LibWasm: Implement reference instructions (ref.{null,func,is_null}) 2021-06-02 16:09:16 +04:30
Matthew Jones
fe026fef47 Inspector: Check if RemoteProcess is_inspectable
The previous check of looking at `/proc/PID` was not working, it would
always fail even if the process was indeed inspectable.

Commit 70117781 introduced a new IPC for asking InspectorServer whether
or not a given `pid` is actually inspectable.

If a process is not inspectable, the `GUI::ProcessChooser` is
redisplayed if it was previously displayed, otherwise it exits.
2021-06-02 11:19:04 +02:00
Matthew Jones
00c8b74ab4 InspectorServer: Add is_inspectable IPC 2021-06-02 11:19:04 +02:00
BrandonKi
ee38f5241d LibChess: Change cursor style when hovering or dragging valid piece 2021-06-02 11:18:40 +02:00
Gunnar Beutner
cdb070cdfb WindowServer: Don't crash when we can't allocate a bitmap
When the client specifies an absurdly large window size
render_to_cache() fails to allocate a bitmap and crashes.

Refs #7688.
2021-06-02 10:17:42 +01:00
Gunnar Beutner
2df6c70b07 Utilities: Report correct memory addresses for pmap
While I think negative memory might be an interesting concept to
investigate I don't think we're quite ready for it yet:

7ca71000        8192 r-xs-  libcrypt.so: .text
7ca73000        4096 r----  libcrypt.so: .relro
7ca74000        4096 rw---  libcrypt.so: .data
-6d391000       45056 r-xs-  libttf.so: .text
-6d385000        4096 r----  libttf.so: .relro
-6d384000        4096 rw---  libttf.so: .data
2021-06-02 10:16:45 +01:00
Idan Horowitz
de8d081ca4 LibJS: Add the String.prototype.trim{Left, Right} aliases
These are the same as trim{Start, End} respectively.
2021-06-02 09:42:25 +02:00
Matthew Jones
33eb9a6ddc WindowServer: Use user-defined background color, if defined
Use the configured desktop background color, if defined, otherwise
default to the current theme's background color. If a user chooses
a background color via "desktop settings", then this new color
will always be used.

Switching themes will delete the user-defined background color, so
the background color resets to the theme's defined color.
2021-06-02 09:40:53 +02:00
Nick Miller
f02d976ed7 SoundPlayer: Fix playback slider page stepping
Fixes a bug that was preventing the playback slider from changing
value when clicking ahead/behind the current position.
2021-06-02 09:39:30 +02:00
Gunnar Beutner
15b69eef66 Profiler: Fix loading profiles which previously would crash the profiler
The profiler tried to be clever when handling process_exit events by
subtracting one from the timestamp. This was supposed to ensure that
events after a process' death would be attributed to the new process
in case the old process used execve(). However, if there was another
event (e.g. a CPU sample) at the exact same time the process_exit
event was recorded the profile would fail to load because we
didn't find the process anymore.

This changes introduces a new problem where samples would be attributed
to the incorrect process if a CPU sample for the old process, a
process_exit as well as a process_create event plus another CPU sample
event for the new process happened at the exact same time. I think
it's a reasonable compromise though.
2021-06-02 09:24:58 +02:00
Linus Groh
e5c0dbc0d4 LibJS: Fix indendation in CMakeLists.txt 2021-06-02 00:14:53 +01:00
Linus Groh
1580eeed98 md: Improve document parsing error message 2021-06-01 21:30:16 +01:00
Linus Groh
2a940464b8 Userland: Return 1 when help text is shown for insufficient args
ArgsParser also does this, but we don't use that (yet) in a couple of
places. Fix the behaviour manually for consistency.
2021-06-01 21:30:16 +01:00
Linus Groh
f5c35fccca Userland: Replace most printf-style APIs with AK::Format APIs :^) 2021-06-01 21:30:16 +01:00
Itamar
4f1889c2cb CppLanguageServer: Work with a HashMap of Symbols in each document
This is a pretty fundamental refactor of the way
CppComprehensionEngine works.

Previously, in order to answer queries such as "goto definition" or
"autocomplete", we would do ad-hoc logic of walking the AST,
collecting available declaration nodes, computing scopes, and so on.

This commit introduces an architectural change where each Document
builds a hashmap of symbols on creation.

With these hashmaps, it's easier to iterate over all of the available
symbols, and to answer a query such as "which symbols are defined in
this scope".
2021-06-01 22:20:13 +02:00
Itamar
b5da0b71e5 LibCpp: Consider declarations inside a function's body
... in FunctionDeclaration::declarations()
2021-06-01 22:20:13 +02:00
Timothy Flynn
ab79599a5e LibSQL: Return an error for empty common table expression lists
SQL::CommonTableExpressionList is required to be non-empty. Return an
error if zero common table expressions were parsed.

Fixes #7627
2021-06-01 23:48:21 +04:30
Gunnar Beutner
5b86a8bad1 InspectorServer: Remove extraneous curly brackets 2021-06-01 23:36:44 +04:30
Luke
70a575d75f LibWeb: Use correct percent encode set for form submissions
We currently only support application/x-www-form-urlencoded for
form submissions, which uses a special percent encode set when
percent encoding the body/query. However, we were not using this
percent encode set.

With the new URL implementation, we can now specify the percent encode
set to be used, allowing us to use this special percent encode set.

This is one of the fixes needed to make the Google cookie consent work.
2021-06-01 23:26:03 +04:30
Ali Mohammad Pur
944855ca18 AK+Everywhere: Fix compiletime format parsing of replacement fields 2021-06-01 23:12:17 +04:30
Brendan Coles
996f69a1b2 HexEditor: Fix off-by-one bugs in selected text length calculations
find_and_highlight() selected +1 too many bytes.

'Select All' selected +1 too many bytes past the end of
the buffer.

Status bar 'Selected Bytes' count was off by -1 when more
than zero bytes were selected.
2021-06-01 12:23:43 +02:00
Max Wipfli
33396494f6 AK+LibWeb: Remove URL::to_string_encoded()
This replaces URL::to_string_encoded() with to_string() and removes the
former, since they are now equivalent.
2021-06-01 12:23:16 +02:00
Andreas Kling
12a42edd13 Everywhere: codepoint => code point 2021-06-01 10:01:11 +02:00
Andreas Kling
407d6cd9e4 AK: Rename Utf8CodepointIterator => Utf8CodePointIterator 2021-06-01 09:45:52 +02:00
Max Wipfli
628c7f094f LibGUI+Shell+bt+ls: Use proper APIs for creating file URLs
This patch replaces ad-hoc generation of file URL strings with using
URL::create_with_file_scheme().
2021-06-01 09:28:05 +02:00
Max Wipfli
ce80188d6f LibHTTP: Percent encode/decode request URI
This percent encodes/decodes the request URI when creating or parsing
raw HTTP requests. This is necessary because AK::URL now contains
percent decoded data, meaning we have to re-encode it for creating
raw requests.
2021-06-01 09:28:05 +02:00
Max Wipfli
1c4854824b LibWeb: Remove usage of URL::set_path() in FrameLoader
This replaces a call to URL::set_path() with URL::set_paths(), as
set_path() will be deprecated and removed.
2021-06-01 09:28:05 +02:00
Max Wipfli
915cce5b74 Spreadsheet: Remove usage of URL::set_path()
This replaces a call to URL::set_path() with URL::set_paths(), as
set_path() will be deprecated and 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
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
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
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
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
Jesse Buhagiar
573c1c82f7 LibGL: Implement glActiveTexture 2021-05-31 14:59:47 +01:00
Jesse Buhagiar
52e5d3c961 LibGL: Implement basic texture units
These are merely a way to hold the different texture target bind
points that a texture can be bound to.
2021-05-31 14:59:47 +01:00
Brandon Hamilton
6219c3ec3c Spreadsheet: Keep value when clicking out of a cell 2021-05-31 16:57:18 +04:30
Gunnar Beutner
73b9cfac1b LibELF: Support weak symbols when using BIND_NOW
When using BIND_NOW (e.g. via -Wl,-z,now) we would fail to load ELF
images while doing relocations when we encounter a weak symbol. Instead
we should just patch the PLT entry with a null pointer.

This can be reproduced with:

$ cat test.cpp
int main()
{
    std::cout << "Hello World!" << std::endl;
}
$ g++ -o test -Wl,-z,now test.cpp
$ ./test
did not find symbol while doing relocations for library test: _ITM_RU1
2021-05-31 11:49:32 +01:00
Gunnar Beutner
d8b5fa9dfe AK: Remove the public ByteBuffer::trim method
This removes the public trim() method because it is no longer
necessary. Callers can instead use resize().
2021-05-31 14:49:00 +04:30
Gunnar Beutner
5f18cf75c5 AK: Replace ByteBuffer::grow with resize()/ensure_capacity()
Previously ByteBuffer::grow() behaved like Vector<T>::resize().
However the function name was somewhat ambiguous - and so this patch
updates ByteBuffer to behave more like Vector<T> by replacing grow()
with resize() and adding an ensure_capacity() method.

This also lets the user change the buffer's capacity without affecting
the size which was not previously possible.

Additionally this patch makes the capacity() method public (again).
2021-05-31 14:49:00 +04:30
Luke
2ad25aa8f8 LibWeb: Return null in Window.{top,parent} if browsing context is null
We were asserting that it exists, but the spec says to return null in
this case.

Top: https://html.spec.whatwg.org/multipage/browsers.html#dom-top
Parent: https://html.spec.whatwg.org/multipage/browsers.html#dom-parent
2021-05-31 14:22:38 +04:30
Brian Gianforcaro
5bfba3f789 LibELF + LibDebug: Reduce allocations during symbolification
Avoid promotion of static strings to AK::String, instead use
AK::StringView and operator ""sv, to force string view's instead
which avoids allocation of String. This code path isn't hot enough
that it makes a huge difference, but every bit counts.
2021-05-31 14:09:11 +04:30
Andreas Kling
597539aa4c pls: Fix typo in TERM environment variable propagation 2021-05-30 23:13:52 +02:00
Andreas Kling
33f2eeea4a pls: Drastically simplify this program
Since this program is setuid-root, it should be as simple as possible.

To that end, remove `/etc/plsusers` and use filesystem permissions to
achieve the same thing. `/bin/pls` is now only executable by `root` or
members of the `wheel` group.

Also remove all the logic that went to great lengths to `unveil()` a
minimal set of filesystem paths that may be used for the command.
The complexity-to-benefit ratio did not seem justified, and I think
we're better off keeping this simple.

Finally, remove pledge promises the moment they are no longer needed.
2021-05-30 23:09:37 +02:00
Ben Wiederhake
05d49cc0cb LibCrypto: Fix bound checks when reading bitmaps
This only affects malformed RSA keys. Instead of accepting and
continuing with potentially broken pointers (and in ASAN, crashing), we
now consider bitmaps malformed, and stop parsing.

Found by OSS Fuzz: #31698, long-standing-bug:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31698

Fun fact: The "if" only exists because of OSS Fuzz.
8cc279ed74
2021-05-31 00:47:43 +04:30
Tim Schumacher
d5bf9182dd LibC: Don't clear errno on success
POSIX (`errno(3p)`) states that errno should not be set to zero.

This helps with applications that don't expect errno to get updated
unless an intermediate syscall also fails.
2021-05-30 19:37:32 +02:00
brapru
d24dd7a3df Utilities: Implement ArmedScopeGuard in userdel to unlink temp files 2021-05-30 17:42:03 +01:00
brapru
af8b7248c8 LibC: Allow empty spwd members when writing shadow entries via putspent
Previously there was no way to output an empty value into the shadow
file entries when the spwd members were disabled. This would cause new
user entries to the shadow file to be cluttered with disabled values.
This commit checks if the spwd member value is diabled (-1) and will
output as appropriate.
2021-05-30 17:42:03 +01:00
brapru
54578ec5d4 Utilities: Update userdel to use /etc/shadow
Updates userdel to delete entries from /etc/shadow.

Fixes #4884
2021-05-30 17:42:03 +01:00