mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:04:57 +00:00
AK: Remove unnecessary casts to size_t, after Vector changes
Now that Vector uses size_t, we can remove a whole bunch of redundant casts to size_t.
This commit is contained in:
parent
fee20bd8de
commit
22d0a6d92f
15 changed files with 60 additions and 57 deletions
|
@ -130,7 +130,7 @@ String JsonParser::consume_quoted_string()
|
||||||
return String::empty();
|
return String::empty();
|
||||||
|
|
||||||
auto& last_string_starting_with_character = m_last_string_starting_with_character[(u8)buffer.first()];
|
auto& last_string_starting_with_character = m_last_string_starting_with_character[(u8)buffer.first()];
|
||||||
if (last_string_starting_with_character.length() == (size_t)buffer.size()) {
|
if (last_string_starting_with_character.length() == buffer.size()) {
|
||||||
if (!memcmp(last_string_starting_with_character.characters(), buffer.data(), buffer.size()))
|
if (!memcmp(last_string_starting_with_character.characters(), buffer.data(), buffer.size()))
|
||||||
return last_string_starting_with_character;
|
return last_string_starting_with_character;
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ Vector<String> String::split_limit(char separator, size_t limit, bool keep_empty
|
||||||
|
|
||||||
Vector<String> v;
|
Vector<String> v;
|
||||||
size_t substart = 0;
|
size_t substart = 0;
|
||||||
for (size_t i = 0; i < length() && ((size_t)v.size() + 1) != limit; ++i) {
|
for (size_t i = 0; i < length() && (v.size() + 1) != limit; ++i) {
|
||||||
char ch = characters()[i];
|
char ch = characters()[i];
|
||||||
if (ch == separator) {
|
if (ch == separator) {
|
||||||
size_t sublen = i - substart;
|
size_t sublen = i - substart;
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace AK {
|
||||||
|
|
||||||
inline void StringBuilder::will_append(size_t size)
|
inline void StringBuilder::will_append(size_t size)
|
||||||
{
|
{
|
||||||
if ((m_length + size) > (size_t)m_buffer.size())
|
if ((m_length + size) > m_buffer.size())
|
||||||
m_buffer.grow(max((size_t)16, (size_t)m_buffer.size() * 2 + size));
|
m_buffer.grow(max(static_cast<size_t>(16), m_buffer.size() * 2 + size));
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder::StringBuilder(size_t initial_capacity)
|
StringBuilder::StringBuilder(size_t initial_capacity)
|
||||||
|
|
|
@ -40,7 +40,7 @@ StringView::StringView(const String& string)
|
||||||
|
|
||||||
StringView::StringView(const ByteBuffer& buffer)
|
StringView::StringView(const ByteBuffer& buffer)
|
||||||
: m_characters((const char*)buffer.data())
|
: m_characters((const char*)buffer.data())
|
||||||
, m_length((size_t)buffer.size())
|
, m_length(buffer.size())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ int main(int argc, char* argv[])
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto buffer = file->read_all();
|
auto buffer = file->read_all();
|
||||||
StringView source { (const char*)buffer.data(), (size_t)buffer.size() };
|
StringView source { (const char*)buffer.data(), buffer.size() };
|
||||||
|
|
||||||
MDDocument md_document;
|
MDDocument md_document;
|
||||||
bool success = md_document.parse(source);
|
bool success = md_document.parse(source);
|
||||||
|
|
|
@ -599,7 +599,7 @@ void Scheduler::timer_tick(RegisterState& regs)
|
||||||
sample.pid = Process::current->pid();
|
sample.pid = Process::current->pid();
|
||||||
sample.tid = Thread::current->tid();
|
sample.tid = Thread::current->tid();
|
||||||
sample.timestamp = g_uptime;
|
sample.timestamp = g_uptime;
|
||||||
for (size_t i = 0; i < min((size_t)backtrace.size(), Profiling::max_stack_frame_count); ++i) {
|
for (size_t i = 0; i < min(backtrace.size(), Profiling::max_stack_frame_count); ++i) {
|
||||||
sample.frames[i] = backtrace[i];
|
sample.frames[i] = backtrace[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ HashMap<pid_t, Core::ProcessStatistics> ProcessStatisticsReader::get_all()
|
||||||
HashMap<pid_t, Core::ProcessStatistics> map;
|
HashMap<pid_t, Core::ProcessStatistics> map;
|
||||||
|
|
||||||
auto file_contents = file->read_all();
|
auto file_contents = file->read_all();
|
||||||
auto json = JsonValue::from_string({ file_contents.data(), (size_t)file_contents.size() });
|
auto json = JsonValue::from_string(file_contents);
|
||||||
json.as_array().for_each([&](auto& value) {
|
json.as_array().for_each([&](auto& value) {
|
||||||
const JsonObject& process_object = value.as_object();
|
const JsonObject& process_object = value.as_object();
|
||||||
Core::ProcessStatistics process;
|
Core::ProcessStatistics process;
|
||||||
|
|
|
@ -86,7 +86,7 @@ void TextDocument::set_text(const StringView& text)
|
||||||
size_t TextDocumentLine::first_non_whitespace_column() const
|
size_t TextDocumentLine::first_non_whitespace_column() const
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < length(); ++i) {
|
for (size_t i = 0; i < length(); ++i) {
|
||||||
if (!isspace(m_text[(int)i]))
|
if (!isspace(m_text[i]))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return length();
|
return length();
|
||||||
|
|
|
@ -75,9 +75,9 @@ public:
|
||||||
static NonnullRefPtr<TextDocument> create(Client* client = nullptr);
|
static NonnullRefPtr<TextDocument> create(Client* client = nullptr);
|
||||||
~TextDocument();
|
~TextDocument();
|
||||||
|
|
||||||
size_t line_count() const { return (size_t)m_lines.size(); }
|
size_t line_count() const { return m_lines.size(); }
|
||||||
const TextDocumentLine& line(size_t line_index) const { return m_lines[(int)line_index]; }
|
const TextDocumentLine& line(size_t line_index) const { return m_lines[line_index]; }
|
||||||
TextDocumentLine& line(size_t line_index) { return m_lines[(int)line_index]; }
|
TextDocumentLine& line(size_t line_index) { return m_lines[line_index]; }
|
||||||
|
|
||||||
void set_spans(const Vector<TextDocumentSpan>& spans) { m_spans = spans; }
|
void set_spans(const Vector<TextDocumentSpan>& spans) { m_spans = spans; }
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
bool has_spans() const { return !m_spans.is_empty(); }
|
bool has_spans() const { return !m_spans.is_empty(); }
|
||||||
const Vector<TextDocumentSpan>& spans() const { return m_spans; }
|
const Vector<TextDocumentSpan>& spans() const { return m_spans; }
|
||||||
void set_span_at_index(size_t index, TextDocumentSpan span) { m_spans[(int)index] = move(span); }
|
void set_span_at_index(size_t index, TextDocumentSpan span) { m_spans[index] = move(span); }
|
||||||
|
|
||||||
void append_line(NonnullOwnPtr<TextDocumentLine>);
|
void append_line(NonnullOwnPtr<TextDocumentLine>);
|
||||||
void remove_line(size_t line_index);
|
void remove_line(size_t line_index);
|
||||||
|
@ -156,7 +156,7 @@ public:
|
||||||
|
|
||||||
StringView view() const { return { characters(), (size_t)length() }; }
|
StringView view() const { return { characters(), (size_t)length() }; }
|
||||||
const char* characters() const { return m_text.data(); }
|
const char* characters() const { return m_text.data(); }
|
||||||
size_t length() const { return (size_t)m_text.size() - 1; }
|
size_t length() const { return m_text.size() - 1; }
|
||||||
void set_text(TextDocument&, const StringView&);
|
void set_text(TextDocument&, const StringView&);
|
||||||
void append(TextDocument&, char);
|
void append(TextDocument&, char);
|
||||||
void prepend(TextDocument&, char);
|
void prepend(TextDocument&, char);
|
||||||
|
|
|
@ -559,7 +559,8 @@ void TextEditor::move_selected_lines_down()
|
||||||
get_selection_line_boundaries(first_line, last_line);
|
get_selection_line_boundaries(first_line, last_line);
|
||||||
|
|
||||||
auto& lines = document().lines();
|
auto& lines = document().lines();
|
||||||
if (last_line >= (size_t)(lines.size() - 1))
|
ASSERT(lines.size() != 0);
|
||||||
|
if (last_line >= lines.size() - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lines.insert((int)first_line, lines.take((int)last_line + 1));
|
lines.insert((int)first_line, lines.take((int)last_line + 1));
|
||||||
|
|
|
@ -108,7 +108,7 @@ public:
|
||||||
|
|
||||||
auto buffer = message.encode();
|
auto buffer = message.encode();
|
||||||
|
|
||||||
int nwritten = write(m_socket->fd(), buffer.data(), (size_t)buffer.size());
|
int nwritten = write(m_socket->fd(), buffer.data(), buffer.size());
|
||||||
if (nwritten < 0) {
|
if (nwritten < 0) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case EPIPE:
|
case EPIPE:
|
||||||
|
@ -149,7 +149,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t decoded_bytes = 0;
|
size_t decoded_bytes = 0;
|
||||||
for (size_t index = 0; index < (size_t)bytes.size(); index += decoded_bytes) {
|
for (size_t index = 0; index < bytes.size(); index += decoded_bytes) {
|
||||||
auto remaining_bytes = ByteBuffer::wrap(bytes.data() + index, bytes.size() - index);
|
auto remaining_bytes = ByteBuffer::wrap(bytes.data() + index, bytes.size() - index);
|
||||||
auto message = Endpoint::decode_message(remaining_bytes, decoded_bytes);
|
auto message = Endpoint::decode_message(remaining_bytes, decoded_bytes);
|
||||||
if (!message) {
|
if (!message) {
|
||||||
|
|
|
@ -121,7 +121,7 @@ public:
|
||||||
bool post_message(const Message& message)
|
bool post_message(const Message& message)
|
||||||
{
|
{
|
||||||
auto buffer = message.encode();
|
auto buffer = message.encode();
|
||||||
int nwritten = write(m_connection->fd(), buffer.data(), (size_t)buffer.size());
|
int nwritten = write(m_connection->fd(), buffer.data(), buffer.size());
|
||||||
if (nwritten < 0) {
|
if (nwritten < 0) {
|
||||||
perror("write");
|
perror("write");
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
|
@ -165,7 +165,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t decoded_bytes = 0;
|
size_t decoded_bytes = 0;
|
||||||
for (size_t index = 0; index < (size_t)bytes.size(); index += decoded_bytes) {
|
for (size_t index = 0; index < bytes.size(); index += decoded_bytes) {
|
||||||
auto remaining_bytes = ByteBuffer::wrap(bytes.data() + index, bytes.size() - index);
|
auto remaining_bytes = ByteBuffer::wrap(bytes.data() + index, bytes.size() - index);
|
||||||
if (auto message = LocalEndpoint::decode_message(remaining_bytes, decoded_bytes)) {
|
if (auto message = LocalEndpoint::decode_message(remaining_bytes, decoded_bytes)) {
|
||||||
m_unprocessed_messages.append(move(message));
|
m_unprocessed_messages.append(move(message));
|
||||||
|
|
|
@ -66,21 +66,21 @@ void LineEditor::insert(const String& string)
|
||||||
fputs(string.characters(), stdout);
|
fputs(string.characters(), stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
if (m_cursor == (size_t)m_buffer.size()) {
|
if (m_cursor == m_buffer.size()) {
|
||||||
m_buffer.append(string.characters(), (int)string.length());
|
m_buffer.append(string.characters(), string.length());
|
||||||
m_cursor = (size_t)m_buffer.size();
|
m_cursor = m_buffer.size();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vt_save_cursor();
|
vt_save_cursor();
|
||||||
vt_clear_to_end_of_line();
|
vt_clear_to_end_of_line();
|
||||||
for (size_t i = m_cursor; i < (size_t)m_buffer.size(); ++i)
|
for (size_t i = m_cursor; i < m_buffer.size(); ++i)
|
||||||
fputc(m_buffer[(int)i], stdout);
|
fputc(m_buffer[i], stdout);
|
||||||
vt_restore_cursor();
|
vt_restore_cursor();
|
||||||
|
|
||||||
m_buffer.ensure_capacity(m_buffer.size() + (int)string.length());
|
m_buffer.ensure_capacity(m_buffer.size() + string.length());
|
||||||
for (size_t i = 0; i < string.length(); ++i)
|
for (size_t i = 0; i < string.length(); ++i)
|
||||||
m_buffer.insert((int)m_cursor + (int)i, string[i]);
|
m_buffer.insert(m_cursor + i, string[i]);
|
||||||
m_cursor += string.length();
|
m_cursor += string.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,19 +89,19 @@ void LineEditor::insert(const char ch)
|
||||||
putchar(ch);
|
putchar(ch);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
if (m_cursor == (size_t)m_buffer.size()) {
|
if (m_cursor == m_buffer.size()) {
|
||||||
m_buffer.append(ch);
|
m_buffer.append(ch);
|
||||||
m_cursor = (size_t)m_buffer.size();
|
m_cursor = m_buffer.size();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vt_save_cursor();
|
vt_save_cursor();
|
||||||
vt_clear_to_end_of_line();
|
vt_clear_to_end_of_line();
|
||||||
for (size_t i = m_cursor; i < (size_t)m_buffer.size(); ++i)
|
for (size_t i = m_cursor; i < m_buffer.size(); ++i)
|
||||||
fputc(m_buffer[(int)i], stdout);
|
fputc(m_buffer[i], stdout);
|
||||||
vt_restore_cursor();
|
vt_restore_cursor();
|
||||||
|
|
||||||
m_buffer.insert((int)m_cursor, ch);
|
m_buffer.insert(m_cursor, ch);
|
||||||
++m_cursor;
|
++m_cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ Vector<String> LineEditor::tab_complete_first_token(const String& token)
|
||||||
if (completion.length() > token.length())
|
if (completion.length() > token.length())
|
||||||
insert(completion.substring(token.length(), completion.length() - token.length()));
|
insert(completion.substring(token.length(), completion.length() - token.length()));
|
||||||
// If we have a single match, we add a space, unless we already have one.
|
// If we have a single match, we add a space, unless we already have one.
|
||||||
if (!seen_others && (m_cursor == (size_t)m_buffer.size() || m_buffer[(int)m_cursor] != ' '))
|
if (!seen_others && (m_cursor == m_buffer.size() || m_buffer[m_cursor] != ' '))
|
||||||
insert(' ');
|
insert(' ');
|
||||||
|
|
||||||
return suggestions;
|
return suggestions;
|
||||||
|
@ -184,18 +184,20 @@ Vector<String> LineEditor::tab_complete_other_token(String& token)
|
||||||
String path;
|
String path;
|
||||||
Vector<String> suggestions;
|
Vector<String> suggestions;
|
||||||
|
|
||||||
int last_slash = (int)token.length() - 1;
|
ASSERT(token.length() != 0);
|
||||||
|
|
||||||
|
ssize_t last_slash = token.length() - 1;
|
||||||
while (last_slash >= 0 && token[last_slash] != '/')
|
while (last_slash >= 0 && token[last_slash] != '/')
|
||||||
--last_slash;
|
--last_slash;
|
||||||
|
|
||||||
if (last_slash >= 0) {
|
if (last_slash >= 0) {
|
||||||
// Split on the last slash. We'll use the first part as the directory
|
// Split on the last slash. We'll use the first part as the directory
|
||||||
// to search and the second part as the token to complete.
|
// to search and the second part as the token to complete.
|
||||||
path = token.substring(0, (size_t)last_slash + 1);
|
path = token.substring(0, last_slash + 1);
|
||||||
if (path[0] != '/')
|
if (path[0] != '/')
|
||||||
path = String::format("%s/%s", g.cwd.characters(), path.characters());
|
path = String::format("%s/%s", g.cwd.characters(), path.characters());
|
||||||
path = canonicalized_path(path);
|
path = canonicalized_path(path);
|
||||||
token = token.substring((size_t)last_slash + 1, token.length() - (size_t)last_slash - 1);
|
token = token.substring(last_slash + 1, token.length() - last_slash - 1);
|
||||||
} else {
|
} else {
|
||||||
// We have no slashes, so the directory to search is the current
|
// We have no slashes, so the directory to search is the current
|
||||||
// directory and the token to complete is just the original token.
|
// directory and the token to complete is just the original token.
|
||||||
|
@ -247,7 +249,7 @@ Vector<String> LineEditor::tab_complete_other_token(String& token)
|
||||||
if (!stat_error) {
|
if (!stat_error) {
|
||||||
if (S_ISDIR(program_status.st_mode))
|
if (S_ISDIR(program_status.st_mode))
|
||||||
insert('/');
|
insert('/');
|
||||||
else if (m_cursor == (size_t)m_buffer.size() || m_buffer[(int)m_cursor] != ' ')
|
else if (m_cursor == m_buffer.size() || m_buffer[m_cursor] != ' ')
|
||||||
insert(' ');
|
insert(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,17 +299,17 @@ String LineEditor::get_line(const String& prompt)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto do_delete = [&] {
|
auto do_delete = [&] {
|
||||||
if (m_cursor == (size_t)m_buffer.size()) {
|
if (m_cursor == m_buffer.size()) {
|
||||||
fputc('\a', stdout);
|
fputc('\a', stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_buffer.remove((int)m_cursor - 1);
|
m_buffer.remove(m_cursor - 1);
|
||||||
fputs("\033[3~", stdout);
|
fputs("\033[3~", stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
vt_save_cursor();
|
vt_save_cursor();
|
||||||
vt_clear_to_end_of_line();
|
vt_clear_to_end_of_line();
|
||||||
for (size_t i = m_cursor; i < (size_t)m_buffer.size(); ++i)
|
for (size_t i = m_cursor; i < m_buffer.size(); ++i)
|
||||||
fputc(m_buffer[i], stdout);
|
fputc(m_buffer[i], stdout);
|
||||||
vt_restore_cursor();
|
vt_restore_cursor();
|
||||||
};
|
};
|
||||||
|
@ -353,7 +355,7 @@ String LineEditor::get_line(const String& prompt)
|
||||||
m_state = InputState::Free;
|
m_state = InputState::Free;
|
||||||
continue;
|
continue;
|
||||||
case 'C': // right
|
case 'C': // right
|
||||||
if (m_cursor < (size_t)m_buffer.size()) {
|
if (m_cursor < m_buffer.size()) {
|
||||||
++m_cursor;
|
++m_cursor;
|
||||||
fputs("\033[C", stdout);
|
fputs("\033[C", stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -369,10 +371,10 @@ String LineEditor::get_line(const String& prompt)
|
||||||
m_state = InputState::Free;
|
m_state = InputState::Free;
|
||||||
continue;
|
continue;
|
||||||
case 'F':
|
case 'F':
|
||||||
if (m_cursor < (size_t)m_buffer.size()) {
|
if (m_cursor < m_buffer.size()) {
|
||||||
fprintf(stdout, "\033[%zuC", (size_t)m_buffer.size() - m_cursor);
|
fprintf(stdout, "\033[%zuC", m_buffer.size() - m_cursor);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
m_cursor = (size_t)m_buffer.size();
|
m_cursor = m_buffer.size();
|
||||||
}
|
}
|
||||||
m_state = InputState::Free;
|
m_state = InputState::Free;
|
||||||
continue;
|
continue;
|
||||||
|
@ -398,10 +400,10 @@ String LineEditor::get_line(const String& prompt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch == '\t') {
|
if (ch == '\t') {
|
||||||
bool is_empty_token = m_cursor == 0 || m_buffer[(int)m_cursor - 1] == ' ';
|
bool is_empty_token = m_cursor == 0 || m_buffer[m_cursor - 1] == ' ';
|
||||||
m_times_tab_pressed++;
|
m_times_tab_pressed++;
|
||||||
|
|
||||||
int token_start = (int)m_cursor - 1;
|
int token_start = m_cursor - 1;
|
||||||
if (!is_empty_token) {
|
if (!is_empty_token) {
|
||||||
while (token_start >= 0 && m_buffer[token_start] != ' ')
|
while (token_start >= 0 && m_buffer[token_start] != ' ')
|
||||||
--token_start;
|
--token_start;
|
||||||
|
@ -416,7 +418,7 @@ String LineEditor::get_line(const String& prompt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String token = is_empty_token ? String() : String(&m_buffer[token_start], m_cursor - (size_t)token_start);
|
String token = is_empty_token ? String() : String(&m_buffer[token_start], m_cursor - token_start);
|
||||||
Vector<String> suggestions;
|
Vector<String> suggestions;
|
||||||
|
|
||||||
if (is_first_token)
|
if (is_first_token)
|
||||||
|
@ -463,13 +465,13 @@ String LineEditor::get_line(const String& prompt)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_buffer.remove((int)m_cursor - 1);
|
m_buffer.remove(m_cursor - 1);
|
||||||
--m_cursor;
|
--m_cursor;
|
||||||
putchar(8);
|
putchar(8);
|
||||||
vt_save_cursor();
|
vt_save_cursor();
|
||||||
vt_clear_to_end_of_line();
|
vt_clear_to_end_of_line();
|
||||||
for (size_t i = m_cursor; i < (size_t)m_buffer.size(); ++i)
|
for (size_t i = m_cursor; i < m_buffer.size(); ++i)
|
||||||
fputc(m_buffer[(int)i], stdout);
|
fputc(m_buffer[i], stdout);
|
||||||
vt_restore_cursor();
|
vt_restore_cursor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -480,7 +482,7 @@ String LineEditor::get_line(const String& prompt)
|
||||||
if (ch == g.termios.c_cc[VWERASE]) {
|
if (ch == g.termios.c_cc[VWERASE]) {
|
||||||
bool has_seen_nonspace = false;
|
bool has_seen_nonspace = false;
|
||||||
while (m_cursor > 0) {
|
while (m_cursor > 0) {
|
||||||
if (isspace(m_buffer[(int)m_cursor - 1])) {
|
if (isspace(m_buffer[m_cursor - 1])) {
|
||||||
if (has_seen_nonspace)
|
if (has_seen_nonspace)
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -500,8 +502,8 @@ String LineEditor::get_line(const String& prompt)
|
||||||
fputs(prompt.characters(), stdout);
|
fputs(prompt.characters(), stdout);
|
||||||
for (size_t i = 0; i < m_buffer.size(); ++i)
|
for (size_t i = 0; i < m_buffer.size(); ++i)
|
||||||
fputc(m_buffer[i], stdout);
|
fputc(m_buffer[i], stdout);
|
||||||
if (m_cursor < (size_t)m_buffer.size())
|
if (m_cursor < m_buffer.size())
|
||||||
printf("\033[%zuD", (size_t)m_buffer.size() - m_cursor); // Move cursor N steps left.
|
printf("\033[%zuD", m_buffer.size() - m_cursor); // Move cursor N steps left.
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -521,10 +523,10 @@ String LineEditor::get_line(const String& prompt)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ch == 0x05) { // ^E
|
if (ch == 0x05) { // ^E
|
||||||
if (m_cursor < (size_t)m_buffer.size()) {
|
if (m_cursor < m_buffer.size()) {
|
||||||
printf("\033[%zuC", (size_t)m_buffer.size() - m_cursor);
|
printf("\033[%zuC", m_buffer.size() - m_cursor);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
m_cursor = (size_t)m_buffer.size();
|
m_cursor = m_buffer.size();
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
dbg() << "Loading man page from " << file->filename();
|
dbg() << "Loading man page from " << file->filename();
|
||||||
auto buffer = file->read_all();
|
auto buffer = file->read_all();
|
||||||
String source { (const char*)buffer.data(), (size_t)buffer.size() };
|
auto source = String::copy(buffer);
|
||||||
|
|
||||||
printf("%s(%s)\t\tSerenityOS manual\n", name, section);
|
printf("%s(%s)\t\tSerenityOS manual\n", name, section);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ int main(int argc, char* argv[])
|
||||||
auto buffer = file->read_all();
|
auto buffer = file->read_all();
|
||||||
dbg() << "Read size " << buffer.size();
|
dbg() << "Read size " << buffer.size();
|
||||||
|
|
||||||
String input { (const char*)buffer.data(), (size_t)buffer.size() };
|
auto input = String::copy(buffer);
|
||||||
MDDocument document;
|
MDDocument document;
|
||||||
success = document.parse(input);
|
success = document.parse(input);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue