after reading in a file and detecting the format it's in, set the file

format flags (DOS_FILE and MAC_FILE) to match, and preserve them across
multiple file buffers


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1958 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-10-03 13:47:26 +00:00
parent 360191c434
commit 7c1f17ab6d
2 changed files with 35 additions and 7 deletions

View File

@ -64,6 +64,11 @@ CVS code -
do_insertfile(), shortcut_init(), do_gotoline(), etc. do_insertfile(), shortcut_init(), do_gotoline(), etc.
- Make sure a few uninitialized static variables are initialized - Make sure a few uninitialized static variables are initialized
to sane values. (DLR) to sane values. (DLR)
- After reading in a file and detecting the format it's in, set
the file format flags (DOS_FILE and MAC_FILE) to match, and
preserve them across multiple file buffers. Changes to
read_file(), add_open_file(), and load_open_file(). (DLR,
suggested by Bill Soudan)
- files.c: - files.c:
do_insertfile() do_insertfile()
- Readd the NANO_SMALL #ifdef around the start_again: label to - Readd the NANO_SMALL #ifdef around the start_again: label to

View File

@ -170,6 +170,13 @@ void read_file(FILE *f, const char *filename)
* is NULL, then so is fileage. */ * is NULL, then so is fileage. */
assert(current != NULL || fileage == NULL); assert(current != NULL || fileage == NULL);
#ifndef NANO_SMALL
/* Clear the DOS and Mac file format flags, since we don't know
* which file format we have yet. */
UNSET(DOS_FILE);
UNSET(MAC_FILE);
#endif
/* Read the entire file into the file struct. */ /* Read the entire file into the file struct. */
while ((input_int = getc(f)) != EOF) { while ((input_int = getc(f)) != EOF) {
input = (char)input_int; input = (char)input_int;
@ -303,15 +310,17 @@ void read_file(FILE *f, const char *filename)
P_("Read %lu line (Converted from DOS and Mac format)", P_("Read %lu line (Converted from DOS and Mac format)",
"Read %lu lines (Converted from DOS and Mac format)", "Read %lu lines (Converted from DOS and Mac format)",
(unsigned long)num_lines), (unsigned long)num_lines); (unsigned long)num_lines), (unsigned long)num_lines);
else if (fileformat == 2) else if (fileformat == 2) {
SET(MAC_FILE);
statusbar(P_("Read %lu line (Converted from Mac format)", statusbar(P_("Read %lu line (Converted from Mac format)",
"Read %lu lines (Converted from Mac format)", "Read %lu lines (Converted from Mac format)",
(unsigned long)num_lines), (unsigned long)num_lines); (unsigned long)num_lines), (unsigned long)num_lines);
else if (fileformat == 1) } else if (fileformat == 1) {
SET(DOS_FILE);
statusbar(P_("Read %lu line (Converted from DOS format)", statusbar(P_("Read %lu line (Converted from DOS format)",
"Read %lu lines (Converted from DOS format)", "Read %lu lines (Converted from DOS format)",
(unsigned long)num_lines), (unsigned long)num_lines); (unsigned long)num_lines), (unsigned long)num_lines);
else } else
#endif #endif
statusbar(P_("Read %lu line", "Read %lu lines", statusbar(P_("Read %lu line", "Read %lu lines",
(unsigned long) num_lines),(unsigned long)num_lines); (unsigned long) num_lines),(unsigned long)num_lines);
@ -738,12 +747,14 @@ void add_open_file(int update)
/* save current line number */ /* save current line number */
open_files->file_lineno = current->lineno; open_files->file_lineno = current->lineno;
/* start with default modification status: unmodified (and marking /* start with default modification status: unmodified, unmarked (if
status, if available: unmarked) */ available), not in DOS format (if available), and not in Mac
format (if available) */
open_files->file_flags = 0; open_files->file_flags = 0;
/* if we're updating, save current modification status (and marking /* if we're updating, save current modification status, current
status, if available) */ marking status (if available), and current file format status (if
available) */
if (update) { if (update) {
if (ISSET(MODIFIED)) if (ISSET(MODIFIED))
open_files->file_flags |= MODIFIED; open_files->file_flags |= MODIFIED;
@ -753,6 +764,10 @@ void add_open_file(int update)
open_files->file_mark_beginx = mark_beginx; open_files->file_mark_beginx = mark_beginx;
open_files->file_flags |= MARK_ISSET; open_files->file_flags |= MARK_ISSET;
} }
if (ISSET(DOS_FILE))
open_files->file_flags |= DOS_FILE;
else if (ISSET(MAC_FILE))
open_files->file_flags |= MAC_FILE;
#endif #endif
} }
@ -804,6 +819,14 @@ void load_open_file(void)
SET(MARK_ISSET); SET(MARK_ISSET);
} else } else
UNSET(MARK_ISSET); UNSET(MARK_ISSET);
/* restore file format status */
UNSET(DOS_FILE);
UNSET(MAC_FILE);
if (open_files->file_flags & DOS_FILE)
SET(DOS_FILE);
else if (open_files->file_flags & MAC_FILE)
SET(MAC_FILE);
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR