| 52 |
continue; |
continue; |
| 53 |
} |
} |
| 54 |
|
|
| 55 |
if (c > 127 && c <= 255) // GBK chinese character |
if (c < 0 || c > 127) // GBK chinese character |
| 56 |
{ |
{ |
| 57 |
if (*p_display_len + 2 > max_display_len) |
if (*p_display_len + 2 > max_display_len) |
| 58 |
{ |
{ |
|
*p_eol = 1; |
|
| 59 |
break; |
break; |
| 60 |
} |
} |
| 61 |
i++; |
i++; |
| 62 |
*p_display_len += 2; |
(*p_display_len) += 2; |
| 63 |
} |
} |
| 64 |
else |
else |
| 65 |
{ |
{ |
| 66 |
if (*p_display_len + 1 > max_display_len) |
if (*p_display_len + 1 > max_display_len) |
| 67 |
{ |
{ |
|
*p_eol = 1; |
|
| 68 |
break; |
break; |
| 69 |
} |
} |
| 70 |
(*p_display_len)++; |
(*p_display_len)++; |
| 74 |
return i; |
return i; |
| 75 |
} |
} |
| 76 |
|
|
| 77 |
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) |
| 78 |
{ |
{ |
| 79 |
int line_cnt = 0; |
int line_cnt = 0; |
| 80 |
int len = 0; |
int len = 0; |
| 87 |
{ |
{ |
| 88 |
len = split_line(p_buf, max_display_len, &end_of_line, &display_len); |
len = split_line(p_buf, max_display_len, &end_of_line, &display_len); |
| 89 |
|
|
| 90 |
if (len == 0 || !end_of_line) // !end_of_line == EOF |
if (len == 0) // EOF |
| 91 |
{ |
{ |
| 92 |
break; |
break; |
| 93 |
} |
} |
| 94 |
|
|
| 95 |
// Exceed max_line_cnt |
// Exceed max_line_cnt |
| 96 |
if (line_cnt + 1 >= max_line_cnt) |
if (line_cnt + 1 >= line_offsets_count) |
| 97 |
{ |
{ |
| 98 |
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); |
| 99 |
return line_cnt; |
return line_cnt; |
| 100 |
} |
} |
| 101 |
|
|
| 104 |
p_buf += len; |
p_buf += len; |
| 105 |
} |
} |
| 106 |
|
|
|
if (len > 0 && line_cnt + 1 < max_line_cnt) |
|
|
{ |
|
|
p_line_offsets[line_cnt + 1] = p_line_offsets[line_cnt] + len; |
|
|
line_cnt++; |
|
|
} |
|
|
|
|
| 107 |
return line_cnt; |
return line_cnt; |
| 108 |
} |
} |