summaryrefslogtreecommitdiff
path: root/files.c
diff options
context:
space:
mode:
Diffstat (limited to 'files.c')
-rw-r--r--files.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/files.c b/files.c
index 17743a5..dfeb3b2 100644
--- a/files.c
+++ b/files.c
@@ -7,7 +7,7 @@
void write_file(FILE *fc){
FILE *fout;
- int i;
+ int i, ne;
if (!fname[0] || force_new){
get_string(fc, "Write to: ", fname, 255);
@@ -23,8 +23,16 @@ void write_file(FILE *fc){
get_key(fc, "Error opening file.");
return;
}
+ ne = 0;
for (i=0; i<HEIGHT; i++){
- fprintf(fout, "%s\n", screen.l[i].s);
+ if (strlen(screen.l[i].s)){/* remove trailing blank lines */
+ /* put the empty lines preceeding the current non-empty one */
+ while (ne--)
+ fprintf(fout, "\n");
+ fprintf(fout, "%s\n", screen.l[i].s);
+ ne = 0;
+ }
+ else ne++;
}
fclose(fout);
modified = 0;
@@ -51,7 +59,7 @@ void load_file(FILE *fc){
if ((fin=fopen(newfname, "r")) != NULL){
i = 0;
while((fgets(screen.l[i].s, WIDTH+1, fin)) != NULL && i<HEIGHT){
- screen.l[i].lst = strlen(screen.l[i].s) - 1;
+ screen.l[i].lst = strlen(screen.l[i].s) - 2;
screen.l[i].n = i;
screen.l[i].s[strlen(screen.l[i].s)-1]='\0';
i++;