Revert "Fix issue#100: CRLF across 8k boundary inserts an empty line."
This reverts commit f6d7a422f3
.
This commit is contained in:
parent
0c974a2db5
commit
ab31ab9b12
|
@ -290,6 +290,7 @@ pluma_document_output_stream_write (GOutputStream *stream,
|
||||||
gsize len;
|
gsize len;
|
||||||
gboolean freetext = FALSE;
|
gboolean freetext = FALSE;
|
||||||
const gchar *end;
|
const gchar *end;
|
||||||
|
gsize nvalid;
|
||||||
gboolean valid;
|
gboolean valid;
|
||||||
|
|
||||||
if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||||
|
@ -327,22 +328,16 @@ pluma_document_output_stream_write (GOutputStream *stream,
|
||||||
|
|
||||||
/* validate */
|
/* validate */
|
||||||
valid = g_utf8_validate (text, len, &end);
|
valid = g_utf8_validate (text, len, &end);
|
||||||
|
nvalid = end - text;
|
||||||
/* Avoid keeping a CRLF across two buffers. */
|
|
||||||
if (valid && len > 1 && end[-1] == '\r') {
|
|
||||||
valid = FALSE;
|
|
||||||
end--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!valid)
|
if (!valid)
|
||||||
{
|
{
|
||||||
gsize nvalid = end - text;
|
gsize remainder;
|
||||||
gsize remainder = len - nvalid;
|
|
||||||
gunichar ch;
|
remainder = len - nvalid;
|
||||||
|
|
||||||
if ((remainder < MAX_UNICHAR_LEN) &&
|
if ((remainder < MAX_UNICHAR_LEN) &&
|
||||||
((ch = g_utf8_get_char_validated (text + nvalid, remainder)) == (gunichar)-2 ||
|
(g_utf8_get_char_validated (text + nvalid, remainder) == (gunichar)-2))
|
||||||
ch == (gunichar)'\r'))
|
|
||||||
{
|
{
|
||||||
ostream->priv->buffer = g_strndup (end, remainder);
|
ostream->priv->buffer = g_strndup (end, remainder);
|
||||||
ostream->priv->buflen = remainder;
|
ostream->priv->buflen = remainder;
|
||||||
|
@ -350,7 +345,7 @@ pluma_document_output_stream_write (GOutputStream *stream,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* TODO: we could escape invalid text and tag it in red
|
/* TODO: we cuould escape invalid text and tag it in red
|
||||||
* and make the doc readonly.
|
* and make the doc readonly.
|
||||||
*/
|
*/
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
|
||||||
|
|
Loading…
Reference in New Issue