]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_bkgd.c
ncurses 6.2 - patch 20200531
[ncurses.git] / ncurses / base / lib_bkgd.c
index aa1db21e4fa8f5f050b8fc0ae64a55eecf2dd91c..1dcae90d6ad955c1576f46a556fb54635d078a18 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc.              *
+ * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 1998-2014,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -36,7 +37,9 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_bkgd.c,v 1.53 2019/08/17 20:59:41 tom Exp $")
+MODULE_ID("$Id: lib_bkgd.c,v 1.55 2020/03/02 01:34:48 tom Exp $")
+
+static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
 
 /*
  * Set the window's background information.
@@ -142,6 +145,14 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch)
            SetPair(new_bkgd, 0);
        }
 
+       /* avoid setting background-character to a null */
+       if (CharOf(new_bkgd) == 0) {
+           NCURSES_CH_T tmp_bkgd = blank;
+           SetAttr(tmp_bkgd, AttrOf(new_bkgd));
+           SetPair(tmp_bkgd, GetPair(new_bkgd));
+           new_bkgd = tmp_bkgd;
+       }
+
        memset(&old_bkgd, 0, sizeof(old_bkgd));
        (void) wgetbkgrnd(win, &old_bkgd);