mirror of
git://git.sv.gnu.org/nano.git
synced 2024-12-25 03:46:52 +03:00
More Mac file fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@777 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
960a8635bc
commit
0319176f2d
17
files.c
17
files.c
@ -125,6 +125,7 @@ filestruct *read_line(char *buf, filestruct * prev, int *line1ins)
|
|||||||
strcpy(fileptr->data, buf);
|
strcpy(fileptr->data, buf);
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
|
/* If it's a DOS file (CRLF), strip out the CR part*/
|
||||||
if (buf[strlen(buf) - 1] == '\r') {
|
if (buf[strlen(buf) - 1] == '\r') {
|
||||||
fileptr->data[strlen(buf) - 1] = 0;
|
fileptr->data[strlen(buf) - 1] = 0;
|
||||||
totsize--;
|
totsize--;
|
||||||
@ -184,15 +185,21 @@ int read_file(int fd, char *filename, int quiet)
|
|||||||
/* Read the entire file into file struct */
|
/* Read the entire file into file struct */
|
||||||
while ((size = read_byte(fd, filename, input)) > 0) {
|
while ((size = read_byte(fd, filename, input)) > 0) {
|
||||||
linetemp = 0;
|
linetemp = 0;
|
||||||
if (input[0] == '\n'
|
|
||||||
#ifndef NANO_SMALL
|
if (input[0] == '\n') {
|
||||||
|| (ISSET(MAC_FILE) && input[0] == '\r')
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
fileptr = read_line(buf, fileptr, &line1ins);
|
fileptr = read_line(buf, fileptr, &line1ins);
|
||||||
num_lines++;
|
num_lines++;
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
/* If it's a Mac file (no LF just a CR), handle it! */
|
||||||
|
} else if (i > 0 && buf[i-1] == '\r') {
|
||||||
|
fileptr = read_line(buf, fileptr, &line1ins);
|
||||||
|
num_lines++;
|
||||||
|
buf[0] = input[0];
|
||||||
|
buf[1] = 0;
|
||||||
|
i = 1;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* Now we allocate a bigger buffer 128 characters at a time.
|
/* Now we allocate a bigger buffer 128 characters at a time.
|
||||||
If we allocate a lot of space for one line, we may indeed
|
If we allocate a lot of space for one line, we may indeed
|
||||||
|
Loading…
Reference in New Issue
Block a user