Commit 7bf86e17 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

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
parent 23d3cf45
Showing with 18 additions and 6 deletions
+18 -6
...@@ -54,6 +54,9 @@ CVS code - ...@@ -54,6 +54,9 @@ CVS code -
and NANO_APPEND_KEY are. Changes to shortcut_init(), usage(), and NANO_APPEND_KEY are. Changes to shortcut_init(), usage(),
main(), search_init(), nanorc.sample, nano.1, nanorc.5, main(), search_init(), nanorc.sample, nano.1, nanorc.5,
nano.texi, etc. (DLR) nano.texi, etc. (DLR)
- When reading a file in, make sure each line is a valid
multibyte string. Changes to make_mbstring(), read_line(),
and do_credits(). (DLR)
- chars.c: - chars.c:
make_mbstring() make_mbstring()
- Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a - Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a
......
...@@ -301,7 +301,7 @@ char *make_mbchar(int chr, int *chr_mb_len) ...@@ -301,7 +301,7 @@ char *make_mbchar(int chr, int *chr_mb_len)
return chr_mb; return chr_mb;
} }
#if defined(ENABLE_NANORC) || defined(NANO_EXTRA) #if !defined(NANO_SMALL) || defined(ENABLE_NANORC) || defined(NANO_EXTRA)
/* Convert the string str to a valid multibyte string with the same wide /* Convert the string str to a valid multibyte string with the same wide
* character values as str. Return the (dynamically allocated) * character values as str. Return the (dynamically allocated)
* multibyte string. */ * multibyte string. */
......
...@@ -77,10 +77,16 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool ...@@ -77,10 +77,16 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
fileptr->data = mallocstrcpy(NULL, buf); fileptr->data = mallocstrcpy(NULL, buf);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* If it's a DOS file (CR LF), and file conversion isn't disabled, if (!ISSET(NO_CONVERT)) {
* strip out the CR part. */ /* If it's a DOS file (CR LF), and file conversion isn't
if (!ISSET(NO_CONVERT) && len > 0 && buf[len - 1] == '\r') * disabled, strip the CR part from fileptr->data. */
if (len > 0 && buf[len - 1] == '\r')
fileptr->data[len - 1] = '\0'; fileptr->data[len - 1] = '\0';
/* Make sure fileptr->data is a valid multibyte string. */
fileptr->data = mallocstrassn(fileptr->data,
make_mbstring(fileptr->data));
}
#endif #endif
if (*first_line_ins || fileage == NULL) { if (*first_line_ins || fileage == NULL) {
......
...@@ -557,6 +557,9 @@ void parse_rcfile(FILE *rcstream) ...@@ -557,6 +557,9 @@ void parse_rcfile(FILE *rcstream)
if (*option == '"') if (*option == '"')
option++; option++;
ptr = parse_argument(ptr); ptr = parse_argument(ptr);
/* Make sure option is a valid multibyte
* string. */
option = make_mbstring(option); option = make_mbstring(option);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "option = \"%s\"\n", option); fprintf(stderr, "option = \"%s\"\n", option);
......
...@@ -4036,7 +4036,7 @@ void do_credits(void) ...@@ -4036,7 +4036,7 @@ void do_credits(void)
"David Benbennick", "David Benbennick",
"Ken Tyler", "Ken Tyler",
"Sven Guckes", "Sven Guckes",
"Florian König", "Florian K\xF6nig",
"Pauli Virtanen", "Pauli Virtanen",
"Daniele Medri", "Daniele Medri",
"Clement Laforet", "Clement Laforet",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment