1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Merging....

BitKeeper/etc/logging_ok:
  auto-union
client/insert_test.c:
  Auto merged
client/select_test.c:
  Auto merged
include/mysql.h:
  Auto merged
include/mysql_com.h:
  Auto merged
libmysql/libmysql.c:
  Auto merged
sql/item_create.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_strfunc.h:
  Auto merged
sql/lex.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/sql_parse.cc:
  Manual merge
This commit is contained in:
unknown
2002-11-29 22:03:14 +03:00
210 changed files with 18620 additions and 8283 deletions

View File

@ -557,3 +557,14 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
bkpull.log
bkpull.log.2
bkpull.log.3
build.log
sql/safe_to_cache_query.txt
bkpull.log.4
bkpull.log.5
bkpull.log.6
bkpush.log
sql/sql_yacc.output
libmysqld/item_row.cc

View File

@ -72,6 +72,12 @@ if (@config_env > 0)
$opt_config_env= join(" ", @config_env);
}
if (@config_env > 0)
{
chomp(@config_env);
$opt_config_env= join(" ", @config_env);
}
chomp($host=`hostname`);
$full_host_name=$host;
$connect_option= ($opt_tcpip ? "--host=$host" : "");

View File

@ -16,9 +16,8 @@
# This file is public domain and comes with NO WARRANTY of any kind
INCLUDES = -I$(srcdir)/../include \
-I../include -I$(srcdir)/.. -I$(top_srcdir) \
-I.. $(openssl_includes)
#AUTOMAKE_OPTIONS = nostdinc
INCLUDES = -I$(top_srcdir)/include $(openssl_includes)
LIBS = @CLIENT_LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \

View File

@ -27,7 +27,7 @@
#include <my_sys.h>
#include "completion_hash.h"
uint hashpjw(char *arKey, uint nKeyLength)
uint hashpjw(const char *arKey, uint nKeyLength)
{
uint h = 0, g, i;
@ -111,7 +111,7 @@ int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength,
return SUCCESS;
}
static Bucket *completion_hash_find(HashTable *ht, char *arKey,
static Bucket *completion_hash_find(HashTable *ht, const char *arKey,
uint nKeyLength)
{
uint h, nIndex;
@ -156,7 +156,7 @@ int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength)
return 0;
}
Bucket *find_all_matches(HashTable *ht, char *str, uint length,
Bucket *find_all_matches(HashTable *ht, const char *str, uint length,
uint *res_length)
{
Bucket *b;

View File

@ -43,14 +43,14 @@ typedef struct hashtable {
uint nTableSize;
uint initialized;
MEM_ROOT mem_root;
uint(*pHashFunction) (char *arKey, uint nKeyLength);
uint(*pHashFunction) (const char *arKey, uint nKeyLength);
Bucket **arBuckets;
} HashTable;
extern int completion_hash_init(HashTable *ht, uint nSize);
extern int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength, char *str);
extern int hash_exists(HashTable *ht, char *arKey);
extern Bucket *find_all_matches(HashTable *ht, char *str, uint length, uint *res_length);
extern Bucket *find_all_matches(HashTable *ht, const char *str, uint length, uint *res_length);
extern Bucket *find_longest_match(HashTable *ht, char *str, uint length, uint *res_length);
extern void add_word(HashTable *ht,char *str);
extern void completion_hash_clean(HashTable *ht);

View File

@ -1049,8 +1049,8 @@ static bool add_line(String &buffer,char *line,char *in_string)
#ifdef HAVE_READLINE
static char *new_command_generator(char *text, int);
static char **new_mysql_completion (char *text, int start, int end);
static char *new_command_generator(const char *text, int);
static char **new_mysql_completion (const char *text, int start, int end);
/*
Tell the GNU Readline library how to complete. We want to try to complete
@ -1058,8 +1058,8 @@ static char **new_mysql_completion (char *text, int start, int end);
if not.
*/
char **no_completion (char *text __attribute__ ((unused)),
char *word __attribute__ ((unused)))
char *no_completion (const char *text __attribute__ ((unused)),
int )
{
return 0; /* No filename completion */
}
@ -1070,9 +1070,13 @@ static void initialize_readline (char *name)
rl_readline_name = name;
/* Tell the completer that we want a crack first. */
/* rl_attempted_completion_function = (CPPFunction *)mysql_completion;*/
rl_attempted_completion_function = (CPPFunction *) new_mysql_completion;
rl_completion_entry_function=(Function *) no_completion;
#if RL_READLINE_VERSION > 0x0400
rl_attempted_completion_function = &new_mysql_completion;
rl_completion_entry_function= &no_completion;
#else
rl_attempted_completion_function =(CPPFunction *)new_mysql_completion;
rl_completion_entry_function= (Function *)no_completion;
#endif
}
/*
@ -1082,17 +1086,21 @@ static void initialize_readline (char *name)
array of matches, or NULL if there aren't any.
*/
static char **new_mysql_completion (char *text,
static char **new_mysql_completion (const char *text,
int start __attribute__((unused)),
int end __attribute__((unused)))
{
if (!status.batch && !quick)
return completion_matches(text, (CPFunction*) new_command_generator);
#if RL_READLINE_VERSION > 0x0400
return rl_completion_matches(text, new_command_generator);
#else
return completion_matches((char *)text, (CPFunction *)new_command_generator);
#endif
else
return (char**) 0;
}
static char *new_command_generator(char *text,int state)
static char *new_command_generator(const char *text,int state)
{
static int textlen;
char *ptr;

View File

@ -15,6 +15,7 @@ SHARED_LIB_VERSION=12:0:0
# Set all version vars based on $VERSION. How do we do this more elegant ?
# Remember that regexps needs to quote [ and ] since this is run through m4
MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|-.*$||"`
MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|[[a-z]]*-.*$||"`
MYSQL_BASE_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|\.[[^.]]*$||"`
F_PART=`echo $MYSQL_BASE_VERSION | sed -e "s|\.||g"| sed -e "s|[a-zA-Z]\+||"|sed -e "s|^\(..\)$|\\10|"`
L_PART=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|^[[0-9]]\.[[0-9]]*\.||" | sed -e "s|^\(.\)$|0\\1|" | sed -e "s|[[a-z]]||"`

View File

@ -15,7 +15,7 @@
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include
LDADD = libdbug.a ../strings/libmystrings.a
pkglib_LIBRARIES = libdbug.a
noinst_HEADERS = dbug_long.h

View File

@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include -I..
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
../dbug/libdbug.a ../strings/libmystrings.a
bin_PROGRAMS = replace comp_err perror resolveip my_print_defaults \

View File

@ -27,11 +27,8 @@ DISTCLEANFILES = CorbaFS-common.* CorbaFS-stubs.* CorbaFS-skels.* CorbaFS.h
MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include \
-I$(srcdir)/../regex \
-I$(srcdir) -I../include -I.. -I. \
-I$(srcdir) -I../include -I.. -I. \
$(orbit_includes)
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include \
-I$(top_srcdir)/regex $(orbit_includes)
WRAPLIBS= @WRAPLIBS@
libexec_PROGRAMS = mysqlcorbafsd
noinst_PROGRAMS =mysqlfs_test

View File

@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include
LDADD = libheap.a ../mysys/libmysys.a ../dbug/libdbug.a \
../strings/libmystrings.a
pkglib_LIBRARIES = libheap.a

View File

@ -125,11 +125,11 @@ typedef struct charset_info_st
/* Charset dependant snprintf() */
int (*snprintf)(struct charset_info_st *, char *to, uint n, const char *fmt, ...);
long (*strtol)(struct charset_info_st *, const char *s, char **e, int base);
ulong (*strtoul)(struct charset_info_st *, const char *s, char **e, int base);
longlong (*strtoll)(struct charset_info_st *, const char *s, char **e, int base);
ulonglong (*strtoull)(struct charset_info_st *, const char *s, char **e, int base);
double (*strtod)(struct charset_info_st *, const char *s, char **e);
long (*strntol)(struct charset_info_st *, const char *s, uint l,char **e, int base);
ulong (*strntoul)(struct charset_info_st *, const char *s, uint l, char **e, int base);
longlong (*strntoll)(struct charset_info_st *, const char *s, uint l, char **e, int base);
ulonglong (*strntoull)(struct charset_info_st *, const char *s, uint l, char **e, int base);
double (*strntod)(struct charset_info_st *, const char *s, uint l, char **e);
} CHARSET_INFO;
@ -169,11 +169,11 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e);
int my_snprintf_8bit(struct charset_info_st *, char *to, uint n, const char *fmt, ...);
long my_strtol_8bit(CHARSET_INFO *, const char *s, char **e, int base);
ulong my_strtoul_8bit(CHARSET_INFO *, const char *s, char **e, int base);
longlong my_strtoll_8bit(CHARSET_INFO *, const char *s, char **e, int base);
ulonglong my_strtoull_8bit(CHARSET_INFO *, const char *s, char **e, int base);
double my_strtod_8bit(CHARSET_INFO *, const char *s, char **e);
long my_strntol_8bit(CHARSET_INFO *, const char *s, uint l,char **e, int base);
ulong my_strntoul_8bit(CHARSET_INFO *, const char *s, uint l,char **e, int base);
longlong my_strntoll_8bit(CHARSET_INFO *, const char *s, uint l,char **e, int base);
ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, uint l,char **e, int base);
double my_strntod_8bit(CHARSET_INFO *, const char *s, uint l,char **e);
my_bool my_like_range_simple(CHARSET_INFO *cs,
const char *ptr, uint ptr_length,
@ -257,11 +257,11 @@ int my_wildcmp_mb(CHARSET_INFO *,
#define my_strcasecmp(s, a, b) ((s)->strcasecmp((s), (a), (b)))
#define my_strncasecmp(s, a, b, l) ((s)->strncasecmp((s), (a), (b), (l)))
#define my_strtol(s, a, b, c) ((s)->strtol((s),(a),(b),(c)))
#define my_strtoul(s, a, b, c) ((s)->strtoul((s),(a),(b),(c)))
#define my_strtoll(s, a, b, c) ((s)->strtoll((s),(a),(b),(c)))
#define my_strtoull(s, a, b, c) ((s)->strtoull((s),(a),(b),(c)))
#define my_strtod(s, a, b) ((s)->strtod((s),(a),(b)))
#define my_strntol(s, a, b, c, d) ((s)->strntol((s),(a),(b),(c),(d)))
#define my_strntoul(s, a, b, c, d) ((s)->strntoul((s),(a),(b),(c),(d)))
#define my_strntoll(s, a, b, c, d) ((s)->strntoll((s),(a),(b),(c),(d)))
#define my_strntoull(s, a, b, c,d) ((s)->strntoull((s),(a),(b),(c),(d)))
#define my_strntod(s, a, b, c ) ((s)->strntod((s),(a),(b),(c)))
/* XXX: still need to take care of this one */

View File

@ -32,7 +32,7 @@ extern LIST *list_add(LIST *root,LIST *element);
extern LIST *list_delete(LIST *root,LIST *element);
extern LIST *list_cons(void *data,LIST *root);
extern LIST *list_reverse(LIST *root);
extern void list_free(LIST *root,pbool free_data);
extern void list_free(LIST *root,uint free_data);
extern uint list_length(LIST *list);
extern int list_walk(LIST *list,list_walk_action action,gptr argument);

View File

@ -360,31 +360,6 @@ typedef struct st_sort_info
pthread_cond_t cond;
} SORT_INFO;
typedef struct st_mi_sort_param
{
pthread_t thr;
IO_CACHE read_cache, tempfile, tempfile_for_exceptions;
DYNAMIC_ARRAY buffpek;
ulonglong unique[MI_MAX_KEY_SEG+1];
my_off_t pos,max_pos,filepos,start_recpos;
uint key, key_length,real_key_length,sortbuff_size;
uint maxbuffers, keys, find_length, sort_keys_length;
my_bool fix_datafile, master;
MI_KEYDEF *keyinfo;
SORT_INFO *sort_info;
uchar **sort_keys;
byte *rec_buff;
void *wordlist, *wordptr;
char *record;
MY_TMPDIR *tmpdir;
int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *);
int (*key_read)(struct st_mi_sort_param *,void *);
int (*key_write)(struct st_mi_sort_param *, const void *);
void (*lock_in_memory)(MI_CHECK *);
} MI_SORT_PARAM;
/* functions in mi_check */
void myisamchk_init(MI_CHECK *param);
int chk_status(MI_CHECK *param, MI_INFO *info);
@ -415,9 +390,7 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
my_off_t length, const char *type);
int movepoint(MI_INFO *info,byte *record,my_off_t oldpos,
my_off_t newpos, uint prot_key);
int sort_write_record(MI_SORT_PARAM *sort_param);
int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile);
int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong);
int test_if_almost_full(MI_INFO *info);
int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename);
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows);

View File

@ -84,6 +84,7 @@ extern int myrg_rfirst(MYRG_INFO *file,byte *buf,int inx);
extern int myrg_rlast(MYRG_INFO *file,byte *buf,int inx);
extern int myrg_rnext(MYRG_INFO *file,byte *buf,int inx);
extern int myrg_rprev(MYRG_INFO *file,byte *buf,int inx);
extern int myrg_rnext_same(MYRG_INFO *file,byte *buf);
extern int myrg_rkey(MYRG_INFO *file,byte *buf,int inx,const byte *key,
uint key_len, enum ha_rkey_function search_flag);
extern int myrg_rrnd(MYRG_INFO *file,byte *buf,ulonglong pos);

View File

@ -61,6 +61,8 @@ typedef int my_socket;
#define CHECK_EXTRA_ARGUMENTS
#endif
#include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */
extern unsigned int mysql_port;
extern char *mysql_unix_port;
@ -213,6 +215,8 @@ typedef struct st_mysql
struct st_mysql* last_used_slave; /* needed for round-robin slave pick */
/* needed for send/read/store/use result to work correctly with replication */
struct st_mysql* last_used_con;
LIST *stmts; /* list of all statements */
} MYSQL;
@ -457,6 +461,7 @@ typedef struct st_mysql_stmt
MYSQL_RES *result; /* resultset */
MYSQL_BIND *bind; /* row binding */
MYSQL_FIELD *fields; /* prepare meta info */
LIST list; /* list to keep track of all stmts */
char *query; /* query buffer */
MEM_ROOT mem_root; /* root allocations */
MYSQL_RES tmp_result; /* Used by mysql_prepare_result */
@ -469,8 +474,8 @@ typedef struct st_mysql_stmt
char last_error[MYSQL_ERRMSG_SIZE]; /* error message */
my_bool long_alloced; /* flag to indicate long alloced */
my_bool send_types_to_server; /* to indicate types supply to server */
my_bool param_buffers; /* to indicate the param bound buffers */
my_bool res_buffers; /* to indicate the result bound buffers */
my_bool param_buffers; /* to indicate the param bound buffers */
my_bool res_buffers; /* to indicate the output bound buffers */
} MYSQL_STMT;
@ -478,8 +483,8 @@ MYSQL_STMT * STDCALL mysql_prepare(MYSQL * mysql, const char *query,
unsigned long length);
int STDCALL mysql_execute(MYSQL_STMT * stmt);
unsigned long STDCALL mysql_param_count(MYSQL_STMT * stmt);
my_bool STDCALL mysql_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bind);
my_bool STDCALL mysql_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bind);
my_bool STDCALL mysql_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
my_bool STDCALL mysql_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt);
const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt);

View File

@ -242,7 +242,7 @@ struct rand_struct {
/* The following is for user defined functions */
enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT};
enum Item_result {STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT};
typedef struct st_udf_args
{

View File

@ -255,11 +255,12 @@
#define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
#define ER_WRONG_FK_DEF 1237
#define ER_KEY_REF_DO_NOT_MATCH_TABLE_REF 1238
#define ER_SUBSELECT_NO_1_COL 1239
#define ER_CARDINALITY_COL 1239
#define ER_SUBSELECT_NO_1_ROW 1240
#define ER_UNKNOWN_STMT_HANDLER 1241
#define ER_CORRUPT_HELP_DB 1242
#define ER_CYCLIC_REFERENCE 1243
#define ER_AUTO_CONVERT 1244
#define ER_ILLEGAL_REFERENCE 1245
#define ER_ERROR_MESSAGES 246
#define ER_SELECT_REDUCED 1246
#define ER_ERROR_MESSAGES 247

View File

@ -90,6 +90,12 @@ ut_malloc_low(
"InnoDB: on Linux we get a stack trace.\n",
n, ut_total_allocated_memory, errno);
/* Flush stderr to make more probable that the error
message gets in the error file before we generate a seg
fault */
fflush(stderr);
os_fast_mutex_unlock(&ut_list_mutex);
/* Make an intentional seg fault so that we get a stack

View File

@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include
LDADD = @CLIENT_EXTRA_LDFLAGS@ libnisam.a ../mysys/libmysys.a \
../dbug/libdbug.a ../strings/libmystrings.a
pkglib_LIBRARIES = libnisam.a

View File

@ -20,8 +20,7 @@
target = libmysqlclient.la
target_defs = -DUNDEF_THREADS_HACK -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ -DMYSQL_CLIENT
LIBS = @CLIENT_LIBS@
INCLUDES = -I$(srcdir)/../include -I../include \
-I$(srcdir)/.. -I$(top_srcdir) -I.. $(openssl_includes)
INCLUDES = -I$(top_srcdir)/include $(openssl_includes)
include $(srcdir)/Makefile.shared

View File

@ -114,6 +114,7 @@ static my_bool send_file_to_server(MYSQL *mysql,const char *filename);
static sig_handler pipe_sig_handler(int sig);
static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
const char *from, ulong length);
static my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list);
static my_bool org_my_init_done=0;
@ -2510,6 +2511,16 @@ mysql_close(MYSQL *mysql)
}
mysql->rpl_pivot=0;
}
if (mysql->stmts)
{
/* Free any open prepared statements */
LIST *element, *next_element;
for (element= mysql->stmts; element; element= next_element)
{
next_element= element->next;
stmt_close((MYSQL_STMT *)element->data, 0);
}
}
if (mysql != mysql->master)
mysql_close(mysql->master);
if (mysql->free_me)
@ -3749,18 +3760,20 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length)
}
if (simple_command(mysql, COM_PREPARE, query, length, 1))
{
mysql_stmt_close(stmt);
stmt_close(stmt, 1);
DBUG_RETURN(0);
}
init_alloc_root(&stmt->mem_root,8192,0);
if (read_prepare_result(mysql, stmt))
{
mysql_stmt_close(stmt);
stmt_close(stmt, 1);
DBUG_RETURN(0);
}
stmt->state= MY_ST_PREPARE;
stmt->mysql= mysql;
mysql->stmts= list_add(mysql->stmts, &stmt->list);
stmt->list.data= stmt;
DBUG_PRINT("info", ("Parameter count: %ld", stmt->param_count));
DBUG_RETURN(stmt);
}
@ -4260,7 +4273,7 @@ mysql_send_long_data(MYSQL_STMT *stmt, uint param_number,
static void fetch_result_tinyint(MYSQL_BIND *param, uchar **row)
{
*param->buffer= (uchar) **row;
*row++;
(*row)++;
}
static void fetch_result_short(MYSQL_BIND *param, uchar **row)
@ -4378,7 +4391,6 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
DBUG_RETURN(0);
}
/*
Fetch row data to bind buffers
*/
@ -4461,27 +4473,42 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt)
*********************************************************************/
/*
Close the statement handle by freeing all resources
*/
Close the statement handle by freeing all alloced resources
my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
SYNOPSIS
mysql_stmt_close()
stmt Statement handle
skip_list Flag to indicate delete from list or not
RETURN VALUES
0 ok
1 error
*/
static my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
{
my_bool error=0;
DBUG_ENTER("mysql_stmt_close");
if (stmt->state != MY_ST_UNKNOWN)
DBUG_ASSERT(stmt != 0);
if (stmt->state == MY_ST_PREPARE || stmt->state == MY_ST_EXECUTE)
{
char buff[4];
int4store(buff, stmt->stmt_id);
error= simple_command(stmt->mysql, COM_CLOSE_STMT, buff, 4, 0);
error= simple_command(stmt->mysql, COM_CLOSE_STMT, buff, 4, 1);
}
mysql_free_result(stmt->result);
free_root(&stmt->mem_root, MYF(0));
my_free((gptr) stmt->query, MYF(MY_WME | MY_ALLOW_ZERO_PTR));
if (!skip_list)
stmt->mysql->stmts= list_delete(stmt->mysql->stmts, &stmt->list);
my_free((gptr) stmt, MYF(MY_WME));
DBUG_RETURN(error);
}
my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
{
return stmt_close(stmt, 0);
}
/*
Return statement error code
*/

View File

@ -21,8 +21,7 @@ target = libmysqlclient_r.la
target_defs = -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@
## LIBS = @LIBS@
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include \
-I$(srcdir)/.. -I$(top_srcdir) -I.. $(openssl_includes)
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include $(openssl_includes)
## automake barfs if you don't use $(srcdir) or $(top_srcdir) in include
include $(top_srcdir)/libmysql/Makefile.shared

View File

@ -25,9 +25,8 @@ DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \
-DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \
-DSHAREDIR="\"$(MYSQLSHAREdir)\""
INCLUDES= @MT_INCLUDES@ @bdb_includes@ -I$(srcdir)/../include \
-I../include -I$(srcdir)/.. -I$(top_srcdir) -I.. \
-I../sql -I../regex
INCLUDES= @MT_INCLUDES@ @bdb_includes@ -I$(top_srcdir)/include \
-I$(top_srcdir)/sql -I$(top_srcdir)/regex
noinst_LIBRARIES = libmysqld_int.a
pkglib_LIBRARIES = libmysqld.a
@ -43,7 +42,7 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
hostname.cc init.cc \
item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
item_uniq.cc item_subselect.cc \
item_uniq.cc item_subselect.cc item_row.cc\
key.cc lock.cc log.cc log_event.cc mf_iocache.cc\
mini_client.cc net_pkg.cc net_serv.cc opt_ft.cc opt_range.cc \
opt_sum.cc procedure.cc records.cc sql_acl.cc \

View File

@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include
pkglib_LIBRARIES = libmerge.a
noinst_HEADERS = mrg_def.h
libmerge_a_SOURCES = mrg_open.c mrg_extra.c mrg_info.c mrg_locking.c \

View File

@ -17,7 +17,7 @@
EXTRA_DIST = mi_test_all.sh mi_test_all.res
pkgdata_DATA = mi_test_all mi_test_all.res
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include
LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a ../mysys/libmysys.a \
../dbug/libdbug.a ../strings/libmystrings.a
pkglib_LIBRARIES = libmyisam.a

View File

@ -111,7 +111,7 @@ FT_WORD * ft_linearize(TREE *wtree)
#else
#define misc_word_char(X) ((X)=='\'' || (X)=='-')
#endif
#define word_char(s,X) (true_word_char(s,X) || misc_word_char(s,X))
#define word_char(s,X) (true_word_char(s,X) || misc_word_char(X))
/* returns:

View File

@ -3682,10 +3682,7 @@ static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows)
key_maxlength+=ft_max_word_len_for_sort-HA_FT_MAXLEN;
return (key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY | HA_FULLTEXT) &&
((ulonglong) rows * key_maxlength >
(ulonglong) myisam_max_temp_length ||
(ulonglong) rows * (key_maxlength - key->minlength) / 2 >
myisam_max_extra_temp_length ||
(rows == 0 && (key_maxlength / key->minlength) > 2)));
(ulonglong) myisam_max_temp_length));
}

View File

@ -38,7 +38,15 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->last_key_func=search_flag;
if (!info->use_packed_key)
if (info->once_flags & USE_PACKED_KEYS)
{
/* key is already packed! */
key_buff=info->lastkey+info->s->base.max_key_length;
info->last_rkey_length=pack_key_length=key_len;
bmove(key_buff,key,key_len);
info->once_flags&= ~USE_PACKED_KEYS;
}
else
{
if (key_len == 0)
key_len=USE_WHOLE_KEY;
@ -48,13 +56,6 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,share->keyinfo[inx].seg,
key_buff,pack_key_length););
}
else
{
/* key is already packed! */
key_buff=info->lastkey+info->s->base.max_key_length;
info->last_rkey_length=pack_key_length=key_len;
bmove(key_buff,key,key_len);
}
if (fast_mi_readinfo(info))
goto err;

View File

@ -46,7 +46,10 @@ int mi_rrnd(MI_INFO *info, byte *buf, register my_off_t filepos)
filepos= info->nextpos;
}
info->lastinx= -1; /* Can't forward or backward */
if (info->once_flags & RRND_PRESERVE_LASTINX)
info->once_flags&= ~RRND_PRESERVE_LASTINX;
else
info->lastinx= -1; /* Can't forward or backward */
/* Init all but update-flag */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);

View File

@ -267,7 +267,7 @@ struct st_myisam_info {
my_bool quick_mode;
my_bool page_changed; /* If info->buff can't be used for rnext */
my_bool buff_used; /* If info->buff has to be reread for rnext */
my_bool use_packed_key; /* For MYISAMMRG */
my_bool once_flags; /* For MYISAMMRG */
#ifdef THREAD
THR_LOCK_DATA lock;
#endif
@ -275,7 +275,41 @@ struct st_myisam_info {
int rtree_recursion_depth;
};
typedef struct st_buffpek {
my_off_t file_pos; /* Where we are in the sort file */
uchar *base,*key; /* Key pointers */
ha_rows count; /* Number of rows in table */
ulong mem_count; /* numbers of keys in memory */
ulong max_keys; /* Max keys in buffert */
} BUFFPEK;
typedef struct st_mi_sort_param
{
pthread_t thr;
IO_CACHE read_cache, tempfile, tempfile_for_exceptions;
DYNAMIC_ARRAY buffpek;
ulonglong unique[MI_MAX_KEY_SEG+1];
my_off_t pos,max_pos,filepos,start_recpos;
uint key, key_length,real_key_length,sortbuff_size;
uint maxbuffers, keys, find_length, sort_keys_length;
my_bool fix_datafile, master;
MI_KEYDEF *keyinfo;
SORT_INFO *sort_info;
uchar **sort_keys;
byte *rec_buff;
void *wordlist, *wordptr;
char *record;
MY_TMPDIR *tmpdir;
int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *);
int (*key_read)(struct st_mi_sort_param *,void *);
int (*key_write)(struct st_mi_sort_param *, const void *);
void (*lock_in_memory)(MI_CHECK *);
NEAR int (*write_keys)(struct st_mi_sort_param *, register uchar **,
uint , struct st_buffpek *, IO_CACHE *);
NEAR uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
NEAR int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,char *,
uint, uint);
} MI_SORT_PARAM;
/* Some defines used by isam-funktions */
#define USE_WHOLE_KEY MI_MAX_KEY_BUFF*2 /* Use whole key in _mi_search() */
@ -288,6 +322,10 @@ struct st_myisam_info {
#define WRITEINFO_UPDATE_KEYFILE 1
#define WRITEINFO_NO_UNLOCK 2
/* once_flags */
#define USE_PACKED_KEYS 1
#define RRND_PRESERVE_LASTINX 2
/* bits in state.changed */
#define STATE_CHANGED 1
@ -658,6 +696,9 @@ int thr_write_keys(MI_SORT_PARAM *sort_param);
pthread_handler_decl(thr_find_all_keys,arg);
#endif
int sort_write_record(MI_SORT_PARAM *sort_param);
int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong);
#ifdef __cplusplus
}
#endif

View File

@ -39,13 +39,10 @@
#define MYF_RW MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL)
#define DISK_BUFFER_SIZE (IO_SIZE*16)
typedef struct st_buffpek {
my_off_t file_pos; /* Where we are in the sort file */
uchar *base,*key; /* Key pointers */
ha_rows count; /* Number of rows in table */
ulong mem_count; /* numbers of keys in memory */
ulong max_keys; /* Max keys in buffert */
} BUFFPEK;
/*
Pointers of functions for store and read keys from temp file
*/
extern void print_error _VARARGS((const char *fmt,...));
@ -56,7 +53,7 @@ static ha_rows NEAR_F find_all_keys(MI_SORT_PARAM *info,uint keys,
DYNAMIC_ARRAY *buffpek,int *maxbuffer,
IO_CACHE *tempfile,
IO_CACHE *tempfile_for_exceptions);
static int NEAR_F write_keys(MI_SORT_PARAM *info,uchar * *sort_keys,
static int NEAR_F write_keys(MI_SORT_PARAM *info,uchar **sort_keys,
uint count, BUFFPEK *buffpek,IO_CACHE *tempfile);
static int NEAR_F write_key(MI_SORT_PARAM *info, uchar *key,
IO_CACHE *tempfile);
@ -75,7 +72,16 @@ static int NEAR_F merge_buffers(MI_SORT_PARAM *info,uint keys,
static int NEAR_F merge_index(MI_SORT_PARAM *,uint,uchar **,BUFFPEK *, int,
IO_CACHE *);
static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info,uchar **sort_keys,
uint count, BUFFPEK *buffpek,
IO_CACHE *tempfile);
static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek,
uint sort_length);
static int NEAR_F write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file,
char* key, uint sort_length, uint count);
static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, IO_CACHE *to_file,
char* key, uint sort_length, uint count);
inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs);
/*
Creates a index of sorted keys
@ -102,6 +108,19 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
DBUG_ENTER("_create_index_by_sort");
DBUG_PRINT("enter",("sort_length: %d", info->key_length));
if (info->keyinfo->flag && HA_VAR_LENGTH_KEY)
{
info->write_keys=write_keys_varlen;
info->read_to_buffer=read_to_buffer_varlen;
info->write_key=write_merge_key_varlen;
}
else
{
info->write_keys=write_keys;
info->read_to_buffer=read_to_buffer;
info->write_key=write_merge_key;
}
my_b_clear(&tempfile);
my_b_clear(&tempfile_for_exceptions);
bzero((char*) &buffpek,sizeof(buffpek));
@ -249,7 +268,7 @@ static ha_rows NEAR_F find_all_keys(MI_SORT_PARAM *info, uint keys,
if (++idx == keys)
{
if (write_keys(info,sort_keys,idx-1,(BUFFPEK *)alloc_dynamic(buffpek),
if (info->write_keys(info,sort_keys,idx-1,(BUFFPEK *)alloc_dynamic(buffpek),
tempfile))
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
@ -263,7 +282,7 @@ static ha_rows NEAR_F find_all_keys(MI_SORT_PARAM *info, uint keys,
DBUG_RETURN(HA_POS_ERROR); /* Aborted by get_key */ /* purecov: inspected */
if (buffpek->elements)
{
if (write_keys(info,sort_keys,idx,(BUFFPEK *)alloc_dynamic(buffpek),
if (info->write_keys(info,sort_keys,idx,(BUFFPEK *)alloc_dynamic(buffpek),
tempfile))
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
*maxbuffer=buffpek->elements-1;
@ -292,6 +311,19 @@ pthread_handler_decl(thr_find_all_keys,arg)
if (info->sort_info->got_error)
goto err;
if (info->keyinfo->flag && HA_VAR_LENGTH_KEY)
{
info->write_keys=write_keys_varlen;
info->read_to_buffer=read_to_buffer_varlen;
info->write_key=write_merge_key_varlen;
}
else
{
info->write_keys=write_keys;
info->read_to_buffer=read_to_buffer;
info->write_key=write_merge_key;
}
my_b_clear(&info->tempfile);
my_b_clear(&info->tempfile_for_exceptions);
bzero((char*) &info->buffpek,sizeof(info->buffpek));
@ -365,7 +397,7 @@ pthread_handler_decl(thr_find_all_keys,arg)
if (++idx == keys)
{
if (write_keys(info,sort_keys,idx-1,
if (info->write_keys(info,sort_keys,idx-1,
(BUFFPEK *)alloc_dynamic(&info->buffpek),
&info->tempfile))
goto err;
@ -379,7 +411,7 @@ pthread_handler_decl(thr_find_all_keys,arg)
goto err;
if (info->buffpek.elements)
{
if (write_keys(info,sort_keys, idx,
if (info->write_keys(info,sort_keys, idx,
(BUFFPEK *) alloc_dynamic(&info->buffpek), &info->tempfile))
goto err;
info->keys=(info->buffpek.elements-1)*(keys-1)+idx;
@ -464,6 +496,18 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
{
if (got_error)
continue;
if (sinfo->keyinfo->flag && HA_VAR_LENGTH_KEY)
{
sinfo->write_keys=write_keys_varlen;
sinfo->read_to_buffer=read_to_buffer_varlen;
sinfo->write_key=write_merge_key_varlen;
}
else
{
sinfo->write_keys=write_keys;
sinfo->read_to_buffer=read_to_buffer;
sinfo->write_key=write_merge_key;
}
if (sinfo->buffpek.elements)
{
uint maxbuffer=sinfo->buffpek.elements-1;
@ -568,6 +612,43 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys,
DBUG_RETURN(0);
} /* write_keys */
inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs)
{
int err;
uint16 len = _mi_keylength(info->keyinfo,bufs);
if (err=my_b_write(to_file,(byte*)&len,sizeof(len)))
return(err);
if (err=my_b_write(to_file,(byte*)bufs,(uint) len))
return(err);
return(0);
}
static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_keys,
uint count, BUFFPEK *buffpek, IO_CACHE *tempfile)
{
uchar **end;
int err;
DBUG_ENTER("write_keys_varlen");
qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp,
info);
if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
DBUG_RETURN(1); /* purecov: inspected */
buffpek->file_pos=my_b_tell(tempfile);
buffpek->count=count;
for (end=sort_keys+count ; sort_keys != end ; sort_keys++)
{
if (err=my_var_write(info,tempfile,*sort_keys))
DBUG_RETURN(err);
}
DBUG_RETURN(0);
} /* write_keys_varlen */
static int NEAR_F write_key(MI_SORT_PARAM *info, uchar *key,
IO_CACHE *tempfile)
@ -683,6 +764,59 @@ static uint NEAR_F read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
return (count*sort_length);
} /* read_to_buffer */
static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
uint sort_length)
{
register uint count;
uint16 length_of_key = 0;
uint idx;
uchar *buffp;
if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
{
buffp = buffpek->base;
for (idx=1;idx<=count;idx++)
{
if (my_pread(fromfile->file,(byte*)&length_of_key,sizeof(length_of_key),
buffpek->file_pos,MYF_RW))
return((uint) -1);
buffpek->file_pos+=sizeof(length_of_key);
if (my_pread(fromfile->file,(byte*) buffp,length_of_key,
buffpek->file_pos,MYF_RW))
return((uint) -1);
buffpek->file_pos+=length_of_key;
buffp = buffp + sort_length;
}
buffpek->key=buffpek->base;
buffpek->count-= count;
buffpek->mem_count= count;
}
return (count*sort_length);
} /* read_to_buffer_varlen */
static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, IO_CACHE *to_file,char* key,
uint sort_length, uint count)
{
uint idx;
char *bufs = key;
for (idx=1;idx<=count;idx++)
{
int err;
if (err = my_var_write(info,to_file,bufs))
return(err);
bufs=bufs+sort_length;
}
return(0);
}
static int NEAR_F write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file,char* key,
uint sort_length, uint count)
{
return(my_b_write(to_file,(byte*) key,(uint) sort_length*count));
}
/*
Merge buffers to one buffer
@ -722,8 +856,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
count+= buffpek->count;
buffpek->base= strpos;
buffpek->max_keys=maxcount;
strpos+= (uint) (error=(int) read_to_buffer(from_file,buffpek,
sort_length));
strpos+= (uint) (error=(int) info->read_to_buffer(from_file,buffpek,sort_length));
if (error == -1)
goto err; /* purecov: inspected */
queue_insert(&queue,(char*) buffpek);
@ -740,7 +873,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
buffpek=(BUFFPEK*) queue_top(&queue);
if (to_file)
{
if (my_b_write(to_file,(byte*) buffpek->key,(uint) sort_length))
if (info->write_key(info,to_file,(byte*) buffpek->key,(uint) sort_length,1))
{
error=1; goto err; /* purecov: inspected */
}
@ -755,7 +888,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
buffpek->key+=sort_length;
if (! --buffpek->mem_count)
{
if (!(error=(int) read_to_buffer(from_file,buffpek,sort_length)))
if (!(error=(int) info->read_to_buffer(from_file,buffpek,sort_length)))
{
uchar *base=buffpek->base;
uint max_keys=buffpek->max_keys;
@ -795,8 +928,8 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
{
if (to_file)
{
if (my_b_write(to_file,(byte*) buffpek->key,
(sort_length*buffpek->mem_count)))
if (info->write_key(info,to_file,(byte*) buffpek->key,
sort_length,buffpek->mem_count))
{
error=1; goto err; /* purecov: inspected */
}
@ -816,7 +949,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
}
}
}
while ((error=(int) read_to_buffer(from_file,buffpek,sort_length)) != -1 &&
while ((error=(int) info->read_to_buffer(from_file,buffpek,sort_length)) != -1 &&
error != 0);
lastbuff->count=count;

View File

@ -14,14 +14,15 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include
pkglib_LIBRARIES = libmyisammrg.a
noinst_HEADERS = myrg_def.h
libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c
myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \
myrg_rnext_same.c
# Don't update the files from bitkeeper
%::SCCS/s.%

View File

@ -62,9 +62,8 @@ int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key,
}
else
{
mi->use_packed_key=1;
mi->once_flags|= USE_PACKED_KEYS;
err=mi_rkey(mi,0,inx,key_buff,pack_key_length,search_flag);
mi->use_packed_key=0;
}
info->last_used_table=table+1;
@ -83,5 +82,6 @@ int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key,
return HA_ERR_KEY_NOT_FOUND;
mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table;
mi->once_flags|= RRND_PRESERVE_LASTINX;
return mi_rrnd(mi,record,mi->lastpos);
}

View File

@ -0,0 +1,40 @@
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program 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 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "myrg_def.h"
int myrg_rnext_same(MYRG_INFO *info, byte *buf)
{
uint err;
MI_INFO *mi;
if (!info->current_table)
return (HA_ERR_KEY_NOT_FOUND);
err=mi_rnext_same(info->current_table->table,buf);
if (err == HA_ERR_END_OF_FILE)
{
queue_remove(&(info->by_key),0);
if (!info->by_key.elements)
return HA_ERR_END_OF_FILE;
mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table;
mi->once_flags|= RRND_PRESERVE_LASTINX;
return mi_rrnd(mi,buf,mi->lastpos);
}
return err;
}

View File

@ -52,24 +52,3 @@ select min(big),max(big),max(big)-1 from t1 group by a;
min(big) max(big) max(big)-1
-1 9223372036854775807 9223372036854775806
drop table t1;
select CAST(1-2 AS UNSIGNED);
CAST(1-2 AS UNSIGNED)
18446744073709551615
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
-1
select CONVERT('-1',UNSIGNED);
CONVERT('-1',UNSIGNED)
18446744073709551615
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1
18446744073709551611 18446744073709551611
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
18446744073709551610 18446744073709551612
select ~5, cast(~5 as signed);
~5 cast(~5 as signed)
18446744073709551610 -6
select cast(5 as unsigned) -6.0;
cast(5 as unsigned) -6.0
-1.0

39
mysql-test/r/cast.result Normal file
View File

@ -0,0 +1,39 @@
select CAST(1-2 AS UNSIGNED);
CAST(1-2 AS UNSIGNED)
18446744073709551615
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
-1
select CONVERT('-1',UNSIGNED);
CONVERT('-1',UNSIGNED)
18446744073709551615
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1
18446744073709551611 18446744073709551611
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
18446744073709551610 18446744073709551612
select ~5, cast(~5 as signed);
~5 cast(~5 as signed)
18446744073709551610 -6
select cast(5 as unsigned) -6.0;
cast(5 as unsigned) -6.0
-1.0
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
cast("A" as binary) = "a" cast(BINARY "a" as CHAR) = "A"
0 1
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
cast("2001-1-1" as DATE) cast("2001-1-1" as DATETIME)
2001-1-1 2001-1-1
select cast("1:2:3" as TIME);
cast("1:2:3" as TIME)
1:2:3
select cast("2001-1-1" as date) = "2001-01-01";
cast("2001-1-1" as date) = "2001-01-01"
0
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
0
select cast("1:2:3" as TIME) = "1:02:03";
cast("1:2:3" as TIME) = "1:02:03"
0

View File

@ -0,0 +1,16 @@
drop table if exists t1;
create table t1 (a int check (a>0));
insert into t1 values (1);
insert into t1 values (0);
drop table t1;
create table t1 (a int ,b int, check a>b);
insert into t1 values (1,0);
insert into t1 values (0,1);
drop table t1;
create table t1 (a int ,b int, constraint abc check (a>b));
insert into t1 values (1,0);
insert into t1 values (0,1);
drop table t1;
create table t1 (a int null);
insert into t1 values (1),(NULL);
drop table t1;

View File

@ -65,3 +65,6 @@ a t
19 19
20 20
drop table if exists t1;
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a)));
(SELECT * FROM (SELECT 1 as a))
1

View File

@ -24,6 +24,12 @@ now()-curdate()*1000000-curtime()
select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
strcmp(current_timestamp(),concat(current_date()," ",current_time()))
0
select strcmp(localtime(),concat(current_date()," ",current_time()));
strcmp(localtime(),concat(current_date()," ",current_time()))
0
select strcmp(localtimestamp(),concat(current_date()," ",current_time()));
strcmp(localtimestamp(),concat(current_date()," ",current_time()))
0
select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")
January Thursday 2nd 1997 97 01 02 03 04 05 4

View File

@ -0,0 +1,97 @@
drop table if exists t1;
create table t1 (id integer, x integer) type=INNODB;
insert into t1 values(0, 0);
set autocommit=0;
SELECT * from t1 where id = 0 FOR UPDATE;
id x
0 0
set autocommit=0;
update t1 set x=2 where id = 0;
update t1 set x=1 where id = 0;
select * from t1;
id x
0 1
commit;
commit;
select * from t1;
id x
0 2
commit;
drop table t1;
drop table if exists t1, t2;
create table t1 (id integer, x integer) type=INNODB;
create table t2 (b integer, a integer) type=INNODB;
insert into t1 values(0, 0), (300, 300);
insert into t2 values(0, 10), (1, 20), (2, 30);
commit;
set autocommit=0;
select * from t2;
b a
0 10
1 20
2 30
update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE);
select * from t2;
b a
0 100
1 20
2 30
select * from t1;
id x
0 0
300 300
set autocommit=0;
update t1 set x=2 where id = 0;
update t1 set x=1 where id = 0;
select * from t1;
id x
0 1
300 300
commit;
commit;
select * from t1;
id x
0 2
300 300
commit;
drop table t1, t2;
create table t1 (id integer, x integer) type=INNODB;
create table t2 (b integer, a integer) type=INNODB;
insert into t1 values(0, 0), (300, 300);
insert into t2 values(0, 0), (1, 20), (2, 30);
commit;
select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
a b
0 0
20 1
30 2
300 300
select * from t2;
b a
0 0
1 20
2 30
select * from t1;
id x
0 0
300 300
update t2 set a=2 where b = 0;
select * from t2;
b a
0 2
1 20
2 30
update t1 set x=2 where id = 0;
update t1 set x=1 where id = 0;
select * from t1;
id x
0 1
300 300
commit;
commit;
select * from t1;
id x
0 2
300 300
commit;
drop table t1, t2;

View File

@ -98,3 +98,13 @@ commit;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
drop table if exists t1;
CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) TYPE=InnoDB;
select count(*) from t1;
count(*)
0
insert into t1 (id) values (0);
select count(*) from t1;
count(*)
1
drop table t1;

View File

@ -228,3 +228,36 @@ alter table t1 add key id (id);
select * from t1, t2 where t1.id = t2.id;
id id
drop table t1,t2;
create table t1 (
id integer,
id2 integer not null,
index (id),
index (id2)
);
insert into t1 values(null,null),(1,1);
select * from t1;
id id2
NULL 0
1 1
select * from t1 where id <=> null;
id id2
NULL 0
select * from t1 where id <=> null or id > 0;
id id2
NULL 0
1 1
select * from t1 where id is null or id > 0;
id id2
NULL 0
1 1
select * from t1 where id2 <=> null or id2 > 0;
id id2
1 1
select * from t1 where id2 is null or id2 > 0;
id id2
1 1
delete from t1 where id <=> NULL;
select * from t1;
id id2
1 1
drop table t1;

View File

@ -0,0 +1,60 @@
SELECT (1,2,3)=(1,2,3);
(1,2,3)=(1,2,3)
1
SELECT (2,2,3)=(1+1,2,3);
(2,2,3)=(1+1,2,3)
1
SELECT (1,2,3)=(1+1,2,3);
(1,2,3)=(1+1,2,3)
0
SELECT (1,2,3)<(1+1,2,3);
(1,2,3)<(1+1,2,3)
1
SELECT (1,2,3)>(1+1,2,3);
(1,2,3)>(1+1,2,3)
0
SELECT (1,2,3)<=(1+1,2,3);
(1,2,3)<=(1+1,2,3)
1
SELECT (1,2,3)>=(1+1,2,3);
(1,2,3)>=(1+1,2,3)
0
SELECT (1,2,3)<>(1+1,2,3);
(1,2,3)<>(1+1,2,3)
1
SELECT (NULL,2,3)=(NULL,2,3);
(NULL,2,3)=(NULL,2,3)
NULL
SELECT (NULL,2,3)<=>(NULL,2,3);
(NULL,2,3)<=>(NULL,2,3)
1
SELECT (1,2,(3,4,5))=(1,2,(3,4,5));
(1,2,(3,4,5))=(1,2,(3,4,5))
1
SELECT ('test',2,3.33)=('test',2,3.33);
('test',2,3.33)=('test',2,3.33)
1
SELECT ('test',2,3.33)=('test',2,3.33,4);
Cardinality error (more/less than 3 columns)
drop table if exists t1;
create table t1 ( a int, b int, c int);
insert into t1 values (1,2,3), (2,3,1), (3,2,1);
select * from t1 where (1,2,3)=(a,b,c);
a b c
1 2 3
select * from t1 where (0,2,3)=(a,b,c);
a b c
select * from t1 where (1,2,3)<(a,b,c);
a b c
2 3 1
3 2 1
drop table t1;
select (1,1);
Cardinality error (more/less than 1 columns)
drop table if exists t1;
create table t1 (i int);
select 1 from t1 where (1,1);
Cardinality error (more/less than 1 columns)
select count(*) from t1 order by (1,1);
Cardinality error (more/less than 1 columns)
drop table t1;

View File

@ -32,6 +32,17 @@ a
1
SELECT 1 FROM (SELECT (SELECT a));
Unknown column 'a' in 'field list'
SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
id
1
SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT 1,1);
Cardinality error (more/less than 1 columns)
SELECT 1 IN (SELECT 1);
1 IN (SELECT 1)
1
SELECT 1 FROM (SELECT 1 as a) WHERE 1 IN (SELECT (SELECT a));
1
1
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int);
create table t2 (a int, b int);
@ -125,6 +136,47 @@ select * from t3 where not exists (select * from t2 where t2.b=t3.a);
a
6
3
select * from t3 where a in (select b from t2);
a
7
select * from t3 where a not in (select b from t2);
a
6
3
select * from t3 where a = some (select b from t2);
a
7
select * from t3 where a <> any (select b from t2);
a
6
3
select * from t3 where a = all (select b from t2);
a
7
select * from t3 where a <> all (select b from t2);
a
6
3
insert into t2 values (100, 5);
select * from t3 where a < any (select b from t2);
a
6
3
select * from t3 where a < all (select b from t2);
a
3
select * from t3 where a >= any (select b from t2);
a
6
7
select * from t3 where a >= all (select b from t2);
a
7
delete from t2 where a=100;
select * from t3 where a in (select a,b from t2);
Cardinality error (more/less than 1 columns)
select * from t3 where a in (select * from t2);
Cardinality error (more/less than 1 columns)
insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9);
select b,max(a) as ma from t4 group by b having b < (select max(t2.a)
from t2 where t2.b=t4.b);
@ -200,10 +252,10 @@ id select_type table type possible_keys key key_len ref rows Extra
3 SUBSELECT t8 const PRIMARY PRIMARY 35 const 1
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
Subselect returns more than 1 field
Cardinality error (more/less than 1 columns)
SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
pseudo='joce');
Subselect returns more than 1 field
Cardinality error (more/less than 1 columns)
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
pseudo
joce
@ -269,8 +321,39 @@ numeropost maxnumrep
40143 1
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1);
Unknown column 'a' in 'having clause'
drop table t1, t2;
drop table if exists t1;
SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
Unknown column 'a' in 'having clause'
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY date);
mot topic date pseudo
joce 40143 2002-10-22 joce
joce 43506 2002-10-22 joce
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY date HAVING topic < 4100);
mot topic date pseudo
joce 43506 2002-10-22 joce
SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1);
mot topic date pseudo
SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY date);
mot topic date pseudo
joce 40143 2002-10-22 joce
joce 43506 2002-10-22 joce
SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY date HAVING topic < 4100);
mot topic date pseudo
joce 43506 2002-10-22 joce
SELECT * from t2 where topic = any (SELECT SUM(topic) FROM t1);
mot topic date pseudo
SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY date);
mot topic date pseudo
joce 40143 2002-10-22 joce
SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY date HAVING topic < 4100);
mot topic date pseudo
joce 40143 2002-10-22 joce
SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2);
mot topic date pseudo
SELECT * from t2 where topic <> any (SELECT SUM(topic) FROM t2);
mot topic date pseudo
joce 40143 2002-10-22 joce
joce 43506 2002-10-22 joce
drop table t1,t2;
CREATE TABLE `t1` (
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
`maxnumrep` int(10) unsigned NOT NULL default '0',
@ -319,3 +402,161 @@ SELECT 1 FROM (SELECT a FROM t1) HAVING (SELECT a)=1;
1
1
drop table t1;
create table t1 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
insert into t1 values (0, 10),(1, 11),(2, 12);
insert into t2 values (1, 21),(2, 22),(3, 23);
select * from t1;
a b
0 10
1 11
2 12
update t1 set b= (select b from t2 where t1.a = t2.a);
select * from t1;
a b
0 NULL
1 21
2 22
drop table t1, t2;
create table t1 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
insert into t1 values (0, 10),(1, 11),(2, 12);
insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t1;
a b
0 10
1 11
2 12
select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
delete from t1 where b = (select b from t2 where t1.a = t2.a);
select * from t1;
a b
0 10
1 11
drop table t1, t2;
drop table if exists t11, t12, t2;
create table t11 (a int NOT NULL, b int, primary key (a));
create table t12 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t11;
a b
0 10
1 11
2 12
select * from t12;
a b
33 10
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
drop table t11, t12, t2;
CREATE TABLE t1 (x int);
create table t2 (a int);
insert into t2 values (1);
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
select * from t1;
x
1
insert into t2 values (1);
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1;
x
1
2
INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
select * from t1;
x
1
2
3
3
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
INSERT TABLE 't1' isn't allowed in FROM table list
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t1));
select * from t1;
x
1
2
3
3
9
drop table t1, t2;
CREATE TABLE t1 (x int not null, y int, primary key (x));
create table t2 (a int);
insert into t2 values (1);
select * from t1;
x y
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
select * from t1;
x y
1 2
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+2 FROM t2));
select * from t1;
x y
1 3
replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a FROM t2));
select * from t1;
x y
1 3
4 1
replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2));
select * from t1;
x y
1 3
4 2
replace LOW_PRIORITY into t1 (x, y) VALUES ((SELECT a+1 FROM t2), (SELECT a FROM t2));
select * from t1;
x y
1 3
4 2
2 1
drop table t1, t2;
SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT *);
No tables used
drop table if exists t;
CREATE TABLE t (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
INSERT INTO t VALUES (1),(2);
SELECT * FROM t WHERE id IN (SELECT 1);
id
1
EXPLAIN SELECT * FROM t WHERE id IN (SELECT 1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t ref id id 5 const 1 Using where; Using index
Warnings:
Note 1246 Select 2 was reduced during optimisation
SELECT * FROM t WHERE id IN (SELECT 1 UNION SELECT 3);
id
1
SELECT * FROM t WHERE id IN (SELECT 1+(select 1));
id
2
EXPLAIN SELECT * FROM t WHERE id IN (SELECT 1+(select 1));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t ref id id 5 const 1 Using where; Using index
3 SUBSELECT No tables used
Warnings:
Note 1246 Select 2 was reduced during optimisation
EXPLAIN SELECT * FROM t WHERE id IN (SELECT 1 UNION SELECT 3);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t index NULL id 5 NULL 2 Using where; Using index
2 DEPENDENT SUBSELECT No tables used
3 UNION No tables used
SELECT * FROM t WHERE id IN (SELECT 5 UNION SELECT 3);
id
SELECT * FROM t WHERE id IN (SELECT 5 UNION SELECT 2);
id
2
drop table if exists t;

View File

@ -35,11 +35,3 @@ alter table t1 modify big bigint not null;
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
drop table t1;
select CAST(1-2 AS UNSIGNED);
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
select CONVERT('-1',UNSIGNED);
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
select ~5, cast(~5 as signed);
select cast(5 as unsigned) -6.0;

22
mysql-test/t/cast.test Normal file
View File

@ -0,0 +1,22 @@
#
# Test of cast function
#
select CAST(1-2 AS UNSIGNED);
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
select CONVERT('-1',UNSIGNED);
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
select ~5, cast(~5 as signed);
select cast(5 as unsigned) -6.0;
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
select cast("1:2:3" as TIME);
#
# The following should be fixed in 4.1
#
select cast("2001-1-1" as date) = "2001-01-01";
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
select cast("1:2:3" as TIME) = "1:02:03";

View File

@ -0,0 +1,21 @@
#
# Testing of constraints
# Currently MySQL only ignores the syntax.
#
drop table if exists t1;
create table t1 (a int check (a>0));
insert into t1 values (1);
insert into t1 values (0);
drop table t1;
create table t1 (a int ,b int, check a>b);
insert into t1 values (1,0);
insert into t1 values (0,1);
drop table t1;
create table t1 (a int ,b int, constraint abc check (a>b));
insert into t1 values (1,0);
insert into t1 values (0,1);
drop table t1;
create table t1 (a int null);
insert into t1 values (1),(NULL);
drop table t1;

View File

@ -34,3 +34,4 @@ while ($1)
enable_query_log;
SELECT * FROM (SELECT * FROM t1) ORDER BY a ASC LIMIT 0,20;
drop table if exists t1;
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a)));

View File

@ -12,6 +12,8 @@ select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
select sec_to_time(time_to_sec('-838:59:59'));
select now()-curdate()*1000000-curtime();
select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
select strcmp(localtime(),concat(current_date()," ",current_time()));
select strcmp(localtimestamp(),concat(current_date()," ",current_time()));
select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
select date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w"));
select dayofmonth("1997-01-02"),dayofmonth(19970323);
@ -164,6 +166,7 @@ select to_days("0000-00-00"),to_days(d),to_days(dt),to_days(t),to_days(c) from t
select extract(MONTH FROM "0000-00-00"),extract(MONTH FROM d),extract(MONTH FROM dt),extract(MONTH FROM t),extract(MONTH FROM c) from t1;
drop table t1;
#
# Test problem with TIMESTAMP and BETWEEN
#

View File

@ -0,0 +1,111 @@
-- source include/have_innodb.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
drop table if exists t1;
#
# Testing of FOR UPDATE
#
connection con1;
create table t1 (id integer, x integer) type=INNODB;
insert into t1 values(0, 0);
set autocommit=0;
SELECT * from t1 where id = 0 FOR UPDATE;
connection con2;
set autocommit=0;
# The following query should hang because con1 is locking the page
--send
update t1 set x=2 where id = 0;
--sleep 2;
connection con1;
update t1 set x=1 where id = 0;
select * from t1;
commit;
connection con2;
reap;
commit;
connection con1;
select * from t1;
commit;
drop table t1;
drop table if exists t1, t2;
#
# Testing of FOR UPDATE
#
connection con1;
create table t1 (id integer, x integer) type=INNODB;
create table t2 (b integer, a integer) type=INNODB;
insert into t1 values(0, 0), (300, 300);
insert into t2 values(0, 10), (1, 20), (2, 30);
commit;
set autocommit=0;
select * from t2;
update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE);
select * from t2;
select * from t1;
connection con2;
set autocommit=0;
# The following query should hang because con1 is locking the page
--send
update t1 set x=2 where id = 0;
--sleep 2;
connection con1;
update t1 set x=1 where id = 0;
select * from t1;
commit;
connection con2;
reap;
commit;
connection con1;
select * from t1;
commit;
drop table t1, t2;
create table t1 (id integer, x integer) type=INNODB;
create table t2 (b integer, a integer) type=INNODB;
insert into t1 values(0, 0), (300, 300);
insert into t2 values(0, 0), (1, 20), (2, 30);
commit;
connection con1;
select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
select * from t2;
select * from t1;
connection con2;
# The following query should hang because con1 is locking the page
update t2 set a=2 where b = 0;
select * from t2;
--send
update t1 set x=2 where id = 0;
--sleep 2;
connection con1;
update t1 set x=1 where id = 0;
select * from t1;
commit;
connection con2;
reap;
commit;
connection con1;
select * from t1;
commit;
drop table t1, t2;

View File

@ -48,3 +48,10 @@ show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";
commit;
show status like "Qcache_queries_in_cache";
drop table if exists t1;
CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) TYPE=InnoDB;
select count(*) from t1;
insert into t1 (id) values (0);
select count(*) from t1;
drop table t1;

View File

@ -135,3 +135,24 @@ select * from t1, t2 where t1.id = t2.id;
alter table t1 add key id (id);
select * from t1, t2 where t1.id = t2.id;
drop table t1,t2;
#
# Check bug when doing <=> NULL on an indexed null field
#
create table t1 (
id integer,
id2 integer not null,
index (id),
index (id2)
);
insert into t1 values(null,null),(1,1);
select * from t1;
select * from t1 where id <=> null;
select * from t1 where id <=> null or id > 0;
select * from t1 where id is null or id > 0;
select * from t1 where id2 <=> null or id2 > 0;
select * from t1 where id2 is null or id2 > 0;
delete from t1 where id <=> NULL;
select * from t1;
drop table t1;

View File

@ -0,0 +1,36 @@
SELECT (1,2,3)=(1,2,3);
SELECT (2,2,3)=(1+1,2,3);
SELECT (1,2,3)=(1+1,2,3);
SELECT (1,2,3)<(1+1,2,3);
SELECT (1,2,3)>(1+1,2,3);
SELECT (1,2,3)<=(1+1,2,3);
SELECT (1,2,3)>=(1+1,2,3);
SELECT (1,2,3)<>(1+1,2,3);
SELECT (NULL,2,3)=(NULL,2,3);
SELECT (NULL,2,3)<=>(NULL,2,3);
SELECT (1,2,(3,4,5))=(1,2,(3,4,5));
SELECT ('test',2,3.33)=('test',2,3.33);
-- error 1239
SELECT ('test',2,3.33)=('test',2,3.33,4);
drop table if exists t1;
create table t1 ( a int, b int, c int);
insert into t1 values (1,2,3), (2,3,1), (3,2,1);
select * from t1 where (1,2,3)=(a,b,c);
select * from t1 where (0,2,3)=(a,b,c);
select * from t1 where (1,2,3)<(a,b,c);
drop table t1;
-- error 1239
select (1,1);
drop table if exists t1;
create table t1 (i int);
-- error 1239
select 1 from t1 where (1,1);
-- error 1239
select count(*) from t1 order by (1,1);
#TODO remove comments after parser fixing
#-- error 1239
#select count(*) from t1 order by i having (1,1);
#-- error 1239
#select 1 from t1 limit (1,1), (1,1);
drop table t1;

View File

@ -15,6 +15,12 @@ SELECT (SELECT 1), a;
SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1;
-- error 1054
SELECT 1 FROM (SELECT (SELECT a));
SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
-- error 1239
SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT 1,1);
SELECT 1 IN (SELECT 1);
SELECT 1 FROM (SELECT 1 as a) WHERE 1 IN (SELECT (SELECT a));
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int);
create table t2 (a int, b int);
@ -50,6 +56,22 @@ select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2
explain select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4;
select * from t3 where exists (select * from t2 where t2.b=t3.a);
select * from t3 where not exists (select * from t2 where t2.b=t3.a);
select * from t3 where a in (select b from t2);
select * from t3 where a not in (select b from t2);
select * from t3 where a = some (select b from t2);
select * from t3 where a <> any (select b from t2);
select * from t3 where a = all (select b from t2);
select * from t3 where a <> all (select b from t2);
insert into t2 values (100, 5);
select * from t3 where a < any (select b from t2);
select * from t3 where a < all (select b from t2);
select * from t3 where a >= any (select b from t2);
select * from t3 where a >= all (select b from t2);
delete from t2 where a=100;
-- error 1239
select * from t3 where a in (select a,b from t2);
-- error 1239
select * from t3 where a in (select * from t2);
insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9);
select b,max(a) as ma from t4 group by b having b < (select max(t2.a)
from t2 where t2.b=t4.b);
@ -112,7 +134,7 @@ SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%jo
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
#searchconthardwarefr3
#searchconthardwarefr3 forumconthardwarefr7
CREATE TABLE `t1` (
`topic` mediumint(8) unsigned NOT NULL default '0',
`date` date NOT NULL default '0000-00-00',
@ -155,10 +177,21 @@ select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20;
-- error 1054
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1);
drop table t1, t2;
-- error 1054
SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY date);
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY date HAVING topic < 4100);
SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1);
SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY date);
SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY date HAVING topic < 4100);
SELECT * from t2 where topic = any (SELECT SUM(topic) FROM t1);
SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY date);
SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY date HAVING topic < 4100);
SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2);
SELECT * from t2 where topic <> any (SELECT SUM(topic) FROM t2);
drop table t1,t2;
#forumconthardwarefr7
drop table if exists t1;
CREATE TABLE `t1` (
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
`maxnumrep` int(10) unsigned NOT NULL default '0',
@ -200,7 +233,98 @@ EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1
EXPLAIN SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
SELECT 1 FROM (SELECT a FROM t1) HAVING (SELECT a)=1;
drop table t1;
#update with subselects
create table t1 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
insert into t1 values (0, 10),(1, 11),(2, 12);
insert into t2 values (1, 21),(2, 22),(3, 23);
select * from t1;
update t1 set b= (select b from t2 where t1.a = t2.a);
select * from t1;
drop table t1, t2;
#delete with subselects
create table t1 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
insert into t1 values (0, 10),(1, 11),(2, 12);
insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t1;
select * from t1 where b = (select b from t2 where t1.a = t2.a);
delete from t1 where b = (select b from t2 where t1.a = t2.a);
select * from t1;
drop table t1, t2;
#multi-delete with subselects
drop table if exists t11, t12, t2;
create table t11 (a int NOT NULL, b int, primary key (a));
create table t12 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t11;
select * from t12;
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
select * from t11;
select * from t12;
drop table t11, t12, t2;
#insert with subselects
CREATE TABLE t1 (x int);
create table t2 (a int);
insert into t2 values (1);
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
select * from t1;
insert into t2 values (1);
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
-- sleep 1
select * from t1;
INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
select * from t1;
-- error 1093
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t1));
-- sleep 1
select * from t1;
drop table t1, t2;
#replace with subselects
CREATE TABLE t1 (x int not null, y int, primary key (x));
create table t2 (a int);
insert into t2 values (1);
select * from t1;
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
select * from t1;
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+2 FROM t2));
select * from t1;
replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a FROM t2));
-- sleep 1
select * from t1;
replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2));
-- sleep 1
select * from t1;
replace LOW_PRIORITY into t1 (x, y) VALUES ((SELECT a+1 FROM t2), (SELECT a FROM t2));
select * from t1;
drop table t1, t2;
-- error 1096
SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT *);
drop table if exists t;
CREATE TABLE t (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
INSERT INTO t VALUES (1),(2);
SELECT * FROM t WHERE id IN (SELECT 1);
EXPLAIN SELECT * FROM t WHERE id IN (SELECT 1);
SELECT * FROM t WHERE id IN (SELECT 1 UNION SELECT 3);
SELECT * FROM t WHERE id IN (SELECT 1+(select 1));
EXPLAIN SELECT * FROM t WHERE id IN (SELECT 1+(select 1));
EXPLAIN SELECT * FROM t WHERE id IN (SELECT 1 UNION SELECT 3);
SELECT * FROM t WHERE id IN (SELECT 5 UNION SELECT 3);
SELECT * FROM t WHERE id IN (SELECT 5 UNION SELECT 2);
drop table if exists t;

View File

@ -17,7 +17,7 @@
MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include -I.. -I$(srcdir)
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include -I$(srcdir)
pkglib_LIBRARIES = libmysys.a
LDADD = libmysys.a ../dbug/libdbug.a \
../strings/libmystrings.a

View File

@ -391,10 +391,11 @@ static CHARSET_INFO *add_charset(CHARSET_INFO *cs, myf flags)
cs->hash_caseup = my_hash_caseup_simple;
cs->hash_sort = my_hash_sort_simple;
cs->snprintf = my_snprintf_8bit;
cs->strtol = my_strtol_8bit;
cs->strtoul = my_strtoul_8bit;
cs->strtoll = my_strtoll_8bit;
cs->strtoull = my_strtoull_8bit;
cs->strntol = my_strntol_8bit;
cs->strntoul = my_strntoul_8bit;
cs->strntoll = my_strntoll_8bit;
cs->strntoull = my_strntoull_8bit;
cs->strntod = my_strntod_8bit;
cs->mbmaxlen = 1;
set_max_sort_char(cs);

View File

@ -55,7 +55,7 @@ LIST *list_delete(LIST *root, LIST *element)
}
void list_free(LIST *root, pbool free_data)
void list_free(LIST *root, uint free_data)
{
LIST *next;
while (root)

View File

@ -335,54 +335,67 @@ void *tree_search_key(TREE *tree, const void *key,
enum ha_rkey_function flag, void *custom_arg)
{
int cmp;
TREE_ELEMENT *element = tree->root;
TREE_ELEMENT **last_left_step_parent = NULL;
TREE_ELEMENT **last_equal_element = NULL;
TREE_ELEMENT *element= tree->root;
TREE_ELEMENT **last_left_step_parent= NULL, **last_right_step_parent= NULL;
TREE_ELEMENT **last_equal_element= NULL;
/*
TODO: handle HA_READ_KEY_OR_PREV, HA_READ_BEFORE_KEY, HA_READ_PREFIX,
HA_READ_PREFIX_LAST flags if needed.
TODO: support for HA_READ_KEY_OR_PREV, HA_READ_PREFIX flags if needed.
*/
*parents = &tree->null_element;
while (element != &tree->null_element)
{
*++parents = element;
if ((cmp = (*tree->compare)(custom_arg, ELEMENT_KEY(tree, element),
key)) == 0)
*++parents= element;
if ((cmp= (*tree->compare)(custom_arg, ELEMENT_KEY(tree, element),
key)) == 0)
{
switch (flag) {
case HA_READ_KEY_EXACT:
case HA_READ_KEY_OR_NEXT:
last_equal_element = parents;
cmp = 1;
break;
case HA_READ_BEFORE_KEY:
last_equal_element= parents;
cmp= 1;
break;
case HA_READ_AFTER_KEY:
cmp = -1;
break;
cmp= -1;
break;
case HA_READ_PREFIX_LAST:
case HA_READ_PREFIX_LAST_OR_PREV:
last_equal_element= parents;
cmp= -1;
break;
default:
return NULL;
return NULL;
}
}
if (cmp < 0) /* element < key */
{
element = element->right;
last_right_step_parent= parents;
element= element->right;
}
else
{
last_left_step_parent = parents;
element = element->left;
last_left_step_parent= parents;
element= element->left;
}
}
switch (flag) {
case HA_READ_KEY_EXACT:
*last_pos = last_equal_element;
case HA_READ_PREFIX_LAST:
*last_pos= last_equal_element;
break;
case HA_READ_KEY_OR_NEXT:
*last_pos = last_equal_element ? last_equal_element : last_left_step_parent;
*last_pos= last_equal_element ? last_equal_element : last_left_step_parent;
break;
case HA_READ_AFTER_KEY:
*last_pos = last_left_step_parent;
*last_pos= last_left_step_parent;
break;
case HA_READ_PREFIX_LAST_OR_PREV:
*last_pos= last_equal_element ? last_equal_element : last_right_step_parent;
break;
case HA_READ_BEFORE_KEY:
*last_pos= last_right_step_parent;
break;
default:
return NULL;

View File

@ -20,7 +20,7 @@
#
SUBDIRS = aout
INCLUDES = -I$(srcdir)/../include -I../include
INCLUDES = -I$(top_srcdir)/include
noinst_HEADERS = bucomm.h debug.h ieee.h budbg.h demangle.h \
linuxthreads.h pstack.h pstacktrace.h
SRC= bucomm.c filemode.c linuxthreads.c rddbg.c \

View File

@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
59 Temple Place, Suite 330, Boston, MA 02111 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -305,7 +305,7 @@ the "copyright" line and a pointer to where the full notice is found.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Also add information on how to contact you by electronic and paper mail.

View File

@ -1,73 +1,81 @@
Basic Installation
==================
These are generic installation instructions.
These are installation instructions for Readline-4.3.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
The simplest way to compile readline is:
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
1. `cd' to the directory containing the readline source code and type
`./configure' to configure readline for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
Running `configure' takes some time. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
2. Type `make' to compile readline and build the static readline
and history libraries. If supported, the shared readline and history
libraries will be built also. See below for instructions on compiling
the other parts of the distribution. Typing `make everything' will
cause the static and shared libraries (if supported) and the example
programs to be built.
3. Optionally, type `make check' to run any self-tests that come with
the package.
3. Type `make install' to install the static readline and history
libraries, the readline include files, the documentation, and, if
supported, the shared readline and history libraries.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
4. You can remove the created libraries and object files from the
build directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile readline for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
for the readline developers, and should be used with care.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It
uses those values to create a `Makefile' in the build directory,
and Makefiles in the `doc', `shlib', and `examples'
subdirectories. It also creates a `config.h' file containing
system-dependent definitions. Finally, it creates a shell script
`config.status' that you can run in the future to recreate the
current configuration, a file `config.cache' that saves the
results of its tests to speed up reconfiguring, and a file
`config.log' containing compiler output (useful mainly for
debugging `configure').
If you need to do unusual things to compile readline, please try
to figure out how `configure' could check whether to do them, and
mail diffs or instructions to <bug-readline@gnu.org> so they can
be considered for the next release. If at some point
`config.cache' contains results you don't want to keep, you may
remove or edit it.
The file `configure.in' is used to create `configure' by a
program called `autoconf'. You only need `configure.in' if you
want to change it or regenerate `configure' using a newer version
of `autoconf'. The readline `configure.in' requires autoconf
version 2.50 or newer.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
You can compile readline for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
@ -75,80 +83,59 @@ directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile readline for one architecture at a
time in the source code directory. After you have installed
readline for one architecture, use `make distclean' before
reconfiguring for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
By default, `make install' will install the readline libraries in
`/usr/local/lib', the include files in
`/usr/local/include/readline', the man pages in `/usr/local/man',
and the info files in `/usr/local/info'. You can specify an
installation prefix other than `/usr/local' by giving `configure'
the option `--prefix=PATH' or by supplying a value for the
DESTDIR variable when running `make install'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files.
If you give `configure' the option `--exec-prefix=PATH', the
readline Makefiles will use PATH as the prefix for installing the
libraries. Documentation and other data files will still use the
regular prefix.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
There may be some features `configure' can not figure out
automatically, but need to determine by the type of host readline
will run on. Usually `configure' can figure that out, but if it
prints a message saying it can not guess the host type, give it
the `--host=TYPE' option. TYPE can either be a short name for
the system type, such as `sun4', or a canonical name with three
fields: CPU-COMPANY-SYSTEM (e.g., i386-unknown-freebsd4.2).
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
See the file `config.sub' for the possible values of each field.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
A warning: the readline `configure' looks for a site script, but not
all `configure' scripts do.
Operation Controls
==================
`configure' recognizes the following options to control how it
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
@ -174,3 +161,113 @@ operates.
`configure' also accepts some other, not widely useful, options.
Optional Features
=================
The readline `configure' recognizes a single `--with-PACKAGE' option:
`--with-curses'
This tells readline that it can find the termcap library functions
(tgetent, et al.) in the curses library, rather than a separate
termcap library. Readline uses the termcap functions, but does not
link with the termcap or curses library itself, allowing applications
which link with readline the to choose an appropriate library.
This option tells readline to link the example programs with the
curses library rather than libtermcap.
`configure' also recognizes two `--enable-FEATURE' options:
`--enable-shared'
Build the shared libraries by default on supported platforms. The
default is `yes'.
`--enable-static'
Build the static libraries by default. The default is `yes'.
Shared Libraries
================
There is support for building shared versions of the readline and
history libraries. The configure script creates a Makefile in
the `shlib' subdirectory, and typing `make shared' will cause
shared versions of the readline and history libraries to be built
on supported platforms.
If `configure' is given the `--enable-shared' option, it will attempt
to build the shared libraries by default on supported platforms.
Configure calls the script support/shobj-conf to test whether or
not shared library creation is supported and to generate the values
of variables that are substituted into shlib/Makefile. If you
try to build shared libraries on an unsupported platform, `make'
will display a message asking you to update support/shobj-conf for
your platform.
If you need to update support/shobj-conf, you will need to create
a `stanza' for your operating system and compiler. The script uses
the value of host_os and ${CC} as determined by configure. For
instance, FreeBSD 4.2 with any version of gcc is identified as
`freebsd4.2-gcc*'.
In the stanza for your operating system-compiler pair, you will need to
define several variables. They are:
SHOBJ_CC The C compiler used to compile source files into shareable
object files. This is normally set to the value of ${CC}
by configure, and should not need to be changed.
SHOBJ_CFLAGS Flags to pass to the C compiler ($SHOBJ_CC) to create
position-independent code. If you are using gcc, this
should probably be set to `-fpic'.
SHOBJ_LD The link editor to be used to create the shared library from
the object files created by $SHOBJ_CC. If you are using
gcc, a value of `gcc' will probably work.
SHOBJ_LDFLAGS Flags to pass to SHOBJ_LD to enable shared object creation.
If you are using gcc, `-shared' may be all that is necessary.
These should be the flags needed for generic shared object
creation.
SHLIB_XLDFLAGS Additional flags to pass to SHOBJ_LD for shared library
creation. Many systems use the -R option to the link
editor to embed a path within the library for run-time
library searches. A reasonable value for such systems would
be `-R$(libdir)'.
SHLIB_LIBS Any additional libraries that shared libraries should be
linked against when they are created.
SHLIB_LIBSUFF The suffix to add to `libreadline' and `libhistory' when
generating the filename of the shared library. Many systems
use `so'; HP-UX uses `sl'.
SHLIB_LIBVERSION The string to append to the filename to indicate the version
of the shared library. It should begin with $(SHLIB_LIBSUFF),
and possibly include version information that allows the
run-time loader to load the version of the shared library
appropriate for a particular program. Systems using shared
libraries similar to SunOS 4.x use major and minor library
version numbers; for those systems a value of
`$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' is appropriate.
Systems based on System V Release 4 don't use minor version
numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
Other Unix versions use different schemes.
SHLIB_STATUS Set this to `supported' when you have defined the other
necessary variables. Make uses this to determine whether
or not shared library creation should be attempted. If
shared libraries are not supported, this will be set to
`unsupported'.
You should look at the existing stanzas in support/shobj-conf for ideas.
Once you have updated support/shobj-conf, re-run configure and type
`make shared' or `make'. The shared libraries will be created in the
shlib subdirectory.
If shared libraries are created, `make install' will install them.
You may install only the shared libraries by running `make
install-shared' from the top-level build directory. Running `make
install' in the shlib subdirectory will also work. If you don't want
to install any created shared libraries, run `make install-static'.

View File

@ -2,7 +2,7 @@
# Makefile for the GNU readline library.
# Copyright (C) 1994,1996,1997 Free Software Foundation, Inc.
INCLUDES = -I$(srcdir)/../include -I$(srcdir)/.. -I..
INCLUDES = -I$(top_srcdir)/include
noinst_LIBRARIES = libreadline.a
@ -15,7 +15,7 @@ libreadline_a_SOURCES = readline.c funmap.c keymaps.c \
callback.c terminal.c xmalloc.c \
history.c histsearch.c histexpand.c \
histfile.c nls.c search.c \
shell.c tilde.c
shell.c tilde.c misc.c text.c mbutil.c
pkginclude_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h

View File

@ -1,7 +1,7 @@
Introduction
============
This is the Gnu Readline library, version 4.0.
This is the Gnu Readline library, version 4.3.
The Readline library provides a set of functions for use by applications
that allow users to edit command lines as they are typed in. Both
@ -16,8 +16,8 @@ may be used without Readline in applications which desire its
capabilities.
The Readline library is free software, distributed under the terms of
the GNU Public License, version 2. For more information, see the file
COPYING.
the [GNU] General Public License, version 2. For more information, see
the file COPYING.
To build the library, try typing `./configure', then `make'. The
configuration process is automated, so no further intervention should
@ -37,6 +37,9 @@ to customize and control the build process.
The file rlconf.h contains C preprocessor defines that enable and disable
certain Readline features.
The special make target `everything' will build the static and shared
libraries (if the target platform supports them) and the examples.
Examples
========
@ -54,6 +57,9 @@ a Makefile in the `shlib' subdirectory, and typing `make shared'
will cause shared versions of the Readline and History libraries
to be built on supported platforms.
If `configure' is given the `--enable-shared' option, it will attempt
to build the shared libraries by default on supported platforms.
Configure calls the script support/shobj-conf to test whether or
not shared library creation is supported and to generate the values
of variables that are substituted into shlib/Makefile. If you
@ -64,8 +70,8 @@ your platform.
If you need to update support/shobj-conf, you will need to create
a `stanza' for your operating system and compiler. The script uses
the value of host_os and ${CC} as determined by configure. For
instance, FreeBSD 2.2.5 with any version of gcc is identified as
`freebsd2.2.5-gcc*'.
instance, FreeBSD 4.2 with any version of gcc is identified as
`freebsd4.2-gcc*'.
In the stanza for your operating system-compiler pair, you will need to
define several variables. They are:
@ -122,18 +128,21 @@ Once you have updated support/shobj-conf, re-run configure and type
`make shared'. The shared libraries will be created in the shlib
subdirectory.
Since shared libraries are not created on all platforms, `make install'
will not automatically install the shared libraries. To install them,
change the current directory to shlib and type `make install'. Running
`make install-shared' from the top-level build directory will also work.
If shared libraries are created, `make install' will install them.
You may install only the shared libraries by running `make
install-shared' from the top-level build directory. Running `make
install' in the shlib subdirectory will also work. If you don't want
to install any created shared libraries, run `make install-static'.
Documentation
=============
The documentation for the Readline and History libraries appears in the
`doc' subdirectory. There are two texinfo files and a Unix-style manual
page describing the programming facilities available in the Readline
library. The texinfo files include both user and programmer's manuals.
The documentation for the Readline and History libraries appears in
the `doc' subdirectory. There are three texinfo files and a
Unix-style manual page describing the facilities available in the
Readline library. The texinfo files include both user and
programmer's manuals. HTML versions of the manuals appear in the
`doc' subdirectory as well.
Reporting Bugs
==============
@ -144,7 +153,7 @@ Bug reports for Readline should be sent to:
When reporting a bug, please include the following information:
* the version number and release status of Readline (e.g., 4.0-release)
* the version number and release status of Readline (e.g., 4.2-release)
* the machine and OS that it is running on
* a list of the compilation flags or the contents of `config.h', if
appropriate

View File

@ -18,18 +18,31 @@
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
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 long int atol ();
extern double atof ();
extern double strtod ();
/* Memory allocation functions. */
extern char *malloc ();
extern char *realloc ();
/* 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. */

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
The GNU Readline 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 1, or
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@ -18,7 +18,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@ -29,22 +29,20 @@
#if defined (READLINE_CALLBACKS)
#include <stdlib.h>
#include <sys/types.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif
#include <stdio.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "readline.h"
extern void readline_internal_setup ();
extern char *readline_internal_teardown ();
extern int readline_internal_char ();
extern void _rl_init_line_state ();
extern int _rl_meta_flag;
extern char *rl_prompt;
extern int rl_visible_prompt_length;
#include "rlprivate.h"
/* **************************************************************** */
/* */
@ -61,7 +59,7 @@ extern int rl_visible_prompt_length;
text read in at each end of line. The terminal is kept prepped and
signals handled all the time, except during calls to the user's function. */
VFunction *rl_linefunc; /* user callback function */
rl_vcpfunc_t *rl_linefunc; /* user callback function */
static int in_handler; /* terminal_prepped and signals set? */
/* Make sure the terminal is set up, initialize readline, and prompt. */
@ -87,11 +85,10 @@ _rl_callback_newline ()
/* Install a readline handler, set up the terminal, and issue the prompt. */
void
rl_callback_handler_install (prompt, linefunc)
char *prompt;
VFunction *linefunc;
const char *prompt;
rl_vcpfunc_t *linefunc;
{
rl_prompt = prompt;
rl_visible_prompt_length = rl_prompt ? rl_expand_prompt (rl_prompt) : 0;
rl_set_prompt (prompt);
rl_linefunc = linefunc;
_rl_callback_newline ();
}
@ -111,24 +108,33 @@ rl_callback_read_char ()
eof = readline_internal_char ();
if (rl_done)
/* We loop in case some function has pushed input back with rl_execute_next. */
for (;;)
{
line = readline_internal_teardown (eof);
if (rl_done)
{
line = readline_internal_teardown (eof);
(*rl_deprep_term_function) ();
(*rl_deprep_term_function) ();
#if defined (HANDLE_SIGNALS)
rl_clear_signals ();
rl_clear_signals ();
#endif
in_handler = 0;
(*rl_linefunc) (line);
in_handler = 0;
(*rl_linefunc) (line);
/* If the user did not clear out the line, do it for him. */
if (rl_line_buffer[0])
_rl_init_line_state ();
/* If the user did not clear out the line, do it for him. */
if (rl_line_buffer[0])
_rl_init_line_state ();
/* Redisplay the prompt if readline_handler_{install,remove} not called. */
if (in_handler == 0 && rl_linefunc)
_rl_callback_newline ();
/* Redisplay the prompt if readline_handler_{install,remove}
not called. */
if (in_handler == 0 && rl_linefunc)
_rl_callback_newline ();
}
if (rl_pending_input)
eof = readline_internal_char ();
else
break;
}
}

View File

@ -7,7 +7,7 @@
The GNU Readline 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 1, or
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@ -18,21 +18,23 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _CHARDEFS_H_
#define _CHARDEFS_H_
#ifndef _m_ctype_h
#include <ctype.h>
#endif
#if defined (HAVE_CONFIG_H)
# if defined (HAVE_STRING_H)
# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
# include <memory.h>
# endif
# include <string.h>
# else
# include <strings.h>
# endif /* HAVE_STRING_H */
# if defined (HAVE_STRINGS_H)
# include <strings.h>
# endif /* HAVE_STRINGS_H */
#else
# include <string.h>
#endif /* !HAVE_CONFIG_H */
@ -42,7 +44,10 @@
#endif
#ifdef CTRL
#undef CTRL
# undef CTRL
#endif
#ifdef UNCTRL
# undef UNCTRL
#endif
/* Some character stuff. */
@ -53,7 +58,7 @@
#define meta_character_bit 0x080 /* x0000000, must be on. */
#define largest_char 255 /* Largest character value. */
#define CTRL_CHAR(c) ((c) < control_character_threshold && (c) >= 0)
#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
#define CTRL(c) ((c) & control_character_mask)
@ -62,33 +67,59 @@
#define UNMETA(c) ((c) & (~meta_character_bit))
#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
/* Old versions
#define _rl_lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
#define _rl_uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
*/
#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
# define IN_CTYPE_DOMAIN(c) 1
#else
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
#define _rl_lowercase_p(c) (islower(c))
#define _rl_uppercase_p(c) (isupper(c))
#define _rl_digit_p(x) (isdigit (x))
#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
#endif
#define _rl_pure_alphabetic(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c))
#define ALPHABETIC(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c) || _rl_digit_p(c))
#define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
/* Old versions
# define _rl_to_upper(c) (_rl_lowercase_p(c) ? ((c) - 32) : (c))
# define _rl_to_lower(c) (_rl_uppercase_p(c) ? ((c) + 32) : (c))
*/
/* Some systems define these; we want our definitions. */
#undef ISPRINT
#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c))
#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c))
#ifndef _rl_to_upper
# define _rl_to_upper(c) (islower(c) ? toupper(c) : (c))
# define _rl_to_lower(c) (isupper(c) ? tolower(c) : (c))
# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
#endif
#ifndef _rl_digit_value
#define _rl_digit_value(x) ((x) - '0')
# define _rl_digit_value(x) ((x) - '0')
#endif
#ifndef _rl_isident
# define _rl_isident(c) (ISALNUM(c) || (c) == '_')
#endif
#ifndef ISOCTAL
# define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
#endif
#define OCTVALUE(c) ((c) - '0')
#define HEXVALUE(c) \
(((c) >= 'a' && (c) <= 'f') \
? (c)-'a'+10 \
: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
#ifndef NEWLINE
#define NEWLINE '\n'
#endif
@ -125,18 +156,4 @@
#endif
#define ESC CTRL('[')
#ifndef ISOCTAL
#define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
#endif
#define OCTVALUE(c) ((c) - '0')
#ifndef isxdigit
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
#endif
#define HEXVALUE(c) \
(((c) >= 'a' && (c) <= 'f') \
? (c)-'a'+10 \
: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
#endif /* _CHARDEFS_H_ */

File diff suppressed because it is too large Load Diff

6130
readline/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -4,34 +4,49 @@ dnl
dnl report bugs to chet@po.cwru.edu
dnl
dnl Process this file with autoconf to produce a configure script.
AC_REVISION([for Readline 4.0, version 2.14, from autoconf version] AC_ACVERSION)
LIBVERSION=4.0
AC_REVISION([for Readline 4.3, version 2.45, from autoconf version] AC_ACVERSION)
AC_INIT(readline.h)
AC_CONFIG_HEADER(config.h)
AC_INIT(readline, 4.3, bug-readline@gnu.org)
dnl make sure we are using a recent autoconf version
AC_PREREQ(2.10)
AC_PREREQ(2.50)
AC_CONFIG_SRCDIR(readline.h)
AC_CONFIG_AUX_DIR(./support)
AC_CONFIG_HEADERS(config.h)
dnl update the value of RL_READLINE_VERSION in readline.h when this changes
LIBVERSION=4.3
AC_CANONICAL_HOST
dnl configure defaults
opt_curses=no
opt_shared=no
dnl arguments to configure
AC_ARG_WITH(curses, --with-curses use the curses library instead of the termcap library,opt_curses=$withval)
AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
if test "$opt_curses" = "yes"; then
prefer_curses=yes
fi
dnl option parsing for optional features
opt_static_libs=yes
opt_shared_libs=yes
AC_ARG_ENABLE(shared, AC_HELP_STRING([--enable-shared], [build shared libraries [[default=YES]]]), opt_shared_libs=$enableval)
AC_ARG_ENABLE(static, AC_HELP_STRING([--enable-static], [build static libraries [[default=YES]]]), opt_static_libs=$enableval)
echo ""
echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_vendor}-${host_os}"
echo ""
# We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
AC_PROG_MAKE_SET
AC_PROG_CC
dnl AC_AIX
AC_MINIX
# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
@ -39,7 +54,7 @@ test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
AC_CHECK_PROG(AR, ar, ar)
AC_CHECK_PROG(AR, ar, , ar)
dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
dnl This allows people to set it when running configure or make
test -n "$ARFLAGS" || ARFLAGS="cr"
@ -48,32 +63,42 @@ AC_PROG_RANLIB
MAKE_SHELL=/bin/sh
AC_SUBST(MAKE_SHELL)
AC_RETSIGTYPE
AC_C_CONST
AC_C_PROTOTYPES
AC_C_CHAR_UNSIGNED
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_CHECK_TYPE(ssize_t, int)
AC_HEADER_STAT
AC_HEADER_DIRENT
AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr setlocale lstat)
AC_CHECK_FUNCS(lstat memmove putenv select setenv setlocale \
strcasecmp strpbrk tcgetattr vsnprintf isascii isxdigit)
AC_FUNC_STRCOLL
AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h \
sys/ptem.h sys/pte.h sys/stream.h sys/select.h \
termcap.h termios.h termio.h sys/file.h locale.h)
AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \
limits.h sys/ptem.h sys/pte.h sys/stream.h sys/select.h \
termcap.h termios.h termio.h sys/file.h locale.h memory.h )
BASH_SIGNAL_CHECK
BASH_REINSTALL_SIGHANDLERS
BASH_SYS_SIGNAL_VINTAGE
BASH_SYS_REINSTALL_SIGHANDLERS
BASH_FUNC_POSIX_SETJMP
BASH_FUNC_LSTAT
BASH_CHECK_GETPW_FUNCS
BASH_FUNC_STRCOLL
BASH_CHECK_GETPW_FUNCS
AC_HEADER_TIOCGWINSZ
BASH_TYPE_SIGHANDLER
BASH_HAVE_TIOCGWINSZ
BASH_HAVE_TIOCSTAT
BASH_HAVE_FIONREAD
BASH_MISC_SPEED_T
BASH_CHECK_SPEED_T
BASH_STRUCT_WINSIZE
BASH_STRUCT_DIRENT_D_INO
BASH_STRUCT_DIRENT_D_FILENO
@ -84,11 +109,18 @@ aix*) prefer_curses=yes ;;
esac
BASH_CHECK_LIB_TERMCAP
if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
TERMCAP_LIB=-ltermcap #default
if test "$prefer_curses" = yes; then
TERMCAP_LIB=-lcurses
else
TERMCAP_LIB=-ltermcap #default
fi
fi
BASH_CHECK_MULTIBYTE
case "$host_cpu" in
*cray*) LOCAL_CFLAGS=-DCRAY ;;
*s390*) LOCAL_CFLAGS=-fsigned-char ;;
esac
case "$host_os" in
@ -102,7 +134,7 @@ esac
#
if test -f ${srcdir}/support/shobj-conf; then
AC_MSG_CHECKING(configuration for building shared libraries)
eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C ${CC} -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
AC_SUBST(SHOBJ_CC)
AC_SUBST(SHOBJ_CFLAGS)
AC_SUBST(SHOBJ_LD)
@ -116,9 +148,40 @@ if test -f ${srcdir}/support/shobj-conf; then
AC_SUBST(SHLIB_LIBVERSION)
AC_SUBST(SHLIB_LIBS)
AC_MSG_RESULT($SHLIB_STATUS)
# SHLIB_STATUS is either `supported' or `unsupported'. If it's
# `unsupported', turn off any default shared library building
if test "$SHLIB_STATUS" = 'unsupported'; then
opt_shared_libs=no
fi
# shared library versioning
# quoted for m4 so I can use character classes
SHLIB_MAJOR=[`expr "$LIBVERSION" : '\([0-9]\)\..*'`]
SHLIB_MINOR=[`expr "$LIBVERSION" : '[0-9]\.\([0-9]\).*'`]
AC_SUBST(SHLIB_MAJOR)
AC_SUBST(SHLIB_MINOR)
fi
BUILD_DIR=`pwd`
if test "$opt_static_libs" = "yes"; then
STATIC_TARGET=static
STATIC_INSTALL_TARGET=install-static
fi
if test "$opt_shared_libs" = "yes"; then
SHARED_TARGET=shared
SHARED_INSTALL_TARGET=install-shared
fi
AC_SUBST(STATIC_TARGET)
AC_SUBST(SHARED_TARGET)
AC_SUBST(STATIC_INSTALL_TARGET)
AC_SUBST(SHARED_INSTALL_TARGET)
case "$host_os" in
msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file
*) BUILD_DIR=`pwd` ;;
esac
AC_SUBST(BUILD_DIR)
AC_SUBST(CFLAGS)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
The GNU Readline 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 1, or
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@ -18,15 +18,13 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
extern char *xmalloc (), *xrealloc ();
#if !defined (BUFSIZ)
#include <stdio.h>
#endif /* BUFSIZ */
@ -40,7 +38,15 @@ extern char *xmalloc (), *xrealloc ();
#include "rlconf.h"
#include "readline.h"
extern int _rl_qsort_string_compare ();
#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;
@ -54,7 +60,8 @@ static FUNMAP default_funmap[] = {
{ "abort", rl_abort },
{ "accept-line", rl_newline },
{ "arrow-key-prefix", rl_arrow_keys },
{ "backward-char", rl_backward },
{ "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 },
@ -85,7 +92,8 @@ static FUNMAP default_funmap[] = {
{ "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-char", rl_forward },
{ "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 },
@ -102,7 +110,8 @@ static FUNMAP default_funmap[] = {
{ "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 },
#ifdef __CYGWIN32__
{ "overwrite-mode", rl_overwrite_mode },
#ifdef __CYGWIN__
{ "paste-from-clipboard", rl_paste_from_clipboard },
#endif
{ "possible-completions", rl_possible_completions },
@ -136,7 +145,6 @@ static FUNMAP default_funmap[] = {
{ "vi-arg-digit", rl_vi_arg_digit },
{ "vi-back-to-indent", rl_vi_back_to_indent },
{ "vi-bWord", rl_vi_bWord },
{ "vi-bracktype", rl_vi_bracktype },
{ "vi-bword", rl_vi_bword },
{ "vi-change-case", rl_vi_change_case },
{ "vi-change-char", rl_vi_change_char },
@ -176,11 +184,13 @@ static FUNMAP default_funmap[] = {
{ "vi-yank-to", rl_vi_yank_to },
#endif /* VI_MODE */
{(char *)NULL, (Function *)NULL }
{(char *)NULL, (rl_command_func_t *)NULL }
};
int
rl_add_funmap_entry (const char *name, Function *function)
rl_add_funmap_entry (name, function)
const char *name;
rl_command_func_t *function;
{
if (funmap_entry + 2 >= funmap_size)
{
@ -217,36 +227,27 @@ rl_initialize_funmap ()
/* 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. */
char **
const char **
rl_funmap_names ()
{
char **result;
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 = (char **)NULL; funmap[result_index]; result_index++)
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 = (char **)xrealloc (result, result_size * sizeof (char *));
result = (const char **)xrealloc (result, result_size * sizeof (char *));
}
result[result_index] = (char*) funmap[result_index]->name;
result[result_index] = funmap[result_index]->name;
result[result_index + 1] = (char *)NULL;
}
qsort (result, result_index, sizeof (char *), _rl_qsort_string_compare);
qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
return (result);
}
/* Things that mean `Control'. */
const char *possible_control_prefixes[] = {
"Control-", "C-", "CTRL-", (char *)NULL
};
const char *possible_meta_prefixes[] = {
"Meta", "M-", (char *)NULL
};

View File

@ -7,7 +7,7 @@
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 1, or (at your option)
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
@ -18,7 +18,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
@ -41,18 +41,21 @@
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "rlmbutil.h"
#include "history.h"
#include "histlib.h"
#include "rlshell.h"
#include "xmalloc.h"
#define HISTORY_WORD_DELIMITERS " \t\n;&()|<>"
#define HISTORY_QUOTE_CHARACTERS "\"'`"
typedef int _hist_search_func_t PARAMS((const char *, int));
extern int rl_byte_oriented; /* declared in mbutil.c */
static char error_pointer;
static char *subst_lhs;
@ -60,15 +63,10 @@ static char *subst_rhs;
static int subst_lhs_len;
static int subst_rhs_len;
static char *get_history_word_specifier ();
static char *history_find_word ();
static char *get_history_word_specifier PARAMS((char *, char *, int *));
static char *history_find_word PARAMS((char *, int));
extern int history_offset;
extern char *single_quote ();
static char *quote_breaks ();
extern char *xmalloc (), *xrealloc ();
static char *quote_breaks PARAMS((char *));
/* Variables exported by this file. */
/* The character that represents the start of a history expansion
@ -93,9 +91,12 @@ const char *history_no_expand_chars = " \t\n\r=";
The default is 0. */
int history_quotes_inhibit_expansion = 0;
/* Used to split words by history_tokenize_internal. */
const char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
/* If set, this points to a function that is called to verify that a
particular history expansion should be performed. */
Function *history_inhibit_expansion_function;
rl_linebuf_func_t *history_inhibit_expansion_function;
/* **************************************************************** */
/* */
@ -124,7 +125,7 @@ static char *search_match;
line = get_history_event ("!echo:p", &index, 0); */
char *
get_history_event (string, caller_index, delimiting_quote)
char *string;
const char *string;
int *caller_index;
int delimiting_quote;
{
@ -132,7 +133,7 @@ get_history_event (string, caller_index, delimiting_quote)
register char c;
HIST_ENTRY *entry;
int which, sign, local_index, substring_okay;
Function *search_func;
_hist_search_func_t *search_func;
char *temp;
/* The event can be specified in a number of ways.
@ -201,15 +202,33 @@ get_history_event (string, caller_index, delimiting_quote)
/* Only a closing `?' or a newline delimit a substring search string. */
for (local_index = i; (c = string[i]); i++)
if ((!substring_okay && (whitespace (c) || c == ':' ||
(history_search_delimiter_chars && member (c, history_search_delimiter_chars)) ||
string[i] == delimiting_quote)) ||
string[i] == '\n' ||
(substring_okay && string[i] == '?'))
break;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int v;
mbstate_t ps;
memset (&ps, 0, sizeof (mbstate_t));
/* These produce warnings because we're passing a const string to a
function that takes a non-const string. */
_rl_adjust_point (string, i, &ps);
if ((v = _rl_get_char_len (string + i, &ps)) > 1)
{
i += v - 1;
continue;
}
}
else
#endif /* HANDLE_MULTIBYTE */
if ((!substring_okay && (whitespace (c) || c == ':' ||
(history_search_delimiter_chars && member (c, history_search_delimiter_chars)) ||
string[i] == delimiting_quote)) ||
string[i] == '\n' ||
(substring_okay && string[i] == '?'))
break;
which = i - local_index;
temp = xmalloc (1 + which);
temp = (char *)xmalloc (1 + which);
if (which)
strncpy (temp, string + local_index, which);
temp[which] = '\0';
@ -311,7 +330,7 @@ quote_breaks (s)
len += 2;
}
r = ret = xmalloc (len);
r = ret = (char *)xmalloc (len);
*r++ = '\'';
for (p = s; p && *p; )
{
@ -376,7 +395,7 @@ hist_error(s, start, current, errtype)
break;
}
temp = xmalloc (ll + elen + 3);
temp = (char *)xmalloc (ll + elen + 3);
strncpy (temp, s + start, ll);
temp[ll] = ':';
temp[ll + 1] = ' ';
@ -402,17 +421,37 @@ get_subst_pattern (str, iptr, delimiter, is_rhs, lenptr)
int *iptr, delimiter, is_rhs, *lenptr;
{
register int si, i, j, k;
char *s = (char *) NULL;
char *s;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
#endif
s = (char *)NULL;
i = *iptr;
#if defined (HANDLE_MULTIBYTE)
memset (&ps, 0, sizeof (mbstate_t));
_rl_adjust_point (str, i, &ps);
#endif
for (si = i; str[si] && str[si] != delimiter; si++)
if (str[si] == '\\' && str[si + 1] == delimiter)
si++;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int v;
if ((v = _rl_get_char_len (str + si, &ps)) > 1)
si += v - 1;
else if (str[si] == '\\' && str[si + 1] == delimiter)
si++;
}
else
#endif /* HANDLE_MULTIBYTE */
if (str[si] == '\\' && str[si + 1] == delimiter)
si++;
if (si > i || is_rhs)
{
s = xmalloc (si - i + 1);
s = (char *)xmalloc (si - i + 1);
for (j = 0, k = i; k < si; j++, k++)
{
/* Remove a backslash quoting the search string delimiter. */
@ -439,13 +478,13 @@ postproc_subst_rhs ()
char *new;
int i, j, new_size;
new = xmalloc (new_size = subst_rhs_len + subst_lhs_len);
new = (char *)xmalloc (new_size = subst_rhs_len + subst_lhs_len);
for (i = j = 0; i < subst_rhs_len; i++)
{
if (subst_rhs[i] == '&')
{
if (j + subst_lhs_len >= new_size)
new = xrealloc (new, (new_size = new_size * 2 + subst_lhs_len));
new = (char *)xrealloc (new, (new_size = new_size * 2 + subst_lhs_len));
strcpy (new + j, subst_lhs);
j += subst_lhs_len;
}
@ -455,7 +494,7 @@ postproc_subst_rhs ()
if (subst_rhs[i] == '\\' && subst_rhs[i + 1] == '&')
i++;
if (j >= new_size)
new = xrealloc (new, new_size *= 2);
new = (char *)xrealloc (new, new_size *= 2);
new[j++] = subst_rhs[i];
}
}
@ -481,8 +520,13 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
int substitute_globally, want_quotes, print_only;
char *event, *temp, *result, *tstr, *t, c, *word_spec;
int result_len;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
result = xmalloc (result_len = 128);
memset (&ps, 0, sizeof (mbstate_t));
#endif
result = (char *)xmalloc (result_len = 128);
i = start;
@ -511,8 +555,21 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
quote, then this expansion takes place inside of the
quoted string. If we have to search for some text ("!foo"),
allow the delimiter to end the search string. */
if (i && (string[i - 1] == '\'' || string[i - 1] == '"'))
quoted_search_delimiter = string[i - 1];
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int c, l;
l = _rl_find_prev_mbchar (string, i, MB_FIND_ANY);
c = string[l];
/* XXX - original patch had i - 1 ??? If i == 0 it would fail. */
if (i && (c == '\'' || c == '"'))
quoted_search_delimiter = c;
}
else
#endif /* HANDLE_MULTIBYTE */
if (i && (string[i - 1] == '\'' || string[i - 1] == '"'))
quoted_search_delimiter = string[i - 1];
event = get_history_event (string, &i, quoted_search_delimiter);
}
@ -625,13 +682,26 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
case '&':
case 's':
{
char *new_event, *t;
char *new_event;
int delimiter, failed, si, l_temp;
if (c == 's')
{
if (i + 2 < (int)strlen (string))
delimiter = string[i + 2];
{
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
_rl_adjust_point (string, i + 2, &ps);
if (_rl_get_char_len (string + i + 2, &ps) > 1)
delimiter = 0;
else
delimiter = string[i + 2];
}
else
#endif /* HANDLE_MULTIBYTE */
delimiter = string[i + 2];
}
else
break; /* no search delimiter */
@ -695,7 +765,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
if (STREQN (temp+si, subst_lhs, subst_lhs_len))
{
int len = subst_rhs_len - subst_lhs_len + l_temp;
new_event = xmalloc (1 + len);
new_event = (char *)xmalloc (1 + len);
strncpy (new_event, temp, si);
strncpy (new_event + si, subst_rhs, subst_rhs_len);
strncpy (new_event + si + subst_rhs_len,
@ -744,7 +814,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
char *x;
if (want_quotes == 'q')
x = single_quote (temp);
x = sh_single_quote (temp);
else if (want_quotes == 'x')
x = quote_breaks (temp);
else
@ -756,7 +826,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
n = strlen (temp);
if (n >= result_len)
result = xrealloc (result, n + 2);
result = (char *)xrealloc (result, n + 2);
strcpy (result, temp);
free (temp);
@ -787,7 +857,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
{ \
while (j >= result_len) \
result_len += 128; \
result = xrealloc (result, result_len); \
result = (char *)xrealloc (result, result_len); \
} \
strcpy (result + j - sl, s); \
} \
@ -797,7 +867,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
do \
{ \
if (j >= result_len - 1) \
result = xrealloc (result, result_len += 64); \
result = (char *)xrealloc (result, result_len += 64); \
result[j++] = c; \
result[j] = '\0'; \
} \
@ -816,9 +886,17 @@ history_expand (hstring, output)
int result_len;
char *result;
#if defined (HANDLE_MULTIBYTE)
char mb[MB_LEN_MAX];
mbstate_t ps;
#endif
/* Used when adding the string. */
char *temp;
if (output == 0)
return 0;
/* Setting the history expansion character to 0 inhibits all
history expansion. */
if (history_expansion_char == 0)
@ -828,7 +906,7 @@ history_expand (hstring, output)
}
/* Prepare the buffer for printing error messages. */
result = xmalloc (result_len = 256);
result = (char *)xmalloc (result_len = 256);
result[0] = '\0';
only_printing = modified = 0;
@ -845,7 +923,7 @@ history_expand (hstring, output)
that is the substitution that we do. */
if (hstring[0] == history_subst_char)
{
string = xmalloc (l + 5);
string = (char *)xmalloc (l + 5);
string[0] = string[1] = history_expansion_char;
string[2] = ':';
@ -855,6 +933,10 @@ history_expand (hstring, output)
}
else
{
#if defined (HANDLE_MULTIBYTE)
memset (&ps, 0, sizeof (mbstate_t));
#endif
string = hstring;
/* If not quick substitution, still maybe have to do expansion. */
@ -862,13 +944,26 @@ history_expand (hstring, output)
is NOT an expansion. */
for (i = 0; string[i]; i++)
{
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int v;
v = _rl_get_char_len (string + i, &ps);
if (v > 1)
{
i += v - 1;
continue;
}
}
#endif /* HANDLE_MULTIBYTE */
cc = string[i + 1];
/* The history_comment_char, if set, appearing that the beginning
/* The history_comment_char, if set, appearing at the beginning
of a word signifies that the rest of the line should not have
history expansion performed on it.
Skip the rest of the line and break out of the loop. */
if (history_comment_char && string[i] == history_comment_char &&
(i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS)))
(i == 0 || member (string[i - 1], history_word_delimiters)))
{
while (string[i])
i++;
@ -926,6 +1021,30 @@ history_expand (hstring, output)
continue;
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int k, c;
c = tchar;
memset (mb, 0, sizeof (mb));
for (k = 0; k < MB_LEN_MAX; k++)
{
mb[k] = (char)c;
memset (&ps, 0, sizeof (mbstate_t));
if (_rl_get_char_len (mb, &ps) == -2)
c = string[++i];
else
break;
}
if (strlen (mb) > 1)
{
ADD_STRING (mb);
break;
}
}
#endif /* HANDLE_MULTIBYTE */
if (tchar == history_expansion_char)
tchar = -3;
else if (tchar == history_comment_char)
@ -954,7 +1073,7 @@ history_expand (hstring, output)
hist_string_extract_single_quoted (string, &i);
slen = i - quote + 2;
temp = xmalloc (slen);
temp = (char *)xmalloc (slen);
strncpy (temp, string + quote, slen);
temp[slen - 1] = '\0';
ADD_STRING (temp);
@ -966,9 +1085,9 @@ history_expand (hstring, output)
}
case -2: /* history_comment_char */
if (i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS))
if (i == 0 || member (string[i - 1], history_word_delimiters))
{
temp = xmalloc (l - i + 1);
temp = (char *)xmalloc (l - i + 1);
strcpy (temp, string + i);
ADD_STRING (temp);
free (temp);
@ -1000,7 +1119,7 @@ history_expand (hstring, output)
{
if (result)
{
temp = xmalloc (1 + strlen (result));
temp = (char *)xmalloc (1 + strlen (result));
strcpy (temp, result);
ADD_STRING (temp);
free (temp);
@ -1134,7 +1253,14 @@ get_history_word_specifier (spec, from, caller_index)
i++;
last = '$';
}
else if (!spec[i] || spec[i] == ':') /* could be modifier separator */
#if 0
else if (!spec[i] || spec[i] == ':')
/* check against `:' because there could be a modifier separator */
#else
else
/* csh seems to allow anything to terminate the word spec here,
leaving it as an abbreviation. */
#endif
last = -1; /* x- abbreviates x-$ omitting word `$' */
}
@ -1154,7 +1280,7 @@ get_history_word_specifier (spec, from, caller_index)
char *
history_arg_extract (first, last, string)
int first, last;
char *string;
const char *string;
{
register int i, len;
char *result;
@ -1190,7 +1316,7 @@ history_arg_extract (first, last, string)
{
for (size = 0, i = first; i < last; i++)
size += strlen (list[i]) + 1;
result = xmalloc (size + 1);
result = (char *)xmalloc (size + 1);
result[0] = '\0';
for (i = first, offset = 0; i < last; i++)
@ -1220,13 +1346,18 @@ history_arg_extract (first, last, string)
*INDP. */
static char **
history_tokenize_internal (string, wind, indp)
char *string;
const char *string;
int wind, *indp;
{
char **result;
register int i, start, result_index, size;
int len, delimiter;
/* 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. */
if (indp && wind != -1)
*indp = -1;
/* 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]; )
@ -1301,7 +1432,7 @@ history_tokenize_internal (string, wind, indp)
continue;
}
if (!delimiter && (member (string[i], HISTORY_WORD_DELIMITERS)))
if (!delimiter && (member (string[i], history_word_delimiters)))
break;
if (!delimiter && member (string[i], HISTORY_QUOTE_CHARACTERS))
@ -1318,7 +1449,7 @@ history_tokenize_internal (string, wind, indp)
len = i - start;
if (result_index + 2 >= size)
result = (char **)xrealloc (result, ((size += 10) * sizeof (char *)));
result[result_index] = xmalloc (1 + len);
result[result_index] = (char *)xmalloc (1 + len);
strncpy (result[result_index], string + start, len);
result[result_index][len] = '\0';
result[++result_index] = (char *)NULL;
@ -1331,7 +1462,7 @@ history_tokenize_internal (string, wind, indp)
parsed out of STRING. */
char **
history_tokenize (string)
char *string;
const char *string;
{
return (history_tokenize_internal (string, -1, (int *)NULL));
}
@ -1348,7 +1479,7 @@ history_find_word (line, ind)
int i, wind;
words = history_tokenize_internal (line, ind, &wind);
if (wind == -1)
if (wind == -1 || words == 0)
return ((char *)NULL);
s = words[wind];
for (i = 0; i < wind; i++)

View File

@ -7,7 +7,7 @@
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 1, or (at your option)
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
@ -18,7 +18,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions
@ -35,7 +35,7 @@
#ifndef _MINIX
# include <sys/file.h>
#endif
#include <sys/stat.h>
#include "posixstat.h"
#include <fcntl.h>
#if defined (HAVE_STDLIB_H)
@ -48,21 +48,39 @@
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#if defined (__EMX__) || defined (__CYGWIN__)
# undef HAVE_MMAP
#endif
#if defined (__EMX__)
#ifdef HAVE_MMAP
# include <sys/mman.h>
# ifdef MAP_FILE
# define MAP_RFLAGS (MAP_FILE|MAP_PRIVATE)
# define MAP_WFLAGS (MAP_FILE|MAP_SHARED)
# else
# define MAP_RFLAGS MAP_PRIVATE
# define MAP_WFLAGS MAP_SHARED
# endif
# ifndef MAP_FAILED
# define MAP_FAILED ((void *)-1)
# endif
#endif /* HAVE_MMAP */
/* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
on win 95/98/nt), we want to open files with O_BINARY mode so that there
is no \n -> \r\n conversion performed. On other systems, we don't want to
mess around with O_BINARY at all, so we ensure that it's defined to 0. */
#if defined (__EMX__) || defined (__CYGWIN__)
# ifndef O_BINARY
# define O_BINARY 0
# endif
#else /* !__EMX__ */
/* If we're not compiling for __EMX__, we don't want this at all. Ever. */
#else /* !__EMX__ && !__CYGWIN__ */
# undef O_BINARY
# define O_BINARY 0
#endif /* !__EMX__ */
#endif /* !__EMX__ && !__CYGWIN__ */
#include <errno.h>
#if !defined (errno)
@ -72,17 +90,15 @@ extern int errno;
#include "history.h"
#include "histlib.h"
/* Functions imported from shell.c */
extern char *get_env_value ();
extern char *xmalloc (), *xrealloc ();
#include "rlshell.h"
#include "xmalloc.h"
/* Return the string that should be used in the place of this
filename. This only matters when you don't specify the
filename to read_history (), or write_history (). */
static char *
history_filename (filename)
char *filename;
const char *filename;
{
char *return_val;
const char *home;
@ -93,7 +109,7 @@ history_filename (filename)
if (return_val)
return (return_val);
home = get_env_value ("HOME");
home = sh_get_env_value ("HOME");
if (home == 0)
{
@ -103,10 +119,14 @@ history_filename (filename)
else
home_len = strlen (home);
return_val = xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
return_val = (char *)xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
strcpy (return_val, home);
return_val[home_len] = '/';
#if defined (__MSDOS__)
strcpy (return_val + home_len + 1, "_history");
#else
strcpy (return_val + home_len + 1, ".history");
#endif
return (return_val);
}
@ -116,7 +136,7 @@ history_filename (filename)
successful, or errno if not. */
int
read_history (filename)
char *filename;
const char *filename;
{
return (read_history_range (filename, 0, -1));
}
@ -128,13 +148,14 @@ read_history (filename)
~/.history. Returns 0 if successful, or errno if not. */
int
read_history_range (filename, from, to)
char *filename;
const char *filename;
int from, to;
{
char *input, *buffer;
int file, current_line;
register char *line_start, *line_end;
char *input, *buffer, *bufend;
int file, current_line, chars_read;
struct stat finfo;
size_t line_start, line_end, file_size;
size_t file_size;
buffer = (char *)NULL;
input = history_filename (filename);
@ -150,57 +171,67 @@ read_history_range (filename, from, to)
{
#if defined (EFBIG)
errno = EFBIG;
#elif defined (EOVERFLOW)
errno = EOVERFLOW;
#endif
goto error_and_exit;
}
buffer = xmalloc (file_size + 1);
#if 0
if (read (file, buffer, file_size) != file_size)
#ifdef HAVE_MMAP
/* We map read/write and private so we can change newlines to NULs without
affecting the underlying object. */
buffer = (char *)mmap (0, file_size, PROT_READ|PROT_WRITE, MAP_RFLAGS, file, 0);
if ((void *)buffer == MAP_FAILED)
goto error_and_exit;
chars_read = file_size;
#else
if (read (file, buffer, file_size) < 0)
buffer = (char *)malloc (file_size + 1);
if (buffer == 0)
goto error_and_exit;
chars_read = read (file, buffer, file_size);
#endif
if (chars_read < 0)
{
error_and_exit:
chars_read = errno;
if (file >= 0)
close (file);
FREE (input);
#ifndef HAVE_MMAP
FREE (buffer);
#endif
return (errno);
return (chars_read);
}
close (file);
/* Set TO to larger than end of file if negative. */
if (to < 0)
to = file_size;
to = chars_read;
/* Start at beginning of file, work to end. */
line_start = line_end = current_line = 0;
bufend = buffer + chars_read;
current_line = 0;
/* Skip lines until we are at FROM. */
while (line_start < file_size && current_line < from)
{
for (line_end = line_start; line_end < file_size; line_end++)
if (buffer[line_end] == '\n')
{
current_line++;
line_start = line_end + 1;
if (current_line == from)
break;
}
}
for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
if (*line_end == '\n')
{
current_line++;
line_start = line_end + 1;
}
/* If there are lines left to gobble, then gobble them now. */
for (line_end = line_start; line_end < file_size; line_end++)
if (buffer[line_end] == '\n')
for (line_end = line_start; line_end < bufend; line_end++)
if (*line_end == '\n')
{
buffer[line_end] = '\0';
*line_end = '\0';
if (buffer[line_start])
add_history (buffer + line_start);
if (*line_start)
add_history (line_start);
current_line++;
@ -211,30 +242,52 @@ read_history_range (filename, from, to)
}
FREE (input);
#ifndef HAVE_MMAP
FREE (buffer);
#else
munmap (buffer, file_size);
#endif
return (0);
}
/* Truncate the history file FNAME, leaving only LINES trailing lines.
If FNAME is NULL, then use ~/.history. */
If FNAME is NULL, then use ~/.history. Returns 0 on success, errno
on failure. */
int
history_truncate_file (fname, lines)
char *fname;
const char *fname;
int lines;
{
register int i;
int file, chars_read;
char *buffer, *filename;
char *buffer, *filename, *bp;
int file, chars_read, rv;
struct stat finfo;
size_t file_size;
buffer = (char *)NULL;
filename = history_filename (fname);
file = open (filename, O_RDONLY|O_BINARY, 0666);
rv = 0;
/* Don't try to truncate non-regular files. */
if (file == -1 || fstat (file, &finfo) == -1)
goto truncate_exit;
{
rv = errno;
if (file != -1)
close (file);
goto truncate_exit;
}
if (S_ISREG (finfo.st_mode) == 0)
{
close (file);
#ifdef EFTYPE
rv = EFTYPE;
#else
rv = EINVAL;
#endif
goto truncate_exit;
}
file_size = (size_t)finfo.st_size;
@ -243,23 +296,36 @@ history_truncate_file (fname, lines)
{
close (file);
#if defined (EFBIG)
errno = EFBIG;
rv = errno = EFBIG;
#elif defined (EOVERFLOW)
rv = errno = EOVERFLOW;
#else
rv = errno = EINVAL;
#endif
goto truncate_exit;
}
buffer = xmalloc (file_size + 1);
buffer = (char *)malloc (file_size + 1);
if (buffer == 0)
{
close (file);
goto truncate_exit;
}
chars_read = read (file, buffer, file_size);
close (file);
if (chars_read <= 0)
goto truncate_exit;
{
rv = (chars_read < 0) ? errno : 0;
goto truncate_exit;
}
/* Count backwards from the end of buffer until we have passed
LINES lines. */
for (i = chars_read - 1; lines && i; i--)
for (bp = buffer + chars_read - 1; lines && bp > buffer; bp--)
{
if (buffer[i] == '\n')
if (*bp == '\n')
lines--;
}
@ -268,22 +334,22 @@ history_truncate_file (fname, lines)
anything. It's the first line if we don't find a newline between
the current value of i and 0. Otherwise, write from the start of
this line until the end of the buffer. */
for ( ; i; i--)
if (buffer[i] == '\n')
for ( ; bp > buffer; bp--)
if (*bp == '\n')
{
i++;
bp++;
break;
}
/* Write only if there are more lines in the file than we want to
truncate to. */
if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
if (bp > buffer && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
{
write (file, buffer + i, file_size - i);
write (file, bp, chars_read - (bp - buffer));
#if defined (__BEOS__)
/* BeOS ignores O_TRUNC. */
ftruncate (file, file_size - i);
ftruncate (file, chars_read - (bp - buffer));
#endif
close (file);
@ -294,7 +360,7 @@ history_truncate_file (fname, lines)
FREE (buffer);
free (filename);
return 0;
return rv;
}
/* Workhorse function for writing history. Writes NELEMENT entries
@ -302,15 +368,21 @@ history_truncate_file (fname, lines)
wish to replace FILENAME with the entries. */
static int
history_do_write (filename, nelements, overwrite)
char *filename;
const char *filename;
int nelements, overwrite;
{
register int i;
char *output;
int file, mode;
int file, mode, rv;
size_t cursize;
#ifdef HAVE_MMAP
mode = overwrite ? O_RDWR|O_CREAT|O_TRUNC|O_BINARY : O_RDWR|O_APPEND|O_BINARY;
#else
mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
#endif
output = history_filename (filename);
rv = 0;
if ((file = open (output, mode, 0600)) == -1)
{
@ -318,6 +390,10 @@ history_do_write (filename, nelements, overwrite)
return (errno);
}
#ifdef HAVE_MMAP
cursize = overwrite ? 0 : lseek (file, 0, SEEK_END);
#endif
if (nelements > history_length)
nelements = history_length;
@ -335,7 +411,28 @@ history_do_write (filename, nelements, overwrite)
buffer_size += 1 + strlen (the_history[i]->line);
/* Allocate the buffer, and fill it. */
buffer = xmalloc (buffer_size);
#ifdef HAVE_MMAP
if (ftruncate (file, buffer_size+cursize) == -1)
goto mmap_error;
buffer = (char *)mmap (0, buffer_size, PROT_READ|PROT_WRITE, MAP_WFLAGS, file, cursize);
if ((void *)buffer == MAP_FAILED)
{
mmap_error:
rv = errno;
FREE (output);
close (file);
return rv;
}
#else
buffer = (char *)malloc (buffer_size);
if (buffer == 0)
{
rv = errno;
FREE (output);
close (file);
return rv;
}
#endif
for (j = 0, i = history_length - nelements; i < history_length; i++)
{
@ -344,15 +441,21 @@ history_do_write (filename, nelements, overwrite)
buffer[j++] = '\n';
}
write (file, buffer, buffer_size);
#ifdef HAVE_MMAP
if (msync (buffer, buffer_size, 0) != 0 || munmap (buffer, buffer_size) != 0)
rv = errno;
#else
if (write (file, buffer, buffer_size) < 0)
rv = errno;
free (buffer);
#endif
}
close (file);
FREE (output);
return (0);
return (rv);
}
/* Append NELEMENT entries to FILENAME. The entries appended are from
@ -360,7 +463,7 @@ history_do_write (filename, nelements, overwrite)
int
append_history (nelements, filename)
int nelements;
char *filename;
const char *filename;
{
return (history_do_write (filename, nelements, HISTORY_APPEND));
}
@ -370,7 +473,7 @@ append_history (nelements, filename)
are as in read_history ().*/
int
write_history (filename)
char *filename;
const char *filename;
{
return (history_do_write (filename, history_length, HISTORY_OVERWRITE));
}

View File

@ -6,7 +6,7 @@
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 1, or (at your option)
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
@ -17,27 +17,24 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_HISTLIB_H_)
#define _HISTLIB_H_
/* Function pointers can be declared as (Function *)foo. */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif /* _FUNCTION_DEF */
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#if !defined (STREQ)
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
#define STREQN(a, b, n) (((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
#define STREQN(a, b, n) (((n) == 0) ? (1) \
: ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
#endif
#ifndef savestring
# ifndef strcpy
extern char *strcpy ();
# endif
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#endif
@ -79,4 +76,7 @@ extern char *strchr ();
#define HISTORY_APPEND 0
#define HISTORY_OVERWRITE 1
/* Some variable definitions shared across history source files. */
extern int history_offset;
#endif /* !_HISTLIB_H_ */

View File

@ -7,7 +7,7 @@
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 1, or (at your option)
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
@ -18,7 +18,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions
@ -44,16 +44,10 @@
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "history.h"
#include "histlib.h"
extern char *xmalloc (), *xrealloc ();
#include "xmalloc.h"
/* The number of slots to increase the_history by. */
#define DEFAULT_HISTORY_GROW_SIZE 50
@ -71,9 +65,13 @@ static HIST_ENTRY **the_history = (HIST_ENTRY **)NULL;
history that we save. */
static int history_stifled;
/* The current number of slots allocated to the input_history. */
static int history_size;
/* If HISTORY_STIFLED is non-zero, then this is the maximum number of
entries to remember. */
int max_input_history;
int history_max_entries;
int max_input_history; /* backwards compatibility */
/* The current location of the interactive history pointer. Just makes
life easier for outside callers. */
@ -82,9 +80,6 @@ int history_offset;
/* The number of strings currently stored in the history list. */
int history_length;
/* The current number of slots allocated to the input_history. */
static int history_size;
/* The logical `base' of the history array. It defaults to 1. */
int history_base = 1;
@ -134,9 +129,7 @@ history_total_bytes ()
{
register int i, result;
result = 0;
for (i = 0; the_history && the_history[i]; i++)
for (i = result = 0; the_history && the_history[i]; i++)
result += strlen (the_history[i]->line);
return (result);
@ -217,16 +210,16 @@ history_get (offset)
is set to NULL. */
void
add_history (string)
char *string;
const char *string;
{
HIST_ENTRY *temp;
if (history_stifled && (history_length == max_input_history))
if (history_stifled && (history_length == history_max_entries))
{
register int i;
/* If the history is stifled, and history_length is zero,
and it equals max_input_history, we don't save items. */
and it equals history_max_entries, we don't save items. */
if (history_length == 0)
return;
@ -277,15 +270,15 @@ add_history (string)
HIST_ENTRY *
replace_history_entry (which, line, data)
int which;
char *line;
const char *line;
histdata_t data;
{
HIST_ENTRY *temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
HIST_ENTRY *old_value;
HIST_ENTRY *temp, *old_value;
if (which >= history_length)
return ((HIST_ENTRY *)NULL);
temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
old_value = the_history[which];
temp->line = savestring (line);
@ -303,12 +296,12 @@ remove_history (which)
int which;
{
HIST_ENTRY *return_value;
register int i;
if (which >= history_length || !history_length)
return_value = (HIST_ENTRY *)NULL;
else
{
register int i;
return_value = the_history[which];
for (i = which; i < history_length; i++)
@ -325,13 +318,13 @@ void
stifle_history (max)
int max;
{
register int i, j;
if (max < 0)
max = 0;
if (history_length > max)
{
register int i, j;
/* This loses because we cannot free the data. */
for (i = 0, j = history_length - max; i < j; i++)
{
@ -347,22 +340,22 @@ stifle_history (max)
}
history_stifled = 1;
max_input_history = max;
max_input_history = history_max_entries = max;
}
/* Stop stifling the history. This returns the previous amount the
history was stifled by. The value is positive if the history was
stifled, negative if it wasn't. */
/* Stop stifling the history. This returns the previous maximum
number of history entries. The value is positive if the history
was stifled, negative if it wasn't. */
int
unstifle_history ()
{
if (history_stifled)
{
history_stifled = 0;
return (-max_input_history);
return (history_max_entries);
}
return (max_input_history);
else
return (-history_max_entries);
}
int

View File

@ -6,7 +6,7 @@
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 1, or (at your option)
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
@ -17,7 +17,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _HISTORY_H_
#define _HISTORY_H_
@ -28,16 +28,10 @@ extern "C" {
#if defined READLINE_LIBRARY
# include "rlstdc.h"
# include "rltypedefs.h"
#else
# include <readline/rlstdc.h>
#endif
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
# include <readline/rltypedefs.h>
#endif
#ifdef __STDC__
@ -68,81 +62,81 @@ typedef struct _hist_state {
/* Begin a session in which the history functions might be used. This
just initializes the interactive variables. */
extern void using_history __P((void));
extern void using_history PARAMS((void));
/* Return the current HISTORY_STATE of the history. */
extern HISTORY_STATE *history_get_history_state __P((void));
extern HISTORY_STATE *history_get_history_state PARAMS((void));
/* Set the state of the current history array to STATE. */
extern void history_set_history_state __P((HISTORY_STATE *));
extern void history_set_history_state PARAMS((HISTORY_STATE *));
/* Manage the history list. */
/* Place STRING at the end of the history list.
The associated data field (if any) is set to NULL. */
extern void add_history __P((char *));
extern void add_history PARAMS((const char *));
/* A reasonably useless function, only here for completeness. WHICH
is the magic number that tells us which element to delete. The
elements are numbered from 0. */
extern HIST_ENTRY *remove_history __P((int));
extern HIST_ENTRY *remove_history PARAMS((int));
/* Make the history entry at WHICH have LINE and DATA. This returns
the old entry so you can dispose of the data. In the case of an
invalid WHICH, a NULL pointer is returned. */
extern HIST_ENTRY *replace_history_entry __P((int, char *, histdata_t));
extern HIST_ENTRY *replace_history_entry PARAMS((int, const char *, histdata_t));
/* Clear the history list and start over. */
extern void clear_history __P((void));
extern void clear_history PARAMS((void));
/* Stifle the history list, remembering only MAX number of entries. */
extern void stifle_history __P((int));
extern void stifle_history PARAMS((int));
/* Stop stifling the history. This returns the previous amount the
history was stifled by. The value is positive if the history was
stifled, negative if it wasn't. */
extern int unstifle_history __P((void));
extern int unstifle_history PARAMS((void));
/* Return 1 if the history is stifled, 0 if it is not. */
extern int history_is_stifled __P((void));
extern int history_is_stifled PARAMS((void));
/* Information about the history list. */
/* Return a NULL terminated array of HIST_ENTRY which is the current input
history. Element 0 of this list is the beginning of time. If there
is no history, return NULL. */
extern HIST_ENTRY **history_list __P((void));
extern HIST_ENTRY **history_list PARAMS((void));
/* Returns the number which says what history element we are now
looking at. */
extern int where_history __P((void));
extern int where_history PARAMS((void));
/* Return the history entry at the current position, as determined by
history_offset. If there is no entry there, return a NULL pointer. */
HIST_ENTRY *current_history __P((void));
extern HIST_ENTRY *current_history PARAMS((void));
/* Return the history entry which is logically at OFFSET in the history
array. OFFSET is relative to history_base. */
extern HIST_ENTRY *history_get __P((int));
extern HIST_ENTRY *history_get PARAMS((int));
/* Return the number of bytes that the primary history entries are using.
This just adds up the lengths of the_history->lines. */
extern int history_total_bytes __P((void));
extern int history_total_bytes PARAMS((void));
/* Moving around the history list. */
/* Set the position in the history list to POS. */
int history_set_pos __P((int));
extern int history_set_pos PARAMS((int));
/* Back up history_offset to the previous history entry, and return
a pointer to that entry. If there is no previous entry, return
a NULL pointer. */
extern HIST_ENTRY *previous_history __P((void));
extern HIST_ENTRY *previous_history PARAMS((void));
/* Move history_offset forward to the next item in the input_history,
and return the a pointer to that entry. If there is no next entry,
return a NULL pointer. */
extern HIST_ENTRY *next_history __P((void));
extern HIST_ENTRY *next_history PARAMS((void));
/* Searching the history list. */
@ -152,45 +146,45 @@ extern HIST_ENTRY *next_history __P((void));
current_history () is the history entry, and the value of this function
is the offset in the line of that history entry that the string was
found in. Otherwise, nothing is changed, and a -1 is returned. */
extern int history_search __P((char *, int));
extern int history_search PARAMS((const char *, int));
/* Search the history for STRING, starting at history_offset.
The search is anchored: matching lines must begin with string.
DIRECTION is as in history_search(). */
extern int history_search_prefix __P((char *, int));
extern int history_search_prefix PARAMS((const char *, int));
/* Search for STRING in the history list, starting at POS, an
absolute index into the list. DIR, if negative, says to search
backwards from POS, else forwards.
Returns the absolute index of the history element where STRING
was found, or -1 otherwise. */
extern int history_search_pos __P((char *, int, int));
extern int history_search_pos PARAMS((const char *, int, int));
/* Managing the history file. */
/* Add the contents of FILENAME to the history list, a line at a time.
If FILENAME is NULL, then read from ~/.history. Returns 0 if
successful, or errno if not. */
extern int read_history __P((char *));
extern int read_history PARAMS((const char *));
/* Read a range of lines from FILENAME, adding them to the history list.
Start reading at the FROM'th line and end at the TO'th. If FROM
is zero, start at the beginning. If TO is less than FROM, read
until the end of the file. If FILENAME is NULL, then read from
~/.history. Returns 0 if successful, or errno if not. */
extern int read_history_range __P((char *, int, int));
extern int read_history_range PARAMS((const char *, int, int));
/* Write the current history to FILENAME. If FILENAME is NULL,
then write the history list to ~/.history. Values returned
are as in read_history (). */
extern int write_history __P((char *));
extern int write_history PARAMS((const char *));
/* Append NELEMENT entries to FILENAME. The entries appended are from
the end of the list minus NELEMENTs up to the end of the list. */
int append_history __P((int, char *));
extern int append_history PARAMS((int, const char *));
/* Truncate the history file, leaving only the last NLINES lines. */
extern int history_truncate_file __P((char *, int));
extern int history_truncate_file PARAMS((const char *, int));
/* History expansion. */
@ -206,12 +200,12 @@ extern int history_truncate_file __P((char *, int));
If an error ocurred in expansion, then OUTPUT contains a descriptive
error message. */
extern int history_expand __P((char *, char **));
extern int history_expand PARAMS((char *, char **));
/* Extract a string segment consisting of the FIRST through LAST
arguments present in STRING. Arguments are broken up as in
the shell. */
extern char *history_arg_extract __P((int, int, char *));
extern char *history_arg_extract PARAMS((int, int, const char *));
/* Return the text of the history event beginning at the current
offset into STRING. Pass STRING with *INDEX equal to the
@ -219,27 +213,31 @@ extern char *history_arg_extract __P((int, int, char *));
DELIMITING_QUOTE is a character that is allowed to end the string
specification for what to search for in addition to the normal
characters `:', ` ', `\t', `\n', and sometimes `?'. */
extern char *get_history_event __P((char *, int *, int));
extern char *get_history_event PARAMS((const char *, int *, int));
/* Return an array of tokens, much as the shell might. The tokens are
parsed out of STRING. */
extern char **history_tokenize __P((char *));
extern char **history_tokenize PARAMS((const char *));
/* Exported history variables. */
extern int history_base;
extern int history_length;
extern int max_input_history;
extern int history_max_entries;
extern char history_expansion_char;
extern char history_subst_char;
extern const char *history_word_delimiters;
extern char history_comment_char;
extern const char *history_no_expand_chars;
extern const char *history_search_delimiter_chars;
extern char *history_search_delimiter_chars;
extern int history_quotes_inhibit_expansion;
/* Backwards compatibility */
extern int max_input_history;
/* If set, this function is called to decide whether or not a particular
history expansion should be treated as a special case for the calling
application and not expanded. */
extern Function *history_inhibit_expansion_function;
extern rl_linebuf_func_t *history_inhibit_expansion_function;
#ifdef __cplusplus
}

View File

@ -7,7 +7,7 @@
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 1, or (at your option)
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
@ -18,7 +18,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
@ -32,27 +32,22 @@
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#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
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "history.h"
#include "histlib.h"
/* Variables imported from other history library files. */
extern int history_offset;
/* The list of alternate characters that can delimit a history search
string. */
const char *history_search_delimiter_chars = (char *)NULL;
char *history_search_delimiter_chars = (char *)NULL;
static int history_search_internal PARAMS((const char *, int, int));
/* Search the history for STRING, starting at history_offset.
If DIRECTION < 0, then the search is through previous entries, else
@ -66,7 +61,7 @@ const char *history_search_delimiter_chars = (char *)NULL;
static int
history_search_internal (string, direction, anchored)
char *string;
const char *string;
int direction, anchored;
{
register int i, reverse;
@ -162,7 +157,7 @@ history_search_internal (string, direction, anchored)
/* Do a non-anchored search for STRING through the history in DIRECTION. */
int
history_search (string, direction)
char *string;
const char *string;
int direction;
{
return (history_search_internal (string, direction, NON_ANCHORED_SEARCH));
@ -171,7 +166,7 @@ history_search (string, direction)
/* Do an anchored search for string through the history in DIRECTION. */
int
history_search_prefix (string, direction)
char *string;
const char *string;
int direction;
{
return (history_search_internal (string, direction, ANCHORED_SEARCH));
@ -182,7 +177,7 @@ history_search_prefix (string, direction)
which point to begin searching. */
int
history_search_pos (string, dir, pos)
char *string;
const char *string;
int dir, pos;
{
int ret, old;

View File

@ -18,7 +18,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@ -42,7 +42,7 @@
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_SELECT)
# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX) || defined(TIME_WITH_SYS_TIME)
# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
# include <sys/time.h>
# endif
#endif /* HAVE_SELECT */
@ -63,48 +63,31 @@ extern int errno;
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
/* Some standard library routines. */
#include "readline.h"
#include "rlprivate.h"
#include "rlshell.h"
#include "xmalloc.h"
/* What kind of non-blocking I/O do we have? */
#if !defined (O_NDELAY) && defined (O_NONBLOCK)
# define O_NDELAY O_NONBLOCK /* Posix style */
#endif
/* Functions imported from other files in the library. */
extern char *xmalloc (), *xrealloc ();
/* Variables and functions from macro.c. */
extern void _rl_add_macro_char ();
extern void _rl_with_macro_input ();
extern int _rl_next_macro_key ();
extern int _rl_defining_kbd_macro;
#if defined (VI_MODE)
extern void _rl_vi_set_last ();
extern int _rl_vi_textmod_command ();
#endif /* VI_MODE */
extern FILE *rl_instream, *rl_outstream;
extern Function *rl_last_func;
extern int rl_key_sequence_length;
extern int rl_pending_input;
extern int rl_editing_mode;
extern Keymap _rl_keymap;
extern int _rl_convert_meta_chars_to_ascii;
#if defined (__GO32__)
# include <pc.h>
#endif /* __GO32__ */
/* Non-null means it is a pointer to a function to run while waiting for
character input. */
Function *rl_event_hook = (Function *)NULL;
rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL;
Function *rl_getc_function = rl_getc;
rl_getc_func_t *rl_getc_function = rl_getc;
static int _keyboard_input_timeout = 100000; /* 0.1 seconds; it's in usec */
static int ibuffer_space PARAMS((void));
static int rl_get_char PARAMS((int *));
static int rl_gather_tyi PARAMS((void));
/* **************************************************************** */
/* */
@ -156,8 +139,8 @@ rl_get_char (key)
/* Stuff KEY into the *front* of the input buffer.
Returns non-zero if successful, zero if there is
no space left in the buffer. */
static int
rl_unget_char (key)
int
_rl_unget_char (key)
int key;
{
if (ibuffer_space ())
@ -171,33 +154,12 @@ rl_unget_char (key)
return (0);
}
#if defined(__EMX__)
int waiting_char = -1;
#endif
/* If a character is available to be read, then read it
and stuff it into IBUFFER. Otherwise, just return. */
static void
/* If a character is available to be read, then read it and stuff it into
IBUFFER. Otherwise, just return. Returns number of characters read
(0 if none available) and -1 on error (EIO). */
static int
rl_gather_tyi ()
{
#if defined (__EMX__)
if (isatty (0) && (waiting_char = _read_kbd(0, 0, 0)) != -1 && ibuffer_space ())
{
int i;
i = (*rl_getc_function) (rl_instream);
rl_stuff_char (i);
}
#elif defined (__GO32__)
char input;
if (isatty (0) && kbhit () && ibuffer_space ())
{
int i;
i = (*rl_getc_function) (rl_instream);
rl_stuff_char (i);
}
#else /* !__GO32__ */
int tty;
register int tem, result;
int chars_avail;
@ -215,14 +177,18 @@ rl_gather_tyi ()
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
timeout.tv_sec = 0;
timeout.tv_usec = 100000; /* 0.1 seconds */
if (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) <= 0)
return; /* Nothing to read. */
timeout.tv_usec = _keyboard_input_timeout;
result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
if (result <= 0)
return 0; /* Nothing to read. */
#endif
result = -1;
#if defined (FIONREAD)
errno = 0;
result = ioctl (tty, FIONREAD, &chars_avail);
if (result == -1 && errno == EIO)
return -1;
#endif
#if defined (O_NDELAY)
@ -235,14 +201,14 @@ rl_gather_tyi ()
fcntl (tty, F_SETFL, tem);
if (chars_avail == -1 && errno == EAGAIN)
return;
return 0;
}
#endif /* O_NDELAY */
/* If there's nothing available, don't waste time trying to read
something. */
if (chars_avail <= 0)
return;
return 0;
tem = ibuffer_space ();
@ -266,23 +232,36 @@ rl_gather_tyi ()
if (chars_avail)
rl_stuff_char (input);
}
#endif /* !__GO32__ */
return 1;
}
int
rl_set_keyboard_input_timeout (u)
int u;
{
int o;
o = _keyboard_input_timeout;
if (u > 0)
_keyboard_input_timeout = u;
return (o);
}
/* Is there input available to be read on the readline input file
descriptor? Only works if the system has select(2) or FIONREAD. */
descriptor? Only works if the system has select(2) or FIONREAD.
Uses the value of _keyboard_input_timeout as the timeout; if another
readline function wants to specify a timeout and not leave it up to
the user, it should use _rl_input_queued(timeout_value_in_microseconds)
instead. */
int
_rl_input_available ()
{
#if defined (__EMX__)
if (isatty (0) && (waiting_char = _read_kbd(0, 0, 0)) != -1)
return 1;
#else /* __EMX__ */
#if defined(HAVE_SELECT)
fd_set readfds, exceptfds;
struct timeval timeout;
#endif
#if defined(FIONREAD)
#if !defined (HAVE_SELECT) && defined(FIONREAD)
int chars_avail;
#endif
int tty;
@ -295,19 +274,32 @@ _rl_input_available ()
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
timeout.tv_sec = 0;
timeout.tv_usec = 100000; /* 0.1 seconds */
timeout.tv_usec = _keyboard_input_timeout;
return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
#endif
#else
#if defined (FIONREAD)
if (ioctl (tty, FIONREAD, &chars_avail) == 0)
return (chars_avail);
#endif
#endif /* !__EMX__ */
#endif
return 0;
}
int
_rl_input_queued (t)
int t;
{
int old_timeout, r;
old_timeout = rl_set_keyboard_input_timeout (t);
r = _rl_input_available ();
rl_set_keyboard_input_timeout (old_timeout);
return r;
}
void
_rl_insert_typein (c)
int c;
@ -316,7 +308,7 @@ _rl_insert_typein (c)
char *string;
i = key = 0;
string = xmalloc (ibuffer_len + 1);
string = (char *)xmalloc (ibuffer_len + 1);
string[i++] = (char) c;
while ((t = rl_get_char (&key)) &&
@ -325,7 +317,7 @@ _rl_insert_typein (c)
string[i++] = key;
if (t)
rl_unget_char (key);
_rl_unget_char (key);
string[i] = '\0';
rl_insert_text (string);
@ -345,6 +337,7 @@ rl_stuff_char (key)
{
key = NEWLINE;
rl_pending_input = EOF;
RL_SETSTATE (RL_STATE_INPUTPENDING);
}
ibuffer[push_index++] = key;
if (push_index >= ibuffer_len)
@ -359,6 +352,16 @@ rl_execute_next (c)
int c;
{
rl_pending_input = c;
RL_SETSTATE (RL_STATE_INPUTPENDING);
return 0;
}
/* Clear any pending input pushed with rl_execute_next() */
int
rl_clear_pending_input ()
{
rl_pending_input = 0;
RL_UNSETSTATE (RL_STATE_INPUTPENDING);
return 0;
}
@ -379,7 +382,7 @@ rl_read_key ()
if (rl_pending_input)
{
c = rl_pending_input;
rl_pending_input = 0;
rl_clear_pending_input ();
}
else
{
@ -393,7 +396,13 @@ rl_read_key ()
while (rl_event_hook && rl_get_char (&c) == 0)
{
(*rl_event_hook) ();
rl_gather_tyi ();
if (rl_done) /* XXX - experimental */
return ('\n');
if (rl_gather_tyi () < 0) /* XXX - EIO */
{
rl_done = 1;
return ('\n');
}
}
}
else
@ -410,96 +419,9 @@ int
rl_getc (stream)
FILE *stream;
{
int result, flags;
int result;
unsigned char c;
#if defined (__EMX__)
if (isatty (0))
{
int key;
if (waiting_char != -1)
{
key = waiting_char;
waiting_char = -1;
}
else
{
#ifdef __RSXNT__
pc_flush();
#endif
key = _read_kbd(0, 1, 0);
}
while (key == 0)
{
key |= (_read_kbd(0, 1, 0) << 8);
/* printf("<%04X> ", key);
fflush(stdout); */
switch (key)
{
case 0x4B00: /* left arrow */
key = 'B' - 64;
break;
case 0x4D00: /* right arrow */
key = 'F' - 64;
break;
case 0x7300: /* ctrl left arrow */
key = 27;
waiting_char = 'B';
break;
case 0x7400: /* ctrl right arrow */
key = 27;
waiting_char = 'F';
break;
case 0x4800: /* up arrow */
key = 'P' - 64;
break;
case 0x5000: /* down arrow */
key = 'N' - 64;
break;
case 0x8D00: /* ctrl up arrow */
key = 'R' - 64;
break;
case 0x9100: /* ctrl down arrow */
key = 'S' - 64;
break;
case 0x4700: /* home key */
key = 'A' - 64;
break;
case 0x4F00: /* end key */
key = 'E' - 64;
break;
case 0x7700: /* ctrl home key */
key = 27;
waiting_char = '<';
break;
case 0x7500: /* ctrl end key */
key = 27;
waiting_char = '>';
break;
case 0x5300: /* delete key */
key = 'D' - 64;
break;
case 0x5200: /* insert key */
key = 'V' - 64;
break;
default: /* ignore all other special keys, read next */
key = _read_kbd(0, 1, 0);
break;
}
}
return (key & 0xFF);
}
#endif /* __EMX__ */
#if defined (__GO32__)
if (isatty (0))
return (getkey () & 0x7F);
#endif /* __GO32__ */
while (1)
{
result = read (fileno (stream), &c, sizeof (unsigned char));
@ -518,40 +440,101 @@ rl_getc (stream)
#endif
#if defined (EWOULDBLOCK)
if (errno == EWOULDBLOCK)
# define X_EWOULDBLOCK EWOULDBLOCK
#else
# define X_EWOULDBLOCK -99
#endif
#if defined (EAGAIN)
# define X_EAGAIN EAGAIN
#else
# define X_EAGAIN -99
#endif
if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
{
if ((flags = fcntl (fileno (stream), F_GETFL, 0)) < 0)
if (sh_unset_nodelay_mode (fileno (stream)) < 0)
return (EOF);
if (flags & O_NDELAY)
{
flags &= ~O_NDELAY;
fcntl (fileno (stream), F_SETFL, flags);
continue;
}
continue;
}
#endif /* EWOULDBLOCK */
#if defined (_POSIX_VERSION) && defined (EAGAIN) && defined (O_NONBLOCK)
if (errno == EAGAIN)
{
if ((flags = fcntl (fileno (stream), F_GETFL, 0)) < 0)
return (EOF);
if (flags & O_NONBLOCK)
{
flags &= ~O_NONBLOCK;
fcntl (fileno (stream), F_SETFL, flags);
continue;
}
}
#endif /* _POSIX_VERSION && EAGAIN && O_NONBLOCK */
#undef X_EWOULDBLOCK
#undef X_EAGAIN
#if !defined (__GO32__)
/* If the error that we received was SIGINT, then try again,
this is simply an interrupted system call to read ().
Otherwise, some error ocurred, also signifying EOF. */
if (errno != EINTR)
return (EOF);
#endif /* !__GO32__ */
}
}
#if defined (HANDLE_MULTIBYTE)
/* read multibyte char */
int
_rl_read_mbchar (mbchar, size)
char *mbchar;
int size;
{
int mb_len = 0;
size_t mbchar_bytes_length;
wchar_t wc;
mbstate_t ps, ps_back;
memset(&ps, 0, sizeof (mbstate_t));
memset(&ps_back, 0, sizeof (mbstate_t));
while (mb_len < size)
{
RL_SETSTATE(RL_STATE_MOREINPUT);
mbchar[mb_len++] = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
if (mbchar_bytes_length == (size_t)(-1))
break; /* invalid byte sequence for the current locale */
else if (mbchar_bytes_length == (size_t)(-2))
{
/* shorted bytes */
ps = ps_back;
continue;
}
else if (mbchar_bytes_length > (size_t)(0))
break;
}
return mb_len;
}
/* Read a multibyte-character string whose first character is FIRST into
the buffer MB of length MBLEN. Returns the last character read, which
may be FIRST. Used by the search functions, among others. Very similar
to _rl_read_mbchar. */
int
_rl_read_mbstring (first, mb, mblen)
int first;
char *mb;
int mblen;
{
int i, c;
mbstate_t ps;
c = first;
memset (mb, 0, mblen);
for (i = 0; i < mblen; i++)
{
mb[i] = (char)c;
memset (&ps, 0, sizeof (mbstate_t));
if (_rl_get_char_len (mb, &ps) == -2)
{
/* Read more for multibyte character */
RL_SETSTATE (RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE (RL_STATE_MOREINPUT);
}
else
break;
}
return c;
}
#endif /* HANDLE_MULTIBYTE */

View File

@ -4,7 +4,7 @@
/* */
/* **************************************************************** */
/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
/* Copyright (C) 1987-2002 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
@ -12,7 +12,7 @@
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 1, or (at your option)
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
@ -23,7 +23,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@ -45,32 +45,33 @@
#endif
#include "rldefs.h"
#include "rlmbutil.h"
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
#include "xmalloc.h"
/* Variables exported to other files in the readline library. */
unsigned char *_rl_isearch_terminators = (unsigned char *)NULL;
char *_rl_isearch_terminators = (char *)NULL;
/* Variables imported from other files in the readline library. */
extern Keymap _rl_keymap;
extern HIST_ENTRY *saved_line_for_history;
extern int rl_line_buffer_len;
extern int rl_point, rl_end;
extern char *rl_line_buffer;
extern HIST_ENTRY *_rl_saved_line_for_history;
extern int rl_execute_next ();
extern void rl_extend_line_buffer ();
extern int _rl_input_available ();
extern char *xmalloc (), *xrealloc ();
static int rl_search_history ();
/* Forward declarations */
static int rl_search_history PARAMS((int, int));
/* Last line found by the current incremental search, so we don't `find'
identical lines many times in a row. */
static char *prev_line_found;
/* Last search string and its length. */
static char *last_isearch_string;
static int last_isearch_string_len;
static const char *default_isearch_terminators = "\033\012";
/* Search backwards through the history looking for a string which is typed
interactively. Start with the current line. */
int
@ -97,15 +98,14 @@ rl_forward_search_history (sign, key)
static void
rl_display_search (search_string, reverse_p, where)
char *search_string;
int reverse_p;
int where __attribute__((unused));
int reverse_p, where __attribute__((unused));
{
char *message;
int msglen, searchlen;
searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
message = xmalloc (searchlen + 33);
message = (char *)xmalloc (searchlen + 33);
msglen = 0;
#if defined (NOTDEF)
@ -135,7 +135,7 @@ rl_display_search (search_string, reverse_p, where)
strcpy (message + msglen, "': ");
rl_message ("%s", message, 0);
rl_message ("%s", message);
free (message);
(*rl_redisplay_function) ();
}
@ -145,7 +145,8 @@ rl_display_search (search_string, reverse_p, where)
DIRECTION is which direction to search; >= 0 means forward, < 0 means
backwards. */
static int
rl_search_history (int direction, int invoking_key __attribute__((unused)))
rl_search_history (direction, invoking_key)
int direction, invoking_key __attribute__((unused));
{
/* The string that the user types in to search for. */
char *search_string;
@ -166,8 +167,12 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
HIST_ENTRY **hlist;
register int i;
int orig_point, orig_line, last_found_line;
int orig_point, orig_mark, orig_line, last_found_line;
int c, found, failed, sline_len;
int n, wstart, wlen;
#if defined (HANDLE_MULTIBYTE)
char mb[MB_LEN_MAX];
#endif
/* The line currently being searched. */
char *sline;
@ -181,19 +186,21 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
/* The list of characters which terminate the search, but are not
subsequently executed. If the variable isearch-terminators has
been set, we use that value, otherwise we use ESC and C-J. */
unsigned char *isearch_terminators;
const char *isearch_terminators;
RL_SETSTATE(RL_STATE_ISEARCH);
orig_point = rl_point;
orig_mark = rl_mark;
last_found_line = orig_line = where_history ();
reverse = direction < 0;
hlist = history_list ();
allocated_line = (char *)NULL;
isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
: (unsigned char *)"\033\012";
: default_isearch_terminators;
/* Create an arrary of pointers to the lines that we want to search. */
maybe_replace_line ();
rl_maybe_replace_line ();
i = 0;
if (hlist)
for (i = 0; hlist[i]; i++);
@ -204,12 +211,12 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
for (i = 0; i < hlen; i++)
lines[i] = hlist[i]->line;
if (saved_line_for_history)
lines[i] = saved_line_for_history->line;
if (_rl_saved_line_for_history)
lines[i] = _rl_saved_line_for_history->line;
else
{
/* Keep track of this so we can free it. */
allocated_line = xmalloc (1 + strlen (rl_line_buffer));
allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer));
strcpy (allocated_line, &rl_line_buffer[0]);
lines[i] = allocated_line;
}
@ -222,7 +229,7 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
rl_save_prompt ();
/* Initialize search parameters. */
search_string = xmalloc (search_string_size = 128);
search_string = (char *)xmalloc (search_string_size = 128);
*search_string = '\0';
search_string_index = 0;
prev_line_found = (char *)0; /* XXX */
@ -239,12 +246,20 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
found = failed = 0;
for (;;)
{
Function *f = (Function *)NULL;
rl_command_func_t *f = (rl_command_func_t *)NULL;
/* Read a key and decide how to proceed. */
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (_rl_keymap[c].type == ISFUNC)
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = _rl_read_mbstring (c, mb, MB_LEN_MAX);
#endif
/* Translate the keys we do something with to opcodes. */
if (c >= 0 && _rl_keymap[c].type == ISFUNC)
{
f = _rl_keymap[c].function;
@ -252,34 +267,56 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
c = reverse ? -1 : -2;
else if (f == rl_forward_search_history)
c = !reverse ? -1 : -2;
else if (f == rl_rubout)
c = -3;
else if (c == CTRL ('G'))
c = -4;
else if (c == CTRL ('W')) /* XXX */
c = -5;
else if (c == CTRL ('Y')) /* XXX */
c = -6;
}
#if 0
/* Let NEWLINE (^J) terminate the search for people who don't like
using ESC. ^M can still be used to terminate the search and
immediately execute the command. */
if (c == ESC || c == NEWLINE)
#else
/* The characters in isearch_terminators (set from the user-settable
variable isearch-terminators) are used to terminate the search but
not subsequently execute the character as a command. The default
value is "\033\012" (ESC and C-J). */
if (strchr((char*) isearch_terminators, c))
#endif
if (strchr (isearch_terminators, c))
{
/* ESC still terminates the search, but if there is pending
input or if input arrives within 0.1 seconds (on systems
with select(2)) it is used as a prefix character
with rl_execute_next. WATCH OUT FOR THIS! This is intended
to allow the arrow keys to be used like ^F and ^B are used
to terminate the search and execute the movement command. */
if (c == ESC && _rl_input_available ()) /* XXX */
to terminate the search and execute the movement command.
XXX - since _rl_input_available depends on the application-
settable keyboard timeout value, this could alternatively
use _rl_input_queued(100000) */
if (c == ESC && _rl_input_available ())
rl_execute_next (ESC);
break;
}
if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('G'))
#define ENDSRCH_CHAR(c) \
((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G')))
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
if (c >= 0 && strlen (mb) == 1 && ENDSRCH_CHAR (c))
{
/* This sets rl_pending_input to c; it will be picked up the next
time rl_read_key is called. */
rl_execute_next (c);
break;
}
}
else
#endif
if (c >= 0 && ENDSRCH_CHAR (c))
{
/* This sets rl_pending_input to c; it will be picked up the next
time rl_read_key is called. */
rl_execute_next (c);
break;
}
@ -288,13 +325,24 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
{
case -1:
if (search_string_index == 0)
continue;
{
if (last_isearch_string)
{
search_string_size = 64 + last_isearch_string_len;
search_string = (char *)xrealloc (search_string, search_string_size);
strcpy (search_string, last_isearch_string);
search_string_index = last_isearch_string_len;
rl_display_search (search_string, reverse, -1);
break;
}
continue;
}
else if (reverse)
--line_index;
else if (line_index != sline_len)
++line_index;
else
ding ();
rl_ding ();
break;
/* switch directions */
@ -303,40 +351,96 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
reverse = direction < 0;
break;
case CTRL ('G'):
strcpy (rl_line_buffer, lines[orig_line]);
/* delete character from search string. */
case -3: /* C-H, DEL */
/* This is tricky. To do this right, we need to keep a
stack of search positions for the current search, with
sentinels marking the beginning and end. But this will
do until we have a real isearch-undo. */
if (search_string_index == 0)
rl_ding ();
else
search_string[--search_string_index] = '\0';
break;
case -4: /* C-G */
rl_replace_line (lines[orig_line], 0);
rl_point = orig_point;
rl_end = strlen (rl_line_buffer);
rl_mark = orig_mark;
rl_restore_prompt();
rl_clear_message ();
if (allocated_line)
free (allocated_line);
free (lines);
RL_UNSETSTATE(RL_STATE_ISEARCH);
return 0;
#if 0
/* delete character from search string. */
case -3:
if (search_string_index == 0)
ding ();
else
case -5: /* C-W */
/* skip over portion of line we already matched */
wstart = rl_point + search_string_index;
if (wstart >= rl_end)
{
search_string[--search_string_index] = '\0';
/* This is tricky. To do this right, we need to keep a
stack of search positions for the current search, with
sentinels marking the beginning and end. */
rl_ding ();
break;
}
/* if not in a word, move to one. */
if (rl_alphabetic(rl_line_buffer[wstart]) == 0)
{
rl_ding ();
break;
}
n = wstart;
while (n < rl_end && rl_alphabetic(rl_line_buffer[n]))
n++;
wlen = n - wstart + 1;
if (search_string_index + wlen + 1 >= search_string_size)
{
search_string_size += wlen + 1;
search_string = (char *)xrealloc (search_string, search_string_size);
}
for (; wstart < n; wstart++)
search_string[search_string_index++] = rl_line_buffer[wstart];
search_string[search_string_index] = '\0';
break;
case -6: /* C-Y */
/* skip over portion of line we already matched */
wstart = rl_point + search_string_index;
if (wstart >= rl_end)
{
rl_ding ();
break;
}
n = rl_end - wstart + 1;
if (search_string_index + n + 1 >= search_string_size)
{
search_string_size += n + 1;
search_string = (char *)xrealloc (search_string, search_string_size);
}
for (n = wstart; n < rl_end; n++)
search_string[search_string_index++] = rl_line_buffer[n];
search_string[search_string_index] = '\0';
break;
#endif
default:
/* Add character to search string and continue search. */
if (search_string_index + 2 >= search_string_size)
{
search_string_size += 128;
search_string = xrealloc (search_string, search_string_size);
search_string = (char *)xrealloc (search_string, search_string_size);
}
search_string[search_string_index++] = c;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int j, l;
for (j = 0, l = strlen (mb); j < l; )
search_string[search_string_index++] = mb[j++];
}
else
#endif
search_string[search_string_index++] = c;
search_string[search_string_index] = '\0';
break;
}
@ -391,7 +495,7 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
if (failed)
{
/* We cannot find the search string. Ding the bell. */
ding ();
rl_ding ();
i = last_found_line;
continue; /* XXX - was break */
}
@ -401,17 +505,9 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
the location. */
if (found)
{
int line_len;
prev_line_found = lines[i];
line_len = strlen (lines[i]);
if (line_len >= rl_line_buffer_len)
rl_extend_line_buffer (line_len);
strcpy (rl_line_buffer, lines[i]);
rl_replace_line (lines[i], 0);
rl_point = line_index;
rl_end = line_len;
last_found_line = i;
rl_display_search (search_string, reverse, (i == orig_line) ? -1 : i);
}
@ -427,23 +523,38 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
rl_restore_prompt ();
/* Free the search string. */
free (search_string);
/* Save the search string for possible later use. */
FREE (last_isearch_string);
last_isearch_string = search_string;
last_isearch_string_len = search_string_index;
if (last_found_line < orig_line)
rl_get_previous_history (orig_line - last_found_line, 0);
else
rl_get_next_history (last_found_line - orig_line, 0);
/* If the string was not found, put point at the end of the line. */
/* If the string was not found, put point at the end of the last matching
line. If last_found_line == orig_line, we didn't find any matching
history lines at all, so put point back in its original position. */
if (line_index < 0)
line_index = strlen (rl_line_buffer);
{
if (last_found_line == orig_line)
line_index = orig_point;
else
line_index = strlen (rl_line_buffer);
rl_mark = orig_mark;
}
rl_point = line_index;
/* Don't worry about where to put the mark here; rl_get_previous_history
and rl_get_next_history take care of it. */
rl_clear_message ();
if (allocated_line)
free (allocated_line);
FREE (allocated_line);
free (lines);
RL_UNSETSTATE(RL_STATE_ISEARCH);
return 0;
}

View File

@ -7,7 +7,7 @@
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 1, or (at your option) any
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
@ -17,7 +17,7 @@
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@ -30,18 +30,18 @@
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include <stdio.h> /* for FILE * definition for readline.h */
#include "readline.h"
#include "rlconf.h"
#include "keymaps.h"
#include "emacs_keymap.c"
#if defined (VI_MODE)
#include "vi_keymap.c"
#endif
extern int rl_do_lowercase_version ();
extern int rl_rubout (), rl_insert ();
extern char *xmalloc (), *xrealloc ();
#include "xmalloc.h"
/* **************************************************************** */
/* */
@ -61,7 +61,7 @@ rl_make_bare_keymap ()
for (i = 0; i < KEYMAP_SIZE; i++)
{
keymap[i].type = ISFUNC;
keymap[i].function = (Function *)NULL;
keymap[i].function = (rl_command_func_t *)NULL;
}
for (i = 'A'; i < ('Z' + 1); i++)

View File

@ -7,7 +7,7 @@
The GNU Readline 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 1, or
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@ -18,25 +18,23 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _KEYMAPS_H_
#define _KEYMAPS_H_
#ifdef __cplusplus
extern "C" {
#endif
#if defined (READLINE_LIBRARY)
# include "rlstdc.h"
# include "chardefs.h"
# include "rltypedefs.h"
#else
# include <readline/rlstdc.h>
# include <readline/chardefs.h>
#endif
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
# include <readline/rltypedefs.h>
#endif
/* A keymap contains one entry for each key in the ASCII set.
@ -46,16 +44,17 @@ typedef char **CPPFunction ();
TYPE says which kind of thing FUNCTION is. */
typedef struct _keymap_entry {
char type;
Function *function;
rl_command_func_t *function;
} KEYMAP_ENTRY;
/* This must be large enough to hold bindings for all of the characters
in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
and so on). */
#define KEYMAP_SIZE 256
and so on) plus one for subsequence matching. */
#define KEYMAP_SIZE 257
#define ANYOTHERKEY KEYMAP_SIZE-1
/* I wanted to make the above structure contain a union of:
union { Function *function; struct _keymap_entry *keymap; } value;
union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
but this made it impossible for me to create a static array.
Maybe I need C lessons. */
@ -72,29 +71,33 @@ extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
/* Return a new, empty keymap.
Free it with free() when you are done. */
extern Keymap rl_make_bare_keymap __P((void));
extern Keymap rl_make_bare_keymap PARAMS((void));
/* Return a new keymap which is a copy of MAP. */
extern Keymap rl_copy_keymap __P((Keymap));
extern Keymap rl_copy_keymap PARAMS((Keymap));
/* Return a new keymap with the printing characters bound to rl_insert,
the lowercase Meta characters bound to run their equivalents, and
the Meta digits bound to produce numeric arguments. */
extern Keymap rl_make_keymap __P((void));
extern Keymap rl_make_keymap PARAMS((void));
/* Free the storage associated with a keymap. */
extern void rl_discard_keymap __P((Keymap));
extern void rl_discard_keymap PARAMS((Keymap));
/* These functions actually appear in bind.c */
/* Return the keymap corresponding to a given name. Names look like
`emacs' or `emacs-meta' or `vi-insert'. */
extern Keymap rl_get_keymap_by_name __P((char *));
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
/* Return the current keymap. */
extern Keymap rl_get_keymap __P((void));
extern Keymap rl_get_keymap PARAMS((void));
/* Set the current keymap to MAP. */
extern void rl_set_keymap __P((Keymap));
extern void rl_set_keymap PARAMS((Keymap));
#ifdef __cplusplus
}
#endif
#endif /* _KEYMAPS_H_ */

View File

@ -7,7 +7,7 @@
The GNU Readline 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 1, or
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@ -18,7 +18,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@ -46,17 +46,8 @@
#include "readline.h"
#include "history.h"
extern int _rl_last_command_was_kill;
extern int rl_editing_mode;
extern int rl_explicit_arg;
extern Function *rl_last_func;
extern void _rl_init_argument ();
extern int _rl_set_mark_at_pos ();
extern void _rl_fix_point ();
extern void _rl_abort_internal ();
extern char *xmalloc (), *xrealloc ();
#include "rlprivate.h"
#include "xmalloc.h"
/* **************************************************************** */
/* */
@ -79,10 +70,16 @@ static int rl_kill_index;
/* How many slots we have in the kill ring. */
static int rl_kill_ring_length;
static int _rl_copy_to_kill_ring PARAMS((char *, int));
static int region_kill_internal PARAMS((int));
static int _rl_copy_word_as_kill PARAMS((int, int));
static int rl_yank_nth_arg_internal PARAMS((int, int, int));
/* How to say that you only want to save a certain amount
of kill material. */
int
rl_set_retained_kills (int num __attribute__((unused)))
rl_set_retained_kills (num)
int num __attribute__((unused));
{
return 0;
}
@ -137,7 +134,7 @@ _rl_copy_to_kill_ring (text, append)
if (_rl_last_command_was_kill && rl_editing_mode != vi_mode)
{
old = rl_kill_ring[slot];
new = xmalloc (1 + strlen (old) + strlen (text));
new = (char *)xmalloc (1 + strlen (old) + strlen (text));
if (append)
{
@ -204,18 +201,21 @@ int
rl_kill_word (count, key)
int count, key;
{
int orig_point = rl_point;
int orig_point;
if (count < 0)
return (rl_backward_kill_word (-count, key));
else
{
orig_point = rl_point;
rl_forward_word (count, key);
if (rl_point != orig_point)
rl_kill_text (orig_point, rl_point);
rl_point = orig_point;
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
return 0;
}
@ -225,16 +225,20 @@ int
rl_backward_kill_word (count, ignore)
int count, ignore;
{
int orig_point = rl_point;
int orig_point;
if (count < 0)
return (rl_kill_word (-count, ignore));
else
{
orig_point = rl_point;
rl_backward_word (count, ignore);
if (rl_point != orig_point)
rl_kill_text (orig_point, rl_point);
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
return 0;
}
@ -245,16 +249,19 @@ int
rl_kill_line (direction, ignore)
int direction, ignore;
{
int orig_point = rl_point;
int orig_point;
if (direction < 0)
return (rl_backward_kill_line (1, ignore));
else
{
orig_point = rl_point;
rl_end_of_line (1, ignore);
if (orig_point != rl_point)
rl_kill_text (orig_point, rl_point);
rl_point = orig_point;
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
return 0;
}
@ -265,18 +272,22 @@ int
rl_backward_kill_line (direction, ignore)
int direction, ignore;
{
int orig_point = rl_point;
int orig_point;
if (direction < 0)
return (rl_kill_line (1, ignore));
else
{
if (!rl_point)
ding ();
rl_ding ();
else
{
orig_point = rl_point;
rl_beg_of_line (1, ignore);
rl_kill_text (orig_point, rl_point);
if (rl_point != orig_point)
rl_kill_text (orig_point, rl_point);
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
}
return 0;
@ -284,12 +295,13 @@ rl_backward_kill_line (direction, ignore)
/* Kill the whole line, no matter where point is. */
int
rl_kill_full_line (int count __attribute__((unused)),
int ignore __attribute__((unused)))
rl_kill_full_line (count, ignore)
int count __attribute__((unused)), ignore __attribute__((unused));
{
rl_begin_undo_group ();
rl_point = 0;
rl_kill_text (rl_point, rl_end);
rl_mark = 0;
rl_end_undo_group ();
return 0;
}
@ -301,12 +313,13 @@ rl_kill_full_line (int count __attribute__((unused)),
/* This does what C-w does in Unix. We can't prevent people from
using behaviour that they expect. */
int
rl_unix_word_rubout (int count, int key __attribute__((unused)))
rl_unix_word_rubout (count, key)
int count, key __attribute__((unused));
{
int orig_point;
if (rl_point == 0)
ding ();
rl_ding ();
else
{
orig_point = rl_point;
@ -323,6 +336,8 @@ rl_unix_word_rubout (int count, int key __attribute__((unused)))
}
rl_kill_text (orig_point, rl_point);
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
return 0;
}
@ -334,15 +349,17 @@ rl_unix_word_rubout (int count, int key __attribute__((unused)))
into the line at all, and if you aren't, then you know what you are
doing. */
int
rl_unix_line_discard (int count __attribute__((unused)),
int key __attribute__((unused)))
rl_unix_line_discard (count, key)
int count __attribute__((unused)), key __attribute__((unused));
{
if (rl_point == 0)
ding ();
rl_ding ();
else
{
rl_kill_text (rl_point, 0);
rl_point = 0;
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
return 0;
}
@ -355,38 +372,37 @@ region_kill_internal (delete)
{
char *text;
if (rl_mark == rl_point)
if (rl_mark != rl_point)
{
_rl_last_command_was_kill++;
return 0;
text = rl_copy_text (rl_point, rl_mark);
if (delete)
rl_delete_text (rl_point, rl_mark);
_rl_copy_to_kill_ring (text, rl_point < rl_mark);
}
text = rl_copy_text (rl_point, rl_mark);
if (delete)
rl_delete_text (rl_point, rl_mark);
_rl_copy_to_kill_ring (text, rl_point < rl_mark);
_rl_last_command_was_kill++;
return 0;
}
/* Copy the text in the region to the kill ring. */
int
rl_copy_region_to_kill (int count __attribute__((unused)),
int key __attribute__((unused)))
rl_copy_region_to_kill (count, ignore)
int count __attribute__((unused)), ignore __attribute__((unused));
{
return (region_kill_internal (0));
}
/* Kill the text between the point and mark. */
int
rl_kill_region (int count __attribute__((unused)),
int key __attribute__((unused)))
rl_kill_region (count, ignore)
int count __attribute__((unused)), ignore __attribute__((unused));
{
int r;
int r, npoint;
npoint = (rl_point < rl_mark) ? rl_point : rl_mark;
r = region_kill_internal (1);
_rl_fix_point (1);
rl_point = npoint;
return r;
}
@ -443,8 +459,8 @@ rl_copy_backward_word (count, key)
/* Yank back the last killed text. This ignores arguments. */
int
rl_yank (int count __attribute__((unused)),
int key __attribute__((unused)))
rl_yank (count, ignore)
int count __attribute__((unused)), ignore __attribute__((unused));
{
if (rl_kill_ring == 0)
{
@ -462,8 +478,8 @@ rl_yank (int count __attribute__((unused)),
delete that text from the line, rotate the index down, and
yank back some other text. */
int
rl_yank_pop (int count __attribute__((unused)),
int key __attribute__((unused)))
rl_yank_pop (count, key)
int count __attribute__((unused)), key __attribute__((unused));
{
int l, n;
@ -501,7 +517,9 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
{
register HIST_ENTRY *entry;
char *arg;
int i;
int i, pos;
pos = where_history ();
if (history_skip)
{
@ -510,30 +528,26 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
}
entry = previous_history ();
if (entry)
history_set_pos (pos);
if (entry == 0)
{
if (history_skip)
{
for (i = 0; i < history_skip; i++)
next_history ();
}
next_history ();
}
else
{
ding ();
rl_ding ();
return -1;
}
arg = history_arg_extract (count, count, entry->line);
if (!arg || !*arg)
{
ding ();
rl_ding ();
return -1;
}
rl_begin_undo_group ();
_rl_set_mark_at_pos (rl_point);
#if defined (VI_MODE)
/* Vi mode always inserts a space before yanking the argument, and it
inserts it right *after* rl_point. */
@ -601,7 +615,7 @@ rl_yank_last_arg (count, key)
}
/* A special paste command for users of Cygnus's cygwin32. */
#if defined (__CYGWIN32__)
#if defined (__CYGWIN__)
#include <windows.h>
int
@ -621,12 +635,13 @@ rl_paste_from_clipboard (count, key)
if (ptr)
{
len = ptr - data;
ptr = xmalloc (len + 1);
ptr = (char *)xmalloc (len + 1);
ptr[len] = '\0';
strncpy (ptr, data, len);
}
else
ptr = data;
_rl_set_mark_at_pos (rl_point);
rl_insert_text (ptr);
if (ptr != data)
free (ptr);
@ -634,4 +649,4 @@ rl_paste_from_clipboard (count, key)
}
return (0);
}
#endif /* __CYGWIN32__ */
#endif /* __CYGWIN__ */

View File

@ -7,7 +7,7 @@
The GNU Readline 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 1, or
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@ -18,7 +18,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@ -46,19 +46,8 @@
#include "readline.h"
#include "history.h"
#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
/* Forward definitions. */
void _rl_push_executing_macro (), _rl_pop_executing_macro ();
void _rl_add_macro_char ();
/* Extern declarations. */
extern int rl_explicit_arg;
extern int rl_key_sequence_length;
extern void _rl_abort_internal ();
extern char *xmalloc (), *xrealloc ();
#include "rlprivate.h"
#include "xmalloc.h"
/* **************************************************************** */
/* */
@ -66,12 +55,9 @@ extern char *xmalloc (), *xrealloc ();
/* */
/* **************************************************************** */
/* Non-zero means to save keys that we dispatch on in a kbd macro. */
int _rl_defining_kbd_macro = 0;
/* The currently executing macro string. If this is non-zero,
then it is a malloc ()'ed string where input is coming from. */
char *_rl_executing_macro = (char *)NULL;
char *rl_executing_macro = (char *)NULL;
/* The offset in the above string to the next character to be read. */
static int executing_macro_index;
@ -90,7 +76,7 @@ static int current_macro_index;
It is a linked list of string/index for each saved macro. */
struct saved_macro {
struct saved_macro *next;
const char *string;
char *string;
int sindex;
};
@ -100,11 +86,13 @@ static struct saved_macro *macro_list = (struct saved_macro *)NULL;
/* Set up to read subsequent input from STRING.
STRING is free ()'ed when we are done with it. */
void
_rl_with_macro_input (const char *string)
_rl_with_macro_input (string)
char *string;
{
_rl_push_executing_macro ();
_rl_executing_macro = (char*) string;
rl_executing_macro = string;
executing_macro_index = 0;
RL_SETSTATE(RL_STATE_MACROINPUT);
}
/* Return the next character available from a macro, or 0 if
@ -112,16 +100,16 @@ _rl_with_macro_input (const char *string)
int
_rl_next_macro_key ()
{
if (_rl_executing_macro == 0)
if (rl_executing_macro == 0)
return (0);
if (_rl_executing_macro[executing_macro_index] == 0)
if (rl_executing_macro[executing_macro_index] == 0)
{
_rl_pop_executing_macro ();
return (_rl_next_macro_key ());
}
return (_rl_executing_macro[executing_macro_index++]);
return (rl_executing_macro[executing_macro_index++]);
}
/* Save the currently executing macro on a stack of saved macros. */
@ -133,7 +121,7 @@ _rl_push_executing_macro ()
saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro));
saver->next = macro_list;
saver->sindex = executing_macro_index;
saver->string = _rl_executing_macro;
saver->string = rl_executing_macro;
macro_list = saver;
}
@ -145,20 +133,21 @@ _rl_pop_executing_macro ()
{
struct saved_macro *macro;
if (_rl_executing_macro)
free (_rl_executing_macro);
_rl_executing_macro = (char *)NULL;
FREE (rl_executing_macro);
rl_executing_macro = (char *)NULL;
executing_macro_index = 0;
if (macro_list)
{
macro = macro_list;
_rl_executing_macro = (char*) macro_list->string;
rl_executing_macro = macro_list->string;
executing_macro_index = macro_list->sindex;
macro_list = macro_list->next;
free (macro);
}
if (rl_executing_macro == 0)
RL_UNSETSTATE(RL_STATE_MACROINPUT);
}
/* Add a character to the macro being built. */
@ -169,9 +158,9 @@ _rl_add_macro_char (c)
if (current_macro_index + 1 >= current_macro_size)
{
if (current_macro == 0)
current_macro = xmalloc (current_macro_size = 25);
current_macro = (char *)xmalloc (current_macro_size = 25);
else
current_macro = xrealloc (current_macro, current_macro_size += 25);
current_macro = (char *)xrealloc (current_macro, current_macro_size += 25);
}
current_macro[current_macro_index++] = c;
@ -188,14 +177,11 @@ _rl_kill_kbd_macro ()
}
current_macro_size = current_macro_index = 0;
if (_rl_executing_macro)
{
free (_rl_executing_macro);
_rl_executing_macro = (char *) NULL;
}
FREE (rl_executing_macro);
rl_executing_macro = (char *) NULL;
executing_macro_index = 0;
_rl_defining_kbd_macro = 0;
RL_UNSETSTATE(RL_STATE_MACRODEF);
}
/* Begin defining a keyboard macro.
@ -205,10 +191,10 @@ _rl_kill_kbd_macro ()
definition to the end of the existing macro, and start by
re-executing the existing macro. */
int
rl_start_kbd_macro (int count __attribute__((unused)),
int key __attribute__((unused)))
rl_start_kbd_macro (ignore1, ignore2)
int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
{
if (_rl_defining_kbd_macro)
if (RL_ISSTATE (RL_STATE_MACRODEF))
{
_rl_abort_internal ();
return -1;
@ -222,7 +208,7 @@ rl_start_kbd_macro (int count __attribute__((unused)),
else
current_macro_index = 0;
_rl_defining_kbd_macro = 1;
RL_SETSTATE(RL_STATE_MACRODEF);
return 0;
}
@ -230,9 +216,10 @@ rl_start_kbd_macro (int count __attribute__((unused)),
A numeric argument says to execute the macro right now,
that many times, counting the definition as the first time. */
int
rl_end_kbd_macro (int count, int ignore __attribute__((unused)))
rl_end_kbd_macro (count, ignore)
int count, ignore __attribute__((unused));
{
if (_rl_defining_kbd_macro == 0)
if (RL_ISSTATE (RL_STATE_MACRODEF) == 0)
{
_rl_abort_internal ();
return -1;
@ -241,7 +228,7 @@ rl_end_kbd_macro (int count, int ignore __attribute__((unused)))
current_macro_index -= rl_key_sequence_length - 1;
current_macro[current_macro_index] = '\0';
_rl_defining_kbd_macro = 0;
RL_UNSETSTATE(RL_STATE_MACRODEF);
return (rl_call_last_kbd_macro (--count, 0));
}
@ -249,14 +236,15 @@ rl_end_kbd_macro (int count, int ignore __attribute__((unused)))
/* Execute the most recently defined keyboard macro.
COUNT says how many times to execute it. */
int
rl_call_last_kbd_macro (int count, int key __attribute__((unused)))
rl_call_last_kbd_macro (count, ignore)
int count, ignore __attribute__((unused));
{
if (current_macro == 0)
_rl_abort_internal ();
if (_rl_defining_kbd_macro)
if (RL_ISSTATE (RL_STATE_MACRODEF))
{
ding (); /* no recursive macros */
rl_ding (); /* no recursive macros */
current_macro[--current_macro_index] = '\0'; /* erase this char */
return 0;
}

337
readline/mbutil.c Normal file
View File

@ -0,0 +1,337 @@
/* mbutil.c -- readline multibyte character utility functions */
/* Copyright (C) 2001 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline 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 GNU Readline 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. */
#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"
/* Declared here so it can be shared between the readline and history
libraries. */
#if defined (HANDLE_MULTIBYTE)
int rl_byte_oriented = 0;
#else
int rl_byte_oriented = 1;
#endif
/* **************************************************************** */
/* */
/* Multibyte Character Utility Functions */
/* */
/* **************************************************************** */
#if defined(HANDLE_MULTIBYTE)
static int
_rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
char *string;
int seed, count, find_non_zero;
{
size_t tmp = 0;
mbstate_t ps;
int point = 0;
wchar_t wc;
memset(&ps, 0, sizeof (mbstate_t));
if (seed < 0)
seed = 0;
if (count <= 0)
return seed;
point = seed + _rl_adjust_point(string, seed, &ps);
/* if this is true, means that seed was not pointed character
started byte. So correct the point and consume count */
if (seed < point)
count --;
while (count > 0)
{
tmp = mbrtowc (&wc, string+point, strlen(string + point), &ps);
if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
{
/* invalid bytes. asume a byte represents a character */
point++;
count--;
/* reset states. */
memset(&ps, 0, sizeof(mbstate_t));
}
else if (tmp == (size_t)0)
/* found '\0' char */
break;
else
{
/* valid bytes */
point += tmp;
if (find_non_zero)
{
if (wcwidth (wc) == 0)
continue;
else
count--;
}
else
count--;
}
}
if (find_non_zero)
{
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
while (wcwidth (wc) == 0)
{
point += tmp;
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
if (tmp == (size_t)(0) || tmp == (size_t)(-1) || tmp == (size_t)(-2))
break;
}
}
return point;
}
static int
_rl_find_prev_mbchar_internal (string, seed, find_non_zero)
char *string;
int seed, find_non_zero;
{
mbstate_t ps;
int prev, non_zero_prev, point, length;
size_t tmp;
wchar_t wc;
memset(&ps, 0, sizeof(mbstate_t));
length = strlen(string);
if (seed < 0)
return 0;
else if (length < seed)
return length;
prev = non_zero_prev = point = 0;
while (point < seed)
{
tmp = mbrtowc (&wc, string + point, length - point, &ps);
if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
{
/* in this case, bytes are invalid or shorted to compose
multibyte char, so assume that the first byte represents
a single character anyway. */
tmp = 1;
/* clear the state of the byte sequence, because
in this case effect of mbstate is undefined */
memset(&ps, 0, sizeof (mbstate_t));
}
else if (tmp == 0)
break; /* Found '\0' char. Can this happen? */
else
{
if (find_non_zero)
{
if (wcwidth (wc) != 0)
prev = point;
}
else
prev = point;
}
point += tmp;
}
return prev;
}
/* return the number of bytes parsed from the multibyte sequence starting
at src, if a non-L'\0' wide character was recognized. It returns 0,
if a L'\0' wide character was recognized. It returns (size_t)(-1),
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 (src, ps)
const char *src;
mbstate_t *ps;
{
size_t tmp;
tmp = mbrlen((const char *)src, (size_t)strlen (src), ps);
if (tmp == (size_t)(-2))
{
/* shorted to compose multibyte char */
memset (ps, 0, sizeof(mbstate_t));
return -2;
}
else if (tmp == (size_t)(-1))
{
/* invalid to compose multibyte char */
/* initialize the conversion state */
memset (ps, 0, sizeof(mbstate_t));
return -1;
}
else if (tmp == (size_t)0)
return 0;
else
return (int)tmp;
}
/* compare the specified two characters. If the characters matched,
return 1. Otherwise return 0. */
int
_rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2)
char *buf1, *buf2;
mbstate_t *ps1, *ps2;
int pos1, pos2;
{
int i, w1, w2;
if ((w1 = _rl_get_char_len (&buf1[pos1], ps1)) <= 0 ||
(w2 = _rl_get_char_len (&buf2[pos2], ps2)) <= 0 ||
(w1 != w2) ||
(buf1[pos1] != buf2[pos2]))
return 0;
for (i = 1; i < w1; i++)
if (buf1[pos1+i] != buf2[pos2+i])
return 0;
return 1;
}
/* adjust pointed byte and find mbstate of the point of string.
adjusted point will be point <= adjusted_point, and returns
differences of the byte(adjusted_point - point).
if point is invalied (point < 0 || more than string length),
it returns -1 */
int
_rl_adjust_point(string, point, ps)
const char *string;
int point;
mbstate_t *ps;
{
size_t tmp = 0;
int length;
int pos = 0;
length = strlen(string);
if (point < 0)
return -1;
if (length < point)
return -1;
while (pos < point)
{
tmp = mbrlen (string + pos, length - pos, ps);
if((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
{
/* in this case, bytes are invalid or shorted to compose
multibyte char, so assume that the first byte represents
a single character anyway. */
pos++;
/* clear the state of the byte sequence, because
in this case effect of mbstate is undefined */
memset (ps, 0, sizeof (mbstate_t));
}
else
pos += tmp;
}
return (pos - point);
}
int
_rl_is_mbchar_matched (string, seed, end, mbchar, length)
char *string;
int seed, end;
char *mbchar;
int length;
{
int i;
if ((end - seed) < length)
return 0;
for (i = 0; i < length; i++)
if (string[seed + i] != mbchar[i])
return 0;
return 1;
}
#endif /* HANDLE_MULTIBYTE */
/* Find next `count' characters started byte point of the specified seed.
If flags is MB_FIND_NONZERO, we look for non-zero-width multibyte
characters. */
#undef _rl_find_next_mbchar
int
_rl_find_next_mbchar (string, seed, count, flags)
char *string __attribute__((unused));
int seed, count, flags __attribute__((unused));
{
#if defined (HANDLE_MULTIBYTE)
return _rl_find_next_mbchar_internal (string, seed, count, flags);
#else
return (seed + count);
#endif
}
/* Find previous character started byte point of the specified seed.
Returned point will be point <= seed. If flags is MB_FIND_NONZERO,
we look for non-zero-width multibyte characters. */
#undef _rl_find_prev_mbchar
int
_rl_find_prev_mbchar (string, seed, flags)
char *string __attribute__((unused));
int seed, flags __attribute__((unused));
{
#if defined (HANDLE_MULTIBYTE)
return _rl_find_prev_mbchar_internal (string, seed, flags);
#else
return ((seed == 0) ? seed : seed - 1);
#endif
}

496
readline/misc.c Normal file
View File

@ -0,0 +1,496 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline 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 GNU Readline 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. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_LOCALE_H)
# include <locale.h>
#endif
#include <stdio.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
#include "rlshell.h"
#include "xmalloc.h"
static int rl_digit_loop PARAMS((void));
static void _rl_history_set_point PARAMS((void));
/* Forward declarations used in this file */
void _rl_free_history_entry PARAMS((HIST_ENTRY *));
/* If non-zero, rl_get_previous_history and rl_get_next_history attempt
to preserve the value of rl_point from line to line. */
int _rl_history_preserve_point = 0;
/* Saved target point for when _rl_history_preserve_point is set. Special
value of -1 means that point is at the end of the line. */
int _rl_history_saved_point = -1;
/* **************************************************************** */
/* */
/* Numeric Arguments */
/* */
/* **************************************************************** */
/* Handle C-u style numeric args, as well as M--, and M-digits. */
static int
rl_digit_loop ()
{
int key, c, sawminus, sawdigits;
rl_save_prompt ();
RL_SETSTATE(RL_STATE_NUMERICARG);
sawminus = sawdigits = 0;
while (1)
{
if (rl_numeric_arg > 1000000)
{
sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
rl_ding ();
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return 1;
}
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
RL_SETSTATE(RL_STATE_MOREINPUT);
key = c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (c < 0)
{
_rl_abort_internal ();
return -1;
}
/* If we see a key bound to `universal-argument' after seeing digits,
it ends the argument but is otherwise ignored. */
if (_rl_keymap[c].type == ISFUNC &&
_rl_keymap[c].function == rl_universal_argument)
{
if (sawdigits == 0)
{
rl_numeric_arg *= 4;
continue;
}
else
{
RL_SETSTATE(RL_STATE_MOREINPUT);
key = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (_rl_dispatch (key, _rl_keymap));
}
}
c = UNMETA (c);
if (_rl_digit_p (c))
{
rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + c - '0' : c - '0';
sawdigits = rl_explicit_arg = 1;
}
else if (c == '-' && rl_explicit_arg == 0)
{
rl_numeric_arg = sawminus = 1;
rl_arg_sign = -1;
}
else
{
/* Make M-- command equivalent to M--1 command. */
if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0)
rl_explicit_arg = 1;
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (_rl_dispatch (key, _rl_keymap));
}
}
/*NOTREACHED*/
}
/* Add the current digit to the argument in progress. */
int
rl_digit_argument (ignore, key)
int ignore __attribute__((unused)), key;
{
rl_execute_next (key);
return (rl_digit_loop ());
}
/* What to do when you abort reading an argument. */
int
rl_discard_argument ()
{
rl_ding ();
rl_clear_message ();
_rl_init_argument ();
return 0;
}
/* Create a default argument. */
int
_rl_init_argument ()
{
rl_numeric_arg = rl_arg_sign = 1;
rl_explicit_arg = 0;
return 0;
}
/* C-u, universal argument. Multiply the current argument by 4.
Read a key. If the key has nothing to do with arguments, then
dispatch on it. If the key is the abort character then abort. */
int
rl_universal_argument (count, key)
int count __attribute__((unused)), key __attribute__((unused));
{
rl_numeric_arg *= 4;
return (rl_digit_loop ());
}
/* **************************************************************** */
/* */
/* History Utilities */
/* */
/* **************************************************************** */
/* We already have a history library, and that is what we use to control
the history features of readline. This is our local interface to
the history mechanism. */
/* While we are editing the history, this is the saved
version of the original line. */
HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
/* Set the history pointer back to the last entry in the history. */
void
_rl_start_using_history ()
{
using_history ();
if (_rl_saved_line_for_history)
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Free the contents (and containing structure) of a HIST_ENTRY. */
void
_rl_free_history_entry (entry)
HIST_ENTRY *entry;
{
if (entry == 0)
return;
if (entry->line)
free (entry->line);
free (entry);
}
/* Perhaps put back the current line if it has changed. */
int
rl_maybe_replace_line ()
{
HIST_ENTRY *temp;
temp = current_history ();
/* If the current line has changed, save the changes. */
if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
{
temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
free (temp->line);
free (temp);
}
return 0;
}
/* Restore the _rl_saved_line_for_history if there is one. */
int
rl_maybe_unsave_line ()
{
if (_rl_saved_line_for_history)
{
rl_replace_line (_rl_saved_line_for_history->line, 0);
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
rl_point = rl_end; /* rl_replace_line sets rl_end */
}
else
rl_ding ();
return 0;
}
/* Save the current line in _rl_saved_line_for_history. */
int
rl_maybe_save_line ()
{
if (_rl_saved_line_for_history == 0)
{
_rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
_rl_saved_line_for_history->line = savestring (rl_line_buffer);
_rl_saved_line_for_history->data = (char *)rl_undo_list;
}
return 0;
}
int
_rl_free_saved_history_line ()
{
if (_rl_saved_line_for_history)
{
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
return 0;
}
static void
_rl_history_set_point ()
{
rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1)
? _rl_history_saved_point
: rl_end;
if (rl_point > rl_end)
rl_point = rl_end;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_point = 0;
#endif /* VI_MODE */
if (rl_editing_mode == emacs_mode)
rl_mark = (rl_point == rl_end ? 0 : rl_end);
}
void
rl_replace_from_history (entry, flags)
HIST_ENTRY *entry;
int flags __attribute__((unused)); /* currently unused */
{
rl_replace_line (entry->line, 0);
rl_undo_list = (UNDO_LIST *)entry->data;
rl_point = rl_end;
rl_mark = 0;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
{
rl_point = 0;
rl_mark = rl_end;
}
#endif
}
/* **************************************************************** */
/* */
/* History Commands */
/* */
/* **************************************************************** */
/* Meta-< goes to the start of the history. */
int
rl_beginning_of_history (count, key)
int count __attribute__((unused)), key;
{
return (rl_get_previous_history (1 + where_history (), key));
}
/* Meta-> goes to the end of the history. (The current line). */
int
rl_end_of_history (count, key)
int count __attribute__((unused)), key __attribute__((unused));
{
rl_maybe_replace_line ();
using_history ();
rl_maybe_unsave_line ();
return 0;
}
/* Move down to the next history line. */
int
rl_get_next_history (count, key)
int count, key;
{
HIST_ENTRY *temp;
if (count < 0)
return (rl_get_previous_history (-count, key));
if (count == 0)
return 0;
rl_maybe_replace_line ();
/* either not saved by rl_newline or at end of line, so set appropriately. */
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
temp = (HIST_ENTRY *)NULL;
while (count)
{
temp = next_history ();
if (!temp)
break;
--count;
}
if (temp == 0)
rl_maybe_unsave_line ();
else
{
rl_replace_from_history (temp, 0);
_rl_history_set_point ();
}
return 0;
}
/* Get the previous item out of our interactive history, making it the current
line. If there is no previous history, just ding. */
int
rl_get_previous_history (count, key)
int count, key;
{
HIST_ENTRY *old_temp, *temp;
if (count < 0)
return (rl_get_next_history (-count, key));
if (count == 0)
return 0;
/* either not saved by rl_newline or at end of line, so set appropriately. */
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
/* If we don't have a line saved, then save this one. */
rl_maybe_save_line ();
/* If the current line has changed, save the changes. */
rl_maybe_replace_line ();
temp = old_temp = (HIST_ENTRY *)NULL;
while (count)
{
temp = previous_history ();
if (temp == 0)
break;
old_temp = temp;
--count;
}
/* If there was a large argument, and we moved back to the start of the
history, that is not an error. So use the last value found. */
if (!temp && old_temp)
temp = old_temp;
if (temp == 0)
rl_ding ();
else
{
rl_replace_from_history (temp, 0);
_rl_history_set_point ();
}
return 0;
}
/* **************************************************************** */
/* */
/* Editing Modes */
/* */
/* **************************************************************** */
/* How to toggle back and forth between editing modes. */
int
rl_vi_editing_mode (count, key)
int count __attribute__((unused)), key;
{
#if defined (VI_MODE)
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
rl_editing_mode = vi_mode;
rl_vi_insertion_mode (1, key);
#endif /* VI_MODE */
return 0;
}
int
rl_emacs_editing_mode (count, key)
int count __attribute__((unused)), key __attribute__((unused));
{
rl_editing_mode = emacs_mode;
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
_rl_keymap = emacs_standard_keymap;
return 0;
}
/* Function for the rest of the library to use to set insert/overwrite mode. */
void
_rl_set_insert_mode (im, force)
int im, force __attribute__((unused));
{
#ifdef CURSOR_MODE
_rl_set_cursor (im, force);
#endif
rl_insert_mode = im;
}
/* Toggle overwrite mode. A positive explicit argument selects overwrite
mode. A negative or zero explicit argument selects insert mode. */
int
rl_overwrite_mode (count, key)
int count, key __attribute__((unused));
{
if (rl_explicit_arg == 0)
_rl_set_insert_mode (rl_insert_mode ^ 1, 0);
else if (count > 0)
_rl_set_insert_mode (RL_IM_OVERWRITE, 0);
else
_rl_set_insert_mode (RL_IM_INSERT, 0);
return 0;
}

View File

@ -7,7 +7,7 @@
The GNU Readline 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 1, or
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@ -18,7 +18,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@ -27,6 +27,8 @@
#include <sys/types.h>
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
@ -44,13 +46,9 @@
#include <ctype.h>
#include "rldefs.h"
extern int _rl_convert_meta_chars_to_ascii;
extern int _rl_output_meta_chars;
extern int _rl_meta_flag;
/* Functions imported from shell.c */
extern char *get_env_value ();
#include "readline.h"
#include "rlshell.h"
#include "rlprivate.h"
#if !defined (HAVE_SETLOCALE)
/* A list of legal values for the LANG or LC_CTYPE environment variables.
@ -70,12 +68,11 @@ static char *legal_lang_values[] =
"iso88599",
"iso885910",
"koi8r",
"koi8-r",
0
};
static char *normalize_codeset ();
static char *find_codeset ();
static char *normalize_codeset PARAMS((char *));
static char *find_codeset PARAMS((char *, size_t *));
#endif /* !HAVE_SETLOCALE */
/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value
@ -108,9 +105,9 @@ _rl_init_eightbit ()
/* We don't have setlocale. Finesse it. Check the environment for the
appropriate variables and set eight-bit mode if they have the right
values. */
lspec = get_env_value ("LC_ALL");
if (lspec == 0) lspec = get_env_value ("LC_CTYPE");
if (lspec == 0) lspec = get_env_value ("LANG");
lspec = sh_get_env_value ("LC_ALL");
if (lspec == 0) lspec = sh_get_env_value ("LC_CTYPE");
if (lspec == 0) lspec = sh_get_env_value ("LANG");
if (lspec == 0 || (t = normalize_codeset (lspec)) == 0)
return (0);
for (i = 0; t && legal_lang_values[i]; i++)
@ -144,10 +141,10 @@ normalize_codeset (codeset)
all_digits = 1;
for (len = 0, i = 0; i < namelen; i++)
{
if (isalnum (codeset[i]))
if (ISALNUM ((unsigned char)codeset[i]))
{
len++;
all_digits &= isdigit (codeset[i]);
all_digits &= _rl_digit_p (codeset[i]);
}
}
@ -165,9 +162,9 @@ normalize_codeset (codeset)
}
for (i = 0; i < namelen; i++)
if (isalpha (codeset[i]))
*wp++ = (isupper (codeset[i])) ? tolower (codeset[i]) : codeset[i];
else if (isdigit (codeset[i]))
if (ISALPHA ((unsigned char)codeset[i]))
*wp++ = _rl_to_lower (codeset[i]);
else if (_rl_digit_p (codeset[i]))
*wp++ = codeset[i];
*wp = '\0';

View File

@ -7,7 +7,7 @@
The GNU Readline 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 1, or
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@ -18,23 +18,11 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#include "rlconf.h"
#if !defined (PAREN_MATCHING)
extern int rl_insert ();
int
rl_insert_close (count, invoking_key)
int count, invoking_key;
{
return (rl_insert (count, invoking_key));
}
#else /* PAREN_MATCHING */
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
@ -42,6 +30,10 @@ rl_insert_close (count, invoking_key)
#include <stdio.h>
#include <sys/types.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined (FD_SET) && !defined (HAVE_SELECT)
# define HAVE_SELECT
#endif
@ -64,8 +56,9 @@ extern char *strchr (), *strrchr ();
#endif /* !strchr && !__STDC__ */
#include "readline.h"
#include "rlprivate.h"
extern int rl_explicit_arg;
static int find_matching_open PARAMS((char *, int, int));
/* Non-zero means try to blink the matching open parenthesis when the
close parenthesis is inserted. */
@ -75,14 +68,46 @@ int rl_blink_matching_paren = 1;
int rl_blink_matching_paren = 0;
#endif /* !HAVE_SELECT */
static int find_matching_open ();
static int _paren_blink_usec = 500000;
/* Change emacs_standard_keymap to have bindings for paren matching when
ON_OR_OFF is 1, change them back to self_insert when ON_OR_OFF == 0. */
void
_rl_enable_paren_matching (on_or_off)
int on_or_off;
{
if (on_or_off)
{ /* ([{ */
rl_bind_key_in_map (')', rl_insert_close, emacs_standard_keymap);
rl_bind_key_in_map (']', rl_insert_close, emacs_standard_keymap);
rl_bind_key_in_map ('}', rl_insert_close, emacs_standard_keymap);
}
else
{ /* ([{ */
rl_bind_key_in_map (')', rl_insert, emacs_standard_keymap);
rl_bind_key_in_map (']', rl_insert, emacs_standard_keymap);
rl_bind_key_in_map ('}', rl_insert, emacs_standard_keymap);
}
}
int
rl_set_paren_blink_timeout (u)
int u;
{
int o;
o = _paren_blink_usec;
if (u > 0)
_paren_blink_usec = u;
return (o);
}
int
rl_insert_close (count, invoking_key)
int count, invoking_key;
{
if (rl_explicit_arg || !rl_blink_matching_paren)
rl_insert (count, invoking_key);
_rl_insert_char (count, invoking_key);
else
{
#if defined (HAVE_SELECT)
@ -90,7 +115,7 @@ rl_insert_close (count, invoking_key)
struct timeval timer;
fd_set readfds;
rl_insert (1, invoking_key);
_rl_insert_char (1, invoking_key);
(*rl_redisplay_function) ();
match_point =
find_matching_open (rl_line_buffer, rl_point - 2, invoking_key);
@ -102,7 +127,7 @@ rl_insert_close (count, invoking_key)
FD_ZERO (&readfds);
FD_SET (fileno (rl_instream), &readfds);
timer.tv_sec = 0;
timer.tv_usec = 500000;
timer.tv_usec = _paren_blink_usec;
orig_point = rl_point;
rl_point = match_point;
@ -110,7 +135,7 @@ rl_insert_close (count, invoking_key)
ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer);
rl_point = orig_point;
#else /* !HAVE_SELECT */
rl_insert (count, invoking_key);
_rl_insert_char (count, invoking_key);
#endif /* !HAVE_SELECT */
}
return 0;
@ -152,5 +177,3 @@ find_matching_open (string, from, closer)
}
return (i);
}
#endif /* PAREN_MATCHING */

View File

@ -6,7 +6,7 @@
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 1, or (at your option)
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
@ -16,7 +16,7 @@
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
@ -46,4 +46,12 @@
# define d_fileno d_ino
#endif
#if defined (_POSIX_SOURCE) && (!defined (STRUCT_DIRENT_HAS_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_ */

View File

@ -1,5 +1,23 @@
/* 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_

View File

@ -7,7 +7,7 @@
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 1, or (at your option)
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
@ -17,7 +17,7 @@
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
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. */

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
The GNU Readline 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 1, or
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@ -18,7 +18,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_READLINE_H_)
#define _READLINE_H_
@ -29,14 +29,21 @@ extern "C" {
#if defined (READLINE_LIBRARY)
# include "rlstdc.h"
# include "rltypedefs.h"
# include "keymaps.h"
# include "tilde.h"
#else
# include <readline/rlstdc.h>
# include <readline/rltypedefs.h>
# include <readline/keymaps.h>
# include <readline/tilde.h>
#endif
/* Hex-encoded Readline version number. */
#define RL_READLINE_VERSION 0x0403 /* Readline 4.3 */
#define RL_VERSION_MAJOR 4
#define RL_VERSION_MINOR 3
/* Readline data structures. */
/* Maintaining the state of undo. We remember individual deletes and inserts
@ -61,7 +68,7 @@ extern UNDO_LIST *rl_undo_list;
/* The data structure for mapping textual names to code addresses. */
typedef struct _funmap {
const char *name;
Function *function;
rl_command_func_t *function;
} FUNMAP;
extern FUNMAP **funmap;
@ -73,184 +80,191 @@ extern FUNMAP **funmap;
/* **************************************************************** */
/* Bindable commands for numeric arguments. */
extern int rl_digit_argument __P((int, int));
extern int rl_universal_argument __P((int, int));
extern int rl_digit_argument PARAMS((int, int));
extern int rl_universal_argument PARAMS((int, int));
/* Bindable commands for moving the cursor. */
extern int rl_forward __P((int, int));
extern int rl_backward __P((int, int));
extern int rl_beg_of_line __P((int, int));
extern int rl_end_of_line __P((int, int));
extern int rl_forward_word __P((int, int));
extern int rl_backward_word __P((int, int));
extern int rl_refresh_line __P((int, int));
extern int rl_clear_screen __P((int, int));
extern int rl_arrow_keys __P((int, int));
extern int rl_forward_byte PARAMS((int, int));
extern int rl_forward_char PARAMS((int, int));
extern int rl_forward PARAMS((int, int));
extern int rl_backward_byte PARAMS((int, int));
extern int rl_backward_char PARAMS((int, int));
extern int rl_backward PARAMS((int, int));
extern int rl_beg_of_line PARAMS((int, int));
extern int rl_end_of_line PARAMS((int, int));
extern int rl_forward_word PARAMS((int, int));
extern int rl_backward_word PARAMS((int, int));
extern int rl_refresh_line PARAMS((int, int));
extern int rl_clear_screen PARAMS((int, int));
extern int rl_arrow_keys PARAMS((int, int));
/* Bindable commands for inserting and deleting text. */
extern int rl_insert __P((int, int));
extern int rl_quoted_insert __P((int, int));
extern int rl_tab_insert __P((int, int));
extern int rl_newline __P((int, int));
extern int rl_do_lowercase_version __P((int, int));
extern int rl_rubout __P((int, int));
extern int rl_delete __P((int, int));
extern int rl_rubout_or_delete __P((int, int));
extern int rl_delete_horizontal_space __P((int, int));
extern int rl_delete_or_show_completions __P((int, int));
extern int rl_insert_comment __P((int, int));
extern int rl_insert PARAMS((int, int));
extern int rl_quoted_insert PARAMS((int, int));
extern int rl_tab_insert PARAMS((int, int));
extern int rl_newline PARAMS((int, int));
extern int rl_do_lowercase_version PARAMS((int, int));
extern int rl_rubout PARAMS((int, int));
extern int rl_delete PARAMS((int, int));
extern int rl_rubout_or_delete PARAMS((int, int));
extern int rl_delete_horizontal_space PARAMS((int, int));
extern int rl_delete_or_show_completions PARAMS((int, int));
extern int rl_insert_comment PARAMS((int, int));
/* Bindable commands for changing case. */
extern int rl_upcase_word __P((int, int));
extern int rl_downcase_word __P((int, int));
extern int rl_capitalize_word __P((int, int));
extern int rl_upcase_word PARAMS((int, int));
extern int rl_downcase_word PARAMS((int, int));
extern int rl_capitalize_word PARAMS((int, int));
/* Bindable commands for transposing characters and words. */
extern int rl_transpose_words __P((int, int));
extern int rl_transpose_chars __P((int, int));
extern int rl_transpose_words PARAMS((int, int));
extern int rl_transpose_chars PARAMS((int, int));
/* Bindable commands for searching within a line. */
extern int rl_char_search __P((int, int));
extern int rl_backward_char_search __P((int, int));
extern int rl_char_search PARAMS((int, int));
extern int rl_backward_char_search PARAMS((int, int));
/* Bindable commands for readline's interface to the command history. */
extern int rl_beginning_of_history __P((int, int));
extern int rl_end_of_history __P((int, int));
extern int rl_get_next_history __P((int, int));
extern int rl_get_previous_history __P((int, int));
extern int rl_beginning_of_history PARAMS((int, int));
extern int rl_end_of_history PARAMS((int, int));
extern int rl_get_next_history PARAMS((int, int));
extern int rl_get_previous_history PARAMS((int, int));
/* Bindable commands for managing the mark and region. */
extern int rl_set_mark __P((int, int));
extern int rl_exchange_point_and_mark __P((int, int));
extern int rl_set_mark PARAMS((int, int));
extern int rl_exchange_point_and_mark PARAMS((int, int));
/* Bindable commands to set the editing mode (emacs or vi). */
extern int rl_vi_editing_mode __P((int, int));
extern int rl_emacs_editing_mode __P((int, int));
extern int rl_vi_editing_mode PARAMS((int, int));
extern int rl_emacs_editing_mode PARAMS((int, int));
/* Bindable commands to change the insert mode (insert or overwrite) */
extern int rl_overwrite_mode PARAMS((int, int));
/* Bindable commands for managing key bindings. */
extern int rl_re_read_init_file __P((int, int));
extern int rl_dump_functions __P((int, int));
extern int rl_dump_macros __P((int, int));
extern int rl_dump_variables __P((int, int));
extern int rl_re_read_init_file PARAMS((int, int));
extern int rl_dump_functions PARAMS((int, int));
extern int rl_dump_macros PARAMS((int, int));
extern int rl_dump_variables PARAMS((int, int));
/* Bindable commands for word completion. */
extern int rl_complete __P((int, int));
extern int rl_possible_completions __P((int, int));
extern int rl_insert_completions __P((int, int));
extern int rl_menu_complete __P((int, int));
extern int rl_complete PARAMS((int, int));
extern int rl_possible_completions PARAMS((int, int));
extern int rl_insert_completions PARAMS((int, int));
extern int rl_menu_complete PARAMS((int, int));
/* Bindable commands for killing and yanking text, and managing the kill ring. */
extern int rl_kill_word __P((int, int));
extern int rl_backward_kill_word __P((int, int));
extern int rl_kill_line __P((int, int));
extern int rl_backward_kill_line __P((int, int));
extern int rl_kill_full_line __P((int, int));
extern int rl_unix_word_rubout __P((int, int));
extern int rl_unix_line_discard __P((int, int));
extern int rl_copy_region_to_kill __P((int, int));
extern int rl_kill_region __P((int, int));
extern int rl_copy_forward_word __P((int, int));
extern int rl_copy_backward_word __P((int, int));
extern int rl_yank __P((int, int));
extern int rl_yank_pop __P((int, int));
extern int rl_yank_nth_arg __P((int, int));
extern int rl_yank_last_arg __P((int, int));
/* Not available unless __CYGWIN32__ is defined. */
#ifdef __CYGWIN32__
extern int rl_paste_from_clipboard __P((int, int));
extern int rl_kill_word PARAMS((int, int));
extern int rl_backward_kill_word PARAMS((int, int));
extern int rl_kill_line PARAMS((int, int));
extern int rl_backward_kill_line PARAMS((int, int));
extern int rl_kill_full_line PARAMS((int, int));
extern int rl_unix_word_rubout PARAMS((int, int));
extern int rl_unix_line_discard PARAMS((int, int));
extern int rl_copy_region_to_kill PARAMS((int, int));
extern int rl_kill_region PARAMS((int, int));
extern int rl_copy_forward_word PARAMS((int, int));
extern int rl_copy_backward_word PARAMS((int, int));
extern int rl_yank PARAMS((int, int));
extern int rl_yank_pop PARAMS((int, int));
extern int rl_yank_nth_arg PARAMS((int, int));
extern int rl_yank_last_arg PARAMS((int, int));
/* Not available unless __CYGWIN__ is defined. */
#ifdef __CYGWIN__
extern int rl_paste_from_clipboard PARAMS((int, int));
#endif
/* Bindable commands for incremental searching. */
extern int rl_reverse_search_history __P((int, int));
extern int rl_forward_search_history __P((int, int));
extern int rl_reverse_search_history PARAMS((int, int));
extern int rl_forward_search_history PARAMS((int, int));
/* Bindable keyboard macro commands. */
extern int rl_start_kbd_macro __P((int, int));
extern int rl_end_kbd_macro __P((int, int));
extern int rl_call_last_kbd_macro __P((int, int));
extern int rl_start_kbd_macro PARAMS((int, int));
extern int rl_end_kbd_macro PARAMS((int, int));
extern int rl_call_last_kbd_macro PARAMS((int, int));
/* Bindable undo commands. */
extern int rl_revert_line __P((int, int));
extern int rl_undo_command __P((int, int));
extern int rl_revert_line PARAMS((int, int));
extern int rl_undo_command PARAMS((int, int));
/* Bindable tilde expansion commands. */
extern int rl_tilde_expand __P((int, int));
extern int rl_tilde_expand PARAMS((int, int));
/* Bindable terminal control commands. */
extern int rl_restart_output __P((int, int));
extern int rl_stop_output __P((int, int));
extern int rl_restart_output PARAMS((int, int));
extern int rl_stop_output PARAMS((int, int));
/* Miscellaneous bindable commands. */
extern int rl_abort __P((int, int));
extern int rl_tty_status __P((int, int));
extern int rl_abort PARAMS((int, int));
extern int rl_tty_status PARAMS((int, int));
/* Bindable commands for incremental and non-incremental history searching. */
extern int rl_history_search_forward __P((int, int));
extern int rl_history_search_backward __P((int, int));
extern int rl_noninc_forward_search __P((int, int));
extern int rl_noninc_reverse_search __P((int, int));
extern int rl_noninc_forward_search_again __P((int, int));
extern int rl_noninc_reverse_search_again __P((int, int));
extern int rl_history_search_forward PARAMS((int, int));
extern int rl_history_search_backward PARAMS((int, int));
extern int rl_noninc_forward_search PARAMS((int, int));
extern int rl_noninc_reverse_search PARAMS((int, int));
extern int rl_noninc_forward_search_again PARAMS((int, int));
extern int rl_noninc_reverse_search_again PARAMS((int, int));
/* Not available unless readline is compiled -DPAREN_MATCHING. */
extern int rl_insert_close __P((int, int));
/* Bindable command used when inserting a matching close character. */
extern int rl_insert_close PARAMS((int, int));
/* Not available unless READLINE_CALLBACKS is defined. */
extern void rl_callback_handler_install __P((char *, VFunction *));
extern void rl_callback_read_char __P((void));
extern void rl_callback_handler_remove __P((void));
extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
extern void rl_callback_read_char PARAMS((void));
extern void rl_callback_handler_remove PARAMS((void));
/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
/* VI-mode bindable commands. */
extern int rl_vi_redo __P((int, int));
extern int rl_vi_undo __P((int, int));
extern int rl_vi_yank_arg __P((int, int));
extern int rl_vi_fetch_history __P((int, int));
extern int rl_vi_search_again __P((int, int));
extern int rl_vi_search __P((int, int));
extern int rl_vi_complete __P((int, int));
extern int rl_vi_tilde_expand __P((int, int));
extern int rl_vi_prev_word __P((int, int));
extern int rl_vi_next_word __P((int, int));
extern int rl_vi_end_word __P((int, int));
extern int rl_vi_insert_beg __P((int, int));
extern int rl_vi_append_mode __P((int, int));
extern int rl_vi_append_eol __P((int, int));
extern int rl_vi_eof_maybe __P((int, int));
extern int rl_vi_insertion_mode __P((int, int));
extern int rl_vi_movement_mode __P((int, int));
extern int rl_vi_arg_digit __P((int, int));
extern int rl_vi_change_case __P((int, int));
extern int rl_vi_put __P((int, int));
extern int rl_vi_column __P((int, int));
extern int rl_vi_delete_to __P((int, int));
extern int rl_vi_change_to __P((int, int));
extern int rl_vi_yank_to __P((int, int));
extern int rl_vi_delete __P((int, int));
extern int rl_vi_back_to_indent __P((int, int));
extern int rl_vi_first_print __P((int, int));
extern int rl_vi_char_search __P((int, int));
extern int rl_vi_match __P((int, int));
extern int rl_vi_change_char __P((int, int));
extern int rl_vi_subst __P((int, int));
extern int rl_vi_overstrike __P((int, int));
extern int rl_vi_overstrike_delete __P((int, int));
extern int rl_vi_replace __P((int, int));
extern int rl_vi_set_mark __P((int, int));
extern int rl_vi_goto_mark __P((int, int));
extern int rl_vi_redo PARAMS((int, int));
extern int rl_vi_undo PARAMS((int, int));
extern int rl_vi_yank_arg PARAMS((int, int));
extern int rl_vi_fetch_history PARAMS((int, int));
extern int rl_vi_search_again PARAMS((int, int));
extern int rl_vi_search PARAMS((int, int));
extern int rl_vi_complete PARAMS((int, int));
extern int rl_vi_tilde_expand PARAMS((int, int));
extern int rl_vi_prev_word PARAMS((int, int));
extern int rl_vi_next_word PARAMS((int, int));
extern int rl_vi_end_word PARAMS((int, int));
extern int rl_vi_insert_beg PARAMS((int, int));
extern int rl_vi_append_mode PARAMS((int, int));
extern int rl_vi_append_eol PARAMS((int, int));
extern int rl_vi_eof_maybe PARAMS((int, int));
extern int rl_vi_insertion_mode PARAMS((int, int));
extern int rl_vi_movement_mode PARAMS((int, int));
extern int rl_vi_arg_digit PARAMS((int, int));
extern int rl_vi_change_case PARAMS((int, int));
extern int rl_vi_put PARAMS((int, int));
extern int rl_vi_column PARAMS((int, int));
extern int rl_vi_delete_to PARAMS((int, int));
extern int rl_vi_change_to PARAMS((int, int));
extern int rl_vi_yank_to PARAMS((int, int));
extern int rl_vi_delete PARAMS((int, int));
extern int rl_vi_back_to_indent PARAMS((int, int));
extern int rl_vi_first_print PARAMS((int, int));
extern int rl_vi_char_search PARAMS((int, int));
extern int rl_vi_match PARAMS((int, int));
extern int rl_vi_change_char PARAMS((int, int));
extern int rl_vi_subst PARAMS((int, int));
extern int rl_vi_overstrike PARAMS((int, int));
extern int rl_vi_overstrike_delete PARAMS((int, int));
extern int rl_vi_replace PARAMS((int, int));
extern int rl_vi_set_mark PARAMS((int, int));
extern int rl_vi_goto_mark PARAMS((int, int));
/* VI-mode utility functions. */
extern int rl_vi_check __P((void));
extern int rl_vi_domove __P((int, int *));
extern int rl_vi_bracktype __P((int));
extern int rl_vi_check PARAMS((void));
extern int rl_vi_domove PARAMS((int, int *));
extern int rl_vi_bracktype PARAMS((int));
/* VI-mode pseudo-bindable commands, used as utility functions. */
extern int rl_vi_fWord __P((int, int));
extern int rl_vi_bWord __P((int, int));
extern int rl_vi_eWord __P((int, int));
extern int rl_vi_fword __P((int, int));
extern int rl_vi_bword __P((int, int));
extern int rl_vi_eword __P((int, int));
extern int rl_vi_fWord PARAMS((int, int));
extern int rl_vi_bWord PARAMS((int, int));
extern int rl_vi_eWord PARAMS((int, int));
extern int rl_vi_fword PARAMS((int, int));
extern int rl_vi_bword PARAMS((int, int));
extern int rl_vi_eword PARAMS((int, int));
/* **************************************************************** */
/* */
@ -260,141 +274,176 @@ extern int rl_vi_eword __P((int, int));
/* Readline functions. */
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
extern char *readline __P((char *));
extern char *readline PARAMS((const char *));
extern int rl_initialize __P((void));
extern int rl_set_prompt PARAMS((const char *));
extern int rl_expand_prompt PARAMS((char *));
extern int rl_discard_argument __P((void));
extern int rl_initialize PARAMS((void));
/* Undocumented; unused by readline */
extern int rl_discard_argument PARAMS((void));
/* Utility functions to bind keys to readline commands. */
extern int rl_add_defun __P((char *, Function *, int));
extern int rl_bind_key __P((int, Function *));
extern int rl_bind_key_in_map __P((int, Function *, Keymap));
extern int rl_unbind_key __P((int));
extern int rl_unbind_key_in_map __P((int, Keymap));
extern int rl_unbind_function_in_map __P((Function *, Keymap));
extern int rl_unbind_command_in_map __P((char *, Keymap));
extern int rl_set_key __P((char *, Function *, Keymap));
extern int rl_generic_bind __P((int, char *, char *, Keymap));
extern int rl_variable_bind __P((char *, char *));
extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
extern int rl_bind_key PARAMS((int, rl_command_func_t *));
extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
extern int rl_unbind_key PARAMS((int));
extern int rl_unbind_key_in_map PARAMS((int, Keymap));
extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
extern int rl_variable_bind PARAMS((const char *, const char *));
/* Backwards compatibility, use rl_generic_bind instead. */
extern int rl_macro_bind __P((char *, char *, Keymap));
extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
/* Undocumented in the texinfo manual; not really useful to programs. */
extern int rl_translate_keyseq __P((char *, char *, int *));
extern char *rl_untranslate_keyseq __P((int));
extern int rl_translate_keyseq PARAMS((const char *, char *, int *));
extern char *rl_untranslate_keyseq PARAMS((int));
extern Function *rl_named_function __P((char *));
extern Function *rl_function_of_keyseq __P((const char *, Keymap, int *));
extern rl_command_func_t *rl_named_function PARAMS((const char *));
extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
extern void rl_list_funmap_names __P((void));
extern char **rl_invoking_keyseqs_in_map __P((Function *, Keymap));
extern char **rl_invoking_keyseqs __P((Function *));
extern void rl_list_funmap_names PARAMS((void));
extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
extern void rl_function_dumper __P((int));
extern void rl_macro_dumper __P((int));
extern void rl_variable_dumper __P((int));
extern void rl_function_dumper PARAMS((int));
extern void rl_macro_dumper PARAMS((int));
extern void rl_variable_dumper PARAMS((int));
extern int rl_read_init_file __P((const char *));
extern int rl_parse_and_bind __P((char *));
extern int rl_read_init_file PARAMS((const char *));
extern int rl_parse_and_bind PARAMS((char *));
/* Functions for manipulating keymaps. */
extern Keymap rl_make_bare_keymap __P((void));
extern Keymap rl_copy_keymap __P((Keymap));
extern Keymap rl_make_keymap __P((void));
extern void rl_discard_keymap __P((Keymap));
extern Keymap rl_make_bare_keymap PARAMS((void));
extern Keymap rl_copy_keymap PARAMS((Keymap));
extern Keymap rl_make_keymap PARAMS((void));
extern void rl_discard_keymap PARAMS((Keymap));
extern Keymap rl_get_keymap_by_name __P((char *));
extern const char *rl_get_keymap_name __P((Keymap));
extern void rl_set_keymap __P((Keymap));
extern Keymap rl_get_keymap __P((void));
extern void rl_set_keymap_from_edit_mode __P((void));
extern const char *rl_get_keymap_name_from_edit_mode __P((void));
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
extern char *rl_get_keymap_name PARAMS((Keymap));
extern void rl_set_keymap PARAMS((Keymap));
extern Keymap rl_get_keymap PARAMS((void));
/* Undocumented; used internally only. */
extern void rl_set_keymap_from_edit_mode PARAMS((void));
extern const char *rl_get_keymap_name_from_edit_mode PARAMS((void));
/* Functions for manipulating the funmap, which maps command names to functions. */
extern int rl_add_funmap_entry __P((const char *, Function *));
extern void rl_initialize_funmap __P((void));
extern char **rl_funmap_names __P((void));
extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
extern const char **rl_funmap_names PARAMS((void));
/* Undocumented, only used internally -- there is only one funmap, and this
function may be called only once. */
extern void rl_initialize_funmap PARAMS((void));
/* Utility functions for managing keyboard macros. */
extern void rl_push_macro_input __P((char *));
extern void rl_push_macro_input PARAMS((char *));
/* Functions for undoing, from undo.c */
extern void rl_add_undo __P((enum undo_code, int, int, char *));
extern void free_undo_list __P((void));
extern int rl_do_undo __P((void));
extern int rl_begin_undo_group __P((void));
extern int rl_end_undo_group __P((void));
extern int rl_modifying __P((int, int));
extern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
extern void rl_free_undo_list PARAMS((void));
extern int rl_do_undo PARAMS((void));
extern int rl_begin_undo_group PARAMS((void));
extern int rl_end_undo_group PARAMS((void));
extern int rl_modifying PARAMS((int, int));
/* Functions for redisplay. */
extern void rl_redisplay __P((void));
extern int rl_on_new_line __P((void));
extern int rl_forced_update_display __P((void));
extern int rl_clear_message __P((void));
extern int rl_reset_line_state __P((void));
extern void rl_redisplay PARAMS((void));
extern int rl_on_new_line PARAMS((void));
extern int rl_on_new_line_with_prompt PARAMS((void));
extern int rl_forced_update_display PARAMS((void));
extern int rl_clear_message PARAMS((void));
extern int rl_reset_line_state PARAMS((void));
extern int rl_crlf PARAMS((void));
#if defined (__STDC__) && defined (USE_VARARGS) && defined (PREFER_STDARG)
extern int rl_message (const char *, ...);
#if (defined (__STDC__) || defined (__cplusplus)) && defined (USE_VARARGS) && defined (PREFER_STDARG)
extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
#else
extern int rl_message ();
#endif
extern int rl_show_char PARAMS((int));
/* Undocumented in texinfo manual. */
extern int rl_show_char __P((int));
extern int rl_character_len __P((int, int));
extern int crlf __P((void));
extern int rl_character_len PARAMS((int, int));
/* Save and restore internal prompt redisplay information. */
extern void rl_save_prompt __P((void));
extern void rl_restore_prompt __P((void));
extern void rl_save_prompt PARAMS((void));
extern void rl_restore_prompt PARAMS((void));
/* Modifying text. */
extern int rl_insert_text __P((const char *));
extern int rl_delete_text __P((int, int));
extern int rl_kill_text __P((int, int));
extern char *rl_copy_text __P((int, int));
extern void rl_replace_line PARAMS((const char *, int));
extern int rl_insert_text PARAMS((const char *));
extern int rl_delete_text PARAMS((int, int));
extern int rl_kill_text PARAMS((int, int));
extern char *rl_copy_text PARAMS((int, int));
/* Terminal and tty mode management. */
extern void rl_prep_terminal __P((int));
extern void rl_deprep_terminal __P((void));
extern void rltty_set_default_bindings __P((Keymap));
extern void rl_prep_terminal PARAMS((int));
extern void rl_deprep_terminal PARAMS((void));
extern void rl_tty_set_default_bindings PARAMS((Keymap));
extern int rl_reset_terminal __P((char *));
extern void rl_resize_terminal __P((void));
extern int rl_reset_terminal PARAMS((const char *));
extern void rl_resize_terminal PARAMS((void));
extern void rl_set_screen_size PARAMS((int, int));
extern void rl_get_screen_size PARAMS((int *, int *));
/* `Public' utility functions . */
extern void rl_extend_line_buffer __P((int));
extern int ding __P((void));
extern const char *rl_get_termcap PARAMS((const char *));
/* Functions for character input. */
extern int rl_stuff_char __P((int));
extern int rl_execute_next __P((int));
extern int rl_read_key __P((void));
extern int rl_getc __P((FILE *));
extern int rl_stuff_char PARAMS((int));
extern int rl_execute_next PARAMS((int));
extern int rl_clear_pending_input PARAMS((void));
extern int rl_read_key PARAMS((void));
extern int rl_getc PARAMS((FILE *));
extern int rl_set_keyboard_input_timeout PARAMS((int));
/* `Public' utility functions . */
extern void rl_extend_line_buffer PARAMS((int));
extern int rl_ding PARAMS((void));
extern int rl_alphabetic PARAMS((int));
/* Readline signal handling, from signals.c */
extern int rl_set_signals __P((void));
extern int rl_clear_signals __P((void));
extern void rl_cleanup_after_signal __P((void));
extern void rl_reset_after_signal __P((void));
extern void rl_free_line_state __P((void));
extern int rl_set_signals PARAMS((void));
extern int rl_clear_signals PARAMS((void));
extern void rl_cleanup_after_signal PARAMS((void));
extern void rl_reset_after_signal PARAMS((void));
extern void rl_free_line_state PARAMS((void));
extern int rl_set_paren_blink_timeout PARAMS((int));
/* Undocumented. */
extern int rl_expand_prompt __P((char *));
extern int maybe_save_line __P((void));
extern int maybe_unsave_line __P((void));
extern int maybe_replace_line __P((void));
extern int rl_maybe_save_line PARAMS((void));
extern int rl_maybe_unsave_line PARAMS((void));
extern int rl_maybe_replace_line PARAMS((void));
/* Completion functions. */
extern int rl_complete_internal __P((int));
extern void rl_display_match_list __P((char **, int, int));
extern int rl_complete_internal PARAMS((int));
extern void rl_display_match_list PARAMS((char **, int, int));
extern char **completion_matches __P((const char *, CPFunction *));
extern char *username_completion_function __P((const char *, int));
extern char *filename_completion_function __P((const char *, int));
extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
extern char *rl_username_completion_function PARAMS((const char *, int));
extern char *rl_filename_completion_function PARAMS((const char *, int));
extern int rl_completion_mode PARAMS((rl_command_func_t *));
#if 0
/* Backwards compatibility (compat.c). These will go away sometime. */
extern void free_undo_list PARAMS((void));
extern int maybe_save_line PARAMS((void));
extern int maybe_unsave_line PARAMS((void));
extern int maybe_replace_line PARAMS((void));
extern int ding PARAMS((void));
extern int alphabetic PARAMS((int));
extern int crlf PARAMS((void));
extern char **completion_matches PARAMS((char *, rl_compentry_func_t *));
extern char *username_completion_function PARAMS((const char *, int));
extern char *filename_completion_function PARAMS((const char *, int));
#endif
/* **************************************************************** */
/* */
@ -403,7 +452,22 @@ extern char *filename_completion_function __P((const char *, int));
/* **************************************************************** */
/* The version of this incarnation of the readline library. */
extern const char *rl_library_version;
extern const char *rl_library_version; /* e.g., "4.2" */
extern int rl_readline_version; /* e.g., 0x0402 */
/* True if this is real GNU readline. */
extern int rl_gnu_readline_p;
/* Flags word encapsulating the current readline state. */
extern int rl_readline_state;
/* Says which editing mode readline is currently using. 1 means emacs mode;
0 means vi mode. */
extern int rl_editing_mode;
/* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means
overwrite mode. Reset to insert mode on each input line. */
extern int rl_insert_mode;
/* The name of the calling program. You should initialize this to
whatever was in argv[0]. It is used when parsing conditionals. */
@ -417,7 +481,8 @@ extern char *rl_prompt;
extern char *rl_line_buffer;
/* The location of point, and end. */
extern int rl_point, rl_end;
extern int rl_point;
extern int rl_end;
/* The mark, or saved cursor position. */
extern int rl_mark;
@ -434,29 +499,44 @@ extern int rl_pending_input;
or directly from an application. */
extern int rl_dispatching;
/* Non-zero if the user typed a numeric argument before executing the
current function. */
extern int rl_explicit_arg;
/* The current value of the numeric argument specified by the user. */
extern int rl_numeric_arg;
/* The address of the last command function Readline executed. */
extern rl_command_func_t *rl_last_func;
/* The name of the terminal to use. */
extern char *rl_terminal_name;
extern const char *rl_terminal_name;
/* The input and output streams. */
extern FILE *rl_instream, *rl_outstream;
extern FILE *rl_instream;
extern FILE *rl_outstream;
/* If non-zero, then this is the address of a function to call just
before readline_internal () prints the first prompt. */
extern Function *rl_startup_hook;
extern rl_hook_func_t *rl_startup_hook;
/* If non-zero, this is the address of a function to call just before
readline_internal_setup () returns and readline_internal starts
reading input characters. */
extern Function *rl_pre_input_hook;
extern rl_hook_func_t *rl_pre_input_hook;
/* The address of a function to call periodically while Readline is
awaiting character input, or NULL, for no event handling. */
extern Function *rl_event_hook;
extern rl_hook_func_t *rl_event_hook;
extern Function *rl_getc_function;
extern VFunction *rl_redisplay_function;
extern VFunction *rl_prep_term_function;
extern VFunction *rl_deprep_term_function;
/* The address of the function to call to fetch a character from the current
Readline input stream */
extern rl_getc_func_t *rl_getc_function;
extern rl_voidfunc_t *rl_redisplay_function;
extern rl_vintfunc_t *rl_prep_term_function;
extern rl_voidfunc_t *rl_deprep_term_function;
/* Dispatch variables. */
extern Keymap rl_executing_keymap;
@ -468,6 +548,18 @@ extern Keymap rl_binding_keymap;
rl_newline. */
extern int rl_erase_empty_line;
/* If non-zero, the application has already printed the prompt (rl_prompt)
before calling readline, so readline should not output it the first time
redisplay is done. */
extern int rl_already_prompted;
/* A non-zero value means to read only this many characters rather than
up to a character bound to accept-line. */
extern int rl_num_chars_to_read;
/* The text of a currently-executing keyboard macro. */
extern char *rl_executing_macro;
/* Variables to control readline signal handling. */
/* If non-zero, readline will install its own signal handlers for
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
@ -482,9 +574,9 @@ extern int rl_catch_sigwinch;
/* Completion variables. */
/* Pointer to the generator function for completion_matches ().
NULL means to use filename_entry_function (), the default filename
completer. */
extern Function *rl_completion_entry_function;
NULL means to use rl_filename_completion_function (), the default
filename completer. */
extern rl_compentry_func_t *rl_completion_entry_function;
/* If rl_ignore_some_completions_function is non-NULL it is the address
of a function to call after all of the possible matches have been
@ -492,7 +584,7 @@ extern Function *rl_completion_entry_function;
The function is called with one argument; a NULL terminated array
of (char *). If your function removes any of the elements, they
must be free()'ed. */
extern Function *rl_ignore_some_completions_function;
extern rl_compignore_func_t *rl_ignore_some_completions_function;
/* Pointer to alternative function to create matches.
Function is called with TEXT, START, and END.
@ -501,7 +593,7 @@ extern Function *rl_ignore_some_completions_function;
If this function exists and returns NULL then call the value of
rl_completion_entry_function to try to match, otherwise use the
array of strings returned. */
extern CPPFunction *rl_attempted_completion_function;
extern rl_completion_func_t *rl_attempted_completion_function;
/* The basic list of characters that signal a break between words for the
completer routine. The initial contents of this variable is what
@ -517,23 +609,34 @@ extern const char *rl_completer_word_break_characters;
Completion occurs on the entire substring, and within the substring
rl_completer_word_break_characters are treated as any other character,
unless they also appear within this list. */
extern char *rl_completer_quote_characters;
extern const char *rl_completer_quote_characters;
/* List of quote characters which cause a word break. */
extern const char *rl_basic_quote_characters;
/* List of characters that need to be quoted in filenames by the completer. */
extern char *rl_filename_quote_characters;
extern const char *rl_filename_quote_characters;
/* List of characters that are word break characters, but should be left
in TEXT when it is passed to the completion function. The shell uses
this to help determine what kind of completing to do. */
extern char *rl_special_prefixes;
extern const char *rl_special_prefixes;
/* If non-zero, then this is the address of a function to call when
completing on a directory name. The function is called with
the address of a string (the current directory name) as an arg. */
extern Function *rl_directory_completion_hook;
the address of a string (the current directory name) as an arg. It
changes what is displayed when the possible completions are printed
or inserted. */
extern rl_icppfunc_t *rl_directory_completion_hook;
/* If non-zero, this is the address of a function to call when completing
a directory name. This function takes the address of the directory name
to be modified as an argument. Unlike rl_directory_completion_hook, it
only modifies the directory name used in opendir(2), not what is displayed
when the possible completions are printed or inserted. It is called
before rl_directory_completion_hook. I'm not happy with how this works
yet, so it's undocumented. */
extern rl_icppfunc_t *rl_directory_rewrite_hook;
/* Backwards compatibility with previous versions of readline. */
#define rl_symbolic_link_hook rl_directory_completion_hook
@ -545,7 +648,7 @@ extern Function *rl_directory_completion_hook;
where MATCHES is the array of strings that matched, NUM_MATCHES is the
number of strings in that array, and MAX_LENGTH is the length of the
longest string in that array. */
extern VFunction *rl_completion_display_matches_hook;
extern rl_compdisp_func_t *rl_completion_display_matches_hook;
/* Non-zero means that the results of the matches are to be treated
as filenames. This is ALWAYS zero on entry, and can only be changed
@ -563,17 +666,17 @@ extern int rl_filename_quoting_desired;
Called with the text to quote, the type of match found (single or multiple)
and a pointer to the quoting character to be used, which the function can
reset if desired. */
extern CPFunction *rl_filename_quoting_function;
extern rl_quote_func_t *rl_filename_quoting_function;
/* Function to call to remove quoting characters from a filename. Called
before completion is attempted, so the embedded quotes do not interfere
with matching names in the file system. */
extern CPFunction *rl_filename_dequoting_function;
extern rl_dequote_func_t *rl_filename_dequoting_function;
/* Function to call to decide whether or not a word break character is
quoted. If a character is quoted, it does not break words for the
completer. */
extern Function *rl_char_is_quoted_p;
extern rl_linebuf_func_t *rl_char_is_quoted_p;
/* Non-zero means to suppress normal filename completion after the
user-specified completion function has been called. */
@ -588,11 +691,26 @@ extern int rl_completion_type;
default is a space. Nothing is added if this is '\0'. */
extern int rl_completion_append_character;
/* If set to non-zero by an application completion function,
rl_completion_append_character will not be appended. */
extern int rl_completion_suppress_append;
/* Up to this many items will be displayed in response to a
possible-completions call. After that, we ask the user if she
is sure she wants to see them all. The default value is 100. */
extern int rl_completion_query_items;
/* If non-zero, a slash will be appended to completed filenames that are
symbolic links to directory names, subject to the value of the
mark-directories variable (which is user-settable). This exists so
that application completion functions can override the user's preference
(set via the mark-symlinked-directories variable) if appropriate.
It's set to the value of _rl_complete_mark_symlink_dirs in
rl_complete_internal before any application-specific completion
function is called, so without that function doing anything, the user's
preferences are honored. */
extern int rl_completion_mark_symlink_dirs;
/* If non-zero, then disallow duplicates in the matches. */
extern int rl_ignore_completion_duplicates;
@ -610,9 +728,69 @@ extern int rl_inhibit_completion;
#define SINGLE_MATCH 1
#define MULT_MATCH 2
#if !defined (savestring)
extern char *savestring (); /* XXX backwards compatibility */
#endif
/* Possible state values for rl_readline_state */
#define RL_STATE_NONE 0x00000 /* no state; before first call */
#define RL_STATE_INITIALIZING 0x00001 /* initializing */
#define RL_STATE_INITIALIZED 0x00002 /* initialization done */
#define RL_STATE_TERMPREPPED 0x00004 /* terminal is prepped */
#define RL_STATE_READCMD 0x00008 /* reading a command key */
#define RL_STATE_METANEXT 0x00010 /* reading input after ESC */
#define RL_STATE_DISPATCHING 0x00020 /* dispatching to a command */
#define RL_STATE_MOREINPUT 0x00040 /* reading more input in a command function */
#define RL_STATE_ISEARCH 0x00080 /* doing incremental search */
#define RL_STATE_NSEARCH 0x00100 /* doing non-inc search */
#define RL_STATE_SEARCH 0x00200 /* doing a history search */
#define RL_STATE_NUMERICARG 0x00400 /* reading numeric argument */
#define RL_STATE_MACROINPUT 0x00800 /* getting input from a macro */
#define RL_STATE_MACRODEF 0x01000 /* defining keyboard macro */
#define RL_STATE_OVERWRITE 0x02000 /* overwrite mode */
#define RL_STATE_COMPLETING 0x04000 /* doing completion */
#define RL_STATE_SIGHANDLER 0x08000 /* in readline sighandler */
#define RL_STATE_UNDOING 0x10000 /* doing an undo */
#define RL_STATE_INPUTPENDING 0x20000 /* rl_execute_next called */
#define RL_STATE_DONE 0x80000 /* done; accepted line */
#define RL_SETSTATE(x) (rl_readline_state |= (x))
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
#define RL_ISSTATE(x) (rl_readline_state & (x))
struct readline_state {
/* line state */
int point;
int end;
int mark;
char *buffer;
int buflen;
UNDO_LIST *ul;
char *prompt;
/* global state */
int rlstate;
int done;
Keymap kmap;
/* input state */
rl_command_func_t *lastfunc;
int insmode;
int edmode;
int kseqlen;
FILE *inf;
FILE *outf;
int pendingin;
char *macro;
/* signal state */
int catchsigs;
int catchsigwinch;
/* reserved for future expansion, so the struct size doesn't change */
char reserved[64];
};
extern int rl_save_state PARAMS((struct readline_state *));
extern int rl_restore_state PARAMS((struct readline_state *));
#ifdef __cplusplus
}

View File

@ -8,7 +8,7 @@
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 1, or (at your option)
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
@ -19,7 +19,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLCONF_H_)
#define _RLCONF_H_
@ -30,10 +30,6 @@
/* Define this to get an indication of file type when listing completions. */
#define VISIBLE_STATS
/* If defined, readline shows opening parens and braces when closing
paren or brace entered. */
/* #define PAREN_MATCHING */
/* This definition is needed by readline.c, rltty.c, and signals.c. */
/* If on, then readline handles signals in a way that doesn't screw. */
#define HANDLE_SIGNALS
@ -58,4 +54,7 @@
X `callback' style. */
#define READLINE_CALLBACKS
/* Define this if you want the cursor to indicate insert or overwrite mode. */
/* #define CURSOR_MODE */
#endif /* _RLCONF_H_ */

View File

@ -10,7 +10,7 @@
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 1, or (at your option)
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
@ -21,7 +21,7 @@
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,
675 Mass Ave, Cambridge, MA 02139, USA. */
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLDEFS_H_)
#define _RLDEFS_H_
@ -30,6 +30,12 @@
# include "config.h"
#endif
#include "rlstdc.h"
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ <8)
#define __attribute__(A)
#endif
#if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
# define TERMIOS_TTY_DRIVER
#else
@ -71,7 +77,14 @@ extern char *strchr (), *strrchr ();
#define _rl_stricmp strcasecmp
#define _rl_strnicmp strncasecmp
#else
extern int _rl_stricmp (), _rl_strnicmp ();
extern int _rl_stricmp PARAMS((char *, char *));
extern int _rl_strnicmp PARAMS((char *, char *, int));
#endif
#if defined (HAVE_STRPBRK)
# define _rl_strpbrk(a,b) strpbrk((a),(b))
#else
extern char *_rl_strpbrk PARAMS((const char *, const char *));
#endif
#if !defined (emacs_mode)
@ -80,6 +93,13 @@ extern int _rl_stricmp (), _rl_strnicmp ();
# define emacs_mode 1
#endif
#if !defined (RL_IM_INSERT)
# define RL_IM_INSERT 1
# define RL_IM_OVERWRITE 0
#
# define RL_IM_DEFAULT RL_IM_INSERT
#endif
/* If you cast map[key].function to type (Keymap) on a Cray,
the compiler takes the value of map[key].function and
divides it by 4 to convert between pointer types (pointers
@ -87,15 +107,14 @@ extern int _rl_stricmp (), _rl_strnicmp ();
This is not what is wanted. */
#if defined (CRAY)
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)((int)map[key].function)
# define KEYMAP_TO_FUNCTION(data) (Function *)((int)(data))
# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)((int)(data))
#else
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)(map[key].function)
# define KEYMAP_TO_FUNCTION(data) (Function *)(data)
# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)(data)
#endif
#ifndef savestring
extern char *xmalloc ();
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
#endif
/* Possible values for _rl_bell_preference. */
@ -113,22 +132,28 @@ extern char *xmalloc ();
/* Possible values for the found_quote flags word used by the completion
functions. It says what kind of (shell-like) quoting we found anywhere
in the line. */
#define RL_QF_SINGLE_QUOTE 0x1
#define RL_QF_DOUBLE_QUOTE 0x2
#define RL_QF_BACKSLASH 0x4
#define RL_QF_SINGLE_QUOTE 0x01
#define RL_QF_DOUBLE_QUOTE 0x02
#define RL_QF_BACKSLASH 0x04
#define RL_QF_OTHER_QUOTE 0x08
/* Default readline line buffer length. */
#define DEFAULT_BUFFER_SIZE 256
#if !defined (STREQ)
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
#define STREQN(a, b, n) (((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
#define STREQN(a, b, n) (((n) == 0) ? (1) \
: ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
#endif
#if !defined (FREE)
# define FREE(x) if (x) free (x)
#endif
#if !defined (SWAP)
# define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
#endif
/* CONFIGURATION SECTION */
#include "rlconf.h"

108
readline/rlmbutil.h Normal file
View File

@ -0,0 +1,108 @@
/* rlmbutil.h -- utility functions for multibyte characters. */
/* Copyright (C) 2001 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline 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 GNU Readline 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 (_RL_MBUTIL_H_)
#define _RL_MBUTIL_H_
#include "rlstdc.h"
/************************************************/
/* check multibyte capability for I18N code */
/************************************************/
/* For platforms which support the ISO C amendement 1 functionality we
support user defined character classes. */
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H)
# include <wchar.h>
# include <wctype.h>
# if defined (HAVE_MBSRTOWCS) /* system is supposed to support XPG5 */
# define HANDLE_MULTIBYTE 1
# endif
#endif
/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
#if HANDLE_MULTIBYTE && !defined (HAVE_MBSTATE_T)
# define wcsrtombs(dest, src, len, ps) (wcsrtombs) (dest, src, len, 0)
# define mbsrtowcs(dest, src, len, ps) (mbsrtowcs) (dest, src, len, 0)
# define wcrtomb(s, wc, ps) (wcrtomb) (s, wc, 0)
# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
# define mbrlen(s, n, ps) (mbrlen) (s, n, 0)
# define mbstate_t int
#endif
/* Make sure MB_LEN_MAX is at least 16 on systems that claim to be able to
handle multibyte chars (some systems define MB_LEN_MAX as 1) */
#ifdef HANDLE_MULTIBYTE
# include <limits.h>
# if defined(MB_LEN_MAX) && (MB_LEN_MAX < 16)
# undef MB_LEN_MAX
# endif
# if !defined (MB_LEN_MAX)
# define MB_LEN_MAX 16
# endif
#endif
/************************************************/
/* end of multibyte capability checks for I18N */
/************************************************/
/*
* Flags for _rl_find_prev_mbchar and _rl_find_next_mbchar:
*
* MB_FIND_ANY find any multibyte character
* MB_FIND_NONZERO find a non-zero-width multibyte character
*/
#define MB_FIND_ANY 0x00
#define MB_FIND_NONZERO 0x01
extern int _rl_find_prev_mbchar PARAMS((char *, int, int));
extern int _rl_find_next_mbchar PARAMS((char *, int, int, int));
#ifdef HANDLE_MULTIBYTE
extern int _rl_compare_chars PARAMS((char *, int, mbstate_t *, char *, int, mbstate_t *));
extern int _rl_get_char_len PARAMS((const char *, mbstate_t *));
extern int _rl_adjust_point PARAMS((const char *, int, mbstate_t *));
extern int _rl_read_mbchar PARAMS((char *, int));
extern int _rl_read_mbstring PARAMS((int, char *, int));
extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
#else /* !HANDLE_MULTIBYTE */
#undef MB_LEN_MAX
#undef MB_CUR_MAX
#define MB_LEN_MAX 1
#define MB_CUR_MAX 1
#define _rl_find_prev_mbchar(b, i, f) (((i) == 0) ? (i) : ((i) - 1))
#define _rl_find_next_mbchar(b, i1, i2, f) ((i1) + (i2))
#endif /* !HANDLE_MULTIBYTE */
extern int rl_byte_oriented;
#endif /* _RL_MBUTIL_H_ */

284
readline/rlprivate.h Normal file
View File

@ -0,0 +1,284 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
/* Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline 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 GNU Readline 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 (_RL_PRIVATE_H_)
#define _RL_PRIVATE_H_
#include "rlconf.h" /* for VISIBLE_STATS */
#include "rlstdc.h"
#include "posixjmp.h" /* defines procenv_t */
/*************************************************************************
* *
* Global functions undocumented in texinfo manual and not in readline.h *
* *
*************************************************************************/
/*************************************************************************
* *
* Global variables undocumented in texinfo manual and not in readline.h *
* *
*************************************************************************/
/* complete.c */
extern int rl_complete_with_tilde_expansion;
#if defined (VISIBLE_STATS)
extern int rl_visible_stats;
#endif /* VISIBLE_STATS */
/* readline.c */
extern int rl_line_buffer_len;
extern int rl_arg_sign;
extern int rl_visible_prompt_length;
extern int readline_echoing_p;
extern int rl_key_sequence_length;
extern int rl_byte_oriented;
/* display.c */
extern int rl_display_fixed;
/* parens.c */
extern int rl_blink_matching_paren;
/*************************************************************************
* *
* Global functions and variables unsed and undocumented *
* *
*************************************************************************/
/* kill.c */
extern int rl_set_retained_kills PARAMS((int));
/* terminal.c */
extern void _rl_set_screen_size PARAMS((int, int));
/* undo.c */
extern int _rl_fix_last_undo_of_type PARAMS((unsigned int, int, int));
/* util.c */
extern char *_rl_savestring PARAMS((const char *));
/*************************************************************************
* *
* Functions and variables private to the readline library *
* *
*************************************************************************/
/* NOTE: Functions and variables prefixed with `_rl_' are
pseudo-global: they are global so they can be shared
between files in the readline library, but are not intended
to be visible to readline callers. */
/*************************************************************************
* Undocumented private functions *
*************************************************************************/
#if defined(READLINE_CALLBACKS)
/* readline.c */
extern void readline_internal_setup PARAMS((void));
extern char *readline_internal_teardown PARAMS((int));
extern int readline_internal_char PARAMS((void));
#endif /* READLINE_CALLBACKS */
/* bind.c */
extern void _rl_bind_if_unbound PARAMS((const char *, rl_command_func_t *));
/* complete.c */
extern char _rl_find_completion_word PARAMS((int *, int *));
extern void _rl_free_match_list PARAMS((char **));
/* display.c */
extern char *_rl_strip_prompt PARAMS((char *));
extern void _rl_move_cursor_relative PARAMS((int, const char *));
extern void _rl_move_vert PARAMS((int));
extern void _rl_save_prompt PARAMS((void));
extern void _rl_restore_prompt PARAMS((void));
extern char *_rl_make_prompt_for_search PARAMS((int));
extern void _rl_erase_at_end_of_line PARAMS((int));
extern void _rl_clear_to_eol PARAMS((int));
extern void _rl_clear_screen PARAMS((void));
extern void _rl_update_final PARAMS((void));
extern void _rl_redisplay_after_sigwinch PARAMS((void));
extern void _rl_clean_up_for_exit PARAMS((void));
extern void _rl_erase_entire_line PARAMS((void));
extern int _rl_current_display_line PARAMS((void));
/* input.c */
extern int _rl_any_typein PARAMS((void));
extern int _rl_input_available PARAMS((void));
extern int _rl_input_queued PARAMS((int));
extern void _rl_insert_typein PARAMS((int));
extern int _rl_unget_char PARAMS((int));
/* macro.c */
extern void _rl_with_macro_input PARAMS((char *));
extern int _rl_next_macro_key PARAMS((void));
extern void _rl_push_executing_macro PARAMS((void));
extern void _rl_pop_executing_macro PARAMS((void));
extern void _rl_add_macro_char PARAMS((int));
extern void _rl_kill_kbd_macro PARAMS((void));
/* misc.c */
extern int _rl_init_argument PARAMS((void));
extern void _rl_start_using_history PARAMS((void));
extern int _rl_free_saved_history_line PARAMS((void));
extern void _rl_set_insert_mode PARAMS((int, int));
/* nls.c */
extern int _rl_init_eightbit PARAMS((void));
/* parens.c */
extern void _rl_enable_paren_matching PARAMS((int));
/* readline.c */
extern void _rl_init_line_state PARAMS((void));
extern void _rl_set_the_line PARAMS((void));
extern int _rl_dispatch PARAMS((int, Keymap));
extern int _rl_dispatch_subseq PARAMS((int, Keymap, int));
/* rltty.c */
extern int _rl_disable_tty_signals PARAMS((void));
extern int _rl_restore_tty_signals PARAMS((void));
/* terminal.c */
extern void _rl_get_screen_size PARAMS((int, int));
extern int _rl_init_terminal_io PARAMS((const char *));
#ifdef _MINIX
extern void _rl_output_character_function PARAMS((int));
#else
extern int _rl_output_character_function PARAMS((int));
#endif
extern void _rl_output_some_chars PARAMS((const char *, int));
extern int _rl_backspace PARAMS((int));
extern void _rl_enable_meta_key PARAMS((void));
extern void _rl_control_keypad PARAMS((int));
extern void _rl_set_cursor PARAMS((int, int));
/* text.c */
extern void _rl_fix_point PARAMS((int));
extern int _rl_replace_text PARAMS((const char *, int, int));
extern int _rl_insert_char PARAMS((int, int));
extern int _rl_overwrite_char PARAMS((int, int));
extern int _rl_overwrite_rubout PARAMS((int, int));
extern int _rl_rubout_char PARAMS((int, int));
#if defined (HANDLE_MULTIBYTE)
extern int _rl_char_search_internal PARAMS((int, int, char *, int));
#else
extern int _rl_char_search_internal PARAMS((int, int, int));
#endif
extern int _rl_set_mark_at_pos PARAMS((int));
/* util.c */
extern int _rl_abort_internal PARAMS((void));
extern char *_rl_strindex PARAMS((const char *, const char *));
extern int _rl_qsort_string_compare PARAMS((char **, char **));
extern int (_rl_uppercase_p) PARAMS((int));
extern int (_rl_lowercase_p) PARAMS((int));
extern int (_rl_pure_alphabetic) PARAMS((int));
extern int (_rl_digit_p) PARAMS((int));
extern int (_rl_to_lower) PARAMS((int));
extern int (_rl_to_upper) PARAMS((int));
extern int (_rl_digit_value) PARAMS((int));
/* vi_mode.c */
extern void _rl_vi_initialize_line PARAMS((void));
extern void _rl_vi_reset_last PARAMS((void));
extern void _rl_vi_set_last PARAMS((int, int, int));
extern int _rl_vi_textmod_command PARAMS((int));
extern void _rl_vi_done_inserting PARAMS((void));
/*************************************************************************
* Undocumented private variables *
*************************************************************************/
/* bind.c */
extern const char *_rl_possible_control_prefixes[];
extern const char *_rl_possible_meta_prefixes[];
/* complete.c */
extern int _rl_complete_show_all;
extern int _rl_complete_mark_directories;
extern int _rl_complete_mark_symlink_dirs;
extern int _rl_print_completions_horizontally;
extern int _rl_completion_case_fold;
extern int _rl_match_hidden_files;
extern int _rl_page_completions;
/* display.c */
extern int _rl_vis_botlin;
extern int _rl_last_c_pos;
extern int _rl_suppress_redisplay;
extern const char *rl_display_prompt;
/* isearch.c */
extern char *_rl_isearch_terminators;
/* macro.c */
extern char *_rl_executing_macro;
/* misc.c */
extern int _rl_history_preserve_point;
extern int _rl_history_saved_point;
/* readline.c */
extern int _rl_horizontal_scroll_mode;
extern int _rl_mark_modified_lines;
extern int _rl_bell_preference;
extern int _rl_meta_flag;
extern int _rl_convert_meta_chars_to_ascii;
extern int _rl_output_meta_chars;
extern char *_rl_comment_begin;
extern unsigned char _rl_parsing_conditionalized_out;
extern Keymap _rl_keymap;
extern FILE *_rl_in_stream;
extern FILE *_rl_out_stream;
extern int _rl_last_command_was_kill;
extern int _rl_eof_char;
extern procenv_t readline_top_level;
/* terminal.c */
extern int _rl_enable_keypad;
extern int _rl_enable_meta;
extern const char *_rl_term_clreol;
extern const char *_rl_term_clrpag;
extern const char *_rl_term_im;
extern const char *_rl_term_ic;
extern const char *_rl_term_ei;
extern const char *_rl_term_DC;
extern const char *_rl_term_up;
extern const char *_rl_term_dc;
extern const char *_rl_term_cr;
extern const char *_rl_term_IC;
extern int _rl_screenheight;
extern int _rl_screenwidth;
extern int _rl_screenchars;
extern int _rl_terminal_can_insert;
extern int _rl_term_autowrap;
/* undo.c */
extern int _rl_doing_an_undo;
extern int _rl_undo_group_level;
#endif /* _RL_PRIVATE_H_ */

34
readline/rlshell.h Normal file
View File

@ -0,0 +1,34 @@
/* rlshell.h -- utility functions normally provided by bash. */
/* Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline 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 GNU Readline 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 (_RL_SHELL_H_)
#define _RL_SHELL_H_
#include "rlstdc.h"
extern char *sh_single_quote PARAMS((char *));
extern void sh_set_lines_and_columns PARAMS((int, int));
extern char *sh_get_env_value PARAMS((const char *));
extern char *sh_get_home_dir PARAMS((void));
extern int sh_unset_nodelay_mode PARAMS((int));
#endif /* _RL_SHELL_H_ */

Some files were not shown because too many files have changed in this diff Show More