Everywhere: Behaviour => Behavior

This commit is contained in:
Andreas Kling 2021-09-07 12:56:50 +02:00
parent 55b0b06897
commit 6ad427993a
Notes: sideshowbarker 2024-07-18 04:32:02 +09:00
48 changed files with 120 additions and 120 deletions

View file

@ -252,7 +252,7 @@ void FormatBuilder::put_u64(
size_t used_by_prefix = 0;
if (align == Align::Right && zero_pad) {
// We want String::formatted("{:#08x}", 32) to produce '0x00000020' instead of '0x000020'. This
// behaviour differs from both fmtlib and printf, but is more intuitive.
// behavior differs from both fmtlib and printf, but is more intuitive.
used_by_prefix = 0;
} else {
if (is_negative || sign_mode != SignMode::OnlyIfNeeded)

View file

@ -250,11 +250,11 @@ public:
}
template<typename U = T>
HashSetResult set(U&& value, HashSetExistingEntryBehavior existing_entry_behaviour = HashSetExistingEntryBehavior::Replace)
HashSetResult set(U&& value, HashSetExistingEntryBehavior existing_entry_behavior = HashSetExistingEntryBehavior::Replace)
{
auto& bucket = lookup_for_writing(value);
if (bucket.used) {
if (existing_entry_behaviour == HashSetExistingEntryBehavior::Keep)
if (existing_entry_behavior == HashSetExistingEntryBehavior::Keep)
return HashSetResult::KeptExistingEntry;
(*bucket.slot()) = forward<U>(value);
return HashSetResult::ReplacedExistingEntry;

View file

@ -547,7 +547,7 @@ void UHCIController::get_port_status(Badge<UHCIRootHub>, u8 port, HubStatus& hub
void UHCIController::reset_port(u8 port)
{
// We still have to reset the port manually because UHCI does not automatically enable the port after reset.
// Additionally, the USB 2.0 specification says the SetPortFeature(PORT_ENABLE) request is not specified and that the _ideal_ behaviour is to return a Request Error.
// Additionally, the USB 2.0 specification says the SetPortFeature(PORT_ENABLE) request is not specified and that the _ideal_ behavior is to return a Request Error.
// Source: USB 2.0 Specification Section 11.24.2.7.1.2
// This means the hub code cannot rely on using it.

View file

@ -473,7 +473,7 @@ struct ext2_inode_large {
#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
/*
* Behaviour when detecting errors
* Behavior when detecting errors
*/
#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
@ -501,7 +501,7 @@ struct ext2_super_block {
__s16 s_max_mnt_count; /* Maximal mount count */
__u16 s_magic; /* Magic signature */
__u16 s_state; /* File system state */
__u16 s_errors; /* Behaviour when detecting errors */
__u16 s_errors; /* Behavior when detecting errors */
__u16 s_minor_rev_level; /* minor revision level */
__u32 s_lastcheck; /* time of last check */
__u32 s_checkinterval; /* max. time between checks */

View file

@ -9,7 +9,7 @@
#include <AK/StringView.h>
#include <AK/Trie.h>
TEST_CASE(normal_behaviour)
TEST_CASE(normal_behavior)
{
Trie<char, String> dictionary('/', "");
constexpr StringView data[] { "test", "example", "foo", "foobar" };

View file

@ -154,17 +154,17 @@ auto CSVExportDialogPage::make_writer() -> Optional<XSV>
quote_escape,
};
auto behaviours = Writer::default_behaviours();
auto behaviors = Writer::default_behaviors();
Vector<String> empty_headers;
auto* headers = &empty_headers;
if (should_export_headers) {
behaviours = behaviours | Writer::WriterBehaviour::WriteHeaders;
behaviors = behaviors | Writer::WriterBehavior::WriteHeaders;
headers = &m_headers;
}
if (should_quote_all_fields)
behaviours = behaviours | Writer::WriterBehaviour::QuoteAll;
behaviors = behaviors | Writer::WriterBehavior::QuoteAll;
// Note that the stream is used only by the ctor.
auto stream = Core::OutputFileStream::open(m_temp_output_file_path);
@ -172,7 +172,7 @@ auto CSVExportDialogPage::make_writer() -> Optional<XSV>
dbgln("Cannot open {} for writing: {}", m_temp_output_file_path, stream.error());
return {};
}
XSV writer(stream.value(), m_data, traits, *headers, behaviours);
XSV writer(stream.value(), m_data, traits, *headers, behaviors);
if (stream.value().has_any_error()) {
dbgln("Write error when making preview");

View file

@ -135,16 +135,16 @@ auto CSVImportDialogPage::make_reader() -> Optional<Reader::XSV>
quote_escape,
};
auto behaviours = Reader::default_behaviours() | Reader::ParserBehaviour::Lenient;
auto behaviors = Reader::default_behaviors() | Reader::ParserBehavior::Lenient;
if (should_read_headers)
behaviours = behaviours | Reader::ParserBehaviour::ReadHeaders;
behaviors = behaviors | Reader::ParserBehavior::ReadHeaders;
if (should_trim_leading)
behaviours = behaviours | Reader::ParserBehaviour::TrimLeadingFieldSpaces;
behaviors = behaviors | Reader::ParserBehavior::TrimLeadingFieldSpaces;
if (should_trim_trailing)
behaviours = behaviours | Reader::ParserBehaviour::TrimTrailingFieldSpaces;
behaviors = behaviors | Reader::ParserBehavior::TrimTrailingFieldSpaces;
return Reader::XSV(m_csv, move(traits), behaviours);
return Reader::XSV(m_csv, move(traits), behaviors);
};
void CSVImportDialogPage::update_preview()

View file

@ -14,8 +14,8 @@ namespace Reader {
class CSV : public XSV {
public:
CSV(StringView source, ParserBehaviour behaviours = default_behaviours())
: XSV(source, { ",", "\"", ParserTraits::Repeat }, behaviours)
CSV(StringView source, ParserBehavior behaviors = default_behaviors())
: XSV(source, { ",", "\"", ParserTraits::Repeat }, behaviors)
{
}
};

View file

@ -18,7 +18,7 @@ TEST_CASE(should_parse_valid_data)
1, 2, 3
4, 5, 6
"""x", y"z, 9)~~~";
auto csv = Reader::CSV { data, Reader::default_behaviours() | Reader::ParserBehaviour::ReadHeaders | Reader::ParserBehaviour::TrimLeadingFieldSpaces };
auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces };
csv.parse();
EXPECT(!csv.has_error());
@ -32,7 +32,7 @@ TEST_CASE(should_parse_valid_data)
1 , 2, 3
4, "5 " , 6
"""x", y"z, 9 )~~~";
auto csv = Reader::CSV { data, Reader::default_behaviours() | Reader::ParserBehaviour::ReadHeaders | Reader::ParserBehaviour::TrimLeadingFieldSpaces | Reader::ParserBehaviour::TrimTrailingFieldSpaces };
auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces | Reader::ParserBehavior::TrimTrailingFieldSpaces };
csv.parse();
EXPECT(!csv.has_error());
@ -48,7 +48,7 @@ TEST_CASE(should_fail_nicely)
{
auto data = R"~~~(Foo, Bar, Baz
x, y)~~~";
auto csv = Reader::CSV { data, Reader::default_behaviours() | Reader::ParserBehaviour::ReadHeaders | Reader::ParserBehaviour::TrimLeadingFieldSpaces };
auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces };
csv.parse();
EXPECT(csv.has_error());
EXPECT_EQ(csv.error(), Reader::ReadError::NonConformingColumnCount);
@ -57,7 +57,7 @@ TEST_CASE(should_fail_nicely)
{
auto data = R"~~~(Foo, Bar, Baz
x, y, "z)~~~";
auto csv = Reader::CSV { data, Reader::default_behaviours() | Reader::ParserBehaviour::ReadHeaders | Reader::ParserBehaviour::TrimLeadingFieldSpaces };
auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces };
csv.parse();
EXPECT(csv.has_error());
EXPECT_EQ(csv.error(), Reader::ReadError::QuoteFailure);
@ -70,7 +70,7 @@ TEST_CASE(should_iterate_rows)
1, 2, 3
4, 5, 6
"""x", y"z, 9)~~~";
auto csv = Reader::CSV { data, Reader::default_behaviours() | Reader::ParserBehaviour::ReadHeaders | Reader::ParserBehaviour::TrimLeadingFieldSpaces };
auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces };
csv.parse();
EXPECT(!csv.has_error());
@ -92,7 +92,7 @@ BENCHMARK_CASE(fairly_big_data)
memcpy(buf.offset_pointer(row * line.length()), line.characters_without_null_termination(), line.length());
}
auto csv = Reader::CSV { (char const*)buf.data(), Reader::default_behaviours() | Reader::ParserBehaviour::ReadHeaders };
auto csv = Reader::CSV { (char const*)buf.data(), Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders };
csv.parse();
EXPECT(!csv.has_error());

View file

@ -9,14 +9,14 @@
namespace Reader {
ParserBehaviour operator&(ParserBehaviour left, ParserBehaviour right)
ParserBehavior operator&(ParserBehavior left, ParserBehavior right)
{
return static_cast<ParserBehaviour>(to_underlying(left) & to_underlying(right));
return static_cast<ParserBehavior>(to_underlying(left) & to_underlying(right));
}
ParserBehaviour operator|(ParserBehaviour left, ParserBehaviour right)
ParserBehavior operator|(ParserBehavior left, ParserBehavior right)
{
return static_cast<ParserBehaviour>(to_underlying(left) | to_underlying(right));
return static_cast<ParserBehavior>(to_underlying(left) | to_underlying(right));
}
void XSV::set_error(ReadError error)
@ -46,7 +46,7 @@ Vector<String> XSV::headers() const
void XSV::parse_preview()
{
reset();
if ((m_behaviours & ParserBehaviour::ReadHeaders) != ParserBehaviour::None)
if ((m_behaviors & ParserBehavior::ReadHeaders) != ParserBehavior::None)
read_headers();
while (!has_error() && !m_lexer.is_eof()) {
@ -59,7 +59,7 @@ void XSV::parse_preview()
void XSV::parse()
{
reset();
if ((m_behaviours & ParserBehaviour::ReadHeaders) != ParserBehaviour::None)
if ((m_behaviors & ParserBehavior::ReadHeaders) != ParserBehavior::None)
read_headers();
while (!has_error() && !m_lexer.is_eof())
@ -103,7 +103,7 @@ Vector<XSV::Field> XSV::read_row(bool header_row)
}
}
auto is_lenient = (m_behaviours & ParserBehaviour::Lenient) != ParserBehaviour::None;
auto is_lenient = (m_behaviors & ParserBehavior::Lenient) != ParserBehavior::None;
if (is_lenient) {
if (m_rows.is_empty())
return row;
@ -120,7 +120,7 @@ Vector<XSV::Field> XSV::read_row(bool header_row)
row.resize(new_size);
}
} else {
auto should_read_headers = (m_behaviours & ParserBehaviour::ReadHeaders) != ParserBehaviour::None;
auto should_read_headers = (m_behaviors & ParserBehavior::ReadHeaders) != ParserBehavior::None;
if (!header_row && should_read_headers && row.size() != m_names.size())
set_error(ReadError::NonConformingColumnCount);
else if (!header_row && !has_explicit_headers() && !m_rows.is_empty() && m_rows.first().size() != row.size())
@ -132,7 +132,7 @@ Vector<XSV::Field> XSV::read_row(bool header_row)
XSV::Field XSV::read_one_field()
{
if ((m_behaviours & ParserBehaviour::TrimLeadingFieldSpaces) != ParserBehaviour::None)
if ((m_behaviors & ParserBehavior::TrimLeadingFieldSpaces) != ParserBehavior::None)
m_lexer.consume_while(is_any_of(" \t\v"));
bool is_quoted = false;
@ -144,7 +144,7 @@ XSV::Field XSV::read_one_field()
field = read_one_unquoted_field();
}
if ((m_behaviours & ParserBehaviour::TrimTrailingFieldSpaces) != ParserBehaviour::None) {
if ((m_behaviors & ParserBehavior::TrimTrailingFieldSpaces) != ParserBehavior::None) {
m_lexer.consume_while(is_any_of(" \t\v"));
if (!is_quoted) {
@ -182,7 +182,7 @@ XSV::Field XSV::read_one_quoted_field()
size_t start = m_lexer.tell(), end = start;
bool is_copy = false;
StringBuilder builder;
auto allow_newlines = (m_behaviours & ParserBehaviour::AllowNewlinesInFields) != ParserBehaviour::None;
auto allow_newlines = (m_behaviors & ParserBehavior::AllowNewlinesInFields) != ParserBehavior::None;
for (; !m_lexer.is_eof();) {
char ch;
@ -248,7 +248,7 @@ XSV::Field XSV::read_one_quoted_field()
XSV::Field XSV::read_one_unquoted_field()
{
size_t start = m_lexer.tell(), end = start;
bool allow_quote_in_field = (m_behaviours & ParserBehaviour::QuoteOnlyInFieldStart) != ParserBehaviour::None;
bool allow_quote_in_field = (m_behaviors & ParserBehavior::QuoteOnlyInFieldStart) != ParserBehavior::None;
for (; !m_lexer.is_eof();) {
if (m_lexer.next_is(m_traits.separator.view()))

View file

@ -14,7 +14,7 @@
namespace Reader {
enum class ParserBehaviour : u32 {
enum class ParserBehavior : u32 {
None = 0,
ReadHeaders = 1,
AllowNewlinesInFields = ReadHeaders << 1,
@ -27,8 +27,8 @@ enum class ParserBehaviour : u32 {
// - updates previous rows with extra columns
};
ParserBehaviour operator&(ParserBehaviour left, ParserBehaviour right);
ParserBehaviour operator|(ParserBehaviour left, ParserBehaviour right);
ParserBehavior operator&(ParserBehavior left, ParserBehavior right);
ParserBehavior operator|(ParserBehavior left, ParserBehavior right);
struct ParserTraits {
String separator;
@ -52,18 +52,18 @@ enum class ReadError {
#undef E
};
constexpr ParserBehaviour default_behaviours()
constexpr ParserBehavior default_behaviors()
{
return ParserBehaviour::QuoteOnlyInFieldStart;
return ParserBehavior::QuoteOnlyInFieldStart;
}
class XSV {
public:
XSV(StringView source, ParserTraits traits, ParserBehaviour behaviours = default_behaviours())
XSV(StringView source, ParserTraits traits, ParserBehavior behaviors = default_behaviors())
: m_source(source)
, m_lexer(m_source)
, m_traits(traits)
, m_behaviours(behaviours)
, m_behaviors(behaviors)
{
parse_preview();
}
@ -88,7 +88,7 @@ public:
size_t size() const { return m_rows.size(); }
Vector<String> headers() const;
[[nodiscard]] bool has_explicit_headers() const { return (static_cast<u32>(m_behaviours) & static_cast<u32>(ParserBehaviour::ReadHeaders)) != 0; }
[[nodiscard]] bool has_explicit_headers() const { return (static_cast<u32>(m_behaviors) & static_cast<u32>(ParserBehavior::ReadHeaders)) != 0; }
class Row {
public:
@ -207,7 +207,7 @@ private:
StringView m_source;
GenericLexer m_lexer;
ParserTraits m_traits;
ParserBehaviour m_behaviours;
ParserBehavior m_behaviors;
Vector<Field> m_names;
Vector<Vector<Field>> m_rows;
ReadError m_error { ReadError::None };

View file

@ -15,8 +15,8 @@ namespace Writer {
template<typename ContainerType>
class CSV : public XSV<ContainerType> {
public:
CSV(OutputStream& output, const ContainerType& data, const Vector<StringView>& headers = {}, WriterBehaviour behaviours = default_behaviours())
: XSV<ContainerType>(output, data, { ",", "\"", WriterTraits::Repeat }, headers, behaviours)
CSV(OutputStream& output, const ContainerType& data, const Vector<StringView>& headers = {}, WriterBehavior behaviors = default_behaviors())
: XSV<ContainerType>(output, data, { ",", "\"", WriterTraits::Repeat }, headers, behaviors)
{
}
};

View file

@ -53,7 +53,7 @@ TEST_CASE(can_write_with_header)
EXPECT_EQ(StringView { stream.bytes() }, expected_output);
}
TEST_CASE(can_write_with_different_behaviours)
TEST_CASE(can_write_with_different_behaviors)
{
Vector<Vector<String>> data = {
{ "Well", "Hello\"", "Friends" },
@ -63,7 +63,7 @@ TEST_CASE(can_write_with_different_behaviours)
auto buffer = ByteBuffer::create_uninitialized(1024).release_value();
OutputMemoryStream stream { buffer };
Writer::CSV csv(stream, data, { "A", "B\"", "C" }, Writer::WriterBehaviour::QuoteOnlyInFieldStart | Writer::WriterBehaviour::WriteHeaders);
Writer::CSV csv(stream, data, { "A", "B\"", "C" }, Writer::WriterBehavior::QuoteOnlyInFieldStart | Writer::WriterBehavior::WriteHeaders);
auto expected_output = R"~(A,B",C
Well,Hello",Friends

View file

@ -16,7 +16,7 @@
namespace Writer {
enum class WriterBehaviour : u32 {
enum class WriterBehavior : u32 {
None = 0,
WriteHeaders = 1,
AllowNewlinesInFields = WriteHeaders << 1,
@ -24,14 +24,14 @@ enum class WriterBehaviour : u32 {
QuoteAll = WriteHeaders << 3,
};
inline WriterBehaviour operator&(WriterBehaviour left, WriterBehaviour right)
inline WriterBehavior operator&(WriterBehavior left, WriterBehavior right)
{
return static_cast<WriterBehaviour>(static_cast<u32>(left) & static_cast<u32>(right));
return static_cast<WriterBehavior>(static_cast<u32>(left) & static_cast<u32>(right));
}
inline WriterBehaviour operator|(WriterBehaviour left, WriterBehaviour right)
inline WriterBehavior operator|(WriterBehavior left, WriterBehavior right)
{
return static_cast<WriterBehaviour>(static_cast<u32>(left) | static_cast<u32>(right));
return static_cast<WriterBehavior>(static_cast<u32>(left) | static_cast<u32>(right));
}
struct WriterTraits {
@ -54,23 +54,23 @@ enum class WriteError {
#undef E
};
constexpr WriterBehaviour default_behaviours()
constexpr WriterBehavior default_behaviors()
{
return WriterBehaviour::None;
return WriterBehavior::None;
}
template<typename ContainerType, typename HeaderType = Vector<StringView>>
class XSV {
public:
XSV(OutputStream& output, const ContainerType& data, const WriterTraits& traits, const HeaderType& headers = {}, WriterBehaviour behaviours = default_behaviours())
XSV(OutputStream& output, const ContainerType& data, const WriterTraits& traits, const HeaderType& headers = {}, WriterBehavior behaviors = default_behaviors())
: m_data(data)
, m_traits(traits)
, m_behaviours(behaviours)
, m_behaviors(behaviors)
, m_names(headers)
, m_output(output)
{
if (!headers.is_empty())
m_behaviours = m_behaviours | WriterBehaviour::WriteHeaders;
m_behaviors = m_behaviors | WriterBehavior::WriteHeaders;
generate();
}
@ -101,7 +101,7 @@ private:
void generate()
{
auto with_headers = (m_behaviours & WriterBehaviour::WriteHeaders) != WriterBehaviour::None;
auto with_headers = (m_behaviors & WriterBehavior::WriteHeaders) != WriterBehavior::None;
if (with_headers) {
write_row(m_names);
if (m_output.write({ "\n", 1 }) != 1)
@ -139,12 +139,12 @@ private:
{
auto string = String::formatted("{}", FormatIfSupported(entry));
auto safe_to_write_normally = (m_behaviours & WriterBehaviour::QuoteAll) == WriterBehaviour::None
auto safe_to_write_normally = (m_behaviors & WriterBehavior::QuoteAll) == WriterBehavior::None
&& !string.contains("\n")
&& !string.contains(m_traits.separator);
if (safe_to_write_normally) {
if ((m_behaviours & WriterBehaviour::QuoteOnlyInFieldStart) == WriterBehaviour::None)
if ((m_behaviors & WriterBehavior::QuoteOnlyInFieldStart) == WriterBehavior::None)
safe_to_write_normally = !string.contains(m_traits.quote);
else
safe_to_write_normally = !string.starts_with(m_traits.quote);
@ -190,7 +190,7 @@ private:
const ContainerType& m_data;
const WriterTraits& m_traits;
WriterBehaviour m_behaviours;
WriterBehavior m_behaviors;
const HeaderType& m_names;
WriteError m_error { WriteError::None };
OutputStream& m_output;

View file

@ -547,7 +547,7 @@ extern "C" int vsscanf(const char* input, const char* format, va_list ap)
case ConversionSpecifier::Invalid:
case ConversionSpecifier::Unspecified:
default:
// "undefined behaviour", let's be nice and crash.
// "undefined behavior", let's be nice and crash.
dbgln("Invalid conversion specifier {} in scanf!", (int)conversion_specifier);
VERIFY_NOT_REACHED();
case ConversionSpecifier::Decimal:

View file

@ -241,7 +241,7 @@ ALWAYS_INLINE UnsignedBigInteger::Word UnsignedBigIntegerAlgorithms::shift_left_
VERIFY(num_bits <= UnsignedBigInteger::BITS_IN_WORD);
u32 result = 0;
// we need to check for "num_bits != 0" since shifting right by 32 is apparently undefined behaviour!
// we need to check for "num_bits != 0" since shifting right by 32 is apparently undefined behavior!
if (result_word_index > 0 && num_bits != 0) {
result += number.m_words[result_word_index - 1] >> (UnsignedBigInteger::BITS_IN_WORD - num_bits);
}

View file

@ -35,7 +35,7 @@ static constexpr float wrap(float value, GLint mode)
case GL_REPEAT:
return wrap_repeat(value);
// FIXME: These clamp modes actually have slightly different behaviour
// FIXME: These clamp modes actually have slightly different behavior
case GL_CLAMP:
case GL_CLAMP_TO_BORDER:
case GL_CLAMP_TO_EDGE:

View file

@ -1353,7 +1353,7 @@ void VimEditingEngine::put_after()
m_editor->set_cursor({ m_editor->cursor().line(), m_editor->current_line().first_non_whitespace_column() });
} else {
// FIXME: If attempting to put on the last column a line,
// the buffer will bne placed on the next line due to the move_one_left/right behaviour.
// the buffer will bne placed on the next line due to the move_one_left/right behavior.
move_one_right();
StringBuilder sb = StringBuilder(m_yank_buffer.length() * amount);
for (auto i = 0; i < amount; i++) {

View file

@ -104,7 +104,7 @@ bool Array::set_length(PropertyDescriptor const& property_descriptor)
// 15. Let succeeded be ! OrdinaryDefineOwnProperty(A, "length", newLenDesc).
// 16. If succeeded is false, return false.
// NOTE: Because the length property does not actually exist calling OrdinaryDefineOwnProperty
// will result in unintended behaviour, so instead we only implement here the small subset of
// will result in unintended behavior, so instead we only implement here the small subset of
// checks performed inside of it that would have mattered to us:
// 10.1.6.3 ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ), https://tc39.es/ecma262/#sec-validateandapplypropertydescriptor

View file

@ -115,7 +115,7 @@ void iterator_close(Object& iterator)
auto& vm = iterator.vm();
auto& global_object = iterator.global_object();
// Emulates `completion` behaviour
// Emulates `completion` behavior
auto* completion_exception = vm.exception();
vm.clear_exception();
auto unwind_until = vm.unwind_until();

View file

@ -252,7 +252,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::repeat)
if (n == 0)
return js_string(vm, String::empty());
// NOTE: This is an optimization, it is not required by the specification but it produces equivalent behaviour
// NOTE: This is an optimization, it is not required by the specification but it produces equivalent behavior
if (string->is_empty())
return js_string(vm, String::empty());

View file

@ -173,7 +173,7 @@ Optional<ISODate> regulate_iso_date(GlobalObject& global_object, double year, do
// 3. If overflow is "reject", then
if (overflow == "reject"sv) {
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat these doubles as normal integers from this point onwards.
// This does not change the exposed behaviour as the call to IsValidISODate will immediately check that these values are valid ISO
// This does not change the exposed behavior as the call to IsValidISODate will immediately check that these values are valid ISO
// values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31) all of which are subsets of this check.
if (!AK::is_within_range<i32>(year) || !AK::is_within_range<u8>(month) || !AK::is_within_range<u8>(day)) {
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate);
@ -193,7 +193,7 @@ Optional<ISODate> regulate_iso_date(GlobalObject& global_object, double year, do
// 4. If overflow is "constrain", then
else if (overflow == "constrain"sv) {
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat this double as normal integer from this point onwards. This
// does not change the exposed behaviour as the parent's call to CreateTemporalDate will immediately check that this value is a valid
// does not change the exposed behavior as the parent's call to CreateTemporalDate will immediately check that this value is a valid
// ISO value for years: -273975 - 273975, which is a subset of this check.
if (!AK::is_within_range<i32>(year)) {
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate);

View file

@ -73,7 +73,7 @@ Value PlainDateConstructor::construct(FunctionObject& new_target)
return {};
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat these doubles as normal integers from this point onwards.
// This does not change the exposed behaviour as the call to CreateTemporalDate will immediately check that these values are valid
// This does not change the exposed behavior as the call to CreateTemporalDate will immediately check that these values are valid
// ISO values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31) all of which are subsets of this check.
if (!AK::is_within_range<i32>(y) || !AK::is_within_range<u8>(m) || !AK::is_within_range<u8>(d)) {
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate);

View file

@ -103,7 +103,7 @@ Value PlainDateTimeConstructor::construct(FunctionObject& new_target)
return {};
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat these doubles as normal integers from this point onwards.
// This does not change the exposed behaviour as the call to CreateTemporalDateTime will immediately check that these values are valid
// This does not change the exposed behavior as the call to CreateTemporalDateTime will immediately check that these values are valid
// ISO values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31, for hours: 0 - 23, for minutes and seconds: 0 - 59,
// milliseconds, microseconds, and nanoseconds: 0 - 999) all of which are subsets of this check.
if (!AK::is_within_range<i32>(iso_year) || !AK::is_within_range<u8>(iso_month) || !AK::is_within_range<u8>(iso_day) || !AK::is_within_range<u8>(hour) || !AK::is_within_range<u8>(minute) || !AK::is_within_range<u8>(second) || !AK::is_within_range<u16>(millisecond) || !AK::is_within_range<u16>(microsecond) || !AK::is_within_range<u16>(nanosecond)) {

View file

@ -78,7 +78,7 @@ Value PlainMonthDayConstructor::construct(FunctionObject& new_target)
return {};
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat these doubles as normal integers from this point onwards.
// This does not change the exposed behaviour as the call to CreateTemporalMonthDay will immediately check that these values are valid
// This does not change the exposed behavior as the call to CreateTemporalMonthDay will immediately check that these values are valid
// ISO values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31) all of which are subsets of this check.
if (!AK::is_within_range<i32>(ref) || !AK::is_within_range<u8>(m) || !AK::is_within_range<u8>(d)) {
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainYearMonth);

View file

@ -81,7 +81,7 @@ Value PlainTimeConstructor::construct(FunctionObject& new_target)
return {};
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat these doubles as normal integers from this point onwards.
// This does not change the exposed behaviour as the call to CreateTemporalTime will immediately check that these values are valid
// This does not change the exposed behavior as the call to CreateTemporalTime will immediately check that these values are valid
// ISO values (for hours: 0 - 23, for minutes and seconds: 0 - 59, milliseconds, microseconds, and nanoseconds: 0 - 999) all of which
// are subsets of this check.
if (!AK::is_within_range<u8>(hour) || !AK::is_within_range<u8>(minute) || !AK::is_within_range<u8>(second) || !AK::is_within_range<u16>(millisecond) || !AK::is_within_range<u16>(microsecond) || !AK::is_within_range<u16>(nanosecond)) {

View file

@ -44,7 +44,7 @@ Optional<ISOYearMonth> regulate_iso_year_month(GlobalObject& global_object, doub
// 3. If overflow is "constrain", then
if (overflow == "constrain"sv) {
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat `year` (a double) as normal integer from this point onwards.
// This does not change the exposed behaviour as the subsequent call to CreateTemporalYearMonth will check that its value is a valid ISO
// This does not change the exposed behavior as the subsequent call to CreateTemporalYearMonth will check that its value is a valid ISO
// values (for years: -273975 - 273975) which is a subset of this check.
// If RegulateISOYearMonth is ever used outside ISOYearMonthFromFields, this may need to be changed.
if (!AK::is_within_range<i32>(year)) {
@ -59,7 +59,7 @@ Optional<ISOYearMonth> regulate_iso_year_month(GlobalObject& global_object, doub
// 4. If overflow is "reject", then
if (overflow == "reject"sv) {
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat these doubles as normal integers from this point onwards.
// This does not change the exposed behaviour as the call to IsValidISOMonth and subsequent call to CreateTemporalDateTime will check
// This does not change the exposed behavior as the call to IsValidISOMonth and subsequent call to CreateTemporalDateTime will check
// that these values are valid ISO values (for years: -273975 - 273975, for months: 1 - 12) all of which are subsets of this check.
if (!AK::is_within_range<i32>(year) || !AK::is_within_range<u8>(month)) {
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainYearMonth);

View file

@ -78,7 +78,7 @@ Value PlainYearMonthConstructor::construct(FunctionObject& new_target)
return {};
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat these doubles as normal integers from this point onwards.
// This does not change the exposed behaviour as the call to CreateTemporalYearMonth will immediately check that these values are valid
// This does not change the exposed behavior as the call to CreateTemporalYearMonth will immediately check that these values are valid
// ISO values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31) all of which are subsets of this check.
if (!AK::is_within_range<i32>(y) || !AK::is_within_range<u8>(m) || !AK::is_within_range<u8>(ref)) {
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainYearMonth);

View file

@ -22,7 +22,7 @@ test("length is 2", () => {
});
});
describe("normal behaviour", () => {
describe("normal behavior", () => {
test("Noop", () => {
TYPED_ARRAYS.forEach(T => {
const array = new T([1, 2]);
@ -37,7 +37,7 @@ describe("normal behaviour", () => {
});
});
test("basic behaviour", () => {
test("basic behavior", () => {
TYPED_ARRAYS.forEach(T => {
const array = new T([1, 2, 3]);
expect(array.copyWithin(1, 2)).toEqual(array);

View file

@ -112,7 +112,7 @@ describe("errors", () => {
});
});
describe("normal behaviour", () => {
describe("normal behavior", () => {
test("never calls callback with empty array", () => {
TYPED_ARRAYS.forEach(T => {
let callbackCalled = 0;

View file

@ -44,7 +44,7 @@ describe("errors", () => {
BIGINT_TYPED_ARRAYS.forEach(T => errorTests(T));
});
describe("normal behaviour", () => {
describe("normal behavior", () => {
test("basic functionality", () => {
TYPED_ARRAYS.forEach(T => {
const typedArray = new T([1, 2, 3]);

View file

@ -44,7 +44,7 @@ describe("errors", () => {
BIGINT_TYPED_ARRAYS.forEach(T => errorTests(T));
});
describe("normal behaviour", () => {
describe("normal behavior", () => {
test("basic functionality", () => {
TYPED_ARRAYS.forEach(T => {
const typedArray = new T([1, 2, 3]);

View file

@ -44,7 +44,7 @@ describe("errors", () => {
BIGINT_TYPED_ARRAYS.forEach(T => errorTests(T));
});
describe("normal behaviour", () => {
describe("normal behavior", () => {
test("basic functionality", () => {
TYPED_ARRAYS.forEach(T => {
const typedArray = new T([1, 2, 3]);

View file

@ -44,7 +44,7 @@ describe("errors", () => {
BIGINT_TYPED_ARRAYS.forEach(T => errorTests(T));
});
describe("normal behaviour", () => {
describe("normal behavior", () => {
test("basic functionality", () => {
TYPED_ARRAYS.forEach(T => {
const typedArray = new T([1, 2, 3]);

View file

@ -44,7 +44,7 @@ describe("errors", () => {
BIGINT_TYPED_ARRAYS.forEach(T => errorTests(T));
});
describe("normal behaviour", () => {
describe("normal behavior", () => {
test("never calls callback with empty array", () => {
function emptyTest(T) {
var callbackCalled = 0;

View file

@ -144,7 +144,7 @@ describe("errors", () => {
});
});
describe("normal behaviour", () => {
describe("normal behavior", () => {
test("never calls callback with empty array", () => {
TYPED_ARRAYS.forEach(T => {
let callbackCalled = 0;

View file

@ -41,11 +41,11 @@ Configuration Configuration::from_config(const StringView& libname)
Configuration configuration;
auto config_file = Core::ConfigFile::open_for_lib(libname);
// Read behaviour options.
auto refresh = config_file->read_entry("behaviour", "refresh", "lazy");
auto operation = config_file->read_entry("behaviour", "operation_mode");
auto bracketed_paste = config_file->read_bool_entry("behaviour", "bracketed_paste", true);
auto default_text_editor = config_file->read_entry("behaviour", "default_text_editor");
// Read behavior options.
auto refresh = config_file->read_entry("behavior", "refresh", "lazy");
auto operation = config_file->read_entry("behavior", "operation_mode");
auto bracketed_paste = config_file->read_bool_entry("behavior", "bracketed_paste", true);
auto default_text_editor = config_file->read_entry("behavior", "default_text_editor");
Configuration::Flags flags { Configuration::Flags::None };
if (bracketed_paste)
@ -184,7 +184,7 @@ void Editor::set_default_keybinds()
Editor::Editor(Configuration configuration)
: m_configuration(move(configuration))
{
m_always_refresh = m_configuration.refresh_behaviour == Configuration::RefreshBehaviour::Eager;
m_always_refresh = m_configuration.refresh_behavior == Configuration::RefreshBehavior::Eager;
m_pending_chars = {};
get_terminal_size();
m_suggestion_display = make<XtermSuggestionDisplay>(m_num_lines, m_num_columns);
@ -1024,8 +1024,8 @@ void Editor::handle_read_event()
ArmedScopeGuard suggestion_cleanup { [this] { cleanup_suggestions(); } };
// Normally ^D. `stty eof \^n` can change it to ^N (or something else), but Serenity doesn't have `stty` yet.
// Process this here since the keybinds might override its behaviour.
// This only applies when the buffer is empty. at any other time, the behaviour should be configurable.
// Process this here since the keybinds might override its behavior.
// This only applies when the buffer is empty. at any other time, the behavior should be configurable.
if (code_point == m_termios.c_cc[VEOF] && m_buffer.size() == 0) {
finish_edit();
continue;

View file

@ -45,7 +45,7 @@ struct KeyBinding {
};
struct Configuration {
enum RefreshBehaviour {
enum RefreshBehavior {
Lazy,
Eager,
};
@ -80,7 +80,7 @@ struct Configuration {
set(arg);
}
void set(RefreshBehaviour refresh) { refresh_behaviour = refresh; }
void set(RefreshBehavior refresh) { refresh_behavior = refresh; }
void set(OperationMode mode) { operation_mode = mode; }
void set(SignalHandler mode) { m_signal_mode = mode; }
void set(const KeyBinding& binding) { keybindings.append(binding); }
@ -92,7 +92,7 @@ struct Configuration {
static Configuration from_config(const StringView& libname = "line");
RefreshBehaviour refresh_behaviour { RefreshBehaviour::Lazy };
RefreshBehavior refresh_behavior { RefreshBehavior::Lazy };
SignalHandler m_signal_mode { SignalHandler::WithSignalHandlers };
OperationMode operation_mode { OperationMode::Unset };
Vector<KeyBinding> keybindings;

View file

@ -34,7 +34,7 @@ enum class AllFlags {
Multiline = __Regex_Multiline, // Handle newline characters. Match each line, one by one.
SkipTrimEmptyMatches = __Regex_SkipTrimEmptyMatches, // Do not remove empty capture group results.
Internal_Stateful = __Regex_Internal_Stateful, // Make global matches match one result at a time, and further match() calls on the same instance continue where the previous one left off.
Internal_BrowserExtended = __Regex_Internal_BrowserExtended, // Only for ECMA262, Enable the behaviours defined in section B.1.4. of the ECMA262 spec.
Internal_BrowserExtended = __Regex_Internal_BrowserExtended, // Only for ECMA262, Enable the behaviors defined in section B.1.4. of the ECMA262 spec.
Last = Internal_BrowserExtended,
};

View file

@ -260,7 +260,7 @@ private:
// Most patterns should have no need to ever populate this field.
Optional<size_t> m_total_number_of_capturing_parenthesis;
// Keep the Annex B. behaviour behind a flag, the users can enable it by passing the `ECMAScriptFlags::BrowserExtended` flag.
// Keep the Annex B. behavior behind a flag, the users can enable it by passing the `ECMAScriptFlags::BrowserExtended` flag.
bool m_should_use_browser_extended_grammar { false };
// ECMA-262 basically requires that we clear the inner captures of a capture group before trying to match it,

View file

@ -307,7 +307,7 @@ template<typename V, typename T>
MakeSigned<T> BytecodeInterpreter::checked_signed_truncate(V value)
{
if (isnan(value) || isinf(value)) { // "undefined", let's just trap.
m_trap = Trap { "Signed truncation undefined behaviour" };
m_trap = Trap { "Signed truncation undefined behavior" };
return 0;
}
@ -330,7 +330,7 @@ template<typename V, typename T>
MakeUnsigned<T> BytecodeInterpreter::checked_unsigned_truncate(V value)
{
if (isnan(value) || isinf(value)) { // "undefined", let's just trap.
m_trap = Trap { "Unsigned truncation undefined behaviour" };
m_trap = Trap { "Unsigned truncation undefined behavior" };
return 0;
}
double truncated;

View file

@ -317,7 +317,7 @@ struct CheckedTruncate {
AK::Result<ResultT, StringView> operator()(Lhs lhs) const
{
if (isnan(lhs) || isinf(lhs)) // "undefined", let's just trap.
return "Truncation undefined behaviour"sv;
return "Truncation undefined behavior"sv;
Lhs truncated;
if constexpr (IsSame<float, Lhs>)

View file

@ -181,7 +181,7 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr<
bool is_activation_event = is<UIEvents::MouseEvent>(*event) && event->type() == HTML::EventNames::click;
if (is_activation_event && target->activation_behaviour)
if (is_activation_event && target->activation_behavior)
activation_target = target;
// FIXME: Let slottable be target, if target is a slottable and is assigned, and null otherwise.
@ -203,7 +203,7 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr<
if (is<Window>(parent)
|| (is<Node>(parent) && verify_cast<Node>(*target).root().is_shadow_including_inclusive_ancestor_of(verify_cast<Node>(*parent)))) {
if (is_activation_event && event->bubbles() && !activation_target && parent->activation_behaviour)
if (is_activation_event && event->bubbles() && !activation_target && parent->activation_behavior)
activation_target = parent;
event->append_to_path(*parent, nullptr, related_target, touch_targets, slot_in_closed_tree);
@ -212,7 +212,7 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr<
} else {
target = *parent;
if (is_activation_event && !activation_target && target->activation_behaviour)
if (is_activation_event && !activation_target && target->activation_behavior)
activation_target = target;
event->append_to_path(*parent, target, related_target, touch_targets, slot_in_closed_tree);
@ -255,8 +255,8 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr<
}
}
if (activation_target && activation_target->legacy_pre_activation_behaviour)
activation_target->legacy_pre_activation_behaviour();
if (activation_target && activation_target->legacy_pre_activation_behavior)
activation_target->legacy_pre_activation_behavior();
for (ssize_t i = event->path().size() - 1; i >= 0; --i) {
auto& entry = event->path().at(i);
@ -298,11 +298,11 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr<
if (activation_target) {
if (!event->cancelled()) {
// NOTE: Since activation_target is set, it will have activation behaviour.
activation_target->activation_behaviour(event);
// NOTE: Since activation_target is set, it will have activation behavior.
activation_target->activation_behavior(event);
} else {
if (activation_target->legacy_cancelled_activation_behaviour)
activation_target->legacy_cancelled_activation_behaviour();
if (activation_target->legacy_cancelled_activation_behavior)
activation_target->legacy_cancelled_activation_behavior();
}
}

View file

@ -47,11 +47,11 @@ public:
Vector<EventListenerRegistration>& listeners() { return m_listeners; }
const Vector<EventListenerRegistration>& listeners() const { return m_listeners; }
Function<void(const Event&)> activation_behaviour;
Function<void(const Event&)> activation_behavior;
// NOTE: These only exist for checkbox and radio input elements.
Function<void()> legacy_pre_activation_behaviour;
Function<void()> legacy_cancelled_activation_behaviour;
Function<void()> legacy_pre_activation_behavior;
Function<void()> legacy_cancelled_activation_behavior;
protected:
explicit EventTarget(Bindings::ScriptExecutionContext&);

View file

@ -27,7 +27,7 @@ namespace AttributeNames {
__ENUMERATE_HTML_ATTRIBUTE(autoplay) \
__ENUMERATE_HTML_ATTRIBUTE(axis) \
__ENUMERATE_HTML_ATTRIBUTE(background) \
__ENUMERATE_HTML_ATTRIBUTE(behaviour) \
__ENUMERATE_HTML_ATTRIBUTE(behavior) \
__ENUMERATE_HTML_ATTRIBUTE(bgcolor) \
__ENUMERATE_HTML_ATTRIBUTE(border) \
__ENUMERATE_HTML_ATTRIBUTE(cellpadding) \

View file

@ -1,6 +1,6 @@
interface HTMLMarqueeElement : HTMLElement {
[Reflect] attribute DOMString behaviour;
[Reflect] attribute DOMString behavior;
[Reflect=bgcolor] attribute DOMString bgColor;
[Reflect] attribute DOMString direction;
[Reflect] attribute DOMString height;

View file

@ -2080,7 +2080,7 @@ RefPtr<Value> MatchExpr::run(RefPtr<Shell> shell)
} else {
auto list = option.run(shell);
option.for_each_entry(shell, [&](auto&& value) {
pattern.extend(value->resolve_as_list(nullptr)); // Note: 'nullptr' incurs special behaviour,
pattern.extend(value->resolve_as_list(nullptr)); // Note: 'nullptr' incurs special behavior,
// asking the node for a 'raw' value.
return IterationDecision::Continue;
});

View file

@ -110,7 +110,7 @@ int main(int argc, char** argv)
args_parser.add_positional_argument(files, "File(s) to process", "file", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv);
// mock grep behaviour: if -e is omitted, use first positional argument as pattern
// mock grep behavior: if -e is omitted, use first positional argument as pattern
if (pattern == nullptr && files.size())
pattern = files.take_first();