forked from AuroraMiddleware/gtk
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:
parent
fb2127452a
commit
f537723753
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user