equal
deleted
inserted
replaced
73 hbuf = *p_hbuf = g_list_last(*p_hbuf); |
73 hbuf = *p_hbuf = g_list_last(*p_hbuf); |
74 hbuf_b_prev = hbuf->data; |
74 hbuf_b_prev = hbuf->data; |
75 hbuf_block_elt->ptr = hbuf_b_prev->ptr_end; |
75 hbuf_block_elt->ptr = hbuf_b_prev->ptr_end; |
76 hbuf_block_elt->flags = HBB_FLAG_PERSISTENT; |
76 hbuf_block_elt->flags = HBB_FLAG_PERSISTENT; |
77 hbuf_block_elt->ptr_end_alloc = hbuf_b_prev->ptr_end_alloc; |
77 hbuf_block_elt->ptr_end_alloc = hbuf_b_prev->ptr_end_alloc; |
78 g_list_append(*p_hbuf, hbuf_block_elt); |
78 *p_hbuf = g_list_append(*p_hbuf, hbuf_block_elt); |
79 } |
79 } |
80 |
80 |
81 if (strlen(text) >= HBB_BLOCKSIZE) { |
81 if (strlen(text) >= HBB_BLOCKSIZE) { |
82 // Too long |
82 // Too long |
83 text = "[ERR:LINE_TOO_LONG]"; |
83 text = "[ERR:LINE_TOO_LONG]"; |
111 hbuf_block_elt = g_new0(hbuf_block, 1); |
111 hbuf_block_elt = g_new0(hbuf_block, 1); |
112 hbuf_block_elt->ptr = hbuf_b_prev->ptr_end + 1; // == cr+1 |
112 hbuf_block_elt->ptr = hbuf_b_prev->ptr_end + 1; // == cr+1 |
113 hbuf_block_elt->ptr_end = end; |
113 hbuf_block_elt->ptr_end = end; |
114 hbuf_block_elt->flags = HBB_FLAG_PERSISTENT; |
114 hbuf_block_elt->flags = HBB_FLAG_PERSISTENT; |
115 hbuf_block_elt->ptr_end_alloc = hbuf_b_prev->ptr_end_alloc; |
115 hbuf_block_elt->ptr_end_alloc = hbuf_b_prev->ptr_end_alloc; |
116 g_list_append(*p_hbuf, hbuf_block_elt); |
116 *p_hbuf = g_list_append(*p_hbuf, hbuf_block_elt); |
117 line = hbuf_block_elt->ptr; |
117 line = hbuf_block_elt->ptr; |
118 } else { |
118 } else { |
119 // We need to break where we can find a space char |
119 // We need to break where we can find a space char |
120 char *br; // break pointer |
120 char *br; // break pointer |
121 for (br = line + width; br > line && *br != 32 && *br != 9; br--) |
121 for (br = line + width; br > line && *br != 32 && *br != 9; br--) |
129 hbuf_block_elt = g_new0(hbuf_block, 1); |
129 hbuf_block_elt = g_new0(hbuf_block, 1); |
130 hbuf_block_elt->ptr = hbuf_b_prev->ptr_end; // == br |
130 hbuf_block_elt->ptr = hbuf_b_prev->ptr_end; // == br |
131 hbuf_block_elt->ptr_end = end; |
131 hbuf_block_elt->ptr_end = end; |
132 hbuf_block_elt->flags = 0; |
132 hbuf_block_elt->flags = 0; |
133 hbuf_block_elt->ptr_end_alloc = hbuf_b_prev->ptr_end_alloc; |
133 hbuf_block_elt->ptr_end_alloc = hbuf_b_prev->ptr_end_alloc; |
134 g_list_append(*p_hbuf, hbuf_block_elt); |
134 *p_hbuf = g_list_append(*p_hbuf, hbuf_block_elt); |
135 line = hbuf_block_elt->ptr; |
135 line = hbuf_block_elt->ptr; |
136 } |
136 } |
137 cr = strchr(line, '\n'); |
137 cr = strchr(line, '\n'); |
138 } |
138 } |
139 } |
139 } |
180 hbuf_b_next = (hbuf_block*)(next_elt->data); |
180 hbuf_b_next = (hbuf_block*)(next_elt->data); |
181 // Is next line not-persistent? |
181 // Is next line not-persistent? |
182 if (!(hbuf_b_next->flags & HBB_FLAG_PERSISTENT)) { |
182 if (!(hbuf_b_next->flags & HBB_FLAG_PERSISTENT)) { |
183 hbuf_b_curr->ptr_end = hbuf_b_next->ptr_end; |
183 hbuf_b_curr->ptr_end = hbuf_b_next->ptr_end; |
184 g_free(hbuf_b_next); |
184 g_free(hbuf_b_next); |
185 g_list_delete_link(curr_elt, next_elt); |
185 curr_elt = g_list_delete_link(curr_elt, next_elt); |
186 } else |
186 } else |
187 curr_elt = next_elt; |
187 curr_elt = next_elt; |
188 } |
188 } |
189 // #2 Go back to head and create non-persistent blocks when needed |
189 // #2 Go back to head and create non-persistent blocks when needed |
190 if (width) { |
190 if (width) { |