Commit graph

287 commits

Author SHA1 Message Date
Andreas Kling b7cca76ca2 AK: Add an extremely primitive unit test for String.
This builds for the host system rather than for Serenity.
We need to improve on it a *lot*, but at least it's a place to start.
2019-06-14 06:42:21 +02:00
Sergey Bugaev 1a697f70db AK: Add more StringView utilities for making substrings.
These two allow making a new substring view starting from,
or starting after, an existing substring view.

Also make use of one of them in the kernel.
2019-06-14 06:24:02 +02:00
Sergey Bugaev 3e326de8fa AK: Fix nullptr dereference in String::matches().
In case cp and mp were never set, we should not try
to use them.
2019-06-14 06:24:02 +02:00
Sergey Bugaev e585ed48b0 AK: Fix String::matches() with non-null-terminated StringViews.
StringView character buffer is not guaranteed to be null-terminated;
in particular it will not be null-terminated when making a substring.
This means it is not correct to check whether we've reached the end
of a StringView by comparing the next character to null; instead, we
need to do an explicit length (or pointer) comparison.
2019-06-14 06:24:02 +02:00
Conrad Pankoff f7dce4765c AK: Add find_first_{set,unset} and grow methods to Bitmap 2019-06-12 15:38:17 +02:00
Andreas Kling e673bb921e AK: Delete the Badge copy and move constructors. 2019-06-11 23:47:51 -07:00
Andreas Kling cdb44be703 StringView: Store a StringImpl* rather than a String*. 2019-06-08 23:55:13 +02:00
Andreas Kling 6a51093ab1 AK: Add String::operator==(const char*).
Without this function, comparing a String to a const char* will instantiate
a temporary String which is obviously not great.

Also add some missing null checks to StringView::operator==(const char*).
2019-06-08 18:32:09 +02:00
Andreas Kling de65c960e9 Kernel: Tweak some String&& => const String&.
String&& is just not very practical. Also return const String& when the
returned string is a member variable. The call site is free to make a copy
if he wants, but otherwise we can avoid the retain count churn.
2019-06-07 20:58:12 +02:00
Andreas Kling de9edb0169 StringView: operator==(const char*) needs to stop when the view ends.
We were comparing past the end of the view, which was clearly not correct.
2019-06-07 19:22:58 +02:00
Andreas Kling a0bde822ee AK: Add IterationDecision.h. 2019-06-07 17:14:16 +02:00
Andreas Kling 39d1a9ae66 Meta: Tweak .clang-format to not wrap braces after enums. 2019-06-07 17:13:23 +02:00
Andreas Kling 9145917bf0 ELF: Run clang-format on everything. 2019-06-07 17:12:30 +02:00
Andreas Kling e42c3b4fd7 Kernel: Rename LinearAddress => VirtualAddress. 2019-06-07 12:56:50 +02:00
Andreas Kling b34b084619 AK: Run clang-format on everything. 2019-06-07 11:46:22 +02:00
Andreas Kling 7ad8790d80 LibGUI: Run clang-format on everything. 2019-06-07 11:46:02 +02:00
Andreas Kling 98eeb8f22d AK: Rename printf.cpp to PrintfImplementation.h. 2019-06-07 11:41:11 +02:00
Andreas Kling 69a6ce90df AK: Add a ScopeGuard helper that invokes a callback when destroyed.
This is useful when you want to ensure some little thing happens when you
exit a certain scope.

