commit bash-20100525 snapshot

This commit is contained in:
Chet Ramey
2011-12-12 21:59:37 -05:00
parent eb0b2ad86b
commit 6faad6254a
160 changed files with 12731 additions and 588 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
/* xmbsrtowcs.c -- replacement function for mbsrtowcs */
/* Copyright (C) 2002-2004 Free Software Foundation, Inc.
/* Copyright (C) 2002-2010 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+5 -1
View File
@@ -219,7 +219,6 @@ xdupmbstowcs2 (destp, src)
}
#endif /* HAVE_MBSNRTOWCS */
/* Convert a multibyte string to a wide character string. Memory for the
new wide character string is obtained with malloc.
@@ -255,6 +254,11 @@ xdupmbstowcs (destp, indicesp, src)
return (size_t)-1;
}
#if HAVE_MBSNRTOWCS
if (indicesp == NULL)
return (xdupmbstowcs2 (destp, src));
#endif
memset (&state, '\0', sizeof(mbstate_t));
wsbuf_size = WSBUF_INC;
+2 -1
View File
@@ -1,6 +1,6 @@
/* bind.c -- key binding and startup file support for the readline library. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -1424,6 +1424,7 @@ static const struct {
{ "blink-matching-paren", &rl_blink_matching_paren, V_SPECIAL },
{ "byte-oriented", &rl_byte_oriented, 0 },
{ "completion-ignore-case", &_rl_completion_case_fold, 0 },
{ "completion-map-case", &_rl_completion_case_map, 0 },
{ "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
{ "disable-completion", &rl_inhibit_completion, 0 },
{ "echo-control-characters", &_rl_echo_control_chars, 0 },
+6
View File
@@ -1424,6 +1424,7 @@ static const struct {
{ "blink-matching-paren", &rl_blink_matching_paren, V_SPECIAL },
{ "byte-oriented", &rl_byte_oriented, 0 },
{ "completion-ignore-case", &_rl_completion_case_fold, 0 },
{ "completion-map-case", &_rl_completion_case_map, 0 },
{ "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
{ "disable-completion", &rl_inhibit_completion, 0 },
{ "echo-control-characters", &_rl_echo_control_chars, 0 },
@@ -2283,6 +2284,11 @@ _rl_get_string_variable_value (name)
}
else if (_rl_stricmp (name, "comment-begin") == 0)
return (_rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
else if (_rl_stricmp (name, "completion-display-width") == 0)
{
sprintf (numbuf, "%d", _rl_completion_columns);
return (numbuf);
}
else if (_rl_stricmp (name, "completion-prefix-display-length") == 0)
{
sprintf (numbuf, "%d", _rl_completion_prefix_display_length);
+64 -17
View File
@@ -119,6 +119,7 @@ static char **remove_duplicate_matches PARAMS((char **));
static void insert_match PARAMS((char *, int, int, char *));
static int append_to_match PARAMS((char *, int, int, int));
static void insert_all_matches PARAMS((char **, int, char *));
static int complete_fncmp PARAMS((const char *, int, const char *, int));
static void display_matches PARAMS((char **));
static int compute_lcd_of_matches PARAMS((char **, int, const char *));
static int postprocess_matches PARAMS((char ***, int));
@@ -158,9 +159,13 @@ int _rl_print_completions_horizontally;
#if defined (__MSDOS__) && !defined (__DJGPP__)
int _rl_completion_case_fold = 1;
#else
int _rl_completion_case_fold;
int _rl_completion_case_fold = 0;
#endif
/* Non-zero means that `-' and `_' are equivalent when comparing filenames
for completion. */
int _rl_completion_case_map = 0;
/* If zero, don't match hidden files (filenames beginning with a `.' on
Unix) when doing filename completion. */
int _rl_match_hidden_files = 1;
@@ -2056,6 +2061,62 @@ rl_username_completion_function (text, state)
#endif /* !__WIN32__ && !__OPENNT */
}
/* Return non-zero if CONVFN matches FILENAME up to the length of FILENAME
(FILENAME_LEN). If _rl_completion_case_fold is set, compare without
regard to the alphabetic case of characters. CONVFN is the possibly-
converted directory entry; FILENAME is what the user typed. */
static int
complete_fncmp (convfn, convlen, filename, filename_len)
const char *convfn;
int convlen;
const char *filename;
int filename_len;
{
register char *s1, *s2;
int d, len;
/* Otherwise, if these match up to the length of filename, then
it is a match. */
if (_rl_completion_case_fold && _rl_completion_case_map)
{
/* Case-insensitive comparison treating _ and - as equivalent */
if (filename_len == 0)
return 1;
if (convlen < filename_len)
return 0;
s1 = convfn;
s2 = filename;
len = filename_len;
do
{
d = _rl_to_lower (*s1) - _rl_to_lower (*s2);
/* *s1 == [-_] && *s2 == [-_] */
if ((*s1 == '-' || *s1 == '_') && (*s2 == '-' || *s2 == '_'))
d = 0;
if (d != 0)
return 0;
s1++; s2++; /* already checked convlen >= filename_len */
}
while (--len != 0);
return 1;
}
else if (_rl_completion_case_fold)
{
if ((_rl_to_lower (convfn[0]) == _rl_to_lower (filename[0])) &&
(convlen >= filename_len) &&
(_rl_strnicmp (filename, convfn, filename_len) == 0))
return 1;
}
else
{
if ((convfn[0] == filename[0]) &&
(convlen >= filename_len) &&
(strncmp (filename, convfn, filename_len) == 0))
return 1;
}
return 0;
}
/* Okay, now we write the entry_function for filename completion. In the
general case. Note that completion in the shell is a little different
because of all the pathnames that must be followed when looking up the
@@ -2198,22 +2259,8 @@ rl_filename_completion_function (text, state)
}
else
{
/* Otherwise, if these match up to the length of filename, then
it is a match. */
if (_rl_completion_case_fold)
{
if ((_rl_to_lower (convfn[0]) == _rl_to_lower (filename[0])) &&
(convlen >= filename_len) &&
(_rl_strnicmp (filename, convfn, filename_len) == 0))
break;
}
else
{
if ((convfn[0] == filename[0]) &&
(convlen >= filename_len) &&
(strncmp (filename, convfn, filename_len) == 0))
break;
}
if (complete_fncmp (convfn, convlen, filename, filename_len))
break;
}
}
+89 -18
View File
@@ -119,6 +119,7 @@ static char **remove_duplicate_matches PARAMS((char **));
static void insert_match PARAMS((char *, int, int, char *));
static int append_to_match PARAMS((char *, int, int, int));
static void insert_all_matches PARAMS((char **, int, char *));
static int complete_fncmp PARAMS((const char *, int, const char *, int));
static void display_matches PARAMS((char **));
static int compute_lcd_of_matches PARAMS((char **, int, const char *));
static int postprocess_matches PARAMS((char ***, int));
@@ -158,9 +159,13 @@ int _rl_print_completions_horizontally;
#if defined (__MSDOS__) && !defined (__DJGPP__)
int _rl_completion_case_fold = 1;
#else
int _rl_completion_case_fold;
int _rl_completion_case_fold = 0;
#endif
/* Non-zero means that `-' and `_' are equivalent when comparing filenames
for completion. */
int _rl_completion_case_map = 1;
/* If zero, don't match hidden files (filenames beginning with a `.' on
Unix) when doing filename completion. */
int _rl_match_hidden_files = 1;
@@ -173,7 +178,7 @@ int _rl_completion_prefix_display_length = 0;
/* The readline-private number of screen columns to use when displaying
matches. If < 0 or > _rl_screenwidth, it is ignored. */
int _rl_completion_columns = 0;
int _rl_completion_columns = -1;
/* Global variables available to applications using readline. */
@@ -1784,6 +1789,9 @@ rl_complete_internal (what_to_do)
int start, end, delimiter, found_quote, i, nontrivial_lcd;
char *text, *saved_line_buffer;
char quote_char;
#if 1
int tlen, mlen;
#endif
RL_SETSTATE(RL_STATE_COMPLETING);
@@ -1811,6 +1819,10 @@ rl_complete_internal (what_to_do)
/* nontrivial_lcd is set if the common prefix adds something to the word
being completed. */
nontrivial_lcd = matches && strcmp (text, matches[0]) != 0;
#if 1
if (what_to_do == '!' || what_to_do == '@')
tlen = strlen (text);
#endif
free (text);
if (matches == 0)
@@ -1844,8 +1856,25 @@ rl_complete_internal (what_to_do)
case '!':
case '@':
/* Insert the first match with proper quoting. */
#if 0
if (*matches[0])
insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, &quote_char);
#else
if (what_to_do == TAB)
{
if (*matches[0])
insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, &quote_char);
}
else if (*matches[0] && matches[1] == 0)
/* should we perform the check only if there are multiple matches? */
insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, &quote_char);
else if (*matches[0]) /* what_to_do != TAB && multiple matches */
{
mlen = *matches[0] ? strlen (matches[0]) : 0;
if (mlen >= tlen)
insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, &quote_char);
}
#endif
/* If there are more matches, ring the bell to indicate.
If we are in vi mode, Posix.2 says to not ring the bell.
@@ -2032,6 +2061,62 @@ rl_username_completion_function (text, state)
#endif /* !__WIN32__ && !__OPENNT */
}
/* Return non-zero if CONVFN matches FILENAME up to the length of FILENAME
(FILENAME_LEN). If _rl_completion_case_fold is set, compare without
regard to the alphabetic case of characters. CONVFN is the possibly-
converted directory entry; FILENAME is what the user typed. */
static int
complete_fncmp (convfn, convlen, filename, filename_len)
const char *convfn;
int convlen;
const char *filename;
int filename_len;
{
register char *s1, *s2;
int d, len;
/* Otherwise, if these match up to the length of filename, then
it is a match. */
if (_rl_completion_case_fold && _rl_completion_case_map)
{
/* Case-insensitive comparison treating _ and - as equivalent */
if (filename_len == 0)
return 1;
if (convlen < filename_len)
return 0;
s1 = convfn;
s2 = filename;
len = filename_len;
do
{
d = _rl_to_lower (*s1) - _rl_to_lower (*s2);
/* *s1 == [-_] && *s2 == [-_] */
if ((*s1 == '-' || *s1 == '_') && (*s2 == '-' || *s2 == '_'))
d = 0;
if (d != 0)
return 0;
s1++; s2++; /* already checked convlen >= filename_len */
}
while (--len != 0);
return 1;
}
else if (_rl_completion_case_fold)
{
if ((_rl_to_lower (convfn[0]) == _rl_to_lower (filename[0])) &&
(convlen >= filename_len) &&
(_rl_strnicmp (filename, convfn, filename_len) == 0))
return 1;
}
else
{
if ((convfn[0] == filename[0]) &&
(convlen >= filename_len) &&
(strncmp (filename, convfn, filename_len) == 0))
return 1;
}
return 0;
}
/* Okay, now we write the entry_function for filename completion. In the
general case. Note that completion in the shell is a little different
because of all the pathnames that must be followed when looking up the
@@ -2174,22 +2259,8 @@ rl_filename_completion_function (text, state)
}
else
{
/* Otherwise, if these match up to the length of filename, then
it is a match. */
if (_rl_completion_case_fold)
{
if ((_rl_to_lower (convfn[0]) == _rl_to_lower (filename[0])) &&
(convlen >= filename_len) &&
(_rl_strnicmp (filename, convfn, filename_len) == 0))
break;
}
else
{
if ((convfn[0] == filename[0]) &&
(convlen >= filename_len) &&
(strncmp (filename, convfn, filename_len) == 0))
break;
}
if (complete_fncmp (convfn, convlen, filename, filename_len))
break;
}
}
+6 -1
View File
@@ -8,7 +8,7 @@
.\"
.\" Last Change: Thu Apr 22 18:59:21 EDT 2010
.\"
.TH READLINE 3 "2009 April 22" "GNU Readline 6.1"
.TH READLINE 3 "2010 April 22" "GNU Readline 6.1"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@@ -373,6 +373,11 @@ The default value is -1.
If set to \fBOn\fP, readline performs filename matching and completion
in a case\-insensitive fashion.
.TP
.B completion\-map\-case (Off)
If set to \fBOn\fP, and \fBcompletion\-ignore\-case\fP is enabled, readline
treats hyphens (\fI\-\fP) and underscores (\fI_\fP) as equivalent when
performing case\-insensitive filename matching and completion.
.TP
.B completion\-prefix\-display\-length (0)
The length in characters of the common prefix of a list of possible
completions that is displayed without modification. When set to a
+11
View File
@@ -373,6 +373,11 @@ The default value is -1.
If set to \fBOn\fP, readline performs filename matching and completion
in a case\-insensitive fashion.
.TP
.B completion\-map\-case (Off)
If set to \fBOn\fP, and \fBcompletion\-ignore\-case\fP is enabled, readline
treats hyphens (\fI\-\fP) and underscores (\fI_\fP) as equivalent when
performing case\-insensitive filename matching and completion.
.TP
.B completion\-prefix\-display\-length (0)
The length in characters of the common prefix of a list of possible
completions that is displayed without modification. When set to a
@@ -931,6 +936,12 @@ only attempts filename completion under certain circumstances.
.TP
.B possible\-completions (M\-?)
List the possible completions of the text before point.
When displaying completions, readline sets the number of columns used
for display to the value of \fBcompletion-display-width\fP, the value of
the environment variable
.SM
.BR COLUMNS ,
or the screen width, in that order.
.TP
.B insert\-completions (M\-*)
Insert all completions of the text before point
+6
View File
@@ -446,6 +446,12 @@ If set to @samp{on}, Readline performs filename matching and completion
in a case-insensitive fashion.
The default value is @samp{off}.
@item completion-map-case
@vindex completion-map-case
If set to @samp{on}, and @var{completion-ignore-case} is enabled, Readline
treats hyphens (@samp{-}) and underscores (@samp{_}) as equivalent when
performing case-insensitive filename matching and completion.
@item completion-prefix-display-length
@vindex completion-prefix-display-length
The length in characters of the common prefix of a list of possible
+3 -3
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2010 Free Software Foundation, Inc.
@set EDITION 6.1
@set VERSION 6.1
@set UPDATED April 22 2010
@set UPDATED-MONTH April 2010
@set UPDATED May 292010
@set UPDATED-MONTH May 2010
@set LASTCHANGE Thu Apr 22 18:59:44 EDT 2010
@set LASTCHANGE Sat May 29 17:14:10 EDT 2010
+2 -2
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2010 Free Software Foundation, Inc.
@set EDITION 6.1
@set VERSION 6.1
@set UPDATED April 17 2010
@set UPDATED April 22 2010
@set UPDATED-MONTH April 2010
@set LASTCHANGE Sat Apr 17 23:45:29 EDT 2010
@set LASTCHANGE Thu Apr 22 18:59:44 EDT 2010
+6 -1
View File
@@ -1,6 +1,6 @@
/* funmap.c -- attach names to functions. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -148,6 +148,8 @@ static const FUNMAP default_funmap[] = {
{ "vi-append-mode", rl_vi_append_mode },
{ "vi-arg-digit", rl_vi_arg_digit },
{ "vi-back-to-indent", rl_vi_back_to_indent },
{ "vi-backward-bigword", rl_vi_bWord },
{ "vi-backward-word", rl_vi_bword },
{ "vi-bWord", rl_vi_bWord },
{ "vi-bword", rl_vi_bword },
{ "vi-change-case", rl_vi_change_case },
@@ -160,12 +162,15 @@ static const FUNMAP default_funmap[] = {
{ "vi-delete-to", rl_vi_delete_to },
{ "vi-eWord", rl_vi_eWord },
{ "vi-editing-mode", rl_vi_editing_mode },
{ "vi-end-bigword", rl_vi_eWord },
{ "vi-end-word", rl_vi_end_word },
{ "vi-eof-maybe", rl_vi_eof_maybe },
{ "vi-eword", rl_vi_eword },
{ "vi-fWord", rl_vi_fWord },
{ "vi-fetch-history", rl_vi_fetch_history },
{ "vi-first-print", rl_vi_first_print },
{ "vi-forward-bigword", rl_vi_fWord },
{ "vi-forward-word", rl_vi_fword },
{ "vi-fword", rl_vi_fword },
{ "vi-goto-mark", rl_vi_goto_mark },
{ "vi-insert-beg", rl_vi_insert_beg },
+263
View File
@@ -0,0 +1,263 @@
/* funmap.c -- attach names to functions. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#if !defined (BUFSIZ)
#include <stdio.h>
#endif /* BUFSIZ */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include "rlconf.h"
#include "readline.h"
#include "xmalloc.h"
#ifdef __STDC__
typedef int QSFUNC (const void *, const void *);
#else
typedef int QSFUNC ();
#endif
extern int _rl_qsort_string_compare PARAMS((char **, char **));
FUNMAP **funmap;
static int funmap_size;
static int funmap_entry;
/* After initializing the function map, this is the index of the first
program specific function. */
int funmap_program_specific_entry_start;
static const FUNMAP default_funmap[] = {
{ "abort", rl_abort },
{ "accept-line", rl_newline },
{ "arrow-key-prefix", rl_arrow_keys },
{ "backward-byte", rl_backward_byte },
{ "backward-char", rl_backward_char },
{ "backward-delete-char", rl_rubout },
{ "backward-kill-line", rl_backward_kill_line },
{ "backward-kill-word", rl_backward_kill_word },
{ "backward-word", rl_backward_word },
{ "beginning-of-history", rl_beginning_of_history },
{ "beginning-of-line", rl_beg_of_line },
{ "call-last-kbd-macro", rl_call_last_kbd_macro },
{ "capitalize-word", rl_capitalize_word },
{ "character-search", rl_char_search },
{ "character-search-backward", rl_backward_char_search },
{ "clear-screen", rl_clear_screen },
{ "complete", rl_complete },
{ "copy-backward-word", rl_copy_backward_word },
{ "copy-forward-word", rl_copy_forward_word },
{ "copy-region-as-kill", rl_copy_region_to_kill },
{ "delete-char", rl_delete },
{ "delete-char-or-list", rl_delete_or_show_completions },
{ "delete-horizontal-space", rl_delete_horizontal_space },
{ "digit-argument", rl_digit_argument },
{ "do-lowercase-version", rl_do_lowercase_version },
{ "downcase-word", rl_downcase_word },
{ "dump-functions", rl_dump_functions },
{ "dump-macros", rl_dump_macros },
{ "dump-variables", rl_dump_variables },
{ "emacs-editing-mode", rl_emacs_editing_mode },
{ "end-kbd-macro", rl_end_kbd_macro },
{ "end-of-history", rl_end_of_history },
{ "end-of-line", rl_end_of_line },
{ "exchange-point-and-mark", rl_exchange_point_and_mark },
{ "forward-backward-delete-char", rl_rubout_or_delete },
{ "forward-byte", rl_forward_byte },
{ "forward-char", rl_forward_char },
{ "forward-search-history", rl_forward_search_history },
{ "forward-word", rl_forward_word },
{ "history-search-backward", rl_history_search_backward },
{ "history-search-forward", rl_history_search_forward },
{ "insert-comment", rl_insert_comment },
{ "insert-completions", rl_insert_completions },
{ "kill-whole-line", rl_kill_full_line },
{ "kill-line", rl_kill_line },
{ "kill-region", rl_kill_region },
{ "kill-word", rl_kill_word },
{ "menu-complete", rl_menu_complete },
{ "menu-complete-backward", rl_backward_menu_complete },
{ "next-history", rl_get_next_history },
{ "non-incremental-forward-search-history", rl_noninc_forward_search },
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
{ "old-menu-complete", rl_old_menu_complete },
{ "overwrite-mode", rl_overwrite_mode },
#ifdef __CYGWIN__
{ "paste-from-clipboard", rl_paste_from_clipboard },
#endif
{ "possible-completions", rl_possible_completions },
{ "previous-history", rl_get_previous_history },
{ "quoted-insert", rl_quoted_insert },
{ "re-read-init-file", rl_re_read_init_file },
{ "redraw-current-line", rl_refresh_line},
{ "reverse-search-history", rl_reverse_search_history },
{ "revert-line", rl_revert_line },
{ "self-insert", rl_insert },
{ "set-mark", rl_set_mark },
{ "skip-csi-sequence", rl_skip_csi_sequence },
{ "start-kbd-macro", rl_start_kbd_macro },
{ "tab-insert", rl_tab_insert },
{ "tilde-expand", rl_tilde_expand },
{ "transpose-chars", rl_transpose_chars },
{ "transpose-words", rl_transpose_words },
{ "tty-status", rl_tty_status },
{ "undo", rl_undo_command },
{ "universal-argument", rl_universal_argument },
{ "unix-filename-rubout", rl_unix_filename_rubout },
{ "unix-line-discard", rl_unix_line_discard },
{ "unix-word-rubout", rl_unix_word_rubout },
{ "upcase-word", rl_upcase_word },
{ "yank", rl_yank },
{ "yank-last-arg", rl_yank_last_arg },
{ "yank-nth-arg", rl_yank_nth_arg },
{ "yank-pop", rl_yank_pop },
#if defined (VI_MODE)
{ "vi-append-eol", rl_vi_append_eol },
{ "vi-append-mode", rl_vi_append_mode },
{ "vi-arg-digit", rl_vi_arg_digit },
{ "vi-back-to-indent", rl_vi_back_to_indent },
{ "vi-backward-bigword", rl_vi_bWord },
{ "vi-backward-word", rl_vi_bword },
{ "vi-bWord", rl_vi_bWord },
{ "vi-bword", rl_vi_bword },
{ "vi-change-case", rl_vi_change_case },
{ "vi-change-char", rl_vi_change_char },
{ "vi-change-to", rl_vi_change_to },
{ "vi-char-search", rl_vi_char_search },
{ "vi-column", rl_vi_column },
{ "vi-complete", rl_vi_complete },
{ "vi-delete", rl_vi_delete },
{ "vi-delete-to", rl_vi_delete_to },
{ "vi-eWord", rl_vi_eWord },
{ "vi-editing-mode", rl_vi_editing_mode },
{ "vi-end-bigword", rl_vi_eWord },
{ "vi-end-word", rl_vi_end_word },
{ "vi-eof-maybe", rl_vi_eof_maybe },
{ "vi-eword", rl_vi_eword },
{ "vi-fWord", rl_vi_fWord },
{ "vi-fetch-history", rl_vi_fetch_history },
{ "vi-first-print", rl_vi_first_print },
{ "vi-forward-bigword", rl_vi_fWord },
{ "vi-forward-word", rl_vi_fword },
{ "vi-fword", rl_vi_fword },
{ "vi-goto-mark", rl_vi_goto_mark },
{ "vi-insert-beg", rl_vi_insert_beg },
{ "vi-insertion-mode", rl_vi_insertion_mode },
{ "vi-match", rl_vi_match },
{ "vi-movement-mode", rl_vi_movement_mode },
{ "vi-next-word", rl_vi_next_word },
{ "vi-overstrike", rl_vi_overstrike },
{ "vi-overstrike-delete", rl_vi_overstrike_delete },
{ "vi-prev-word", rl_vi_prev_word },
{ "vi-put", rl_vi_put },
{ "vi-redo", rl_vi_redo },
{ "vi-replace", rl_vi_replace },
{ "vi-rubout", rl_vi_rubout },
{ "vi-search", rl_vi_search },
{ "vi-search-again", rl_vi_search_again },
{ "vi-set-mark", rl_vi_set_mark },
{ "vi-subst", rl_vi_subst },
{ "vi-tilde-expand", rl_vi_tilde_expand },
{ "vi-yank-arg", rl_vi_yank_arg },
{ "vi-yank-to", rl_vi_yank_to },
#endif /* VI_MODE */
{(char *)NULL, (rl_command_func_t *)NULL }
};
int
rl_add_funmap_entry (name, function)
const char *name;
rl_command_func_t *function;
{
if (funmap_entry + 2 >= funmap_size)
{
funmap_size += 64;
funmap = (FUNMAP **)xrealloc (funmap, funmap_size * sizeof (FUNMAP *));
}
funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP));
funmap[funmap_entry]->name = name;
funmap[funmap_entry]->function = function;
funmap[++funmap_entry] = (FUNMAP *)NULL;
return funmap_entry;
}
static int funmap_initialized;
/* Make the funmap contain all of the default entries. */
void
rl_initialize_funmap ()
{
register int i;
if (funmap_initialized)
return;
for (i = 0; default_funmap[i].name; i++)
rl_add_funmap_entry (default_funmap[i].name, default_funmap[i].function);
funmap_initialized = 1;
funmap_program_specific_entry_start = i;
}
/* Produce a NULL terminated array of known function names. The array
is sorted. The array itself is allocated, but not the strings inside.
You should free () the array when you done, but not the pointrs. */
const char **
rl_funmap_names ()
{
const char **result;
int result_size, result_index;
/* Make sure that the function map has been initialized. */
rl_initialize_funmap ();
for (result_index = result_size = 0, result = (const char **)NULL; funmap[result_index]; result_index++)
{
if (result_index + 2 > result_size)
{
result_size += 20;
result = (const char **)xrealloc (result, result_size * sizeof (char *));
}
result[result_index] = funmap[result_index]->name;
result[result_index + 1] = (char *)NULL;
}
qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
return (result);
}
+1 -1
View File
@@ -1,6 +1,6 @@
/* histexpand.c -- history expansion. */
/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
/* Copyright (C) 1989-2010 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
+1 -1
View File
@@ -1472,7 +1472,7 @@ history_tokenize_word (string, ind)
}
}
/* same mechanism also used for <(...)/>(...) above */
/* same code also used for $(...)/<(...)/>(...) above */
if (member (string[i], "!@?+*"))
{
int peek = string[i + 1];
+1 -1
View File
@@ -1,6 +1,6 @@
/* histfile.c - functions to manipulate the history file. */
/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
/* Copyright (C) 1989-2010 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
+8 -3
View File
@@ -126,8 +126,12 @@ history_filename (filename)
if (home == 0)
{
#if 0
home = ".";
home_len = 1;
#else
return (NULL);
#endif
}
else
home_len = strlen (home);
@@ -179,7 +183,7 @@ read_history_range (filename, from, to)
buffer = last_ts = (char *)NULL;
input = history_filename (filename);
file = open (input, O_RDONLY|O_BINARY, 0666);
file = input ? open (input, O_RDONLY|O_BINARY, 0666) : -1;
if ((file < 0) || (fstat (file, &finfo) == -1))
goto error_and_exit;
@@ -314,7 +318,7 @@ history_truncate_file (fname, lines)
buffer = (char *)NULL;
filename = history_filename (fname);
file = open (filename, O_RDONLY|O_BINARY, 0666);
file = filename ? open (filename, O_RDONLY|O_BINARY, 0666) : -1;
rv = 0;
/* Don't try to truncate non-regular files. */
@@ -436,9 +440,10 @@ history_do_write (filename, nelements, overwrite)
mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
#endif
output = history_filename (filename);
file = output ? open (output, mode, 0600) : -1;
rv = 0;
if ((file = open (output, mode, 0600)) == -1)
if (file == -1)
{
FREE (output);
return (errno);
+1 -1
View File
@@ -1,6 +1,6 @@
/* input.c -- character input functions for readline. */
/* Copyright (C) 1994-2009 Free Software Foundation, Inc.
/* Copyright (C) 1994-2010 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
+7 -6
View File
@@ -133,7 +133,6 @@ rl_get_char (key)
#endif
pop_index = 0;
fprintf(stderr, "rl_get_char: returning 1 (key = %d)\n", *key);
return (1);
}
@@ -428,17 +427,19 @@ rl_read_key ()
/* If the user has an event function, then call it periodically. */
if (rl_event_hook)
{
while (rl_event_hook && rl_get_char (&c) == 0)
while (rl_event_hook)
{
(*rl_event_hook) ();
RL_CHECK_SIGNALS ();
if (rl_done) /* XXX - experimental */
return ('\n');
if (rl_gather_tyi () < 0) /* XXX - EIO */
{
rl_done = 1;
return ('\n');
}
RL_CHECK_SIGNALS ();
if (rl_get_char (&c) != 0)
break;
if (rl_done) /* XXX - experimental */
return ('\n');
(*rl_event_hook) ();
}
}
else
+24 -2
View File
@@ -1,7 +1,7 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
/* Copyright (C) 1999-2010 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -120,7 +120,28 @@ typedef struct __rl_keyseq_context
int childval;
} _rl_keyseq_cxt;
/* fill in more as needed */
/* vi-mode commands that use result of motion command to define boundaries */
#define VIM_DELETE 0x01
#define VIM_CHANGE 0x02
#define VIM_YANK 0x04
/* various states for vi-mode commands that use motion commands. reflects
RL_READLINE_STATE */
#define VMSTATE_READ 0x01
#define VMSTATE_NUMARG 0x02
typedef struct __rl_vimotion_context
{
int op;
int state;
int flags; /* reserved */
_rl_arg_cxt ncxt;
int numeric_arg;
int start, end; /* rl_point, rl_end */
int key, motion; /* initial key, motion command */
} _rl_vimotion_cxt;
/* fill in more as needed */
/* `Generic' callback data and functions */
typedef struct __rl_callback_generic_arg
{
@@ -388,6 +409,7 @@ extern int _rl_completion_prefix_display_length;
extern int _rl_completion_columns;
extern int _rl_print_completions_horizontally;
extern int _rl_completion_case_fold;
extern int _rl_completion_case_map;
extern int _rl_match_hidden_files;
extern int _rl_page_completions;
extern int _rl_skip_completed_text;
+20 -2
View File
@@ -1,7 +1,7 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
/* Copyright (C) 1999-2010 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -120,7 +120,23 @@ typedef struct __rl_keyseq_context
int childval;
} _rl_keyseq_cxt;
/* fill in more as needed */
/* vi-mode commands that use result of motion command to define boundaries */
#define VIM_DELETE 0x01
#define VIM_CHANGE 0x02
#define VIM_YANK 0x04
typedef struct __rl_vimotion_context
{
int op;
int state;
int flags; /* reserved */
_rl_arg_cxt ncxt;
int numeric_arg;
int start, end; /* rl_point, rl_end */
int key, motion; /* initial key, motion command */
} _rl_vimotion_cxt;
/* fill in more as needed */
/* `Generic' callback data and functions */
typedef struct __rl_callback_generic_arg
{
@@ -385,8 +401,10 @@ extern int _rl_complete_show_unmodified;
extern int _rl_complete_mark_directories;
extern int _rl_complete_mark_symlink_dirs;
extern int _rl_completion_prefix_display_length;
extern int _rl_completion_columns;
extern int _rl_print_completions_horizontally;
extern int _rl_completion_case_fold;
extern int _rl_completion_case_map;
extern int _rl_match_hidden_files;
extern int _rl_page_completions;
extern int _rl_skip_completed_text;
+1 -1
View File
@@ -1,6 +1,6 @@
/* text.c -- text handling commands for readline. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
+3
View File
@@ -1495,6 +1495,9 @@ _rl_char_search_internal (count, dir, schar)
int prepos;
#endif
if (dir == 0)
return -1;
pos = rl_point;
inc = (dir < 0) ? -1 : 1;
while (count)
+33 -18
View File
@@ -1,6 +1,6 @@
/* util.c -- readline utility functions */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -366,41 +366,56 @@ _rl_strpbrk (string1, string2)
#if !defined (HAVE_STRCASECMP)
/* Compare at most COUNT characters from string1 to string2. Case
doesn't matter. */
doesn't matter (strncasecmp). */
int
_rl_strnicmp (string1, string2, count)
char *string1, *string2;
int count;
{
register char ch1, ch2;
register char *s1, *s2;
int d;
while (count)
if (count <= 0 || (string1 == string2))
return 0;
s1 = string1;
s2 = string2;
do
{
ch1 = *string1++;
ch2 = *string2++;
if (_rl_to_upper(ch1) == _rl_to_upper(ch2))
count--;
else
d = _rl_to_lower (*s1) - _rl_to_lower (*s2); /* XXX - cast to unsigned char? */
if (d != 0)
return d;
if (*s1++ == '\0')
break;
s2++;
}
return (count);
while (--count != 0)
return (0);
}
/* strcmp (), but caseless. */
/* strcmp (), but caseless (strcasecmp). */
int
_rl_stricmp (string1, string2)
char *string1, *string2;
{
register char ch1, ch2;
register char *s1, *s2;
int d;
while (*string1 && *string2)
s1 = string1;
s2 = string2;
if (s1 == s2)
return 0;
while ((d = _rl_to_lower (*s1) - _rl_to_lower (*s2)) == 0)
{
ch1 = *string1++;
ch2 = *string2++;
if (_rl_to_upper(ch1) != _rl_to_upper(ch2))
return (1);
if (*s1++ == '\0')
return 0;
s2++;
}
return (*string1 - *string2);
return (d);
}
#endif /* !HAVE_STRCASECMP */
+526
View File
@@ -0,0 +1,526 @@
/* util.c -- readline utility functions */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
#include "posixjmp.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h> /* for _POSIX_VERSION */
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include <stdio.h>
#include <ctype.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
#if defined (TIOCSTAT_IN_SYS_IOCTL)
# include <sys/ioctl.h>
#endif /* TIOCSTAT_IN_SYS_IOCTL */
/* Some standard library routines. */
#include "readline.h"
#include "rlprivate.h"
#include "xmalloc.h"
/* **************************************************************** */
/* */
/* Utility Functions */
/* */
/* **************************************************************** */
/* Return 0 if C is not a member of the class of characters that belong
in words, or 1 if it is. */
int _rl_allow_pathname_alphabetic_chars = 0;
static const char * const pathname_alphabetic_chars = "/-_=~.#$";
int
rl_alphabetic (c)
int c;
{
if (ALPHABETIC (c))
return (1);
return (_rl_allow_pathname_alphabetic_chars &&
strchr (pathname_alphabetic_chars, c) != NULL);
}
#if defined (HANDLE_MULTIBYTE)
int
_rl_walphabetic (wchar_t wc)
{
int c;
if (iswalnum (wc))
return (1);
c = wc & 0177;
return (_rl_allow_pathname_alphabetic_chars &&
strchr (pathname_alphabetic_chars, c) != NULL);
}
#endif
/* How to abort things. */
int
_rl_abort_internal ()
{
rl_ding ();
rl_clear_message ();
_rl_reset_argument ();
rl_clear_pending_input ();
RL_UNSETSTATE (RL_STATE_MACRODEF);
while (rl_executing_macro)
_rl_pop_executing_macro ();
rl_last_func = (rl_command_func_t *)NULL;
longjmp (_rl_top_level, 1);
return (0);
}
int
rl_abort (count, key)
int count, key;
{
return (_rl_abort_internal ());
}
int
_rl_null_function (count, key)
int count, key;
{
return 0;
}
int
rl_tty_status (count, key)
int count, key;
{
#if defined (TIOCSTAT)
ioctl (1, TIOCSTAT, (char *)0);
rl_refresh_line (count, key);
#else
rl_ding ();
#endif
return 0;
}
/* Return a copy of the string between FROM and TO.
FROM is inclusive, TO is not. */
char *
rl_copy_text (from, to)
int from, to;
{
register int length;
char *copy;
/* Fix it if the caller is confused. */
if (from > to)
SWAP (from, to);
length = to - from;
copy = (char *)xmalloc (1 + length);
strncpy (copy, rl_line_buffer + from, length);
copy[length] = '\0';
return (copy);
}
/* Increase the size of RL_LINE_BUFFER until it has enough space to hold
LEN characters. */
void
rl_extend_line_buffer (len)
int len;
{
while (len >= rl_line_buffer_len)
{
rl_line_buffer_len += DEFAULT_BUFFER_SIZE;
rl_line_buffer = (char *)xrealloc (rl_line_buffer, rl_line_buffer_len);
}
_rl_set_the_line ();
}
/* A function for simple tilde expansion. */
int
rl_tilde_expand (ignore, key)
int ignore, key;
{
register int start, end;
char *homedir, *temp;
int len;
end = rl_point;
start = end - 1;
if (rl_point == rl_end && rl_line_buffer[rl_point] == '~')
{
homedir = tilde_expand ("~");
_rl_replace_text (homedir, start, end);
xfree (homedir);
return (0);
}
else if (rl_line_buffer[start] != '~')
{
for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--)
;
start++;
}
end = start;
do
end++;
while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end);
if (whitespace (rl_line_buffer[end]) || end >= rl_end)
end--;
/* If the first character of the current word is a tilde, perform
tilde expansion and insert the result. If not a tilde, do
nothing. */
if (rl_line_buffer[start] == '~')
{
len = end - start + 1;
temp = (char *)xmalloc (len + 1);
strncpy (temp, rl_line_buffer + start, len);
temp[len] = '\0';
homedir = tilde_expand (temp);
xfree (temp);
_rl_replace_text (homedir, start, end);
xfree (homedir);
}
return (0);
}
#if defined (USE_VARARGS)
void
#if defined (PREFER_STDARG)
_rl_ttymsg (const char *format, ...)
#else
_rl_ttymsg (va_alist)
va_dcl
#endif
{
va_list args;
#if defined (PREFER_VARARGS)
char *format;
#endif
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
format = va_arg (args, char *);
#endif
fprintf (stderr, "readline: ");
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
fflush (stderr);
va_end (args);
rl_forced_update_display ();
}
void
#if defined (PREFER_STDARG)
_rl_errmsg (const char *format, ...)
#else
_rl_errmsg (va_alist)
va_dcl
#endif
{
va_list args;
#if defined (PREFER_VARARGS)
char *format;
#endif
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
format = va_arg (args, char *);
#endif
fprintf (stderr, "readline: ");
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
fflush (stderr);
va_end (args);
}
#else /* !USE_VARARGS */
void
_rl_ttymsg (format, arg1, arg2)
char *format;
{
fprintf (stderr, "readline: ");
fprintf (stderr, format, arg1, arg2);
fprintf (stderr, "\n");
rl_forced_update_display ();
}
void
_rl_errmsg (format, arg1, arg2)
char *format;
{
fprintf (stderr, "readline: ");
fprintf (stderr, format, arg1, arg2);
fprintf (stderr, "\n");
}
#endif /* !USE_VARARGS */
/* **************************************************************** */
/* */
/* String Utility Functions */
/* */
/* **************************************************************** */
/* Determine if s2 occurs in s1. If so, return a pointer to the
match in s1. The compare is case insensitive. */
char *
_rl_strindex (s1, s2)
register const char *s1, *s2;
{
register int i, l, len;
for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
if (_rl_strnicmp (s1 + i, s2, l) == 0)
return ((char *) (s1 + i));
return ((char *)NULL);
}
#ifndef HAVE_STRPBRK
/* Find the first occurrence in STRING1 of any character from STRING2.
Return a pointer to the character in STRING1. */
char *
_rl_strpbrk (string1, string2)
const char *string1, *string2;
{
register const char *scan;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
register int i, v;
memset (&ps, 0, sizeof (mbstate_t));
#endif
for (; *string1; string1++)
{
for (scan = string2; *scan; scan++)
{
if (*string1 == *scan)
return ((char *)string1);
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
v = _rl_get_char_len (string1, &ps);
if (v > 1)
string1 += v - 1; /* -1 to account for auto-increment in loop */
}
#endif
}
return ((char *)NULL);
}
#endif
#if !defined (HAVE_STRCASECMP)
/* Compare at most COUNT characters from string1 to string2. Case
doesn't matter (strncasecmp). */
int
_rl_strnicmp (string1, string2, count)
char *string1, *string2;
int count;
{
register char *s1, *s2;
int d;
if (count <= 0 || (string1 == string2))
return 0;
s1 = string1;
s2 = string2;
do
{
d = _rl_to_lower (*s1) - _rl_to_lower (*s2); /* XXX - cast to unsigned char? */
if (d != 0)
return d;
if (*s1++ == '\0')
break;
s2++;
}
while (--count != 0)
return (0);
}
/* strcmp (), but caseless (strcasecmp). */
int
_rl_stricmp (string1, string2)
char *string1, *string2;
{
register char *s1, *s2;
int d;
s1 = string1;
s2 = string2;
if (s1 == s2)
return 0;
while ((d = _rl_to_lower (*s1) - _rl_to_lower (*s2)) == 0)
{
if (*s1++ == '\0')
return 0;
s2++;
}
return (d);
}
#endif /* !HAVE_STRCASECMP */
/* Stupid comparison routine for qsort () ing strings. */
int
_rl_qsort_string_compare (s1, s2)
char **s1, **s2;
{
#if defined (HAVE_STRCOLL)
return (strcoll (*s1, *s2));
#else
int result;
result = **s1 - **s2;
if (result == 0)
result = strcmp (*s1, *s2);
return result;
#endif
}
/* Function equivalents for the macros defined in chardefs.h. */
#define FUNCTION_FOR_MACRO(f) int (f) (c) int c; { return f (c); }
FUNCTION_FOR_MACRO (_rl_digit_p)
FUNCTION_FOR_MACRO (_rl_digit_value)
FUNCTION_FOR_MACRO (_rl_lowercase_p)
FUNCTION_FOR_MACRO (_rl_pure_alphabetic)
FUNCTION_FOR_MACRO (_rl_to_lower)
FUNCTION_FOR_MACRO (_rl_to_upper)
FUNCTION_FOR_MACRO (_rl_uppercase_p)
/* A convenience function, to force memory deallocation to be performed
by readline. DLLs on Windows apparently require this. */
void
rl_free (mem)
void *mem;
{
if (mem)
free (mem);
}
/* Backwards compatibility, now that savestring has been removed from
all `public' readline header files. */
#undef _rl_savestring
char *
_rl_savestring (s)
const char *s;
{
return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s)));
}
#if defined (USE_VARARGS)
static FILE *_rl_tracefp;
void
#if defined (PREFER_STDARG)
_rl_trace (const char *format, ...)
#else
_rl_trace (va_alist)
va_dcl
#endif
{
va_list args;
#if defined (PREFER_VARARGS)
char *format;
#endif
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
format = va_arg (args, char *);
#endif
if (_rl_tracefp == 0)
_rl_tropen ();
vfprintf (_rl_tracefp, format, args);
fprintf (_rl_tracefp, "\n");
fflush (_rl_tracefp);
va_end (args);
}
int
_rl_tropen ()
{
char fnbuf[128];
if (_rl_tracefp)
fclose (_rl_tracefp);
sprintf (fnbuf, "/var/tmp/rltrace.%ld", getpid());
unlink(fnbuf);
_rl_tracefp = fopen (fnbuf, "w+");
return _rl_tracefp != 0;
}
int
_rl_trclose ()
{
int r;
r = fclose (_rl_tracefp);
_rl_tracefp = 0;
return r;
}
#endif
+158 -37
View File
@@ -1,7 +1,7 @@
/* vi_mode.c -- A vi emulation mode for Bash.
Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -65,6 +65,8 @@
int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */
_rl_vimotion_cxt *_rl_vimvcxt = 0;
/* Non-zero means enter insertion mode. */
static int _rl_vi_doing_insert;
@@ -128,6 +130,12 @@ static int _rl_vi_callback_change_char PARAMS((_rl_callback_generic_arg *));
static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *));
#endif
static int vi_change_dispatch PARAMS((_rl_vimotion_cxt *));
static int vi_delete_dispatch PARAMS((_rl_vimotion_cxt *));
static int vi_yank_dispatch PARAMS((_rl_vimotion_cxt *));
static int vidomove_dispatch PARAMS((_rl_vimotion_cxt *));
void
_rl_vi_initialize_line ()
{
@@ -1076,28 +1084,60 @@ rl_digit_loop1 ()
return (0);
}
int
rl_vi_delete_to (count, key)
int count, key;
static void
_rl_mvcxt_init (m, op, key)
_rl_vimotion_cxt *m;
int op, key;
{
int c, start_pos;
m->op = op;
m->state = m->flags = 0;
m->ncxt = 0;
m->numeric_arg = -1;
m->start = rl_point;
m->end = rl_end;
m->key = key;
m->motion = -1;
}
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
else if (vi_redoing)
rl_stuff_char (_rl_vi_last_motion);
static _rl_vimotion_cxt *
_rl_mvcxt_alloc (op, key)
int op, key;
{
_rl_vimotion_cxt *m;
start_pos = rl_point;
m = xmalloc (sizeof (_rl_vimotion_cxt));
_rl_mvcxt_init (m, op, key);
return m;
}
if (rl_vi_domove (key, &c))
{
rl_ding ();
return -1;
}
static void
_rl_mvcxt_dispose (m)
_rl_vimotion_cxt *m;
{
free (m);
}
/*
* 1. Create context, set initial values
* 2. Pass to rl_vi_domove to populate
* 3. Use returned context to finish rest of command
*
* Context:
* op
* state
* flags
* numeric arg
* start, end positions
* initial key (key), motion key (c)
*/
static int
vi_delete_dispatch (m)
_rl_vimotion_cxt *m;
{
/* These are the motion commands that do not require adjusting the
mark. */
if (((strchr (" l|h^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
if (((strchr (" l|h^0bBFT`", m->motion) == 0) && (rl_point >= m->start)) &&
(rl_mark < rl_end))
rl_mark++;
@@ -1106,34 +1146,47 @@ rl_vi_delete_to (count, key)
}
int
rl_vi_change_to (count, key)
rl_vi_delete_to (count, key)
int count, key;
{
int c, start_pos;
int c, r;
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
else if (vi_redoing)
rl_stuff_char (_rl_vi_last_motion);
start_pos = rl_point;
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key);
_rl_vimvcxt->start = rl_point;
/* XXX -- TODO -- pass and use context in rl_vi_domove */
if (rl_vi_domove (key, &c))
{
rl_ding ();
return -1;
}
_rl_vimvcxt->motion = c;
r = vidomove_dispatch (_rl_vimvcxt);
_rl_mvcxt_dispose (_rl_vimvcxt);
_rl_vimvcxt = 0;
return r;
}
static int
vi_change_dispatch (m)
_rl_vimotion_cxt *m;
{
/* These are the motion commands that do not require adjusting the
mark. c[wW] are handled by special-case code in rl_vi_domove(),
and already leave the mark at the correct location. */
if (((strchr (" l|hwW^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
if (((strchr (" l|hwW^0bBFT`", m->motion) == 0) && (rl_point >= m->start)) &&
(rl_mark < rl_end))
rl_mark++;
/* The cursor never moves with c[wW]. */
if ((_rl_to_upper (c) == 'W') && rl_point < start_pos)
rl_point = start_pos;
if ((_rl_to_upper (m->motion) == 'W') && rl_point < m->start)
rl_point = m->start;
if (vi_redoing)
{
@@ -1151,44 +1204,112 @@ rl_vi_change_to (count, key)
rl_begin_undo_group (); /* to make the `u' command work */
rl_kill_text (rl_point, rl_mark);
/* `C' does not save the text inserted for undoing or redoing. */
if (_rl_uppercase_p (key) == 0)
if (_rl_uppercase_p (m->key) == 0)
_rl_vi_doing_insert = 1;
rl_vi_start_inserting (key, rl_numeric_arg, rl_arg_sign);
/* XXX -- TODO -- use m->numericarg? */
rl_vi_start_inserting (m->key, rl_numeric_arg, rl_arg_sign);
}
return (0);
}
int
rl_vi_change_to (count, key)
int count, key;
{
int c, r;
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
else if (vi_redoing)
rl_stuff_char (_rl_vi_last_motion);
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key);
_rl_vimvcxt->start = rl_point;
/* XXX -- TODO -- pass and use context in rl_vi_domove */
if (rl_vi_domove (key, &c))
{
rl_ding ();
return -1;
}
_rl_vimvcxt->motion = c;
r = vidomove_dispatch (_rl_vimvcxt);
_rl_mvcxt_dispose (_rl_vimvcxt);
_rl_vimvcxt = 0;
return r;
}
static int
vi_yank_dispatch (m)
_rl_vimotion_cxt *m;
{
/* These are the motion commands that do not require adjusting the
mark. */
if (((strchr (" l|h^0%bBFT`", m->motion) == 0) && (rl_point >= m->start)) &&
(rl_mark < rl_end))
rl_mark++;
rl_begin_undo_group ();
rl_kill_text (rl_point, rl_mark);
rl_end_undo_group ();
rl_do_undo ();
rl_point = m->start;
return (0);
}
int
rl_vi_yank_to (count, key)
int count, key;
{
int c, start_pos;
int c, r;
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
start_pos = rl_point;
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key);
_rl_vimvcxt->start = rl_point;
/* XXX -- TODO -- pass and use context in rl_vi_domove */
if (rl_vi_domove (key, &c))
{
rl_ding ();
return -1;
}
_rl_vimvcxt->motion = c;
/* These are the motion commands that do not require adjusting the
mark. */
if (((strchr (" l|h^0%bBFT`", c) == 0) && (rl_point >= start_pos)) &&
(rl_mark < rl_end))
rl_mark++;
r = vidomove_dispatch (_rl_vimvcxt);
_rl_mvcxt_dispose (_rl_vimvcxt);
_rl_vimvcxt = 0;
return r;
}
rl_begin_undo_group ();
rl_kill_text (rl_point, rl_mark);
rl_end_undo_group ();
rl_do_undo ();
rl_point = start_pos;
static int
vidomove_dispatch (m)
_rl_vimotion_cxt *m;
{
int r;
return (0);
switch (m->op)
{
case VIM_DELETE:
r = vi_delete_dispatch (m);
break;
case VIM_CHANGE:
r = vi_change_dispatch (m);
break;
case VIM_YANK:
r = vi_yank_dispatch (m);
break;
default:
fprintf (stderr, "vidomove_dispatch: unknown operator %d", m->op);
r = 1;
break;
}
return r;
}
int
File diff suppressed because it is too large Load Diff
+170 -48
View File
@@ -1,7 +1,7 @@
/* vi_mode.c -- A vi emulation mode for Bash.
Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -65,6 +65,8 @@
int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */
_rl_vimotion_cxt *_rl_vimvcxt = 0;
/* Non-zero means enter insertion mode. */
static int _rl_vi_doing_insert;
@@ -128,6 +130,12 @@ static int _rl_vi_callback_change_char PARAMS((_rl_callback_generic_arg *));
static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *));
#endif
static int vi_change_dispatch PARAMS((_rl_vimotion_cxt *));
static int vi_delete_dispatch PARAMS((_rl_vimotion_cxt *));
static int vi_yank_dispatch PARAMS((_rl_vimotion_cxt *));
static int vidomove_dispatch PARAMS((_rl_vimotion_cxt *));
void
_rl_vi_initialize_line ()
{
@@ -1076,28 +1084,60 @@ rl_digit_loop1 ()
return (0);
}
int
rl_vi_delete_to (count, key)
int count, key;
static void
_rl_mvcxt_init (m, op, key)
_rl_vimotion_cxt *m;
int op, key;
{
int c, start_pos;
m->op = op;
m->state = m->flags = 0;
m->ncxt = 0;
m->numeric_arg = -1;
m->start = rl_point;
m->end = rl_end;
m->key = key;
m->motion = -1;
}
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
else if (vi_redoing)
rl_stuff_char (_rl_vi_last_motion);
static _rl_vimotion_cxt *
_rl_mvcxt_alloc (op, key)
int op, key;
{
_rl_vimotion_cxt *m;
start_pos = rl_point;
m = xmalloc (sizeof (_rl_vimotion_cxt));
_rl_mvcxt_init (m, op, key);
return m;
}
if (rl_vi_domove (key, &c))
{
rl_ding ();
return -1;
}
static void
_rl_mvcxt_dispose (m)
_rl_vimotion_cxt *m;
{
free (m);
}
/*
* 1. Create context, set initial values
* 2. Pass to rl_vi_domove to populate
* 3. Use returned context to finish rest of command
*
* Context:
* op
* state
* flags
* numeric arg
* start, end positions
* initial key (key), motion key (c)
*/
static int
vi_delete_dispatch (m)
_rl_vimotion_cxt *m;
{
/* These are the motion commands that do not require adjusting the
mark. */
if (((strchr (" l|h^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
if (((strchr (" l|h^0bBFT`", m->motion) == 0) && (rl_point >= m->start)) &&
(rl_mark < rl_end))
rl_mark++;
@@ -1106,34 +1146,47 @@ rl_vi_delete_to (count, key)
}
int
rl_vi_change_to (count, key)
rl_vi_delete_to (count, key)
int count, key;
{
int c, start_pos;
int c, r;
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
else if (vi_redoing)
rl_stuff_char (_rl_vi_last_motion);
start_pos = rl_point;
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key);
_rl_vimvcxt->start = rl_point;
/* XXX -- TODO -- pass and use context in rl_vi_domove */
if (rl_vi_domove (key, &c))
{
rl_ding ();
return -1;
}
_rl_vimvcxt->motion = c;
r = vidomove_dispatch (_rl_vimvcxt);
_rl_mvcxt_dispose (_rl_vimvcxt);
_rl_vimvcxt = 0;
return r;
}
static int
vi_change_dispatch (m)
_rl_vimotion_cxt *m;
{
/* These are the motion commands that do not require adjusting the
mark. c[wW] are handled by special-case code in rl_vi_domove(),
and already leave the mark at the correct location. */
if (((strchr (" l|hwW^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
if (((strchr (" l|hwW^0bBFT`", m->motion) == 0) && (rl_point >= m->start)) &&
(rl_mark < rl_end))
rl_mark++;
/* The cursor never moves with c[wW]. */
if ((_rl_to_upper (c) == 'W') && rl_point < start_pos)
rl_point = start_pos;
if ((_rl_to_upper (m->motion) == 'W') && rl_point < m->start)
rl_point = m->start;
if (vi_redoing)
{
@@ -1151,44 +1204,112 @@ rl_vi_change_to (count, key)
rl_begin_undo_group (); /* to make the `u' command work */
rl_kill_text (rl_point, rl_mark);
/* `C' does not save the text inserted for undoing or redoing. */
if (_rl_uppercase_p (key) == 0)
if (_rl_uppercase_p (m->key) == 0)
_rl_vi_doing_insert = 1;
rl_vi_start_inserting (key, rl_numeric_arg, rl_arg_sign);
/* XXX -- TODO -- use m->numericarg? */
rl_vi_start_inserting (m->key, rl_numeric_arg, rl_arg_sign);
}
return (0);
}
int
rl_vi_change_to (count, key)
int count, key;
{
int c, r;
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
else if (vi_redoing)
rl_stuff_char (_rl_vi_last_motion);
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key);
_rl_vimvcxt->start = rl_point;
/* XXX -- TODO -- pass and use context in rl_vi_domove */
if (rl_vi_domove (key, &c))
{
rl_ding ();
return -1;
}
_rl_vimvcxt->motion = c;
r = vidomove_dispatch (_rl_vimvcxt);
_rl_mvcxt_dispose (_rl_vimvcxt);
_rl_vimvcxt = 0;
return r;
}
static int
vi_yank_dispatch (m)
_rl_vimotion_cxt *m;
{
/* These are the motion commands that do not require adjusting the
mark. */
if (((strchr (" l|h^0%bBFT`", m->motion) == 0) && (rl_point >= m->start)) &&
(rl_mark < rl_end))
rl_mark++;
rl_begin_undo_group ();
rl_kill_text (rl_point, rl_mark);
rl_end_undo_group ();
rl_do_undo ();
rl_point = m->start;
return (0);
}
int
rl_vi_yank_to (count, key)
int count, key;
{
int c, start_pos;
int c, r;
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
start_pos = rl_point;
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key);
_rl_vimvcxt->start = rl_point;
/* XXX -- TODO -- pass and use context in rl_vi_domove */
if (rl_vi_domove (key, &c))
{
rl_ding ();
return -1;
}
_rl_vimvcxt->motion = c;
/* These are the motion commands that do not require adjusting the
mark. */
if (((strchr (" l|h^0%bBFT`", c) == 0) && (rl_point >= start_pos)) &&
(rl_mark < rl_end))
rl_mark++;
r = vidomove_dispatch (_rl_vimvcxt);
_rl_mvcxt_dispose (_rl_vimvcxt);
_rl_vimvcxt = 0;
return r;
}
rl_begin_undo_group ();
rl_kill_text (rl_point, rl_mark);
rl_end_undo_group ();
rl_do_undo ();
rl_point = start_pos;
static int
vidomove_dispatch (m)
_rl_vimotion_cxt *m;
{
int r;
return (0);
switch (m->op)
{
case VIM_DELETE:
r = vi_delete_callback (m);
break;
case VIM_CHANGE:
r = vi_change_callback (m);
break;
case VIM_YANK:
r = vi_yank_callback (m);
break;
default:
fprintf (stderr, "vidomove_dispatch: unknown operator %d", m->op);
r = 1;
break;
}
return r;
}
int
@@ -1316,18 +1437,19 @@ rl_vi_char_search (count, key)
static char target;
#endif
if (_rl_cs_orig_dir == 0)
return -1;
#if defined (HANDLE_MULTIBYTE)
if (_rl_vi_last_search_mblen == 0)
return -1;
#else
if (_rl_vi_last_search_char == 0)
return -1;
#endif
if (key == ';' || key == ',')
_rl_cs_dir = (key == ';') ? _rl_cs_orig_dir : -_rl_cs_orig_dir;
{
if (_rl_cs_orig_dir == 0)
return -1;
#if defined (HANDLE_MULTIBYTE)
if (_rl_vi_last_search_mblen == 0)
return -1;
#else
if (_rl_vi_last_search_char == 0)
return -1;
#endif
_rl_cs_dir = (key == ';') ? _rl_cs_orig_dir : -_rl_cs_orig_dir;
}
else
{
switch (key)
+1 -1
View File
@@ -1,6 +1,6 @@
/* dprintf -- printf to a file descriptor */
/* Copyright (C) 2008,2009 Free Software Foundation, Inc.
/* Copyright (C) 2008-2010 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+3 -3
View File
@@ -1,4 +1,4 @@
/* fdprintf -- printf to a file descriptor */
/* dprintf -- printf to a file descriptor */
/* Copyright (C) 2008,2009 Free Software Foundation, Inc.
@@ -38,9 +38,9 @@
int
#if defined (PREFER_STDARG)
fdprintf(int fd, const char *format, ...)
dprintf(int fd, const char *format, ...)
#else
fdprintf(fd, format, va_alist)
dprintf(fd, format, va_alist)
int fd;
const char *format;
va_dcl
+1 -1
View File
@@ -1,6 +1,6 @@
/* eaccess.c - eaccess replacement for the shell, plus other access functions. */
/* Copyright (C) 2006 Free Software Foundation, Inc.
/* Copyright (C) 2006-2010 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+6 -1
View File
@@ -206,7 +206,12 @@ sh_eaccess (path, mode)
#if defined (HAVE_FACCESSAT) && defined (AT_EACCESS)
return (faccessat (AT_FDCWD, path, mode, AT_EACCESS));
#elif defined (HAVE_EACCESS) /* FreeBSD */
return (eaccess (path, mode)); /* XXX -- not always correct for X_OK */
ret = eaccess (path, mode); /* XXX -- not always correct for X_OK */
# if defined (__FreeBSD__)
if (ret == 0 && current_user.euid == 0 && mode == X_OK)
return (sh_stataccess (path, mode));
# endif
return ret;
#elif defined (EFF_ONLY_OK) /* SVR4(?), SVR4.2 */
return access (path, mode|EFF_ONLY_OK);
#else
+1 -1
View File
@@ -1,6 +1,6 @@
/* fnxform - use iconv(3) to transform strings to and from "filename" format */
/* Copyright (C) 2009 Free Software Foundation, Inc.
/* Copyright (C) 2009-2010 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+199
View File
@@ -0,0 +1,199 @@
/* fnxform - use iconv(3) to transform strings to and from "filename" format */
/* Copyright (C) 2009 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "bashansi.h"
#include <stdio.h>
#include "bashtypes.h"
#include "stdc.h"
#include "bashintl.h"
#include <xmalloc.h>
#if defined (HAVE_ICONV)
# include <iconv.h>
#endif
#if defined (HAVE_LOCALE_CHARSET)
extern const char *locale_charset __P((void));
#else
extern char *get_locale_var __P((char *));
#endif
#if defined (HAVE_ICONV)
static iconv_t conv_fromfs = (iconv_t)-1;
static iconv_t conv_tofs = (iconv_t)-1;
#define OUTLEN_MAX 4096
static char *outbuf = 0;
static size_t outlen = 0;
static char *curencoding __P((void));
static void init_tofs __P((void));
static void init_fromfs __P((void));
static char *
curencoding ()
{
char *loc;
#if defined (HAVE_LOCALE_CHARSET)
loc = (char *)locale_charset ();
return loc;
#else
char *dot, *mod;
loc = get_locale_var ("LC_CTYPE");
if (loc == 0 || *loc == 0)
return "";
dot = strchr (loc, '.');
if (dot == 0)
return loc;
mod = strchr (dot, '@');
if (mod)
*mod = '\0';
return dot;
#endif
}
static void
init_tofs ()
{
char *cur;
cur = curencoding ();
conv_tofs = iconv_open ("UTF-8-MAC", cur);
}
static void
init_fromfs ()
{
char *cur;
cur = curencoding ();
conv_fromfs = iconv_open (cur, "UTF-8-MAC");
}
char *
fnx_tofs (string, len)
char *string;
size_t len;
{
#ifdef MACOSX
ICONV_CONST char *inbuf;
char *tempbuf;
size_t templen;
if (conv_tofs == (iconv_t)-1)
init_tofs ();
if (conv_tofs == (iconv_t)-1)
return string;
/* Free and reallocate outbuf if it's *too* big */
if (outlen >= OUTLEN_MAX && len < OUTLEN_MAX - 8)
{
free (outbuf);
outbuf = 0;
outlen = 0;
}
inbuf = string;
if (outbuf == 0 || outlen < len + 8)
{
outlen = len + 8;
outbuf = outbuf ? xrealloc (outbuf, outlen + 1) : xmalloc (outlen + 1);
}
tempbuf = outbuf;
templen = outlen;
iconv (conv_tofs, NULL, NULL, NULL, NULL);
if (iconv (conv_tofs, &inbuf, &len, &tempbuf, &templen) == (size_t)-1)
return string;
*tempbuf = '\0';
return outbuf;
#else
return string;
#endif
}
char *
fnx_fromfs (string, len)
char *string;
size_t len;
{
#ifdef MACOSX
ICONV_CONST char *inbuf;
char *tempbuf;
size_t templen;
if (conv_fromfs == (iconv_t)-1)
init_fromfs ();
if (conv_fromfs == (iconv_t)-1)
return string;
/* Free and reallocate outbuf if it's *too* big */
if (outlen >= OUTLEN_MAX && len < OUTLEN_MAX - 8)
{
free (outbuf);
outbuf = 0;
outlen = 0;
}
inbuf = string;
if (outbuf == 0 || outlen < (len + 8))
{
outlen = len + 8;
outbuf = outbuf ? xrealloc (outbuf, outlen + 1) : xmalloc (outlen + 1);
}
tempbuf = outbuf;
templen = outlen;
iconv (conv_fromfs, NULL, NULL, NULL, NULL);
if (iconv (conv_fromfs, &inbuf, &len, &tempbuf, &templen) == (size_t)-1)
return string;
*tempbuf = '\0';
return outbuf;
#else
return string;
#endif
}
#else
char *
fnx_tofs (string)
char *string;
{
return string;
}
char *
fnx_fromfs (string)
char *string;
{
return string;
}
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
/* oslib.c - functions present only in some unix versions. */
/* Copyright (C) 1995 Free Software Foundation, Inc.
/* Copyright (C) 1995,2010 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+2 -1
View File
@@ -213,7 +213,8 @@ gethostname (name, namelen)
# else /* !HAVE_UNAME */
int
gethostname (name, namelen)
int name, namelen;
char *name;
int namelen;
{
strncpy (name, "unknown", namelen);
name[namelen] = '\0';
+1 -1
View File
@@ -9,7 +9,7 @@
Unix snprintf implementation.
derived from inetutils/libinetutils/snprintf.c Version 1.1
Copyright (C) 2001,2006 Free Software Foundation, Inc.
Copyright (C) 2001,2006,2010 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+2173
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,6 +1,6 @@
/* strtrans.c - Translate and untranslate strings with ANSI-C escape sequences. */
/* Copyright (C) 2000 Free Software Foundation, Inc.
/* Copyright (C) 2000-2010 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+3
View File
@@ -51,6 +51,9 @@ ansicstr (string, len, flags, sawc, rlen)
{
int c, temp, v;
char *ret, *r, *s;
#if defined (HANDLE_MULTIBYTE)
char mbch[25]; /* 25 > MB_LEN_MAX, plus can handle 4-byte UTF-8 and large Unicode characters*/
#endif
if (string == 0 || *string == '\0')
return ((char *)NULL);
+1 -1
View File
@@ -1,6 +1,6 @@
/* unicode.c - functions to convert unicode characters */
/* Copyright (C) 2006 Free Software Foundation, Inc.
/* Copyright (C) 2010 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+4
View File
@@ -44,6 +44,10 @@
# endif
#endif
#if !defined (STREQ)
# define STREQ(a, b) ((a)[0] == (b)[0] && strcmp ((a), (b)) == 0)
#endif /* !STREQ */
#if defined (HAVE_LOCALE_CHARSET)
extern const char *locale_charset __P((void));
#else