mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
AK: Make Vector use size_t for its size and capacity
This commit is contained in:
parent
9c6f7d3e7d
commit
ceec1a7d38
94 changed files with 323 additions and 317 deletions
|
@ -162,7 +162,7 @@ Vector<String> LineEditor::tab_complete_first_token(const String& token)
|
|||
cut_mismatching_chars(completion, m_path[i], token.length());
|
||||
seen_others = true;
|
||||
}
|
||||
for (int i = index + 1; i < m_path.size() && m_path[i].starts_with(token); ++i) {
|
||||
for (size_t i = index + 1; i < m_path.size() && m_path[i].starts_with(token); ++i) {
|
||||
cut_mismatching_chars(completion, m_path[i], token.length());
|
||||
suggestions.append(m_path[i]);
|
||||
seen_others = true;
|
||||
|
@ -433,7 +433,7 @@ String LineEditor::get_line(const String& prompt)
|
|||
size_t num_printed = 0;
|
||||
putchar('\n');
|
||||
for (auto& suggestion : suggestions) {
|
||||
int next_column = num_printed + suggestion.length() + longest_suggestion_length + 2;
|
||||
size_t next_column = num_printed + suggestion.length() + longest_suggestion_length + 2;
|
||||
|
||||
if (next_column > m_num_columns) {
|
||||
putchar('\n');
|
||||
|
@ -498,7 +498,7 @@ String LineEditor::get_line(const String& prompt)
|
|||
if (ch == 0xc) { // ^L
|
||||
printf("\033[3J\033[H\033[2J"); // Clear screen.
|
||||
fputs(prompt.characters(), stdout);
|
||||
for (int i = 0; i < m_buffer.size(); ++i)
|
||||
for (size_t i = 0; i < m_buffer.size(); ++i)
|
||||
fputc(m_buffer[i], stdout);
|
||||
if (m_cursor < (size_t)m_buffer.size())
|
||||
printf("\033[%zuD", (size_t)m_buffer.size() - m_cursor); // Move cursor N steps left.
|
||||
|
|
|
@ -59,13 +59,13 @@ private:
|
|||
|
||||
Vector<char, 1024> m_buffer;
|
||||
size_t m_cursor { 0 };
|
||||
int m_times_tab_pressed { 0 };
|
||||
int m_num_columns { 0 };
|
||||
size_t m_times_tab_pressed { 0 };
|
||||
size_t m_num_columns { 0 };
|
||||
|
||||
// FIXME: This should be something more take_first()-friendly.
|
||||
Vector<String> m_history;
|
||||
int m_history_cursor { 0 };
|
||||
int m_history_capacity { 100 };
|
||||
size_t m_history_cursor { 0 };
|
||||
size_t m_history_capacity { 100 };
|
||||
|
||||
Vector<String, 256> m_path;
|
||||
|
||||
|
|
|
@ -241,8 +241,8 @@ static int sh_cd(int argc, const char** argv)
|
|||
|
||||
static int sh_history(int, const char**)
|
||||
{
|
||||
for (int i = 0; i < editor.history().size(); ++i) {
|
||||
printf("%6d %s\n", i, editor.history()[i].characters());
|
||||
for (size_t i = 0; i < editor.history().size(); ++i) {
|
||||
printf("%6zu %s\n", i, editor.history()[i].characters());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ static int sh_dirs(int argc, const char** argv)
|
|||
for (int i = 0; i < argc; i++) {
|
||||
const char* arg = argv[i];
|
||||
if (!strcmp(arg, "-c")) {
|
||||
for (int i = 1; i < g.directory_stack.size(); i++)
|
||||
for (size_t i = 1; i < g.directory_stack.size(); i++)
|
||||
g.directory_stack.remove(i);
|
||||
|
||||
printed = true;
|
||||
|
@ -605,7 +605,7 @@ static Vector<String> expand_globs(const StringView& path, const StringView& bas
|
|||
builder.append(base);
|
||||
Vector<String> res;
|
||||
|
||||
for (int i = 0; i < parts.size(); ++i) {
|
||||
for (size_t i = 0; i < parts.size(); ++i) {
|
||||
auto& part = parts[i];
|
||||
if (!is_glob(part)) {
|
||||
builder.append(part);
|
||||
|
@ -758,7 +758,7 @@ static int run_command(const String& cmd)
|
|||
|
||||
FileDescriptionCollector fds;
|
||||
|
||||
for (int i = 0; i < command.subcommands.size(); ++i) {
|
||||
for (size_t i = 0; i < command.subcommands.size(); ++i) {
|
||||
auto& subcommand = command.subcommands[i];
|
||||
for (auto& redirection : subcommand.redirections) {
|
||||
switch (redirection.type) {
|
||||
|
@ -814,7 +814,7 @@ static int run_command(const String& cmd)
|
|||
|
||||
CommandTimer timer(cmd);
|
||||
|
||||
for (int i = 0; i < command.subcommands.size(); ++i) {
|
||||
for (size_t i = 0; i < command.subcommands.size(); ++i) {
|
||||
auto& subcommand = command.subcommands[i];
|
||||
Vector<String> argv_string = process_arguments(subcommand.args);
|
||||
Vector<const char*> argv;
|
||||
|
@ -879,7 +879,7 @@ static int run_command(const String& cmd)
|
|||
|
||||
int wstatus = 0;
|
||||
|
||||
for (int i = 0; i < children.size(); ++i) {
|
||||
for (size_t i = 0; i < children.size(); ++i) {
|
||||
auto& child = children[i];
|
||||
do {
|
||||
int rc = waitpid(child.pid, &wstatus, WEXITED | WSTOPPED);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue