diff options
Diffstat (limited to 'files.c')
-rw-r--r-- | files.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -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++; |