diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2024-08-04 09:42:24 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2024-08-04 09:42:24 +0000 |
commit | ef8eba4759f51356dec0ca53c46976d9083e3cb7 (patch) | |
tree | 76eed37271419698e9a341061905dccc08af10fb /usr.bin/tmux/cmd-parse.y | |
parent | 90dfb65d8d05c75fcae4f42dbdd636c9bfc6bedb (diff) |
Make a little effort to treate CRLF as LF in config files. GitHub issue
3720.
Diffstat (limited to 'usr.bin/tmux/cmd-parse.y')
-rw-r--r-- | usr.bin/tmux/cmd-parse.y | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y index 8140b5b58a2..6565d2d2797 100644 --- a/usr.bin/tmux/cmd-parse.y +++ b/usr.bin/tmux/cmd-parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-parse.y,v 1.50 2023/03/15 08:15:39 nicm Exp $ */ +/* $OpenBSD: cmd-parse.y,v 1.51 2024/08/04 09:42:23 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1273,6 +1273,16 @@ yylex(void) continue; } + if (ch == '\r') { + /* + * Treat \r\n as \n. + */ + ch = yylex_getc(); + if (ch != '\n') { + yylex_ungetc(ch); + ch = '\r'; + } + } if (ch == '\n') { /* * End of line. Update the line number. @@ -1619,6 +1629,13 @@ yylex_token(int ch) log_debug("%s: end at EOF", __func__); break; } + if (state == NONE && ch == '\r') { + ch = yylex_getc(); + if (ch != '\n') { + yylex_ungetc(ch); + ch = '\r'; + } + } if (state == NONE && ch == '\n') { log_debug("%s: end at EOL", __func__); break; |