--- lbbs/src/str_process.c 2025/05/15 14:17:53 1.8 +++ lbbs/src/str_process.c 2025/05/28 05:46:27 1.10 @@ -52,21 +52,19 @@ int split_line(const char *buffer, int m continue; } - if (c > 127 && c <= 255) // GBK chinese character + if (c < 0 || c > 127) // GBK chinese character { if (*p_display_len + 2 > max_display_len) { - *p_eol = 1; break; } i++; - *p_display_len += 2; + (*p_display_len) += 2; } else { if (*p_display_len + 1 > max_display_len) { - *p_eol = 1; break; } (*p_display_len)++; @@ -76,7 +74,7 @@ int split_line(const char *buffer, int m return i; } -int split_data_lines(const char *p_buf, int max_display_len, long *p_line_offsets, int max_line_cnt) +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; @@ -89,15 +87,15 @@ int split_data_lines(const char *p_buf, { len = split_line(p_buf, max_display_len, &end_of_line, &display_len); - if (len == 0 || !end_of_line) // !end_of_line == EOF + if (len == 0) // EOF { break; } // Exceed max_line_cnt - if (line_cnt + 1 >= max_line_cnt) + if (line_cnt + 1 >= line_offsets_count) { - log_error("File line count %d reaches limit\n", line_cnt + 1); + log_error("Line count %d reaches limit %d\n", line_cnt + 1, line_offsets_count); return line_cnt; } @@ -106,11 +104,5 @@ int split_data_lines(const char *p_buf, p_buf += len; } - if (len > 0 && line_cnt + 1 < max_line_cnt) - { - p_line_offsets[line_cnt + 1] = p_line_offsets[line_cnt] + len; - line_cnt++; - } - return line_cnt; }