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().
This commit is contained in:
Robert Brady 2000-10-25 19:14:19 +00:00 committed by Robert Brady
parent fb2127452a
commit f537723753
2 changed files with 12 additions and 6 deletions

View File

@ -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;

View File

@ -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;