This patch makes use of it in LibC's netdb code to make sure we close the
connection to the LookupServer.
2019-06-07 09:19:15 +02:00
Andreas Kling 29a9430246 AK: Make timeval_add() and timeval_sub() take references. 2019-06-06 18:02:28 +02:00
Conrad Pankoff 419e886497 AK: Add String::starts_with to match String::ends_with 2019-06-04 04:58:35 -07:00
Conrad Pankoff 042895317d AK: Add AKString::split_limit to split strings with a limit
This is a small change to the existing split() functionality to support
the case of splitting a string and stopping at a certain number of
tokens. This is useful for parsing e.g. key/value pairs, where the value
may contain the delimiter you're splitting on.
2019-06-04 10:16:45 +02:00
Andreas Kling ccc6e69a29 LibC: Implement popen() and pclose().
I feel reasonably confident that I might have gotten these right. :^)
2019-06-03 21:17:58 +02:00
Robin Burchell 1024dfa81a StringViewize a bunch of things -- mostly LibGUI 2019-06-03 20:27:05 +02:00
Robin Burchell f9ba7adae2 StringView: Make construction of String from a StringView containing a String cheaper
... at the cost of an additional pointer per view.
2019-06-03 20:27:05 +02:00
Robin Burchell 7bce096afd Take StringView in more places
We should work towards a pattern where we take StringView as function
arguments, and store String as member, to push the String construction
to the last possible moment.
2019-06-02 12:55:51 +02:00
Robin Burchell b55b6cd7fc AK: Add implicit String -> StringView conversion
And tidy up existing view() users.
2019-06-02 12:55:51 +02:00
Andreas Kling e24f18dd83 AK: Add a comment to String about the relationship with StringImpl. 2019-06-02 08:37:01 +02:00
Andreas Kling b8e705da0e LibCore: CObjects without is<T> specialization shouldn't LARP as others. 2019-06-01 14:11:31 +02:00
Christopher Dumas 6a4cb25557 Terminal: Settings windows can be opened multiple times 2019-06-01 00:07:45 +02:00
Christopher Dumas f8a02d4733 Terminal: Audible vs Visible beep option 2019-06-01 00:07:45 +02:00
Andreas Kling 3a1d5fa112 ELFLoader: Fix typo in segment naming.
Executable segments now get an "x" character in their region name.
2019-05-30 16:23:48 +02:00
Andreas Kling baaede1bf9 Kernel: Make the Process allocate_region* API's understand "int prot".
Instead of having to inspect 'prot' at every call site, make the Process
API's take care of that so we can just pass it through.
2019-05-30 16:14:37 +02:00
Andreas Kling 08926e59b3 Kernel: Add InodeFile, a File subclass for regular files.
Finally everything that can be held by a FileDescriptor actually inherits
from the File class.
2019-05-30 13:39:17 +02:00
Robin Burchell 0dc9af5f7e Add clang-format file
Also run it across the whole tree to get everything using the One True Style.
We don't yet run this in an automated fashion as it's a little slow, but
there is a snippet to do so in makeall.sh.
2019-05-28 17:31:20 +02:00
Andreas Kling cbd858544d LibC: Move struct timeval to sys/time.h. #POSIX 2019-05-28 13:48:06 +02:00
Robin Burchell 9947ee9566 Shell: Allow * and ? wildcard expansion in arguments
Should also presumably allow for escaping and such, but this is a start.
Fixes #112.
2019-05-28 00:17:39 +02:00
Andreas Kling 12120167a9 AK: Add ensure_capacity() for HashMap and HashTable.
These functions make sure that the underlying table can accomodate at least
'capacity' entries before needing a rehash.
2019-05-27 13:07:20 +02:00
Andreas Kling 5ba2dba392 FileSystemPath: Add a has_extension() helper.
This code:

    if (path.string().to_lowercase().ends_with(".foo"))

Can now be written as:

    if (path.has_extension(".foo"))
2019-05-27 01:53:42 +02:00
Faissal Bensefia 411cdf067b AK: Implement String::to_int (#99) 2019-05-26 04:08:36 +02:00
Robin Burchell 23a5ce3319 QuickSort: Don't sort a single item, nothing to do 2019-05-26 01:47:41 +02:00
Andreas Kling ad908f1395 WindowServer: Factor out compositing from WSWindowManager into WSCompositor.
This is far from finished and the two classes are awkwardly grabbing at each
other's innards, but here's a first step in the right direction.
2019-05-24 19:32:46 +02:00
Robin Burchell 6917c42140 Kernel/AK: Move ELF loader to AK
This is in preparation for eventually using it in userspace.
LinearAddress.h has not been moved for the time being (as it seems to be
only used by a very small part of the code).
2019-05-23 16:57:34 +02:00
Andreas Kling a8313ae0a3 AK: Always inline convert_between_host_and_network<T>. 2019-05-21 16:14:02 +02:00
Andreas Kling 52f135fe13 AK: Add some more features to Vector iterators. 2019-05-21 01:36:36 +02:00
Andreas Kling 6e305bf838 AK: Simplify quick_sort() and improve Vector iterators a bit. 2019-05-19 01:53:51 +02:00
Robin Burchell df74a9222f Kernel: Fix timeout support in select
The scheduler expects m_select_timeout to act as a deadline. That is, it
should contain the time that a task should wake at -- but we were
directly copying the time from userspace, which meant that it always
returned virtually immediately.

At the same time, fix CEventLoop to not rely on the broken select behavior
by subtracting the current time from the time of the nearest timer.
2019-05-18 02:57:38 +02:00
Robin Burchell 5babcac289 Build: Install most headers to Root (and libcore.a/libgui.a)
This makes out-of-tree linking possible. And at the same time, add a
CMakeToolchain.txt file that can be used to build arbitrary cmake-using
applications on Serenity by pointing to the CMAKE_TOOLCHAIN_FILE when
running cmake:

    -DCMAKE_TOOLCHAIN_FILE=~/code/serenity/Toolchain/CMakeToolchain.txt
2019-05-17 21:59:48 +02:00
Robin Burchell 77dfd419e9 LibCore: Move AK/ArgsParser to LibCore/CArgsParser
Also rename the classes to match LibCore naming style.
This means that it's no longer incorrectly linked into LibC and Kernel.
2019-05-17 15:49:37 +02:00
Robin Burchell bffed9e3cb ArgsParser: Expand to be able to handle multiple single arguments
This is needed for e.g. ln
2019-05-17 15:49:37 +02:00
Robin Burchell 6dd7ee53ea AK/Userland: Add single value to ArgsParser usage, and port tail to use ArgsParser 2019-05-17 15:49:37 +02:00