diff options
Diffstat (limited to 'buff.c')
-rw-r--r-- | buff.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -138,6 +138,7 @@ int read_file(){ cur = b_end; fclose(fin); fprintf(stderr, "%d\n", tot); + mod = 0; return 0; } @@ -207,7 +208,7 @@ void append_lines(){ first = last = NULL; n = __get_lines(stdin, &first, &last, &tot); __append_lines(addr1, n, first, last); - + mod = 1; } void insert_lines(){ @@ -221,7 +222,7 @@ void insert_lines(){ __append_lines(addr1, n, first, last); else __append_lines(addr1-1, n, first, last); - + mod = 1; } @@ -264,7 +265,8 @@ void delete_lines(){ pos = addr2 - 1; cur = prev; } - num -= addr1 - addr2 + 1; + num -= addr1 - addr2 + 1; + mod = 1; } @@ -276,15 +278,19 @@ void change_lines(){ -int write_lines(){ +int write_lines(char app){ FILE *fout; line_t *l; int tot=0; - - if (! (fout = fopen(fname, "w+"))){ - return -1; - } + if (!app) + fout = fopen(fname, "w+"); + else + fout = fopen(fname, "a"); + + if (!fout) + return -1; + l = b_start; while(l){ tot += fprintf(fout, "%s", l->c); @@ -381,4 +387,5 @@ void transfer_lines(int addr, char move){ } __append_lines(addr, n, first, last); move_to_line(addr+n,0); + mod = 1; } |