aboutsummaryrefslogtreecommitdiff
path: root/ncurses/base/lib_screen.c
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2014-02-28 19:12:44 +0000
committerXin LI <delphij@FreeBSD.org>2014-02-28 19:12:44 +0000
commit4b819fa20a8d007a10f2d3e8d6a5dedf7f18fc9a (patch)
treeb8f6e12b479a78216f3bffb8e1258d54087268de /ncurses/base/lib_screen.c
parente07762606a5bf651a501cb095c98cba90e4a8fe2 (diff)
downloadsrc-4b819fa20a8d007a10f2d3e8d6a5dedf7f18fc9a.tar.gz
src-4b819fa20a8d007a10f2d3e8d6a5dedf7f18fc9a.zip
Undo two previous imports which was never done in preparation of doing a
new import.
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=262616
Diffstat (limited to 'ncurses/base/lib_screen.c')
-rw-r--r--ncurses/base/lib_screen.c126
1 files changed, 40 insertions, 86 deletions
diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c
index 27212b790611..4aa58ea2a19c 100644
--- a/ncurses/base/lib_screen.c
+++ b/ncurses/base/lib_screen.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 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 *
@@ -30,45 +30,35 @@
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1996 on *
- * and: Juergen Pfeifer 2009 *
****************************************************************************/
#include <curses.priv.h>
-#ifndef CUR
-#define CUR SP_TERMTYPE
-#endif
-
-MODULE_ID("$Id: lib_screen.c,v 1.38 2009/10/24 22:08:55 tom Exp $")
+MODULE_ID("$Id: lib_screen.c,v 1.31 2008/08/16 19:05:37 tom Exp $")
#define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */
NCURSES_EXPORT(WINDOW *)
-NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
+getwin(FILE *filep)
{
WINDOW tmp, *nwin;
int n;
- T((T_CALLED("getwin(%p)"), (void *) filep));
+ T((T_CALLED("getwin(%p)"), filep));
clearerr(filep);
- if (fread(&tmp, 1, sizeof(WINDOW), filep) < sizeof(WINDOW)
- || ferror(filep)
+ (void) fread(&tmp, sizeof(WINDOW), 1, filep);
+ if (ferror(filep)
|| tmp._maxy == 0
|| tmp._maxy > MAX_SIZE
|| tmp._maxx == 0
- || tmp._maxx > MAX_SIZE) {
+ || tmp._maxx > MAX_SIZE)
returnWin(0);
- }
if (tmp._flags & _ISPAD) {
- nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx
- tmp._maxy + 1,
- tmp._maxx + 1);
+ nwin = newpad(tmp._maxy + 1, tmp._maxx + 1);
} else {
- nwin = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx
- tmp._maxy + 1,
- tmp._maxx + 1, 0, 0);
+ nwin = newwin(tmp._maxy + 1, tmp._maxx + 1, 0, 0);
}
/*
@@ -77,8 +67,6 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
* made sense is probably gone.
*/
if (nwin != 0) {
- size_t linesize = sizeof(NCURSES_CH_T) * (size_t) (tmp._maxx + 1);
-
nwin->_curx = tmp._curx;
nwin->_cury = tmp._cury;
nwin->_maxy = tmp._maxy;
@@ -110,8 +98,11 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
for (n = 0; n <= nwin->_maxy; n++) {
clearerr(filep);
- if (fread(nwin->_line[n].text, 1, linesize, filep) < linesize
- || ferror(filep)) {
+ (void) fread(nwin->_line[n].text,
+ sizeof(NCURSES_CH_T),
+ (size_t) (nwin->_maxx + 1),
+ filep);
+ if (ferror(filep)) {
delwin(nwin);
returnWin(0);
}
@@ -121,21 +112,13 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
returnWin(nwin);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(WINDOW *)
-getwin(FILE *filep)
-{
- return NCURSES_SP_NAME(getwin) (CURRENT_SCREEN, filep);
-}
-#endif
-
NCURSES_EXPORT(int)
putwin(WINDOW *win, FILE *filep)
{
int code = ERR;
int n;
- T((T_CALLED("putwin(%p,%p)"), (void *) win, (void *) filep));
+ T((T_CALLED("putwin(%p,%p)"), win, filep));
if (win != 0) {
size_t len = (size_t) (win->_maxx + 1);
@@ -158,34 +141,26 @@ putwin(WINDOW *win, FILE *filep)
}
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(scr_restore) (NCURSES_SP_DCLx const char *file)
+scr_restore(const char *file)
{
FILE *fp = 0;
- T((T_CALLED("scr_restore(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
+ T((T_CALLED("scr_restore(%s)"), _nc_visbuf(file)));
if (_nc_access(file, R_OK) < 0
|| (fp = fopen(file, "rb")) == 0) {
returnCode(ERR);
} else {
- delwin(NewScreen(SP_PARM));
- NewScreen(SP_PARM) = getwin(fp);
+ delwin(newscr);
+ SP->_newscr = getwin(fp);
#if !USE_REENTRANT
- newscr = NewScreen(SP_PARM);
+ newscr = SP->_newscr;
#endif
(void) fclose(fp);
returnCode(OK);
}
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-scr_restore(const char *file)
-{
- return NCURSES_SP_NAME(scr_restore) (CURRENT_SCREEN, file);
-}
-#endif
-
NCURSES_EXPORT(int)
scr_dump(const char *file)
{
@@ -204,63 +179,42 @@ scr_dump(const char *file)
}
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(scr_init) (NCURSES_SP_DCLx const char *file)
+scr_init(const char *file)
{
FILE *fp = 0;
- int code = ERR;
- T((T_CALLED("scr_init(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
+ T((T_CALLED("scr_init(%s)"), _nc_visbuf(file)));
- if (SP_PARM != 0 &&
-#ifdef USE_TERM_DRIVER
- InfoOf(SP_PARM).caninit
-#else
- !(exit_ca_mode && non_rev_rmcup)
-#endif
- ) {
- if (_nc_access(file, R_OK) >= 0
- && (fp = fopen(file, "rb")) != 0) {
- delwin(CurScreen(SP_PARM));
- CurScreen(SP_PARM) = getwin(fp);
+ if (exit_ca_mode && non_rev_rmcup)
+ returnCode(ERR);
+
+ if (_nc_access(file, R_OK) < 0
+ || (fp = fopen(file, "rb")) == 0) {
+ returnCode(ERR);
+ } else {
+ delwin(curscr);
+ SP->_curscr = getwin(fp);
#if !USE_REENTRANT
- curscr = CurScreen(SP_PARM);
+ curscr = SP->_curscr;
#endif
- (void) fclose(fp);
- code = OK;
- }
+ (void) fclose(fp);
+ returnCode(OK);
}
- returnCode(code);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-scr_init(const char *file)
-{
- return NCURSES_SP_NAME(scr_init) (CURRENT_SCREEN, file);
}
-#endif
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(scr_set) (NCURSES_SP_DCLx const char *file)
+scr_set(const char *file)
{
- T((T_CALLED("scr_set(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
+ T((T_CALLED("scr_set(%s)"), _nc_visbuf(file)));
- if (NCURSES_SP_NAME(scr_init) (NCURSES_SP_ARGx file) == ERR) {
+ if (scr_init(file) == ERR) {
returnCode(ERR);
} else {
- delwin(NewScreen(SP_PARM));
- NewScreen(SP_PARM) = dupwin(curscr);
+ delwin(newscr);
+ SP->_newscr = dupwin(curscr);
#if !USE_REENTRANT
- newscr = NewScreen(SP_PARM);
+ newscr = SP->_newscr;
#endif
returnCode(OK);
}
}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-scr_set(const char *file)
-{
- return NCURSES_SP_NAME(scr_set) (CURRENT_SCREEN, file);
-}
-#endif