From 35fd5a4dba535285ccee5826e092c97b0f1adcad Mon Sep 17 00:00:00 2001 From: khamidou Date: Tue, 9 Jun 2009 23:17:16 +0200 Subject: [PATCH] added a function to insert a char in a buffer --- buffer.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/buffer.c b/buffer.c index 44ae165..3941995 100644 --- a/buffer.c +++ b/buffer.c @@ -39,12 +39,13 @@ void free_buffer(struct te_buffer *b) struct te_buffer* load_buffer(char *filename) { FILE *fp = fopen(filename, "r"); - + if (fp == NULL) fail("Unable to open %s", filename); struct te_buffer *b = alloc_and_insert_buffer(); + b->name = strdup(filename); b->contents = bfromcstr(""); if (b->contents == NULL) fail("Unable to allocate memory for buffer contents"); @@ -150,4 +151,14 @@ int move_right(struct te_buffer *buf) return OK; } +void insert_char(struct te_buffer *buf, char c) +{ + if (buf == NULL) + return; + + binsertch(buf->contents, buf->point, 1, c); + + return; +} + -- 2.43.0