~ubuntu-branches/debian/sid/ncurses/sid-200908151540

« back to all changes in this revision

Viewing changes to ncurses/tinfo/setbuf.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-11-30 03:43:00 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20081130034300-lw6qrujyjmv6e32x
Tags: 5.7+20081122-2
Adding patch from Samuel Thibault to ensure that aalib checks the
value returned by Gpm_GetEvent() and only proceeds if value == 1
(Closes: #506717).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
 
 * Copyright (c) 1998-2007,2009 Free Software Foundation, Inc.              *
 
2
 * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc.              *
3
3
 *                                                                          *
4
4
 * Permission is hereby granted, free of charge, to any person obtaining a  *
5
5
 * copy of this software and associated documentation files (the            *
29
29
/****************************************************************************
30
30
 *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
31
31
 *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
32
 
 *     and: Thomas E. Dickey                        1996-on                 *
33
 
 *     and: Juergen Pfeifer                         2008                    *
34
32
 ****************************************************************************/
35
33
 
36
34
/*
42
40
 
43
41
#include <curses.priv.h>
44
42
 
45
 
MODULE_ID("$Id: setbuf.c,v 1.14 2009/05/09 23:09:00 tom Exp $")
 
43
MODULE_ID("$Id: setbuf.c,v 1.13 2007/05/12 19:04:02 tom Exp $")
46
44
 
47
45
/*
48
46
 * If the output file descriptor is connected to a tty (the typical case) it
100
98
 * buffer.  So we disable this by default (there may yet be a workaround).
101
99
 */
102
100
NCURSES_EXPORT(void)
103
 
NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered)
 
101
_nc_set_buffer(FILE *ofp, bool buffered)
104
102
{
105
103
    /* optional optimization hack -- do before any output to ofp */
106
104
#if HAVE_SETVBUF || HAVE_SETBUFFER
107
 
    if (SP_PARM->_buffered != buffered) {
 
105
    if (SP->_buffered != buffered) {
108
106
        unsigned buf_len;
109
107
        char *buf_ptr;
110
108
 
117
115
#endif
118
116
        if (buffered != 0) {
119
117
            buf_len = min(LINES * (COLS + 6), 2800);
120
 
            if ((buf_ptr = SP_PARM->_setbuf) == 0) {
 
118
            if ((buf_ptr = SP->_setbuf) == 0) {
121
119
                if ((buf_ptr = typeMalloc(char, buf_len)) == NULL)
122
120
                      return;
123
 
                SP_PARM->_setbuf = buf_ptr;
 
121
                SP->_setbuf = buf_ptr;
124
122
                /* Don't try to free this! */
125
123
            }
126
124
#if !USE_SETBUF_0
146
144
        (void) setbuffer(ofp, buf_ptr, (int) buf_len);
147
145
#endif
148
146
 
149
 
        SP_PARM->_buffered = buffered;
 
147
        SP->_buffered = buffered;
150
148
    }
151
149
#endif /* HAVE_SETVBUF || HAVE_SETBUFFER */
152
150
}
153
 
 
154
 
#if NCURSES_SP_FUNCS
155
 
NCURSES_EXPORT(void)
156
 
_nc_set_buffer(FILE *ofp, bool buffered)
157
 
{
158
 
    return NCURSES_SP_NAME(_nc_set_buffer) (CURRENT_SCREEN, ofp, buffered);
159
 
}
160
 
#endif