/[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.12 by sysadm, Wed Jun 11 04:27:48 2025 UTC Revision 1.14 by sysadm, Sat Jun 14 02:58:11 2025 UTC
# Line 63  int split_line(const char *buffer, int m Line 63  int split_line(const char *buffer, int m
63                          }                          }
64                          (*p_display_len)++;                          (*p_display_len)++;
65    
66                           // \n is regarded as 1 character wide in terminal editor, which is different from Web version                          // \n is regarded as 1 character wide in terminal editor, which is different from Web version
67                          if (c == '\n')                          if (c == '\n')
68                          {                          {
69                                  i++;                                  i++;
# Line 79  int split_line(const char *buffer, int m Line 79  int split_line(const char *buffer, int m
79  long split_data_lines(const char *p_buf, int max_display_len, long *p_line_offsets, long line_offsets_count)  long split_data_lines(const char *p_buf, int max_display_len, long *p_line_offsets, long line_offsets_count)
80  {  {
81          int line_cnt = 0;          int line_cnt = 0;
82          int len = 0;          int len;
83          int end_of_line = 0;          int end_of_line = 0;
84          int display_len = 0;          int display_len = 0;
85    
86          p_line_offsets[line_cnt] = 0L;          p_line_offsets[line_cnt] = 0L;
87    
88          while (1)          do
89          {          {
90                  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);
91    
                 if (len == 0) // EOF  
                 {  
                         break;  
                 }  
   
92                  // Exceed max_line_cnt                  // Exceed max_line_cnt
93                  if (line_cnt + 1 >= line_offsets_count)                  if (line_cnt + 1 >= line_offsets_count)
94                  {                  {
# Line 104  long split_data_lines(const char *p_buf, Line 99  long split_data_lines(const char *p_buf,
99                  p_line_offsets[line_cnt + 1] = p_line_offsets[line_cnt] + len;                  p_line_offsets[line_cnt + 1] = p_line_offsets[line_cnt] + len;
100                  line_cnt++;                  line_cnt++;
101                  p_buf += len;                  p_buf += len;
102          }          } while (p_buf[0] != '\0');
103    
104          return line_cnt;          return line_cnt;
105  }  }
106    
107    int ctrl_seq_filter(char *buffer)
108    {
109            int i;
110            int j;
111            char c;
112    
113            for (i = 0, j = 0; buffer[i] != '\0'; i++)
114            {
115                    c = buffer[i];
116    
117                    if (c == '\r' || c == '\7') // skip
118                    {
119                            continue;
120                    }
121    
122                    if (c == '\033' && buffer[i + 1] == '[') // Skip control sequence
123                    {
124                            i += 2;
125                            while (buffer[i] != '\0' && buffer[i] != 'm')
126                            {
127                                    i++;
128                            }
129                            continue;
130                    }
131    
132                    buffer[j] = buffer[i];
133                    j++;
134            }
135    
136            buffer[j] = '\0';
137    
138            return j;
139    }


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

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