Make a little effort to treate CRLF as LF in config files. GitHub issue
authornicm <nicm@openbsd.org>
Sun, 4 Aug 2024 09:42:23 +0000 (09:42 +0000)
committernicm <nicm@openbsd.org>
Sun, 4 Aug 2024 09:42:23 +0000 (09:42 +0000)
3720.

usr.bin/tmux/cmd-parse.y
usr.bin/tmux/tty.c

index 8140b5b..6565d2d 100644 (file)
@@ -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;
index 124cb35..51dd937 100644 (file)
@@ -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 <nicholas.marriott@gmail.com>
@@ -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)