]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/wresize.c
ncurses 6.4 - patch 20240302
[ncurses.git] / ncurses / base / wresize.c
index ee0594034d3759164c7fe183c9d946a9a652133c..6d5589e2794e867de44e1d9ac55e50cfb685b64a 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2019 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2010,2011 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            *
@@ -33,7 +34,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: wresize.c,v 1.38 2019/05/11 20:15:15 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.43 2023/10/21 11:13:03 tom Exp $")
 
 static int
 cleanup_lines(struct ldat *data, int length)
@@ -54,7 +55,7 @@ repair_subwindows(WINDOW *cmp)
     WINDOWLIST *wp;
     struct ldat *pline = cmp->_line;
     int row;
-#ifdef USE_SP_WINDOWLIST
+#if NCURSES_SP_FUNCS && defined(USE_SP_WINDOWLIST)
     SCREEN *sp = _nc_screen_of(cmp);
 #endif
 
@@ -134,7 +135,7 @@ wresize(WINDOW *win, int ToLines, int ToCols)
        && ToCols == size_x)
        returnCode(OK);
 
-    if ((win->_flags & _SUBWIN)) {
+    if (IS_SUBWIN(win)) {
        /*
         * Check if the new limits will fit into the parent window's size.  If
         * not, do not resize.  We could adjust the location of the subwindow,
@@ -168,14 +169,22 @@ wresize(WINDOW *win, int ToLines, int ToCols)
        int end = ToCols;
        NCURSES_CH_T *s;
 
-       if (!(win->_flags & _SUBWIN)) {
+       if (!IS_SUBWIN(win)) {
            if (row <= size_y) {
                if (ToCols != size_x) {
                    s = typeMalloc(NCURSES_CH_T, (unsigned) ToCols + 1);
                    if (s == 0)
                        returnCode(cleanup_lines(new_lines, row));
                    for (col = 0; col <= ToCols; ++col) {
-                       s[col] = (col <= size_x
+                       bool valid = (col <= size_x);
+                       if_WIDEC({
+                           if (col == ToCols
+                               && col < size_x
+                               && isWidecBase(win->_line[row].text[col])) {
+                               valid = FALSE;
+                           }
+                       });
+                       s[col] = (valid
                                  ? win->_line[row].text[col]
                                  : win->_nc_bkgd);
                    }