99
99
inbufcount = stream->buflen;
100
100
if (inbufcount > 0)
101
memcpy (inbuffer, stream->buf, inbufcount);
101
memcpy (inbuffer, stream->buf, inbufcount);
104
/* At this point, inbuffer[0..inbufcount-1] is filled. */
106
/* Combine the previous rest with a chunk of new input. */
108
(len <= BUFFERSIZE - inbufcount ? len : BUFFERSIZE - inbufcount);
112
memcpy (inbuffer + inbufcount, data, n);
113
data = (char *) data + n;
119
/* Handle complete UTF-8 characters. */
120
const char *inptr = inbuffer;
121
size_t insize = inbufcount;
129
c0 = ((const unsigned char *) inptr)[0];
130
if (insize < (c0 < 0xc0 ? 1 : c0 < 0xe0 ? 2 : c0 < 0xf0 ? 3 :
131
c0 < 0xf8 ? 4 : c0 < 0xfc ? 5 : 6))
134
nbytes = u8_mbtouc (&uc, (const unsigned char *) inptr, insize);
138
size_t prev_class_stack_size = stream->curr_class_stack_size;
139
stream->curr_class_stack_size = 0;
140
emit_pending_spans (stream, false);
141
ostream_write_str (stream->destination, "<br/>");
142
stream->curr_class_stack_size = prev_class_stack_size;
146
emit_pending_spans (stream, true);
151
ostream_write_str (stream->destination, """);
154
ostream_write_str (stream->destination, "&");
157
ostream_write_str (stream->destination, "<");
160
/* Needed to avoid "]]>" in the output. */
161
ostream_write_str (stream->destination, ">");
164
/* Needed because HTML viewers merge adjacent spaces
165
and drop spaces adjacent to <br> and similar. */
166
ostream_write_str (stream->destination, " ");
169
if (uc >= 0x20 && uc < 0x7F)
171
/* Output ASCII characters as such. */
174
ostream_write_mem (stream->destination, bytes, 1);
178
/* Output non-ASCII characters in #&nnn;
181
sprintf (bytes, "&#%d;", uc);
182
ostream_write_str (stream->destination, bytes);
191
/* Put back the unconverted part. */
192
if (insize > BUFSIZE)
197
memcpy (stream->buf, inptr, insize);
198
stream->buflen = insize;
202
memmove (inbuffer, inptr, insize);
104
/* At this point, inbuffer[0..inbufcount-1] is filled. */
106
/* Combine the previous rest with a chunk of new input. */
108
(len <= BUFFERSIZE - inbufcount ? len : BUFFERSIZE - inbufcount);
112
memcpy (inbuffer + inbufcount, data, n);
113
data = (char *) data + n;
119
/* Handle complete UTF-8 characters. */
120
const char *inptr = inbuffer;
121
size_t insize = inbufcount;
129
c0 = ((const unsigned char *) inptr)[0];
130
if (insize < (c0 < 0xc0 ? 1 : c0 < 0xe0 ? 2 : c0 < 0xf0 ? 3 :
131
c0 < 0xf8 ? 4 : c0 < 0xfc ? 5 : 6))
134
nbytes = u8_mbtouc (&uc, (const unsigned char *) inptr, insize);
138
size_t prev_class_stack_size = stream->curr_class_stack_size;
139
stream->curr_class_stack_size = 0;
140
emit_pending_spans (stream, false);
141
ostream_write_str (stream->destination, "<br/>");
142
stream->curr_class_stack_size = prev_class_stack_size;
146
emit_pending_spans (stream, true);
151
ostream_write_str (stream->destination, """);
154
ostream_write_str (stream->destination, "&");
157
ostream_write_str (stream->destination, "<");
160
/* Needed to avoid "]]>" in the output. */
161
ostream_write_str (stream->destination, ">");
164
/* Needed because HTML viewers merge adjacent spaces
165
and drop spaces adjacent to <br> and similar. */
166
ostream_write_str (stream->destination, " ");
169
if (uc >= 0x20 && uc < 0x7F)
171
/* Output ASCII characters as such. */
174
ostream_write_mem (stream->destination, bytes, 1);
178
/* Output non-ASCII characters in #&nnn;
181
sprintf (bytes, "&#%d;", (int) uc);
182
ostream_write_str (stream->destination, bytes);
191
/* Put back the unconverted part. */
192
if (insize > BUFSIZE)
197
memcpy (stream->buf, inptr, insize);
198
stream->buflen = insize;
202
memmove (inbuffer, inptr, insize);
206
206
#undef BUFFERSIZE