From 2544af8ff809cc0db07c43becadd3244e3bfee5b Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 4 Aug 2024 09:42:23 +0000 Subject: [PATCH] Make a little effort to treate CRLF as LF in config files. GitHub issue 3720. --- usr.bin/tmux/cmd-parse.y | 19 ++++++++++++++++++- usr.bin/tmux/tty.c | 3 +-- 2 files changed, 19 insertions(+), 3 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 @@ -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; diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 124cb357d62..51dd9378efa 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.437 2024/08/04 09:35:30 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.438 2024/08/04 09:42:23 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2656,7 +2656,6 @@ static void tty_colours(struct tty *tty, const struct grid_cell *gc) { struct grid_cell *tc = &tty->cell; - int have_ax; /* No changes? Nothing is necessary. */ if (gc->fg == tc->fg && gc->bg == tc->bg && gc->us == tc->us) -- 2.20.1