when reading a file in, make sure each line is a valid multibyte string

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2612 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
David Lawrence Ramsey
2005-06-08 19:50:02 +00:00
parent 23d3cf4515
commit 7bf86e1707
5 changed files with 18 additions and 6 deletions

View File

@@ -77,10 +77,16 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
fileptr->data = mallocstrcpy(NULL, buf);
#ifndef NANO_SMALL
/* If it's a DOS file (CR LF), and file conversion isn't disabled,
* strip out the CR part. */
if (!ISSET(NO_CONVERT) && len > 0 && buf[len - 1] == '\r')
fileptr->data[len - 1] = '\0';
if (!ISSET(NO_CONVERT)) {
/* If it's a DOS file (CR LF), and file conversion isn't
* disabled, strip the CR part from fileptr->data. */
if (len > 0 && buf[len - 1] == '\r')
fileptr->data[len - 1] = '\0';
/* Make sure fileptr->data is a valid multibyte string. */
fileptr->data = mallocstrassn(fileptr->data,
make_mbstring(fileptr->data));
}
#endif
if (*first_line_ins || fileage == NULL) {