From: khamidou Date: Tue, 9 Jun 2009 21:17:16 +0000 (+0200) Subject: added a function to insert a char in a buffer X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=35fd5a4dba535285ccee5826e092c97b0f1adcad;p=te.git added a function to insert a char in a buffer --- 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; +} +