Code to read/write dos formatted files. Massive amounts of new code in read_line and write_file. New flag DOS_FILE
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@771 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
5d25f06e3b
commit
91841895e0
|
@ -10,6 +10,8 @@ CVS code -
|
||||||
function check_operating_dir(), changes to load_file (arg),
|
function check_operating_dir(), changes to load_file (arg),
|
||||||
open_file_dup_search (arg), new function do_gotopos for -F
|
open_file_dup_search (arg), new function do_gotopos for -F
|
||||||
(Ravid Lawrence Ramsey).
|
(Ravid Lawrence Ramsey).
|
||||||
|
- Code to read/write dos formatted files. Massive amounts of
|
||||||
|
new code in read_line and write_file. New flag DOS_FILE.
|
||||||
- nano.c:
|
- nano.c:
|
||||||
main()
|
main()
|
||||||
- Added vars oldcurrent and oldcurrent_x to check whether cursor
|
- Added vars oldcurrent and oldcurrent_x to check whether cursor
|
||||||
|
|
22
files.c
22
files.c
|
@ -124,6 +124,13 @@ filestruct *read_line(char *buf, filestruct * prev, int *line1ins)
|
||||||
fileptr->data = charalloc(strlen(buf) + 2);
|
fileptr->data = charalloc(strlen(buf) + 2);
|
||||||
strcpy(fileptr->data, buf);
|
strcpy(fileptr->data, buf);
|
||||||
|
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
if (buf[strlen(buf) - 1] == '\r') {
|
||||||
|
SET(DOS_FILE);
|
||||||
|
fileptr->data[strlen(buf) - 1] = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (*line1ins) {
|
if (*line1ins) {
|
||||||
/* Special case, insert with cursor on 1st line. */
|
/* Special case, insert with cursor on 1st line. */
|
||||||
fileptr->prev = NULL;
|
fileptr->prev = NULL;
|
||||||
|
@ -1117,6 +1124,10 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
||||||
fprintf(stderr, _("Wrote >%s\n"), fileptr->data);
|
fprintf(stderr, _("Wrote >%s\n"), fileptr->data);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
if (ISSET(DOS_FILE))
|
||||||
|
write(fd, "\r", 1);
|
||||||
|
#endif
|
||||||
write(fd, "\n", 1);
|
write(fd, "\n", 1);
|
||||||
|
|
||||||
fileptr = fileptr->next;
|
fileptr = fileptr->next;
|
||||||
|
@ -1130,6 +1141,17 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
} else if (size > 0) {
|
} else if (size > 0) {
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
if (ISSET(DOS_FILE)) {
|
||||||
|
size = write(fd, "\r", 1);
|
||||||
|
lineswritten++;
|
||||||
|
if (size == -1) {
|
||||||
|
statusbar(_("Could not open file for writing: %s"),
|
||||||
|
strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
size = write(fd, "\n", 1);
|
size = write(fd, "\n", 1);
|
||||||
lineswritten++;
|
lineswritten++;
|
||||||
if (size == -1) {
|
if (size == -1) {
|
||||||
|
|
1
nano.h
1
nano.h
|
@ -140,6 +140,7 @@ typedef struct rcoption {
|
||||||
#define REVERSE_SEARCH (1<<18)
|
#define REVERSE_SEARCH (1<<18)
|
||||||
#define MULTIBUFFER (1<<19)
|
#define MULTIBUFFER (1<<19)
|
||||||
#define CLEAR_BACKUPSTRING (1<<20)
|
#define CLEAR_BACKUPSTRING (1<<20)
|
||||||
|
#define DOS_FILE (1<<21)
|
||||||
|
|
||||||
/* Control key sequences, changing these would be very very bad */
|
/* Control key sequences, changing these would be very very bad */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue