diff options
author | KatolaZ <katolaz@freaknet.org> | 2018-05-31 14:36:27 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2018-05-31 14:36:27 +0100 |
commit | 973479aa7fc254b887aed5fe6a57935648ee883c (patch) | |
tree | 791036edaccb2be9ed73514cf534bb41765ea344 /buff.c | |
parent | 00d893c8f8e742acc15e6675dec20c946dfb6fd7 (diff) |
Check on modified files 'q'.Implemented 'W'.more tests.minor fixes
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; } |