Commit graph

12532 commits

Author SHA1 Message Date
Peter Elliott
274be68102 Chess: Allow resizing Chess using resize_aspect_ratio(1,1) 2020-08-23 01:05:22 +02:00
Peter Elliott
45ed58865e LibGUI+WindowServer: Add resize_aspect_ratio()
When a resize_aspect_ratio is specified, and window will only be resized
to a multiple of that ratio. When resize_aspect_ratio is set, windows
cannot be tiled.
2020-08-23 01:05:22 +02:00
Peter Elliott
c68537271c AK: Add operator== to AK::Optional
The semantics:
- two Optionals are equal if they are both None
- two Optionals are equal if they are both Some, and their values are
  operator==
2020-08-23 01:05:22 +02:00
Peter Elliott
b0ffd4e946 Chess: Optionaly display coordinates at edge of board 2020-08-23 01:05:22 +02:00
Peter Elliott
28db3cd5ef LibGfx: Add TextAlignment::BottomRight 2020-08-23 01:05:22 +02:00
Ben Wiederhake
23a43d10f3 LibCrypto: Don't cause errors when function unused
Any (future) program that includes this header would fail to compile, because the
private symbol 'kind_name' is defined, along with a bunch of code, but unused.

A good way to see this is by #include'ing LibCrypto/ASN1/ASN1.h in an unrelated
.cpp-file, for example Userland/md.cpp.

No other headers seem to have this problem.
2020-08-23 00:53:16 +02:00
Ben Wiederhake
2a2630edc9 Meta: Fix wrong 'using namespace X' usages
Apart from causing All AK:: and Crypto:: symbols being suddenly visible even though
they might not be supposed to be, the style guide also says this is wrong:

https://github.com/SerenityOS/serenity/blob/master/Documentation/CodingStyle.md#using-statements
2020-08-23 00:53:16 +02:00
Ben Wiederhake
4f77ccbda8 LibC+Userland: Prefer snprintf over sprintf
I ignored the sprintf in Userland/cal.cpp because it's too much trouble.
However, this only underlines the need for bounds checking.
2020-08-22 20:55:10 +02:00
Ben Wiederhake
1aad0f8b16 Kernel: Stop supporting sprintf
The kernel no longer needs sprintf (which might, in theory, overflow),
so we can hide the C++ declaration and make the function uncallable
from within the kernel.

However, libstdc++ still links against it, as libstdc++ uses it for
demangling, from AK::demangle().
2020-08-22 20:55:10 +02:00
Ben Wiederhake
04f494fc44 AK: Prefer snprintf over sprintf 2020-08-22 20:55:10 +02:00
Ben Wiederhake
b6afe1f0ce Kernel: Prefer snprintf over sprintf 2020-08-22 20:55:10 +02:00
Ben Wiederhake
0240baa42d AK+Kernel: Support snprintf
In contrast to sprintf, which might overflow the given buffer.

I feel bad about the code duplication, but that is a pre-existing issue.
2020-08-22 20:55:10 +02:00
Ben Wiederhake
2d34f0f93a LibC: Fix off-by-one in snprintf()
snprintf is supposed to *always* NUL-terminate its output, so it has to write one
output byte fewer.

And yes, I *did* check all existing usages; this shouldn't break anything.
2020-08-22 20:55:10 +02:00
Ben Wiederhake
499e953380 LibC: Demonstrate off-by-one in current snprintf
The function whose main selling point is that there always is a
NUL-terminator ... missed the NUL-terminator.
2020-08-22 20:55:10 +02:00
AnotherTest
db18e75a09 Shell: Add tests for 'if' 2020-08-22 20:53:21 +02:00
AnotherTest
b90eb5c9ba Shell: Add 'if' expressions
```sh
if foo bar baz {
    quux
} else if foobar || whatever {
    echo I ran out of example words
} else {
    exit 2
}
```
2020-08-22 20:53:21 +02:00
asynts
c2be38e50f AK: TestSuite: Terminate when ASSERT_NOT_REACHED is called.
Previously, it would just print something with 'FAIL' to stderr which
would be picked up by CTest. However, some code assumes that
ASSERT_NOT_REACHED() doesn't return, for example:

    bool foo(int value) {
        switch(value) {
        case 0:
            return true;
        case 1:
            return false;
        default:
            ASSERT_NOT_REACHED();
        }

        // warning: control reaches end of non-void function
    }
