1
1

rcfile: allow alternate line endings in nanorc files

When copy-pasting has resulted in a nanorc file with DOS line endings
(CR+LF), then silently ignore the carriage return, to avoid printing
an error message that partly overwrites itself.

This fulfills https://savannah.gnu.org/bugs/?57756.
Requested-by: Matthias Aßhauer <mha1993@live.de>
Этот коммит содержится в:
Benno Schulenberg 2020-02-09 11:41:56 +01:00
родитель f8d2f552bd
Коммит 98f038ad96

Просмотреть файл

@ -1317,9 +1317,11 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
if (just_syntax && !intros_only && lineno <= live_syntax->lineno) if (just_syntax && !intros_only && lineno <= live_syntax->lineno)
continue; continue;
#endif #endif
/* Strip the terminating newline, if any. */ /* Strip the terminating newline and possibly a carriage return. */
if (buffer[len - 1] == '\n') if (buffer[len - 1] == '\n')
buffer[len - 1] = '\0'; buffer[--len] = '\0';
if (buffer[len - 1] == '\r')
buffer[--len] = '\0';
ptr = buffer; ptr = buffer;
while (isblank((unsigned char)*ptr)) while (isblank((unsigned char)*ptr))