]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/setbuf.c
ncurses 5.7 - patch 20100501
[ncurses.git] / ncurses / tinfo / setbuf.c
index 5610913d35b05e17d25d49e3020ef7418b5b148f..f3be7f95f905e06897404b838173a3d6403a43a4 100644 (file)
@@ -42,7 +42,7 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: setbuf.c,v 1.14 2009/05/09 23:09:00 tom Exp $")
+MODULE_ID("$Id: setbuf.c,v 1.15 2009/05/23 22:13:44 tom Exp $")
 
 /*
  * If the output file descriptor is connected to a tty (the typical case) it
 
 /*
  * If the output file descriptor is connected to a tty (the typical case) it
@@ -102,6 +102,15 @@ MODULE_ID("$Id: setbuf.c,v 1.14 2009/05/09 23:09:00 tom Exp $")
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered)
 {
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered)
 {
+    int Cols;
+    int Lines;
+
+    if (0 == SP_PARM)
+       return;
+
+    Cols = *(ptrCols(SP_PARM));
+    Lines = *(ptrLines(SP_PARM));
+
     /* optional optimization hack -- do before any output to ofp */
 #if HAVE_SETVBUF || HAVE_SETBUFFER
     if (SP_PARM->_buffered != buffered) {
     /* optional optimization hack -- do before any output to ofp */
 #if HAVE_SETVBUF || HAVE_SETBUFFER
     if (SP_PARM->_buffered != buffered) {
@@ -116,7 +125,7 @@ NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered)
        setmode(ofp, O_BINARY);
 #endif
        if (buffered != 0) {
        setmode(ofp, O_BINARY);
 #endif
        if (buffered != 0) {
-           buf_len = min(LINES * (COLS + 6), 2800);
+           buf_len = min(Lines * (Cols + 6), 2800);
            if ((buf_ptr = SP_PARM->_setbuf) == 0) {
                if ((buf_ptr = typeMalloc(char, buf_len)) == NULL)
                      return;
            if ((buf_ptr = SP_PARM->_setbuf) == 0) {
                if ((buf_ptr = typeMalloc(char, buf_len)) == NULL)
                      return;
@@ -155,6 +164,6 @@ NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered)
 NCURSES_EXPORT(void)
 _nc_set_buffer(FILE *ofp, bool buffered)
 {
 NCURSES_EXPORT(void)
 _nc_set_buffer(FILE *ofp, bool buffered)
 {
-    return NCURSES_SP_NAME(_nc_set_buffer) (CURRENT_SCREEN, ofp, buffered);
+    NCURSES_SP_NAME(_nc_set_buffer) (CURRENT_SCREEN, ofp, buffered);
 }
 #endif
 }
 #endif