--- lbbs/src/str_process.c 2025/06/02 15:01:55 1.11 +++ lbbs/src/str_process.c 2025/06/13 10:52:07 1.13 @@ -36,13 +36,6 @@ int split_line(const char *buffer, int m continue; } - if (c == '\n') - { - i++; - *p_eol = 1; - break; - } - if (c == '\033' && buffer[i + 1] == '[') // Skip control sequence { i += 2; @@ -69,6 +62,14 @@ int split_line(const char *buffer, int m break; } (*p_display_len)++; + + // \n is regarded as 1 character wide in terminal editor, which is different from Web version + if (c == '\n') + { + i++; + *p_eol = 1; + break; + } } } @@ -78,21 +79,16 @@ int split_line(const char *buffer, int m long split_data_lines(const char *p_buf, int max_display_len, long *p_line_offsets, long line_offsets_count) { int line_cnt = 0; - int len = 0; + int len; int end_of_line = 0; int display_len = 0; p_line_offsets[line_cnt] = 0L; - while (1) + do { len = split_line(p_buf, max_display_len, &end_of_line, &display_len); - if (len == 0) // EOF - { - break; - } - // Exceed max_line_cnt if (line_cnt + 1 >= line_offsets_count) { @@ -103,7 +99,7 @@ long split_data_lines(const char *p_buf, p_line_offsets[line_cnt + 1] = p_line_offsets[line_cnt] + len; line_cnt++; p_buf += len; - } + } while (p_buf[0] != '\0'); return line_cnt; }