summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libcurses++/cursesw.cc14
-rw-r--r--lib/libcurses++/cursesw.h118
-rw-r--r--lib/libcurses++/demo.cc12
-rw-r--r--lib/libcurses/curses.h4
-rw-r--r--lib/libcurses/tinfo/comp_scan.c167
-rw-r--r--lib/libcurses/tty/tty_update.c28
-rw-r--r--usr.bin/tic/tic.c8
7 files changed, 167 insertions, 184 deletions
diff --git a/lib/libcurses++/cursesw.cc b/lib/libcurses++/cursesw.cc
index baa7a373045..c23f8b578f8 100644
--- a/lib/libcurses++/cursesw.cc
+++ b/lib/libcurses++/cursesw.cc
@@ -25,7 +25,7 @@
#include "cursesw.h"
#include "internal.h"
-MODULE_ID("$From: cursesw.cc,v 1.17 2000/09/02 18:55:31 tom Exp $")
+MODULE_ID("$From: cursesw.cc,v 1.18 2001/01/28 01:17:41 tom Exp $")
#define COLORS_NEED_INITIALIZATION -1
#define COLORS_NOT_INITIALIZED 0
@@ -142,8 +142,7 @@ NCursesWindow::initialize() {
}
NCursesWindow::NCursesWindow() {
- if (!b_initialized)
- initialize();
+ initialize();
w = (WINDOW *)0;
init();
@@ -154,8 +153,7 @@ NCursesWindow::NCursesWindow() {
NCursesWindow::NCursesWindow(int lines, int cols, int begin_y, int begin_x)
{
- if (!b_initialized)
- initialize();
+ initialize();
w = ::newwin(lines, cols, begin_y, begin_x);
if (w == 0) {
@@ -170,8 +168,7 @@ NCursesWindow::NCursesWindow(int lines, int cols, int begin_y, int begin_x)
NCursesWindow::NCursesWindow(WINDOW* &window)
{
- if (!b_initialized)
- initialize();
+ initialize();
w = window;
init();
@@ -183,6 +180,7 @@ NCursesWindow::NCursesWindow(WINDOW* &window)
NCursesWindow::NCursesWindow(NCursesWindow& win, int l, int c,
int begin_y, int begin_x, char absrel)
{
+ initialize();
if (absrel == 'a') { // absolute origin
begin_y -= win.begy();
begin_x -= win.begx();
@@ -208,6 +206,7 @@ NCursesWindow::NCursesWindow(NCursesWindow& win, int l, int c,
NCursesWindow::NCursesWindow(NCursesWindow& win,
bool do_box NCURSES_PARAM_INIT(TRUE))
{
+ initialize();
w = :: derwin(win.w,win.height()-2,win.width()-2,1,1);
if (w == 0) {
err_handler("Cannot construct subwindow");
@@ -244,6 +243,7 @@ static RIPOFFINIT* prip = R_INIT;
extern "C" int _nc_ripoffline(int,int (*init)(WINDOW*,int));
NCursesWindow::NCursesWindow(WINDOW *win, int cols) {
+ initialize();
w = win;
assert((w->_maxx+1)==cols);
alloced = FALSE;
diff --git a/lib/libcurses++/cursesw.h b/lib/libcurses++/cursesw.h
index fab04b960e4..135bc835784 100644
--- a/lib/libcurses++/cursesw.h
+++ b/lib/libcurses++/cursesw.h
@@ -2,7 +2,7 @@
#ifndef _CURSESW_H
#define _CURSESW_H
-// $From: cursesw.h,v 1.20 2000/12/10 03:22:35 tom Exp $
+// $From: cursesw.h,v 1.21 2001/01/28 01:18:23 tom Exp $
#include <etip.h>
#include <stdio.h>
@@ -152,7 +152,7 @@ inline int UNDEF(erase)() { return erase(); }
#endif
#ifdef flushok
-inline int UNDEF(flushok)(WINDOW* _win, bool _bf) {
+inline int UNDEF(flushok)(WINDOW* _win, bool _bf) {
return flushok(_win, _bf); }
#undef flushok
#define flushok UNDEF(flushok)
@@ -185,49 +185,49 @@ inline int UNDEF(innstr)(char *_str, int n) { return innstr(_str,n); }
#endif
#ifdef mvwinnstr
-inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) {
+inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) {
return mvwinnstr(win,y,x,_str,n); }
#undef mvwinnstr
#define mvwinnstr UNDEF(mvwinnstr)
#endif
#ifdef mvinnstr
-inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) {
+inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) {
return mvinnstr(y,x,_str,n); }
#undef mvinnstr
#define mvinnstr UNDEF(mvinnstr)
#endif
#ifdef winsstr
-inline int UNDEF(winsstr)(WINDOW *w, const char *_str) {
+inline int UNDEF(winsstr)(WINDOW *w, const char *_str) {
return winsstr(w,_str); }
#undef winsstr
#define winsstr UNDEF(winsstr)
#endif
#ifdef mvwinsstr
-inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) {
+inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) {
return mvwinsstr(w,y,x,_str); }
#undef mvwinsstr
#define mvwinsstr UNDEF(mvwinsstr)
#endif
#ifdef insstr
-inline int UNDEF(insstr)(const char *_str) {
+inline int UNDEF(insstr)(const char *_str) {
return insstr(_str); }
#undef insstr
#define insstr UNDEF(insstr)
#endif
#ifdef mvinsstr
-inline int UNDEF(mvinsstr)(int y, int x,const char *_str) {
+inline int UNDEF(mvinsstr)(int y, int x,const char *_str) {
return mvinsstr(y,x,_str); }
#undef mvinsstr
#define mvinsstr UNDEF(mvinsstr)
#endif
#ifdef insnstr
-inline int UNDEF(insnstr)(const char *_str, int n) {
+inline int UNDEF(insnstr)(const char *_str, int n) {
return insnstr(_str,n); }
#undef insnstr
#define insnstr UNDEF(insnstr)
@@ -254,7 +254,7 @@ inline int UNDEF(getnstr)(char *_str, int n) { return getnstr(_str,n); }
#endif
#ifdef getyx
-inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) {
+inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) {
getyx(win, y, x); }
#undef getyx
#define getyx UNDEF(getyx)
@@ -365,7 +365,7 @@ inline int UNDEF(standout)() { return standout(); }
#endif
#ifdef subpad
-inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x)
+inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x)
{ return derwin(p,l,c,y,x); }
#undef subpad
#define subpad UNDEF(subpad)
@@ -434,7 +434,7 @@ inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); }
#endif
#ifdef chgat
-inline int UNDEF(chgat)(int n,attr_t attr, short color, const void *opts) {
+inline int UNDEF(chgat)(int n,attr_t attr, short color, const void *opts) {
return chgat(n,attr,color,opts); }
#undef chgat
#define chgat UNDEF(chgat)
@@ -442,7 +442,7 @@ inline int UNDEF(chgat)(int n,attr_t attr, short color, const void *opts) {
#ifdef mvchgat
inline int UNDEF(mvchgat)(int y, int x, int n,
- attr_t attr, short color, const void *opts) {
+ attr_t attr, short color, const void *opts) {
return mvchgat(y,x,n,attr,color,opts); }
#undef mvchgat
#define mvchgat UNDEF(mvchgat)
@@ -450,7 +450,7 @@ inline int UNDEF(mvchgat)(int y, int x, int n,
#ifdef mvwchgat
inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n,
- attr_t attr, short color, const void *opts) {
+ attr_t attr, short color, const void *opts) {
return mvwchgat(win,y,x,n,attr,color,opts); }
#undef mvwchgat
#define mvwchgat UNDEF(mvwchgat)
@@ -538,7 +538,7 @@ inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n)
#endif
#ifdef mvwinch
-inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
+inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
return mvwinch(win, y, x);}
#undef mvwinch
#define mvwinch UNDEF(mvwinch)
@@ -675,14 +675,14 @@ class NCURSES_IMPEXP NCursesWindow
{
friend class NCursesMenu;
friend class NCursesForm;
-
+
private:
static bool b_initialized;
static void initialize();
static int ripoff_init(WINDOW *,int);
- void init();
-
+ void init();
+
short getcolor(int getback) const;
static int setpalette(short fore, short back, short pair);
@@ -700,15 +700,15 @@ protected:
// We rely on the c++ promise that
// all otherwise uninitialized
// static class vars are set to 0
-
+
WINDOW* w; // the curses WINDOW
-
+
bool alloced; // TRUE if we own the WINDOW
-
+
NCursesWindow* par; // parent, if subwindow
NCursesWindow* subwins; // head of subwindows list
NCursesWindow* sib; // next subwindow of parent
-
+
void kill_subwindows(); // disable all subwindows
// Destroy all subwindows.
@@ -718,12 +718,12 @@ protected:
public:
NCursesWindow(WINDOW* &window); // useful only for stdscr
-
+
NCursesWindow(int lines, // number of lines
int cols, // number of columns
int begin_y, // line origin
int begin_x); // col origin
-
+
NCursesWindow(NCursesWindow& par,// parent window
int lines, // number of lines
int cols, // number of columns
@@ -751,9 +751,9 @@ public:
int (*init)(NCursesWindow& win));
// This function is used to generate a window of ripped-of lines.
// If the argument is positive, lines are removed from the top, if it
- // is negative lines are removed from the bottom. This enhances the
- // lowlevel ripoffline() function because it uses the internal
- // implementation that allows to remove more than just a single line.
+ // is negative lines are removed from the bottom. This enhances the
+ // lowlevel ripoffline() function because it uses the internal
+ // implementation that allows to remove more than just a single line.
// This function must be called before any other ncurses function. The
// creation of the window is defered until ncurses gets initialized.
// The initialization function is then called.
@@ -761,13 +761,13 @@ public:
// -------------------------------------------------------------------------
// terminal status
// -------------------------------------------------------------------------
- int lines() const { return LINES; }
+ int lines() const { initialize(); return LINES; }
// Number of lines on terminal, *not* window
- int cols() const { return COLS; }
+ int cols() const { initialize(); return COLS; }
// Number of cols on terminal, *not* window
- int tabsize() const { return TABSIZE; }
+ int tabsize() const { initialize(); return TABSIZE; }
// Size of a tab on terminal, *not* window
static int NumberOfColors();
@@ -775,7 +775,7 @@ public:
int colors() const { return NumberOfColors(); }
// Number of available colors
-
+
// -------------------------------------------------------------------------
// window status
// -------------------------------------------------------------------------
@@ -811,7 +811,7 @@ public:
int setcolor(short pair);
// Set actually used palette entry
-
+
// -------------------------------------------------------------------------
// window positioning
// -------------------------------------------------------------------------
@@ -827,12 +827,12 @@ public:
// Move cursor the this position
void getyx(int& y, int& x) const { ::getyx(w, y, x); }
- // Get current position of the cursor
+ // Get current position of the cursor
- int mvcur(int oldrow, int oldcol, int newrow, int newcol) const {
+ int mvcur(int oldrow, int oldcol, int newrow, int newcol) const {
return ::mvcur(oldrow, oldcol, newrow, newcol); }
// Perform lowlevel cursor motion that takes effect immediately.
-
+
// -------------------------------------------------------------------------
// input
// -------------------------------------------------------------------------
@@ -842,13 +842,13 @@ public:
int getch(int y, int x) { return ::mvwgetch(w,y,x); }
// Move cursor to position and get a keystroke from the window
- int getstr(char* str, int n=-1) {
+ int getstr(char* str, int n=-1) {
return ::wgetnstr(w, str,n); }
// Read a series of characters into str until a newline or carriage return
// is received. Read at most n characters. If n is negative, the limit is
// ignored.
- int getstr(int y, int x, char* str, int n=-1) {
+ int getstr(int y, int x, char* str, int n=-1) {
return ::mvwgetnstr(w,y,x,str,n); }
// Move the cursor to the requested position and then perform the getstr()
// as described above.
@@ -880,12 +880,12 @@ public:
#else
;
#endif
-
+
// -------------------------------------------------------------------------
// output
// -------------------------------------------------------------------------
int addch(const chtype ch) { return ::waddch(w, ch); }
- // Put attributed character to the window.
+ // Put attributed character to the window.
int addch(int y, int x, const chtype ch) {
return ::mvwaddch(w,y,x,ch); }
@@ -895,10 +895,10 @@ public:
int echochar(const chtype ch) { return ::wechochar(w,ch); }
// Put attributed character to the window and refresh it immediately.
- int addstr(const char* str, int n=-1) {
+ int addstr(const char* str, int n=-1) {
return ::waddnstr(w, (char*)str,n); }
// Write the string str to the window, stop writing if the terminating
- // NUL or the limit n is reached. If n is negative, it is ignored.
+ // NUL or the limit n is reached. If n is negative, it is ignored.
int addstr(int y, int x, const char * str, int n=-1) {
return ::mvwaddnstr(w,y,x,(char*)str,n); }
@@ -939,7 +939,7 @@ public:
int insertln() { return ::winsdelln(w,1); }
// Insert an empty line above the current line.
-
+
int insdelln(int n=1) { return ::winsdelln(w,n); }
// If n>0 insert that many lines above the current line. If n<0 delete
// that many lines beginning with the current line.
@@ -949,7 +949,7 @@ public:
// Insert the string into the window before the current cursor position.
// Insert stops at end of string or when the limit n is reached. If n is
// negative, it is ignored.
-
+
int insstr(int y, int x, const char *s, int n=-1) {
return ::mvwinsnstr(w,y,x,s,n); }
// Move the cursor to the requested position and then perform the insstr()
@@ -957,7 +957,7 @@ public:
int attron (chtype at) { return ::wattron (w, at); }
// Switch on the window attributes;
-
+
int attroff(chtype at) { return ::wattroff(w, (int) at); }
// Switch off the window attributes;
@@ -995,7 +995,7 @@ public:
// -------------------------------------------------------------------------
// borders
// -------------------------------------------------------------------------
- int box(chtype vert=0, chtype hor=0) {
+ int box(chtype vert=0, chtype hor=0) {
return ::wborder(w, vert, vert, hor, hor, 0, 0 ,0, 0); }
// Draw a box around the window with the given vertical and horizontal
// drawing characters. If you specifiy a zero as character, curses will try
@@ -1016,7 +1016,7 @@ public:
// -------------------------------------------------------------------------
int hline(int len, chtype ch=0) { return ::whline(w, ch, len); }
// Draw a horizontal line of len characters with the given character. If
- // you pass zero for the character, curses will try to find a "nice" one.
+ // you pass zero for the character, curses will try to find a "nice" one.
int hline(int y, int x, int len, chtype ch=0) {
return ::mvwhline(w,y,x,ch,len); }
@@ -1029,7 +1029,7 @@ public:
int vline(int y, int x, int len, chtype ch=0) {
return ::mvwvline(w,y,x,ch,len); }
// Move the cursor to the requested position and then draw a vertical line.
-
+
// -------------------------------------------------------------------------
// erasure
// -------------------------------------------------------------------------
@@ -1050,7 +1050,7 @@ public:
// Clear to the end of the line.
int delch() { return ::wdelch(w); }
- // Delete character under the cursor.
+ // Delete character under the cursor.
int delch(int y, int x) { return ::mvwdelch(w,y,x); }
// Move cursor to requested position and delete the character under the
@@ -1090,18 +1090,18 @@ public:
int untouchwin() { return ::wtouchln(w,0,height(),0); }
// Mark the whole window as unmodified.
- int touchln(int s, int cnt, bool changed=TRUE) {
+ int touchln(int s, int cnt, bool changed=TRUE) {
return ::wtouchln(w,s,cnt,(int)(changed?1:0)); }
// Mark cnt lines beginning from line s as changed or unchanged, depending
// on the value of the changed flag.
- bool is_linetouched(int line) const {
+ bool is_linetouched(int line) const {
return (::is_linetouched(w,line) ? TRUE:FALSE); }
- // Return TRUE if line is marked as changed, FALSE otherwise
+ // Return TRUE if line is marked as changed, FALSE otherwise
- bool is_wintouched() const {
+ bool is_wintouched() const {
return (::is_wintouched(w) ? TRUE:FALSE); }
- // Return TRUE if window is marked as changed, FALSE otherwise
+ // Return TRUE if window is marked as changed, FALSE otherwise
int leaveok(bool bf) { return ::leaveok(w, bf); }
// If bf is TRUE, curses will leave the cursor after an update whereever
@@ -1141,7 +1141,7 @@ public:
int meta(bool bf) { return ::meta(w,bf); }
// If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise
- // 7-Bit characters are generated.
+ // 7-Bit characters are generated.
int standout() { return ::wstandout(w); }
// Enable "standout" attributes
@@ -1158,9 +1158,9 @@ public:
// doupdate(). This is redefined in NCursesPanel.
virtual int noutrefresh() { return ::wnoutrefresh(w); }
- // Propagate the changes in this window to the virtual screen. This is
+ // Propagate the changes in this window to the virtual screen. This is
// redefined in NCursesPanel.
-
+
// -------------------------------------------------------------------------
// multiple window control
// -------------------------------------------------------------------------
@@ -1228,8 +1228,8 @@ public:
char absrel = 'a') // if `a', by & bx are
: NCursesWindow(par,lines,cols, // absolute screen pos,
begin_y,begin_x, // else if `r', they are
- absrel ) { // relative to par origin
- useColors(); }
+ absrel ) { // relative to par origin
+ useColors(); }
};
// These enum definitions really belong inside the NCursesPad class, but only
@@ -1301,7 +1301,7 @@ public:
int echochar(const chtype ch) { return ::pechochar(w,ch); }
// Put the attributed character onto the pad and immediately do a
// prefresh().
-
+
int refresh();
// If a viewport is defined the pad is displayed in this window, otherwise
// this is a noop.
diff --git a/lib/libcurses++/demo.cc b/lib/libcurses++/demo.cc
index f08cbe9a874..d09b718b0a8 100644
--- a/lib/libcurses++/demo.cc
+++ b/lib/libcurses++/demo.cc
@@ -6,7 +6,7 @@
* Demo code for NCursesMenu and NCursesForm written by
* Juergen Pfeifer <juergen.pfeifer@gmx.net>
*
- * $From: demo.cc,v 1.19 2000/12/09 23:46:12 tom Exp $
+ * $From: demo.cc,v 1.20 2001/01/28 02:26:27 tom Exp $
*/
#include "cursesapp.h"
@@ -446,12 +446,4 @@ int TestApplication::run() {
//
// -------------------------------------------------------------------------
//
-// static TestApplication Demo;
-
-int main()
-{
- TestApplication * Demo = new TestApplication();
- Demo->run();
- return 0;
-}
-
+static TestApplication Demo;
diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h
index cd125521da8..275d36a9b36 100644
--- a/lib/libcurses/curses.h
+++ b/lib/libcurses/curses.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: curses.h,v 1.57 2001/01/22 18:01:33 millert Exp $ */
+/* $OpenBSD: curses.h,v 1.58 2001/02/22 04:16:34 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -50,7 +50,7 @@
/* These are defined only in curses.h, and are used for conditional compiles */
#define NCURSES_VERSION_MAJOR 5
#define NCURSES_VERSION_MINOR 2
-#define NCURSES_VERSION_PATCH 20010114
+#define NCURSES_VERSION_PATCH 20010210
/* This is defined in more than one ncurses header, for identification */
#undef NCURSES_VERSION
diff --git a/lib/libcurses/tinfo/comp_scan.c b/lib/libcurses/tinfo/comp_scan.c
index 65d9a248a23..f757493654f 100644
--- a/lib/libcurses/tinfo/comp_scan.c
+++ b/lib/libcurses/tinfo/comp_scan.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000,2001 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 *
@@ -50,7 +50,7 @@
#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$From: comp_scan.c,v 1.52 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$From: comp_scan.c,v 1.54 2001/02/04 01:09:26 tom Exp $")
/*
* Maximum length of string capability we'll accept before raising an error.
@@ -89,18 +89,19 @@ static int pushtype; /* type of pushback token */
static char pushname[MAX_NAME_SIZE + 1];
#if NCURSES_EXT_FUNCS
-NCURSES_EXPORT_VAR(bool) _nc_disable_period = FALSE; /* used by tic -a option */
+NCURSES_EXPORT_VAR(bool)
+_nc_disable_period = FALSE; /* used by tic -a option */
#endif
- static int last_char(void);
- static int next_char(void);
- static long stream_pos(void);
- static bool end_of_stream(void);
- static void push_back(char c);
+static int last_char(void);
+static int next_char(void);
+static long stream_pos(void);
+static bool end_of_stream(void);
+static void push_back(char c);
/* Assume we may be looking at a termcap-style continuation */
- static inline int
- eat_escaped_newline(int ch)
+static inline int
+eat_escaped_newline(int ch)
{
if (ch == '\\')
while ((ch = next_char()) == '\n' || iswhite(ch))
@@ -238,13 +239,11 @@ _nc_get_token(void)
_nc_syntax = SYN_TERMINFO;
separator = ',';
/*
- * Fall-through here is not an accident.
- * The idea is that if we see a comma, we
- * figure this is terminfo unless we
- * subsequently run into a colon -- but
- * we don't stop looking for that colon until
- * hitting a newline. This allows commas to
- * be embedded in description fields of
+ * Fall-through here is not an accident. The idea is that
+ * if we see a comma, we figure this is terminfo unless we
+ * subsequently run into a colon -- but we don't stop
+ * looking for that colon until hitting a newline. This
+ * allows commas to be embedded in description fields of
* either syntax.
*/
/* FALLTHRU */
@@ -256,11 +255,10 @@ _nc_get_token(void)
ptr[0] = '\0';
if (_nc_syntax == ERR) {
/*
- * Grrr...what we ought to do here is barf,
- * complaining that the entry is malformed.
- * But because a couple of name fields in the
- * 8.2 termcap file end with |\, we just have
- * to assume it's termcap syntax.
+ * Grrr...what we ought to do here is barf, complaining that
+ * the entry is malformed. But because a couple of name fields
+ * in the 8.2 termcap file end with |\, we just have to assume
+ * it's termcap syntax.
*/
_nc_syntax = SYN_TERMCAP;
separator = ':';
@@ -272,8 +270,8 @@ _nc_get_token(void)
}
/*
- * This is the soonest we have the terminal name
- * fetched. Set up for following warning messages.
+ * This is the soonest we have the terminal name fetched. Set up
+ * for following warning messages.
*/
ptr = strchr(buffer, '|');
if (ptr == (char *) NULL)
@@ -284,8 +282,8 @@ _nc_get_token(void)
*ptr = ch;
/*
- * Compute the boundary between the aliases and the
- * description field for syntax-checking purposes.
+ * Compute the boundary between the aliases and the description
+ * field for syntax-checking purposes.
*/
desc = strrchr(buffer, '|');
if (desc) {
@@ -300,10 +298,9 @@ _nc_get_token(void)
desc = buffer + strlen(buffer);
/*
- * Whitespace in a name field other than the long name
- * can confuse rdist and some termcap tools. Slashes
- * are a no-no. Other special characters can be
- * dangerous due to shell expansion.
+ * Whitespace in a name field other than the long name can confuse
+ * rdist and some termcap tools. Slashes are a no-no. Other
+ * special characters can be dangerous due to shell expansion.
*/
for (ptr = buffer; ptr < desc; ptr++) {
if (isspace(CharOf(*ptr))) {
@@ -440,7 +437,10 @@ _nc_get_token(void)
if (dot_flag == TRUE) /* if commented out, use the next one */
type = _nc_get_token();
- DEBUG(3, ("token: `%s', class %d", _nc_curr_token.tk_name, type));
+ DEBUG(3, ("token: `%s', class %d",
+ _nc_curr_token.tk_name != 0 ? _nc_curr_token.tk_name :
+ "<null>",
+ type));
return (type);
}
@@ -622,10 +622,10 @@ NCURSES_EXPORT(void)
_nc_push_token(int tokclass)
{
/*
- * This implementation is kind of bogus, it will fail if we ever do
- * more than one pushback at a time between get_token() calls. It
- * relies on the fact that curr_tok is static storage that nothing
- * but get_token() touches.
+ * This implementation is kind of bogus, it will fail if we ever do more
+ * than one pushback at a time between get_token() calls. It relies on the
+ * fact that curr_tok is static storage that nothing but get_token()
+ * touches.
*/
pushtype = tokclass;
_nc_get_type(pushname);
@@ -718,6 +718,10 @@ static int
next_char(void)
{
if (!yyin) {
+ /*
+ * An string with an embedded null will truncate the input. This is
+ * intentional (we don't read binary files here).
+ */
if (*bufptr == '\0')
return (EOF);
if (*bufptr == '\n') {
@@ -726,52 +730,61 @@ next_char(void)
}
} else if (!bufptr || !*bufptr) {
/*
- * In theory this could be recoded to do its I/O one
- * character at a time, saving the buffer space. In
- * practice, this turns out to be quite hard to get
- * completely right. Try it and see. If you succeed,
- * don't forget to hack push_back() correspondingly.
+ * In theory this could be recoded to do its I/O one character at a
+ * time, saving the buffer space. In practice, this turns out to be
+ * quite hard to get completely right. Try it and see. If you
+ * succeed, don't forget to hack push_back() correspondingly.
*/
- static char line[LEXBUFSIZ];
+ static char *result;
+ static size_t allocated;
+ size_t used;
size_t len;
do {
- _nc_curr_file_pos = ftell(yyin);
-
- if ((bufstart = fgets(line, LEXBUFSIZ, yyin)) != NULL) {
- _nc_curr_line++;
- _nc_curr_col = 0;
- }
- bufptr = bufstart;
- } while
- (bufstart != NULL && line[0] == '#');
-
- if (bufstart == NULL || *bufstart == 0)
- return (EOF);
-
- while (iswhite(*bufptr))
- bufptr++;
-
- /*
- * Treat a trailing <cr><lf> the same as a <newline> so we can read
- * files on OS/2, etc.
- */
- if ((len = strlen(bufptr)) > 1) {
- if (bufptr[len - 1] == '\n'
- && bufptr[len - 2] == '\r') {
- len--;
- bufptr[len - 1] = '\n';
- bufptr[len] = '\0';
- }
- }
+ bufstart = 0;
+ used = 0;
+ do {
+ if (used + (LEXBUFSIZ / 4) >= allocated) {
+ allocated += (allocated + LEXBUFSIZ);
+ result = _nc_doalloc(result, allocated);
+ if (result == 0)
+ return (EOF);
+ }
+ if (used == 0)
+ _nc_curr_file_pos = ftell(yyin);
+
+ if (fgets(result + used, allocated - used, yyin) != NULL) {
+ bufstart = result;
+ if (used == 0) {
+ _nc_curr_line++;
+ _nc_curr_col = 0;
+ }
+ } else {
+ if (used != 0)
+ strcat(result, "\n");
+ }
+ if ((bufptr = bufstart) != 0) {
+ used = strlen(bufptr);
+ while (iswhite(*bufptr))
+ bufptr++;
- /*
- * If we don't have a trailing newline, it's because the line is simply
- * too long. Give up. (FIXME: We could instead reallocate the line
- * buffer and allow arbitrary-length lines).
- */
- if (len == 0 || (bufptr[len - 1] != '\n'))
- return (EOF);
+ /*
+ * Treat a trailing <cr><lf> the same as a <newline> so we
+ * can read files on OS/2, etc.
+ */
+ if ((len = strlen(bufptr)) > 1) {
+ if (bufptr[len - 1] == '\n'
+ && bufptr[len - 2] == '\r') {
+ len--;
+ bufptr[len - 1] = '\n';
+ bufptr[len] = '\0';
+ }
+ }
+ } else {
+ return (EOF);
+ }
+ } while (bufptr[len - 1] != '\n'); /* complete a line */
+ } while (result[0] == '#'); /* ignore comments */
}
first_column = (bufptr == bufstart);
@@ -803,5 +816,3 @@ end_of_stream(void)
return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
? TRUE : FALSE);
}
-
-/* comp_scan.c ends here */
diff --git a/lib/libcurses/tty/tty_update.c b/lib/libcurses/tty/tty_update.c
index 194bc4343d9..28b6b99927e 100644
--- a/lib/libcurses/tty/tty_update.c
+++ b/lib/libcurses/tty/tty_update.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: tty_update.c,v 1.14 2001/01/22 18:02:01 millert Exp $ */
+/* $OpenBSD: tty_update.c,v 1.15 2001/02/22 04:16:35 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000,2001 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 *
@@ -72,7 +72,7 @@
#include <term.h>
-MODULE_ID("$From: tty_update.c,v 1.150 2001/01/14 00:16:22 tom Exp $")
+MODULE_ID("$From: tty_update.c,v 1.151 2001/02/03 23:41:55 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -279,18 +279,6 @@ check_pending(void)
return FALSE;
}
-/*
- * No one supports recursive inline functions. However, gcc is quieter if we
- * instantiate the recursive part separately.
- */
-#if CC_HAS_INLINE_FUNCS
-static void callPutChar(chtype const);
-#else
-#define callPutChar(ch) PutChar(ch)
-#endif
-
-static inline void PutChar(chtype const ch); /* forward declaration */
-
/* put char at lower right corner */
static void
PutCharLR(chtype const ch)
@@ -312,7 +300,7 @@ PutCharLR(chtype const ch)
} else if ((enter_insert_mode && exit_insert_mode)
|| insert_character || parm_ich) {
GoTo(screen_lines - 1, screen_columns - 2);
- callPutChar(ch);
+ PutAttrChar(ch);
GoTo(screen_lines - 1, screen_columns - 2);
InsStr(newscr->_line[screen_lines - 1].text + screen_columns - 2, 1);
}
@@ -513,14 +501,6 @@ PutRange(
return EmitRange(ntext + first, last - first + 1);
}
-#if CC_HAS_INLINE_FUNCS
-static void
-callPutChar(chtype const ch)
-{
- PutChar(ch);
-}
-#endif
-
/* leave unbracketed here so 'indent' works */
#define MARK_NOCHANGE(win,row) \
win->_line[row].firstchar = _NOCHANGE; \
diff --git a/usr.bin/tic/tic.c b/usr.bin/tic/tic.c
index 13f5f9aad8a..ba5b9164607 100644
--- a/usr.bin/tic/tic.c
+++ b/usr.bin/tic/tic.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: tic.c,v 1.24 2001/01/29 01:58:23 niklas Exp $ */
+/* $OpenBSD: tic.c,v 1.25 2001/02/22 04:16:36 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000,2001 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 *
@@ -46,7 +46,7 @@
#include <term_entry.h>
#include <transform.h>
-MODULE_ID("$From: tic.c,v 1.84 2000/11/04 22:50:16 tom Exp $")
+MODULE_ID("$From: tic.c,v 1.85 2001/02/03 23:31:45 tom Exp $")
const char *_nc_progname = "tic";
@@ -707,7 +707,7 @@ main(int argc, char *argv[])
printf("# length=%d\n", len);
}
}
- if (!namelst) {
+ if (!namelst && _nc_tail) {
int c, oldc = '\0';
bool in_comment = FALSE;
bool trailing_comment = FALSE;