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

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -23,12 +23,12 @@ static int read_event(int fd)
return rc;
}
static DeprecatedString get_event_name()
static ByteString get_event_name()
{
if (event->name_length == 0)
return DeprecatedString();
return ByteString();
return DeprecatedString { event->name, event->name_length - 1 };
return ByteString { event->name, event->name_length - 1 };
}
TEST_CASE(inode_watcher_metadata_modified_event)

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibFileSystem/FileSystem.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
@ -23,7 +23,7 @@ TEST_CASE(test_mktemp_unique_filename)
if (fork() == 0) {
char path[] = "/tmp/test.mktemp.XXXXXX";
auto temp_path = DeprecatedString::formatted("{}", mktemp(path));
auto temp_path = ByteString::formatted("{}", mktemp(path));
EXPECT(temp_path.characters());
unlink(path);
@ -33,10 +33,10 @@ TEST_CASE(test_mktemp_unique_filename)
} else {
wait(NULL);
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
auto path1 = ByteString::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mktemp.XXXXXX";
auto path2 = DeprecatedString::formatted("{}", mktemp(path));
auto path2 = ByteString::formatted("{}", mktemp(path));
EXPECT(path2.characters());
unlink(path);
@ -53,7 +53,7 @@ TEST_CASE(test_mkdtemp_unique_filename)
if (fork() == 0) {
char path[] = "/tmp/test.mkdtemp.XXXXXX";
auto temp_path = DeprecatedString::formatted("{}", mkdtemp(path));
auto temp_path = ByteString::formatted("{}", mkdtemp(path));
EXPECT(temp_path.characters());
rmdir(path);
@ -63,10 +63,10 @@ TEST_CASE(test_mkdtemp_unique_filename)
} else {
wait(NULL);
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
auto path1 = ByteString::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mkdtemp.XXXXXX";
auto path2 = DeprecatedString::formatted("{}", mkdtemp(path));
auto path2 = ByteString::formatted("{}", mkdtemp(path));
EXPECT(path2.characters());
rmdir(path);
@ -86,8 +86,8 @@ TEST_CASE(test_mkstemp_unique_filename)
auto fd = mkstemp(path);
EXPECT_NE(fd, -1);
auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
auto temp_path = temp_path_string.to_deprecated_string();
auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
auto temp_path = temp_path_string.to_byte_string();
EXPECT(temp_path.characters());
close(fd);
@ -99,14 +99,14 @@ TEST_CASE(test_mkstemp_unique_filename)
} else {
wait(NULL);
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
auto path1 = ByteString::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mkstemp.XXXXXX";
auto fd = mkstemp(path);
EXPECT(fd != -1);
auto path2_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
auto path2 = path2_string.to_deprecated_string();
auto path2_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
auto path2 = path2_string.to_byte_string();
EXPECT(path2.characters());
close(fd);
@ -128,8 +128,8 @@ TEST_CASE(test_mkstemps_unique_filename)
auto fd = mkstemps(path, 6);
EXPECT_NE(fd, -1);
auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
auto temp_path = temp_path_string.to_deprecated_string();
auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
auto temp_path = temp_path_string.to_byte_string();
EXPECT(temp_path.characters());
close(fd);
@ -145,14 +145,14 @@ TEST_CASE(test_mkstemps_unique_filename)
} else {
wait(NULL);
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
auto path1 = ByteString::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mkstemps.prefixXXXXXXsuffix";
auto fd = mkstemps(path, 6);
EXPECT(fd != -1);
auto path2_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
auto path2 = path2_string.to_deprecated_string();
auto path2_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
auto path2 = path2_string.to_byte_string();
EXPECT(path2.characters());
close(fd);

View file

@ -37,7 +37,7 @@ TEST_CASE(memmem_search)
auto expected = test_case.matching_offset >= 0 ? test_case.haystack + test_case.matching_offset : nullptr;
auto result = memmem(test_case.haystack, test_case.haystack_length, test_case.needle, test_case.needle_length);
if (result != expected) {
FAIL(DeprecatedString::formatted("Test {} FAILED! expected {:p}, got {:p}", i, expected, result));
FAIL(ByteString::formatted("Test {} FAILED! expected {:p}, got {:p}", i, expected, result));
}
++i;
}

View file

@ -12,9 +12,9 @@
#include <time.h>
#include <unistd.h>
static DeprecatedString random_dirname()
static ByteString random_dirname()
{
return DeprecatedString::formatted("/tmp/test_mkdir_{:04x}", (u16)rand());
return ByteString::formatted("/tmp/test_mkdir_{:04x}", (u16)rand());
}
TEST_SETUP
@ -46,7 +46,7 @@ TEST_CASE(insufficient_permissions)
TEST_CASE(nonexistent_parent)
{
auto parent = random_dirname();
auto child = DeprecatedString::formatted("{}/foo", parent);
auto child = ByteString::formatted("{}/foo", parent);
int res = mkdir(child.characters(), 0755);
int cached_errno = errno;
EXPECT(res < 0);

View file

@ -10,7 +10,7 @@
#include <pwd.h>
struct PasswdEntry {
DeprecatedString name;
ByteString name;
uid_t uid {};
};

View file

@ -6,7 +6,7 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/QuickSort.h>
#include <AK/Random.h>
#include <AK/Vector.h>
@ -54,7 +54,7 @@ TEST_CASE(quick_sort)
auto const& key1 = test_objects[i].m_key;
auto const& key2 = test_objects[i + 1].m_key;
if (key1 > key2) {
FAIL(DeprecatedString::formatted("saw key {} before key {}\n", key1, key2));
FAIL(ByteString::formatted("saw key {} before key {}\n", key1, key2));
}
}
// Check that the object's payloads have not been corrupted
@ -62,7 +62,7 @@ TEST_CASE(quick_sort)
auto const expected = calc_payload_for_pos(i);
auto const payload = test_objects[i].m_payload;
if (payload != expected) {
FAIL(DeprecatedString::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload));
FAIL(ByteString::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload));
}
}
}

