Make posix line mode the default always.

This commit is contained in:
2026-09-13 13:15:07 +01:00
parent 3346bc9f83
commit d246559292
5 changed files with 46 additions and 48 deletions
+20 -22
View File
@@ -202,7 +202,7 @@ Shard *Shard::build(Shard **pieces, uint64_t lo, uint64_t hi) {
return node;
}
Shard *Shard::from_command(const char *cmd, bool posix_ending) {
Shard *Shard::from_command(const char *cmd) {
auto o = new OriginalStorage("/tmp");
int dest_fd = o->fd;
if (dest_fd == -1) {
@@ -278,23 +278,21 @@ Shard *Shard::from_command(const char *cmd, bool posix_ending) {
io::IO::enable_raw();
return nullptr;
}
if (posix_ending) {
if (ending[1] == '\n') {
Petal *last = (Petal *)pieces.back();
last->lines--;
last->length--;
if (last->length == 0) {
Shard::release(last);
pieces.pop_back();
last = nullptr;
if (!pieces.empty())
last = (Petal *)pieces.back();
else
return nullptr;
}
if (last && ending[0] == '\r')
last->length--;
if (ending[1] == '\n') {
Petal *last = (Petal *)pieces.back();
last->lines--;
last->length--;
if (last->length == 0) {
Shard::release(last);
pieces.pop_back();
last = nullptr;
if (!pieces.empty())
last = (Petal *)pieces.back();
else
return nullptr;
}
if (last && ending[0] == '\r')
last->length--;
}
o->initialize();
io::IO::enable_raw();
@@ -303,7 +301,7 @@ Shard *Shard::from_command(const char *cmd, bool posix_ending) {
return build(pieces.data(), 0, pieces.size());
}
Shard *Shard::from_file(const std::filesystem::path &path, bool posix_ending) {
Shard *Shard::from_file(const std::filesystem::path &path) {
auto o = new OriginalStorage("/tmp");
int dest_fd = o->fd;
if (dest_fd == -1) {
@@ -313,10 +311,10 @@ Shard *Shard::from_file(const std::filesystem::path &path, bool posix_ending) {
int src_fd = open(path.c_str(), O_RDONLY);
if (src_fd == -1) {
delete o;
return nullptr;
throw ed_error("Couldn't open file.");
}
uint64_t total = std::filesystem::file_size(path);
if (posix_ending && total > 0) {
if (total > 0) {
char last;
if (pread(src_fd, &last, 1, (off_t)(total - 1)) != 1) {
delete o;
@@ -381,7 +379,7 @@ Shard *Shard::from_file(const std::filesystem::path &path, bool posix_ending) {
return build(pieces.data(), 0, pieces.size());
}
Shard *Shard::from_string(const char *data, uint64_t len, bool posix_ending) {
Shard *Shard::from_string(const char *data, uint64_t len) {
auto o = new OriginalStorage("/tmp");
int dest_fd = o->fd;
if (dest_fd == -1 || data == nullptr) {
@@ -389,7 +387,7 @@ Shard *Shard::from_string(const char *data, uint64_t len, bool posix_ending) {
return nullptr;
}
uint64_t total = len;
if (posix_ending && total > 0) {
if (total > 0) {
if (data[total - 1] == '\n') {
total--;
if (total > 0 && data[total - 1] == '\r')