2020-08-22 20:52:19 +02:00
AnotherTest
103f659ef6 Shell: Actually process for loop entries as a stream
This actually does what d4bcc68 meant to do.
2020-08-22 20:52:07 +02:00
AnotherTest
2c14abedd6 Shell: Do not flatten syntactic lists in for_each_entry() 2020-08-22 20:52:07 +02:00
AnotherTest
0676bd4afc Shell: Mark AST::Background as would_execute if its subnode does 2020-08-22 20:52:07 +02:00
Andreas Kling
2fd9e72264 Revert "Kernel: Switch singletons to use new Singleton class"
This reverts commit f48feae0b2.
2020-08-22 18:01:59 +02:00
Andreas Kling
0addcb45b8 Kernel: Make Process::dump_regions() sort the regions before dumping 2020-08-22 18:01:59 +02:00
Ben Wiederhake
9a0cd9a50d Kernel: Prevent confusing silent misuse of PCI::Address 2020-08-22 17:18:14 +02:00
Ben Wiederhake
b4f26c2b31 AK: Prevent confusing silent misuse of Userspace<T> 2020-08-22 17:18:14 +02:00
Ben Wiederhake
a6314f2ce6 AK: Fix description of DistinctNumeric around operator bool 2020-08-22 17:18:14 +02:00
Ben Wiederhake
4acdb60ba3 AK: Prevent confusing silent misuse of ByteBuffer
Thankfully, this hasn't happened in any other code yet, but it happened
while I was trying something out. Using '==' on two ByteBuffers to check
whether they're equal seemed straight-forward, so I ran into the trap.
2020-08-22 17:18:14 +02:00
Ben Wiederhake
901ed9b85d AK: Demonstrate surprising ByteBuffer behavior
This seems to be because ByteBuffer implements 'operator bool', and C++
considers bool to be an integer type. Thus, when trying to find a way to
evaluate '==', it attempts integer promotion, which in turn finds 'operator bool'.

This explains why all non-empty buffers seem to be equal, but different from the
empty one. Also, why comparison seems to be implemented.
2020-08-22 17:18:14 +02:00
Andreas Kling
8925ad3fa0 Revert "Kernel: Move Singleton class to AK"
This reverts commit f0906250a1.
2020-08-22 16:34:49 +02:00
Andreas Kling
b0a24a83be Revert "Kernel: Fix regression where MemoryManager is initialized twice"
This reverts commit 8a75e0b892.
2020-08-22 16:34:15 +02:00
Andreas Kling
68580d5a8d Revert "AK: Get rid of make_singleton function"
This reverts commit 5a98e329d1.
2020-08-22 16:34:14 +02:00
Andreas Kling
8a21491d86 Revert "Kernel: Copy command line to a safe place"
This reverts commit 41c005cb14.
2020-08-22 16:34:12 +02:00
Andreas Kling
0db7e04c2e Revert "Kernel: Make PhysicalPage not movable and use atomic ref counting"
This reverts commit a89ccd842b.
2020-08-22 16:34:11 +02:00
Andreas Kling
23f335bcd7 Revert "Kernel: Fix kmalloc memory corruption"
This reverts commit b306f240a4.
2020-08-22 16:34:08 +02:00
Andreas Kling
e374eb3035 LibGUI+WindowServer: Remove ResizeEvent::old_size()
Turns out nobody was using this information anyway, so let's not go
through all the trouble of plumbing it from WindowServer to LibGUI.

