moved buffer function into buffer.c

master
bx 2022-04-03 08:15:22 +01:00
parent 338bda9c80
commit de01f1cf91
5 changed files with 30 additions and 29 deletions

View File

@ -1,8 +0,0 @@
Row *
b_getline(Row *r, int l) {
if (l == 1) return r;
if (r->n == NULL) return NULL;
return b_getline(r->n, l - 1);
}

View File

@ -1,8 +0,0 @@
Row *
b_insert(Row *r) {
Row *new = calloc(1, sizeof(Row));
new->n = r->n;
new->p = r;
r->n = new;
return new;
}

View File

@ -1,10 +0,0 @@
void
b_truncate(Row *row) {
Row *n = row->n;
row->n = NULL;
if (n != NULL) {
b_truncate(n);
free(n);
}
}

27
buffer.c 100644
View File

@ -0,0 +1,27 @@
Row *
b_getline(Row *r, int l) {
if (l == 1) return r;
if (r->n == NULL) return NULL;
return b_getline(r->n, l - 1);
}
Row *
b_insert(Row *r) {
Row *new = calloc(1, sizeof(Row));
new->n = r->n;
new->p = r;
r->n = new;
return new;
}
void
b_truncate(Row *row) {
Row *n = row->n;
row->n = NULL;
if (n != NULL) {
b_truncate(n);
free(n);
}
}

6
efn.c
View File

@ -12,11 +12,10 @@
#include "c_file.c"
#include "b_truncate.c"
#include "buffer.c"
#include "c_print.c"
#include "b_insert.c"
#include "c_writeline.c"
#include "b_getline.c"
#include "c_insertline.c"
#include "c_indent.c"
@ -27,3 +26,4 @@