commit bash-20110401 snapshot

This commit is contained in:
Chet Ramey
2011-12-29 13:06:12 -05:00
parent c1854f2dd6
commit af32e54dd7
19 changed files with 1838 additions and 1271 deletions
+23 -2
View File
@@ -41,6 +41,10 @@
#include <stdio.h>
#ifdef __MSDOS__
# include <pc.h>
#endif
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
@@ -2057,9 +2061,18 @@ _rl_move_vert (to)
}
else
{ /* delta < 0 */
#ifdef __DJGPP__
int row, col;
fflush (rl_outstream);
ScreenGetCursor (&row, &col);
ScreenSetCursor (row + delta, col);
i = -delta;
#else
if (_rl_term_up && *_rl_term_up)
for (i = 0; i < -delta; i++)
tputs (_rl_term_up, 1, _rl_output_character_function);
#endif /* !__DJGPP__ */
}
_rl_last_v_pos = to; /* Now TO is here */
@@ -2342,10 +2355,13 @@ void
_rl_clear_to_eol (count)
int count;
{
#ifndef __MSDOS__
if (_rl_term_clreol)
tputs (_rl_term_clreol, 1, _rl_output_character_function);
else if (count)
space_to_eol (count);
else
#endif
if (count)
space_to_eol (count);
}
/* Clear to the end of the line using spaces. COUNT is the minimum
@@ -2365,10 +2381,15 @@ space_to_eol (count)
void
_rl_clear_screen ()
{
#ifndef __DJGPP__
if (_rl_term_clrpag)
tputs (_rl_term_clrpag, 1, _rl_output_character_function);
else
rl_crlf ();
#else
ScreenClear ();
ScreenSetCursor (0, 0);
#endif /* __DJGPP__ */
}
/* Insert COUNT characters from STRING to the output stream at column COL. */
+28 -4
View File
@@ -176,7 +176,8 @@ int _rl_vis_botlin = 0;
static int last_lmargin;
/* A buffer for `modeline' messages. */
static char msg_buf[128];
static char *msg_buf = 0;
static int msg_bufsiz = 0;
/* Non-zero forces the redisplay even if we thought it was unnecessary. */
static int forced_display;
@@ -2136,6 +2137,9 @@ rl_message (va_alist)
#if defined (PREFER_VARARGS)
char *format;
#endif
#if defined (HAVE_VSNPRINTF)
int bneed;
#endif
#if defined (PREFER_STDARG)
va_start (args, format);
@@ -2144,11 +2148,28 @@ rl_message (va_alist)
format = va_arg (args, char *);
#endif
if (msg_buf == 0)
msg_buf = xmalloc (msg_bufsiz = 128);
#if defined (HAVE_VSNPRINTF)
vsnprintf (msg_buf, sizeof (msg_buf) - 1, format, args);
bneed = vsnprintf (msg_buf, msg_bufsiz - 1, format, args);
if (bneed >= msg_bufsiz - 1)
{
msg_bufsiz = bneed + 1;
msg_buf = xrealloc (msg_buf, msg_bufsiz);
va_end (args);
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
format = va_arg (args, char *);
#endif
vsnprintf (msg_buf, msg_bufsiz - 1, format, args);
}
#else
vsprintf (msg_buf, format, args);
msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
msg_buf[msg_bufsiz - 1] = '\0'; /* overflow? */
#endif
va_end (args);
@@ -2173,8 +2194,11 @@ int
rl_message (format, arg1, arg2)
char *format;
{
if (msg_buf == 0)
msg_buf = xmalloc (msg_bufsiz = 128);
sprintf (msg_buf, format, arg1, arg2);
msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
msg_buf[msg_bufsiz - 1] = '\0'; /* overflow? */
rl_display_prompt = msg_buf;
if (saved_local_prompt == 0)
+41 -4
View File
@@ -55,6 +55,10 @@
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
#ifdef __MSDOS__
# include <pc.h>
#endif
#include "rltty.h"
#include "tcap.h"
@@ -91,8 +95,10 @@ int rl_prefer_env_winsize = 0;
/* */
/* **************************************************************** */
#ifndef __MSDOS__
static char *term_buffer = (char *)NULL;
static char *term_string_buffer = (char *)NULL;
#endif
static int tcap_initialized;
@@ -264,7 +270,10 @@ _rl_get_screen_size (tty, ignore_env)
if (_rl_screenwidth <= 0)
_rl_screenwidth = wc;
#if !defined (__DJGPP__)
#if defined (__DJGPP__)
if (_rl_screenwidth <= 0)
_rl_screenwidth = ScreenCols ();
#else
if (_rl_screenwidth <= 0 && term_string_buffer)
_rl_screenwidth = tgetnum ("co");
#endif
@@ -280,7 +289,10 @@ _rl_get_screen_size (tty, ignore_env)
if (_rl_screenheight <= 0)
_rl_screenheight = wr;
#if !defined (__DJGPP__)
#if defined (__DJGPP__)
if (_rl_screenheight <= 0)
_rl_screenheight = ScreenRows ();
#else
if (_rl_screenheight <= 0 && term_string_buffer)
_rl_screenheight = tgetnum ("li");
#endif
@@ -296,8 +308,7 @@ _rl_get_screen_size (tty, ignore_env)
/* If we're being compiled as part of bash, set the environment
variables $LINES and $COLUMNS to new values. Otherwise, just
do a pair of putenv () or setenv () calls. */
if (ignore_env == 0)
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
if (_rl_term_autowrap == 0)
_rl_screenwidth--;
@@ -439,6 +450,23 @@ _rl_init_terminal_io (terminal_name)
if (term == 0)
term = "dumb";
#ifdef __MSDOS__
_rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
_rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
_rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
_rl_term_mm = _rl_term_mo = (char *)NULL;
_rl_terminal_can_insert = term_has_meta = _rl_term_autowrap = 0;
_rl_term_cr = "\r";
_rl_term_clreol = _rl_term_clrpag = _rl_term_backspace = (char *)NULL;
_rl_term_goto = _rl_term_pc = _rl_term_ip = (char *)NULL;
_rl_term_ks = _rl_term_ke =_rl_term_vs = _rl_term_ve = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL;
#if defined(HACK_TERMCAP_MOTION)
_rl_term_forward_char = (char *)NULL;
#endif
_rl_get_screen_size (tty, 0);
#else /* !__MSDOS__ */
/* I've separated this out for later work on not calling tgetent at all
if the calling application has supplied a custom redisplay function,
(and possibly if the application has supplied a custom input function). */
@@ -538,6 +566,7 @@ _rl_init_terminal_io (terminal_name)
term_has_meta = tgetflag ("km") != 0;
if (term_has_meta == 0)
_rl_term_mm = _rl_term_mo = (char *)NULL;
#endif /* !__MSDOS__ */
/* Attempt to find and bind the arrow keys. Do not override already
bound keys in an overzealous attempt, however. */
@@ -635,10 +664,12 @@ _rl_backspace (count)
{
register int i;
#ifndef __MSDOS__
if (_rl_term_backspace)
for (i = 0; i < count; i++)
tputs (_rl_term_backspace, 1, _rl_output_character_function);
else
#endif
for (i = 0; i < count; i++)
putc ('\b', _rl_out_stream);
return 0;
@@ -670,7 +701,11 @@ rl_ding ()
case VISIBLE_BELL:
if (_rl_visible_bell)
{
#ifdef __DJGPP__
ScreenVisualBell ();
#else
tputs (_rl_visible_bell, 1, _rl_output_character_function);
#endif
break;
}
/* FALLTHROUGH */
@@ -725,6 +760,7 @@ void
_rl_set_cursor (im, force)
int im, force;
{
#ifndef __MSDOS__
if (_rl_term_ve && _rl_term_vs)
{
if (force || im != rl_insert_mode)
@@ -735,4 +771,5 @@ _rl_set_cursor (im, force)
tputs (_rl_term_ve, 1, _rl_output_character_function);
}
}
#endif
}
+1 -3
View File
@@ -296,8 +296,7 @@ _rl_get_screen_size (tty, ignore_env)
/* If we're being compiled as part of bash, set the environment
variables $LINES and $COLUMNS to new values. Otherwise, just
do a pair of putenv () or setenv () calls. */
if (ignore_env == 0)
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
if (_rl_term_autowrap == 0)
_rl_screenwidth--;
@@ -367,7 +366,6 @@ rl_resize_terminal ()
}
}
struct _tc_string {
const char * const tc_var;
char **tc_value;
+31 -38
View File
@@ -303,11 +303,30 @@ static void dfallback __P((struct DATA *, const char *, const char *, double));
static char *groupnum __P((char *));
#ifndef HAVE_ISINF_IN_LIBC
static int isinf __P((double));
#if defined (HAVE_LONG_DOUBLE)
# define LONGDOUBLE long double
#else
# define LONGDOUBLE double
#endif
#ifndef HAVE_ISNAN_IN_LIBC
static int isnan __P((double));
#ifndef isnan
static inline int isnan_f (float x) { return x != x; }
static inline int isnan_d (double x) { return x != x; }
static inline int isnan_ld (LONGDOUBLE x) { return x != x; }
# define isnan(x) \
(sizeof (x) == sizeof (LONGDOUBLE) ? isnan_ld (x) \
: sizeof (x) == sizeof (double) ? isnan_d (x) \
: isnan_f (x))
#endif
#ifndef isinf
static inline int isinf_f (float x) { return !isnan (x) && isnan (x - x); }
static inline int isinf_d (double x) { return !isnan (x) && isnan (x - x); }
static inline int isinf_ld (LONGDOUBLE x) { return !isnan (x) && isnan (x - x); }
# define isinf(x) \
(sizeof (x) == sizeof (LONGDOUBLE) ? isinf_ld (x) \
: sizeof (x) == sizeof (double) ? isinf_d (x) \
: isinf_f (x))
#endif
#ifdef DRIVER
@@ -431,9 +450,9 @@ static void xfree __P((void *));
if (lv) \
{ \
if (lv->decimal_point && lv->decimal_point[0]) \
(d) = lv->decimal_point[0]; \
(d) = lv->decimal_point[0]; \
if (lv->thousands_sep && lv->thousands_sep[0]) \
(t) = lv->thousands_sep[0]; \
(t) = lv->thousands_sep[0]; \
(g) = lv->grouping ? lv->grouping : ""; \
if (*(g) == '\0' || *(g) == CHAR_MAX || (t) == -1) (g) = 0; \
} \
@@ -698,7 +717,7 @@ number(p, d, base)
{
GETLOCALEDATA(decpoint, thoussep, grouping);
if (grouping && (t = groupnum (tmp)))
tmp = t;
tmp = t;
}
p->width -= strlen(tmp);
@@ -768,7 +787,7 @@ lnumber(p, d, base)
{
GETLOCALEDATA(decpoint, thoussep, grouping);
if (grouping && (t = groupnum (tmp)))
tmp = t;
tmp = t;
}
p->width -= strlen(tmp);
@@ -875,11 +894,11 @@ wstrings(p, tmp)
{
len = wcsrtombs (NULL, &ws, 0, &mbs);
if (len != (size_t)-1)
{
{
memset (&mbs, '\0', sizeof (mbstate_t));
os = (char *)xmalloc (len + 1);
(void)wcsrtombs (os, &ws, len + 1, &mbs);
}
}
}
if (len == (size_t)-1)
{
@@ -919,32 +938,6 @@ wchars (p, wc)
#ifdef FLOATING_POINT
#ifndef HAVE_ISINF_IN_LIBC
/* Half-assed versions, since we don't want to link with libm. */
static int
isinf(d)
double d;
{
#ifdef DBL_MAX
if (d < DBL_MIN)
return -1;
else if (d > DBL_MAX)
return 1;
else
#endif
return 0;
}
#endif
#ifndef HAVE_ISNAN_IN_LIBC
static int
isnan(d)
double d;
{
return 0;
}
#endif
/* Check for [+-]infinity and NaN. If MODE == 1, we check for Infinity, else
(mode == 2) we check for NaN. This does the necessary printing. Returns
1 if Inf or Nan, 0 if not. */
@@ -1002,7 +995,7 @@ floating(p, d)
{
/* smash the trailing zeros unless altform */
for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
tmp2[i] = '\0';
tmp2[i] = '\0';
if (tmp2[0] == '\0')
p->precision = 0;
}
@@ -1163,7 +1156,7 @@ groupnum (s)
else if (*g == CHAR_MAX)
{
do
*--re = *--se;
*--re = *--se;
while (se > s);
break;
}