Commit f5377237 authored by Robert Brady's avatar Robert Brady Committed by Robert Brady

Allow creation of new files when saving.

2000-10-25  Robert Brady  <robert@suse.co.uk>

	* gtk/testtext.c (save_buffer): Allow creation of new files when
	saving.

	(fill_file_buffer): Don't die if a UTF-8 sequence is split across
	calls to read().
parent fb212745
......@@ -620,7 +620,7 @@ fill_file_buffer (GtkTextBuffer *buffer, const char *filename)
gint count;
char *leftover, *next;
int to_read = 2047 - remaining;
count = fread (buf + remaining, 1, to_read, f);
buf[count + remaining] = '\0';
......@@ -632,6 +632,10 @@ fill_file_buffer (GtkTextBuffer *buffer, const char *filename)
break;
next = g_utf8_next_char (next);
if (next > buf+count+remaining) {
next = NULL;
break;
}
}
gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf);
......@@ -1090,9 +1094,8 @@ save_buffer (Buffer *buffer)
buffer->filename, bak_filename, g_strerror (errno));
msgbox_run (NULL, err, "OK", NULL, NULL, 0);
g_free (err);
return FALSE;
}
return FALSE;
}
else
have_backup = TRUE;
......
......@@ -620,7 +620,7 @@ fill_file_buffer (GtkTextBuffer *buffer, const char *filename)
gint count;
char *leftover, *next;
int to_read = 2047 - remaining;
count = fread (buf + remaining, 1, to_read, f);
buf[count + remaining] = '\0';
......@@ -632,6 +632,10 @@ fill_file_buffer (GtkTextBuffer *buffer, const char *filename)
break;
next = g_utf8_next_char (next);
if (next > buf+count+remaining) {
next = NULL;
break;
}
}
gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf);
......@@ -1090,9 +1094,8 @@ save_buffer (Buffer *buffer)
buffer->filename, bak_filename, g_strerror (errno));
msgbox_run (NULL, err, "OK", NULL, NULL, 0);
g_free (err);
return FALSE;
}
return FALSE;
}
else
have_backup = TRUE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment