/* bind.c -- key binding and startup file support for the readline library. */
-/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2023 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.
/* Stack of previous values of parsing_conditionalized_out. */
static unsigned char *if_stack = (unsigned char *)NULL;
static int if_stack_depth;
-static int if_stack_size;
+static size_t if_stack_size;
/* Push _rl_parsing_conditionalized_out, and set parser state based
on ARGS. */
if (_rl_stricmp (string, "set") == 0)
{
char *var, *value, *e;
- int s;
var = string + i;
/* Make VAR point to start of variable name. */
if (*funname == '\'' || *funname == '"')
{
char useq[2];
- int fl = strlen (funname);
+ size_t fl = strlen (funname);
useq[0] = key; useq[1] = '\0';
if (fl && funname[fl - 1] == *funname)
{
register int key;
char **result;
- int result_index, result_size;
+ size_t result_index, result_size;
result = (char **)NULL;
result_index = result_size = 0;
static void
_rl_macro_dumper_internal (int print_readably, Keymap map, char *prefix)
{
- register int key;
+ int key;
char *keyname, *out;
- int prefix_len;
+ size_t prefix_len;
for (key = 0; key < KEYMAP_SIZE; key++)
{
text = rl_copy_text (start, end);
matches = gen_completion_matches (text, start, end, our_func, found_quote, quote_char);
+ /* If TEXT contains quote characters, it will be dequoted as part of
+ generating the matches, and the matches will not contain any quote
+ characters. We need to dequote TEXT before performing the comparison.
+ Since compare_match performs the dequoting, and we only want to do it
+ once, we don't call compare_matches after dequoting TEXT; we call
+ strcmp directly. */
/* nontrivial_lcd is set if the common prefix adds something to the word
being completed. */
- nontrivial_lcd = matches && compare_match (text, matches[0]) != 0;
+ if (rl_filename_completion_desired && rl_filename_quoting_desired &&
+ rl_completion_found_quote && rl_filename_dequoting_function)
+ {
+ char *t;
+ t = (*rl_filename_dequoting_function) (text, rl_completion_quote_character);
+ xfree (text);
+ text = t;
+ nontrivial_lcd = matches && strcmp (text, matches[0]) != 0;
+ }
+ else
+ nontrivial_lcd = matches && strcmp (text, matches[0]) != 0;
if (what_to_do == '!' || what_to_do == '@')
tlen = strlen (text);
xfree (text);
register int i;
/* Number of slots in match_list. */
- int match_list_size;
+ size_t match_list_size;
/* The list of matches. */
char **match_list;
static char *users_dirname = (char *)NULL;
static int filename_len;
char *temp, *dentry, *convfn;
- int dirlen, dentlen, convlen;
+ size_t dirlen;
+ int dentlen, convlen;
int tilde_dirname;
struct dirent *entry;
/* Now that we have some state, we can read the directory. */
entry = (struct dirent *)NULL;
+ convfn = dentry = 0;
while (directory && (entry = readdir (directory)))
{
convfn = dentry = entry->d_name;
static int full_completion = 0; /* set to 1 if menu completion should reinitialize on next call */
static int orig_start, orig_end;
static char quote_char;
- static int delimiter, cstate;
+ static int delimiter;
/* The first time through, we generate the list of matches and set things
up to insert them. */
static void
realloc_line (int minsize)
{
- int minimum_size;
- int newsize, delta;
+ size_t minimum_size;
+ size_t newsize, delta;
minimum_size = DEFAULT_LINE_BUFFER_SIZE;
if (minsize < minimum_size)
{
int in, out, c, linenum, cursor_linenum;
int inv_botlin, lb_botlin, lb_linenum, o_cpos;
- int newlines, lpos, temp, n0, num, prompt_lines_estimate;
+ int newlines, lpos, temp, num, prompt_lines_estimate;
char *prompt_this_line;
char cur_face;
int hl_begin, hl_end;
rl_forced_update_display (void)
{
register char *temp;
- register int tlen;
if (visible_line)
memset (visible_line, 0, line_size);
extern int _rl_qsort_string_compare (char **, char **);
FUNMAP **funmap;
-static int funmap_size;
+static size_t funmap_size;
static int funmap_entry;
/* After initializing the function map, this is the index of the first
rl_funmap_names (void)
{
const char **result;
- int result_size, result_index;
+ size_t result_size, result_index;
/* Make sure that the function map has been initialized. */
rl_initialize_funmap ();
/* gettimeofday.c - gettimeofday replacement using time() */
-/* Copyright (C) 2020 Free Software Foundation, Inc.
+/* Copyright (C) 2020, 2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#if !defined (HAVE_GETTIMEOFDAY)
#include "posixtime.h"
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
-/* A version of gettimeofday that just sets tv_sec from time(3) */
+/* A version of gettimeofday that just sets tv_sec from time(3) on Unix-like
+ systems that don't have it, or a version for Win32 systems. */
int
gettimeofday (struct timeval *restrict tv, void *restrict tz)
{
+#if !defined (_WIN32)
tv->tv_sec = (time_t) time ((time_t *)0);
tv->tv_usec = 0;
+#else
+ /* EPOCH is the number of 100 nanosecond intervals from
+ January 1, 1601 (UTC) to January 1, 1970.
+ (the correct value has 9 trailing zeros) */
+ static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
+
+ SYSTEMTIME system_time;
+ FILETIME file_time;
+ uint64_t time;
+
+ GetSystemTime(&system_time);
+ SystemTimeToFileTime(&system_time, &file_time);
+ time = ((uint64_t)file_time.dwLowDateTime);
+ time += ((uint64_t)file_time.dwHighDateTime) << 32;
+
+ tp->tv_sec = (long) ((time - EPOCH) / 10000000L);
+ tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
+#endif
+
return 0;
}
#endif
/* histexpand.c -- history expansion. */
-/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2021,2023 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
specifications from word designators. Static for now */
static char *history_event_delimiter_chars = HISTORY_EVENT_DELIMITERS;
-static char *get_history_word_specifier (char *, char *, int *);
+static char *get_history_word_specifier (const char *, char *, int *);
static int history_tokenize_word (const char *, int);
static char **history_tokenize_internal (const char *, int, int *);
static char *history_substring (const char *, int, int);
static void freewords (char **, int);
-static char *history_find_word (char *, int);
+static char *history_find_word (const char *, int);
static char *quote_breaks (char *);
to the closing single quote. FLAGS currently used to allow backslash
to escape a single quote (e.g., for bash $'...'). */
static void
-hist_string_extract_single_quoted (char *string, int *sindex, int flags)
+hist_string_extract_single_quoted (const char *string, int *sindex, int flags)
{
register int i;
}
static char *
-hist_error(char *s, int start, int current, int errtype)
+hist_error(const char *s, int start, int current, int errtype)
{
char *temp;
const char *emsg;
subst_rhs is allowed to be set to the empty string. */
static char *
-get_subst_pattern (char *str, int *iptr, int delimiter, int is_rhs, int *lenptr)
+get_subst_pattern (const char *str, int *iptr, int delimiter, int is_rhs, int *lenptr)
{
register int si, i, j, k;
char *s;
*END_INDEX_PTR, and the expanded specifier in *RET_STRING. */
/* need current line for !# */
static int
-history_expand_internal (char *string, int start, int qc, int *end_index_ptr, char **ret_string, char *current_line)
+history_expand_internal (const char *string, int start, int qc, int *end_index_ptr, char **ret_string, char *current_line)
{
int i, n, starting_index;
int substitute_globally, subst_bywords, want_quotes, print_only;
char *event, *temp, *result, *tstr, *t, c, *word_spec;
- int result_len;
+ size_t result_len;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
#define ADD_STRING(s) \
do \
{ \
- int sl = strlen (s); \
+ size_t sl = strlen (s); \
j += sl; \
if (j >= result_len) \
{ \
int
history_expand (char *hstring, char **output)
{
- register int j;
- int i, r, l, passc, cc, modified, eindex, only_printing, dquote, squote, flag;
+ int j;
+ int i, r, passc, cc, modified, eindex, only_printing, dquote, squote, flag;
+ size_t l;
char *string;
/* The output string, and its length. */
- int result_len;
+ size_t result_len;
char *result;
#if defined (HANDLE_MULTIBYTE)
CALLER_INDEX is the offset in SPEC to start looking; it is updated
to point to just after the last character parsed. */
static char *
-get_history_word_specifier (char *spec, char *from, int *caller_index)
+get_history_word_specifier (const char *spec, char *from, int *caller_index)
{
register int i = *caller_index;
int first, last;
{
register int i, len;
char *result;
- int size, offset;
+ size_t size, offset;
char **list;
/* XXX - think about making history_tokenize return a struct array,
static int
history_tokenize_word (const char *string, int ind)
{
- register int i, j;
+ int i, j;
int delimiter, nestdelim, delimopen;
i = ind;
history_tokenize_internal (const char *string, int wind, int *indp)
{
char **result;
- register int i, start, result_index, size;
+ int i, start, result_index;
+ size_t size;
/* If we're searching for a string that's not part of a word (e.g., " "),
make sure we set *INDP to a reasonable value. */
/* Get a token, and stuff it into RESULT. The tokens are split
exactly where the shell would split them. */
- for (i = result_index = size = 0, result = (char **)NULL; string[i]; )
+ for (i = result_index = 0, size = 0, result = (char **)NULL; string[i]; )
{
/* Skip leading whitespace. */
for (; string[i] && fielddelim (string[i]); i++)
in the history line LINE. Used to save the word matched by the
last history !?string? search. */
static char *
-history_find_word (char *line, int ind)
+history_find_word (const char *line, int ind)
{
char **words, *s;
int i, wind;
{
char *return_val;
const char *home;
- int home_len;
+ size_t home_len;
return_val = filename ? savestring (filename) : (char *)NULL;
char *ret, linkbuf[PATH_MAX+1];
size_t len;
ssize_t n;
- struct stat fs;
fn = filename;
#if defined (HAVE_READLINK)
char *ret, linkbuf[PATH_MAX+1];
size_t len;
ssize_t n;
- struct stat fs;
int pid;
fn = filename;
file = filename ? open (filename, O_RDONLY|O_BINARY, 0666) : -1;
rv = exists = 0;
+ orig_lines = lines;
+
/* Don't try to truncate non-regular files. */
if (file == -1 || fstat (file, &finfo) == -1)
{
goto truncate_exit;
}
- orig_lines = lines;
/* Count backwards from the end of buffer until we have passed
LINES lines. bp1 is set funny initially. But since bp[1] can't
be a comment character (since it's off the end) and *bp can't be
register int i;
char *output, *tempname, *histname;
int file, mode, rv, exists;
- struct stat finfo, nfinfo;
+ struct stat finfo;
#ifdef HISTORY_USE_MMAP
size_t cursize;
Suggested by Peter Ho (peter@robosts.oxford.ac.uk). */
{
HIST_ENTRY **the_history; /* local */
- register int j;
- int buffer_size;
+ size_t j;
+ size_t buffer_size;
char *buffer;
the_history = history_list ();
if (history_stifled && (history_length == history_max_entries))
{
- register int i;
-
/* If the history is stifled, and history_length is zero,
and it equals history_max_entries, we don't save items. */
if (history_length == 0)
static int
history_search_internal (const char *string, int direction, int flags)
{
- register int i, reverse;
- register char *line;
- register int line_index;
- int string_len, anchored, patsearch;
+ int i, reverse;
+ char *line;
+ int line_index;
+ size_t string_len;
+ int anchored, patsearch;
HIST_ENTRY **the_history; /* local */
i = history_offset;
int rl_timeout_remaining (unsigned int *, unsigned int *);
int _rl_timeout_init (void);
-int _rl_timeout_sigalrm_handler (void);
+int _rl_timeout_handle_sigalrm (void);
#if defined (RL_TIMEOUT_USE_SELECT)
int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *);
#endif
int
rl_getc (FILE *stream)
{
- int result;
+ int result, ostate, osig;
unsigned char c;
int fd;
#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
fd = fileno (stream);
while (1)
{
+ osig = _rl_caught_signal;
+ ostate = rl_readline_state;
+
RL_CHECK_SIGNALS ();
+#if defined (READLINE_CALLBACKS)
+ /* Do signal handling post-processing here, but just in callback mode
+ for right now because the signal cleanup can change some of the
+ callback state, and we need to either let the application have a
+ chance to react or abort some current operation that gets cleaned
+ up by rl_callback_sigcleanup(). If not, we'll just run through the
+ loop again. */
+ if (osig != 0 && (ostate & RL_STATE_CALLBACK))
+ goto postproc_signal;
+#endif
+
/* We know at this point that _rl_caught_signal == 0 */
#if defined (__MINGW32__)
/* fprintf(stderr, "rl_getc: result = %d errno = %d\n", result, errno); */
handle_error:
+ osig = _rl_caught_signal;
+ ostate = rl_readline_state;
+
/* If the error that we received was EINTR, then try again,
this is simply an interrupted system call to read (). We allow
the read to be interrupted if we caught SIGHUP, SIGTERM, or any
RL_CHECK_SIGNALS ();
#endif /* SIGALRM */
+postproc_signal:
+ /* POSIX says read(2)/pselect(2)/select(2) don't return EINTR for any
+ reason other than being interrupted by a signal, so we can safely
+ call the application's signal event hook. */
if (rl_signal_event_hook)
(*rl_signal_event_hook) ();
+#if defined (READLINE_CALLBACKS)
+ else if (osig == SIGINT && (ostate & RL_STATE_CALLBACK) && (ostate & (RL_STATE_ISEARCH|RL_STATE_NSEARCH|RL_STATE_NUMERICARG)))
+ /* just these cases for now */
+ _rl_abort_internal ();
+#endif
}
}
/* */
/* **************************************************************** */
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021,2023 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.
rl_display_search (char *search_string, int flags, int where)
{
char *message;
- int msglen, searchlen;
+ size_t msglen, searchlen;
searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
int
_rl_isearch_dispatch (_rl_search_cxt *cxt, int c)
{
- int n, wstart, wlen, limit, cval, incr;
+ int n, wstart, wlen, limit, cval;
char *paste;
size_t pastelen;
int j;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
- int j;
+ int w;
if (cxt->mb[0] == 0 || cxt->mb[1] == 0)
cxt->search_string[cxt->search_string_index++] = cxt->mb[0];
else
- for (j = 0; j < wlen; )
- cxt->search_string[cxt->search_string_index++] = cxt->mb[j++];
+ for (w = 0; w < wlen; )
+ cxt->search_string[cxt->search_string_index++] = cxt->mb[w++];
}
else
#endif
/* kill.c -- kill ring management. */
-/* Copyright (C) 1994-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2023 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.
int
rl_bracketed_paste_begin (int count, int key)
{
- int retval, c;
- size_t len, cap;
+ int retval;
+ size_t len;
char *buf;
buf = _rl_bracketed_text (&len);
_rl_read_bracketed_paste_prefix (int c)
{
char pbuf[BRACK_PASTE_SLEN+1], *pbpref;
- int key, ind, j;
+ int key, ind;
pbpref = BRACK_PASTE_PREF; /* XXX - debugging */
if (c != pbpref[0])
int
_rl_bracketed_read_mbstring (char *mb, int mlen)
{
- int c, r;
+ int c;
c = _rl_bracketed_read_key ();
if (c < 0)
static char *current_macro = (char *)NULL;
/* The size of the buffer allocated to current_macro. */
-static int current_macro_size;
+static size_t current_macro_size;
/* The index at which characters are being added to current_macro. */
static int current_macro_index;
/* mbutil.c -- readline multibyte character utility functions */
-/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2021,2023 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.
}
static int
-_rl_find_next_mbchar_internal (char *string, int seed, int count, int find_non_zero)
+_rl_find_next_mbchar_internal (const char *string, int seed, int count, int find_non_zero)
{
size_t tmp, len;
mbstate_t ps;
}
static inline int
-_rl_test_nonzero (char *string, int ind, int len)
+_rl_test_nonzero (const char *string, int ind, int len)
{
size_t tmp;
WCHAR_T wc;
/* experimental -- needs to handle zero-width characters better */
static int
-_rl_find_prev_utf8char (char *string, int seed, int find_non_zero)
+_rl_find_prev_utf8char (const char *string, int seed, int find_non_zero)
{
- char *s;
unsigned char b;
int save, prev;
size_t len;
}
/*static*/ int
-_rl_find_prev_mbchar_internal (char *string, int seed, int find_non_zero)
+_rl_find_prev_mbchar_internal (const char *string, int seed, int find_non_zero)
{
mbstate_t ps;
int prev, non_zero_prev, point, length;
if an invalid multibyte sequence was encountered. It returns (size_t)(-2)
if it couldn't parse a complete multibyte character. */
int
-_rl_get_char_len (char *src, mbstate_t *ps)
+_rl_get_char_len (const char *src, mbstate_t *ps)
{
size_t tmp, l;
int mb_cur_max;
else
{
mb_cur_max = MB_CUR_MAX;
- tmp = mbrlen((const char *)src, (l < mb_cur_max) ? l : mb_cur_max, ps);
+ tmp = mbrlen(src, (l < mb_cur_max) ? l : mb_cur_max, ps);
}
if (tmp == (size_t)(-2))
{
/* compare the specified two characters. If the characters matched,
return 1. Otherwise return 0. */
int
-_rl_compare_chars (char *buf1, int pos1, mbstate_t *ps1, char *buf2, int pos2, mbstate_t *ps2)
+_rl_compare_chars (const char *buf1, int pos1, mbstate_t *ps1, const char *buf2, int pos2, mbstate_t *ps2)
{
int i, w1, w2;
if point is invalid (point < 0 || more than string length),
it returns -1 */
int
-_rl_adjust_point (char *string, int point, mbstate_t *ps)
+_rl_adjust_point (const char *string, int point, mbstate_t *ps)
{
size_t tmp;
int length, pos;
}
int
-_rl_is_mbchar_matched (char *string, int seed, int end, char *mbchar, int length)
+_rl_is_mbchar_matched (const char *string, int seed, int end, char *mbchar, int length)
{
int i;
}
WCHAR_T
-_rl_char_value (char *buf, int ind)
+_rl_char_value (const char *buf, int ind)
{
size_t tmp;
WCHAR_T wc;
mbstate_t ps;
- int l;
+ size_t l;
if (MB_LEN_MAX == 1 || rl_byte_oriented)
return ((WCHAR_T) buf[ind]);
characters. */
#undef _rl_find_next_mbchar
int
-_rl_find_next_mbchar (char *string, int seed, int count, int flags)
+_rl_find_next_mbchar (const char *string, int seed, int count, int flags)
{
#if defined (HANDLE_MULTIBYTE)
return _rl_find_next_mbchar_internal (string, seed, count, flags);
we look for non-zero-width multibyte characters. */
#undef _rl_find_prev_mbchar
int
-_rl_find_prev_mbchar (char *string, int seed, int flags)
+_rl_find_prev_mbchar (const char *string, int seed, int flags)
{
#if defined (HANDLE_MULTIBYTE)
return _rl_find_prev_mbchar_internal (string, seed, flags);
int
_rl_free_saved_history_line (void)
{
- UNDO_LIST *orig;
-
if (_rl_saved_line_for_history)
{
if (rl_undo_list && rl_undo_list == (UNDO_LIST *)_rl_saved_line_for_history->data)
/* posixtime.h -- wrapper for time.h, sys/times.h mess. */
-/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#endif
#if !HAVE_GETTIMEOFDAY
-extern int gettimeofday PARAMS((struct timeval * restrict, void * restrict));
+extern int gettimeofday (struct timeval * restrict, void * restrict);
#endif
/* These exist on BSD systems, at least. */
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
-/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2023 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.
int rl_executing_key;
char *rl_executing_keyseq = 0;
-int _rl_executing_keyseq_size = 0;
+size_t _rl_executing_keyseq_size = 0;
struct _rl_cmd _rl_pending_command;
struct _rl_cmd *_rl_command_to_execute = (struct _rl_cmd *)NULL;
{
(*rl_redisplay_function) ();
_rl_want_redisplay = 0;
- memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t));
+ if (RL_ISSTATE (RL_STATE_CALLBACK))
+ memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t));
/* If we longjmped because of a timeout, handle it here. */
if (RL_ISSTATE (RL_STATE_TIMEOUT))
char *prompt;
/* global state */
- int rlstate;
+ int rlstate; /* XXX -- needs to be unsigned long */
int done;
Keymap kmap;
# if defined (HAVE_TERMIO_H)
# define TERMIO_TTY_DRIVER
# else
-# if !defined (__MINGW32__) && !defined (_WIN32)
+# if !defined (__MINGW32__) && !defined (_MSC_VER)
# define NEW_TTY_DRIVER
# else
# define NO_TTY_DRIVER
#define MB_FIND_ANY 0x00
#define MB_FIND_NONZERO 0x01
-extern int _rl_find_prev_mbchar (char *, int, int);
-extern int _rl_find_next_mbchar (char *, int, int, int);
+extern int _rl_find_prev_mbchar (const char *, int, int);
+extern int _rl_find_next_mbchar (const char *, int, int, int);
#ifdef HANDLE_MULTIBYTE
-extern int _rl_compare_chars (char *, int, mbstate_t *, char *, int, mbstate_t *);
-extern int _rl_get_char_len (char *, mbstate_t *);
-extern int _rl_adjust_point (char *, int, mbstate_t *);
+extern int _rl_compare_chars (const char *, int, mbstate_t *, const char *, int, mbstate_t *);
+extern int _rl_get_char_len (const char *, mbstate_t *);
+extern int _rl_adjust_point (const char *, int, mbstate_t *);
extern int _rl_read_mbchar (char *, int);
extern int _rl_read_mbstring (int, char *, int);
-extern int _rl_is_mbchar_matched (char *, int, int, char *, int);
+extern int _rl_is_mbchar_matched (const char *, int, int, char *, int);
-extern WCHAR_T _rl_char_value (char *, int);
+extern WCHAR_T _rl_char_value (const char *, int);
extern int _rl_walphabetic (WCHAR_T);
#define _rl_to_wupper(wc) (iswlower (wc) ? towupper (wc) : (wc))
extern _rl_keyseq_cxt *_rl_kscxt;
extern int _rl_keyseq_timeout;
-extern int _rl_executing_keyseq_size;
+extern size_t _rl_executing_keyseq_size;
extern rl_hook_func_t *_rl_internal_startup_hook;
static int _rl_history_search_flags;
static char *history_search_string;
-static int history_string_size;
+static size_t history_string_size;
static void make_history_line_current (HIST_ENTRY *);
static int noninc_search_from_pos (char *, int, int, int, int *);
/* **************************************************************** */
#if defined (HAVE_POSIX_SIGNALS)
-static sigset_t sigint_set, sigint_oset;
static sigset_t sigwinch_set, sigwinch_oset;
#else /* !HAVE_POSIX_SIGNALS */
# if defined (HAVE_BSD_SIGNALS)
int last;
};
+/* Needs WCHAR_T from rlmbutil.h */
+#ifndef WCHAR_T
+# define WCHAR_t wchar_t
+#endif
+
/* auxiliary function for binary search in interval table */
-static int bisearch(wchar_t ucs, const struct interval *table, int max) {
+static int bisearch(WCHAR_T ucs, const struct interval *table, int max) {
int min = 0;
int mid;
* in ISO 10646.
*/
-int mk_wcwidth(wchar_t ucs)
+int mk_wcwidth(WCHAR_T ucs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */
/* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
}
-int mk_wcswidth(const wchar_t *pwcs, size_t n)
+int mk_wcswidth(const WCHAR_T *pwcs, size_t n)
{
int w, width = 0;
* the traditional terminal character-width behaviour. It is not
* otherwise recommended for general use.
*/
-int mk_wcwidth_cjk(wchar_t ucs)
+int mk_wcwidth_cjk(WCHAR_T ucs)
{
/* sorted list of non-overlapping intervals of East Asian Ambiguous
* characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
}
-int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
+int mk_wcswidth_cjk(const WCHAR_T *pwcs, size_t n)
{
int w, width = 0;
extern short ospeed;
-extern int tgetent ();
-extern int tgetflag ();
-extern int tgetnum ();
-extern char *tgetstr ();
+extern int tgetent PARAMS((char *, const char *));
+extern int tgetflag PARAMS((const char *));
+extern int tgetnum PARAMS((const char *));
+extern char *tgetstr PARAMS((const char *, char **));
-extern int tputs ();
+extern int tputs PARAMS((const char *, int, int (*)(int));
-extern char *tgoto ();
+extern char *tgoto PARAMS((const char *, int, int));
#endif /* HAVE_TERMCAP_H */
#include "rlshell.h"
#include "xmalloc.h"
-#if defined (__MINGW32__)
+#if defined (_WIN32)
# include <windows.h>
# include <wincon.h>
}
#endif
-#if defined (__MINGW32__)
+#if defined (_WIN32)
static void
_win_get_screensize (int *swp, int *shp)
{
#if defined (__EMX__)
_emx_get_screensize (&wc, &wr);
-#elif defined (__MINGW32__)
+#elif defined (_WIN32) && !defined (__CYGWIN__)
_win_get_screensize (&wc, &wr);
#endif
/* text.c -- text handling commands for readline. */
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021,2023 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.
/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */
-/* Copyright (C) 1988-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1988-2020,2023 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.
static int
tilde_find_suffix (const char *string)
{
- register int i, j, string_len;
- register char **suffixes;
+ int i, j;
+ size_t string_len;
+ char **suffixes;
suffixes = tilde_additional_suffixes;
string_len = strlen (string);
tilde_expand (const char *string)
{
char *result;
- int result_size, result_index;
+ size_t result_size, result_index;
result_index = result_size = 0;
if (result = strchr (string, '~'))
/* Scan through STRING expanding tildes as we come to them. */
while (1)
{
- register int start, end;
+ int start, end;
char *tilde_word, *expansion;
int len;
glue_prefix_and_suffix (char *prefix, const char *suffix, int suffind)
{
char *ret;
- int plen, slen;
+ size_t plen, slen;
plen = (prefix && *prefix) ? strlen (prefix) : 0;
slen = strlen (suffix + suffind);
void
rl_free_undo_list (void)
{
- UNDO_LIST *release, *orig_list;
+ UNDO_LIST *orig_list;
orig_list = rl_undo_list;
_rl_free_undo_list (rl_undo_list);
char *
_rl_strindex (const char *s1, const char *s2)
{
- register int i, l, len;
+ int i;
+ size_t l, len;
for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
if (_rl_strnicmp (s1 + i, s2, l) == 0)
/* vi_mode.c -- A vi emulation mode for Bash.
Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021,2023 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.
/* If non-zero, we have text inserted after a c[motion] command that put
us implicitly into insert mode. Some people want this text to be
attached to the command so that it is `redoable' with `.'. */
-static int vi_continued_command;
static char *vi_insert_buffer;
-static int vi_insert_buffer_size;
+static size_t vi_insert_buffer_size;
static int _rl_vi_last_repeat = 1;
static int _rl_vi_last_arg_sign = 1;
int
rl_vi_domove (int x, int *ignore)
{
- int r;
_rl_vimotion_cxt *m;
m = _rl_vimvcxt;