View file

@ -6,7 +6,7 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/StringBuilder.h>
#include <errno.h>
#include <limits.h>
@ -24,7 +24,7 @@ static constexpr size_t ITERATION_DEPTH = 17;
static void check_result(char const* what, StringView expected, char const* actual)
{
if (expected != actual)
FAIL(DeprecatedString::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0));
FAIL(ByteString::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0));
}
TEST_CASE(overlong_realpath)
@ -50,7 +50,7 @@ TEST_CASE(overlong_realpath)
expected.append({ tmp_dir, strlen(tmp_dir) });
// But first, demonstrate the functionality at a reasonable depth:
auto expected_str = expected.to_deprecated_string();
auto expected_str = expected.to_byte_string();
check_result("getwd", expected_str, getwd(static_cast<char*>(calloc(1, PATH_MAX))));
check_result("getcwd", expected_str, getcwd(nullptr, 0));
check_result("realpath", expected_str, realpath(".", nullptr));
@ -59,7 +59,7 @@ TEST_CASE(overlong_realpath)
ret = mkdir(PATH_LOREM_250, S_IRWXU);
if (ret < 0) {
perror("mkdir iter");
FAIL(DeprecatedString::formatted("Unable to mkdir the overlong path fragment in iteration {}", i));
FAIL(ByteString::formatted("Unable to mkdir the overlong path fragment in iteration {}", i));
return;
}
expected.append('/');
@ -67,14 +67,14 @@ TEST_CASE(overlong_realpath)
ret = chdir(PATH_LOREM_250);
if (ret < 0) {
perror("chdir iter");
FAIL(DeprecatedString::formatted("Unable to chdir to the overlong path fragment in iteration {}", i));
FAIL(ByteString::formatted("Unable to chdir to the overlong path fragment in iteration {}", i));
return;
}
}
outln("cwd should now be ridiculously large");
// Evaluate
expected_str = expected.to_deprecated_string();
expected_str = expected.to_byte_string();
check_result("getwd", {}, getwd(static_cast<char*>(calloc(1, PATH_MAX))));
check_result("getcwd", expected_str, getcwd(nullptr, 0));

View file