Fixes #3247.
2020-08-22 13:11:25 +02:00
Andreas Kling
683ae4f7ad LibGUI: Fix crash during HackStudio application teardown
We can't rely on a plain global WeakPtr during application teardown
since destruction order is not defined. Instead, use a NeverDestroyed
to hold the GUI::Application weak pointer. This way it will always
be reliable.

Fixes #3251.
2020-08-22 13:10:14 +02:00
thankyouverycool
0359a5ce27 MenuApplets: Add a mini calendar to Clock applet 2020-08-22 11:54:30 +02:00
thankyouverycool
ab3fff4211 LibGUI+Calendar: Make Calendar a common widget in LibGUI
Refactors the Calendar widget into LibGUI and updates the Calendar
app interface. Calendar widget lets layout engine manage most of
its geometry now and has a few new features like tile click
navigation, hover highlighting and a togglable year/month mode.
2020-08-22 11:54:30 +02:00
thankyouverycool
918f2c592d LibCore: Fix spelling for month of "August" 2020-08-22 11:54:30 +02:00
thankyouverycool
efb55b1a4f Base: Add new Calendar icons 2020-08-22 11:54:30 +02:00
Nico Weber
c399caf27f LibC: Make mktime() and timegm() handle years before 1970
And also years that don't fit in 32-bit.

Lovingly tested via LibJS's Date.UTC(), which happens to call
timegm().
2020-08-22 10:53:33 +02:00
Nico Weber
96891669c3 test-js: Sometimes include more details for failures
LibJS doesn't store stacks for exception objects, so this
only amends test-common.js's __expect() with an optional
`details` function that can produce a more detailed error
message, and it lets test-js.cpp read and print that
error message.  I added the optional details parameter to
a few matchers, most notably toBe() where it now prints
expected and actual value.

It'd be nice to have line numbers of failures, but that
seems hard to do with the current design, and this is already
much better than the current state.
2020-08-22 10:52:40 +02:00
Nico Weber
3fbb02c3cc test-js: Print parse error if test-common.js fails to parse 2020-08-22 10:52:40 +02:00
Nico Weber
ebd510ef5e LibJS: Allow conversion from Symbol to String via explicit String() call
https://tc39.es/ecma262/#sec-string-constructor-string-value has an
explicit special case for Symbols allowing this:

    If NewTarget is undefined and Type(value) is Symbol,
    return SymbolDescriptiveString(value).
2020-08-22 10:52:40 +02:00
asynts
aa25fb8875 Userland: Use TestSuite.h in test-compress. 2020-08-22 10:46:56 +02:00
asynts
d2121ab7c7 AK: Make some tweaks in TestSuite.h. 2020-08-22 10:46:56 +02:00
asynts
207b9774e0 AK: Remove <chrono> requirement from TestSuite.h. 2020-08-22 10:46:56 +02:00
asynts
20a7d2c61b AK: Remove exceptions from TestSuite.h.
Serenity is build with -fno-exceptions, this is an effort to make
TestSuite.h useable in the userland.
2020-08-22 10:46:56 +02:00
asynts
d5999c3811 AK: Move include <AK/TestSuite.h> to the top.
clang-format automatically sorts include statements that are in a
'block'. Adding a whitespace prevents this. It is crutial that
<AK/TestSuite.h> is included first because it redefines some macros.
2020-08-22 10:46:56 +02:00
asynts
39b464dcfd AK: Remove test case that doesn't test anything.
Currently, there is no way to check that an assert fails. This test
passes regardless of the assert. (AK/HashTable.h:93)
2020-08-22 10:46:56 +02:00
Tom
b306f240a4 Kernel: Fix kmalloc memory corruption
Rather than hardcoding where the kmalloc pool should be, place
it at the end of the kernel image instead. This avoids corrupting
global variables or other parts of the kernel as it grows.

Fixes #3257
2020-08-22 10:46:24 +02:00