1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:47:34 +00:00

AK: Remove the ctype adapters and use the actual ctype functions instead

This finally takes care of the kind-of excessive boilerplate code that were the
ctype adapters. On the other hand, I had to link `LibC/ctype.cpp` to the Kernel
(for `AK/JsonParser.cpp` and `AK/Format.cpp`). The previous commit actually makes
sense now: the `string.h` includes in `ctype.{h,cpp}` would require to link more LibC
stuff to the Kernel when it only needs the `_ctype_` array of `ctype.cpp`, and there
wasn't any string stuff used in ctype.
Instead of all this I could have put static derivatives of `is_any_of()` in the
concerned AK files, however that would have meant more boilerplate and workarounds;
so I went for the Kernel approach.
This commit is contained in:
Benoît Lormeau 2020-09-27 12:44:03 +02:00 committed by Andreas Kling
parent f158cb27ea
commit f0f6b09acb
8 changed files with 33 additions and 125 deletions

View file

@ -35,6 +35,7 @@
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
#include <LibCore/ProcessStatisticsReader.h>
#include <ctype.h>
#include <stdio.h>
struct OpenFile {
@ -56,8 +57,8 @@ static bool parse_name(StringView name, OpenFile& file)
return true;
} else {
file.type = component1;
auto component2 = lexer.consume_while([](char c) { return is_printable(c) && !is_whitespace(c) && c != '('; });
lexer.ignore_while(is_whitespace);
auto component2 = lexer.consume_while([](char c) { return isprint(c) && !isspace(c) && c != '('; });
lexer.ignore_while(isspace);
file.name = component2;
if (lexer.tell_remaining() == 0) {