commit bash-20051103 snapshot

This commit is contained in:
Chet Ramey
2011-12-03 13:53:00 -05:00
parent bc7bed5099
commit 6bf74e5aca
25 changed files with 8910 additions and 395 deletions
+5 -1
View File
@@ -46,6 +46,9 @@ a. Fixed a bug that caused reversing the incremental search direction to
b. Fixed the vi-mode `U' command to only undo up to the first time insert mode
was entered, as Posix specifies.
c. Fixed a bug in the vi-mode `r' command that left the cursor in the wrong
place.
4. New Features in Readline
a. New application-callable auxiliary function, rl_variable_value, returns
@@ -160,7 +163,8 @@ d. Fixed the non-incremental search code in vi mode to dispose of any current
undo list when copying a line from the history into the current editing
buffer.
e. The variable assignment code now ignores whitespace at the end of lines.
e. The variable assignment code now ignores whitespace at the end of lines
when assigning to boolean variables.
f. The `C-w' binding in incremental search now understands multibyte
characters.
+28
View File
@@ -12335,3 +12335,31 @@ execute_cmd.c
- in shell_execve, improve the error message a little bit if the
interpreter name in a #! exec header ends with a ^M (as in a DOS-
format file)
11/1
----
lib/readline/vi_mode.c
- fix vi-mode `r' command to leave the cursor in the right place
[bash-3.1-rc1 frozen]
11/5
----
execute_cmd.c
- make sure a DEBUG trap doesn't overwrite a command string passed to
make_child in execute_simple_command
bashline.c
- rearrange some code in bash_quote_filename so filenames with leading
tildes containing spaces aren't tilde-expanded before being
returned to the caller
11/6
----
lib/readline/display.c
- when deciding where to move the cursor in rl_redisplay and needing
to move the cursor back after moving it vertically and compensate
for invisible characters in the prompt string, make sure that
_rl_last_c_pos is treated as an absolute cursor position in a
multibyte locale and the wrap offset (number of invisible characters)
is added explicitly when deciding how many characters to backspace
+22
View File
@@ -12331,3 +12331,25 @@ builtins/evalstring.c
- make sure we don't turn on CMD_NO_FORK in parse_and_execute if
we're running a trap command on signal receipt or exit
execute_cmd.c
- in shell_execve, improve the error message a little bit if the
interpreter name in a #! exec header ends with a ^M (as in a DOS-
format file)
11/1
----
lib/readline/vi_mode.c
- fix vi-mode `r' command to leave the cursor in the right place
[bash-3.1-rc1 frozen]
11/5
----
execute_cmd.c
- make sure a DEBUG trap doesn't overwrite a command string passed to
make_child in execute_simple_command
bashline.c
- rearrange some code in bash_quote_filename so filenames with leading
tildes containing spaces aren't tilde-expanded before being
returned to the caller
+9 -7
View File
@@ -2879,10 +2879,6 @@ bash_quote_filename (s, rtype, qcp)
to perform tilde expansion, because single and double
quotes inhibit tilde expansion by the shell. */
mtext = s;
if (mtext[0] == '~' && rtype == SINGLE_MATCH)
mtext = bash_tilde_expand (s, 0);
cs = completion_quoting_style;
/* Might need to modify the default completion style based on *qcp,
since it's set to any user-provided opening quote. We also change
@@ -2890,7 +2886,7 @@ bash_quote_filename (s, rtype, qcp)
the word being completed contains newlines, since those are not
quoted correctly using backslashes (a backslash-newline pair is
special to the shell parser). */
if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && xstrchr (mtext, '\n'))
if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && xstrchr (s, '\n'))
cs = COMPLETE_SQUOTE;
else if (*qcp == '"')
cs = COMPLETE_DQUOTE;
@@ -2898,17 +2894,23 @@ bash_quote_filename (s, rtype, qcp)
cs = COMPLETE_SQUOTE;
#if defined (BANG_HISTORY)
else if (*qcp == '\0' && history_expansion && cs == COMPLETE_DQUOTE &&
history_expansion_inhibited == 0 && xstrchr (mtext, '!'))
history_expansion_inhibited == 0 && xstrchr (s, '!'))
cs = COMPLETE_BSQUOTE;
if (*qcp == '"' && history_expansion && cs == COMPLETE_DQUOTE &&
history_expansion_inhibited == 0 && xstrchr (mtext, '!'))
history_expansion_inhibited == 0 && xstrchr (s, '!'))
{
cs = COMPLETE_BSQUOTE;
*qcp = '\0';
}
#endif
/* Don't tilde-expand backslash-quoted filenames, since only single and
double quotes inhibit tilde expansion. */
mtext = s;
if (mtext[0] == '~' && rtype == SINGLE_MATCH && cs != COMPLETE_BSQUOTE)
mtext = bash_tilde_expand (s, 0);
switch (cs)
{
case COMPLETE_DQUOTE:
+16 -9
View File
@@ -1443,7 +1443,11 @@ command_word_completion_function (hint_text, state)
if (absolute_program (hint))
{
match = strncmp (val, hint, hint_len) == 0;
if (igncase == 0)
match = strncmp (val, hint, hint_len) == 0;
else
match = strncasecmp (val, hint, hint_len) == 0;
/* If we performed tilde expansion, restore the original
filename. */
if (*hint_text == '~')
@@ -1476,7 +1480,10 @@ command_word_completion_function (hint_text, state)
if (temp)
{
temp++;
freetemp = match = strncmp (temp, hint, hint_len) == 0;
if (igncase == 0)
freetemp = match = strncmp (temp, hint, hint_len) == 0;
else
freetemp = match = strncasecmp (temp, hint, hint_len) == 0;
if (match)
temp = savestring (temp);
}
@@ -2872,10 +2879,6 @@ bash_quote_filename (s, rtype, qcp)
to perform tilde expansion, because single and double
quotes inhibit tilde expansion by the shell. */
mtext = s;
if (mtext[0] == '~' && rtype == SINGLE_MATCH)
mtext = bash_tilde_expand (s, 0);
cs = completion_quoting_style;
/* Might need to modify the default completion style based on *qcp,
since it's set to any user-provided opening quote. We also change
@@ -2883,7 +2886,7 @@ bash_quote_filename (s, rtype, qcp)
the word being completed contains newlines, since those are not
quoted correctly using backslashes (a backslash-newline pair is
special to the shell parser). */
if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && xstrchr (mtext, '\n'))
if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && xstrchr (s, '\n'))
cs = COMPLETE_SQUOTE;
else if (*qcp == '"')
cs = COMPLETE_DQUOTE;
@@ -2891,17 +2894,21 @@ bash_quote_filename (s, rtype, qcp)
cs = COMPLETE_SQUOTE;
#if defined (BANG_HISTORY)
else if (*qcp == '\0' && history_expansion && cs == COMPLETE_DQUOTE &&
history_expansion_inhibited == 0 && xstrchr (mtext, '!'))
history_expansion_inhibited == 0 && xstrchr (s, '!'))
cs = COMPLETE_BSQUOTE;
if (*qcp == '"' && history_expansion && cs == COMPLETE_DQUOTE &&
history_expansion_inhibited == 0 && xstrchr (mtext, '!'))
history_expansion_inhibited == 0 && xstrchr (s, '!'))
{
cs = COMPLETE_BSQUOTE;
*qcp = '\0';
}
#endif
mtext = s;
if (mtext[0] == '~' && rtype == SINGLE_MATCH && cs != COMPLETE_BSQUOTE)
mtext = bash_tilde_expand (s, 0);
switch (cs)
{
case COMPLETE_DQUOTE:
-1
View File
@@ -1 +0,0 @@
texinfo.tex.20030205
+6688
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -2753,7 +2753,9 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
vast majority of cases. */
maybe_make_export_env ();
if (make_child (savestring (the_printed_command), async) == 0)
/* Don't let a DEBUG trap overwrite the command string to be saved with
the process/job associated with this child. */
if (make_child (savestring (the_printed_command_except_trap), async) == 0)
{
already_forked = 1;
simple_command->flags |= CMD_NO_FORK;
+4 -2
View File
@@ -2753,7 +2753,11 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
vast majority of cases. */
maybe_make_export_env ();
#if 0
if (make_child (savestring (the_printed_command), async) == 0)
#else
if (make_child (savestring (the_printed_command_except_trap), async) == 0)
#endif
{
already_forked = 1;
simple_command->flags |= CMD_NO_FORK;
@@ -3875,8 +3879,6 @@ shell_execve (command, args, env)
interp = getinterp (sample, sample_len, (int *)NULL);
ilen = strlen (interp);
errno = i;
itrace("shell_execve: interp = `%s', ilen = %d", interp, ilen);
itrace("shell_execve: interp[ilen - 1] = %d", interp[ilen - 1]);
if (interp[ilen - 1] == '\r')
{
interp = xrealloc (interp, ilen + 2);
+66 -89
View File
@@ -63,17 +63,6 @@
# include <bsdtty.h>
#endif /* hpux && !TERMIOS_TTY_DRIVER */
#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
/* For struct winsize on SCO */
/* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
# if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
# if defined (HAVE_SYS_STREAM_H)
# include <sys/stream.h>
# endif
# include <sys/ptem.h>
# endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
#include "bashansi.h"
#include "bashintl.h"
#include "shell.h"
@@ -142,10 +131,6 @@ extern int errno;
typedef int sh_job_map_func_t __P((JOB *, int, int, int));
#if defined (READLINE)
extern void rl_set_screen_size __P((int, int));
#endif
/* Variables used here but defined in other files. */
extern int subshell_environment, line_number;
extern int posixly_correct, shell_level;
@@ -160,6 +145,7 @@ extern procenv_t wait_intr_buf;
extern int wait_signal_received;
extern WORD_LIST *subst_assign_varlist;
static struct jobstats zerojs = { -1L, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NO_JOB, NO_JOB, 0, 0 };
struct jobstats js = { -1L, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NO_JOB, NO_JOB, 0, 0 };
struct bgpids bgpids = { 0, 0, 0 };
@@ -223,13 +209,10 @@ int check_window_size;
/* Functions local to this file. */
static void get_new_window_size __P((int));
static void run_sigchld_trap __P((int));
static sighandler wait_sigint_handler __P((int));
static sighandler sigchld_handler __P((int));
static sighandler sigwinch_sighandler __P((int));
static sighandler sigcont_sighandler __P((int));
static sighandler sigstop_sighandler __P((int));
@@ -312,10 +295,6 @@ static int queue_sigchld;
static SigHandler *old_tstp, *old_ttou, *old_ttin;
static SigHandler *old_cont = (SigHandler *)SIG_DFL;
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
static SigHandler *old_winch = (SigHandler *)SIG_DFL;
#endif
/* A place to temporarily save the current pipeline. */
static PROCESS *saved_pipeline;
static int saved_already_making_children;
@@ -349,6 +328,13 @@ tcgetpgrp (fd)
#endif /* !_POSIX_VERSION */
/* Initialize the global job stats structure. */
void
init_job_stats ()
{
js = zerojs;
}
/* Return the working directory for the current process. Unlike
job_working_directory, this does not call malloc (), nor do any
of the functions it calls. This is so that it can safely be called
@@ -410,11 +396,16 @@ stop_making_children ()
void
cleanup_the_pipeline ()
{
if (the_pipeline)
{
discard_pipeline (the_pipeline);
the_pipeline = (PROCESS *)NULL;
}
PROCESS *disposer;
sigset_t set, oset;
BLOCK_CHILD (set, oset);
disposer = the_pipeline;
the_pipeline = (PROCESS *)NULL;
UNBLOCK_CHILD (oset);
if (disposer)
discard_pipeline (disposer);
}
void
@@ -422,9 +413,9 @@ save_pipeline (clear)
int clear;
{
saved_pipeline = the_pipeline;
saved_already_making_children = already_making_children;
if (clear)
the_pipeline = (PROCESS *)NULL;
saved_already_making_children = already_making_children;
}
void
@@ -1019,6 +1010,7 @@ add_process (name, pid)
}
#endif
itrace("add_process: %s %d", name, pid);
t = (PROCESS *)xmalloc (sizeof (PROCESS));
t->next = the_pipeline;
t->pid = pid;
@@ -1984,6 +1976,13 @@ wait_for_single_pid (pid)
jobs[job]->flags |= J_NOTIFIED;
UNBLOCK_CHILD (oset);
/* If running in posix mode, remove the job from the jobs table immediately */
if (posixly_correct)
{
cleanup_dead_jobs ();
bgp_delete (pid);
}
return r;
}
@@ -2635,7 +2634,7 @@ start_job (job, foreground)
register PROCESS *p;
int already_running;
sigset_t set, oset;
char *wd;
char *wd, *s;
static TTYSTRUCT save_stty;
BLOCK_CHILD (set, oset);
@@ -2653,7 +2652,7 @@ start_job (job, foreground)
{
internal_error (_("%s: job %d already in background"), this_command_name, job + 1);
UNBLOCK_CHILD (oset);
return (-1);
return (0); /* XPG6/SUSv3 says this is not an error */
}
wd = current_working_directory ();
@@ -2671,8 +2670,15 @@ start_job (job, foreground)
p = jobs[job]->pipe;
if (foreground == 0)
printf ("[%d]%c ", job + 1,
(job == js.j_current) ? '+': ((job == js.j_previous) ? '-' : ' '));
{
/* POSIX.2 says `bg' doesn't give any indication about current or
previous job. */
if (posixly_correct == 0)
s = (job == js.j_current) ? "+ ": ((job == js.j_previous) ? "- " : " ");
else
s = " ";
printf ("[%d]%s", job + 1, s);
}
do
{
@@ -2744,9 +2750,17 @@ kill_pid (pid, sig, group)
int sig, group;
{
register PROCESS *p;
int job, result;
int job, result, negative;
sigset_t set, oset;
if (pid < -1)
{
pid = -pid;
group = negative = 1;
}
else
negative = 0;
result = EXECUTION_SUCCESS;
if (group)
{
@@ -2758,8 +2772,26 @@ kill_pid (pid, sig, group)
jobs[job]->flags &= ~J_NOTIFIED;
/* Kill process in backquotes or one started without job control? */
if (jobs[job]->pgrp == shell_pgrp)
/* If we're passed a pid < -1, just call killpg and see what happens */
if (negative && jobs[job]->pgrp == shell_pgrp)
result = killpg (pid, sig);
/* If we're killing using job control notification, for example,
without job control active, we have to do things ourselves. */
else if (jobs[job]->pgrp == shell_pgrp)
{
p = jobs[job]->pipe;
do
{
if (PALIVE (p) == 0)
continue; /* avoid pid recycling problem */
kill (p->pid, sig);
if (PEXITED (p) && (sig == SIGTERM || sig == SIGHUP))
kill (p->pid, SIGCONT);
p = p->next;
}
while (p != jobs[job]->pipe);
}
else
{
result = killpg (jobs[job]->pgrp, sig);
@@ -3493,60 +3525,6 @@ set_new_line_discipline (tty)
#endif
}
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
static void
get_new_window_size (from_sig)
int from_sig;
{
struct winsize win;
if ((ioctl (shell_tty, TIOCGWINSZ, &win) == 0) &&
win.ws_row > 0 && win.ws_col > 0)
{
#if defined (aixpc)
shell_tty_info.c_winsize = win; /* structure copying */
#endif
sh_set_lines_and_columns (win.ws_row, win.ws_col);
#if defined (READLINE)
rl_set_screen_size (win.ws_row, win.ws_col);
#endif
}
}
static sighandler
sigwinch_sighandler (sig)
int sig;
{
#if defined (MUST_REINSTALL_SIGHANDLERS)
set_signal_handler (SIGWINCH, sigwinch_sighandler);
#endif /* MUST_REINSTALL_SIGHANDLERS */
get_new_window_size (1);
SIGRETURN (0);
}
#else
static void
get_new_window_size (from_sig)
int from_sig;
{
}
#endif /* TIOCGWINSZ && SIGWINCH */
void
set_sigwinch_handler ()
{
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
old_winch = set_signal_handler (SIGWINCH, sigwinch_sighandler);
#endif
}
void
unset_sigwinch_handler ()
{
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
set_signal_handler (SIGWINCH, old_winch);
#endif
}
/* Setup this shell to handle C-C, etc. */
void
initialize_job_signals ()
@@ -3557,7 +3535,6 @@ initialize_job_signals ()
set_signal_handler (SIGTSTP, SIG_IGN);
set_signal_handler (SIGTTOU, SIG_IGN);
set_signal_handler (SIGTTIN, SIG_IGN);
set_sigwinch_handler ();
}
else if (job_control)
{
-1
View File
@@ -1 +0,0 @@
../../include/ansi_stdlib.h
+54
View File
@@ -0,0 +1,54 @@
/* ansi_stdlib.h -- An ANSI Standard stdlib.h. */
/* A minimal stdlib.h containing extern declarations for those functions
that bash uses. */
/* Copyright (C) 1993 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_STDLIB_H_)
#define _STDLIB_H_ 1
/* String conversion functions. */
extern int atoi ();
extern double atof ();
extern double strtod ();
/* Memory allocation functions. */
/* Generic pointer type. */
#ifndef PTR_T
#if defined (__STDC__)
# define PTR_T void *
#else
# define PTR_T char *
#endif
#endif /* PTR_T */
extern PTR_T malloc ();
extern PTR_T realloc ();
extern void free ();
/* Other miscellaneous functions. */
extern void abort ();
extern void exit ();
extern char *getenv ();
extern void qsort ();
#endif /* _STDLIB_H */
+438
View File
@@ -0,0 +1,438 @@
*** ../../../bash-3.0-patched/lib/readline/display.c 2004-09-08 11:07:51.000000000 -0400
--- display.c 2005-11-06 21:32:59.000000000 -0500
***************
*** 1,5 ****
/* display.c -- readline redisplay facility. */
! /* Copyright (C) 1987-2004 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
--- 1,5 ----
/* display.c -- readline redisplay facility. */
! /* Copyright (C) 1987-2005 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
***************
*** 119,122 ****
--- 119,123 ----
int _rl_suppress_redisplay = 0;
+ int _rl_want_redisplay = 0;
/* The stuff that gets printed out before the actual text of the line.
***************
*** 125,129 ****
--- 126,135 ----
/* Pseudo-global variables declared here. */
+
/* The visible cursor position. If you print some text, adjust this. */
+ /* NOTE: _rl_last_c_pos is used as a buffer index when not in a locale
+ supporting multibyte characters, and an absolute cursor position when
+ in such a locale. This is an artifact of the donated multibyte support.
+ Care must be taken when modifying its value. */
int _rl_last_c_pos = 0;
int _rl_last_v_pos = 0;
***************
*** 181,184 ****
--- 187,202 ----
static int prompt_physical_chars;
+ /* Variables to save and restore prompt and display information. */
+
+ /* These are getting numerous enough that it's time to create a struct. */
+
+ static char *saved_local_prompt;
+ static char *saved_local_prefix;
+ static int saved_last_invisible;
+ static int saved_visible_length;
+ static int saved_prefix_length;
+ static int saved_invis_chars_first_line;
+ static int saved_physical_chars;
+
/* Expand the prompt string S and return the number of visible
characters in *LP, if LP is not null. This is currently more-or-less
***************
*** 237,241 ****
{
ignoring = 0;
! last = r - ret - 1;
continue;
}
--- 255,260 ----
{
ignoring = 0;
! if (p[-1] != RL_PROMPT_START_IGNORE)
! last = r - ret - 1;
continue;
}
***************
*** 336,340 ****
local_prompt = local_prompt_prefix = (char *)0;
! prompt_last_invisible = prompt_visible_length = 0;
if (prompt == 0 || *prompt == 0)
--- 355,360 ----
local_prompt = local_prompt_prefix = (char *)0;
! prompt_last_invisible = prompt_invis_chars_first_line = 0;
! prompt_visible_length = prompt_physical_chars = 0;
if (prompt == 0 || *prompt == 0)
***************
*** 441,445 ****
rl_display_prompt = "";
! if (invisible_line == 0)
{
init_line_structures (0);
--- 461,465 ----
rl_display_prompt = "";
! if (invisible_line == 0 || vis_lbreaks == 0)
{
init_line_structures (0);
***************
*** 834,838 ****
if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
{
! int nleft, pos, changed_screen_line;
if (!rl_display_fixed || forced_display)
--- 854,858 ----
if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
{
! int nleft, pos, changed_screen_line, tx, fudge;
if (!rl_display_fixed || forced_display)
***************
*** 879,883 ****
(_rl_last_c_pos < visible_first_line_len))
{
! nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
if (nleft)
_rl_clear_to_eol (nleft);
--- 899,906 ----
(_rl_last_c_pos < visible_first_line_len))
{
! if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
! nleft = _rl_screenwidth - _rl_last_c_pos;
! else
! nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
if (nleft)
_rl_clear_to_eol (nleft);
***************
*** 915,919 ****
but the buffer position needs to be adjusted to account
for invisible characters. */
! if (cursor_linenum == 0 && wrap_offset)
_rl_last_c_pos += wrap_offset;
}
--- 938,942 ----
but the buffer position needs to be adjusted to account
for invisible characters. */
! if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
_rl_last_c_pos += wrap_offset;
}
***************
*** 948,951 ****
--- 971,980 ----
nleft = c_pos - pos;
+ /* NLEFT is now a number of characters in a buffer. When in a
+ multibyte locale, however, _rl_last_c_pos is an absolute cursor
+ position that doesn't take invisible characters in the prompt
+ into account. We use a fudge factor to compensate. */
+ fudge = (MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? wrap_offset : 0;
+
/* Since _rl_backspace() doesn't know about invisible characters in the
prompt, and there's no good way to tell it, we compensate for
***************
*** 953,961 ****
if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)
{
- _rl_backspace (_rl_last_c_pos - nleft);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
! _rl_last_c_pos = _rl_col_width (&visible_line[pos], 0, nleft);
else
! _rl_last_c_pos = nleft;
}
--- 982,994 ----
if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)
{
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
! tx = _rl_col_width (&visible_line[pos], 0, nleft);
else
! tx = nleft;
! if ((_rl_last_c_pos+fudge) != tx)
! {
! _rl_backspace (_rl_last_c_pos + fudge - tx); /* XXX */
! _rl_last_c_pos = tx;
! }
}
***************
*** 1118,1122 ****
emulators. In this calculation, TEMP is the physical screen
position of the cursor. */
! temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
&& _rl_last_v_pos == current_line - 1)
--- 1151,1158 ----
emulators. In this calculation, TEMP is the physical screen
position of the cursor. */
! if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
! temp = _rl_last_c_pos;
! else
! temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
&& _rl_last_v_pos == current_line - 1)
***************
*** 1324,1328 ****
{
_rl_move_vert (current_line);
! if (current_line == 0 && visible_wrap_offset)
_rl_last_c_pos += visible_wrap_offset;
}
--- 1360,1364 ----
{
_rl_move_vert (current_line);
! if ((MB_CUR_MAX == 1 || rl_byte_oriented) && current_line == 0 && visible_wrap_offset)
_rl_last_c_pos += visible_wrap_offset;
}
***************
*** 1415,1419 ****
_rl_last_c_pos += col_lendiff;
}
! else if (*ols == 0 && lendiff > 0)
{
/* At the end of a line the characters do not have to
--- 1451,1455 ----
_rl_last_c_pos += col_lendiff;
}
! else if ((MB_CUR_MAX == 1 || rl_byte_oriented != 0) && *ols == 0 && lendiff > 0)
{
/* At the end of a line the characters do not have to
***************
*** 1797,1803 ****
return ((ISPRINT (uc)) ? 1 : 2);
}
-
/* How to print things in the "echo-area". The prompt is treated as a
mini-modeline. */
#if defined (USE_VARARGS)
--- 1833,1839 ----
return ((ISPRINT (uc)) ? 1 : 2);
}
/* How to print things in the "echo-area". The prompt is treated as a
mini-modeline. */
+ static int msg_saved_prompt = 0;
#if defined (USE_VARARGS)
***************
*** 1830,1835 ****
--- 1866,1882 ----
va_end (args);
+ if (saved_local_prompt == 0)
+ {
+ rl_save_prompt ();
+ msg_saved_prompt = 1;
+ }
rl_display_prompt = msg_buf;
+ local_prompt = expand_prompt (msg_buf, &prompt_visible_length,
+ &prompt_last_invisible,
+ &prompt_invis_chars_first_line,
+ &prompt_physical_chars);
+ local_prompt_prefix = (char *)NULL;
(*rl_redisplay_function) ();
+
return 0;
}
***************
*** 1841,1846 ****
--- 1888,1905 ----
sprintf (msg_buf, format, arg1, arg2);
msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
+
rl_display_prompt = msg_buf;
+ if (saved_local_prompt == 0)
+ {
+ rl_save_prompt ();
+ msg_saved_prompt = 1;
+ }
+ local_prompt = expand_prompt (msg_buf, &prompt_visible_length,
+ &prompt_last_invisible,
+ &prompt_invis_chars_first_line,
+ &prompt_physical_chars);
+ local_prompt_prefix = (char *)NULL;
(*rl_redisplay_function) ();
+
return 0;
}
***************
*** 1852,1855 ****
--- 1911,1919 ----
{
rl_display_prompt = rl_prompt;
+ if (msg_saved_prompt)
+ {
+ rl_restore_prompt ();
+ msg_saved_prompt = 0;
+ }
(*rl_redisplay_function) ();
return 0;
***************
*** 1866,1878 ****
}
- /* These are getting numerous enough that it's time to create a struct. */
-
- static char *saved_local_prompt;
- static char *saved_local_prefix;
- static int saved_last_invisible;
- static int saved_visible_length;
- static int saved_invis_chars_first_line;
- static int saved_physical_chars;
-
void
rl_save_prompt ()
--- 1930,1933 ----
***************
*** 1880,1883 ****
--- 1935,1939 ----
saved_local_prompt = local_prompt;
saved_local_prefix = local_prompt_prefix;
+ saved_prefix_length = prompt_prefix_length;
saved_last_invisible = prompt_last_invisible;
saved_visible_length = prompt_visible_length;
***************
*** 1886,1890 ****
local_prompt = local_prompt_prefix = (char *)0;
! prompt_last_invisible = prompt_visible_length = 0;
prompt_invis_chars_first_line = prompt_physical_chars = 0;
}
--- 1942,1946 ----
local_prompt = local_prompt_prefix = (char *)0;
! prompt_last_invisible = prompt_visible_length = prompt_prefix_length = 0;
prompt_invis_chars_first_line = prompt_physical_chars = 0;
}
***************
*** 1898,1905 ****
--- 1954,1967 ----
local_prompt = saved_local_prompt;
local_prompt_prefix = saved_local_prefix;
+ prompt_prefix_length = saved_prefix_length;
prompt_last_invisible = saved_last_invisible;
prompt_visible_length = saved_visible_length;
prompt_invis_chars_first_line = saved_invis_chars_first_line;
prompt_physical_chars = saved_physical_chars;
+
+ /* can test saved_local_prompt to see if prompt info has been saved. */
+ saved_local_prompt = saved_local_prefix = (char *)0;
+ saved_last_invisible = saved_visible_length = saved_prefix_length = 0;
+ saved_invis_chars_first_line = saved_physical_chars = 0;
}
***************
*** 1935,1938 ****
--- 1997,2002 ----
}
+ prompt_physical_chars = saved_physical_chars + 1;
+
return pmt;
}
***************
*** 1995,1998 ****
--- 2059,2065 ----
int count, col;
{
+ #if defined (__MSDOS__) || defined (__MINGW32__)
+ _rl_output_some_chars (string, count);
+ #else
/* DEBUGGING */
if (MB_CUR_MAX == 1 || rl_byte_oriented)
***************
*** 2033,2036 ****
--- 2100,2104 ----
tputs (_rl_term_ei, 1, _rl_output_character_function);
}
+ #endif /* __MSDOS__ || __MINGW32__ */
}
***************
*** 2043,2046 ****
--- 2111,2115 ----
return;
+ #if !defined (__MSDOS__) && !defined (__MINGW32__)
if (_rl_term_DC && *_rl_term_DC)
{
***************
*** 2055,2058 ****
--- 2124,2128 ----
tputs (_rl_term_dc, 1, _rl_output_character_function);
}
+ #endif /* !__MSDOS__ && !__MINGW32__ */
}
***************
*** 2110,2125 ****
char *t;
{
! char *oldp, *oldl, *oldlprefix;
! int oldlen, oldlast, oldplen, oldninvis, oldphyschars;
- /* Geez, I should make this a struct. */
oldp = rl_display_prompt;
! oldl = local_prompt;
! oldlprefix = local_prompt_prefix;
! oldlen = prompt_visible_length;
! oldplen = prompt_prefix_length;
! oldlast = prompt_last_invisible;
! oldninvis = prompt_invis_chars_first_line;
! oldphyschars = prompt_physical_chars;
rl_display_prompt = t;
--- 2180,2187 ----
char *t;
{
! char *oldp;
oldp = rl_display_prompt;
! rl_save_prompt ();
rl_display_prompt = t;
***************
*** 2129,2142 ****
&prompt_physical_chars);
local_prompt_prefix = (char *)NULL;
rl_forced_update_display ();
rl_display_prompt = oldp;
! local_prompt = oldl;
! local_prompt_prefix = oldlprefix;
! prompt_visible_length = oldlen;
! prompt_prefix_length = oldplen;
! prompt_last_invisible = oldlast;
! prompt_invis_chars_first_line = oldninvis;
! prompt_physical_chars = oldphyschars;
}
--- 2191,2199 ----
&prompt_physical_chars);
local_prompt_prefix = (char *)NULL;
+
rl_forced_update_display ();
rl_display_prompt = oldp;
! rl_restore_prompt();
}
+10 -4
View File
@@ -853,7 +853,7 @@ rl_redisplay ()
if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
{
int nleft, pos, changed_screen_line, tx;
int nleft, pos, changed_screen_line, tx, fudge;
if (!rl_display_fixed || forced_display)
{
@@ -937,7 +937,7 @@ rl_redisplay ()
the physical cursor position on the screen stays the same,
but the buffer position needs to be adjusted to account
for invisible characters. */
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
_rl_last_c_pos += wrap_offset;
}
@@ -970,6 +970,12 @@ rl_redisplay ()
start of the line and the cursor position. */
nleft = c_pos - pos;
/* NLEFT is now a number of characters in a buffer. When in a
multibyte locale, however, _rl_last_c_pos is an absolute cursor
position that doesn't take invisible characters in the prompt
into account. We use a fudge factor to compensate. */
fudge = (MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? wrap_offset : 0;
/* Since _rl_backspace() doesn't know about invisible characters in the
prompt, and there's no good way to tell it, we compensate for
those characters here and call _rl_backspace() directly. */
@@ -979,9 +985,9 @@ rl_redisplay ()
tx = _rl_col_width (&visible_line[pos], 0, nleft);
else
tx = nleft;
if (_rl_last_c_pos != tx)
if ((_rl_last_c_pos+fudge) != tx)
{
_rl_backspace (_rl_last_c_pos - tx); /* XXX */
_rl_backspace (_rl_last_c_pos + fudge - tx); /* XXX */
_rl_last_c_pos = tx;
}
}
+10 -5
View File
@@ -424,7 +424,6 @@ init_line_structures (minsize)
invisible_line[n] = 1;
}
kill(getpid(), SIGWINCH);
if (vis_lbreaks == 0)
{
/* should be enough. */
@@ -445,7 +444,7 @@ rl_redisplay ()
register int in, out, c, linenum, cursor_linenum;
register char *line;
int c_pos, inv_botlin, lb_botlin, lb_linenum;
int newlines, lpos, temp, modmark, n0, num;
int newlines, lpos, temp, modmark, n0, num, fudge;
char *prompt_this_line;
#if defined (HANDLE_MULTIBYTE)
wchar_t wc;
@@ -938,7 +937,7 @@ rl_redisplay ()
the physical cursor position on the screen stays the same,
but the buffer position needs to be adjusted to account
for invisible characters. */
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
_rl_last_c_pos += wrap_offset;
}
@@ -971,6 +970,12 @@ rl_redisplay ()
start of the line and the cursor position. */
nleft = c_pos - pos;
/* NLEFT is now a number of characters in a buffer. When in a
multibyte locale, however, _rl_last_c_pos is an absolute cursor
position that doesn't take invisible characters in the prompt
into account. We use a fudge factor to compensate. */
fudge = (MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? wrap_offset : 0;
/* Since _rl_backspace() doesn't know about invisible characters in the
prompt, and there's no good way to tell it, we compensate for
those characters here and call _rl_backspace() directly. */
@@ -980,9 +985,9 @@ rl_redisplay ()
tx = _rl_col_width (&visible_line[pos], 0, nleft);
else
tx = nleft;
if (_rl_last_c_pos != tx)
if ((_rl_last_c_pos+fudge) != tx)
{
_rl_backspace (_rl_last_c_pos - tx); /* XXX */
_rl_backspace (_rl_last_c_pos + fudge - tx); /* XXX */
_rl_last_c_pos = tx;
}
}
-1
View File
@@ -1 +0,0 @@
../../../doc/fdl.texi
+452
View File
@@ -0,0 +1,452 @@
@node GNU Free Documentation License
@appendixsec GNU Free Documentation License
@cindex FDL, GNU Free Documentation License
@center Version 1.2, November 2002
@display
Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display
@enumerate 0
@item
PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
@item
APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The ``Document'', below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as ``you''. You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not ``Transparent'' is called ``Opaque''.
Examples of suitable formats for Transparent copies include plain
@sc{ascii} without markup, Texinfo input format, La@TeX{} input
format, @acronym{SGML} or @acronym{XML} using a publicly available
@acronym{DTD}, and standard-conforming simple @acronym{HTML},
PostScript or @acronym{PDF} designed for human modification. Examples
of transparent image formats include @acronym{PNG}, @acronym{XCF} and
@acronym{JPG}. Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, @acronym{SGML} or
@acronym{XML} for which the @acronym{DTD} and/or processing tools are
not generally available, and the machine-generated @acronym{HTML},
PostScript or @acronym{PDF} produced by some word processors for
output purposes only.
The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
@item
VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
@item
COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
@item
MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.
@item
Preserve all the copyright notices of the Document.
@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
@item
Include an unaltered copy of this License.
@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.
@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
@item
Delete any section Entitled ``Endorsements''. Such a section
may not be included in the Modified Version.
@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.
@item
Preserve any Warranty Disclaimers.
@end enumerate
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
@item
COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''. You must delete all
sections Entitled ``Endorsements.''
@item
COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
@item
AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
@item
TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
@item
TERMINATION
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License. However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.
@item
FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
@uref{http://www.gnu.org/copyleft/}.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
@end enumerate
@page
@appendixsubsec ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
@smallexample
@group
Copyright (C) @var{year} @var{your name}.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end group
@end smallexample
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with...Texts.'' line with this:
@smallexample
@group
with the Invariant Sections being @var{list their titles}, with
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
being @var{list}.
@end group
@end smallexample
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:
-1
View File
@@ -1 +0,0 @@
../../include/posixdir.h
+61
View File
@@ -0,0 +1,61 @@
/* posixdir.h -- Posix directory reading includes and defines. */
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
#if !defined (_POSIXDIR_H_)
#define _POSIXDIR_H_
#if defined (HAVE_DIRENT_H)
# include <dirent.h>
# if defined (HAVE_STRUCT_DIRENT_D_NAMLEN)
# define D_NAMLEN(d) ((d)->d_namlen)
# else
# define D_NAMLEN(d) (strlen ((d)->d_name))
# endif /* !HAVE_STRUCT_DIRENT_D_NAMLEN */
#else
# if defined (HAVE_SYS_NDIR_H)
# include <sys/ndir.h>
# endif
# if defined (HAVE_SYS_DIR_H)
# include <sys/dir.h>
# endif
# if defined (HAVE_NDIR_H)
# include <ndir.h>
# endif
# if !defined (dirent)
# define dirent direct
# endif /* !dirent */
# define D_NAMLEN(d) ((d)->d_namlen)
#endif /* !HAVE_DIRENT_H */
#if defined (HAVE_STRUCT_DIRENT_D_INO) && !defined (HAVE_STRUCT_DIRENT_D_FILENO)
# define d_fileno d_ino
#endif
#if defined (_POSIX_SOURCE) && (!defined (HAVE_STRUCT_DIRENT_D_INO) || defined (BROKEN_DIRENT_D_INO))
/* Posix does not require that the d_ino field be present, and some
systems do not provide it. */
# define REAL_DIR_ENTRY(dp) 1
#else
# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
#endif /* _POSIX_SOURCE */
#endif /* !_POSIXDIR_H_ */
-1
View File
@@ -1 +0,0 @@
../../include/posixjmp.h
+40
View File
@@ -0,0 +1,40 @@
/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _POSIXJMP_H_
#define _POSIXJMP_H_
#include <setjmp.h>
/* This *must* be included *after* config.h */
#if defined (HAVE_POSIX_SIGSETJMP)
# define procenv_t sigjmp_buf
# if !defined (__OPENNT)
# undef setjmp
# define setjmp(x) sigsetjmp((x), 1)
# undef longjmp
# define longjmp(x, n) siglongjmp((x), (n))
# endif /* !__OPENNT */
#else
# define procenv_t jmp_buf
#endif
#endif /* _POSIXJMP_H_ */
-1
View File
@@ -1 +0,0 @@
../../include/posixstat.h
+142
View File
@@ -0,0 +1,142 @@
/* posixstat.h -- Posix stat(2) definitions for systems that
don't have them. */
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* This file should be included instead of <sys/stat.h>.
It relies on the local sys/stat.h to work though. */
#if !defined (_POSIXSTAT_H_)
#define _POSIXSTAT_H_
#include <sys/stat.h>
#if defined (STAT_MACROS_BROKEN)
# undef S_ISBLK
# undef S_ISCHR
# undef S_ISDIR
# undef S_ISFIFO
# undef S_ISREG
# undef S_ISLNK
#endif /* STAT_MACROS_BROKEN */
/* These are guaranteed to work only on isc386 */
#if !defined (S_IFDIR) && !defined (S_ISDIR)
# define S_IFDIR 0040000
#endif /* !S_IFDIR && !S_ISDIR */
#if !defined (S_IFMT)
# define S_IFMT 0170000
#endif /* !S_IFMT */
/* Posix 1003.1 5.6.1.1 <sys/stat.h> file types */
/* Some Posix-wannabe systems define _S_IF* macros instead of S_IF*, but
do not provide the S_IS* macros that Posix requires. */
#if defined (_S_IFMT) && !defined (S_IFMT)
#define S_IFMT _S_IFMT
#endif
#if defined (_S_IFIFO) && !defined (S_IFIFO)
#define S_IFIFO _S_IFIFO
#endif
#if defined (_S_IFCHR) && !defined (S_IFCHR)
#define S_IFCHR _S_IFCHR
#endif
#if defined (_S_IFDIR) && !defined (S_IFDIR)
#define S_IFDIR _S_IFDIR
#endif
#if defined (_S_IFBLK) && !defined (S_IFBLK)
#define S_IFBLK _S_IFBLK
#endif
#if defined (_S_IFREG) && !defined (S_IFREG)
#define S_IFREG _S_IFREG
#endif
#if defined (_S_IFLNK) && !defined (S_IFLNK)
#define S_IFLNK _S_IFLNK
#endif
#if defined (_S_IFSOCK) && !defined (S_IFSOCK)
#define S_IFSOCK _S_IFSOCK
#endif
/* Test for each symbol individually and define the ones necessary (some
systems claiming Posix compatibility define some but not all). */
#if defined (S_IFBLK) && !defined (S_ISBLK)
#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */
#endif
#if defined (S_IFCHR) && !defined (S_ISCHR)
#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */
#endif
#if defined (S_IFDIR) && !defined (S_ISDIR)
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */
#endif
#if defined (S_IFREG) && !defined (S_ISREG)
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */
#endif
#if defined (S_IFIFO) && !defined (S_ISFIFO)
#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */
#endif
#if defined (S_IFLNK) && !defined (S_ISLNK)
#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */
#endif
#if defined (S_IFSOCK) && !defined (S_ISSOCK)
#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */
#endif
/*
* POSIX 1003.1 5.6.1.2 <sys/stat.h> File Modes
*/
#if !defined (S_IRWXU)
# if !defined (S_IREAD)
# define S_IREAD 00400
# define S_IWRITE 00200
# define S_IEXEC 00100
# endif /* S_IREAD */
# if !defined (S_IRUSR)
# define S_IRUSR S_IREAD /* read, owner */
# define S_IWUSR S_IWRITE /* write, owner */
# define S_IXUSR S_IEXEC /* execute, owner */
# define S_IRGRP (S_IREAD >> 3) /* read, group */
# define S_IWGRP (S_IWRITE >> 3) /* write, group */
# define S_IXGRP (S_IEXEC >> 3) /* execute, group */
# define S_IROTH (S_IREAD >> 6) /* read, other */
# define S_IWOTH (S_IWRITE >> 6) /* write, other */
# define S_IXOTH (S_IEXEC >> 6) /* execute, other */
# endif /* !S_IRUSR */
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
#endif /* !S_IRWXU */
/* These are non-standard, but are used in builtins.c$symbolic_umask() */
#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
#define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
#define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
#endif /* _POSIXSTAT_H_ */
-1
View File
@@ -1 +0,0 @@
../tilde/tilde.c
+502
View File
@@ -0,0 +1,502 @@
/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */
/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
This file is part of GNU Readline, a library for reading lines
of text with interactive input and history editing.
Readline is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else /* !HAVE_STRING_H */
# include <strings.h>
#endif /* !HAVE_STRING_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include <sys/types.h>
#if defined (HAVE_PWD_H)
#include <pwd.h>
#endif
#include "tilde.h"
#if defined (TEST) || defined (STATIC_MALLOC)
static void *xmalloc (), *xrealloc ();
#else
# include "xmalloc.h"
#endif /* TEST || STATIC_MALLOC */
#if !defined (HAVE_GETPW_DECLS)
# if defined (HAVE_GETPWUID)
extern struct passwd *getpwuid PARAMS((uid_t));
# endif
# if defined (HAVE_GETPWNAM)
extern struct passwd *getpwnam PARAMS((const char *));
# endif
#endif /* !HAVE_GETPW_DECLS */
#if !defined (savestring)
#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
#endif /* !savestring */
#if !defined (NULL)
# if defined (__STDC__)
# define NULL ((void *) 0)
# else
# define NULL 0x0
# endif /* !__STDC__ */
#endif /* !NULL */
/* If being compiled as part of bash, these will be satisfied from
variables.o. If being compiled as part of readline, they will
be satisfied from shell.o. */
extern char *sh_get_home_dir PARAMS((void));
extern char *sh_get_env_value PARAMS((const char *));
/* The default value of tilde_additional_prefixes. This is set to
whitespace preceding a tilde so that simple programs which do not
perform any word separation get desired behaviour. */
static const char *default_prefixes[] =
{ " ~", "\t~", (const char *)NULL };
/* The default value of tilde_additional_suffixes. This is set to
whitespace or newline so that simple programs which do not
perform any word separation get desired behaviour. */
static const char *default_suffixes[] =
{ " ", "\n", (const char *)NULL };
/* If non-null, this contains the address of a function that the application
wants called before trying the standard tilde expansions. The function
is called with the text sans tilde, and returns a malloc()'ed string
which is the expansion, or a NULL pointer if the expansion fails. */
tilde_hook_func_t *tilde_expansion_preexpansion_hook = (tilde_hook_func_t *)NULL;
/* If non-null, this contains the address of a function to call if the
standard meaning for expanding a tilde fails. The function is called
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
which is the expansion, or a NULL pointer if there is no expansion. */
tilde_hook_func_t *tilde_expansion_failure_hook = (tilde_hook_func_t *)NULL;
/* When non-null, this is a NULL terminated array of strings which
are duplicates for a tilde prefix. Bash uses this to expand
`=~' and `:~'. */
char **tilde_additional_prefixes = (char **)default_prefixes;
/* When non-null, this is a NULL terminated array of strings which match
the end of a username, instead of just "/". Bash sets this to
`:' and `=~'. */
char **tilde_additional_suffixes = (char **)default_suffixes;
static int tilde_find_prefix PARAMS((const char *, int *));
static int tilde_find_suffix PARAMS((const char *));
static char *isolate_tilde_prefix PARAMS((const char *, int *));
static char *glue_prefix_and_suffix PARAMS((char *, const char *, int));
/* Find the start of a tilde expansion in STRING, and return the index of
the tilde which starts the expansion. Place the length of the text
which identified this tilde starter in LEN, excluding the tilde itself. */
static int
tilde_find_prefix (string, len)
const char *string;
int *len;
{
register int i, j, string_len;
register char **prefixes;
prefixes = tilde_additional_prefixes;
string_len = strlen (string);
*len = 0;
if (*string == '\0' || *string == '~')
return (0);
if (prefixes)
{
for (i = 0; i < string_len; i++)
{
for (j = 0; prefixes[j]; j++)
{
if (strncmp (string + i, prefixes[j], strlen (prefixes[j])) == 0)
{
*len = strlen (prefixes[j]) - 1;
return (i + *len);
}
}
}
}
return (string_len);
}
/* Find the end of a tilde expansion in STRING, and return the index of
the character which ends the tilde definition. */
static int
tilde_find_suffix (string)
const char *string;
{
register int i, j, string_len;
register char **suffixes;
suffixes = tilde_additional_suffixes;
string_len = strlen (string);
for (i = 0; i < string_len; i++)
{
#if defined (__MSDOS__)
if (string[i] == '/' || string[i] == '\\' /* || !string[i] */)
#else
if (string[i] == '/' /* || !string[i] */)
#endif
break;
for (j = 0; suffixes && suffixes[j]; j++)
{
if (strncmp (string + i, suffixes[j], strlen (suffixes[j])) == 0)
return (i);
}
}
return (i);
}
/* Return a new string which is the result of tilde expanding STRING. */
char *
tilde_expand (string)
const char *string;
{
char *result;
int result_size, result_index;
result_index = result_size = 0;
if (result = strchr (string, '~'))
result = (char *)xmalloc (result_size = (strlen (string) + 16));
else
result = (char *)xmalloc (result_size = (strlen (string) + 1));
/* Scan through STRING expanding tildes as we come to them. */
while (1)
{
register int start, end;
char *tilde_word, *expansion;
int len;
/* Make START point to the tilde which starts the expansion. */
start = tilde_find_prefix (string, &len);
/* Copy the skipped text into the result. */
if ((result_index + start + 1) > result_size)
result = (char *)xrealloc (result, 1 + (result_size += (start + 20)));
strncpy (result + result_index, string, start);
result_index += start;
/* Advance STRING to the starting tilde. */
string += start;
/* Make END be the index of one after the last character of the
username. */
end = tilde_find_suffix (string);
/* If both START and END are zero, we are all done. */
if (!start && !end)
break;
/* Expand the entire tilde word, and copy it into RESULT. */
tilde_word = (char *)xmalloc (1 + end);
strncpy (tilde_word, string, end);
tilde_word[end] = '\0';
string += end;
expansion = tilde_expand_word (tilde_word);
free (tilde_word);
len = strlen (expansion);
#ifdef __CYGWIN__
/* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when
$HOME for `user' is /. On cygwin, // denotes a network drive. */
if (len > 1 || *expansion != '/' || *string != '/')
#endif
{
if ((result_index + len + 1) > result_size)
result = (char *)xrealloc (result, 1 + (result_size += (len + 20)));
strcpy (result + result_index, expansion);
result_index += len;
}
free (expansion);
}
result[result_index] = '\0';
return (result);
}
/* Take FNAME and return the tilde prefix we want expanded. If LENP is
non-null, the index of the end of the prefix into FNAME is returned in
the location it points to. */
static char *
isolate_tilde_prefix (fname, lenp)
const char *fname;
int *lenp;
{
char *ret;
int i;
ret = (char *)xmalloc (strlen (fname));
#if defined (__MSDOS__)
for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
#else
for (i = 1; fname[i] && fname[i] != '/'; i++)
#endif
ret[i - 1] = fname[i];
ret[i - 1] = '\0';
if (lenp)
*lenp = i;
return ret;
}
#if 0
/* Public function to scan a string (FNAME) beginning with a tilde and find
the portion of the string that should be passed to the tilde expansion
function. Right now, it just calls tilde_find_suffix and allocates new
memory, but it can be expanded to do different things later. */
char *
tilde_find_word (fname, flags, lenp)
const char *fname;
int flags, *lenp;
{
int x;
char *r;
x = tilde_find_suffix (fname);
if (x == 0)
{
r = savestring (fname);
if (lenp)
*lenp = 0;
}
else
{
r = (char *)xmalloc (1 + x);
strncpy (r, fname, x);
r[x] = '\0';
if (lenp)
*lenp = x;
}
return r;
}
#endif
/* Return a string that is PREFIX concatenated with SUFFIX starting at
SUFFIND. */
static char *
glue_prefix_and_suffix (prefix, suffix, suffind)
char *prefix;
const char *suffix;
int suffind;
{
char *ret;
int plen, slen;
plen = (prefix && *prefix) ? strlen (prefix) : 0;
slen = strlen (suffix + suffind);
ret = (char *)xmalloc (plen + slen + 1);
if (plen)
strcpy (ret, prefix);
strcpy (ret + plen, suffix + suffind);
return ret;
}
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
tilde. If there is no expansion, call tilde_expansion_failure_hook.
This always returns a newly-allocated string, never static storage. */
char *
tilde_expand_word (filename)
const char *filename;
{
char *dirname, *expansion, *username;
int user_len;
struct passwd *user_entry;
if (filename == 0)
return ((char *)NULL);
if (*filename != '~')
return (savestring (filename));
/* A leading `~/' or a bare `~' is *always* translated to the value of
$HOME or the home directory of the current user, regardless of any
preexpansion hook. */
if (filename[1] == '\0' || filename[1] == '/')
{
/* Prefix $HOME to the rest of the string. */
expansion = sh_get_env_value ("HOME");
/* If there is no HOME variable, look up the directory in
the password database. */
if (expansion == 0)
expansion = sh_get_home_dir ();
return (glue_prefix_and_suffix (expansion, filename, 1));
}
username = isolate_tilde_prefix (filename, &user_len);
if (tilde_expansion_preexpansion_hook)
{
expansion = (*tilde_expansion_preexpansion_hook) (username);
if (expansion)
{
dirname = glue_prefix_and_suffix (expansion, filename, user_len);
free (username);
free (expansion);
return (dirname);
}
}
/* No preexpansion hook, or the preexpansion hook failed. Look in the
password database. */
dirname = (char *)NULL;
#if defined (HAVE_GETPWNAM)
user_entry = getpwnam (username);
#else
user_entry = 0;
#endif
if (user_entry == 0)
{
/* If the calling program has a special syntax for expanding tildes,
and we couldn't find a standard expansion, then let them try. */
if (tilde_expansion_failure_hook)
{
expansion = (*tilde_expansion_failure_hook) (username);
if (expansion)
{
dirname = glue_prefix_and_suffix (expansion, filename, user_len);
free (expansion);
}
}
free (username);
/* If we don't have a failure hook, or if the failure hook did not
expand the tilde, return a copy of what we were passed. */
if (dirname == 0)
dirname = savestring (filename);
}
else
{
free (username);
dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len);
}
#if defined (HAVE_GETPWENT)
endpwent ();
#endif
return (dirname);
}
#if defined (TEST)
#undef NULL
#include <stdio.h>
main (argc, argv)
int argc;
char **argv;
{
char *result, line[512];
int done = 0;
while (!done)
{
printf ("~expand: ");
fflush (stdout);
if (!gets (line))
strcpy (line, "done");
if ((strcmp (line, "done") == 0) ||
(strcmp (line, "quit") == 0) ||
(strcmp (line, "exit") == 0))
{
done = 1;
break;
}
result = tilde_expand (line);
printf (" --> %s\n", result);
free (result);
}
exit (0);
}
static void memory_error_and_abort ();
static void *
xmalloc (bytes)
size_t bytes;
{
void *temp = (char *)malloc (bytes);
if (!temp)
memory_error_and_abort ();
return (temp);
}
static void *
xrealloc (pointer, bytes)
void *pointer;
int bytes;
{
void *temp;
if (!pointer)
temp = malloc (bytes);
else
temp = realloc (pointer, bytes);
if (!temp)
memory_error_and_abort ();
return (temp);
}
static void
memory_error_and_abort ()
{
fprintf (stderr, "readline: out of virtual memory\n");
abort ();
}
/*
* Local variables:
* compile-command: "gcc -g -DTEST -o tilde tilde.c"
* end:
*/
#endif /* TEST */
-1
View File
@@ -1 +0,0 @@
../tilde/tilde.h
+81
View File
@@ -0,0 +1,81 @@
/* tilde.h: Externally available variables and function in libtilde.a. */
/* Copyright (C) 1992 Free Software Foundation, Inc.
This file contains the Readline Library (the Library), a set of
routines for providing Emacs style line input to programs that ask
for it.
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_TILDE_H_)
# define _TILDE_H_
#ifdef __cplusplus
extern "C" {
#endif
/* A function can be defined using prototypes and compile on both ANSI C
and traditional C compilers with something like this:
extern char *func PARAMS((char *, char *, int)); */
#if !defined (PARAMS)
# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
# define PARAMS(protos) protos
# else
# define PARAMS(protos) ()
# endif
#endif
typedef char *tilde_hook_func_t PARAMS((char *));
/* If non-null, this contains the address of a function that the application
wants called before trying the standard tilde expansions. The function
is called with the text sans tilde, and returns a malloc()'ed string
which is the expansion, or a NULL pointer if the expansion fails. */
extern tilde_hook_func_t *tilde_expansion_preexpansion_hook;
/* If non-null, this contains the address of a function to call if the
standard meaning for expanding a tilde fails. The function is called
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
which is the expansion, or a NULL pointer if there is no expansion. */
extern tilde_hook_func_t *tilde_expansion_failure_hook;
/* When non-null, this is a NULL terminated array of strings which
are duplicates for a tilde prefix. Bash uses this to expand
`=~' and `:~'. */
extern char **tilde_additional_prefixes;
/* When non-null, this is a NULL terminated array of strings which match
the end of a username, instead of just "/". Bash sets this to
`:' and `=~'. */
extern char **tilde_additional_suffixes;
/* Return a new string which is the result of tilde expanding STRING. */
extern char *tilde_expand PARAMS((const char *));
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
extern char *tilde_expand_word PARAMS((const char *));
/* Find the portion of the string beginning with ~ that should be expanded. */
extern char *tilde_find_word PARAMS((const char *, int, int *));
#ifdef __cplusplus
}
#endif
#endif /* _TILDE_H_ */
+4
View File
@@ -1416,6 +1416,10 @@ _rl_vi_change_char (count, c, mb)
#endif
_rl_insert_char (1, c);
}
/* The cursor shall be left on the last character changed. */
rl_backward_char (1, c);
rl_end_undo_group ();
return (0);
-52
View File
@@ -1,52 +0,0 @@
typedef union {
WORD_DESC *word; /* the word that we read. */
int number; /* the number that we read. */
WORD_LIST *word_list;
COMMAND *command;
REDIRECT *redirect;
ELEMENT element;
PATTERN_LIST *pattern;
} YYSTYPE;
#define IF 257
#define THEN 258
#define ELSE 259
#define ELIF 260
#define FI 261
#define CASE 262
#define ESAC 263
#define FOR 264
#define SELECT 265
#define WHILE 266
#define UNTIL 267
#define DO 268
#define DONE 269
#define FUNCTION 270
#define COND_START 271
#define COND_END 272
#define COND_ERROR 273
#define IN 274
#define BANG 275
#define TIME 276
#define TIMEOPT 277
#define WORD 278
#define ASSIGNMENT_WORD 279
#define NUMBER 280
#define ARITH_CMD 281
#define ARITH_FOR_EXPRS 282
#define COND_CMD 283
#define AND_AND 284
#define OR_OR 285
#define GREATER_GREATER 286
#define LESS_LESS 287
#define LESS_AND 288
#define LESS_LESS_LESS 289
#define GREATER_AND 290
#define SEMI_SEMI 291
#define LESS_LESS_MINUS 292
#define AND_GREATER 293
#define LESS_GREATER 294
#define GREATER_BAR 295
#define yacc_EOF 296
extern YYSTYPE yylval;
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
+275 -217
View File
File diff suppressed because it is too large Load Diff