mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-01 07:04:26 +03:00
in read_file(), improve autodetection of DOS and Mac format files to not
trigger on carriage returns in the middle of files, as found by Kjell Braden git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4179 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
4510bac41d
commit
cfd4b89f4b
@ -1,3 +1,9 @@
|
|||||||
|
2007-11-17 David Lawrence Ramsey <pooka109@gmail.com>
|
||||||
|
|
||||||
|
* files.c (read_file): Improve autodetection of DOS and Mac
|
||||||
|
format files to not trigger on carriage returns in the middle of
|
||||||
|
files, as found by Kjell Braden.
|
||||||
|
|
||||||
2007-11-06 David Lawrence Ramsey <pooka109@gmail.com>
|
2007-11-06 David Lawrence Ramsey <pooka109@gmail.com>
|
||||||
|
|
||||||
* doc/man/rnano.1, doc/man/fr/rnano.1: Update copyright notices,
|
* doc/man/rnano.1, doc/man/fr/rnano.1: Update copyright notices,
|
||||||
|
23
src/files.c
23
src/files.c
@ -382,12 +382,15 @@ void read_file(FILE *f, const char *filename)
|
|||||||
* conversion isn't disabled, handle it! */
|
* conversion isn't disabled, handle it! */
|
||||||
if (input == '\n') {
|
if (input == '\n') {
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* If there's a '\r' before the '\n', set format to DOS if
|
/* If it's a DOS file or a DOS/Mac file ('\r' before '\n' on
|
||||||
* we currently think this is a *nix file, or to both if we
|
* the first line if we think it's a *nix file, or on any
|
||||||
* currently think it's a Mac file. */
|
* line otherwise), and file conversion isn't disabled,
|
||||||
if (!ISSET(NO_CONVERT) && i > 0 && buf[i - 1] == '\r' &&
|
* handle it! */
|
||||||
(format == 0 || format == 2))
|
if (!ISSET(NO_CONVERT) && (num_lines == 0 || format != 0) &&
|
||||||
format++;
|
i > 0 && buf[i - 1] == '\r') {
|
||||||
|
if (format == 0 || format == 2)
|
||||||
|
format++;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Read in the line properly. */
|
/* Read in the line properly. */
|
||||||
@ -401,9 +404,11 @@ void read_file(FILE *f, const char *filename)
|
|||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
i = 0;
|
i = 0;
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* If it's a Mac file ('\r' without '\n'), and file conversion
|
/* If it's a Mac file ('\r' without '\n' on the first line if we
|
||||||
* isn't disabled, handle it! */
|
* think it's a *nix file, or on any line otherwise), and file
|
||||||
} else if (!ISSET(NO_CONVERT) && i > 0 && buf[i - 1] == '\r') {
|
* conversion isn't disabled, handle it! */
|
||||||
|
} else if (!ISSET(NO_CONVERT) && (num_lines == 0 ||
|
||||||
|
format != 0) && i > 0 && buf[i - 1] == '\r') {
|
||||||
/* If we currently think the file is a *nix file, set format
|
/* If we currently think the file is a *nix file, set format
|
||||||
* to Mac. If we currently think the file is a DOS file,
|
* to Mac. If we currently think the file is a DOS file,
|
||||||
* set format to both DOS and Mac. */
|
* set format to both DOS and Mac. */
|
||||||
|
Loading…
Reference in New Issue
Block a user