/[LeafOK_CVS]/lbbs/src/str_process.c
ViewVC logotype

Diff of /lbbs/src/str_process.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.5 by sysadm, Tue May 13 02:19:49 2025 UTC Revision 1.6 by sysadm, Thu May 15 12:05:32 2025 UTC
# Line 20  Line 20 
20  #include <stdio.h>  #include <stdio.h>
21  #include <string.h>  #include <string.h>
22    
23  unsigned int split_line(const char *buffer, int max_len, int *p_eol, int *p_display_len)  unsigned int split_line(const char *buffer, int max_display_len, int *p_eol, int *p_display_len)
24  {  {
25          size_t len = strnlen(buffer, LINE_BUFFER_LEN);          size_t len = strnlen(buffer, LINE_BUFFER_LEN);
26          unsigned int i = 0;          unsigned int i = 0;
# Line 60  unsigned int split_line(const char *buff Line 60  unsigned int split_line(const char *buff
60    
61                  if (c > 127 && c <= 255) // GBK chinese character                  if (c > 127 && c <= 255) // GBK chinese character
62                  {                  {
63                          if (*p_display_len + 2 > max_len)                          if (*p_display_len + 2 > max_display_len)
64                          {                          {
65                                  *p_eol = 1;                                  *p_eol = 1;
66                                  break;                                  break;
# Line 70  unsigned int split_line(const char *buff Line 70  unsigned int split_line(const char *buff
70                  }                  }
71                  else                  else
72                  {                  {
73                          if (*p_display_len + 1 > max_len)                          if (*p_display_len + 1 > max_display_len)
74                          {                          {
75                                  *p_eol = 1;                                  *p_eol = 1;
76                                  break;                                  break;
# Line 82  unsigned int split_line(const char *buff Line 82  unsigned int split_line(const char *buff
82          return i;          return i;
83  }  }
84    
85  unsigned int split_file_lines(FILE *fin, int max_len, long *p_line_offsets, int max_line_cnt)  unsigned int split_file_lines(FILE *fin, int max_display_len, long *p_line_offsets, int max_line_cnt)
86  {  {
87          char buffer[LINE_BUFFER_LEN];          char buffer[LINE_BUFFER_LEN];
88          char *p_buf = buffer;          char *p_buf = buffer;
# Line 98  unsigned int split_file_lines(FILE *fin, Line 98  unsigned int split_file_lines(FILE *fin,
98                  p_buf = buffer;                  p_buf = buffer;
99                  while (1)                  while (1)
100                  {                  {
101                          len = split_line(p_buf, max_len, &end_of_line, &display_len);                          len = split_line(p_buf, max_display_len, &end_of_line, &display_len);
102    
103                          if (len == 0 || !end_of_line) // !end_of_line == EOF                          if (len == 0 || !end_of_line) // !end_of_line == EOF
104                          {                          {


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1