mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibLine: Fix build in Linux environment
My host compiler was complaining about "%b" in format strings and about ignoring the return value from a bunch of write() calls.
This commit is contained in:
parent
6529b78d08
commit
28edafbfa6
1 changed files with 12 additions and 6 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace Line {
|
namespace Line {
|
||||||
|
@ -250,7 +251,7 @@ String Editor::get_line(const String& prompt)
|
||||||
m_state = InputState::ExpectTerminator;
|
m_state = InputState::ExpectTerminator;
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
dbgprintf("Shell: Unhandled final: %b (%c)\n", ch, ch);
|
dbgprintf("Shell: Unhandled final: %02x (%c)\n", ch, ch);
|
||||||
m_state = InputState::Free;
|
m_state = InputState::Free;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -323,11 +324,16 @@ String Editor::get_line(const String& prompt)
|
||||||
}
|
}
|
||||||
|
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
write(STDOUT_FILENO, prompt.characters(), prompt.length());
|
struct iovec iov[] = {
|
||||||
write(STDOUT_FILENO, m_buffer.data(), m_cursor);
|
{ const_cast<char*>(prompt.characters()), prompt.length() },
|
||||||
// Prevent not printing characters in case the user has moved the cursor and then pressed tab
|
{ m_buffer.data(), m_cursor },
|
||||||
write(STDOUT_FILENO, m_buffer.data() + m_cursor, m_buffer.size() - m_cursor);
|
{ m_buffer.data() + m_cursor, m_buffer.size() - m_cursor }
|
||||||
m_cursor = m_buffer.size(); // bash doesn't do this, but it makes a little bit more sense
|
};
|
||||||
|
if (writev(STDOUT_FILENO, iov, 3)) {
|
||||||
|
perror("writev");
|
||||||
|
ASSERT_NOT_REACHED();
|
||||||
|
}
|
||||||
|
m_cursor = m_buffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestions.clear_with_capacity();
|
suggestions.clear_with_capacity();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue