1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-08-26 21:54:50 -04:00

Fold load_textarea_file into textarea_edit.

This commit is contained in:
Miciah Dashiel Butler Masters 2005-12-18 16:00:48 +00:00 committed by Miciah Dashiel Butler Masters
parent 517bb03da4
commit 9959f4d788

View File

@ -311,22 +311,6 @@ save_textarea_file(unsigned char *value)
return filename; return filename;
} }
static unsigned char *
load_textarea_file(unsigned char *filename, size_t maxlength)
{
struct string file;
if (!init_string(&file)
|| !add_file_to_string(&file, filename))
return NULL;
unlink(filename);
if (file.length > maxlength) { done_string(&file); return NULL; }
return file.source;
}
void void
textarea_edit(int op, struct terminal *term_, struct form_state *fs_, textarea_edit(int op, struct terminal *term_, struct form_state *fs_,
struct document_view *doc_view_, struct link *link_) struct document_view *doc_view_, struct link *link_)
@ -388,17 +372,29 @@ textarea_edit(int op, struct terminal *term_, struct form_state *fs_,
textarea_editor = 1; textarea_editor = 1;
} else if (op == 1 && fs) { } else if (op == 1 && fs) {
unsigned char *value = load_textarea_file(fn, fc_maxlength); struct string file;
if (value) { if (!init_string(&file)
mem_free(fs->value); || !add_file_to_string(&file, fn)) {
fs->value = value; textarea_editor = 0;
fs->state = strlen(value); goto free_and_return;
if (doc_view && link)
draw_form_entry(term, doc_view, link);
} }
unlink(fn);
if (file.length > fc_maxlength) {
done_string(&file);
textarea_editor = 0;
goto free_and_return;
}
mem_free(fs->value);
fs->value = file.source;
fs->state = file.length;
if (doc_view && link)
draw_form_entry(term, doc_view, link);
textarea_editor = 0; textarea_editor = 0;
goto free_and_return; goto free_and_return;
} }