Lines Matching refs:source
62 get_next_block_fn(register Source source) in get_next_block_fn() argument
70 if (source == NULL) { in get_next_block_fn()
73 if ((source->fd < 0) || in get_next_block_fn()
74 ((source->bytes_left_in_file <= 0) && in get_next_block_fn()
75 (source->inp_buf_ptr >= source->inp_buf_end))) { in get_next_block_fn()
77 if (source->fd > 2) { in get_next_block_fn()
78 (void) close(source->fd); in get_next_block_fn()
86 if (source->string.free_after_use && in get_next_block_fn()
87 (source->string.buffer.start != NULL)) { in get_next_block_fn()
88 retmem(source->string.buffer.start); in get_next_block_fn()
89 source->string.buffer.start = NULL; in get_next_block_fn()
91 if (source->inp_buf != NULL) { in get_next_block_fn()
92 retmem_mb(source->inp_buf); in get_next_block_fn()
93 source->inp_buf = NULL; in get_next_block_fn()
95 source = source->previous; in get_next_block_fn()
96 if (source != NULL) { in get_next_block_fn()
97 source->error_converting = false; in get_next_block_fn()
99 return source; in get_next_block_fn()
101 if (source->bytes_left_in_file > 0) { in get_next_block_fn()
106 to_read = source->bytes_left_in_file; in get_next_block_fn()
107 source->inp_buf_ptr = source->inp_buf = getmem(to_read + 1); in get_next_block_fn()
108 source->inp_buf_end = source->inp_buf + to_read; in get_next_block_fn()
109 length = read(source->fd, source->inp_buf, (unsigned int) to_read); in get_next_block_fn()
121 *source->inp_buf_end = nul_char; in get_next_block_fn()
122 source->bytes_left_in_file = 0; in get_next_block_fn()
127 ptr = source->inp_buf_ptr + STRING_LEN_TO_CONVERT; in get_next_block_fn()
128 if (ptr > source->inp_buf_end) { in get_next_block_fn()
129 ptr = source->inp_buf_end; in get_next_block_fn()
131 for (num_wc_chars = 0; ptr > source->inp_buf_ptr; ptr--) { in get_next_block_fn()
134 num_wc_chars = mbstowcs(source->string.text.end, in get_next_block_fn()
135 source->inp_buf_ptr, in get_next_block_fn()
144 source->error_converting = true; in get_next_block_fn()
145 return source; in get_next_block_fn()
148 source->error_converting = false; in get_next_block_fn()
149 source->inp_buf_ptr = ptr; in get_next_block_fn()
150 source->string.text.end += num_wc_chars; in get_next_block_fn()
151 *source->string.text.end = 0; in get_next_block_fn()
153 if (source->inp_buf_ptr >= source->inp_buf_end) { in get_next_block_fn()
154 if (*(source->string.text.end - 1) != (int) newline_char) { in get_next_block_fn()
158 *source->string.text.end++ = (int) newline_char; in get_next_block_fn()
159 *source->string.text.end = (int) nul_char; in get_next_block_fn()
160 *source->string.buffer.end++; in get_next_block_fn()
162 if (source->inp_buf != NULL) { in get_next_block_fn()
163 retmem_mb(source->inp_buf); in get_next_block_fn()
164 source->inp_buf = NULL; in get_next_block_fn()
167 return source; in get_next_block_fn()