@ -165,7 +165,7 @@ void twalk_action(void const* node, VISIT order, int depth)
// Special case: End signaled by tester.
if (depth == TWALK_CHECK_END) {
if (tests[count].depth != TWALK_END_MARKER) {
FAIL(DeprecatedString::formatted("Expected action (node={:#x}, order={}, depth={}), but twalk ended early.",
FAIL(ByteString::formatted("Expected action (node={:#x}, order={}, depth={}), but twalk ended early.",
tests[count].node, U8(tests[count].order), tests[count].depth));
}
return;
@ -173,7 +173,7 @@ void twalk_action(void const* node, VISIT order, int depth)
// Special case: End marker reached.
if (tests[count].depth == TWALK_END_MARKER) {
FAIL(DeprecatedString::formatted("Expected end, but twalk sent another action (node={:#x}, order={}, depth={}).",
FAIL(ByteString::formatted("Expected end, but twalk sent another action (node={:#x}, order={}, depth={}).",
node, U8(order), depth));
return;
}

View file

@ -28,7 +28,7 @@ struct Testcase {
size_t dest_expected_n; // == dest_n
};
static DeprecatedString show(ByteBuffer const& buf)
static ByteString show(ByteBuffer const& buf)
{
StringBuilder builder;
for (size_t i = 0; i < buf.size(); ++i) {
@ -43,7 +43,7 @@ static DeprecatedString show(ByteBuffer const& buf)
builder.append('_');
}
builder.append(')');
return builder.to_deprecated_string();
return builder.to_byte_string();
}
template<typename TArg>

View file

@ -22,7 +22,7 @@ struct Testcase {
size_t dest_expected_n; // == dest_n
};
static DeprecatedString show(ByteBuffer const& buf)
static ByteString show(ByteBuffer const& buf)
{
StringBuilder builder;
for (size_t i = 0; i < buf.size(); ++i) {
@ -37,7 +37,7 @@ static DeprecatedString show(ByteBuffer const& buf)
builder.append('_');
}
builder.append(')');
return builder.to_deprecated_string();
return builder.to_byte_string();
}
static bool test_single(Testcase const& testcase)

View file

@ -7,7 +7,7 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Format.h>
#include <stdlib.h>
#include <string.h>
@ -330,7 +330,7 @@ static long long hex_to_ll(char const* hex)
} else if ('a' <= ch && ch <= 'f') {
digit = ch - 'a' + 10;
} else {
FAIL(DeprecatedString::formatted("\n!!! Encountered char {:02x} at {}", ch, i));
FAIL(ByteString::formatted("\n!!! Encountered char {:02x} at {}", ch, i));
return result;
}
result <<= 4;
@ -366,7 +366,7 @@ TEST_CASE(strtod_accuracy)
}
outln("Out of {} tests, saw {} successes and {} fails.", NUM_TESTCASES, successes, fails);
if (fails != 0) {
FAIL(DeprecatedString::formatted("{} strtod tests failed", fails));
FAIL(ByteString::formatted("{} strtod tests failed", fails));
}
outln("PASS (with leniency up to {} ULP from the exact solution)", LENIENCY);

View file

@ -215,7 +215,7 @@ TEST_CASE(mbsinit)
size_t ret = mbrtowc(nullptr, "\xdf", 1, &state);
if (ret != -2ul)
FAIL(DeprecatedString::formatted("mbrtowc accepted partial multibyte sequence with return code {} (expected -2)", static_cast<ssize_t>(ret)));
FAIL(ByteString::formatted("mbrtowc accepted partial multibyte sequence with return code {} (expected -2)", static_cast<ssize_t>(ret)));
// Ensure that we are not in an initial state.
EXPECT(mbsinit(&state) == 0);
@ -224,7 +224,7 @@ TEST_CASE(mbsinit)
ret = mbrtowc(nullptr, "\xbf", 1, &state);
if (ret != 1ul)
FAIL(DeprecatedString::formatted("mbrtowc did not consume the expected number of bytes (1), returned {} instead", static_cast<ssize_t>(ret)));
FAIL(ByteString::formatted("mbrtowc did not consume the expected number of bytes (1), returned {} instead", static_cast<ssize_t>(ret)));
// Ensure that we are in an initial state again.
EXPECT(mbsinit(&state) != 0);