bzr merge from guilhem's maria tree to our local 5.1
configure.in: Manually merged mysql-test/lib/My/ConfigFactory.pm: Manually merged mysql-test/mysql-test-run.pl: Manually merged mysql-test/t/information_schema.test: Manually merged sql/handler.cc: Manually merged support-files/mysql.spec.sh: Manually merged
This commit is contained in:
commit
210a412522
@ -754,6 +754,8 @@ mysql-test/linux_sys_vars.inc
|
|||||||
mysql-test/load_sysvars.inc
|
mysql-test/load_sysvars.inc
|
||||||
mysql-test/mtr
|
mysql-test/mtr
|
||||||
mysql-test/mysql-test-run
|
mysql-test/mysql-test-run
|
||||||
|
mysql-test/mysql-test-gcov.err
|
||||||
|
mysql-test/mysql-test-gcov.msg
|
||||||
mysql-test/mysql-test-run-shell
|
mysql-test/mysql-test-run-shell
|
||||||
mysql-test/mysql-test-run.log
|
mysql-test/mysql-test-run.log
|
||||||
mysql-test/mysql_test_run_new
|
mysql-test/mysql_test_run_new
|
||||||
|
@ -152,6 +152,12 @@ IF(MSVC)
|
|||||||
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT})
|
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT})
|
||||||
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
|
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
|
||||||
|
|
||||||
|
# Mark 32 bit executables large address aware so they can
|
||||||
|
# use > 2GB address space
|
||||||
|
IF(CMAKE_SIZEOF_VOID_P MATCHES 4)
|
||||||
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
|
||||||
|
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 4)
|
||||||
|
|
||||||
# Disable automatic manifest generation.
|
# Disable automatic manifest generation.
|
||||||
STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
|
STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
|
||||||
${CMAKE_EXE_LINKER_FLAGS})
|
${CMAKE_EXE_LINKER_FLAGS})
|
||||||
|
@ -250,7 +250,7 @@ static COMMANDS commands[] = {
|
|||||||
{ "connect",'r', com_connect,1,
|
{ "connect",'r', com_connect,1,
|
||||||
"Reconnect to the server. Optional arguments are db and host." },
|
"Reconnect to the server. Optional arguments are db and host." },
|
||||||
{ "delimiter", 'd', com_delimiter, 1,
|
{ "delimiter", 'd', com_delimiter, 1,
|
||||||
"Set statement delimiter. NOTE: Takes the rest of the line as new delimiter." },
|
"Set statement delimiter." },
|
||||||
#ifdef USE_POPEN
|
#ifdef USE_POPEN
|
||||||
{ "edit", 'e', com_edit, 0, "Edit command with $EDITOR."},
|
{ "edit", 'e', com_edit, 0, "Edit command with $EDITOR."},
|
||||||
#endif
|
#endif
|
||||||
@ -2255,8 +2255,22 @@ static bool add_line(String &buffer,char *line,char *in_string,
|
|||||||
}
|
}
|
||||||
if (out != line || !buffer.is_empty())
|
if (out != line || !buffer.is_empty())
|
||||||
{
|
{
|
||||||
*out++='\n';
|
|
||||||
uint length=(uint) (out-line);
|
uint length=(uint) (out-line);
|
||||||
|
|
||||||
|
if (length < 9 ||
|
||||||
|
my_strnncoll (charset_info,
|
||||||
|
(uchar *)line, 9, (const uchar *) "delimiter", 9))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Don't add a new line in case there's a DELIMITER command to be
|
||||||
|
added to the glob buffer (e.g. on processing a line like
|
||||||
|
"<command>;DELIMITER <non-eof>") : similar to how a new line is
|
||||||
|
not added in the case when the DELIMITER is the first command
|
||||||
|
entered with an empty glob buffer.
|
||||||
|
*/
|
||||||
|
*out++='\n';
|
||||||
|
length++;
|
||||||
|
}
|
||||||
if (buffer.length() + length >= buffer.alloced_length())
|
if (buffer.length() + length >= buffer.alloced_length())
|
||||||
buffer.realloc(buffer.length()+length+IO_SIZE);
|
buffer.realloc(buffer.length()+length+IO_SIZE);
|
||||||
if ((!*ml_comment || preserve_comments) && buffer.append(line, length))
|
if ((!*ml_comment || preserve_comments) && buffer.append(line, length))
|
||||||
@ -2280,8 +2294,10 @@ extern "C" char **new_mysql_completion (const char *text, int start, int end);
|
|||||||
if not.
|
if not.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_LIBEDIT_INTERFACE)
|
#if defined(USE_NEW_READLINE_INTERFACE)
|
||||||
extern "C" char *no_completion(const char*,int)
|
extern "C" char *no_completion(const char*,int)
|
||||||
|
#elif defined(USE_LIBEDIT_INTERFACE)
|
||||||
|
extern "C" int no_completion(const char*,int)
|
||||||
#else
|
#else
|
||||||
extern "C" char *no_completion()
|
extern "C" char *no_completion()
|
||||||
#endif
|
#endif
|
||||||
@ -2863,7 +2879,7 @@ com_charset(String *buffer __attribute__((unused)), char *line)
|
|||||||
param= get_arg(buff, 0);
|
param= get_arg(buff, 0);
|
||||||
if (!param || !*param)
|
if (!param || !*param)
|
||||||
{
|
{
|
||||||
return put_info("Usage: \\C char_setname | charset charset_name",
|
return put_info("Usage: \\C charset_name | charset charset_name",
|
||||||
INFO_ERROR, 0);
|
INFO_ERROR, 0);
|
||||||
}
|
}
|
||||||
new_cs= get_charset_by_csname(param, MY_CS_PRIMARY, MYF(MY_WME));
|
new_cs= get_charset_by_csname(param, MY_CS_PRIMARY, MYF(MY_WME));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
|
/* Copyright 2000-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -1475,7 +1475,8 @@ static int connect_to_db(char *host, char *user,char *passwd)
|
|||||||
DB_error(&mysql_connection, "when trying to connect");
|
DB_error(&mysql_connection, "when trying to connect");
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
if (mysql_get_server_version(&mysql_connection) < 40100)
|
if ((mysql_get_server_version(&mysql_connection) < 40100) ||
|
||||||
|
(opt_compatible_mode & 3))
|
||||||
{
|
{
|
||||||
/* Don't dump SET NAMES with a pre-4.1 server (bug#7997). */
|
/* Don't dump SET NAMES with a pre-4.1 server (bug#7997). */
|
||||||
opt_set_charset= 0;
|
opt_set_charset= 0;
|
||||||
@ -2421,11 +2422,11 @@ static uint get_table_structure(char *table, char *db, char *table_type,
|
|||||||
|
|
||||||
row= mysql_fetch_row(result);
|
row= mysql_fetch_row(result);
|
||||||
|
|
||||||
fprintf(sql_file,
|
fprintf(sql_file, (opt_compatible_mode & 3) ? "%s;\n" :
|
||||||
"SET @saved_cs_client = @@character_set_client;\n"
|
"/*!40101 SET @saved_cs_client = @@character_set_client */;\n"
|
||||||
"SET character_set_client = utf8;\n"
|
"/*!40101 SET character_set_client = utf8 */;\n"
|
||||||
"%s;\n"
|
"%s;\n"
|
||||||
"SET character_set_client = @saved_cs_client;\n",
|
"/*!40101 SET character_set_client = @saved_cs_client */;\n",
|
||||||
row[1]);
|
row[1]);
|
||||||
|
|
||||||
check_io(sql_file);
|
check_io(sql_file);
|
||||||
|
@ -4676,6 +4676,10 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host,
|
|||||||
int failed_attempts= 0;
|
int failed_attempts= 0;
|
||||||
|
|
||||||
DBUG_ENTER("safe_connect");
|
DBUG_ENTER("safe_connect");
|
||||||
|
|
||||||
|
verbose_msg("Connecting to server %s:%d (socket %s) as '%s'"
|
||||||
|
", connection '%s', attempt %d ...",
|
||||||
|
host, port, sock, user, name, failed_attempts);
|
||||||
while(!mysql_real_connect(mysql, host,user, pass, db, port, sock,
|
while(!mysql_real_connect(mysql, host,user, pass, db, port, sock,
|
||||||
CLIENT_MULTI_STATEMENTS | CLIENT_REMEMBER_OPTIONS))
|
CLIENT_MULTI_STATEMENTS | CLIENT_REMEMBER_OPTIONS))
|
||||||
{
|
{
|
||||||
@ -4707,6 +4711,7 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host,
|
|||||||
}
|
}
|
||||||
failed_attempts++;
|
failed_attempts++;
|
||||||
}
|
}
|
||||||
|
verbose_msg("... Connected.");
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6904,14 +6909,6 @@ end:
|
|||||||
dynstr_free(&ds_execute_warnings);
|
dynstr_free(&ds_execute_warnings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Close the statement if - no reconnect, need new prepare */
|
|
||||||
if (mysql->reconnect)
|
|
||||||
{
|
|
||||||
mysql_stmt_close(stmt);
|
|
||||||
cur_con->stmt= NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We save the return code (mysql_stmt_errno(stmt)) from the last call sent
|
We save the return code (mysql_stmt_errno(stmt)) from the last call sent
|
||||||
to the server into the mysqltest builtin variable $mysql_errno. This
|
to the server into the mysqltest builtin variable $mysql_errno. This
|
||||||
@ -6920,6 +6917,13 @@ end:
|
|||||||
|
|
||||||
var_set_errno(mysql_stmt_errno(stmt));
|
var_set_errno(mysql_stmt_errno(stmt));
|
||||||
|
|
||||||
|
/* Close the statement if reconnect, need new prepare */
|
||||||
|
if (mysql->reconnect)
|
||||||
|
{
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
cur_con->stmt= NULL;
|
||||||
|
}
|
||||||
|
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7561,8 +7565,12 @@ int main(int argc, char **argv)
|
|||||||
parse_args(argc, argv);
|
parse_args(argc, argv);
|
||||||
|
|
||||||
log_file.open(opt_logdir, result_file_name, ".log");
|
log_file.open(opt_logdir, result_file_name, ".log");
|
||||||
|
verbose_msg("Logging to '%s'.", log_file.file_name());
|
||||||
if (opt_mark_progress)
|
if (opt_mark_progress)
|
||||||
|
{
|
||||||
progress_file.open(opt_logdir, result_file_name, ".progress");
|
progress_file.open(opt_logdir, result_file_name, ".progress");
|
||||||
|
verbose_msg("Tracing progress in '%s'.", progress_file.file_name());
|
||||||
|
}
|
||||||
|
|
||||||
var_set_int("$PS_PROTOCOL", ps_protocol);
|
var_set_int("$PS_PROTOCOL", ps_protocol);
|
||||||
var_set_int("$SP_PROTOCOL", sp_protocol);
|
var_set_int("$SP_PROTOCOL", sp_protocol);
|
||||||
@ -7571,6 +7579,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
DBUG_PRINT("info",("result_file: '%s'",
|
DBUG_PRINT("info",("result_file: '%s'",
|
||||||
result_file_name ? result_file_name : ""));
|
result_file_name ? result_file_name : ""));
|
||||||
|
verbose_msg("Results saved in '%s'.",
|
||||||
|
result_file_name ? result_file_name : "");
|
||||||
if (mysql_server_init(embedded_server_arg_count,
|
if (mysql_server_init(embedded_server_arg_count,
|
||||||
embedded_server_args,
|
embedded_server_args,
|
||||||
(char**) embedded_server_groups))
|
(char**) embedded_server_groups))
|
||||||
@ -7641,6 +7651,7 @@ int main(int argc, char **argv)
|
|||||||
open_file(opt_include);
|
open_file(opt_include);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verbose_msg("Start processing test commands from '%s' ...", cur_file->file_name);
|
||||||
while (!read_command(&command) && !abort_flag)
|
while (!read_command(&command) && !abort_flag)
|
||||||
{
|
{
|
||||||
int current_line_inc = 1, processed = 0;
|
int current_line_inc = 1, processed = 0;
|
||||||
@ -7958,6 +7969,7 @@ int main(int argc, char **argv)
|
|||||||
log_file.close();
|
log_file.close();
|
||||||
|
|
||||||
start_lineno= 0;
|
start_lineno= 0;
|
||||||
|
verbose_msg("... Done processing test commands.");
|
||||||
|
|
||||||
if (parsing_disabled)
|
if (parsing_disabled)
|
||||||
die("Test ended with parsing disabled");
|
die("Test ended with parsing disabled");
|
||||||
@ -8008,6 +8020,7 @@ int main(int argc, char **argv)
|
|||||||
if (!command_executed && result_file_name)
|
if (!command_executed && result_file_name)
|
||||||
die("No queries executed but result file found!");
|
die("No queries executed but result file found!");
|
||||||
|
|
||||||
|
verbose_msg("Test has succeeded!");
|
||||||
timer_output();
|
timer_output();
|
||||||
/* Yes, if we got this far the test has suceeded! Sakila smiles */
|
/* Yes, if we got this far the test has suceeded! Sakila smiles */
|
||||||
cleanup_and_exit(0);
|
cleanup_and_exit(0);
|
||||||
|
@ -71,25 +71,22 @@ bool String::realloc(uint32 alloc_length)
|
|||||||
char *new_ptr;
|
char *new_ptr;
|
||||||
if (alloced)
|
if (alloced)
|
||||||
{
|
{
|
||||||
if ((new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME))))
|
if (!(new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME))))
|
||||||
{
|
|
||||||
Ptr=new_ptr;
|
|
||||||
Alloced_length=len;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return TRUE; // Signal error
|
return TRUE; // Signal error
|
||||||
}
|
}
|
||||||
else if ((new_ptr= (char*) my_malloc(len,MYF(MY_WME))))
|
else if ((new_ptr= (char*) my_malloc(len,MYF(MY_WME))))
|
||||||
{
|
{
|
||||||
|
if (str_length > len - 1)
|
||||||
|
str_length= 0;
|
||||||
if (str_length) // Avoid bugs in memcpy on AIX
|
if (str_length) // Avoid bugs in memcpy on AIX
|
||||||
memcpy(new_ptr,Ptr,str_length);
|
memcpy(new_ptr,Ptr,str_length);
|
||||||
new_ptr[str_length]=0;
|
new_ptr[str_length]=0;
|
||||||
Ptr=new_ptr;
|
|
||||||
Alloced_length=len;
|
|
||||||
alloced=1;
|
alloced=1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return TRUE; // Signal error
|
return TRUE; // Signal error
|
||||||
|
Ptr= new_ptr;
|
||||||
|
Alloced_length= len;
|
||||||
}
|
}
|
||||||
Ptr[alloc_length]=0; // This make other funcs shorter
|
Ptr[alloc_length]=0; // This make other funcs shorter
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -125,7 +122,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
|
|||||||
str_charset=cs;
|
str_charset=cs;
|
||||||
if (decimals >= NOT_FIXED_DEC)
|
if (decimals >= NOT_FIXED_DEC)
|
||||||
{
|
{
|
||||||
uint32 len= my_sprintf(buff,(buff, "%.14g",num));// Enough for a DATETIME
|
uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
|
||||||
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
|
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_FCONVERT
|
#ifdef HAVE_FCONVERT
|
||||||
@ -677,7 +674,7 @@ void String::qs_append(const char *str, uint32 len)
|
|||||||
void String::qs_append(double d)
|
void String::qs_append(double d)
|
||||||
{
|
{
|
||||||
char *buff = Ptr + str_length;
|
char *buff = Ptr + str_length;
|
||||||
str_length+= my_sprintf(buff, (buff, "%.14g", d));
|
str_length+= my_sprintf(buff, (buff, "%.15g", d));
|
||||||
}
|
}
|
||||||
|
|
||||||
void String::qs_append(double *d)
|
void String::qs_append(double *d)
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
## Process this file with automake to create Makefile.in
|
## Process this file with automake to create Makefile.in
|
||||||
# Makefile for the GNU readline library.
|
|
||||||
# Copyright (C) 1994,1996,1997 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
ASRC = $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c
|
ASRC = $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c
|
||||||
AHDR = vi.h emacs.h common.h
|
AHDR = vi.h emacs.h common.h
|
||||||
@ -12,33 +10,23 @@ noinst_LIBRARIES = libedit.a
|
|||||||
libedit_a_SOURCES = chared.c el.c history.c map.c prompt.c readline.c \
|
libedit_a_SOURCES = chared.c el.c history.c map.c prompt.c readline.c \
|
||||||
search.c tokenizer.c vi.c common.c emacs.c \
|
search.c tokenizer.c vi.c common.c emacs.c \
|
||||||
hist.c key.c parse.c read.c refresh.c sig.c term.c \
|
hist.c key.c parse.c read.c refresh.c sig.c term.c \
|
||||||
tty.c help.c fcns.c
|
tty.c help.c fcns.c filecomplete.c \
|
||||||
|
np/unvis.c np/strlcpy.c np/vis.c np/strlcat.c \
|
||||||
EXTRA_libedit_a_SOURCES = np/unvis.c np/strlcpy.c np/vis.c np/strlcat.c \
|
|
||||||
np/fgetln.c
|
np/fgetln.c
|
||||||
|
|
||||||
libedit_a_LIBADD = @LIBEDIT_LOBJECTS@
|
libedit_a_LIBADD = @LIBEDIT_LOBJECTS@
|
||||||
libedit_a_DEPENDENCIES = @LIBEDIT_LOBJECTS@
|
libedit_a_DEPENDENCIES = @LIBEDIT_LOBJECTS@
|
||||||
|
|
||||||
noinst_HEADERS = readline/readline.h \
|
pkginclude_HEADERS = readline/readline.h
|
||||||
\
|
|
||||||
chared.h el.h el_term.h histedit.h key.h parse.h refresh.h sig.h \
|
|
||||||
sys.h tokenizer.h config.h hist.h map.h prompt.h read.h \
|
|
||||||
search.h tty.h libedit_term.h vis.h
|
|
||||||
|
|
||||||
EXTRA_DIST = makelist.sh np/unvis.c np/strlcpy.c np/vis.c np/vis.h np/strlcat.c np/fgetln.c
|
noinst_HEADERS = chared.h el.h el_term.h histedit.h key.h parse.h refresh.h sig.h \
|
||||||
|
sys.h config.h hist.h map.h prompt.h read.h \
|
||||||
|
search.h tty.h filecomplete.h np/vis.h
|
||||||
|
|
||||||
|
EXTRA_DIST = makelist.sh
|
||||||
|
|
||||||
CLEANFILES = makelist common.h emacs.h vi.h fcns.h help.h fcns.c help.c
|
CLEANFILES = makelist common.h emacs.h vi.h fcns.h help.h fcns.c help.c
|
||||||
|
|
||||||
# Make sure to include stuff from this directory first, to get right "config.h"
|
|
||||||
# Automake puts into DEFAULT_INCLUDES this source and corresponding
|
|
||||||
# build directory together with ../../include to let all make files
|
|
||||||
# find the central "config.h". This variable is used before INCLUDES
|
|
||||||
# above. But in automake 1.10 the order of these are changed. Put the
|
|
||||||
# includes of this directory into DEFS to always be sure it is first
|
|
||||||
# before DEFAULT_INCLUDES on the compile line.
|
|
||||||
DEFS = -DUNDEF_THREADS_HACK -DHAVE_CONFIG_H -DNO_KILL_INTR -I. -I$(srcdir)
|
|
||||||
|
|
||||||
SUFFIXES = .sh
|
SUFFIXES = .sh
|
||||||
|
|
||||||
.sh:
|
.sh:
|
||||||
@ -101,6 +89,4 @@ term.o: vi.h emacs.h common.h help.h fcns.h
|
|||||||
tty.o: vi.h emacs.h common.h help.h fcns.h
|
tty.o: vi.h emacs.h common.h help.h fcns.h
|
||||||
help.o: vi.h emacs.h common.h help.h fcns.h
|
help.o: vi.h emacs.h common.h help.h fcns.h
|
||||||
fcns.o: vi.h emacs.h common.h help.h fcns.h
|
fcns.o: vi.h emacs.h common.h help.h fcns.h
|
||||||
|
filecomplete.o: vi.h emacs.h common.h help.h fcns.h
|
||||||
# Don't update the files from bitkeeper
|
|
||||||
%::SCCS/s.%
|
|
||||||
|
50
cmd-line-utils/libedit/README
Normal file
50
cmd-line-utils/libedit/README
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
An approximate method to merge from upstream is:
|
||||||
|
|
||||||
|
# Fetch latest from upstream (we also include some compat stuff)
|
||||||
|
$ CVS_RSH=ssh; export CVS_RSH
|
||||||
|
$ CVSROOT="anoncvs@stripped:/cvsroot"
|
||||||
|
$ cvs co -d libedit -P src/lib/libedit
|
||||||
|
$ mkdir libedit/np
|
||||||
|
$ for f in src/common/lib/libc/string/strlcat.c \
|
||||||
|
> src/common/lib/libc/string/strlcpy.c \
|
||||||
|
> src/include/vis.h \
|
||||||
|
> src/lib/libc/gen/unvis.c \
|
||||||
|
> src/lib/libc/gen/vis.c \
|
||||||
|
> src/tools/compat/fgetln.c
|
||||||
|
> do
|
||||||
|
> cvs co -P ${f}
|
||||||
|
> mv ${f} libedit/np
|
||||||
|
> done
|
||||||
|
$ rm -rf src
|
||||||
|
$ cd libedit
|
||||||
|
|
||||||
|
# Remove files we don't need/use
|
||||||
|
$ rm -rf CVS TEST Makefile shlib_version *.[0-9]
|
||||||
|
$ (cd readline; rm -rf CVS Makefile)
|
||||||
|
|
||||||
|
# Rename files to match our naming
|
||||||
|
$ mv makelist makelist.sh
|
||||||
|
$ mv term.h el_term.h
|
||||||
|
|
||||||
|
# Remove NetBSD-specific bits
|
||||||
|
$ for file in $(find . -type f)
|
||||||
|
> do
|
||||||
|
> cp ${file} ${file}.orig
|
||||||
|
> sed -e 's/#include "term.h"/#include "el_term.h"/g' \
|
||||||
|
> -e 's/sig_handler/el_sig_handler/g' \
|
||||||
|
> -e 's/isprint/el_isprint/g' \
|
||||||
|
> -e '/^__RCSID/d' \
|
||||||
|
> ${file}.orig >${file}
|
||||||
|
> rm ${file}.orig
|
||||||
|
> done
|
||||||
|
|
||||||
|
then merge remaining bits by hand. All MySQL-specific changes should be
|
||||||
|
marked with XXXMYSQL to make them easier to identify and merge. To generate
|
||||||
|
a 'clean' diff against upstream you can use the above commands but use
|
||||||
|
|
||||||
|
cvs co -D "2009/02/06 20:09:00" [..]
|
||||||
|
|
||||||
|
to fetch the baseline of most recent merge.
|
||||||
|
|
||||||
|
Please feed any fixes to Jonathan Perkin <jperkin@stripped> who will endeavour
|
||||||
|
to merge them upstream and keep diffs minimal.
|
@ -1,269 +0,0 @@
|
|||||||
/* $NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1992, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* Christos Zoulas of Cornell University.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#include "compat.h"
|
|
||||||
#ifndef lint
|
|
||||||
__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
|
|
||||||
The Regents of the University of California. All rights reserved.\n");
|
|
||||||
#endif /* not lint */
|
|
||||||
|
|
||||||
#if !defined(lint) && !defined(SCCSID)
|
|
||||||
#if 0
|
|
||||||
static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#else
|
|
||||||
__RCSID("$NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $");
|
|
||||||
#endif
|
|
||||||
#endif /* not lint && not SCCSID */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* test.c: A little test program
|
|
||||||
*/
|
|
||||||
#include "sys.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
#include "histedit.h"
|
|
||||||
#include "tokenizer.h"
|
|
||||||
|
|
||||||
static int continuation = 0;
|
|
||||||
static EditLine *el = NULL;
|
|
||||||
|
|
||||||
static u_char complete(EditLine *, int);
|
|
||||||
int main(int, char **);
|
|
||||||
static char *prompt(EditLine *);
|
|
||||||
static void sig(int);
|
|
||||||
|
|
||||||
static char *
|
|
||||||
prompt(EditLine *el)
|
|
||||||
{
|
|
||||||
static char a[] = "Edit$";
|
|
||||||
static char b[] = "Edit>";
|
|
||||||
|
|
||||||
return (continuation ? b : a);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
sig(int i)
|
|
||||||
{
|
|
||||||
|
|
||||||
(void) fprintf(stderr, "Got signal %d.\n", i);
|
|
||||||
el_reset(el);
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned char
|
|
||||||
complete(EditLine *el, int ch)
|
|
||||||
{
|
|
||||||
DIR *dd = opendir(".");
|
|
||||||
struct dirent *dp;
|
|
||||||
const char* ptr;
|
|
||||||
const LineInfo *lf = el_line(el);
|
|
||||||
int len;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Find the last word
|
|
||||||
*/
|
|
||||||
for (ptr = lf->cursor - 1; !isspace(*ptr) && ptr > lf->buffer; ptr--)
|
|
||||||
continue;
|
|
||||||
len = lf->cursor - ++ptr;
|
|
||||||
|
|
||||||
for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) {
|
|
||||||
if (len > strlen(dp->d_name))
|
|
||||||
continue;
|
|
||||||
if (strncmp(dp->d_name, ptr, len) == 0) {
|
|
||||||
closedir(dd);
|
|
||||||
if (el_insertstr(el, &dp->d_name[len]) == -1)
|
|
||||||
return (CC_ERROR);
|
|
||||||
else
|
|
||||||
return (CC_REFRESH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(dd);
|
|
||||||
return (CC_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int num;
|
|
||||||
const char *buf;
|
|
||||||
Tokenizer *tok;
|
|
||||||
int lastevent = 0, ncontinuation;
|
|
||||||
History *hist;
|
|
||||||
HistEvent ev;
|
|
||||||
|
|
||||||
(void) signal(SIGINT, sig);
|
|
||||||
(void) signal(SIGQUIT, sig);
|
|
||||||
(void) signal(SIGHUP, sig);
|
|
||||||
(void) signal(SIGTERM, sig);
|
|
||||||
|
|
||||||
hist = history_init(); /* Init the builtin history */
|
|
||||||
/* Remember 100 events */
|
|
||||||
history(hist, &ev, H_SETSIZE, 100);
|
|
||||||
|
|
||||||
tok = tok_init(NULL); /* Initialize the tokenizer */
|
|
||||||
|
|
||||||
/* Initialize editline */
|
|
||||||
el = el_init(*argv, stdin, stdout, stderr);
|
|
||||||
|
|
||||||
el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */
|
|
||||||
el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */
|
|
||||||
el_set(el, EL_PROMPT, prompt); /* Set the prompt function */
|
|
||||||
|
|
||||||
/* Tell editline to use this history interface */
|
|
||||||
el_set(el, EL_HIST, history, hist);
|
|
||||||
|
|
||||||
/* Add a user-defined function */
|
|
||||||
el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete);
|
|
||||||
|
|
||||||
/* Bind tab to it */
|
|
||||||
el_set(el, EL_BIND, "^I", "ed-complete", NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Bind j, k in vi command mode to previous and next line, instead
|
|
||||||
* of previous and next history.
|
|
||||||
*/
|
|
||||||
el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL);
|
|
||||||
el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Source the user's defaults file.
|
|
||||||
*/
|
|
||||||
el_source(el, NULL);
|
|
||||||
|
|
||||||
while ((buf = el_gets(el, &num)) != NULL && num != 0) {
|
|
||||||
int ac;
|
|
||||||
char **av;
|
|
||||||
#ifdef DEBUG
|
|
||||||
(void) fprintf(stderr, "got %d %s", num, buf);
|
|
||||||
#endif
|
|
||||||
if (!continuation && num == 1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (tok_line(tok, buf, &ac, &av) > 0)
|
|
||||||
ncontinuation = 1;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (continuation) {
|
|
||||||
/*
|
|
||||||
* Append to the right event in case the user
|
|
||||||
* moved around in history.
|
|
||||||
*/
|
|
||||||
if (history(hist, &ev, H_SET, lastevent) == -1)
|
|
||||||
err(1, "%d: %s\n", lastevent, ev.str);
|
|
||||||
history(hist, &ev, H_ADD , buf);
|
|
||||||
} else {
|
|
||||||
history(hist, &ev, H_ENTER, buf);
|
|
||||||
lastevent = ev.num;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* Simpler */
|
|
||||||
history(hist, &ev, continuation ? H_APPEND : H_ENTER, buf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
continuation = ncontinuation;
|
|
||||||
ncontinuation = 0;
|
|
||||||
|
|
||||||
if (strcmp(av[0], "history") == 0) {
|
|
||||||
int rv;
|
|
||||||
|
|
||||||
switch (ac) {
|
|
||||||
case 1:
|
|
||||||
for (rv = history(hist, &ev, H_LAST); rv != -1;
|
|
||||||
rv = history(hist, &ev, H_PREV))
|
|
||||||
(void) fprintf(stdout, "%4d %s",
|
|
||||||
ev.num, ev.str);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
if (strcmp(av[1], "clear") == 0)
|
|
||||||
history(hist, &ev, H_CLEAR);
|
|
||||||
else
|
|
||||||
goto badhist;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
if (strcmp(av[1], "load") == 0)
|
|
||||||
history(hist, &ev, H_LOAD, av[2]);
|
|
||||||
else if (strcmp(av[1], "save") == 0)
|
|
||||||
history(hist, &ev, H_SAVE, av[2]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
badhist:
|
|
||||||
default:
|
|
||||||
(void) fprintf(stderr,
|
|
||||||
"Bad history arguments\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (el_parse(el, ac, av) == -1) {
|
|
||||||
switch (fork()) {
|
|
||||||
case 0:
|
|
||||||
execvp(av[0], av);
|
|
||||||
perror(av[0]);
|
|
||||||
_exit(1);
|
|
||||||
/*NOTREACHED*/
|
|
||||||
break;
|
|
||||||
|
|
||||||
case -1:
|
|
||||||
perror("fork");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (wait(&num) == -1)
|
|
||||||
perror("wait");
|
|
||||||
(void) fprintf(stderr, "Exit %x\n", num);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tok_reset(tok);
|
|
||||||
}
|
|
||||||
|
|
||||||
el_end(el);
|
|
||||||
tok_end(tok);
|
|
||||||
history_end(hist);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp $ */
|
/* $NetBSD: chared.c,v 1.26 2009/02/06 12:45:25 sketch Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* chared.c: Character editor utilities
|
* chared.c: Character editor utilities
|
||||||
@ -40,6 +46,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "el.h"
|
#include "el.h"
|
||||||
|
|
||||||
|
private void ch__clearmacro (EditLine *);
|
||||||
|
|
||||||
/* value to leave unused in line buffer */
|
/* value to leave unused in line buffer */
|
||||||
#define EL_LEAVE 2
|
#define EL_LEAVE 2
|
||||||
|
|
||||||
@ -51,13 +59,13 @@ cv_undo(EditLine *el)
|
|||||||
{
|
{
|
||||||
c_undo_t *vu = &el->el_chared.c_undo;
|
c_undo_t *vu = &el->el_chared.c_undo;
|
||||||
c_redo_t *r = &el->el_chared.c_redo;
|
c_redo_t *r = &el->el_chared.c_redo;
|
||||||
int size;
|
unsigned int size;
|
||||||
|
|
||||||
/* Save entire line for undo */
|
/* Save entire line for undo */
|
||||||
size = el->el_line.lastchar - el->el_line.buffer;
|
size = el->el_line.lastchar - el->el_line.buffer;
|
||||||
vu->len = size;
|
vu->len = size;
|
||||||
vu->cursor = el->el_line.cursor - el->el_line.buffer;
|
vu->cursor = el->el_line.cursor - el->el_line.buffer;
|
||||||
memcpy(vu->buf, el->el_line.buffer, (size_t)size);
|
memcpy(vu->buf, el->el_line.buffer, size);
|
||||||
|
|
||||||
/* save command info for redo */
|
/* save command info for redo */
|
||||||
r->count = el->el_state.doingarg ? el->el_state.argument : 0;
|
r->count = el->el_state.doingarg ? el->el_state.argument : 0;
|
||||||
@ -439,6 +447,8 @@ cv__endword(char *p, char *high, int n, int (*wtest)(int))
|
|||||||
protected int
|
protected int
|
||||||
ch_init(EditLine *el)
|
ch_init(EditLine *el)
|
||||||
{
|
{
|
||||||
|
c_macro_t *ma = &el->el_chared.c_macro;
|
||||||
|
|
||||||
el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ);
|
el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ);
|
||||||
if (el->el_line.buffer == NULL)
|
if (el->el_line.buffer == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -479,11 +489,10 @@ ch_init(EditLine *el)
|
|||||||
el->el_state.argument = 1;
|
el->el_state.argument = 1;
|
||||||
el->el_state.lastcmd = ED_UNASSIGNED;
|
el->el_state.lastcmd = ED_UNASSIGNED;
|
||||||
|
|
||||||
el->el_chared.c_macro.level = -1;
|
ma->level = -1;
|
||||||
el->el_chared.c_macro.offset = 0;
|
ma->offset = 0;
|
||||||
el->el_chared.c_macro.macro = (char **) el_malloc(EL_MAXMACRO *
|
ma->macro = (char **) el_malloc(EL_MAXMACRO * sizeof(char *));
|
||||||
sizeof(char *));
|
if (ma->macro == NULL)
|
||||||
if (el->el_chared.c_macro.macro == NULL)
|
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -492,7 +501,7 @@ ch_init(EditLine *el)
|
|||||||
* Reset the character editor
|
* Reset the character editor
|
||||||
*/
|
*/
|
||||||
protected void
|
protected void
|
||||||
ch_reset(EditLine *el)
|
ch_reset(EditLine *el, int mclear)
|
||||||
{
|
{
|
||||||
el->el_line.cursor = el->el_line.buffer;
|
el->el_line.cursor = el->el_line.buffer;
|
||||||
el->el_line.lastchar = el->el_line.buffer;
|
el->el_line.lastchar = el->el_line.buffer;
|
||||||
@ -513,9 +522,19 @@ ch_reset(EditLine *el)
|
|||||||
el->el_state.argument = 1;
|
el->el_state.argument = 1;
|
||||||
el->el_state.lastcmd = ED_UNASSIGNED;
|
el->el_state.lastcmd = ED_UNASSIGNED;
|
||||||
|
|
||||||
el->el_chared.c_macro.level = -1;
|
|
||||||
|
|
||||||
el->el_history.eventno = 0;
|
el->el_history.eventno = 0;
|
||||||
|
|
||||||
|
if (mclear)
|
||||||
|
ch__clearmacro(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void
|
||||||
|
ch__clearmacro(el)
|
||||||
|
EditLine *el;
|
||||||
|
{
|
||||||
|
c_macro_t *ma = &el->el_chared.c_macro;
|
||||||
|
while (ma->level >= 0)
|
||||||
|
el_free((ptr_t)ma->macro[ma->level--]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ch_enlargebufs():
|
/* ch_enlargebufs():
|
||||||
@ -623,9 +642,9 @@ ch_end(EditLine *el)
|
|||||||
el->el_chared.c_redo.cmd = ED_UNASSIGNED;
|
el->el_chared.c_redo.cmd = ED_UNASSIGNED;
|
||||||
el_free((ptr_t) el->el_chared.c_kill.buf);
|
el_free((ptr_t) el->el_chared.c_kill.buf);
|
||||||
el->el_chared.c_kill.buf = NULL;
|
el->el_chared.c_kill.buf = NULL;
|
||||||
|
ch_reset(el, 1);
|
||||||
el_free((ptr_t) el->el_chared.c_macro.macro);
|
el_free((ptr_t) el->el_chared.c_macro.macro);
|
||||||
el->el_chared.c_macro.macro = NULL;
|
el->el_chared.c_macro.macro = NULL;
|
||||||
ch_reset(el);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: chared.h,v 1.14 2004/08/13 12:10:39 mycroft Exp $ */
|
/* $NetBSD: chared.h,v 1.17 2006/03/06 21:11:56 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -48,7 +48,7 @@
|
|||||||
#define EL_MAXMACRO 10
|
#define EL_MAXMACRO 10
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works
|
* This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works
|
||||||
* like real vi: i.e. the transition from command<->insert modes moves
|
* like real vi: i.e. the transition from command<->insert modes moves
|
||||||
* the cursor.
|
* the cursor.
|
||||||
*
|
*
|
||||||
@ -116,11 +116,10 @@ typedef struct el_chared_t {
|
|||||||
} el_chared_t;
|
} el_chared_t;
|
||||||
|
|
||||||
|
|
||||||
#define STReof "^D\b\b"
|
|
||||||
#define STRQQ "\"\""
|
#define STRQQ "\"\""
|
||||||
|
|
||||||
#define isglob(a) (strchr("*[]?", (a)) != NULL)
|
#define isglob(a) (strchr("*[]?", (a)) != NULL)
|
||||||
#define isword(a) (isprint(a))
|
#define isword(a) (el_isprint(a))
|
||||||
|
|
||||||
#define NOP 0x00
|
#define NOP 0x00
|
||||||
#define DELETE 0x01
|
#define DELETE 0x01
|
||||||
@ -161,7 +160,7 @@ protected int c_gets(EditLine *, char *, const char *);
|
|||||||
protected int c_hpos(EditLine *);
|
protected int c_hpos(EditLine *);
|
||||||
|
|
||||||
protected int ch_init(EditLine *);
|
protected int ch_init(EditLine *);
|
||||||
protected void ch_reset(EditLine *);
|
protected void ch_reset(EditLine *, int);
|
||||||
protected int ch_enlargebufs(EditLine *, size_t);
|
protected int ch_enlargebufs(EditLine *, size_t);
|
||||||
protected void ch_end(EditLine *);
|
protected void ch_end(EditLine *);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: common.c,v 1.16 2003/08/07 16:44:30 agc Exp $ */
|
/* $NetBSD: common.c,v 1.21 2008/09/30 08:37:42 aymeric Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* common.c: Common Editor functions
|
* common.c: Common Editor functions
|
||||||
@ -130,7 +136,7 @@ ed_delete_prev_word(EditLine *el, int c __attribute__((__unused__)))
|
|||||||
*/
|
*/
|
||||||
protected el_action_t
|
protected el_action_t
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
ed_delete_next_char(EditLine *el, int c __attribute__((__unused__)))
|
ed_delete_next_char(EditLine *el, int c)
|
||||||
{
|
{
|
||||||
#ifdef notdef /* XXX */
|
#ifdef notdef /* XXX */
|
||||||
#define EL el->el_line
|
#define EL el->el_line
|
||||||
@ -147,9 +153,8 @@ ed_delete_next_char(EditLine *el, int c __attribute__((__unused__)))
|
|||||||
#ifdef KSHVI
|
#ifdef KSHVI
|
||||||
return (CC_ERROR);
|
return (CC_ERROR);
|
||||||
#else
|
#else
|
||||||
term_overwrite(el, STReof, 4);
|
/* then do an EOF */
|
||||||
/* then do a EOF */
|
term_writechar(el, c);
|
||||||
term__flush();
|
|
||||||
return (CC_EOF);
|
return (CC_EOF);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
@ -207,13 +212,13 @@ ed_move_to_end(EditLine *el, int c __attribute__((__unused__)))
|
|||||||
|
|
||||||
el->el_line.cursor = el->el_line.lastchar;
|
el->el_line.cursor = el->el_line.lastchar;
|
||||||
if (el->el_map.type == MAP_VI) {
|
if (el->el_map.type == MAP_VI) {
|
||||||
#ifdef VI_MOVE
|
|
||||||
el->el_line.cursor--;
|
|
||||||
#endif
|
|
||||||
if (el->el_chared.c_vcmd.action != NOP) {
|
if (el->el_chared.c_vcmd.action != NOP) {
|
||||||
cv_delfini(el);
|
cv_delfini(el);
|
||||||
return (CC_REFRESH);
|
return (CC_REFRESH);
|
||||||
}
|
}
|
||||||
|
#ifdef VI_MOVE
|
||||||
|
el->el_line.cursor--;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return (CC_CURSOR);
|
return (CC_CURSOR);
|
||||||
}
|
}
|
||||||
@ -609,7 +614,7 @@ protected el_action_t
|
|||||||
ed_start_over(EditLine *el, int c __attribute__((__unused__)))
|
ed_start_over(EditLine *el, int c __attribute__((__unused__)))
|
||||||
{
|
{
|
||||||
|
|
||||||
ch_reset(el);
|
ch_reset(el, 0);
|
||||||
return (CC_REFRESH);
|
return (CC_REFRESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -904,7 +909,7 @@ ed_command(EditLine *el, int c __attribute__((__unused__)))
|
|||||||
int tmplen;
|
int tmplen;
|
||||||
|
|
||||||
tmplen = c_gets(el, tmpbuf, "\n: ");
|
tmplen = c_gets(el, tmpbuf, "\n: ");
|
||||||
term__putc('\n');
|
term__putc(el, '\n');
|
||||||
|
|
||||||
if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
|
if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
|
||||||
term_beep(el);
|
term_beep(el);
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
#ifndef __LIBEDIT_COMPATH_H
|
|
||||||
#define __LIBEDIT_COMPATH_H
|
|
||||||
|
|
||||||
#define __RCSID(x)
|
|
||||||
#define __COPYRIGHT(x)
|
|
||||||
|
|
||||||
#include "compat_conf.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_VIS_H
|
|
||||||
/* string visual representation - may want to reimplement */
|
|
||||||
#define strvis(d,s,m) strcpy(d,s)
|
|
||||||
#define strunvis(d,s) strcpy(d,s)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_FGETLN
|
|
||||||
#include "fgetln.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_ISSETUGID
|
|
||||||
#define issetugid() (getuid()!=geteuid() || getegid()!=getgid())
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRLCPY
|
|
||||||
#include "strlcpy.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_SYS_CDEFS_H
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __P
|
|
||||||
#ifdef __STDC__
|
|
||||||
#define __P(x) x
|
|
||||||
#else
|
|
||||||
#define __P(x) ()
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
|
||||||
#define __attribute__(A)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,2 +0,0 @@
|
|||||||
|
|
||||||
#include "my_config.h"
|
|
@ -1,16 +1,2 @@
|
|||||||
|
|
||||||
#include "my_config.h"
|
#include "my_config.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
#define __RCSID(x)
|
|
||||||
#define __COPYRIGHT(x)
|
|
||||||
#endif
|
|
||||||
#define __RENAME(x)
|
|
||||||
#define _DIAGASSERT(x)
|
|
||||||
|
|
||||||
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
|
||||||
#define __attribute__(A)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,619 +0,0 @@
|
|||||||
.\" $NetBSD: editline.3,v 1.21 2001/04/02 18:29:49 wiz Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1997-1999 The NetBSD Foundation, Inc.
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\" 3. All advertising materials mentioning features or use of this software
|
|
||||||
.\" must display the following acknowledgement:
|
|
||||||
.\" This product includes software developed by the NetBSD
|
|
||||||
.\" Foundation, Inc. and its contributors.
|
|
||||||
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
||||||
.\" contributors may be used to endorse or promote products derived
|
|
||||||
.\" from this software without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.Dd November 12, 1999
|
|
||||||
.Os
|
|
||||||
.Dt EDITLINE 3
|
|
||||||
.Sh NAME
|
|
||||||
.Nm editline ,
|
|
||||||
.Nm el_init ,
|
|
||||||
.Nm el_end ,
|
|
||||||
.Nm el_reset ,
|
|
||||||
.Nm el_gets ,
|
|
||||||
.Nm el_getc ,
|
|
||||||
.Nm el_push ,
|
|
||||||
.Nm el_parse ,
|
|
||||||
.Nm el_set ,
|
|
||||||
.Nm el_source ,
|
|
||||||
.Nm el_resize ,
|
|
||||||
.Nm el_line ,
|
|
||||||
.Nm el_insertstr ,
|
|
||||||
.Nm el_deletestr ,
|
|
||||||
.Nm history_init ,
|
|
||||||
.Nm history_end ,
|
|
||||||
.Nm history
|
|
||||||
.Nd line editor and history functions
|
|
||||||
.Sh LIBRARY
|
|
||||||
.Lb libedit
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Fd #include <histedit.h>
|
|
||||||
.Ft EditLine *
|
|
||||||
.Fn el_init "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr"
|
|
||||||
.Ft void
|
|
||||||
.Fn el_end "EditLine *e"
|
|
||||||
.Ft void
|
|
||||||
.Fn el_reset "EditLine *e"
|
|
||||||
.Ft const char *
|
|
||||||
.Fn el_gets "EditLine *e" "int *count"
|
|
||||||
.Ft int
|
|
||||||
.Fn el_getc "EditLine *e" "char *ch"
|
|
||||||
.Ft void
|
|
||||||
.Fn el_push "EditLine *e" "const char *str"
|
|
||||||
.Ft int
|
|
||||||
.Fn el_parse "EditLine *e" "int argc" "char *argv[]"
|
|
||||||
.Ft int
|
|
||||||
.Fn el_set "EditLine *e" "int op" "..."
|
|
||||||
.Ft int
|
|
||||||
.Fn el_get "EditLine *e" "int op" "void *result"
|
|
||||||
.Ft int
|
|
||||||
.Fn el_source "EditLine *e" "const char *file"
|
|
||||||
.Ft void
|
|
||||||
.Fn el_resize "EditLine *e"
|
|
||||||
.Ft const LineInfo *
|
|
||||||
.Fn el_line "EditLine *e"
|
|
||||||
.Ft int
|
|
||||||
.Fn el_insertstr "EditLine *e" "const char *str"
|
|
||||||
.Ft void
|
|
||||||
.Fn el_deletestr "EditLine *e" "int count"
|
|
||||||
.Ft History *
|
|
||||||
.Fn history_init
|
|
||||||
.Ft void
|
|
||||||
.Fn history_end "History *h"
|
|
||||||
.Ft int
|
|
||||||
.Fn history "History *h" "HistEvent *ev" "int op" "..."
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
library provides generic line editing and history functions,
|
|
||||||
similar to those found in
|
|
||||||
.Xr sh 1 .
|
|
||||||
.Pp
|
|
||||||
These functions are available in the
|
|
||||||
.Nm libedit
|
|
||||||
library (which needs the
|
|
||||||
.Nm libtermcap
|
|
||||||
library).
|
|
||||||
Programs should be linked with
|
|
||||||
.Fl ledit ltermcap .
|
|
||||||
.Sh LINE EDITING FUNCTIONS
|
|
||||||
The line editing functions use a common data structure,
|
|
||||||
.Fa EditLine ,
|
|
||||||
which is created by
|
|
||||||
.Fn el_init
|
|
||||||
and freed by
|
|
||||||
.Fn el_end .
|
|
||||||
.Pp
|
|
||||||
The following functions are available:
|
|
||||||
.Bl -tag -width 4n
|
|
||||||
.It Fn el_init
|
|
||||||
Initialise the line editor, and return a data structure
|
|
||||||
to be used by all other line editing functions.
|
|
||||||
.Fa prog
|
|
||||||
is the name of the invoking program, used when reading the
|
|
||||||
.Xr editrc 5
|
|
||||||
file to determine which settings to use.
|
|
||||||
.Fa fin ,
|
|
||||||
.Fa fout
|
|
||||||
and
|
|
||||||
.Fa ferr
|
|
||||||
are the input, output, and error streams (respectively) to use.
|
|
||||||
In this documentation, references to
|
|
||||||
.Dq the tty
|
|
||||||
are actually to this input/output stream combination.
|
|
||||||
.It Fn el_end
|
|
||||||
Clean up and finish with
|
|
||||||
.Fa e ,
|
|
||||||
assumed to have been created with
|
|
||||||
.Fn el_init .
|
|
||||||
.It Fn el_reset
|
|
||||||
Reset the tty and the parser.
|
|
||||||
This should be called after an error which may have upset the tty's
|
|
||||||
state.
|
|
||||||
.It Fn el_gets
|
|
||||||
Read a line from the tty.
|
|
||||||
.Fa count
|
|
||||||
is modified to contain the number of characters read.
|
|
||||||
Returns the line read if successful, or
|
|
||||||
.Dv NULL
|
|
||||||
if no characters were read or if an error occurred.
|
|
||||||
.It Fn el_getc
|
|
||||||
Read a character from the tty.
|
|
||||||
.Fa ch
|
|
||||||
is modified to contain the character read.
|
|
||||||
Returns the number of characters read if successful, -1 otherwise.
|
|
||||||
.It Fn el_push
|
|
||||||
Pushes
|
|
||||||
.Fa str
|
|
||||||
back onto the input stream.
|
|
||||||
This is used by the macro expansion mechanism.
|
|
||||||
Refer to the description of
|
|
||||||
.Ic bind
|
|
||||||
.Fl s
|
|
||||||
in
|
|
||||||
.Xr editrc 5
|
|
||||||
for more information.
|
|
||||||
.It Fn el_parse
|
|
||||||
Parses the
|
|
||||||
.Fa argv
|
|
||||||
array (which is
|
|
||||||
.Fa argc
|
|
||||||
elements in size)
|
|
||||||
to execute builtin
|
|
||||||
.Nm
|
|
||||||
commands.
|
|
||||||
If the command is prefixed with
|
|
||||||
.Dq prog:
|
|
||||||
then
|
|
||||||
.Fn el_parse
|
|
||||||
will only execute the command if
|
|
||||||
.Dq prog
|
|
||||||
matches the
|
|
||||||
.Fa prog
|
|
||||||
argument supplied to
|
|
||||||
.Fn el_init .
|
|
||||||
The return value is
|
|
||||||
-1 if the command is unknown,
|
|
||||||
0 if there was no error or
|
|
||||||
.Dq prog
|
|
||||||
didn't match, or
|
|
||||||
1 if the command returned an error.
|
|
||||||
Refer to
|
|
||||||
.Xr editrc 5
|
|
||||||
for more information.
|
|
||||||
.It Fn el_set
|
|
||||||
Set
|
|
||||||
.Nm
|
|
||||||
parameters.
|
|
||||||
.Fa op
|
|
||||||
determines which parameter to set, and each operation has its
|
|
||||||
own parameter list.
|
|
||||||
.Pp
|
|
||||||
The following values for
|
|
||||||
.Fa op
|
|
||||||
are supported, along with the required argument list:
|
|
||||||
.Bl -tag -width 4n
|
|
||||||
.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)"
|
|
||||||
Define prompt printing function as
|
|
||||||
.Fa f ,
|
|
||||||
which is to return a string that contains the prompt.
|
|
||||||
.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)"
|
|
||||||
Define right side prompt printing function as
|
|
||||||
.Fa f ,
|
|
||||||
which is to return a string that contains the prompt.
|
|
||||||
.It Dv EL_TERMINAL , Fa "const char *type"
|
|
||||||
Define terminal type of the tty to be
|
|
||||||
.Fa type ,
|
|
||||||
or to
|
|
||||||
.Ev TERM
|
|
||||||
if
|
|
||||||
.Fa type
|
|
||||||
is
|
|
||||||
.Dv NULL .
|
|
||||||
.It Dv EL_EDITOR , Fa "const char *mode"
|
|
||||||
Set editing mode to
|
|
||||||
.Fa mode ,
|
|
||||||
which must be one of
|
|
||||||
.Dq emacs
|
|
||||||
or
|
|
||||||
.Dq vi .
|
|
||||||
.It Dv EL_SIGNAL , Fa "int flag"
|
|
||||||
If
|
|
||||||
.Fa flag
|
|
||||||
is non-zero,
|
|
||||||
.Nm
|
|
||||||
will install its own signal handler for the following signals when
|
|
||||||
reading command input:
|
|
||||||
.Dv SIGCONT ,
|
|
||||||
.Dv SIGHUP ,
|
|
||||||
.Dv SIGINT ,
|
|
||||||
.Dv SIGQUIT ,
|
|
||||||
.Dv SIGSTOP ,
|
|
||||||
.Dv SIGTERM ,
|
|
||||||
.Dv SIGTSTP ,
|
|
||||||
and
|
|
||||||
.Dv SIGWINCH .
|
|
||||||
Otherwise, the current signal handlers will be used.
|
|
||||||
.It Dv EL_BIND , Xo
|
|
||||||
.Fa "const char *" ,
|
|
||||||
.Fa "..." ,
|
|
||||||
.Dv NULL
|
|
||||||
.Xc
|
|
||||||
Perform the
|
|
||||||
.Ic bind
|
|
||||||
builtin command.
|
|
||||||
Refer to
|
|
||||||
.Xr editrc 5
|
|
||||||
for more information.
|
|
||||||
.It Dv EL_ECHOTC , Xo
|
|
||||||
.Fa "const char *" ,
|
|
||||||
.Fa "..." ,
|
|
||||||
.Dv NULL
|
|
||||||
.Xc
|
|
||||||
Perform the
|
|
||||||
.Ic echotc
|
|
||||||
builtin command.
|
|
||||||
Refer to
|
|
||||||
.Xr editrc 5
|
|
||||||
for more information.
|
|
||||||
.It Dv EL_SETTC , Xo
|
|
||||||
.Fa "const char *" ,
|
|
||||||
.Fa "..." ,
|
|
||||||
.Dv NULL
|
|
||||||
.Xc
|
|
||||||
Perform the
|
|
||||||
.Ic settc
|
|
||||||
builtin command.
|
|
||||||
Refer to
|
|
||||||
.Xr editrc 5
|
|
||||||
for more information.
|
|
||||||
.It Dv EL_SETTY , Xo
|
|
||||||
.Fa "const char *" ,
|
|
||||||
.Fa "..." ,
|
|
||||||
.Dv NULL
|
|
||||||
.Xc
|
|
||||||
Perform the
|
|
||||||
.Ic setty
|
|
||||||
builtin command.
|
|
||||||
Refer to
|
|
||||||
.Xr editrc 5
|
|
||||||
for more information.
|
|
||||||
.It Dv EL_TELLTC , Xo
|
|
||||||
.Fa "const char *" ,
|
|
||||||
.Fa "..." ,
|
|
||||||
.Dv NULL
|
|
||||||
.Xc
|
|
||||||
Perform the
|
|
||||||
.Ic telltc
|
|
||||||
builtin command.
|
|
||||||
Refer to
|
|
||||||
.Xr editrc 5
|
|
||||||
for more information.
|
|
||||||
.It Dv EL_ADDFN , Xo
|
|
||||||
.Fa "const char *name" ,
|
|
||||||
.Fa "const char *help" ,
|
|
||||||
.Fa "unsigned char (*func)(EditLine *e, int ch)
|
|
||||||
.Xc
|
|
||||||
Add a user defined function,
|
|
||||||
.Fn func ,
|
|
||||||
referred to as
|
|
||||||
.Fa name
|
|
||||||
which is invoked when a key which is bound to
|
|
||||||
.Fa name
|
|
||||||
is entered.
|
|
||||||
.Fa help
|
|
||||||
is a description of
|
|
||||||
.Fa name .
|
|
||||||
At invocation time,
|
|
||||||
.Fa ch
|
|
||||||
is the key which caused the invocation.
|
|
||||||
The return value of
|
|
||||||
.Fn func
|
|
||||||
should be one of:
|
|
||||||
.Bl -tag -width "CC_REDISPLAY"
|
|
||||||
.It Dv CC_NORM
|
|
||||||
Add a normal character.
|
|
||||||
.It Dv CC_NEWLINE
|
|
||||||
End of line was entered.
|
|
||||||
.It Dv CC_EOF
|
|
||||||
EOF was entered.
|
|
||||||
.It Dv CC_ARGHACK
|
|
||||||
Expecting further command input as arguments, do nothing visually.
|
|
||||||
.It Dv CC_REFRESH
|
|
||||||
Refresh display.
|
|
||||||
.It Dv CC_REFRESH_BEEP
|
|
||||||
Refresh display, and beep.
|
|
||||||
.It Dv CC_CURSOR
|
|
||||||
Cursor moved, so update and perform
|
|
||||||
.Dv CC_REFRESH.
|
|
||||||
.It Dv CC_REDISPLAY
|
|
||||||
Redisplay entire input line.
|
|
||||||
This is useful if a key binding outputs extra information.
|
|
||||||
.It Dv CC_ERROR
|
|
||||||
An error occurred.
|
|
||||||
Beep, and flush tty.
|
|
||||||
.It Dv CC_FATAL
|
|
||||||
Fatal error, reset tty to known state.
|
|
||||||
.El
|
|
||||||
.It Dv EL_HIST , Xo
|
|
||||||
.Fa "History *(*func)(History *, int op, ...)" ,
|
|
||||||
.Fa "const char *ptr"
|
|
||||||
.Xc
|
|
||||||
Defines which history function to use, which is usually
|
|
||||||
.Fn history .
|
|
||||||
.Fa ptr
|
|
||||||
should be the value returned by
|
|
||||||
.Fn history_init .
|
|
||||||
.It Dv EL_EDITMODE , Fa "int flag"
|
|
||||||
If
|
|
||||||
.Fa flag
|
|
||||||
is non-zero,
|
|
||||||
editing is enabled (the default).
|
|
||||||
Note that this is only an indication, and does not
|
|
||||||
affect the operation of
|
|
||||||
.Nm "" .
|
|
||||||
At this time, it is the caller's responsibility to
|
|
||||||
check this
|
|
||||||
(using
|
|
||||||
.Fn el_get )
|
|
||||||
to determine if editing should be enabled or not.
|
|
||||||
.El
|
|
||||||
.It Fn el_get
|
|
||||||
Get
|
|
||||||
.Nm
|
|
||||||
parameters.
|
|
||||||
.Fa op
|
|
||||||
determines which parameter to retrieve into
|
|
||||||
.Fa result .
|
|
||||||
.Pp
|
|
||||||
The following values for
|
|
||||||
.Fa op
|
|
||||||
are supported, along with actual type of
|
|
||||||
.Fa result :
|
|
||||||
.Bl -tag -width 4n
|
|
||||||
.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)"
|
|
||||||
Return a pointer to the function that displays the prompt.
|
|
||||||
.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)"
|
|
||||||
Return a pointer to the function that displays the rightside prompt.
|
|
||||||
.It Dv EL_EDITOR , Fa "const char *"
|
|
||||||
Return the name of the editor, which will be one of
|
|
||||||
.Dq emacs
|
|
||||||
or
|
|
||||||
.Dq vi .
|
|
||||||
.It Dv EL_SIGNAL , Fa "int *"
|
|
||||||
Return non-zero if
|
|
||||||
.Nm
|
|
||||||
has installed private signal handlers (see
|
|
||||||
.Fn el_get
|
|
||||||
above).
|
|
||||||
.It Dv EL_EDITMODE, Fa "int *"
|
|
||||||
Return non-zero if editing is enabled.
|
|
||||||
.El
|
|
||||||
.It Fn el_source
|
|
||||||
Initialise
|
|
||||||
.Nm
|
|
||||||
by reading the contents of
|
|
||||||
.Fa file .
|
|
||||||
.Fn el_parse
|
|
||||||
is called for each line in
|
|
||||||
.Fa file .
|
|
||||||
If
|
|
||||||
.Fa file
|
|
||||||
is
|
|
||||||
.Dv NULL ,
|
|
||||||
try
|
|
||||||
.Pa $PWD/.editrc
|
|
||||||
then
|
|
||||||
.Pa $HOME/.editrc .
|
|
||||||
Refer to
|
|
||||||
.Xr editrc 5
|
|
||||||
for details on the format of
|
|
||||||
.Fa file .
|
|
||||||
.It Fn el_resize
|
|
||||||
Must be called if the terminal size changes.
|
|
||||||
If
|
|
||||||
.Dv EL_SIGNAL
|
|
||||||
has been set with
|
|
||||||
.Fn el_set ,
|
|
||||||
then this is done automatically.
|
|
||||||
Otherwise, it's the responsibility of the application to call
|
|
||||||
.Fn el_resize
|
|
||||||
on the appropriate occasions.
|
|
||||||
.It Fn el_line
|
|
||||||
Return the editing information for the current line in a
|
|
||||||
.Fa LineInfo
|
|
||||||
structure, which is defined as follows:
|
|
||||||
.Bd -literal
|
|
||||||
typedef struct lineinfo {
|
|
||||||
const char *buffer; /* address of buffer */
|
|
||||||
const char *cursor; /* address of cursor */
|
|
||||||
const char *lastchar; /* address of last character */
|
|
||||||
} LineInfo;
|
|
||||||
.Ed
|
|
||||||
.It Fn el_insertstr
|
|
||||||
Insert
|
|
||||||
.Fa str
|
|
||||||
into the line at the cursor.
|
|
||||||
Returns -1 if
|
|
||||||
.Fa str
|
|
||||||
is empty or won't fit, and 0 otherwise.
|
|
||||||
.It Fn el_deletestr
|
|
||||||
Delete
|
|
||||||
.Fa num
|
|
||||||
characters before the cursor.
|
|
||||||
.El
|
|
||||||
.Sh HISTORY LIST FUNCTIONS
|
|
||||||
The history functions use a common data structure,
|
|
||||||
.Fa History ,
|
|
||||||
which is created by
|
|
||||||
.Fn history_init
|
|
||||||
and freed by
|
|
||||||
.Fn history_end .
|
|
||||||
.Pp
|
|
||||||
The following functions are available:
|
|
||||||
.Bl -tag -width 4n
|
|
||||||
.It Fn history_init
|
|
||||||
Initialise the history list, and return a data structure
|
|
||||||
to be used by all other history list functions.
|
|
||||||
.It Fn history_end
|
|
||||||
Clean up and finish with
|
|
||||||
.Fa h ,
|
|
||||||
assumed to have been created with
|
|
||||||
.Fn history_init .
|
|
||||||
.It Fn history
|
|
||||||
Perform operation
|
|
||||||
.Fa op
|
|
||||||
on the history list, with optional arguments as needed by the
|
|
||||||
operation.
|
|
||||||
.Fa ev
|
|
||||||
is changed accordingly to operation.
|
|
||||||
The following values for
|
|
||||||
.Fa op
|
|
||||||
are supported, along with the required argument list:
|
|
||||||
.Bl -tag -width 4n
|
|
||||||
.It Dv H_SETSIZE , Fa "int size"
|
|
||||||
Set size of history to
|
|
||||||
.Fa size
|
|
||||||
elements.
|
|
||||||
.It Dv H_GETSIZE
|
|
||||||
Get number of events currently in history.
|
|
||||||
.It Dv H_END
|
|
||||||
Cleans up and finishes with
|
|
||||||
.Fa h ,
|
|
||||||
assumed to be created with
|
|
||||||
.Fn history_init .
|
|
||||||
.It Dv H_CLEAR
|
|
||||||
Clear the history.
|
|
||||||
.It Dv H_FUNC , Xo
|
|
||||||
.Fa "void *ptr" ,
|
|
||||||
.Fa "history_gfun_t first" ,
|
|
||||||
.Fa "history_gfun_t next" ,
|
|
||||||
.Fa "history_gfun_t last" ,
|
|
||||||
.Fa "history_gfun_t prev" ,
|
|
||||||
.Fa "history_gfun_t curr" ,
|
|
||||||
.Fa "history_sfun_t set" ,
|
|
||||||
.Fa "history_vfun_t clear" ,
|
|
||||||
.Fa "history_efun_t enter" ,
|
|
||||||
.Fa "history_efun_t add"
|
|
||||||
.Xc
|
|
||||||
Define functions to perform various history operations.
|
|
||||||
.Fa ptr
|
|
||||||
is the argument given to a function when it's invoked.
|
|
||||||
.It Dv H_FIRST
|
|
||||||
Return the first element in the history.
|
|
||||||
.It Dv H_LAST
|
|
||||||
Return the last element in the history.
|
|
||||||
.It Dv H_PREV
|
|
||||||
Return the previous element in the history.
|
|
||||||
.It Dv H_NEXT
|
|
||||||
Return the next element in the history.
|
|
||||||
.It Dv H_CURR
|
|
||||||
Return the current element in the history.
|
|
||||||
.It Dv H_SET
|
|
||||||
Set the cursor to point to the requested element.
|
|
||||||
.It Dv H_ADD , Fa "const char *str"
|
|
||||||
Append
|
|
||||||
.Fa str
|
|
||||||
to the current element of the history, or create an element with
|
|
||||||
.It Dv H_APPEND , Fa "const char *str"
|
|
||||||
Append
|
|
||||||
.Fa str
|
|
||||||
to the last new element of the history.
|
|
||||||
.It Dv H_ENTER , Fa "const char *str"
|
|
||||||
Add
|
|
||||||
.Fa str
|
|
||||||
as a new element to the history, and, if necessary,
|
|
||||||
removing the oldest entry to keep the list to the created size.
|
|
||||||
.It Dv H_PREV_STR , Fa "const char *str"
|
|
||||||
Return the closest previous event that starts with
|
|
||||||
.Fa str .
|
|
||||||
.It Dv H_NEXT_STR , Fa "const char *str"
|
|
||||||
Return the closest next event that starts with
|
|
||||||
.Fa str .
|
|
||||||
.It Dv H_PREV_EVENT , Fa "int e"
|
|
||||||
Return the previous event numbered
|
|
||||||
.Fa e .
|
|
||||||
.It Dv H_NEXT_EVENT , Fa "int e"
|
|
||||||
Return the next event numbered
|
|
||||||
.Fa e .
|
|
||||||
.It Dv H_LOAD , Fa "const char *file"
|
|
||||||
Load the history list stored in
|
|
||||||
.Fa file .
|
|
||||||
.It Dv H_SAVE , Fa "const char *file"
|
|
||||||
Save the history list to
|
|
||||||
.Fa file .
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
.Fn history
|
|
||||||
returns 0 if the operation
|
|
||||||
.Fa op
|
|
||||||
succeeds. Otherwise, -1 is returned and
|
|
||||||
.Fa ev
|
|
||||||
is updated to contain more details about the error.
|
|
||||||
.El
|
|
||||||
.\"XXX.Sh EXAMPLES
|
|
||||||
.\"XXX: provide some examples
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr editrc 5 ,
|
|
||||||
.Xr sh 1 ,
|
|
||||||
.Xr signal 3 ,
|
|
||||||
.Xr termcap 3
|
|
||||||
.Sh HISTORY
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
library first appeared in
|
|
||||||
.Bx 4.4 .
|
|
||||||
.Dv CC_REDISPLAY
|
|
||||||
appeared in
|
|
||||||
.Nx 1.3 .
|
|
||||||
.Dv CC_REFRESH_BEEP ,
|
|
||||||
.Dv EL_EDITMODE
|
|
||||||
and the readline emulation appeared in
|
|
||||||
.Nx 1.4 .
|
|
||||||
.Dv EL_RPROMPT
|
|
||||||
appeared in
|
|
||||||
.Nx 1.5 .
|
|
||||||
.Sh AUTHORS
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
library was written by Christos Zoulas.
|
|
||||||
Luke Mewburn wrote this manual and implemented
|
|
||||||
.Dv CC_REDISPLAY ,
|
|
||||||
.Dv CC_REFRESH_BEEP ,
|
|
||||||
.Dv EL_EDITMODE ,
|
|
||||||
and
|
|
||||||
.Dv EL_RPROMPT .
|
|
||||||
Jaromir Dolecek implemented the readline emulation.
|
|
||||||
.Sh BUGS
|
|
||||||
The tokenization functions are not publically defined in
|
|
||||||
.Fd <histedit.h>.
|
|
||||||
.Pp
|
|
||||||
At this time, it is the responsibility of the caller to
|
|
||||||
check the result of the
|
|
||||||
.Dv EL_EDITMODE
|
|
||||||
operation of
|
|
||||||
.Fn el_get
|
|
||||||
(after an
|
|
||||||
.Fn el_source
|
|
||||||
or
|
|
||||||
.Fn el_parse )
|
|
||||||
to determine if
|
|
||||||
.Nm
|
|
||||||
should be used for further input.
|
|
||||||
I.e.,
|
|
||||||
.Dv EL_EDITMODE
|
|
||||||
is purely an indication of the result of the most recent
|
|
||||||
.Xr editrc 5
|
|
||||||
.Ic edit
|
|
||||||
command.
|
|
@ -1,491 +0,0 @@
|
|||||||
.\" $NetBSD: editrc.5,v 1.11 2001/06/19 13:42:09 wiz Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\" 3. All advertising materials mentioning features or use of this software
|
|
||||||
.\" must display the following acknowledgement:
|
|
||||||
.\" This product includes software developed by the NetBSD
|
|
||||||
.\" Foundation, Inc. and its contributors.
|
|
||||||
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
||||||
.\" contributors may be used to endorse or promote products derived
|
|
||||||
.\" from this software without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.Dd November 8, 2000
|
|
||||||
.Os
|
|
||||||
.Dt EDITRC 5
|
|
||||||
.Sh NAME
|
|
||||||
.Nm editrc
|
|
||||||
.Nd configuration file for editline library
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Nm
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
file defines various settings to be used by the
|
|
||||||
.Xr editline 3
|
|
||||||
library.
|
|
||||||
.Pp
|
|
||||||
The format of each line is:
|
|
||||||
.Dl [prog:]command [arg [...]]
|
|
||||||
.Pp
|
|
||||||
.Ar command
|
|
||||||
is one of the
|
|
||||||
.Xr editline 3
|
|
||||||
builtin commands.
|
|
||||||
Refer to
|
|
||||||
.Sx BUILTIN COMMANDS
|
|
||||||
for more information.
|
|
||||||
.Pp
|
|
||||||
.Ar prog
|
|
||||||
is the program name string that a program defines when it calls
|
|
||||||
.Xr el_init 3
|
|
||||||
to setup
|
|
||||||
.Xr editline 3 ,
|
|
||||||
which is usually
|
|
||||||
.Va argv[0] .
|
|
||||||
.Ar command
|
|
||||||
will be executed for any program which matches
|
|
||||||
.Ar prog .
|
|
||||||
.Pp
|
|
||||||
.Ar prog
|
|
||||||
may also be a
|
|
||||||
.Xr regex 3
|
|
||||||
style
|
|
||||||
regular expression, in which case
|
|
||||||
.Ar command
|
|
||||||
will be executed for any program that matches the regular expression.
|
|
||||||
.Pp
|
|
||||||
If
|
|
||||||
.Ar prog
|
|
||||||
is absent,
|
|
||||||
.Ar command
|
|
||||||
is executed for all programs.
|
|
||||||
.Sh BUILTIN COMMANDS
|
|
||||||
The
|
|
||||||
.Nm editline
|
|
||||||
library has some builtin commands, which affect the way
|
|
||||||
that the line editing and history functions operate.
|
|
||||||
These are based on similar named builtins present in the
|
|
||||||
.Xr tcsh 1
|
|
||||||
shell.
|
|
||||||
.Pp
|
|
||||||
The following builtin commands are available:
|
|
||||||
.Bl -tag -width 4n
|
|
||||||
.It Ic bind Xo
|
|
||||||
.Op Fl a
|
|
||||||
.Op Fl e
|
|
||||||
.Op Fl k
|
|
||||||
.Op Fl l
|
|
||||||
.Op Fl r
|
|
||||||
.Op Fl s
|
|
||||||
.Op Fl v
|
|
||||||
.Op Ar key Op Ar command
|
|
||||||
.Xc
|
|
||||||
Without options, list all bound keys, and the editor command to which
|
|
||||||
each is bound.
|
|
||||||
If
|
|
||||||
.Ar key
|
|
||||||
is supplied, show the bindings for
|
|
||||||
.Ar key .
|
|
||||||
If
|
|
||||||
.Ar key command
|
|
||||||
is supplied, bind
|
|
||||||
.Ar command
|
|
||||||
to
|
|
||||||
.Ar key .
|
|
||||||
Options include:
|
|
||||||
.Bl -tag -width 4n
|
|
||||||
.It Fl e
|
|
||||||
Bind all keys to the standard GNU Emacs-like bindings.
|
|
||||||
.It Fl v
|
|
||||||
Bind all keys to the standard
|
|
||||||
.Xr vi 1 -like
|
|
||||||
bindings.
|
|
||||||
.It Fl a
|
|
||||||
List or change key bindings in the
|
|
||||||
.Xr vi 1
|
|
||||||
mode alternate (command mode) key map.
|
|
||||||
.It Fl k
|
|
||||||
.Ar key
|
|
||||||
is interpreted as a symbolic arrow key name, which may be one of
|
|
||||||
.Sq up ,
|
|
||||||
.Sq down ,
|
|
||||||
.Sq left
|
|
||||||
or
|
|
||||||
.Sq right .
|
|
||||||
.It Fl l
|
|
||||||
List all editor commands and a short description of each.
|
|
||||||
.It Fl r
|
|
||||||
Remove a key's binding.
|
|
||||||
.It Fl s
|
|
||||||
.Ar command
|
|
||||||
is taken as a literal string and treated as terminal input when
|
|
||||||
.Ar key
|
|
||||||
is typed.
|
|
||||||
Bound keys in
|
|
||||||
.Ar command
|
|
||||||
are themselves reinterpreted, and this continues for ten levels of
|
|
||||||
interpretation.
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
.Ar command
|
|
||||||
may be one of the commands documented in
|
|
||||||
.Sx "EDITOR COMMANDS"
|
|
||||||
below, or another key.
|
|
||||||
.Pp
|
|
||||||
.Ar key
|
|
||||||
and
|
|
||||||
.Ar command
|
|
||||||
can contain control characters of the form
|
|
||||||
.Sm off
|
|
||||||
.Sq No ^ Ar character
|
|
||||||
.Sm on
|
|
||||||
.Po
|
|
||||||
e.g.
|
|
||||||
.Sq ^A
|
|
||||||
.Pc ,
|
|
||||||
and the following backslashed escape sequences:
|
|
||||||
.Pp
|
|
||||||
.Bl -tag -compact -offset indent -width 4n
|
|
||||||
.It Ic \ea
|
|
||||||
Bell
|
|
||||||
.It Ic \eb
|
|
||||||
Backspace
|
|
||||||
.It Ic \ee
|
|
||||||
Escape
|
|
||||||
.It Ic \ef
|
|
||||||
Formfeed
|
|
||||||
.It Ic \en
|
|
||||||
Newline
|
|
||||||
.It Ic \er
|
|
||||||
Carriage return
|
|
||||||
.It Ic \et
|
|
||||||
Horizontal tab
|
|
||||||
.It Ic \ev
|
|
||||||
Vertical tab
|
|
||||||
.Sm off
|
|
||||||
.It Sy \e Ar nnn
|
|
||||||
.Sm on
|
|
||||||
The ASCII character corresponding to the octal number
|
|
||||||
.Ar nnn .
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
.Sq \e
|
|
||||||
nullifies the special meaning of the following character,
|
|
||||||
if it has any, notably
|
|
||||||
.Sq \e
|
|
||||||
and
|
|
||||||
.Sq ^ .
|
|
||||||
.It Ic echotc Xo
|
|
||||||
.Op Fl sv
|
|
||||||
.Ar arg
|
|
||||||
.Ar ...
|
|
||||||
.Xc
|
|
||||||
Exercise terminal capabilities given in
|
|
||||||
.Ar arg Ar ... .
|
|
||||||
If
|
|
||||||
.Ar arg
|
|
||||||
is
|
|
||||||
.Sq baud ,
|
|
||||||
.Sq cols ,
|
|
||||||
.Sq lines ,
|
|
||||||
.Sq rows ,
|
|
||||||
.Sq meta or
|
|
||||||
.Sq tabs ,
|
|
||||||
the value of that capability is printed, with
|
|
||||||
.Dq yes
|
|
||||||
or
|
|
||||||
.Dq no
|
|
||||||
indicating that the terminal does or does not have that capability.
|
|
||||||
.Pp
|
|
||||||
.Fl s
|
|
||||||
returns an emptry string for non-existent capabilities, rather than
|
|
||||||
causing an error.
|
|
||||||
.Fl v
|
|
||||||
causes messages to be verbose.
|
|
||||||
.It Ic edit Op Li on | Li off
|
|
||||||
Enable or disable the
|
|
||||||
.Nm editline
|
|
||||||
functionality in a program.
|
|
||||||
.It Ic history
|
|
||||||
List the history.
|
|
||||||
.It Ic telltc
|
|
||||||
List the values of all the terminal capabilities (see
|
|
||||||
.Xr termcap 5 ).
|
|
||||||
.It Ic settc Ar cap Ar val
|
|
||||||
Set the terminal capability
|
|
||||||
.Ar cap
|
|
||||||
to
|
|
||||||
.Ar val ,
|
|
||||||
as defined in
|
|
||||||
.Xr termcap 5 .
|
|
||||||
No sanity checking is done.
|
|
||||||
.It Ic setty Xo
|
|
||||||
.Op Fl a
|
|
||||||
.Op Fl d
|
|
||||||
.Op Fl q
|
|
||||||
.Op Fl x
|
|
||||||
.Op Ar +mode
|
|
||||||
.Op Ar -mode
|
|
||||||
.Op Ar mode
|
|
||||||
.Xc
|
|
||||||
Control which tty modes that
|
|
||||||
.Nm
|
|
||||||
won't allow the user to change.
|
|
||||||
.Fl d ,
|
|
||||||
.Fl q
|
|
||||||
or
|
|
||||||
.Fl x
|
|
||||||
tells
|
|
||||||
.Ic setty
|
|
||||||
to act on the
|
|
||||||
.Sq edit ,
|
|
||||||
.Sq quote
|
|
||||||
or
|
|
||||||
.Sq execute
|
|
||||||
set of tty modes respectively; defaulting to
|
|
||||||
.Fl x .
|
|
||||||
.Pp
|
|
||||||
Without other arguments,
|
|
||||||
.Ic setty
|
|
||||||
lists the modes in the chosen set which are fixed on
|
|
||||||
.Po
|
|
||||||
.Sq +mode
|
|
||||||
.Pc
|
|
||||||
or off
|
|
||||||
.Po
|
|
||||||
.Sq -mode
|
|
||||||
.Pc .
|
|
||||||
.Fl a
|
|
||||||
lists all tty modes in the chosen set regardless of the setting.
|
|
||||||
With
|
|
||||||
.Ar +mode ,
|
|
||||||
.Ar -mode
|
|
||||||
or
|
|
||||||
.Ar mode ,
|
|
||||||
fixes
|
|
||||||
.Ar mode
|
|
||||||
on or off or removes control of
|
|
||||||
.Ar mode
|
|
||||||
in the chosen set.
|
|
||||||
.El
|
|
||||||
.Sh EDITOR COMMANDS
|
|
||||||
The following editor commands are available for use in key bindings:
|
|
||||||
.\" Section automatically generated with makelist
|
|
||||||
.Bl -tag -width 4n
|
|
||||||
.It Ic vi-paste-next
|
|
||||||
Vi paste previous deletion to the right of the cursor.
|
|
||||||
.It Ic vi-paste-prev
|
|
||||||
Vi paste previous deletion to the left of the cursor.
|
|
||||||
.It Ic vi-prev-space-word
|
|
||||||
Vi move to the previous space delimited word.
|
|
||||||
.It Ic vi-prev-word
|
|
||||||
Vi move to the previous word.
|
|
||||||
.It Ic vi-next-space-word
|
|
||||||
Vi move to the next space delimited word.
|
|
||||||
.It Ic vi-next-word
|
|
||||||
Vi move to the next word.
|
|
||||||
.It Ic vi-change-case
|
|
||||||
Vi change case of character under the cursor and advance one character.
|
|
||||||
.It Ic vi-change-meta
|
|
||||||
Vi change prefix command.
|
|
||||||
.It Ic vi-insert-at-bol
|
|
||||||
Vi enter insert mode at the beginning of line.
|
|
||||||
.It Ic vi-replace-char
|
|
||||||
Vi replace character under the cursor with the next character typed.
|
|
||||||
.It Ic vi-replace-mode
|
|
||||||
Vi enter replace mode.
|
|
||||||
.It Ic vi-substitute-char
|
|
||||||
Vi replace character under the cursor and enter insert mode.
|
|
||||||
.It Ic vi-substitute-line
|
|
||||||
Vi substitute entire line.
|
|
||||||
.It Ic vi-change-to-eol
|
|
||||||
Vi change to end of line.
|
|
||||||
.It Ic vi-insert
|
|
||||||
Vi enter insert mode.
|
|
||||||
.It Ic vi-add
|
|
||||||
Vi enter insert mode after the cursor.
|
|
||||||
.It Ic vi-add-at-eol
|
|
||||||
Vi enter insert mode at end of line.
|
|
||||||
.It Ic vi-delete-meta
|
|
||||||
Vi delete prefix command.
|
|
||||||
.It Ic vi-end-word
|
|
||||||
Vi move to the end of the current space delimited word.
|
|
||||||
.It Ic vi-to-end-word
|
|
||||||
Vi move to the end of the current word.
|
|
||||||
.It Ic vi-undo
|
|
||||||
Vi undo last change.
|
|
||||||
.It Ic vi-command-mode
|
|
||||||
Vi enter command mode (use alternative key bindings).
|
|
||||||
.It Ic vi-zero
|
|
||||||
Vi move to the beginning of line.
|
|
||||||
.It Ic vi-delete-prev-char
|
|
||||||
Vi move to previous character (backspace).
|
|
||||||
.It Ic vi-list-or-eof
|
|
||||||
Vi list choices for completion or indicate end of file if empty line.
|
|
||||||
.It Ic vi-kill-line-prev
|
|
||||||
Vi cut from beginning of line to cursor.
|
|
||||||
.It Ic vi-search-prev
|
|
||||||
Vi search history previous.
|
|
||||||
.It Ic vi-search-next
|
|
||||||
Vi search history next.
|
|
||||||
.It Ic vi-repeat-search-next
|
|
||||||
Vi repeat current search in the same search direction.
|
|
||||||
.It Ic vi-repeat-search-prev
|
|
||||||
Vi repeat current search in the opposite search direction.
|
|
||||||
.It Ic vi-next-char
|
|
||||||
Vi move to the character specified next.
|
|
||||||
.It Ic vi-prev-char
|
|
||||||
Vi move to the character specified previous.
|
|
||||||
.It Ic vi-to-next-char
|
|
||||||
Vi move up to the character specified next.
|
|
||||||
.It Ic vi-to-prev-char
|
|
||||||
Vi move up to the character specified previous.
|
|
||||||
.It Ic vi-repeat-next-char
|
|
||||||
Vi repeat current character search in the same search direction.
|
|
||||||
.It Ic vi-repeat-prev-char
|
|
||||||
Vi repeat current character search in the opposite search direction.
|
|
||||||
.It Ic em-delete-or-list
|
|
||||||
Delete character under cursor or list completions if at end of line.
|
|
||||||
.It Ic em-delete-next-word
|
|
||||||
Cut from cursor to end of current word.
|
|
||||||
.It Ic em-yank
|
|
||||||
Paste cut buffer at cursor position.
|
|
||||||
.It Ic em-kill-line
|
|
||||||
Cut the entire line and save in cut buffer.
|
|
||||||
.It Ic em-kill-region
|
|
||||||
Cut area between mark and cursor and save in cut buffer.
|
|
||||||
.It Ic em-copy-region
|
|
||||||
Copy area between mark and cursor to cut buffer.
|
|
||||||
.It Ic em-gosmacs-traspose
|
|
||||||
Exchange the two characters before the cursor.
|
|
||||||
.It Ic em-next-word
|
|
||||||
Move next to end of current word.
|
|
||||||
.It Ic em-upper-case
|
|
||||||
Uppercase the characters from cursor to end of current word.
|
|
||||||
.It Ic em-capitol-case
|
|
||||||
Capitalize the characters from cursor to end of current word.
|
|
||||||
.It Ic em-lower-case
|
|
||||||
Lowercase the characters from cursor to end of current word.
|
|
||||||
.It Ic em-set-mark
|
|
||||||
Set the mark at cursor.
|
|
||||||
.It Ic em-exchange-mark
|
|
||||||
Exchange the cursor and mark.
|
|
||||||
.It Ic em-universal-argument
|
|
||||||
Universal argument (argument times 4).
|
|
||||||
.It Ic em-meta-next
|
|
||||||
Add 8th bit to next character typed.
|
|
||||||
.It Ic em-toggle-overwrite
|
|
||||||
Switch from insert to overwrite mode or vice versa.
|
|
||||||
.It Ic em-copy-prev-word
|
|
||||||
Copy current word to cursor.
|
|
||||||
.It Ic em-inc-search-next
|
|
||||||
Emacs incremental next search.
|
|
||||||
.It Ic em-inc-search-prev
|
|
||||||
Emacs incremental reverse search.
|
|
||||||
.It Ic ed-end-of-file
|
|
||||||
Indicate end of file.
|
|
||||||
.It Ic ed-insert
|
|
||||||
Add character to the line.
|
|
||||||
.It Ic ed-delete-prev-word
|
|
||||||
Delete from beginning of current word to cursor.
|
|
||||||
.It Ic ed-delete-next-char
|
|
||||||
Delete character under cursor.
|
|
||||||
.It Ic ed-kill-line
|
|
||||||
Cut to the end of line.
|
|
||||||
.It Ic ed-move-to-end
|
|
||||||
Move cursor to the end of line.
|
|
||||||
.It Ic ed-move-to-beg
|
|
||||||
Move cursor to the beginning of line.
|
|
||||||
.It Ic ed-transpose-chars
|
|
||||||
Exchange the character to the left of the cursor with the one under it.
|
|
||||||
.It Ic ed-next-char
|
|
||||||
Move to the right one character.
|
|
||||||
.It Ic ed-prev-word
|
|
||||||
Move to the beginning of the current word.
|
|
||||||
.It Ic ed-prev-char
|
|
||||||
Move to the left one character.
|
|
||||||
.It Ic ed-quoted-insert
|
|
||||||
Add the next character typed verbatim.
|
|
||||||
.It Ic ed-digit
|
|
||||||
Adds to argument or enters a digit.
|
|
||||||
.It Ic ed-argument-digit
|
|
||||||
Digit that starts argument.
|
|
||||||
.It Ic ed-unassigned
|
|
||||||
Indicates unbound character.
|
|
||||||
.It Ic ed-tty-sigint
|
|
||||||
Tty interrupt character.
|
|
||||||
.It Ic ed-tty-dsusp
|
|
||||||
Tty delayed suspend character.
|
|
||||||
.It Ic ed-tty-flush-output
|
|
||||||
Tty flush output characters.
|
|
||||||
.It Ic ed-tty-sigquit
|
|
||||||
Tty quit character.
|
|
||||||
.It Ic ed-tty-sigtstp
|
|
||||||
Tty suspend character.
|
|
||||||
.It Ic ed-tty-stop-output
|
|
||||||
Tty disallow output characters.
|
|
||||||
.It Ic ed-tty-start-output
|
|
||||||
Tty allow output characters.
|
|
||||||
.It Ic ed-newline
|
|
||||||
Execute command.
|
|
||||||
.It Ic ed-delete-prev-char
|
|
||||||
Delete the character to the left of the cursor.
|
|
||||||
.It Ic ed-clear-screen
|
|
||||||
Clear screen leaving current line at the top.
|
|
||||||
.It Ic ed-redisplay
|
|
||||||
Redisplay everything.
|
|
||||||
.It Ic ed-start-over
|
|
||||||
Erase current line and start from scratch.
|
|
||||||
.It Ic ed-sequence-lead-in
|
|
||||||
First character in a bound sequence.
|
|
||||||
.It Ic ed-prev-history
|
|
||||||
Move to the previous history line.
|
|
||||||
.It Ic ed-next-history
|
|
||||||
Move to the next history line.
|
|
||||||
.It Ic ed-search-prev-history
|
|
||||||
Search previous in history for a line matching the current.
|
|
||||||
.It Ic ed-search-next-history
|
|
||||||
Search next in history for a line matching the current.
|
|
||||||
.It Ic ed-prev-line
|
|
||||||
Move up one line.
|
|
||||||
.It Ic ed-next-line
|
|
||||||
Move down one line.
|
|
||||||
.It Ic ed-command
|
|
||||||
Editline extended command.
|
|
||||||
.El
|
|
||||||
.\" End of section automatically generated with makelist
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr editline 3 ,
|
|
||||||
.Xr regex 3 ,
|
|
||||||
.Xr termcap 5
|
|
||||||
.Sh AUTHORS
|
|
||||||
The
|
|
||||||
.Nm editline
|
|
||||||
library was written by Christos Zoulas,
|
|
||||||
and this manual was written by Luke Mewburn,
|
|
||||||
with some sections inspired by
|
|
||||||
.Xr tcsh 1 .
|
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: el.c,v 1.39 2004/07/08 00:51:36 christos Exp $ */
|
/* $NetBSD: el.c,v 1.47 2009/01/18 12:17:24 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* el.c: EditLine interface functions
|
* el.c: EditLine interface functions
|
||||||
@ -58,9 +64,12 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
|
|||||||
|
|
||||||
memset(el, 0, sizeof(EditLine));
|
memset(el, 0, sizeof(EditLine));
|
||||||
|
|
||||||
el->el_infd = fileno(fin);
|
el->el_infile = fin;
|
||||||
el->el_outfile = fout;
|
el->el_outfile = fout;
|
||||||
el->el_errfile = ferr;
|
el->el_errfile = ferr;
|
||||||
|
|
||||||
|
el->el_infd = fileno(fin);
|
||||||
|
|
||||||
if ((el->el_prog = el_strdup(prog)) == NULL) {
|
if ((el->el_prog = el_strdup(prog)) == NULL) {
|
||||||
el_free(el);
|
el_free(el);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -126,7 +135,7 @@ el_reset(EditLine *el)
|
|||||||
{
|
{
|
||||||
|
|
||||||
tty_cookedmode(el);
|
tty_cookedmode(el);
|
||||||
ch_reset(el); /* XXX: Do we want that? */
|
ch_reset(el, 0); /* XXX: Do we want that? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,29 +145,29 @@ el_reset(EditLine *el)
|
|||||||
public int
|
public int
|
||||||
el_set(EditLine *el, int op, ...)
|
el_set(EditLine *el, int op, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list ap;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
if (el == NULL)
|
if (el == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
va_start(va, op);
|
va_start(ap, op);
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case EL_PROMPT:
|
case EL_PROMPT:
|
||||||
case EL_RPROMPT:
|
case EL_RPROMPT:
|
||||||
rv = prompt_set(el, va_arg(va, el_pfunc_t), op);
|
rv = prompt_set(el, va_arg(ap, el_pfunc_t), op);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_TERMINAL:
|
case EL_TERMINAL:
|
||||||
rv = term_set(el, va_arg(va, char *));
|
rv = term_set(el, va_arg(ap, char *));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_EDITOR:
|
case EL_EDITOR:
|
||||||
rv = map_set_editor(el, va_arg(va, char *));
|
rv = map_set_editor(el, va_arg(ap, char *));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_SIGNAL:
|
case EL_SIGNAL:
|
||||||
if (va_arg(va, int))
|
if (va_arg(ap, int))
|
||||||
el->el_flags |= HANDLE_SIGNALS;
|
el->el_flags |= HANDLE_SIGNALS;
|
||||||
else
|
else
|
||||||
el->el_flags &= ~HANDLE_SIGNALS;
|
el->el_flags &= ~HANDLE_SIGNALS;
|
||||||
@ -167,6 +176,7 @@ el_set(EditLine *el, int op, ...)
|
|||||||
case EL_BIND:
|
case EL_BIND:
|
||||||
case EL_TELLTC:
|
case EL_TELLTC:
|
||||||
case EL_SETTC:
|
case EL_SETTC:
|
||||||
|
case EL_GETTC:
|
||||||
case EL_ECHOTC:
|
case EL_ECHOTC:
|
||||||
case EL_SETTY:
|
case EL_SETTY:
|
||||||
{
|
{
|
||||||
@ -174,7 +184,7 @@ el_set(EditLine *el, int op, ...)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < 20; i++)
|
for (i = 1; i < 20; i++)
|
||||||
if ((argv[i] = va_arg(va, char *)) == NULL)
|
if ((argv[i] = va_arg(ap, char *)) == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
@ -213,9 +223,9 @@ el_set(EditLine *el, int op, ...)
|
|||||||
|
|
||||||
case EL_ADDFN:
|
case EL_ADDFN:
|
||||||
{
|
{
|
||||||
char *name = va_arg(va, char *);
|
char *name = va_arg(ap, char *);
|
||||||
char *help = va_arg(va, char *);
|
char *help = va_arg(ap, char *);
|
||||||
el_func_t func = va_arg(va, el_func_t);
|
el_func_t func = va_arg(ap, el_func_t);
|
||||||
|
|
||||||
rv = map_addfunc(el, name, help, func);
|
rv = map_addfunc(el, name, help, func);
|
||||||
break;
|
break;
|
||||||
@ -223,15 +233,15 @@ el_set(EditLine *el, int op, ...)
|
|||||||
|
|
||||||
case EL_HIST:
|
case EL_HIST:
|
||||||
{
|
{
|
||||||
hist_fun_t func = va_arg(va, hist_fun_t);
|
hist_fun_t func = va_arg(ap, hist_fun_t);
|
||||||
ptr_t ptr = va_arg(va, char *);
|
ptr_t ptr = va_arg(ap, char *);
|
||||||
|
|
||||||
rv = hist_set(el, func, ptr);
|
rv = hist_set(el, func, ptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case EL_EDITMODE:
|
case EL_EDITMODE:
|
||||||
if (va_arg(va, int))
|
if (va_arg(ap, int))
|
||||||
el->el_flags &= ~EDIT_DISABLED;
|
el->el_flags &= ~EDIT_DISABLED;
|
||||||
else
|
else
|
||||||
el->el_flags |= EDIT_DISABLED;
|
el->el_flags |= EDIT_DISABLED;
|
||||||
@ -240,17 +250,17 @@ el_set(EditLine *el, int op, ...)
|
|||||||
|
|
||||||
case EL_GETCFN:
|
case EL_GETCFN:
|
||||||
{
|
{
|
||||||
el_rfunc_t rc = va_arg(va, el_rfunc_t);
|
el_rfunc_t rc = va_arg(ap, el_rfunc_t);
|
||||||
rv = el_read_setfn(el, rc);
|
rv = el_read_setfn(el, rc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case EL_CLIENTDATA:
|
case EL_CLIENTDATA:
|
||||||
el->el_data = va_arg(va, void *);
|
el->el_data = va_arg(ap, void *);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_UNBUFFERED:
|
case EL_UNBUFFERED:
|
||||||
rv = va_arg(va, int);
|
rv = va_arg(ap, int);
|
||||||
if (rv && !(el->el_flags & UNBUFFERED)) {
|
if (rv && !(el->el_flags & UNBUFFERED)) {
|
||||||
el->el_flags |= UNBUFFERED;
|
el->el_flags |= UNBUFFERED;
|
||||||
read_prepare(el);
|
read_prepare(el);
|
||||||
@ -262,7 +272,7 @@ el_set(EditLine *el, int op, ...)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_PREP_TERM:
|
case EL_PREP_TERM:
|
||||||
rv = va_arg(va, int);
|
rv = va_arg(ap, int);
|
||||||
if (rv)
|
if (rv)
|
||||||
(void) tty_rawmode(el);
|
(void) tty_rawmode(el);
|
||||||
else
|
else
|
||||||
@ -270,12 +280,45 @@ el_set(EditLine *el, int op, ...)
|
|||||||
rv = 0;
|
rv = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EL_SETFP:
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
int what;
|
||||||
|
|
||||||
|
what = va_arg(ap, int);
|
||||||
|
fp = va_arg(ap, FILE *);
|
||||||
|
|
||||||
|
rv = 0;
|
||||||
|
switch (what) {
|
||||||
|
case 0:
|
||||||
|
el->el_infile = fp;
|
||||||
|
el->el_infd = fileno(fp);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
el->el_outfile = fp;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
el->el_errfile = fp;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
rv = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case EL_REFRESH:
|
||||||
|
re_clear_display(el);
|
||||||
|
re_refresh(el);
|
||||||
|
term__flush(el);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rv = -1;
|
rv = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(va);
|
va_end(ap);
|
||||||
return (rv);
|
return (rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,90 +327,71 @@ el_set(EditLine *el, int op, ...)
|
|||||||
* retrieve the editline parameters
|
* retrieve the editline parameters
|
||||||
*/
|
*/
|
||||||
public int
|
public int
|
||||||
el_get(EditLine *el, int op, void *ret)
|
el_get(EditLine *el, int op, ...)
|
||||||
{
|
{
|
||||||
|
va_list ap;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (el == NULL || ret == NULL)
|
if (el == NULL)
|
||||||
return (-1);
|
return -1;
|
||||||
|
|
||||||
|
va_start(ap, op);
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case EL_PROMPT:
|
case EL_PROMPT:
|
||||||
case EL_RPROMPT:
|
case EL_RPROMPT:
|
||||||
rv = prompt_get(el, (void *) &ret, op);
|
rv = prompt_get(el, va_arg(ap, el_pfunc_t *), op);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_EDITOR:
|
case EL_EDITOR:
|
||||||
rv = map_get_editor(el, (void *) &ret);
|
rv = map_get_editor(el, va_arg(ap, const char **));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_SIGNAL:
|
case EL_SIGNAL:
|
||||||
*((int *) ret) = (el->el_flags & HANDLE_SIGNALS);
|
*va_arg(ap, int *) = (el->el_flags & HANDLE_SIGNALS);
|
||||||
rv = 0;
|
rv = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_EDITMODE:
|
case EL_EDITMODE:
|
||||||
*((int *) ret) = (!(el->el_flags & EDIT_DISABLED));
|
*va_arg(ap, int *) = !(el->el_flags & EDIT_DISABLED);
|
||||||
rv = 0;
|
rv = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_TERMINAL:
|
case EL_TERMINAL:
|
||||||
term_get(el, (const char **)ret);
|
term_get(el, va_arg(ap, const char **));
|
||||||
rv = 0;
|
rv = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if 0 /* XXX */
|
case EL_GETTC:
|
||||||
case EL_BIND:
|
|
||||||
case EL_TELLTC:
|
|
||||||
case EL_SETTC:
|
|
||||||
case EL_ECHOTC:
|
|
||||||
case EL_SETTY:
|
|
||||||
{
|
{
|
||||||
const char *argv[20];
|
static char name[] = "gettc";
|
||||||
|
char *argv[20];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++)
|
for (i = 1; i < (int)(sizeof(argv) / sizeof(argv[0])); i++)
|
||||||
if ((argv[i] = va_arg(va, char *)) == NULL)
|
if ((argv[i] = va_arg(ap, char *)) == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case EL_BIND:
|
case EL_GETTC:
|
||||||
argv[0] = "bind";
|
argv[0] = name;
|
||||||
rv = map_bind(el, i, argv);
|
rv = term_gettc(el, i, argv);
|
||||||
break;
|
|
||||||
|
|
||||||
case EL_TELLTC:
|
|
||||||
argv[0] = "telltc";
|
|
||||||
rv = term_telltc(el, i, argv);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EL_SETTC:
|
|
||||||
argv[0] = "settc";
|
|
||||||
rv = term_settc(el, i, argv);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EL_ECHOTC:
|
|
||||||
argv[0] = "echotc";
|
|
||||||
rv = term_echotc(el, i, argv);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EL_SETTY:
|
|
||||||
argv[0] = "setty";
|
|
||||||
rv = tty_stty(el, i, argv);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rv = -1;
|
rv = -1;
|
||||||
EL_ABORT((el->errfile, "Bad op %d\n", op));
|
EL_ABORT((el->el_errfile, "Bad op %d\n", op));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 /* XXX */
|
||||||
case EL_ADDFN:
|
case EL_ADDFN:
|
||||||
{
|
{
|
||||||
char *name = va_arg(va, char *);
|
char *name = va_arg(ap, char *);
|
||||||
char *help = va_arg(va, char *);
|
char *help = va_arg(ap, char *);
|
||||||
el_func_t func = va_arg(va, el_func_t);
|
el_func_t func = va_arg(ap, el_func_t);
|
||||||
|
|
||||||
rv = map_addfunc(el, name, help, func);
|
rv = map_addfunc(el, name, help, func);
|
||||||
break;
|
break;
|
||||||
@ -375,31 +399,57 @@ el_get(EditLine *el, int op, void *ret)
|
|||||||
|
|
||||||
case EL_HIST:
|
case EL_HIST:
|
||||||
{
|
{
|
||||||
hist_fun_t func = va_arg(va, hist_fun_t);
|
hist_fun_t func = va_arg(ap, hist_fun_t);
|
||||||
ptr_t ptr = va_arg(va, char *);
|
ptr_t ptr = va_arg(ap, char *);
|
||||||
rv = hist_set(el, func, ptr);
|
rv = hist_set(el, func, ptr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* XXX */
|
#endif /* XXX */
|
||||||
|
|
||||||
case EL_GETCFN:
|
case EL_GETCFN:
|
||||||
*((el_rfunc_t *)ret) = el_read_getfn(el);
|
*va_arg(ap, el_rfunc_t *) = el_read_getfn(el);
|
||||||
rv = 0;
|
rv = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_CLIENTDATA:
|
case EL_CLIENTDATA:
|
||||||
*((void **)ret) = el->el_data;
|
*va_arg(ap, void **) = el->el_data;
|
||||||
rv = 0;
|
rv = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EL_UNBUFFERED:
|
case EL_UNBUFFERED:
|
||||||
*((int *) ret) = (!(el->el_flags & UNBUFFERED));
|
*va_arg(ap, int *) = (!(el->el_flags & UNBUFFERED));
|
||||||
rv = 0;
|
rv = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EL_GETFP:
|
||||||
|
{
|
||||||
|
int what;
|
||||||
|
FILE **fpp;
|
||||||
|
|
||||||
|
what = va_arg(ap, int);
|
||||||
|
fpp = va_arg(ap, FILE **);
|
||||||
|
rv = 0;
|
||||||
|
switch (what) {
|
||||||
|
case 0:
|
||||||
|
*fpp = el->el_infile;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
*fpp = el->el_outfile;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
*fpp = el->el_errfile;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
rv = -1;
|
rv = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
rv = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
return (rv);
|
return (rv);
|
||||||
}
|
}
|
||||||
@ -428,17 +478,17 @@ el_source(EditLine *el, const char *fname)
|
|||||||
|
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
if (fname == NULL) {
|
if (fname == NULL) {
|
||||||
|
#ifdef HAVE_ISSETUGID
|
||||||
static const char elpath[] = "/.editrc";
|
static const char elpath[] = "/.editrc";
|
||||||
|
/* XXXMYSQL: Portability fix (for which platforms?) */
|
||||||
#ifdef MAXPATHLEN
|
#ifdef MAXPATHLEN
|
||||||
char path[MAXPATHLEN];
|
char path[MAXPATHLEN];
|
||||||
#else
|
#else
|
||||||
char path[4096];
|
char path[4096];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ISSETUGID
|
|
||||||
if (issetugid())
|
if (issetugid())
|
||||||
return (-1);
|
return (-1);
|
||||||
#endif
|
|
||||||
if ((ptr = getenv("HOME")) == NULL)
|
if ((ptr = getenv("HOME")) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path))
|
if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path))
|
||||||
@ -446,6 +496,14 @@ el_source(EditLine *el, const char *fname)
|
|||||||
if (strlcat(path, elpath, sizeof(path)) >= sizeof(path))
|
if (strlcat(path, elpath, sizeof(path)) >= sizeof(path))
|
||||||
return (-1);
|
return (-1);
|
||||||
fname = path;
|
fname = path;
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* If issetugid() is missing, always return an error, in order
|
||||||
|
* to keep from inadvertently opening up the user to a security
|
||||||
|
* hole.
|
||||||
|
*/
|
||||||
|
return (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
fp = fopen(fname, "r");
|
fp = fopen(fname, "r");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: el.h,v 1.16 2003/10/18 23:48:42 christos Exp $ */
|
/* $NetBSD: el.h,v 1.17 2006/12/15 22:13:33 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -110,6 +110,7 @@ typedef struct el_state_t {
|
|||||||
|
|
||||||
struct editline {
|
struct editline {
|
||||||
char *el_prog; /* the program name */
|
char *el_prog; /* the program name */
|
||||||
|
FILE *el_infile; /* Stdio stuff */
|
||||||
FILE *el_outfile; /* Stdio stuff */
|
FILE *el_outfile; /* Stdio stuff */
|
||||||
FILE *el_errfile; /* Stdio stuff */
|
FILE *el_errfile; /* Stdio stuff */
|
||||||
int el_infd; /* Input file descriptor */
|
int el_infd; /* Input file descriptor */
|
||||||
@ -136,6 +137,7 @@ struct editline {
|
|||||||
|
|
||||||
protected int el_editmode(EditLine *, int, const char **);
|
protected int el_editmode(EditLine *, int, const char **);
|
||||||
|
|
||||||
|
/* XXXMYSQL: Bug#23097 mysql can't insert korean on mysql prompt. */
|
||||||
#define el_isprint(x) ((unsigned char) (x) < 0x80 ? isprint(x) : 1)
|
#define el_isprint(x) ((unsigned char) (x) < 0x80 ? isprint(x) : 1)
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: term.h,v 1.15 2003/09/14 21:48:55 christos Exp $ */
|
/* $NetBSD: term.h,v 1.19 2008/09/10 15:45:37 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -81,25 +81,6 @@ typedef struct {
|
|||||||
#define A_K_EN 5
|
#define A_K_EN 5
|
||||||
#define A_K_NKEYS 6
|
#define A_K_NKEYS 6
|
||||||
|
|
||||||
#ifdef _SUNOS
|
|
||||||
extern int tgetent(char *, const char *);
|
|
||||||
extern int tgetflag(char *);
|
|
||||||
extern int tgetnum(char *);
|
|
||||||
extern int tputs(const char *, int, int (*)(int));
|
|
||||||
extern char* tgoto(const char*, int, int);
|
|
||||||
extern char* tgetstr(char*, char**);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if !HAVE_DECL_TGOTO
|
|
||||||
/*
|
|
||||||
'tgoto' is not declared in the system header files, this causes
|
|
||||||
problems on 64-bit systems. The function returns a 64 bit pointer
|
|
||||||
but caller see it as "int" and it's thus truncated to 32-bit
|
|
||||||
*/
|
|
||||||
extern char* tgoto(const char*, int, int);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected void term_move_to_line(EditLine *, int);
|
protected void term_move_to_line(EditLine *, int);
|
||||||
protected void term_move_to_char(EditLine *, int);
|
protected void term_move_to_char(EditLine *, int);
|
||||||
protected void term_clear_EOL(EditLine *, int);
|
protected void term_clear_EOL(EditLine *, int);
|
||||||
@ -119,10 +100,12 @@ protected void term_end(EditLine *);
|
|||||||
protected void term_get(EditLine *, const char **);
|
protected void term_get(EditLine *, const char **);
|
||||||
protected int term_set(EditLine *, const char *);
|
protected int term_set(EditLine *, const char *);
|
||||||
protected int term_settc(EditLine *, int, const char **);
|
protected int term_settc(EditLine *, int, const char **);
|
||||||
|
protected int term_gettc(EditLine *, int, char **);
|
||||||
protected int term_telltc(EditLine *, int, const char **);
|
protected int term_telltc(EditLine *, int, const char **);
|
||||||
protected int term_echotc(EditLine *, int, const char **);
|
protected int term_echotc(EditLine *, int, const char **);
|
||||||
protected int term__putc(int);
|
protected void term_writec(EditLine *, int);
|
||||||
protected void term__flush(void);
|
protected int term__putc(EditLine *, int);
|
||||||
|
protected void term__flush(EditLine *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Easy access macros
|
* Easy access macros
|
||||||
@ -134,6 +117,7 @@ protected void term__flush(void);
|
|||||||
#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL)
|
#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL)
|
||||||
#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB)
|
#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB)
|
||||||
#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME)
|
#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME)
|
||||||
|
#define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP)
|
||||||
#define EL_HAS_META (EL_FLAGS & TERM_HAS_META)
|
#define EL_HAS_META (EL_FLAGS & TERM_HAS_META)
|
||||||
#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS)
|
#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS)
|
||||||
#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS)
|
#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: emacs.c,v 1.19 2004/10/28 21:14:52 dsl Exp $ */
|
/* $NetBSD: emacs.c,v 1.21 2006/03/06 21:11:56 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* emacs.c: Emacs functions
|
* emacs.c: Emacs functions
|
||||||
@ -45,15 +51,14 @@
|
|||||||
*/
|
*/
|
||||||
protected el_action_t
|
protected el_action_t
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
em_delete_or_list(EditLine *el, int c __attribute__((__unused__)))
|
em_delete_or_list(EditLine *el, int c)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (el->el_line.cursor == el->el_line.lastchar) {
|
if (el->el_line.cursor == el->el_line.lastchar) {
|
||||||
/* if I'm at the end */
|
/* if I'm at the end */
|
||||||
if (el->el_line.cursor == el->el_line.buffer) {
|
if (el->el_line.cursor == el->el_line.buffer) {
|
||||||
/* and the beginning */
|
/* and the beginning */
|
||||||
term_overwrite(el, STReof, 4); /* then do a EOF */
|
term_writec(el, c); /* then do an EOF */
|
||||||
term__flush();
|
|
||||||
return (CC_EOF);
|
return (CC_EOF);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
char *fgetln(FILE *stream, size_t *len);
|
|
558
cmd-line-utils/libedit/filecomplete.c
Normal file
558
cmd-line-utils/libedit/filecomplete.c
Normal file
@ -0,0 +1,558 @@
|
|||||||
|
/* $NetBSD: filecomplete.c,v 1.13 2009/01/26 17:32:41 apb Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Jaromir Dolecek.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* AIX requires this to be the first thing in the file. */
|
||||||
|
#if defined (_AIX) && !defined (__GNUC__)
|
||||||
|
#pragma alloca
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
/* XXXMYSQL */
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# undef alloca
|
||||||
|
# define alloca(n) __builtin_alloca (n)
|
||||||
|
#else
|
||||||
|
# ifdef HAVE_ALLOCA_H
|
||||||
|
# include <alloca.h>
|
||||||
|
# else
|
||||||
|
# ifndef _AIX
|
||||||
|
extern char *alloca ();
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#ifdef HAVE_VIS_H
|
||||||
|
#include <vis.h>
|
||||||
|
#else
|
||||||
|
#include "np/vis.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ALLOCA_H
|
||||||
|
#include <alloca.h>
|
||||||
|
#endif
|
||||||
|
#include "el.h"
|
||||||
|
#include "fcns.h" /* for EL_NUM_FCNS */
|
||||||
|
#include "histedit.h"
|
||||||
|
#include "filecomplete.h"
|
||||||
|
|
||||||
|
static char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', '$',
|
||||||
|
'>', '<', '=', ';', '|', '&', '{', '(', '\0' };
|
||||||
|
|
||||||
|
|
||||||
|
/********************************/
|
||||||
|
/* completion functions */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* does tilde expansion of strings of type ``~user/foo''
|
||||||
|
* if ``user'' isn't valid user name or ``txt'' doesn't start
|
||||||
|
* w/ '~', returns pointer to strdup()ed copy of ``txt''
|
||||||
|
*
|
||||||
|
* it's callers's responsibility to free() returned string
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
fn_tilde_expand(const char *txt)
|
||||||
|
{
|
||||||
|
struct passwd pwres, *pass;
|
||||||
|
char *temp;
|
||||||
|
size_t len = 0;
|
||||||
|
char pwbuf[1024];
|
||||||
|
|
||||||
|
if (txt[0] != '~')
|
||||||
|
return (strdup(txt));
|
||||||
|
|
||||||
|
temp = strchr(txt + 1, '/');
|
||||||
|
if (temp == NULL) {
|
||||||
|
temp = strdup(txt + 1);
|
||||||
|
if (temp == NULL)
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
len = temp - txt + 1; /* text until string after slash */
|
||||||
|
temp = malloc(len);
|
||||||
|
if (temp == NULL)
|
||||||
|
return NULL;
|
||||||
|
(void)strncpy(temp, txt + 1, len - 2);
|
||||||
|
temp[len - 2] = '\0';
|
||||||
|
}
|
||||||
|
/* XXXMYSQL: use non-_r functions for now */
|
||||||
|
if (temp[0] == 0) {
|
||||||
|
pass = getpwuid(getuid());
|
||||||
|
} else {
|
||||||
|
pass = getpwnam(temp);
|
||||||
|
}
|
||||||
|
free(temp); /* value no more needed */
|
||||||
|
if (pass == NULL)
|
||||||
|
return (strdup(txt));
|
||||||
|
|
||||||
|
/* update pointer txt to point at string immedially following */
|
||||||
|
/* first slash */
|
||||||
|
txt += len;
|
||||||
|
|
||||||
|
temp = malloc(strlen(pass->pw_dir) + 1 + strlen(txt) + 1);
|
||||||
|
if (temp == NULL)
|
||||||
|
return NULL;
|
||||||
|
(void)sprintf(temp, "%s/%s", pass->pw_dir, txt);
|
||||||
|
|
||||||
|
return (temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return first found file name starting by the ``text'' or NULL if no
|
||||||
|
* such file can be found
|
||||||
|
* value of ``state'' is ignored
|
||||||
|
*
|
||||||
|
* it's caller's responsibility to free returned string
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
fn_filename_completion_function(const char *text, int state)
|
||||||
|
{
|
||||||
|
static DIR *dir = NULL;
|
||||||
|
static char *filename = NULL, *dirname = NULL, *dirpath = NULL;
|
||||||
|
static size_t filename_len = 0;
|
||||||
|
struct dirent *entry;
|
||||||
|
char *temp;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (state == 0 || dir == NULL) {
|
||||||
|
temp = strrchr(text, '/');
|
||||||
|
if (temp) {
|
||||||
|
char *nptr;
|
||||||
|
temp++;
|
||||||
|
nptr = realloc(filename, strlen(temp) + 1);
|
||||||
|
if (nptr == NULL) {
|
||||||
|
free(filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
filename = nptr;
|
||||||
|
(void)strcpy(filename, temp);
|
||||||
|
len = temp - text; /* including last slash */
|
||||||
|
nptr = realloc(dirname, len + 1);
|
||||||
|
if (nptr == NULL) {
|
||||||
|
free(filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
dirname = nptr;
|
||||||
|
(void)strncpy(dirname, text, len);
|
||||||
|
dirname[len] = '\0';
|
||||||
|
} else {
|
||||||
|
if (*text == 0)
|
||||||
|
filename = NULL;
|
||||||
|
else {
|
||||||
|
filename = strdup(text);
|
||||||
|
if (filename == NULL)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
dirname = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dir != NULL) {
|
||||||
|
(void)closedir(dir);
|
||||||
|
dir = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* support for ``~user'' syntax */
|
||||||
|
free(dirpath);
|
||||||
|
|
||||||
|
if (dirname == NULL && (dirname = strdup("./")) == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (*dirname == '~')
|
||||||
|
dirpath = fn_tilde_expand(dirname);
|
||||||
|
else
|
||||||
|
dirpath = strdup(dirname);
|
||||||
|
|
||||||
|
if (dirpath == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
dir = opendir(dirpath);
|
||||||
|
if (!dir)
|
||||||
|
return (NULL); /* cannot open the directory */
|
||||||
|
|
||||||
|
/* will be used in cycle */
|
||||||
|
filename_len = filename ? strlen(filename) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* find the match */
|
||||||
|
while ((entry = readdir(dir)) != NULL) {
|
||||||
|
/* skip . and .. */
|
||||||
|
if (entry->d_name[0] == '.' && (!entry->d_name[1]
|
||||||
|
|| (entry->d_name[1] == '.' && !entry->d_name[2])))
|
||||||
|
continue;
|
||||||
|
if (filename_len == 0)
|
||||||
|
break;
|
||||||
|
/* otherwise, get first entry where first */
|
||||||
|
/* filename_len characters are equal */
|
||||||
|
if (entry->d_name[0] == filename[0]
|
||||||
|
#if HAVE_STRUCT_DIRENT_D_NAMLEN
|
||||||
|
&& entry->d_namlen >= filename_len
|
||||||
|
#else
|
||||||
|
&& strlen(entry->d_name) >= filename_len
|
||||||
|
#endif
|
||||||
|
&& strncmp(entry->d_name, filename,
|
||||||
|
filename_len) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry) { /* match found */
|
||||||
|
|
||||||
|
#if HAVE_STRUCT_DIRENT_D_NAMLEN
|
||||||
|
len = entry->d_namlen;
|
||||||
|
#else
|
||||||
|
len = strlen(entry->d_name);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
temp = malloc(strlen(dirname) + len + 1);
|
||||||
|
if (temp == NULL)
|
||||||
|
return NULL;
|
||||||
|
(void)sprintf(temp, "%s%s", dirname, entry->d_name);
|
||||||
|
} else {
|
||||||
|
(void)closedir(dir);
|
||||||
|
dir = NULL;
|
||||||
|
temp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
append_char_function(const char *name)
|
||||||
|
{
|
||||||
|
struct stat stbuf;
|
||||||
|
char *expname = *name == '~' ? fn_tilde_expand(name) : NULL;
|
||||||
|
const char *rs = " ";
|
||||||
|
|
||||||
|
if (stat(expname ? expname : name, &stbuf) == -1)
|
||||||
|
goto out;
|
||||||
|
if (S_ISDIR(stbuf.st_mode))
|
||||||
|
rs = "/";
|
||||||
|
out:
|
||||||
|
if (expname)
|
||||||
|
free(expname);
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* returns list of completions for text given
|
||||||
|
* non-static for readline.
|
||||||
|
*/
|
||||||
|
char ** completion_matches(const char *, char *(*)(const char *, int));
|
||||||
|
char **
|
||||||
|
completion_matches(const char *text, char *(*genfunc)(const char *, int))
|
||||||
|
{
|
||||||
|
char **match_list = NULL, *retstr, *prevstr;
|
||||||
|
size_t match_list_len, max_equal, which, i;
|
||||||
|
size_t matches;
|
||||||
|
|
||||||
|
matches = 0;
|
||||||
|
match_list_len = 1;
|
||||||
|
while ((retstr = (*genfunc) (text, (int)matches)) != NULL) {
|
||||||
|
/* allow for list terminator here */
|
||||||
|
if (matches + 3 >= match_list_len) {
|
||||||
|
char **nmatch_list;
|
||||||
|
while (matches + 3 >= match_list_len)
|
||||||
|
match_list_len <<= 1;
|
||||||
|
nmatch_list = realloc(match_list,
|
||||||
|
match_list_len * sizeof(char *));
|
||||||
|
if (nmatch_list == NULL) {
|
||||||
|
free(match_list);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
match_list = nmatch_list;
|
||||||
|
|
||||||
|
}
|
||||||
|
match_list[++matches] = retstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!match_list)
|
||||||
|
return NULL; /* nothing found */
|
||||||
|
|
||||||
|
/* find least denominator and insert it to match_list[0] */
|
||||||
|
which = 2;
|
||||||
|
prevstr = match_list[1];
|
||||||
|
max_equal = strlen(prevstr);
|
||||||
|
for (; which <= matches; which++) {
|
||||||
|
for (i = 0; i < max_equal &&
|
||||||
|
prevstr[i] == match_list[which][i]; i++)
|
||||||
|
continue;
|
||||||
|
max_equal = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
retstr = malloc(max_equal + 1);
|
||||||
|
if (retstr == NULL) {
|
||||||
|
free(match_list);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
(void)strncpy(retstr, match_list[1], max_equal);
|
||||||
|
retstr[max_equal] = '\0';
|
||||||
|
match_list[0] = retstr;
|
||||||
|
|
||||||
|
/* add NULL as last pointer to the array */
|
||||||
|
match_list[matches + 1] = (char *) NULL;
|
||||||
|
|
||||||
|
return (match_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sort function for qsort(). Just wrapper around strcasecmp().
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
_fn_qsort_string_compare(const void *i1, const void *i2)
|
||||||
|
{
|
||||||
|
const char *s1 = ((const char * const *)i1)[0];
|
||||||
|
const char *s2 = ((const char * const *)i2)[0];
|
||||||
|
|
||||||
|
return strcasecmp(s1, s2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display list of strings in columnar format on readline's output stream.
|
||||||
|
* 'matches' is list of strings, 'len' is number of strings in 'matches',
|
||||||
|
* 'max' is maximum length of string in 'matches'.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
fn_display_match_list (EditLine *el, char **matches, int len, int max)
|
||||||
|
{
|
||||||
|
int i, idx, limit, count;
|
||||||
|
int screenwidth = el->el_term.t_size.h;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find out how many entries can be put on one line, count
|
||||||
|
* with two spaces between strings.
|
||||||
|
*/
|
||||||
|
limit = screenwidth / (max + 2);
|
||||||
|
if (limit == 0)
|
||||||
|
limit = 1;
|
||||||
|
|
||||||
|
/* how many lines of output */
|
||||||
|
count = len / limit;
|
||||||
|
if (count * limit < len)
|
||||||
|
count++;
|
||||||
|
|
||||||
|
/* Sort the items if they are not already sorted. */
|
||||||
|
qsort(&matches[1], (size_t)(len - 1), sizeof(char *),
|
||||||
|
_fn_qsort_string_compare);
|
||||||
|
|
||||||
|
idx = 1;
|
||||||
|
for(; count > 0; count--) {
|
||||||
|
for(i = 0; i < limit && matches[idx]; i++, idx++)
|
||||||
|
(void)fprintf(el->el_outfile, "%-*s ", max,
|
||||||
|
matches[idx]);
|
||||||
|
(void)fprintf(el->el_outfile, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Complete the word at or before point,
|
||||||
|
* 'what_to_do' says what to do with the completion.
|
||||||
|
* \t means do standard completion.
|
||||||
|
* `?' means list the possible completions.
|
||||||
|
* `*' means insert all of the possible completions.
|
||||||
|
* `!' means to do standard completion, and list all possible completions if
|
||||||
|
* there is more than one.
|
||||||
|
*
|
||||||
|
* Note: '*' support is not implemented
|
||||||
|
* '!' could never be invoked
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
fn_complete(EditLine *el,
|
||||||
|
char *(*complet_func)(const char *, int),
|
||||||
|
char **(*attempted_completion_function)(const char *, int, int),
|
||||||
|
const char *word_break, const char *special_prefixes,
|
||||||
|
const char *(*app_func)(const char *), int query_items,
|
||||||
|
int *completion_type, int *over, int *point, int *end)
|
||||||
|
{
|
||||||
|
const LineInfo *li;
|
||||||
|
char *temp, **matches;
|
||||||
|
const char *ctemp;
|
||||||
|
size_t len;
|
||||||
|
int what_to_do = '\t';
|
||||||
|
int retval = CC_NORM;
|
||||||
|
|
||||||
|
if (el->el_state.lastcmd == el->el_state.thiscmd)
|
||||||
|
what_to_do = '?';
|
||||||
|
|
||||||
|
/* readline's rl_complete() has to be told what we did... */
|
||||||
|
if (completion_type != NULL)
|
||||||
|
*completion_type = what_to_do;
|
||||||
|
|
||||||
|
if (!complet_func)
|
||||||
|
complet_func = fn_filename_completion_function;
|
||||||
|
if (!app_func)
|
||||||
|
app_func = append_char_function;
|
||||||
|
|
||||||
|
/* We now look backwards for the start of a filename/variable word */
|
||||||
|
li = el_line(el);
|
||||||
|
ctemp = (const char *) li->cursor;
|
||||||
|
while (ctemp > li->buffer
|
||||||
|
&& !strchr(word_break, ctemp[-1])
|
||||||
|
&& (!special_prefixes || !strchr(special_prefixes, ctemp[-1]) ) )
|
||||||
|
ctemp--;
|
||||||
|
|
||||||
|
len = li->cursor - ctemp;
|
||||||
|
#if defined(__SSP__) || defined(__SSP_ALL__)
|
||||||
|
temp = malloc(len + 1);
|
||||||
|
#else
|
||||||
|
temp = alloca(len + 1);
|
||||||
|
#endif
|
||||||
|
(void)strncpy(temp, ctemp, len);
|
||||||
|
temp[len] = '\0';
|
||||||
|
|
||||||
|
/* these can be used by function called in completion_matches() */
|
||||||
|
/* or (*attempted_completion_function)() */
|
||||||
|
if (point != 0)
|
||||||
|
*point = li->cursor - li->buffer;
|
||||||
|
if (end != NULL)
|
||||||
|
*end = li->lastchar - li->buffer;
|
||||||
|
|
||||||
|
if (attempted_completion_function) {
|
||||||
|
int cur_off = li->cursor - li->buffer;
|
||||||
|
matches = (*attempted_completion_function) (temp,
|
||||||
|
(int)(cur_off - len), cur_off);
|
||||||
|
} else
|
||||||
|
matches = 0;
|
||||||
|
if (!attempted_completion_function ||
|
||||||
|
(over != NULL && !*over && !matches))
|
||||||
|
matches = completion_matches(temp, complet_func);
|
||||||
|
|
||||||
|
if (over != NULL)
|
||||||
|
*over = 0;
|
||||||
|
|
||||||
|
if (matches) {
|
||||||
|
int i;
|
||||||
|
int matches_num, maxlen, match_len, match_display=1;
|
||||||
|
|
||||||
|
retval = CC_REFRESH;
|
||||||
|
/*
|
||||||
|
* Only replace the completed string with common part of
|
||||||
|
* possible matches if there is possible completion.
|
||||||
|
*/
|
||||||
|
if (matches[0][0] != '\0') {
|
||||||
|
el_deletestr(el, (int) len);
|
||||||
|
el_insertstr(el, matches[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (what_to_do == '?')
|
||||||
|
goto display_matches;
|
||||||
|
|
||||||
|
if (matches[2] == NULL && strcmp(matches[0], matches[1]) == 0) {
|
||||||
|
/*
|
||||||
|
* We found exact match. Add a space after
|
||||||
|
* it, unless we do filename completion and the
|
||||||
|
* object is a directory.
|
||||||
|
*/
|
||||||
|
el_insertstr(el, (*app_func)(matches[0]));
|
||||||
|
} else if (what_to_do == '!') {
|
||||||
|
display_matches:
|
||||||
|
/*
|
||||||
|
* More than one match and requested to list possible
|
||||||
|
* matches.
|
||||||
|
*/
|
||||||
|
|
||||||
|
for(i=1, maxlen=0; matches[i]; i++) {
|
||||||
|
match_len = strlen(matches[i]);
|
||||||
|
if (match_len > maxlen)
|
||||||
|
maxlen = match_len;
|
||||||
|
}
|
||||||
|
matches_num = i - 1;
|
||||||
|
|
||||||
|
/* newline to get on next line from command line */
|
||||||
|
(void)fprintf(el->el_outfile, "\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there are too many items, ask user for display
|
||||||
|
* confirmation.
|
||||||
|
*/
|
||||||
|
if (matches_num > query_items) {
|
||||||
|
(void)fprintf(el->el_outfile,
|
||||||
|
"Display all %d possibilities? (y or n) ",
|
||||||
|
matches_num);
|
||||||
|
(void)fflush(el->el_outfile);
|
||||||
|
if (getc(stdin) != 'y')
|
||||||
|
match_display = 0;
|
||||||
|
(void)fprintf(el->el_outfile, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_display)
|
||||||
|
fn_display_match_list(el, matches, matches_num,
|
||||||
|
maxlen);
|
||||||
|
retval = CC_REDISPLAY;
|
||||||
|
} else if (matches[0][0]) {
|
||||||
|
/*
|
||||||
|
* There was some common match, but the name was
|
||||||
|
* not complete enough. Next tab will print possible
|
||||||
|
* completions.
|
||||||
|
*/
|
||||||
|
el_beep(el);
|
||||||
|
} else {
|
||||||
|
/* lcd is not a valid object - further specification */
|
||||||
|
/* is needed */
|
||||||
|
el_beep(el);
|
||||||
|
retval = CC_NORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free elements of array and the array itself */
|
||||||
|
for (i = 0; matches[i]; i++)
|
||||||
|
free(matches[i]);
|
||||||
|
free(matches);
|
||||||
|
matches = NULL;
|
||||||
|
}
|
||||||
|
#if defined(__SSP__) || defined(__SSP_ALL__)
|
||||||
|
free(temp);
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* el-compatible wrapper around rl_complete; needed for key binding
|
||||||
|
*/
|
||||||
|
/* ARGSUSED */
|
||||||
|
unsigned char
|
||||||
|
_el_fn_complete(EditLine *el, int ch __attribute__((__unused__)))
|
||||||
|
{
|
||||||
|
return (unsigned char)fn_complete(el, NULL, NULL,
|
||||||
|
break_chars, NULL, NULL, 100,
|
||||||
|
NULL, NULL, NULL, NULL);
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
/* $NetBSD: fgetln.c,v 1.2 2003/12/10 01:30:27 lukem Exp $ */
|
/* $NetBSD: filecomplete.h,v 1.6 2008/04/29 06:53:01 martin Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
* by Christos Zoulas.
|
* by Jaromir Dolecek.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -15,13 +15,6 @@
|
|||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the NetBSD
|
|
||||||
* Foundation, Inc. and its contributors.
|
|
||||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
@ -35,54 +28,17 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
#ifndef _FILECOMPLETE_H_
|
||||||
|
#define _FILECOMPLETE_H_
|
||||||
|
|
||||||
#include <config.h>
|
int fn_complete(EditLine *,
|
||||||
#include <stdio.h>
|
char *(*)(const char *, int),
|
||||||
#include <stdlib.h>
|
char **(*)(const char *, int, int),
|
||||||
#include <unistd.h>
|
const char *, const char *, const char *(*)(const char *), int,
|
||||||
#include <errno.h>
|
int *, int *, int *, int *);
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
void fn_display_match_list(EditLine *, char **, int, int);
|
||||||
|
char *fn_tilde_expand(const char *);
|
||||||
|
char *fn_filename_completion_function(const char *, int);
|
||||||
|
|
||||||
char *
|
#endif
|
||||||
fgetln(FILE *fp, size_t *len)
|
|
||||||
{
|
|
||||||
static char *buf = NULL;
|
|
||||||
static size_t bufsiz = 0;
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
|
|
||||||
if (buf == NULL) {
|
|
||||||
bufsiz = BUFSIZ;
|
|
||||||
if ((buf = malloc(bufsiz)) == NULL)
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fgets(buf, bufsiz, fp) == NULL)
|
|
||||||
return NULL;
|
|
||||||
*len = 0;
|
|
||||||
|
|
||||||
while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
|
|
||||||
size_t nbufsiz = bufsiz + BUFSIZ;
|
|
||||||
char *nbuf = realloc(buf, nbufsiz);
|
|
||||||
|
|
||||||
if (nbuf == NULL) {
|
|
||||||
int oerrno = errno;
|
|
||||||
free(buf);
|
|
||||||
errno = oerrno;
|
|
||||||
buf = NULL;
|
|
||||||
return NULL;
|
|
||||||
} else
|
|
||||||
buf = nbuf;
|
|
||||||
|
|
||||||
*len = bufsiz;
|
|
||||||
if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL)
|
|
||||||
return buf;
|
|
||||||
|
|
||||||
bufsiz = nbufsiz;
|
|
||||||
}
|
|
||||||
|
|
||||||
*len = (ptr - buf) + 1;
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hist.c: History access functions
|
* hist.c: History access functions
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: histedit.h,v 1.25 2003/12/05 13:37:48 lukem Exp $ */
|
/* $NetBSD: histedit.h,v 1.35 2009/02/05 19:15:44 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -41,11 +41,15 @@
|
|||||||
#define _HISTEDIT_H_
|
#define _HISTEDIT_H_
|
||||||
|
|
||||||
#define LIBEDIT_MAJOR 2
|
#define LIBEDIT_MAJOR 2
|
||||||
#define LIBEDIT_MINOR 9
|
#define LIBEDIT_MINOR 11
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ==== Editing ====
|
* ==== Editing ====
|
||||||
*/
|
*/
|
||||||
@ -88,7 +92,7 @@ void el_reset(EditLine *);
|
|||||||
*/
|
*/
|
||||||
const char *el_gets(EditLine *, int *);
|
const char *el_gets(EditLine *, int *);
|
||||||
int el_getc(EditLine *, char *);
|
int el_getc(EditLine *, char *);
|
||||||
void el_push(EditLine *, char *);
|
void el_push(EditLine *, const char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Beep!
|
* Beep!
|
||||||
@ -105,7 +109,8 @@ int el_parse(EditLine *, int, const char **);
|
|||||||
* Low level editline access functions
|
* Low level editline access functions
|
||||||
*/
|
*/
|
||||||
int el_set(EditLine *, int, ...);
|
int el_set(EditLine *, int, ...);
|
||||||
int el_get(EditLine *, int, void *);
|
int el_get(EditLine *, int, ...);
|
||||||
|
unsigned char _el_fn_complete(EditLine *, int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* el_set/el_get parameters
|
* el_set/el_get parameters
|
||||||
@ -128,6 +133,10 @@ int el_get(EditLine *, int, void *);
|
|||||||
#define EL_CLIENTDATA 14 /* , void *); */
|
#define EL_CLIENTDATA 14 /* , void *); */
|
||||||
#define EL_UNBUFFERED 15 /* , int); */
|
#define EL_UNBUFFERED 15 /* , int); */
|
||||||
#define EL_PREP_TERM 16 /* , int); */
|
#define EL_PREP_TERM 16 /* , int); */
|
||||||
|
#define EL_GETTC 17 /* , const char *, ..., NULL); */
|
||||||
|
#define EL_GETFP 18 /* , int, FILE **); */
|
||||||
|
#define EL_SETFP 19 /* , int, FILE *); */
|
||||||
|
#define EL_REFRESH 20 /* , void); */
|
||||||
|
|
||||||
#define EL_BUILTIN_GETCFN (NULL)
|
#define EL_BUILTIN_GETCFN (NULL)
|
||||||
|
|
||||||
@ -192,6 +201,7 @@ int history(History *, HistEvent *, int, ...);
|
|||||||
#define H_CLEAR 19 /* , void); */
|
#define H_CLEAR 19 /* , void); */
|
||||||
#define H_SETUNIQUE 20 /* , int); */
|
#define H_SETUNIQUE 20 /* , int); */
|
||||||
#define H_GETUNIQUE 21 /* , void); */
|
#define H_GETUNIQUE 21 /* , void); */
|
||||||
|
#define H_DEL 22 /* , int); */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -211,4 +221,8 @@ int tok_line(Tokenizer *, const LineInfo *,
|
|||||||
int tok_str(Tokenizer *, const char *,
|
int tok_str(Tokenizer *, const char *,
|
||||||
int *, const char ***);
|
int *, const char ***);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _HISTEDIT_H_ */
|
#endif /* _HISTEDIT_H_ */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: history.c,v 1.28 2004/11/27 18:31:45 christos Exp $ */
|
/* $NetBSD: history.c,v 1.33 2009/02/06 14:40:32 sketch Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hist.c: History access functions
|
* hist.c: History access functions
|
||||||
@ -40,7 +46,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#ifdef HAVE_VIS_H
|
||||||
#include <vis.h>
|
#include <vis.h>
|
||||||
|
#else
|
||||||
|
#include "np/vis.h"
|
||||||
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
static const char hist_cookie[] = "_HiStOrY_V2_\n";
|
static const char hist_cookie[] = "_HiStOrY_V2_\n";
|
||||||
@ -61,6 +71,7 @@ struct history {
|
|||||||
history_gfun_t h_prev; /* Get the previous element */
|
history_gfun_t h_prev; /* Get the previous element */
|
||||||
history_gfun_t h_curr; /* Get the current element */
|
history_gfun_t h_curr; /* Get the current element */
|
||||||
history_sfun_t h_set; /* Set the current element */
|
history_sfun_t h_set; /* Set the current element */
|
||||||
|
history_sfun_t h_del; /* Set the given element */
|
||||||
history_vfun_t h_clear; /* Clear the history list */
|
history_vfun_t h_clear; /* Clear the history list */
|
||||||
history_efun_t h_enter; /* Add an element */
|
history_efun_t h_enter; /* Add an element */
|
||||||
history_efun_t h_add; /* Append to an element */
|
history_efun_t h_add; /* Append to an element */
|
||||||
@ -75,6 +86,7 @@ struct history {
|
|||||||
#define HCLEAR(h, ev) (*(h)->h_clear)((h)->h_ref, ev)
|
#define HCLEAR(h, ev) (*(h)->h_clear)((h)->h_ref, ev)
|
||||||
#define HENTER(h, ev, str) (*(h)->h_enter)((h)->h_ref, ev, str)
|
#define HENTER(h, ev, str) (*(h)->h_enter)((h)->h_ref, ev, str)
|
||||||
#define HADD(h, ev, str) (*(h)->h_add)((h)->h_ref, ev, str)
|
#define HADD(h, ev, str) (*(h)->h_add)((h)->h_ref, ev, str)
|
||||||
|
#define HDEL(h, ev, n) (*(h)->h_del)((h)->h_ref, ev, n)
|
||||||
|
|
||||||
#define h_strdup(a) strdup(a)
|
#define h_strdup(a) strdup(a)
|
||||||
#define h_malloc(a) malloc(a)
|
#define h_malloc(a) malloc(a)
|
||||||
@ -122,16 +134,18 @@ typedef struct history_t {
|
|||||||
#define H_UNIQUE 1 /* Store only unique elements */
|
#define H_UNIQUE 1 /* Store only unique elements */
|
||||||
} history_t;
|
} history_t;
|
||||||
|
|
||||||
private int history_def_first(ptr_t, HistEvent *);
|
|
||||||
private int history_def_last(ptr_t, HistEvent *);
|
|
||||||
private int history_def_next(ptr_t, HistEvent *);
|
private int history_def_next(ptr_t, HistEvent *);
|
||||||
|
private int history_def_first(ptr_t, HistEvent *);
|
||||||
private int history_def_prev(ptr_t, HistEvent *);
|
private int history_def_prev(ptr_t, HistEvent *);
|
||||||
|
private int history_def_last(ptr_t, HistEvent *);
|
||||||
private int history_def_curr(ptr_t, HistEvent *);
|
private int history_def_curr(ptr_t, HistEvent *);
|
||||||
private int history_def_set(ptr_t, HistEvent *, const int n);
|
private int history_def_set(ptr_t, HistEvent *, const int);
|
||||||
|
private void history_def_clear(ptr_t, HistEvent *);
|
||||||
private int history_def_enter(ptr_t, HistEvent *, const char *);
|
private int history_def_enter(ptr_t, HistEvent *, const char *);
|
||||||
private int history_def_add(ptr_t, HistEvent *, const char *);
|
private int history_def_add(ptr_t, HistEvent *, const char *);
|
||||||
|
private int history_def_del(ptr_t, HistEvent *, const int);
|
||||||
|
|
||||||
private int history_def_init(ptr_t *, HistEvent *, int);
|
private int history_def_init(ptr_t *, HistEvent *, int);
|
||||||
private void history_def_clear(ptr_t, HistEvent *);
|
|
||||||
private int history_def_insert(history_t *, HistEvent *, const char *);
|
private int history_def_insert(history_t *, HistEvent *, const char *);
|
||||||
private void history_def_delete(history_t *, HistEvent *, hentry_t *);
|
private void history_def_delete(history_t *, HistEvent *, hentry_t *);
|
||||||
|
|
||||||
@ -353,6 +367,24 @@ history_def_add(ptr_t p, HistEvent *ev, const char *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* history_def_del():
|
||||||
|
* Delete element hp of the h list
|
||||||
|
*/
|
||||||
|
/* ARGSUSED */
|
||||||
|
private int
|
||||||
|
history_def_del(ptr_t p, HistEvent *ev __attribute__((__unused__)),
|
||||||
|
const int num)
|
||||||
|
{
|
||||||
|
history_t *h = (history_t *) p;
|
||||||
|
if (history_def_set(h, ev, num) != 0)
|
||||||
|
return (-1);
|
||||||
|
ev->str = strdup(h->cursor->ev.str);
|
||||||
|
ev->num = h->cursor->ev.num;
|
||||||
|
history_def_delete(h, ev, h->cursor);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* history_def_delete():
|
/* history_def_delete():
|
||||||
* Delete element hp of the h list
|
* Delete element hp of the h list
|
||||||
*/
|
*/
|
||||||
@ -364,6 +396,8 @@ history_def_delete(history_t *h,
|
|||||||
HistEventPrivate *evp = (void *)&hp->ev;
|
HistEventPrivate *evp = (void *)&hp->ev;
|
||||||
if (hp == &h->list)
|
if (hp == &h->list)
|
||||||
abort();
|
abort();
|
||||||
|
if (h->cursor == hp)
|
||||||
|
h->cursor = hp->prev;
|
||||||
hp->prev->next = hp->next;
|
hp->prev->next = hp->next;
|
||||||
hp->next->prev = hp->prev;
|
hp->next->prev = hp->prev;
|
||||||
h_free((ptr_t) evp->str);
|
h_free((ptr_t) evp->str);
|
||||||
@ -497,6 +531,7 @@ history_init(void)
|
|||||||
h->h_clear = history_def_clear;
|
h->h_clear = history_def_clear;
|
||||||
h->h_enter = history_def_enter;
|
h->h_enter = history_def_enter;
|
||||||
h->h_add = history_def_add;
|
h->h_add = history_def_add;
|
||||||
|
h->h_del = history_def_del;
|
||||||
|
|
||||||
return (h);
|
return (h);
|
||||||
}
|
}
|
||||||
@ -512,6 +547,8 @@ history_end(History *h)
|
|||||||
|
|
||||||
if (h->h_next == history_def_next)
|
if (h->h_next == history_def_next)
|
||||||
history_def_clear(h->h_ref, &ev);
|
history_def_clear(h->h_ref, &ev);
|
||||||
|
h_free(h->h_ref);
|
||||||
|
h_free(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -597,7 +634,7 @@ history_set_fun(History *h, History *nh)
|
|||||||
if (nh->h_first == NULL || nh->h_next == NULL || nh->h_last == NULL ||
|
if (nh->h_first == NULL || nh->h_next == NULL || nh->h_last == NULL ||
|
||||||
nh->h_prev == NULL || nh->h_curr == NULL || nh->h_set == NULL ||
|
nh->h_prev == NULL || nh->h_curr == NULL || nh->h_set == NULL ||
|
||||||
nh->h_enter == NULL || nh->h_add == NULL || nh->h_clear == NULL ||
|
nh->h_enter == NULL || nh->h_add == NULL || nh->h_clear == NULL ||
|
||||||
nh->h_ref == NULL) {
|
nh->h_del == NULL || nh->h_ref == NULL) {
|
||||||
if (h->h_next != history_def_next) {
|
if (h->h_next != history_def_next) {
|
||||||
history_def_init(&h->h_ref, &ev, 0);
|
history_def_init(&h->h_ref, &ev, 0);
|
||||||
h->h_first = history_def_first;
|
h->h_first = history_def_first;
|
||||||
@ -609,6 +646,7 @@ history_set_fun(History *h, History *nh)
|
|||||||
h->h_clear = history_def_clear;
|
h->h_clear = history_def_clear;
|
||||||
h->h_enter = history_def_enter;
|
h->h_enter = history_def_enter;
|
||||||
h->h_add = history_def_add;
|
h->h_add = history_def_add;
|
||||||
|
h->h_del = history_def_del;
|
||||||
}
|
}
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -625,6 +663,7 @@ history_set_fun(History *h, History *nh)
|
|||||||
h->h_clear = nh->h_clear;
|
h->h_clear = nh->h_clear;
|
||||||
h->h_enter = nh->h_enter;
|
h->h_enter = nh->h_enter;
|
||||||
h->h_add = nh->h_add;
|
h->h_add = nh->h_add;
|
||||||
|
h->h_del = nh->h_del;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -841,6 +880,10 @@ history(History *h, HistEvent *ev, int fun, ...)
|
|||||||
retval = HADD(h, ev, str);
|
retval = HADD(h, ev, str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case H_DEL:
|
||||||
|
retval = HDEL(h, ev, va_arg(va, const int));
|
||||||
|
break;
|
||||||
|
|
||||||
case H_ENTER:
|
case H_ENTER:
|
||||||
str = va_arg(va, const char *);
|
str = va_arg(va, const char *);
|
||||||
if ((retval = HENTER(h, ev, str)) != -1)
|
if ((retval = HENTER(h, ev, str)) != -1)
|
||||||
@ -925,6 +968,7 @@ history(History *h, HistEvent *ev, int fun, ...)
|
|||||||
hf.h_clear = va_arg(va, history_vfun_t);
|
hf.h_clear = va_arg(va, history_vfun_t);
|
||||||
hf.h_enter = va_arg(va, history_efun_t);
|
hf.h_enter = va_arg(va, history_efun_t);
|
||||||
hf.h_add = va_arg(va, history_efun_t);
|
hf.h_add = va_arg(va, history_efun_t);
|
||||||
|
hf.h_del = va_arg(va, history_sfun_t);
|
||||||
|
|
||||||
if ((retval = history_set_fun(h, &hf)) == -1)
|
if ((retval = history_set_fun(h, &hf)) == -1)
|
||||||
he_seterrev(ev, _HE_PARAM_MISSING);
|
he_seterrev(ev, _HE_PARAM_MISSING);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: key.c,v 1.15 2003/10/18 23:48:42 christos Exp $ */
|
/* $NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,14 +32,20 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* key.c: This module contains the procedures for maintaining
|
* key.c: This module contains the procedures for maintaining
|
||||||
* the extended-key map.
|
* the extended-key map.
|
||||||
*
|
*
|
||||||
* An extended-key (key) is a sequence of keystrokes introduced
|
* An extended-key (key) is a sequence of keystrokes introduced
|
||||||
* with an sequence introducer and consisting of an arbitrary
|
* with a sequence introducer and consisting of an arbitrary
|
||||||
* number of characters. This module maintains a map (the el->el_key.map)
|
* number of characters. This module maintains a map (the el->el_key.map)
|
||||||
* to convert these extended-key sequences into input strs
|
* to convert these extended-key sequences into input strs
|
||||||
* (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE).
|
* (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE).
|
||||||
@ -78,12 +84,12 @@ private int node_trav(EditLine *, key_node_t *, char *,
|
|||||||
private int node__try(EditLine *, key_node_t *, const char *,
|
private int node__try(EditLine *, key_node_t *, const char *,
|
||||||
key_value_t *, int);
|
key_value_t *, int);
|
||||||
private key_node_t *node__get(int);
|
private key_node_t *node__get(int);
|
||||||
|
private void node__free(key_node_t *);
|
||||||
private void node__put(EditLine *, key_node_t *);
|
private void node__put(EditLine *, key_node_t *);
|
||||||
private int node__delete(EditLine *, key_node_t **, const char *);
|
private int node__delete(EditLine *, key_node_t **, const char *);
|
||||||
private int node_lookup(EditLine *, const char *, key_node_t *,
|
private int node_lookup(EditLine *, const char *, key_node_t *,
|
||||||
int);
|
int);
|
||||||
private int node_enum(EditLine *, key_node_t *, int);
|
private int node_enum(EditLine *, key_node_t *, int);
|
||||||
private int key__decode_char(char *, int, int);
|
|
||||||
|
|
||||||
#define KEY_BUFSIZ EL_BUFSIZ
|
#define KEY_BUFSIZ EL_BUFSIZ
|
||||||
|
|
||||||
@ -103,7 +109,6 @@ key_init(EditLine *el)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* key_end():
|
/* key_end():
|
||||||
* Free the key maps
|
* Free the key maps
|
||||||
*/
|
*/
|
||||||
@ -113,8 +118,7 @@ key_end(EditLine *el)
|
|||||||
|
|
||||||
el_free((ptr_t) el->el_key.buf);
|
el_free((ptr_t) el->el_key.buf);
|
||||||
el->el_key.buf = NULL;
|
el->el_key.buf = NULL;
|
||||||
/* XXX: provide a function to clear the keys */
|
node__free(el->el_key.map);
|
||||||
el->el_key.map = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -443,7 +447,7 @@ node__put(EditLine *el, key_node_t *ptr)
|
|||||||
|
|
||||||
|
|
||||||
/* node__get():
|
/* node__get():
|
||||||
* Returns pointer to an key_node_t for ch.
|
* Returns pointer to a key_node_t for ch.
|
||||||
*/
|
*/
|
||||||
private key_node_t *
|
private key_node_t *
|
||||||
node__get(int ch)
|
node__get(int ch)
|
||||||
@ -461,7 +465,15 @@ node__get(int ch)
|
|||||||
return (ptr);
|
return (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void
|
||||||
|
node__free(key_node_t *k)
|
||||||
|
{
|
||||||
|
if (k == NULL)
|
||||||
|
return;
|
||||||
|
node__free(k->sibling);
|
||||||
|
node__free(k->next);
|
||||||
|
el_free((ptr_t) k);
|
||||||
|
}
|
||||||
|
|
||||||
/* node_lookup():
|
/* node_lookup():
|
||||||
* look for the str starting at node ptr.
|
* look for the str starting at node ptr.
|
||||||
@ -483,7 +495,7 @@ node_lookup(EditLine *el, const char *str, key_node_t *ptr, int cnt)
|
|||||||
/* If match put this char into el->el_key.buf. Recurse */
|
/* If match put this char into el->el_key.buf. Recurse */
|
||||||
if (ptr->ch == *str) {
|
if (ptr->ch == *str) {
|
||||||
/* match found */
|
/* match found */
|
||||||
ncnt = key__decode_char(el->el_key.buf, cnt,
|
ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt,
|
||||||
(unsigned char) ptr->ch);
|
(unsigned char) ptr->ch);
|
||||||
if (ptr->next != NULL)
|
if (ptr->next != NULL)
|
||||||
/* not yet at leaf */
|
/* not yet at leaf */
|
||||||
@ -537,7 +549,8 @@ node_enum(EditLine *el, key_node_t *ptr, int cnt)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
/* put this char at end of str */
|
/* put this char at end of str */
|
||||||
ncnt = key__decode_char(el->el_key.buf, cnt, (unsigned char) ptr->ch);
|
ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt,
|
||||||
|
(unsigned char)ptr->ch);
|
||||||
if (ptr->next == NULL) {
|
if (ptr->next == NULL) {
|
||||||
/* print this key and function */
|
/* print this key and function */
|
||||||
el->el_key.buf[ncnt + 1] = '"';
|
el->el_key.buf[ncnt + 1] = '"';
|
||||||
@ -568,9 +581,10 @@ key_kprint(EditLine *el, const char *key, key_value_t *val, int ntype)
|
|||||||
switch (ntype) {
|
switch (ntype) {
|
||||||
case XK_STR:
|
case XK_STR:
|
||||||
case XK_EXE:
|
case XK_EXE:
|
||||||
(void) fprintf(el->el_outfile, fmt, key,
|
(void) key__decode_str(val->str, unparsbuf,
|
||||||
key__decode_str(val->str, unparsbuf,
|
sizeof(unparsbuf),
|
||||||
ntype == XK_STR ? "\"\"" : "[]"));
|
ntype == XK_STR ? "\"\"" : "[]");
|
||||||
|
(void) fprintf(el->el_outfile, fmt, key, unparsbuf);
|
||||||
break;
|
break;
|
||||||
case XK_CMD:
|
case XK_CMD:
|
||||||
for (fp = el->el_map.help; fp->name; fp++)
|
for (fp = el->el_map.help; fp->name; fp++)
|
||||||
@ -595,83 +609,97 @@ key_kprint(EditLine *el, const char *key, key_value_t *val, int ntype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define ADDC(c) \
|
||||||
|
if (b < eb) \
|
||||||
|
*b++ = c; \
|
||||||
|
else \
|
||||||
|
b++
|
||||||
/* key__decode_char():
|
/* key__decode_char():
|
||||||
* Put a printable form of char in buf.
|
* Put a printable form of char in buf.
|
||||||
*/
|
*/
|
||||||
private int
|
protected int
|
||||||
key__decode_char(char *buf, int cnt, int ch)
|
key__decode_char(char *buf, int cnt, int off, int ch)
|
||||||
{
|
{
|
||||||
|
char *sb = buf + off;
|
||||||
|
char *eb = buf + cnt;
|
||||||
|
char *b = sb;
|
||||||
if (ch == 0) {
|
if (ch == 0) {
|
||||||
buf[cnt++] = '^';
|
ADDC('^');
|
||||||
buf[cnt] = '@';
|
ADDC('@');
|
||||||
return (cnt);
|
return b - sb;
|
||||||
}
|
}
|
||||||
if (iscntrl(ch)) {
|
if (iscntrl(ch)) {
|
||||||
buf[cnt++] = '^';
|
ADDC('^');
|
||||||
if (ch == '\177')
|
if (ch == '\177')
|
||||||
buf[cnt] = '?';
|
ADDC('?');
|
||||||
else
|
else
|
||||||
buf[cnt] = ch | 0100;
|
ADDC(ch | 0100);
|
||||||
} else if (ch == '^') {
|
} else if (ch == '^') {
|
||||||
buf[cnt++] = '\\';
|
ADDC('\\');
|
||||||
buf[cnt] = '^';
|
ADDC('^');
|
||||||
} else if (ch == '\\') {
|
} else if (ch == '\\') {
|
||||||
buf[cnt++] = '\\';
|
ADDC('\\');
|
||||||
buf[cnt] = '\\';
|
ADDC('\\');
|
||||||
} else if (ch == ' ' || (el_isprint(ch) && !isspace(ch))) {
|
} else if (ch == ' ' || (el_isprint(ch) && !isspace(ch))) {
|
||||||
buf[cnt] = ch;
|
ADDC(ch);
|
||||||
} else {
|
} else {
|
||||||
buf[cnt++] = '\\';
|
ADDC('\\');
|
||||||
buf[cnt++] = (((unsigned int) ch >> 6) & 7) + '0';
|
ADDC((((unsigned int) ch >> 6) & 7) + '0');
|
||||||
buf[cnt++] = (((unsigned int) ch >> 3) & 7) + '0';
|
ADDC((((unsigned int) ch >> 3) & 7) + '0');
|
||||||
buf[cnt] = (ch & 7) + '0';
|
ADDC((ch & 7) + '0');
|
||||||
}
|
}
|
||||||
return (cnt);
|
return b - sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* key__decode_str():
|
/* key__decode_str():
|
||||||
* Make a printable version of the ey
|
* Make a printable version of the ey
|
||||||
*/
|
*/
|
||||||
protected char *
|
protected int
|
||||||
key__decode_str(const char *str, char *buf, const char *sep)
|
key__decode_str(const char *str, char *buf, int len, const char *sep)
|
||||||
{
|
{
|
||||||
char *b;
|
char *b = buf, *eb = b + len;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
b = buf;
|
b = buf;
|
||||||
if (sep[0] != '\0')
|
if (sep[0] != '\0') {
|
||||||
*b++ = sep[0];
|
ADDC(sep[0]);
|
||||||
if (*str == 0) {
|
}
|
||||||
*b++ = '^';
|
if (*str == '\0') {
|
||||||
*b++ = '@';
|
ADDC('^');
|
||||||
if (sep[0] != '\0' && sep[1] != '\0')
|
ADDC('@');
|
||||||
*b++ = sep[1];
|
if (sep[0] != '\0' && sep[1] != '\0') {
|
||||||
*b++ = 0;
|
ADDC(sep[1]);
|
||||||
return (buf);
|
}
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
for (p = str; *p != 0; p++) {
|
for (p = str; *p != 0; p++) {
|
||||||
if (iscntrl((unsigned char) *p)) {
|
if (iscntrl((unsigned char) *p)) {
|
||||||
*b++ = '^';
|
ADDC('^');
|
||||||
if (*p == '\177')
|
if (*p == '\177') {
|
||||||
*b++ = '?';
|
ADDC('?');
|
||||||
else
|
} else {
|
||||||
*b++ = *p | 0100;
|
ADDC(*p | 0100);
|
||||||
|
}
|
||||||
} else if (*p == '^' || *p == '\\') {
|
} else if (*p == '^' || *p == '\\') {
|
||||||
*b++ = '\\';
|
ADDC('\\');
|
||||||
*b++ = *p;
|
ADDC(*p);
|
||||||
} else if (*p == ' ' || (el_isprint((unsigned char) *p) &&
|
} else if (*p == ' ' || (el_isprint((unsigned char) *p) &&
|
||||||
!isspace((unsigned char) *p))) {
|
!isspace((unsigned char) *p))) {
|
||||||
*b++ = *p;
|
ADDC(*p);
|
||||||
} else {
|
} else {
|
||||||
*b++ = '\\';
|
ADDC('\\');
|
||||||
*b++ = (((unsigned int) *p >> 6) & 7) + '0';
|
ADDC((((unsigned int) *p >> 6) & 7) + '0');
|
||||||
*b++ = (((unsigned int) *p >> 3) & 7) + '0';
|
ADDC((((unsigned int) *p >> 3) & 7) + '0');
|
||||||
*b++ = (*p & 7) + '0';
|
ADDC((*p & 7) + '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sep[0] != '\0' && sep[1] != '\0')
|
if (sep[0] != '\0' && sep[1] != '\0') {
|
||||||
*b++ = sep[1];
|
ADDC(sep[1]);
|
||||||
*b++ = 0;
|
}
|
||||||
return (buf); /* should check for overflow */
|
done:
|
||||||
|
ADDC('\0');
|
||||||
|
if (b - buf >= len)
|
||||||
|
buf[len - 1] = '\0';
|
||||||
|
return b - buf;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: key.h,v 1.8 2003/08/07 16:44:32 agc Exp $ */
|
/* $NetBSD: key.h,v 1.10 2006/03/23 20:22:51 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -74,6 +74,8 @@ protected int key_delete(EditLine *, const char *);
|
|||||||
protected void key_print(EditLine *, const char *);
|
protected void key_print(EditLine *, const char *);
|
||||||
protected void key_kprint(EditLine *, const char *, key_value_t *,
|
protected void key_kprint(EditLine *, const char *, key_value_t *,
|
||||||
int);
|
int);
|
||||||
protected char *key__decode_str(const char *, char *, const char *);
|
protected int key__decode_str(const char *, char *, int,
|
||||||
|
const char *);
|
||||||
|
protected int key__decode_char(char *, int, int, int);
|
||||||
|
|
||||||
#endif /* _h_el_key */
|
#endif /* _h_el_key */
|
||||||
|
@ -1,124 +0,0 @@
|
|||||||
/* $NetBSD: term.h,v 1.12 2001/01/04 15:56:32 christos Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1992, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* Christos Zoulas of Cornell University.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)term.h 8.1 (Berkeley) 6/4/93
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* el.term.h: Termcap header
|
|
||||||
*/
|
|
||||||
#ifndef _h_el_term
|
|
||||||
#define _h_el_term
|
|
||||||
|
|
||||||
#include "histedit.h"
|
|
||||||
|
|
||||||
typedef struct { /* Symbolic function key bindings */
|
|
||||||
const char *name; /* name of the key */
|
|
||||||
int key; /* Index in termcap table */
|
|
||||||
key_value_t fun; /* Function bound to it */
|
|
||||||
int type; /* Type of function */
|
|
||||||
} fkey_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
coord_t t_size; /* # lines and cols */
|
|
||||||
int t_flags;
|
|
||||||
#define TERM_CAN_INSERT 0x001 /* Has insert cap */
|
|
||||||
#define TERM_CAN_DELETE 0x002 /* Has delete cap */
|
|
||||||
#define TERM_CAN_CEOL 0x004 /* Has CEOL cap */
|
|
||||||
#define TERM_CAN_TAB 0x008 /* Can use tabs */
|
|
||||||
#define TERM_CAN_ME 0x010 /* Can turn all attrs. */
|
|
||||||
#define TERM_CAN_UP 0x020 /* Can move up */
|
|
||||||
#define TERM_HAS_META 0x040 /* Has a meta key */
|
|
||||||
#define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */
|
|
||||||
#define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */
|
|
||||||
char *t_buf; /* Termcap buffer */
|
|
||||||
int t_loc; /* location used */
|
|
||||||
char **t_str; /* termcap strings */
|
|
||||||
int *t_val; /* termcap values */
|
|
||||||
char *t_cap; /* Termcap buffer */
|
|
||||||
fkey_t *t_fkey; /* Array of keys */
|
|
||||||
} el_term_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* fKey indexes
|
|
||||||
*/
|
|
||||||
#define A_K_DN 0
|
|
||||||
#define A_K_UP 1
|
|
||||||
#define A_K_LT 2
|
|
||||||
#define A_K_RT 3
|
|
||||||
#define A_K_HO 4
|
|
||||||
#define A_K_EN 5
|
|
||||||
#define A_K_NKEYS 6
|
|
||||||
|
|
||||||
protected void term_move_to_line(EditLine *, int);
|
|
||||||
protected void term_move_to_char(EditLine *, int);
|
|
||||||
protected void term_clear_EOL(EditLine *, int);
|
|
||||||
protected void term_overwrite(EditLine *, const char *, int);
|
|
||||||
protected void term_insertwrite(EditLine *, char *, int);
|
|
||||||
protected void term_deletechars(EditLine *, int);
|
|
||||||
protected void term_clear_screen(EditLine *);
|
|
||||||
protected void term_beep(EditLine *);
|
|
||||||
protected int term_change_size(EditLine *, int, int);
|
|
||||||
protected int term_get_size(EditLine *, int *, int *);
|
|
||||||
protected int term_init(EditLine *);
|
|
||||||
protected void term_bind_arrow(EditLine *);
|
|
||||||
protected void term_print_arrow(EditLine *, const char *);
|
|
||||||
protected int term_clear_arrow(EditLine *, const char *);
|
|
||||||
protected int term_set_arrow(EditLine *, const char *, key_value_t *, int);
|
|
||||||
protected void term_end(EditLine *);
|
|
||||||
protected int term_set(EditLine *, const char *);
|
|
||||||
protected int term_settc(EditLine *, int, const char **);
|
|
||||||
protected int term_telltc(EditLine *, int, const char **);
|
|
||||||
protected int term_echotc(EditLine *, int, const char **);
|
|
||||||
protected int term__putc(int);
|
|
||||||
protected void term__flush(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Easy access macros
|
|
||||||
*/
|
|
||||||
#define EL_FLAGS (el)->el_term.t_flags
|
|
||||||
|
|
||||||
#define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT)
|
|
||||||
#define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE)
|
|
||||||
#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL)
|
|
||||||
#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB)
|
|
||||||
#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME)
|
|
||||||
#define EL_HAS_META (EL_FLAGS & TERM_HAS_META)
|
|
||||||
#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS)
|
|
||||||
#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS)
|
|
||||||
|
|
||||||
#endif /* _h_el_term */
|
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh -
|
#!/bin/sh -
|
||||||
# $NetBSD: makelist,v 1.8 2003/03/10 21:21:10 christos Exp $
|
# $NetBSD: makelist,v 1.11 2005/10/22 16:45:03 christos Exp $
|
||||||
#
|
#
|
||||||
# Copyright (c) 1992, 1993
|
# Copyright (c) 1992, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# The Regents of the University of California. All rights reserved.
|
||||||
@ -15,11 +15,7 @@
|
|||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
# notice, this list of conditions and the following disclaimer in the
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
# documentation and/or other materials provided with the distribution.
|
# documentation and/or other materials provided with the distribution.
|
||||||
# 3. All advertising materials mentioning features or use of this software
|
# 3. Neither the name of the University nor the names of its contributors
|
||||||
# must display the following acknowledgement:
|
|
||||||
# This product includes software developed by the University of
|
|
||||||
# California, Berkeley and its contributors.
|
|
||||||
# 4. Neither the name of the University nor the names of its contributors
|
|
||||||
# may be used to endorse or promote products derived from this software
|
# may be used to endorse or promote products derived from this software
|
||||||
# without specific prior written permission.
|
# without specific prior written permission.
|
||||||
#
|
#
|
||||||
@ -68,6 +64,7 @@ case $FLAG in
|
|||||||
/\(\):/ {
|
/\(\):/ {
|
||||||
pr = substr($2, 1, 2);
|
pr = substr($2, 1, 2);
|
||||||
if (pr == "vi" || pr == "em" || pr == "ed") {
|
if (pr == "vi" || pr == "em" || pr == "ed") {
|
||||||
|
# XXXMYSQL: support CRLF
|
||||||
name = substr($2, 1, index($2,"(") - 1);
|
name = substr($2, 1, index($2,"(") - 1);
|
||||||
#
|
#
|
||||||
# XXX: need a space between name and prototype so that -fc and -fh
|
# XXX: need a space between name and prototype so that -fc and -fh
|
||||||
@ -97,6 +94,7 @@ case $FLAG in
|
|||||||
/\(\):/ {
|
/\(\):/ {
|
||||||
pr = substr($2, 1, 2);
|
pr = substr($2, 1, 2);
|
||||||
if (pr == "vi" || pr == "em" || pr == "ed") {
|
if (pr == "vi" || pr == "em" || pr == "ed") {
|
||||||
|
# XXXMYSQL: support CRLF
|
||||||
name = substr($2, 1, index($2,"(") - 1);
|
name = substr($2, 1, index($2,"(") - 1);
|
||||||
uname = "";
|
uname = "";
|
||||||
fname = "";
|
fname = "";
|
||||||
@ -117,13 +115,13 @@ case $FLAG in
|
|||||||
printf(" \"");
|
printf(" \"");
|
||||||
for (i = 2; i < NF; i++)
|
for (i = 2; i < NF; i++)
|
||||||
printf("%s ", $i);
|
printf("%s ", $i);
|
||||||
|
# XXXMYSQL: support CRLF
|
||||||
sub("\r", "", $i);
|
sub("\r", "", $i);
|
||||||
printf("%s\" },\n", $i);
|
printf("%s\" },\n", $i);
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
printf(" { NULL, 0, NULL }\n");
|
|
||||||
printf("};\n");
|
printf("};\n");
|
||||||
printf("\nprotected const el_bindings_t* help__get()");
|
printf("\nprotected const el_bindings_t* help__get()");
|
||||||
printf("{ return el_func_help; }\n");
|
printf("{ return el_func_help; }\n");
|
||||||
@ -144,6 +142,7 @@ case $FLAG in
|
|||||||
|
|
||||||
# generate fcns.h from various .h files
|
# generate fcns.h from various .h files
|
||||||
#
|
#
|
||||||
|
# XXXMYSQL: use portable tr syntax
|
||||||
-fh)
|
-fh)
|
||||||
cat $FILES | $AWK '/el_action_t/ { print $3 }' | \
|
cat $FILES | $AWK '/el_action_t/ { print $3 }' | \
|
||||||
sort | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | $AWK '
|
sort | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | $AWK '
|
||||||
@ -220,6 +219,7 @@ case $FLAG in
|
|||||||
/\(\):/ {
|
/\(\):/ {
|
||||||
pr = substr($2, 1, 2);
|
pr = substr($2, 1, 2);
|
||||||
if (pr == "vi" || pr == "em" || pr == "ed") {
|
if (pr == "vi" || pr == "em" || pr == "ed") {
|
||||||
|
# XXXMYSQL: support CRLF
|
||||||
name = substr($2, 1, index($2, "(") - 1);
|
name = substr($2, 1, index($2, "(") - 1);
|
||||||
fname = "";
|
fname = "";
|
||||||
for (i = 1; i <= length(name); i++) {
|
for (i = 1; i <= length(name); i++) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $ */
|
/* $NetBSD: map.c,v 1.24 2006/04/09 01:36:51 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* map.c: Editor function definitions
|
* map.c: Editor function definitions
|
||||||
@ -1118,11 +1124,12 @@ private void
|
|||||||
map_print_key(EditLine *el, el_action_t *map, const char *in)
|
map_print_key(EditLine *el, el_action_t *map, const char *in)
|
||||||
{
|
{
|
||||||
char outbuf[EL_BUFSIZ];
|
char outbuf[EL_BUFSIZ];
|
||||||
el_bindings_t *bp;
|
el_bindings_t *bp, *ep;
|
||||||
|
|
||||||
if (in[0] == '\0' || in[1] == '\0') {
|
if (in[0] == '\0' || in[1] == '\0') {
|
||||||
(void) key__decode_str(in, outbuf, "");
|
(void) key__decode_str(in, outbuf, sizeof(outbuf), "");
|
||||||
for (bp = el->el_map.help; bp->name != NULL; bp++)
|
ep = &el->el_map.help[el->el_map.nfunc];
|
||||||
|
for (bp = el->el_map.help; bp < ep; bp++)
|
||||||
if (bp->func == map[(unsigned char) *in]) {
|
if (bp->func == map[(unsigned char) *in]) {
|
||||||
(void) fprintf(el->el_outfile,
|
(void) fprintf(el->el_outfile,
|
||||||
"%s\t->\t%s\n", outbuf, bp->name);
|
"%s\t->\t%s\n", outbuf, bp->name);
|
||||||
@ -1139,7 +1146,7 @@ map_print_key(EditLine *el, el_action_t *map, const char *in)
|
|||||||
private void
|
private void
|
||||||
map_print_some_keys(EditLine *el, el_action_t *map, int first, int last)
|
map_print_some_keys(EditLine *el, el_action_t *map, int first, int last)
|
||||||
{
|
{
|
||||||
el_bindings_t *bp;
|
el_bindings_t *bp, *ep;
|
||||||
char firstbuf[2], lastbuf[2];
|
char firstbuf[2], lastbuf[2];
|
||||||
char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
|
char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
|
||||||
|
|
||||||
@ -1148,39 +1155,47 @@ map_print_some_keys(EditLine *el, el_action_t *map, int first, int last)
|
|||||||
lastbuf[0] = last;
|
lastbuf[0] = last;
|
||||||
lastbuf[1] = 0;
|
lastbuf[1] = 0;
|
||||||
if (map[first] == ED_UNASSIGNED) {
|
if (map[first] == ED_UNASSIGNED) {
|
||||||
if (first == last)
|
if (first == last) {
|
||||||
|
(void) key__decode_str(firstbuf, unparsbuf,
|
||||||
|
sizeof(unparsbuf), STRQQ);
|
||||||
(void) fprintf(el->el_outfile,
|
(void) fprintf(el->el_outfile,
|
||||||
"%-15s-> is undefined\n",
|
"%-15s-> is undefined\n", unparsbuf);
|
||||||
key__decode_str(firstbuf, unparsbuf, STRQQ));
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (bp = el->el_map.help; bp->name != NULL; bp++) {
|
ep = &el->el_map.help[el->el_map.nfunc];
|
||||||
|
for (bp = el->el_map.help; bp < ep; bp++) {
|
||||||
if (bp->func == map[first]) {
|
if (bp->func == map[first]) {
|
||||||
if (first == last) {
|
if (first == last) {
|
||||||
|
(void) key__decode_str(firstbuf, unparsbuf,
|
||||||
|
sizeof(unparsbuf), STRQQ);
|
||||||
(void) fprintf(el->el_outfile, "%-15s-> %s\n",
|
(void) fprintf(el->el_outfile, "%-15s-> %s\n",
|
||||||
key__decode_str(firstbuf, unparsbuf, STRQQ),
|
unparsbuf, bp->name);
|
||||||
bp->name);
|
|
||||||
} else {
|
} else {
|
||||||
|
(void) key__decode_str(firstbuf, unparsbuf,
|
||||||
|
sizeof(unparsbuf), STRQQ);
|
||||||
|
(void) key__decode_str(lastbuf, extrabuf,
|
||||||
|
sizeof(extrabuf), STRQQ);
|
||||||
(void) fprintf(el->el_outfile,
|
(void) fprintf(el->el_outfile,
|
||||||
"%-4s to %-7s-> %s\n",
|
"%-4s to %-7s-> %s\n",
|
||||||
key__decode_str(firstbuf, unparsbuf, STRQQ),
|
unparsbuf, extrabuf, bp->name);
|
||||||
key__decode_str(lastbuf, extrabuf, STRQQ),
|
|
||||||
bp->name);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef MAP_DEBUG
|
#ifdef MAP_DEBUG
|
||||||
if (map == el->el_map.key) {
|
if (map == el->el_map.key) {
|
||||||
|
(void) key__decode_str(firstbuf, unparsbuf,
|
||||||
|
sizeof(unparsbuf), STRQQ);
|
||||||
(void) fprintf(el->el_outfile,
|
(void) fprintf(el->el_outfile,
|
||||||
"BUG!!! %s isn't bound to anything.\n",
|
"BUG!!! %s isn't bound to anything.\n", unparsbuf);
|
||||||
key__decode_str(firstbuf, unparsbuf, STRQQ));
|
|
||||||
(void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
|
(void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
|
||||||
first, el->el_map.key[first]);
|
first, el->el_map.key[first]);
|
||||||
} else {
|
} else {
|
||||||
|
(void) key__decode_str(firstbuf, unparsbuf,
|
||||||
|
sizeof(unparsbuf), STRQQ);
|
||||||
(void) fprintf(el->el_outfile,
|
(void) fprintf(el->el_outfile,
|
||||||
"BUG!!! %s isn't bound to anything.\n",
|
"BUG!!! %s isn't bound to anything.\n", unparsbuf);
|
||||||
key__decode_str(firstbuf, unparsbuf, STRQQ));
|
|
||||||
(void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
|
(void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
|
||||||
first, el->el_map.alt[first]);
|
first, el->el_map.alt[first]);
|
||||||
}
|
}
|
||||||
@ -1237,7 +1252,7 @@ map_bind(EditLine *el, int argc, const char **argv)
|
|||||||
char outbuf[EL_BUFSIZ];
|
char outbuf[EL_BUFSIZ];
|
||||||
const char *in = NULL;
|
const char *in = NULL;
|
||||||
char *out = NULL;
|
char *out = NULL;
|
||||||
el_bindings_t *bp;
|
el_bindings_t *bp, *ep;
|
||||||
int cmd;
|
int cmd;
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
@ -1279,8 +1294,8 @@ map_bind(EditLine *el, int argc, const char **argv)
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
for (bp = el->el_map.help; bp->name != NULL;
|
ep = &el->el_map.help[el->el_map.nfunc];
|
||||||
bp++)
|
for (bp = el->el_map.help; bp < ep; bp++)
|
||||||
(void) fprintf(el->el_outfile,
|
(void) fprintf(el->el_outfile,
|
||||||
"%s\n\t%s\n",
|
"%s\n\t%s\n",
|
||||||
bp->name, bp->description);
|
bp->name, bp->description);
|
||||||
@ -1367,7 +1382,7 @@ map_bind(EditLine *el, int argc, const char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
EL_ABORT((el->el_errfile, "Bad XK_ type\n", ntype));
|
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
@ -1381,7 +1396,7 @@ protected int
|
|||||||
map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func)
|
map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
int nf = el->el_map.nfunc + 2;
|
int nf = el->el_map.nfunc + 1;
|
||||||
|
|
||||||
if (name == NULL || help == NULL || func == NULL)
|
if (name == NULL || help == NULL || func == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -1400,7 +1415,6 @@ map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func)
|
|||||||
el->el_map.help[nf].name = name;
|
el->el_map.help[nf].name = name;
|
||||||
el->el_map.help[nf].func = nf;
|
el->el_map.help[nf].func = nf;
|
||||||
el->el_map.help[nf].description = help;
|
el->el_map.help[nf].description = help;
|
||||||
el->el_map.help[++nf].name = NULL;
|
|
||||||
el->el_map.nfunc++;
|
el->el_map.nfunc++;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: fgetln.c,v 1.1.1.1 1999/04/12 07:43:21 crooksa Exp $ */
|
/* $NetBSD: fgetln.c,v 1.9 2008/04/29 06:53:03 martin Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
@ -15,13 +15,6 @@
|
|||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the NetBSD
|
|
||||||
* Foundation, Inc. and its contributors.
|
|
||||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
@ -36,17 +29,24 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_NBTOOL_CONFIG_H
|
||||||
|
#include "nbtool_config.h"
|
||||||
|
#else
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <stdio.h>
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_FGETLN
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifndef HAVE_NBTOOL_CONFIG_H
|
||||||
|
/* These headers are required, but included from nbtool_config.h */
|
||||||
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
char *
|
char *
|
||||||
fgetln(fp, len)
|
fgetln(FILE *fp, size_t *len)
|
||||||
FILE *fp;
|
|
||||||
size_t *len;
|
|
||||||
{
|
{
|
||||||
static char *buf = NULL;
|
static char *buf = NULL;
|
||||||
static size_t bufsiz = 0;
|
static size_t bufsiz = 0;
|
||||||
@ -61,8 +61,8 @@ fgetln(fp, len)
|
|||||||
|
|
||||||
if (fgets(buf, bufsiz, fp) == NULL)
|
if (fgets(buf, bufsiz, fp) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
*len = 0;
|
|
||||||
|
|
||||||
|
*len = 0;
|
||||||
while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
|
while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
|
||||||
size_t nbufsiz = bufsiz + BUFSIZ;
|
size_t nbufsiz = bufsiz + BUFSIZ;
|
||||||
char *nbuf = realloc(buf, nbufsiz);
|
char *nbuf = realloc(buf, nbufsiz);
|
||||||
@ -76,13 +76,33 @@ fgetln(fp, len)
|
|||||||
} else
|
} else
|
||||||
buf = nbuf;
|
buf = nbuf;
|
||||||
|
|
||||||
*len = bufsiz;
|
if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL) {
|
||||||
if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL)
|
buf[bufsiz] = '\0';
|
||||||
|
*len = strlen(buf);
|
||||||
return buf;
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
*len = bufsiz;
|
||||||
bufsiz = nbufsiz;
|
bufsiz = nbufsiz;
|
||||||
}
|
}
|
||||||
|
|
||||||
*len = (ptr - buf) + 1;
|
*len = (ptr - buf) + 1;
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TEST
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
while ((p = fgetln(stdin, &len)) != NULL) {
|
||||||
|
(void)printf("%zu %s", len, p);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -1,59 +1,68 @@
|
|||||||
|
/* $NetBSD: strlcat.c,v 1.3 2007/06/04 18:19:27 christos Exp $ */
|
||||||
|
/* $OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* modification, are permitted provided that the following conditions
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* are met:
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
|
||||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
|
||||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||||
|
#if HAVE_NBTOOL_CONFIG_H
|
||||||
|
#include "nbtool_config.h"
|
||||||
|
#else
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] =
|
|
||||||
"$FreeBSD: src/lib/libc/string/strlcat.c,v 1.2.4.2 2001/07/09 23:30:06 obrien Exp $";
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
#include "namespace.h"
|
||||||
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# ifdef __weak_alias
|
||||||
|
__weak_alias(strlcat, _strlcat)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <lib/libkern/libkern.h>
|
||||||
|
#endif /* !_KERNEL && !_STANDALONE */
|
||||||
|
|
||||||
|
#if !HAVE_STRLCAT
|
||||||
/*
|
/*
|
||||||
* Appends src to string dst of size siz (unlike strncat, siz is the
|
* Appends src to string dst of size siz (unlike strncat, siz is the
|
||||||
* full size of dst, not space left). At most siz-1 characters
|
* full size of dst, not space left). At most siz-1 characters
|
||||||
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
|
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
|
||||||
* Returns strlen(initial dst) + strlen(src); if retval >= siz,
|
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
|
||||||
* truncation occurred.
|
* If retval >= siz, truncation occurred.
|
||||||
*/
|
*/
|
||||||
size_t strlcat(dst, src, siz)
|
size_t
|
||||||
char *dst;
|
strlcat(char *dst, const char *src, size_t siz)
|
||||||
const char *src;
|
|
||||||
size_t siz;
|
|
||||||
{
|
{
|
||||||
register char *d = dst;
|
char *d = dst;
|
||||||
register const char *s = src;
|
const char *s = src;
|
||||||
register size_t n = siz;
|
size_t n = siz;
|
||||||
size_t dlen;
|
size_t dlen;
|
||||||
|
|
||||||
|
_DIAGASSERT(dst != NULL);
|
||||||
|
_DIAGASSERT(src != NULL);
|
||||||
|
|
||||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
/* Find the end of dst and adjust bytes left but don't go past end */
|
||||||
while (n-- != 0 && *d != '\0')
|
while (n-- != 0 && *d != '\0')
|
||||||
d++;
|
d++;
|
||||||
@ -73,3 +82,4 @@ size_t strlcat(dst, src, siz)
|
|||||||
|
|
||||||
return(dlen + (s - src)); /* count does not include NUL */
|
return(dlen + (s - src)); /* count does not include NUL */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -1,59 +1,63 @@
|
|||||||
/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
|
/* $NetBSD: strlcpy.c,v 1.3 2007/06/04 18:19:27 christos Exp $ */
|
||||||
|
/* $OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* modification, are permitted provided that the following conditions
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* are met:
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
|
||||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
|
||||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||||
|
#if HAVE_NBTOOL_CONFIG_H
|
||||||
|
#include "nbtool_config.h"
|
||||||
|
#else
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#endif
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
#if 0
|
|
||||||
static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
|
|
||||||
#endif
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] =
|
|
||||||
"$FreeBSD: src/lib/libc/string/strlcpy.c,v 1.2.4.1 2001/07/09 23:30:06 obrien Exp $";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
#include "namespace.h"
|
||||||
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# ifdef __weak_alias
|
||||||
|
__weak_alias(strlcpy, _strlcpy)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#include <lib/libkern/libkern.h>
|
||||||
|
#endif /* !_KERNEL && !_STANDALONE */
|
||||||
|
|
||||||
|
|
||||||
|
#if !HAVE_STRLCPY
|
||||||
/*
|
/*
|
||||||
* Copy src to string dst of size siz. At most siz-1 characters
|
* Copy src to string dst of size siz. At most siz-1 characters
|
||||||
* will be copied. Always NUL terminates (unless siz == 0).
|
* will be copied. Always NUL terminates (unless siz == 0).
|
||||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||||
*/
|
*/
|
||||||
size_t strlcpy(dst, src, siz)
|
size_t
|
||||||
char *dst;
|
strlcpy(char *dst, const char *src, size_t siz)
|
||||||
const char *src;
|
|
||||||
size_t siz;
|
|
||||||
{
|
{
|
||||||
register char *d = dst;
|
char *d = dst;
|
||||||
register const char *s = src;
|
const char *s = src;
|
||||||
register size_t n = siz;
|
size_t n = siz;
|
||||||
|
|
||||||
|
_DIAGASSERT(dst != NULL);
|
||||||
|
_DIAGASSERT(src != NULL);
|
||||||
|
|
||||||
/* Copy as many bytes as will fit */
|
/* Copy as many bytes as will fit */
|
||||||
if (n != 0 && --n != 0) {
|
if (n != 0 && --n != 0) {
|
||||||
@ -73,3 +77,4 @@ size_t strlcpy(dst, src, siz)
|
|||||||
|
|
||||||
return(s - src - 1); /* count does not include NUL */
|
return(s - src - 1); /* count does not include NUL */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: unvis.c,v 1.22 2002/03/23 17:38:27 christos Exp $ */
|
/* $NetBSD: unvis.c,v 1.28 2005/09/13 01:44:09 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
@ -12,11 +12,7 @@
|
|||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
@ -34,34 +30,30 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
|
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: unvis.c,v 1.22 2002/03/23 17:38:27 christos Exp $");
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
#define __LIBC12_SOURCE__
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_VIS_H
|
||||||
|
#include <vis.h>
|
||||||
|
#else
|
||||||
#include "np/vis.h"
|
#include "np/vis.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __weak_alias
|
#ifdef __weak_alias
|
||||||
__weak_alias(strunvis,_strunvis)
|
__weak_alias(strunvis,_strunvis)
|
||||||
__weak_alias(unvis,_unvis)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __warn_references
|
#if !HAVE_VIS
|
||||||
__warn_references(unvis,
|
|
||||||
"warning: reference to compatibility unvis(); include <vis.h> for correct reference")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !HAVE_VIS_H
|
|
||||||
/*
|
/*
|
||||||
* decode driven by state machine
|
* decode driven by state machine
|
||||||
*/
|
*/
|
||||||
@ -78,24 +70,16 @@ __warn_references(unvis,
|
|||||||
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
|
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
|
||||||
#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
|
#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* unvis - decode characters previously encoded by vis
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
unvis(cp, c, astate, flag)
|
unvis(cp, c, astate, flag)
|
||||||
char *cp;
|
char *cp;
|
||||||
int c;
|
int c;
|
||||||
int *astate, flag;
|
int *astate, flag;
|
||||||
{
|
{
|
||||||
return __unvis13(cp, (int)c, astate, flag);
|
unsigned char uc = (unsigned char)c;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* unvis - decode characters previously encoded by vis
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
__unvis13(cp, c, astate, flag)
|
|
||||||
char *cp;
|
|
||||||
int c;
|
|
||||||
int *astate, flag;
|
|
||||||
{
|
|
||||||
|
|
||||||
_DIAGASSERT(cp != NULL);
|
_DIAGASSERT(cp != NULL);
|
||||||
_DIAGASSERT(astate != NULL);
|
_DIAGASSERT(astate != NULL);
|
||||||
@ -219,7 +203,7 @@ __unvis13(cp, c, astate, flag)
|
|||||||
return (UNVIS_VALID);
|
return (UNVIS_VALID);
|
||||||
|
|
||||||
case S_OCTAL2: /* second possible octal digit */
|
case S_OCTAL2: /* second possible octal digit */
|
||||||
if (isoctal(c)) {
|
if (isoctal(uc)) {
|
||||||
/*
|
/*
|
||||||
* yes - and maybe a third
|
* yes - and maybe a third
|
||||||
*/
|
*/
|
||||||
@ -235,7 +219,7 @@ __unvis13(cp, c, astate, flag)
|
|||||||
|
|
||||||
case S_OCTAL3: /* third possible octal digit */
|
case S_OCTAL3: /* third possible octal digit */
|
||||||
*astate = S_GROUND;
|
*astate = S_GROUND;
|
||||||
if (isoctal(c)) {
|
if (isoctal(uc)) {
|
||||||
*cp = (*cp << 3) + (c - '0');
|
*cp = (*cp << 3) + (c - '0');
|
||||||
return (UNVIS_VALID);
|
return (UNVIS_VALID);
|
||||||
}
|
}
|
||||||
@ -243,9 +227,10 @@ __unvis13(cp, c, astate, flag)
|
|||||||
* we were done, push back passed char
|
* we were done, push back passed char
|
||||||
*/
|
*/
|
||||||
return (UNVIS_VALIDPUSH);
|
return (UNVIS_VALIDPUSH);
|
||||||
|
|
||||||
case S_HEX1:
|
case S_HEX1:
|
||||||
if (isxdigit(c)) {
|
if (isxdigit(uc)) {
|
||||||
*cp = xtod(c);
|
*cp = xtod(uc);
|
||||||
*astate = S_HEX2;
|
*astate = S_HEX2;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -254,13 +239,15 @@ __unvis13(cp, c, astate, flag)
|
|||||||
*/
|
*/
|
||||||
*astate = S_GROUND;
|
*astate = S_GROUND;
|
||||||
return (UNVIS_VALIDPUSH);
|
return (UNVIS_VALIDPUSH);
|
||||||
|
|
||||||
case S_HEX2:
|
case S_HEX2:
|
||||||
*astate = S_GROUND;
|
*astate = S_GROUND;
|
||||||
if (isxdigit(c)) {
|
if (isxdigit(uc)) {
|
||||||
*cp = xtod(c) | (*cp << 4);
|
*cp = xtod(uc) | (*cp << 4);
|
||||||
return (UNVIS_VALID);
|
return (UNVIS_VALID);
|
||||||
}
|
}
|
||||||
return (UNVIS_VALIDPUSH);
|
return (UNVIS_VALIDPUSH);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/*
|
/*
|
||||||
* decoder in unknown state - (probably uninitialized)
|
* decoder in unknown state - (probably uninitialized)
|
||||||
@ -292,7 +279,7 @@ strunvisx(dst, src, flag)
|
|||||||
|
|
||||||
while ((c = *src++) != '\0') {
|
while ((c = *src++) != '\0') {
|
||||||
again:
|
again:
|
||||||
switch (__unvis13(dst, c, &state, flag)) {
|
switch (unvis(dst, c, &state, flag)) {
|
||||||
case UNVIS_VALID:
|
case UNVIS_VALID:
|
||||||
dst++;
|
dst++;
|
||||||
break;
|
break;
|
||||||
@ -306,7 +293,7 @@ strunvisx(dst, src, flag)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (__unvis13(dst, c, &state, UNVIS_END) == UNVIS_VALID)
|
if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
|
||||||
dst++;
|
dst++;
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
return (dst - start);
|
return (dst - start);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/* $NetBSD: vis.c,v 1.22 2002/03/23 17:38:27 christos Exp $ */
|
/* $NetBSD: vis.c,v 1.38 2008/09/04 09:41:44 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
* The Regents of the University of California. All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
*
|
*
|
||||||
@ -13,11 +12,7 @@
|
|||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
@ -34,21 +29,47 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1999, 2005 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
__RCSID("$NetBSD: vis.c,v 1.22 2002/03/23 17:38:27 christos Exp $");
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#ifdef HAVE_ALLOCA_H
|
#ifdef HAVE_VIS_H
|
||||||
#include <alloca.h>
|
#include <vis.h>
|
||||||
|
#else
|
||||||
|
#include "np/vis.h"
|
||||||
#endif
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "np/vis.h"
|
|
||||||
|
|
||||||
#ifdef __weak_alias
|
#ifdef __weak_alias
|
||||||
__weak_alias(strsvis,_strsvis)
|
__weak_alias(strsvis,_strsvis)
|
||||||
__weak_alias(strsvisx,_strsvisx)
|
__weak_alias(strsvisx,_strsvisx)
|
||||||
@ -58,63 +79,61 @@ __weak_alias(svis,_svis)
|
|||||||
__weak_alias(vis,_vis)
|
__weak_alias(vis,_vis)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAVE_VIS_H
|
#if !HAVE_VIS || !HAVE_SVIS
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#undef BELL
|
|
||||||
#if defined(__STDC__)
|
|
||||||
#define BELL '\a'
|
|
||||||
#else
|
|
||||||
#define BELL '\007'
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define isoctal(c) (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
|
static char *do_svis(char *, int, int, int, const char *);
|
||||||
|
|
||||||
|
#undef BELL
|
||||||
|
#define BELL '\a'
|
||||||
|
|
||||||
|
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
|
||||||
#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
|
#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
|
||||||
#define issafe(c) (c == '\b' || c == BELL || c == '\r')
|
#define issafe(c) (c == '\b' || c == BELL || c == '\r')
|
||||||
#define xtoa(c) "0123456789abcdef"[c]
|
#define xtoa(c) "0123456789abcdef"[c]
|
||||||
|
|
||||||
#define MAXEXTRAS 5
|
#define MAXEXTRAS 5
|
||||||
|
|
||||||
|
#define MAKEEXTRALIST(flag, extra, orig_str) \
|
||||||
|
do { \
|
||||||
|
const char *orig = orig_str; \
|
||||||
|
const char *o = orig; \
|
||||||
|
char *e; \
|
||||||
|
while (*o++) \
|
||||||
|
continue; \
|
||||||
|
extra = malloc((size_t)((o - orig) + MAXEXTRAS)); \
|
||||||
|
if (!extra) break; \
|
||||||
|
for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
|
||||||
|
continue; \
|
||||||
|
e--; \
|
||||||
|
if (flag & VIS_SP) *e++ = ' '; \
|
||||||
|
if (flag & VIS_TAB) *e++ = '\t'; \
|
||||||
|
if (flag & VIS_NL) *e++ = '\n'; \
|
||||||
|
if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
|
||||||
|
*e = '\0'; \
|
||||||
|
} while (/*CONSTCOND*/0)
|
||||||
|
|
||||||
char *MAKEEXTRALIST(unsigned int flag, const char *orig)
|
/*
|
||||||
|
* This is do_hvis, for HTTP style (RFC 1808)
|
||||||
|
*/
|
||||||
|
static char *
|
||||||
|
do_hvis(char *dst, int c, int flag, int nextc, const char *extra)
|
||||||
{
|
{
|
||||||
const char *o = orig;
|
if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) {
|
||||||
char *e, *extra;
|
*dst++ = '%';
|
||||||
while (*o++)
|
*dst++ = xtoa(((unsigned int)c >> 4) & 0xf);
|
||||||
continue;
|
*dst++ = xtoa((unsigned int)c & 0xf);
|
||||||
extra = (char*) malloc((size_t)((o - orig) + MAXEXTRAS));
|
} else {
|
||||||
assert(extra);
|
dst = do_svis(dst, c, flag, nextc, extra);
|
||||||
for (o = orig, e = extra; (*e++ = *o++) != '\0';)
|
}
|
||||||
continue;
|
return dst;
|
||||||
e--;
|
|
||||||
if (flag & VIS_SP) *e++ = ' ';
|
|
||||||
if (flag & VIS_TAB) *e++ = '\t';
|
|
||||||
if (flag & VIS_NL) *e++ = '\n';
|
|
||||||
if ((flag & VIS_NOSLASH) == 0) *e++ = '\\';
|
|
||||||
*e = '\0';
|
|
||||||
return extra;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is HVIS, the macro of vis used to HTTP style (RFC 1808)
|
* This is do_vis, the central code of vis.
|
||||||
*/
|
|
||||||
#define HVIS(dst, c, flag, nextc, extra) \
|
|
||||||
do \
|
|
||||||
if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) { \
|
|
||||||
*dst++ = '%'; \
|
|
||||||
*dst++ = xtoa(((unsigned int)c >> 4) & 0xf); \
|
|
||||||
*dst++ = xtoa((unsigned int)c & 0xf); \
|
|
||||||
} else { \
|
|
||||||
SVIS(dst, c, flag, nextc, extra); \
|
|
||||||
} \
|
|
||||||
while (/*CONSTCOND*/0)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is SVIS, the central macro of vis.
|
|
||||||
* dst: Pointer to the destination buffer
|
* dst: Pointer to the destination buffer
|
||||||
* c: Character to encode
|
* c: Character to encode
|
||||||
* flag: Flag word
|
* flag: Flag word
|
||||||
@ -122,72 +141,78 @@ while (/*CONSTCOND*/0)
|
|||||||
* extra: Pointer to the list of extra characters to be
|
* extra: Pointer to the list of extra characters to be
|
||||||
* backslash-protected.
|
* backslash-protected.
|
||||||
*/
|
*/
|
||||||
#define SVIS(dst, c, flag, nextc, extra) \
|
static char *
|
||||||
do { \
|
do_svis(char *dst, int c, int flag, int nextc, const char *extra)
|
||||||
int isextra, isc; \
|
{
|
||||||
isextra = strchr(extra, c) != NULL; \
|
int isextra;
|
||||||
if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) || \
|
isextra = strchr(extra, c) != NULL;
|
||||||
((flag & VIS_SAFE) && issafe(c)))) { \
|
if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) ||
|
||||||
*dst++ = c; \
|
((flag & VIS_SAFE) && issafe(c)))) {
|
||||||
break; \
|
*dst++ = c;
|
||||||
} \
|
return dst;
|
||||||
isc = 0; \
|
}
|
||||||
if (flag & VIS_CSTYLE) { \
|
if (flag & VIS_CSTYLE) {
|
||||||
switch (c) { \
|
switch (c) {
|
||||||
case '\n': \
|
case '\n':
|
||||||
isc = 1; *dst++ = '\\'; *dst++ = 'n'; \
|
*dst++ = '\\'; *dst++ = 'n';
|
||||||
break; \
|
return dst;
|
||||||
case '\r': \
|
case '\r':
|
||||||
isc = 1; *dst++ = '\\'; *dst++ = 'r'; \
|
*dst++ = '\\'; *dst++ = 'r';
|
||||||
break; \
|
return dst;
|
||||||
case '\b': \
|
case '\b':
|
||||||
isc = 1; *dst++ = '\\'; *dst++ = 'b'; \
|
*dst++ = '\\'; *dst++ = 'b';
|
||||||
break; \
|
return dst;
|
||||||
case BELL: \
|
case BELL:
|
||||||
isc = 1; *dst++ = '\\'; *dst++ = 'a'; \
|
*dst++ = '\\'; *dst++ = 'a';
|
||||||
break; \
|
return dst;
|
||||||
case '\v': \
|
case '\v':
|
||||||
isc = 1; *dst++ = '\\'; *dst++ = 'v'; \
|
*dst++ = '\\'; *dst++ = 'v';
|
||||||
break; \
|
return dst;
|
||||||
case '\t': \
|
case '\t':
|
||||||
isc = 1; *dst++ = '\\'; *dst++ = 't'; \
|
*dst++ = '\\'; *dst++ = 't';
|
||||||
break; \
|
return dst;
|
||||||
case '\f': \
|
case '\f':
|
||||||
isc = 1; *dst++ = '\\'; *dst++ = 'f'; \
|
*dst++ = '\\'; *dst++ = 'f';
|
||||||
break; \
|
return dst;
|
||||||
case ' ': \
|
case ' ':
|
||||||
isc = 1; *dst++ = '\\'; *dst++ = 's'; \
|
*dst++ = '\\'; *dst++ = 's';
|
||||||
break; \
|
return dst;
|
||||||
case '\0': \
|
case '\0':
|
||||||
isc = 1; *dst++ = '\\'; *dst++ = '0'; \
|
*dst++ = '\\'; *dst++ = '0';
|
||||||
if (isoctal(nextc)) { \
|
if (isoctal(nextc)) {
|
||||||
*dst++ = '0'; \
|
*dst++ = '0';
|
||||||
*dst++ = '0'; \
|
*dst++ = '0';
|
||||||
} \
|
}
|
||||||
} \
|
return dst;
|
||||||
} \
|
default:
|
||||||
if (isc) break; \
|
if (isgraph(c)) {
|
||||||
if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \
|
*dst++ = '\\'; *dst++ = c;
|
||||||
*dst++ = '\\'; \
|
return dst;
|
||||||
*dst++ = (unsigned char)(((unsigned int)(unsigned char)c >> 6) & 03) + '0'; \
|
}
|
||||||
*dst++ = (unsigned char)(((unsigned int)(unsigned char)c >> 3) & 07) + '0'; \
|
}
|
||||||
*dst++ = (c & 07) + '0'; \
|
}
|
||||||
} else { \
|
if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) {
|
||||||
if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \
|
*dst++ = '\\';
|
||||||
if (c & 0200) { \
|
*dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + '0';
|
||||||
c &= 0177; *dst++ = 'M'; \
|
*dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + '0';
|
||||||
} \
|
*dst++ = (c & 07) + '0';
|
||||||
if (iscntrl(c)) { \
|
} else {
|
||||||
*dst++ = '^'; \
|
if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\';
|
||||||
if (c == 0177) \
|
if (c & 0200) {
|
||||||
*dst++ = '?'; \
|
c &= 0177; *dst++ = 'M';
|
||||||
else \
|
}
|
||||||
*dst++ = c + '@'; \
|
if (iscntrl(c)) {
|
||||||
} else { \
|
*dst++ = '^';
|
||||||
*dst++ = '-'; *dst++ = c; \
|
if (c == 0177)
|
||||||
} \
|
*dst++ = '?';
|
||||||
} \
|
else
|
||||||
} while (/*CONSTCOND*/0)
|
*dst++ = c + '@';
|
||||||
|
} else {
|
||||||
|
*dst++ = '-'; *dst++ = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -195,22 +220,24 @@ do { \
|
|||||||
* pointed to by `extra'
|
* pointed to by `extra'
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
svis(dst, c, flag, nextc, extra)
|
svis(char *dst, int c, int flag, int nextc, const char *extra)
|
||||||
char *dst;
|
|
||||||
int c, flag, nextc;
|
|
||||||
const char *extra;
|
|
||||||
{
|
{
|
||||||
char *nextra, *to_be_freed;
|
char *nextra = NULL;
|
||||||
|
|
||||||
_DIAGASSERT(dst != NULL);
|
_DIAGASSERT(dst != NULL);
|
||||||
_DIAGASSERT(extra != NULL);
|
_DIAGASSERT(extra != NULL);
|
||||||
nextra= to_be_freed= MAKEEXTRALIST(flag, extra);
|
MAKEEXTRALIST(flag, nextra, extra);
|
||||||
|
if (!nextra) {
|
||||||
|
*dst = '\0'; /* can't create nextra, return "" */
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
if (flag & VIS_HTTPSTYLE)
|
if (flag & VIS_HTTPSTYLE)
|
||||||
HVIS(dst, c, flag, nextc, nextra);
|
dst = do_hvis(dst, c, flag, nextc, nextra);
|
||||||
else
|
else
|
||||||
SVIS(dst, c, flag, nextc, nextra);
|
dst = do_svis(dst, c, flag, nextc, nextra);
|
||||||
|
free(nextra);
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
free(to_be_freed);
|
return dst;
|
||||||
return(dst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -230,89 +257,94 @@ svis(dst, c, flag, nextc, extra)
|
|||||||
* This is useful for encoding a block of data.
|
* This is useful for encoding a block of data.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
strsvis(dst, src, flag, extra)
|
strsvis(char *dst, const char *csrc, int flag, const char *extra)
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
int flag;
|
|
||||||
const char *extra;
|
|
||||||
{
|
{
|
||||||
char c;
|
int c;
|
||||||
char *start;
|
char *start;
|
||||||
char *nextra, *to_be_freed;
|
char *nextra = NULL;
|
||||||
|
const unsigned char *src = (const unsigned char *)csrc;
|
||||||
|
|
||||||
_DIAGASSERT(dst != NULL);
|
_DIAGASSERT(dst != NULL);
|
||||||
_DIAGASSERT(src != NULL);
|
_DIAGASSERT(src != NULL);
|
||||||
_DIAGASSERT(extra != NULL);
|
_DIAGASSERT(extra != NULL);
|
||||||
nextra= to_be_freed= MAKEEXTRALIST(flag, extra);
|
MAKEEXTRALIST(flag, nextra, extra);
|
||||||
|
if (!nextra) {
|
||||||
|
*dst = '\0'; /* can't create nextra, return "" */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (flag & VIS_HTTPSTYLE) {
|
if (flag & VIS_HTTPSTYLE) {
|
||||||
for (start = dst; (c = *src++) != '\0'; /* empty */)
|
for (start = dst; (c = *src++) != '\0'; /* empty */)
|
||||||
HVIS(dst, c, flag, *src, nextra);
|
dst = do_hvis(dst, c, flag, *src, nextra);
|
||||||
} else {
|
} else {
|
||||||
for (start = dst; (c = *src++) != '\0'; /* empty */)
|
for (start = dst; (c = *src++) != '\0'; /* empty */)
|
||||||
SVIS(dst, c, flag, *src, nextra);
|
dst = do_svis(dst, c, flag, *src, nextra);
|
||||||
}
|
}
|
||||||
|
free(nextra);
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
free(to_be_freed);
|
|
||||||
return (dst - start);
|
return (dst - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
strsvisx(dst, src, len, flag, extra)
|
strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
size_t len;
|
|
||||||
int flag;
|
|
||||||
const char *extra;
|
|
||||||
{
|
{
|
||||||
char c;
|
unsigned char c;
|
||||||
char *start;
|
char *start;
|
||||||
char *nextra, *to_be_freed;
|
char *nextra = NULL;
|
||||||
|
const unsigned char *src = (const unsigned char *)csrc;
|
||||||
|
|
||||||
_DIAGASSERT(dst != NULL);
|
_DIAGASSERT(dst != NULL);
|
||||||
_DIAGASSERT(src != NULL);
|
_DIAGASSERT(src != NULL);
|
||||||
_DIAGASSERT(extra != NULL);
|
_DIAGASSERT(extra != NULL);
|
||||||
nextra= to_be_freed= MAKEEXTRALIST(flag, extra);
|
MAKEEXTRALIST(flag, nextra, extra);
|
||||||
|
if (! nextra) {
|
||||||
|
*dst = '\0'; /* can't create nextra, return "" */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (flag & VIS_HTTPSTYLE) {
|
if (flag & VIS_HTTPSTYLE) {
|
||||||
for (start = dst; len > 0; len--) {
|
for (start = dst; len > 0; len--) {
|
||||||
c = *src++;
|
c = *src++;
|
||||||
HVIS(dst, c, flag, len ? *src : '\0', nextra);
|
dst = do_hvis(dst, c, flag,
|
||||||
|
len > 1 ? *src : '\0', nextra);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (start = dst; len > 0; len--) {
|
for (start = dst; len > 0; len--) {
|
||||||
c = *src++;
|
c = *src++;
|
||||||
SVIS(dst, c, flag, len ? *src : '\0', nextra);
|
dst = do_svis(dst, c, flag,
|
||||||
|
len > 1 ? *src : '\0', nextra);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(nextra);
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
free(to_be_freed);
|
|
||||||
return (dst - start);
|
return (dst - start);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_VIS
|
||||||
/*
|
/*
|
||||||
* vis - visually encode characters
|
* vis - visually encode characters
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
vis(dst, c, flag, nextc)
|
vis(char *dst, int c, int flag, int nextc)
|
||||||
char *dst;
|
|
||||||
int c, flag, nextc;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
char *extra, *to_be_freed;
|
char *extra = NULL;
|
||||||
|
unsigned char uc = (unsigned char)c;
|
||||||
|
|
||||||
_DIAGASSERT(dst != NULL);
|
_DIAGASSERT(dst != NULL);
|
||||||
|
|
||||||
extra= to_be_freed= MAKEEXTRALIST(flag, "");
|
MAKEEXTRALIST(flag, extra, "");
|
||||||
|
if (! extra) {
|
||||||
|
*dst = '\0'; /* can't create extra, return "" */
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
if (flag & VIS_HTTPSTYLE)
|
if (flag & VIS_HTTPSTYLE)
|
||||||
HVIS(dst, c, flag, nextc, extra);
|
dst = do_hvis(dst, uc, flag, nextc, extra);
|
||||||
else
|
else
|
||||||
SVIS(dst, c, flag, nextc, extra);
|
dst = do_svis(dst, uc, flag, nextc, extra);
|
||||||
|
free(extra);
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
free(to_be_freed);
|
return dst;
|
||||||
return (dst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -327,34 +359,35 @@ vis(dst, c, flag, nextc)
|
|||||||
* This is useful for encoding a block of data.
|
* This is useful for encoding a block of data.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
strvis(dst, src, flag)
|
strvis(char *dst, const char *src, int flag)
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
int flag;
|
|
||||||
{
|
{
|
||||||
char *extra;
|
char *extra = NULL;
|
||||||
int tmp;
|
int rv;
|
||||||
|
|
||||||
extra= MAKEEXTRALIST(flag, "");
|
MAKEEXTRALIST(flag, extra, "");
|
||||||
tmp= strsvis(dst, src, flag, extra);
|
if (!extra) {
|
||||||
|
*dst = '\0'; /* can't create extra, return "" */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
rv = strsvis(dst, src, flag, extra);
|
||||||
free(extra);
|
free(extra);
|
||||||
return tmp;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
strvisx(dst, src, len, flag)
|
strvisx(char *dst, const char *src, size_t len, int flag)
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
size_t len;
|
|
||||||
int flag;
|
|
||||||
{
|
{
|
||||||
char *extra;
|
char *extra = NULL;
|
||||||
int tmp;
|
int rv;
|
||||||
|
|
||||||
extra= MAKEEXTRALIST(flag, "");
|
MAKEEXTRALIST(flag, extra, "");
|
||||||
tmp= strsvisx(dst, src, len, flag, extra);
|
if (!extra) {
|
||||||
|
*dst = '\0'; /* can't create extra, return "" */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
rv = strsvisx(dst, src, len, flag, extra);
|
||||||
free(extra);
|
free(extra);
|
||||||
return tmp;
|
return rv;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: vis.h,v 1.12 2002/03/23 17:39:05 christos Exp $ */
|
/* $NetBSD: vis.h,v 1.16 2005/09/13 01:44:32 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990, 1993
|
* Copyright (c) 1990, 1993
|
||||||
@ -12,11 +12,7 @@
|
|||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
@ -38,9 +34,7 @@
|
|||||||
#ifndef _VIS_H_
|
#ifndef _VIS_H_
|
||||||
#define _VIS_H_
|
#define _VIS_H_
|
||||||
|
|
||||||
#ifdef HAVE_SYS_CDEFS_H
|
#include <sys/types.h>
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* to select alternate encoding format
|
* to select alternate encoding format
|
||||||
@ -78,6 +72,7 @@
|
|||||||
*/
|
*/
|
||||||
#define UNVIS_END 1 /* no more characters */
|
#define UNVIS_END 1 /* no more characters */
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
char *vis(char *, int, int, int);
|
char *vis(char *, int, int, int);
|
||||||
char *svis(char *, int, int, int, const char *);
|
char *svis(char *, int, int, int, const char *);
|
||||||
int strvis(char *, const char *, int);
|
int strvis(char *, const char *, int);
|
||||||
@ -86,11 +81,7 @@ int strvisx(char *, const char *, size_t, int);
|
|||||||
int strsvisx(char *, const char *, size_t, int, const char *);
|
int strsvisx(char *, const char *, size_t, int, const char *);
|
||||||
int strunvis(char *, const char *);
|
int strunvis(char *, const char *);
|
||||||
int strunvisx(char *, const char *, int);
|
int strunvisx(char *, const char *, int);
|
||||||
#ifdef __LIBC12_SOURCE__
|
|
||||||
int unvis(char *, int, int *, int);
|
int unvis(char *, int, int *, int);
|
||||||
int __unvis13(char *, int, int *, int);
|
__END_DECLS
|
||||||
#else
|
|
||||||
int unvis(char *, int, int *, int) __RENAME(__unvis13);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !_VIS_H_ */
|
#endif /* !_VIS_H_ */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: parse.c,v 1.20 2003/12/05 13:37:48 lukem Exp $ */
|
/* $NetBSD: parse.c,v 1.22 2005/05/29 04:58:15 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* parse.c: parse an editline extended command
|
* parse.c: parse an editline extended command
|
||||||
@ -129,7 +135,7 @@ el_parse(EditLine *el, int argc, const char *argv[])
|
|||||||
* the appropriate character or -1 if the escape is not valid
|
* the appropriate character or -1 if the escape is not valid
|
||||||
*/
|
*/
|
||||||
protected int
|
protected int
|
||||||
parse__escape(const char **const ptr)
|
parse__escape(const char **ptr)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
int c;
|
int c;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: parse.h,v 1.5 2003/08/07 16:44:32 agc Exp $ */
|
/* $NetBSD: parse.h,v 1.6 2005/05/29 04:58:15 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -41,7 +41,7 @@
|
|||||||
#define _h_el_parse
|
#define _h_el_parse
|
||||||
|
|
||||||
protected int parse_line(EditLine *, const char *);
|
protected int parse_line(EditLine *, const char *);
|
||||||
protected int parse__escape(const char ** const);
|
protected int parse__escape(const char **);
|
||||||
protected char *parse__string(char *, const char *);
|
protected char *parse__string(char *, const char *);
|
||||||
protected int parse_cmd(EditLine *, const char *);
|
protected int parse_cmd(EditLine *, const char *);
|
||||||
|
|
||||||
|
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* prompt.c: Prompt printing functions
|
* prompt.c: Prompt printing functions
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: read.c,v 1.35 2005/03/09 23:55:02 christos Exp $ */
|
/* $NetBSD: read.c,v 1.43 2009/02/05 19:15:44 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read.c: Clean this junk up! This is horrible code.
|
* read.c: Clean this junk up! This is horrible code.
|
||||||
@ -50,6 +56,7 @@ private int read__fixio(int, int);
|
|||||||
private int read_preread(EditLine *);
|
private int read_preread(EditLine *);
|
||||||
private int read_char(EditLine *, char *);
|
private int read_char(EditLine *, char *);
|
||||||
private int read_getcmd(EditLine *, el_action_t *, char *);
|
private int read_getcmd(EditLine *, el_action_t *, char *);
|
||||||
|
private void read_pop(c_macro_t *);
|
||||||
|
|
||||||
/* read_init():
|
/* read_init():
|
||||||
* Initialize the read stuff
|
* Initialize the read stuff
|
||||||
@ -205,7 +212,7 @@ read_preread(EditLine *el)
|
|||||||
* Push a macro
|
* Push a macro
|
||||||
*/
|
*/
|
||||||
public void
|
public void
|
||||||
el_push(EditLine *el, char *str)
|
el_push(EditLine *el, const char *str)
|
||||||
{
|
{
|
||||||
c_macro_t *ma = &el->el_chared.c_macro;
|
c_macro_t *ma = &el->el_chared.c_macro;
|
||||||
|
|
||||||
@ -216,7 +223,7 @@ el_push(EditLine *el, char *str)
|
|||||||
ma->level--;
|
ma->level--;
|
||||||
}
|
}
|
||||||
term_beep(el);
|
term_beep(el);
|
||||||
term__flush();
|
term__flush(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -294,6 +301,19 @@ read_char(EditLine *el, char *cp)
|
|||||||
return (num_read);
|
return (num_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* read_pop():
|
||||||
|
* Pop a macro from the stack
|
||||||
|
*/
|
||||||
|
private void
|
||||||
|
read_pop(c_macro_t *ma)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
el_free(ma->macro[0]);
|
||||||
|
for (i = ma->level--; i > 0; i--)
|
||||||
|
ma->macro[i - 1] = ma->macro[i];
|
||||||
|
ma->offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* el_getc():
|
/* el_getc():
|
||||||
* Read a character
|
* Read a character
|
||||||
@ -304,26 +324,28 @@ el_getc(EditLine *el, char *cp)
|
|||||||
int num_read;
|
int num_read;
|
||||||
c_macro_t *ma = &el->el_chared.c_macro;
|
c_macro_t *ma = &el->el_chared.c_macro;
|
||||||
|
|
||||||
term__flush();
|
term__flush(el);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (ma->level < 0) {
|
if (ma->level < 0) {
|
||||||
if (!read_preread(el))
|
if (!read_preread(el))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ma->level < 0)
|
if (ma->level < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (ma->macro[ma->level][ma->offset] == '\0') {
|
if (ma->macro[0][ma->offset] == '\0') {
|
||||||
el_free(ma->macro[ma->level--]);
|
read_pop(ma);
|
||||||
ma->offset = 0;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
*cp = ma->macro[ma->level][ma->offset++] & 0377;
|
|
||||||
if (ma->macro[ma->level][ma->offset] == '\0') {
|
*cp = ma->macro[0][ma->offset++] & 0377;
|
||||||
|
|
||||||
|
if (ma->macro[0][ma->offset] == '\0') {
|
||||||
/* Needed for QuoteMode On */
|
/* Needed for QuoteMode On */
|
||||||
el_free(ma->macro[ma->level--]);
|
read_pop(ma);
|
||||||
ma->offset = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,11 +379,11 @@ read_prepare(EditLine *el)
|
|||||||
we have the wrong size. */
|
we have the wrong size. */
|
||||||
el_resize(el);
|
el_resize(el);
|
||||||
re_clear_display(el); /* reset the display stuff */
|
re_clear_display(el); /* reset the display stuff */
|
||||||
ch_reset(el);
|
ch_reset(el, 0);
|
||||||
re_refresh(el); /* print the prompt */
|
re_refresh(el); /* print the prompt */
|
||||||
|
|
||||||
if (el->el_flags & UNBUFFERED)
|
if (el->el_flags & UNBUFFERED)
|
||||||
term__flush();
|
term__flush(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void
|
protected void
|
||||||
@ -438,7 +460,7 @@ el_gets(EditLine *el, int *nread)
|
|||||||
else
|
else
|
||||||
cp = el->el_line.lastchar;
|
cp = el->el_line.lastchar;
|
||||||
|
|
||||||
term__flush();
|
term__flush(el);
|
||||||
|
|
||||||
while ((*el->el_read.read_char)(el, cp) == 1) {
|
while ((*el->el_read.read_char)(el, cp) == 1) {
|
||||||
/* make sure there is space next character */
|
/* make sure there is space next character */
|
||||||
@ -478,7 +500,7 @@ el_gets(EditLine *el, int *nread)
|
|||||||
#endif /* DEBUG_READ */
|
#endif /* DEBUG_READ */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((unsigned int)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */
|
if ((unsigned int)cmdnum >= (unsigned int)el->el_map.nfunc) { /* BUG CHECK command */
|
||||||
#ifdef DEBUG_EDIT
|
#ifdef DEBUG_EDIT
|
||||||
(void) fprintf(el->el_errfile,
|
(void) fprintf(el->el_errfile,
|
||||||
"ERROR: illegal command from key 0%o\r\n", ch);
|
"ERROR: illegal command from key 0%o\r\n", ch);
|
||||||
@ -570,7 +592,7 @@ el_gets(EditLine *el, int *nread)
|
|||||||
#endif /* DEBUG_READ */
|
#endif /* DEBUG_READ */
|
||||||
/* put (real) cursor in a known place */
|
/* put (real) cursor in a known place */
|
||||||
re_clear_display(el); /* reset the display stuff */
|
re_clear_display(el); /* reset the display stuff */
|
||||||
ch_reset(el); /* reset the input pointers */
|
ch_reset(el, 1); /* reset the input pointers */
|
||||||
re_refresh(el); /* print the prompt again */
|
re_refresh(el); /* print the prompt again */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -581,7 +603,7 @@ el_gets(EditLine *el, int *nread)
|
|||||||
"*** editor ERROR ***\r\n\n");
|
"*** editor ERROR ***\r\n\n");
|
||||||
#endif /* DEBUG_READ */
|
#endif /* DEBUG_READ */
|
||||||
term_beep(el);
|
term_beep(el);
|
||||||
term__flush();
|
term__flush(el);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
el->el_state.argument = 1;
|
el->el_state.argument = 1;
|
||||||
@ -591,7 +613,7 @@ el_gets(EditLine *el, int *nread)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
term__flush(); /* flush any buffered output */
|
term__flush(el); /* flush any buffered output */
|
||||||
/* make sure the tty is set up correctly */
|
/* make sure the tty is set up correctly */
|
||||||
if ((el->el_flags & UNBUFFERED) == 0) {
|
if ((el->el_flags & UNBUFFERED) == 0) {
|
||||||
read_finish(el);
|
read_finish(el);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: read.h,v 1.4 2004/02/27 14:52:18 christos Exp $ */
|
/* $NetBSD: read.h,v 1.6 2008/04/29 06:53:01 martin Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||||
@ -15,13 +15,6 @@
|
|||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the NetBSD
|
|
||||||
* Foundation, Inc. and its contributors.
|
|
||||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: readline.h,v 1.12 2004/09/08 18:15:37 christos Exp $ */
|
/* $NetBSD: readline.h,v 1.24 2009/02/05 19:15:26 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||||
@ -15,13 +15,6 @@
|
|||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the NetBSD
|
|
||||||
* Foundation, Inc. and its contributors.
|
|
||||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
@ -45,14 +38,14 @@
|
|||||||
/* typedefs */
|
/* typedefs */
|
||||||
typedef int Function(const char *, int);
|
typedef int Function(const char *, int);
|
||||||
typedef void VFunction(void);
|
typedef void VFunction(void);
|
||||||
|
typedef void VCPFunction(char *);
|
||||||
typedef char *CPFunction(const char *, int);
|
typedef char *CPFunction(const char *, int);
|
||||||
typedef char **CPPFunction(const char *, int, int);
|
typedef char **CPPFunction(const char *, int, int);
|
||||||
|
typedef char *rl_compentry_func_t(const char *, int);
|
||||||
typedef void *histdata_t;
|
|
||||||
|
|
||||||
typedef struct _hist_entry {
|
typedef struct _hist_entry {
|
||||||
const char *line;
|
const char *line;
|
||||||
histdata_t *data;
|
const char *data;
|
||||||
} HIST_ENTRY;
|
} HIST_ENTRY;
|
||||||
|
|
||||||
typedef struct _keymap_entry {
|
typedef struct _keymap_entry {
|
||||||
@ -73,7 +66,7 @@ typedef KEYMAP_ENTRY *Keymap;
|
|||||||
|
|
||||||
#ifndef CTRL
|
#ifndef CTRL
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#if defined(__GLIBC__) || defined(__MWERKS__)
|
#if !defined(__sun) && !defined(__hpux) && !defined(_AIX)
|
||||||
#include <sys/ttydefaults.h>
|
#include <sys/ttydefaults.h>
|
||||||
#endif
|
#endif
|
||||||
#ifndef CTRL
|
#ifndef CTRL
|
||||||
@ -102,8 +95,9 @@ extern int max_input_history;
|
|||||||
extern char *rl_basic_word_break_characters;
|
extern char *rl_basic_word_break_characters;
|
||||||
extern char *rl_completer_word_break_characters;
|
extern char *rl_completer_word_break_characters;
|
||||||
extern char *rl_completer_quote_characters;
|
extern char *rl_completer_quote_characters;
|
||||||
extern CPFunction *rl_completion_entry_function;
|
extern Function *rl_completion_entry_function;
|
||||||
extern CPPFunction *rl_attempted_completion_function;
|
extern CPPFunction *rl_attempted_completion_function;
|
||||||
|
extern int rl_attempted_completion_over;
|
||||||
extern int rl_completion_type;
|
extern int rl_completion_type;
|
||||||
extern int rl_completion_query_items;
|
extern int rl_completion_query_items;
|
||||||
extern char *rl_special_prefixes;
|
extern char *rl_special_prefixes;
|
||||||
@ -122,11 +116,13 @@ extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
|
|||||||
emacs_ctlx_keymap;
|
emacs_ctlx_keymap;
|
||||||
extern int rl_filename_completion_desired;
|
extern int rl_filename_completion_desired;
|
||||||
extern int rl_ignore_completion_duplicates;
|
extern int rl_ignore_completion_duplicates;
|
||||||
extern Function *rl_getc_function;
|
extern int (*rl_getc_function)(FILE *);
|
||||||
extern VFunction *rl_redisplay_function;
|
extern VFunction *rl_redisplay_function;
|
||||||
extern VFunction *rl_completion_display_matches_hook;
|
extern VFunction *rl_completion_display_matches_hook;
|
||||||
extern VFunction *rl_prep_term_function;
|
extern VFunction *rl_prep_term_function;
|
||||||
extern VFunction *rl_deprep_term_function;
|
extern VFunction *rl_deprep_term_function;
|
||||||
|
extern int readline_echoing_p;
|
||||||
|
extern int _rl_print_completions_horizontally;
|
||||||
|
|
||||||
/* supported functions */
|
/* supported functions */
|
||||||
char *readline(const char *);
|
char *readline(const char *);
|
||||||
@ -141,6 +137,7 @@ int history_is_stifled(void);
|
|||||||
int where_history(void);
|
int where_history(void);
|
||||||
HIST_ENTRY *current_history(void);
|
HIST_ENTRY *current_history(void);
|
||||||
HIST_ENTRY *history_get(int);
|
HIST_ENTRY *history_get(int);
|
||||||
|
HIST_ENTRY *remove_history(int);
|
||||||
int history_total_bytes(void);
|
int history_total_bytes(void);
|
||||||
int history_set_pos(int);
|
int history_set_pos(int);
|
||||||
HIST_ENTRY *previous_history(void);
|
HIST_ENTRY *previous_history(void);
|
||||||
@ -168,7 +165,7 @@ void rl_reset_terminal(const char *);
|
|||||||
int rl_bind_key(int, int (*)(int, int));
|
int rl_bind_key(int, int (*)(int, int));
|
||||||
int rl_newline(int, int);
|
int rl_newline(int, int);
|
||||||
void rl_callback_read_char(void);
|
void rl_callback_read_char(void);
|
||||||
void rl_callback_handler_install(const char *, VFunction *);
|
void rl_callback_handler_install(const char *, VCPFunction *);
|
||||||
void rl_callback_handler_remove(void);
|
void rl_callback_handler_remove(void);
|
||||||
void rl_redisplay(void);
|
void rl_redisplay(void);
|
||||||
int rl_get_previous_history(int, int);
|
int rl_get_previous_history(int, int);
|
||||||
@ -176,13 +173,24 @@ void rl_prep_terminal(int);
|
|||||||
void rl_deprep_terminal(void);
|
void rl_deprep_terminal(void);
|
||||||
int rl_read_init_file(const char *);
|
int rl_read_init_file(const char *);
|
||||||
int rl_parse_and_bind(const char *);
|
int rl_parse_and_bind(const char *);
|
||||||
|
int rl_variable_bind(const char *, const char *);
|
||||||
void rl_stuff_char(int);
|
void rl_stuff_char(int);
|
||||||
int rl_add_defun(const char *, Function *, int);
|
int rl_add_defun(const char *, Function *, int);
|
||||||
|
void rl_get_screen_size(int *, int *);
|
||||||
|
void rl_set_screen_size(int, int);
|
||||||
|
char *rl_filename_completion_function (const char *, int);
|
||||||
|
int _rl_abort_internal(void);
|
||||||
|
int _rl_qsort_string_compare(char **, char **);
|
||||||
|
char **rl_completion_matches(const char *, rl_compentry_func_t *);
|
||||||
|
void rl_forced_update_display(void);
|
||||||
|
int rl_set_prompt(const char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following are not implemented
|
* The following are not implemented
|
||||||
*/
|
*/
|
||||||
|
int rl_kill_text(int, int);
|
||||||
Keymap rl_get_keymap(void);
|
Keymap rl_get_keymap(void);
|
||||||
|
void rl_set_keymap(Keymap);
|
||||||
Keymap rl_make_bare_keymap(void);
|
Keymap rl_make_bare_keymap(void);
|
||||||
int rl_generic_bind(int, const char *, const char *, Keymap);
|
int rl_generic_bind(int, const char *, const char *, Keymap);
|
||||||
int rl_bind_key_in_map(int, Function *, Keymap);
|
int rl_bind_key_in_map(int, Function *, Keymap);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: refresh.c,v 1.26 2003/08/07 16:44:33 agc Exp $ */
|
/* $NetBSD: refresh.c,v 1.28 2008/09/10 15:45:37 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* refresh.c: Lower level screen refreshing functions
|
* refresh.c: Lower level screen refreshing functions
|
||||||
@ -49,6 +55,7 @@ private void re_update_line(EditLine *, char *, char *, int);
|
|||||||
private void re_insert (EditLine *, char *, int, int, char *, int);
|
private void re_insert (EditLine *, char *, int, int, char *, int);
|
||||||
private void re_delete(EditLine *, char *, int, int, int);
|
private void re_delete(EditLine *, char *, int, int, int);
|
||||||
private void re_fastputc(EditLine *, int);
|
private void re_fastputc(EditLine *, int);
|
||||||
|
private void re_clear_eol(EditLine *, int, int, int);
|
||||||
private void re__strncopy(char *, char *, size_t);
|
private void re__strncopy(char *, char *, size_t);
|
||||||
private void re__copy_and_pad(char *, const char *, size_t);
|
private void re__copy_and_pad(char *, const char *, size_t);
|
||||||
|
|
||||||
@ -315,9 +322,9 @@ re_goto_bottom(EditLine *el)
|
|||||||
{
|
{
|
||||||
|
|
||||||
term_move_to_line(el, el->el_refresh.r_oldcv);
|
term_move_to_line(el, el->el_refresh.r_oldcv);
|
||||||
term__putc('\n');
|
term__putc(el, '\n');
|
||||||
re_clear_display(el);
|
re_clear_display(el);
|
||||||
term__flush();
|
term__flush(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -340,7 +347,7 @@ re_insert(EditLine *el __attribute__((__unused__)),
|
|||||||
ELRE_DEBUG(1,
|
ELRE_DEBUG(1,
|
||||||
(__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n",
|
(__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n",
|
||||||
num, dat, dlen, d));
|
num, dat, dlen, d));
|
||||||
ELRE_DEBUG(1, (__F, "s == \"%s\"n", s));
|
ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s));
|
||||||
|
|
||||||
/* open up the space for num chars */
|
/* open up the space for num chars */
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
@ -353,7 +360,7 @@ re_insert(EditLine *el __attribute__((__unused__)),
|
|||||||
ELRE_DEBUG(1, (__F,
|
ELRE_DEBUG(1, (__F,
|
||||||
"re_insert() after insert: %d at %d max %d, d == \"%s\"\n",
|
"re_insert() after insert: %d at %d max %d, d == \"%s\"\n",
|
||||||
num, dat, dlen, d));
|
num, dat, dlen, d));
|
||||||
ELRE_DEBUG(1, (__F, "s == \"%s\"n", s));
|
ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s));
|
||||||
|
|
||||||
/* copy the characters */
|
/* copy the characters */
|
||||||
for (a = d + dat; (a < d + dlen) && (num > 0); num--)
|
for (a = d + dat; (a < d + dlen) && (num > 0); num--)
|
||||||
@ -362,7 +369,7 @@ re_insert(EditLine *el __attribute__((__unused__)),
|
|||||||
ELRE_DEBUG(1,
|
ELRE_DEBUG(1,
|
||||||
(__F, "re_insert() after copy: %d at %d max %d, %s == \"%s\"\n",
|
(__F, "re_insert() after copy: %d at %d max %d, %s == \"%s\"\n",
|
||||||
num, dat, dlen, d, s));
|
num, dat, dlen, d, s));
|
||||||
ELRE_DEBUG(1, (__F, "s == \"%s\"n", s));
|
ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -411,6 +418,32 @@ re__strncopy(char *a, char *b, size_t n)
|
|||||||
*a++ = *b++;
|
*a++ = *b++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* re_clear_eol():
|
||||||
|
* Find the number of characters we need to clear till the end of line
|
||||||
|
* in order to make sure that we have cleared the previous contents of
|
||||||
|
* the line. fx and sx is the number of characters inserted or deleted
|
||||||
|
* int the first or second diff, diff is the difference between the
|
||||||
|
* number of characters between the new and old line.
|
||||||
|
*/
|
||||||
|
private void
|
||||||
|
re_clear_eol(EditLine *el, int fx, int sx, int diff)
|
||||||
|
{
|
||||||
|
|
||||||
|
ELRE_DEBUG(1, (__F, "re_clear_eol sx %d, fx %d, diff %d\n",
|
||||||
|
sx, fx, diff));
|
||||||
|
|
||||||
|
if (fx < 0)
|
||||||
|
fx = -fx;
|
||||||
|
if (sx < 0)
|
||||||
|
sx = -sx;
|
||||||
|
if (fx > diff)
|
||||||
|
diff = fx;
|
||||||
|
if (sx > diff)
|
||||||
|
diff = sx;
|
||||||
|
|
||||||
|
ELRE_DEBUG(1, (__F, "re_clear_eol %d\n", diff));
|
||||||
|
term_clear_EOL(el, diff);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
re_update_line() is based on finding the middle difference of each line
|
re_update_line() is based on finding the middle difference of each line
|
||||||
@ -626,7 +659,7 @@ re_update_line(EditLine *el, char *old, char *new, int i)
|
|||||||
fx = (nsb - nfd) - (osb - ofd);
|
fx = (nsb - nfd) - (osb - ofd);
|
||||||
sx = (nls - nse) - (ols - ose);
|
sx = (nls - nse) - (ols - ose);
|
||||||
|
|
||||||
ELRE_DEBUG(1, (__F, "\n"));
|
ELRE_DEBUG(1, (__F, "fx %d, sx %d\n", fx, sx));
|
||||||
ELRE_DEBUG(1, (__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n",
|
ELRE_DEBUG(1, (__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n",
|
||||||
ofd - old, osb - old, ose - old, ols - old, oe - old));
|
ofd - old, osb - old, ose - old, ols - old, oe - old));
|
||||||
ELRE_DEBUG(1, (__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n",
|
ELRE_DEBUG(1, (__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n",
|
||||||
@ -775,9 +808,7 @@ re_update_line(EditLine *el, char *old, char *new, int i)
|
|||||||
* write (nsb-nfd) chars of new starting at nfd
|
* write (nsb-nfd) chars of new starting at nfd
|
||||||
*/
|
*/
|
||||||
term_overwrite(el, nfd, (nsb - nfd));
|
term_overwrite(el, nfd, (nsb - nfd));
|
||||||
ELRE_DEBUG(1, (__F,
|
re_clear_eol(el, fx, sx, (oe - old) - (ne - new));
|
||||||
"cleareol %d\n", (oe - old) - (ne - new)));
|
|
||||||
term_clear_EOL(el, (oe - old) - (ne - new));
|
|
||||||
/*
|
/*
|
||||||
* Done
|
* Done
|
||||||
*/
|
*/
|
||||||
@ -818,10 +849,7 @@ re_update_line(EditLine *el, char *old, char *new, int i)
|
|||||||
ELRE_DEBUG(1, (__F,
|
ELRE_DEBUG(1, (__F,
|
||||||
"but with nothing left to save\r\n"));
|
"but with nothing left to save\r\n"));
|
||||||
term_overwrite(el, nse, (nls - nse));
|
term_overwrite(el, nse, (nls - nse));
|
||||||
ELRE_DEBUG(1, (__F,
|
re_clear_eol(el, fx, sx, (oe - old) - (ne - new));
|
||||||
"cleareol %d\n", (oe - old) - (ne - new)));
|
|
||||||
if ((oe - old) - (ne - new) != 0)
|
|
||||||
term_clear_EOL(el, (oe - old) - (ne - new));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -982,7 +1010,7 @@ re_refresh_cursor(EditLine *el)
|
|||||||
/* now go there */
|
/* now go there */
|
||||||
term_move_to_line(el, v);
|
term_move_to_line(el, v);
|
||||||
term_move_to_char(el, h);
|
term_move_to_char(el, h);
|
||||||
term__flush();
|
term__flush(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -993,7 +1021,7 @@ private void
|
|||||||
re_fastputc(EditLine *el, int c)
|
re_fastputc(EditLine *el, int c)
|
||||||
{
|
{
|
||||||
|
|
||||||
term__putc(c);
|
term__putc(el, c);
|
||||||
el->el_display[el->el_cursor.v][el->el_cursor.h++] = c;
|
el->el_display[el->el_cursor.v][el->el_cursor.h++] = c;
|
||||||
if (el->el_cursor.h >= el->el_term.t_size.h) {
|
if (el->el_cursor.h >= el->el_term.t_size.h) {
|
||||||
/* if we must overflow */
|
/* if we must overflow */
|
||||||
@ -1020,12 +1048,12 @@ re_fastputc(EditLine *el, int c)
|
|||||||
}
|
}
|
||||||
if (EL_HAS_AUTO_MARGINS) {
|
if (EL_HAS_AUTO_MARGINS) {
|
||||||
if (EL_HAS_MAGIC_MARGINS) {
|
if (EL_HAS_MAGIC_MARGINS) {
|
||||||
term__putc(' ');
|
term__putc(el, ' ');
|
||||||
term__putc('\b');
|
term__putc(el, '\b');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
term__putc('\r');
|
term__putc(el, '\r');
|
||||||
term__putc('\n');
|
term__putc(el, '\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1065,7 +1093,7 @@ re_fastaddc(EditLine *el)
|
|||||||
re_fastputc(el, (int)(((((unsigned int)c) >> 3) & 7) + '0'));
|
re_fastputc(el, (int)(((((unsigned int)c) >> 3) & 7) + '0'));
|
||||||
re_fastputc(el, (c & 7) + '0');
|
re_fastputc(el, (c & 7) + '0');
|
||||||
}
|
}
|
||||||
term__flush();
|
term__flush(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1104,7 +1132,7 @@ re_clear_lines(EditLine *el)
|
|||||||
} else {
|
} else {
|
||||||
term_move_to_line(el, el->el_refresh.r_oldcv);
|
term_move_to_line(el, el->el_refresh.r_oldcv);
|
||||||
/* go to last line */
|
/* go to last line */
|
||||||
term__putc('\r'); /* go to BOL */
|
term__putc(el, '\r'); /* go to BOL */
|
||||||
term__putc('\n'); /* go to new line */
|
term__putc(el, '\n'); /* go to new line */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,17 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* search.c: History and character search functions
|
* search.c: History and character search functions
|
||||||
*/
|
*/
|
||||||
#include <sys/types.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if defined(REGEX)
|
#if defined(REGEX)
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: sig.c,v 1.11 2003/08/07 16:44:33 agc Exp $ */
|
/* $NetBSD: sig.c,v 1.12 2008/09/10 15:45:37 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sig.c: Signal handling stuff.
|
* sig.c: Signal handling stuff.
|
||||||
@ -51,15 +57,15 @@ private const int sighdl[] = {
|
|||||||
- 1
|
- 1
|
||||||
};
|
};
|
||||||
|
|
||||||
private void sig_handler(int);
|
private void el_sig_handler(int);
|
||||||
|
|
||||||
/* sig_handler():
|
/* el_sig_handler():
|
||||||
* This is the handler called for all signals
|
* This is the handler called for all signals
|
||||||
* XXX: we cannot pass any data so we just store the old editline
|
* XXX: we cannot pass any data so we just store the old editline
|
||||||
* state in a private variable
|
* state in a private variable
|
||||||
*/
|
*/
|
||||||
private void
|
private void
|
||||||
sig_handler(int signo)
|
el_sig_handler(int signo)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
sigset_t nset, oset;
|
sigset_t nset, oset;
|
||||||
@ -73,7 +79,7 @@ sig_handler(int signo)
|
|||||||
tty_rawmode(sel);
|
tty_rawmode(sel);
|
||||||
if (ed_redisplay(sel, 0) == CC_REFRESH)
|
if (ed_redisplay(sel, 0) == CC_REFRESH)
|
||||||
re_refresh(sel);
|
re_refresh(sel);
|
||||||
term__flush();
|
term__flush(sel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGWINCH:
|
case SIGWINCH:
|
||||||
@ -154,7 +160,7 @@ sig_set(EditLine *el)
|
|||||||
for (i = 0; sighdl[i] != -1; i++) {
|
for (i = 0; sighdl[i] != -1; i++) {
|
||||||
el_signalhandler_t s;
|
el_signalhandler_t s;
|
||||||
/* This could happen if we get interrupted */
|
/* This could happen if we get interrupted */
|
||||||
if ((s = signal(sighdl[i], sig_handler)) != sig_handler)
|
if ((s = signal(sighdl[i], el_sig_handler)) != el_sig_handler)
|
||||||
el->el_signal[i] = s;
|
el->el_signal[i] = s;
|
||||||
}
|
}
|
||||||
sel = el;
|
sel = el;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: sig.h,v 1.5 2003/08/07 16:44:33 agc Exp $ */
|
/* $NetBSD: sig.h,v 1.6 2008/07/12 15:27:14 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -51,7 +51,6 @@
|
|||||||
#define ALLSIGS \
|
#define ALLSIGS \
|
||||||
_DO(SIGINT) \
|
_DO(SIGINT) \
|
||||||
_DO(SIGTSTP) \
|
_DO(SIGTSTP) \
|
||||||
_DO(SIGSTOP) \
|
|
||||||
_DO(SIGQUIT) \
|
_DO(SIGQUIT) \
|
||||||
_DO(SIGHUP) \
|
_DO(SIGHUP) \
|
||||||
_DO(SIGTERM) \
|
_DO(SIGTERM) \
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
/* $NetBSD: strlcpy.c,v 1.14 2003/10/27 00:12:42 lukem Exp $ */
|
|
||||||
/* $OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
|
|
||||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
|
|
||||||
* FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
# ifdef __weak_alias
|
|
||||||
__weak_alias(strlcpy, _strlcpy)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !HAVE_STRLCPY
|
|
||||||
/*
|
|
||||||
* Copy src to string dst of size siz. At most siz-1 characters
|
|
||||||
* will be copied. Always NUL terminates (unless siz == 0).
|
|
||||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
|
||||||
*/
|
|
||||||
size_t
|
|
||||||
#ifdef _LIBC
|
|
||||||
_strlcpy(dst, src, siz)
|
|
||||||
#else
|
|
||||||
strlcpy(dst, src, siz)
|
|
||||||
#endif
|
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
size_t siz;
|
|
||||||
{
|
|
||||||
char *d = dst;
|
|
||||||
const char *s = src;
|
|
||||||
size_t n = siz;
|
|
||||||
|
|
||||||
_DIAGASSERT(dst != NULL);
|
|
||||||
_DIAGASSERT(src != NULL);
|
|
||||||
|
|
||||||
/* Copy as many bytes as will fit */
|
|
||||||
if (n != 0 && --n != 0) {
|
|
||||||
do {
|
|
||||||
if ((*d++ = *s++) == 0)
|
|
||||||
break;
|
|
||||||
} while (--n != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
|
||||||
if (n == 0) {
|
|
||||||
if (siz != 0)
|
|
||||||
*d = '\0'; /* NUL-terminate dst */
|
|
||||||
while (*s++)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
return(s - src - 1); /* count does not include NUL */
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,2 +0,0 @@
|
|||||||
size_t strlcpy(char *dst, const char *src, size_t size);
|
|
||||||
size_t strlcat(char *dst, const char *src, size_t size);
|
|
@ -48,14 +48,14 @@
|
|||||||
# define __attribute__(A)
|
# define __attribute__(A)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __P
|
|
||||||
# define __P(x) x
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _DIAGASSERT
|
#ifndef _DIAGASSERT
|
||||||
# define _DIAGASSERT(x)
|
# define _DIAGASSERT(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SIZE_T_MAX
|
||||||
|
# define SIZE_T_MAX UINT_MAX
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __BEGIN_DECLS
|
#ifndef __BEGIN_DECLS
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
# define __BEGIN_DECLS extern "C" {
|
# define __BEGIN_DECLS extern "C" {
|
||||||
@ -113,6 +113,25 @@ char *fgetln(FILE *fp, size_t *len);
|
|||||||
#define REGEX /* Use POSIX.2 regular expression functions */
|
#define REGEX /* Use POSIX.2 regular expression functions */
|
||||||
#undef REGEXP /* Use UNIX V8 regular expression functions */
|
#undef REGEXP /* Use UNIX V8 regular expression functions */
|
||||||
|
|
||||||
|
#ifdef __SunOS
|
||||||
|
extern int tgetent(char *, const char *);
|
||||||
|
extern int tgetflag(char *);
|
||||||
|
extern int tgetnum(char *);
|
||||||
|
extern int tputs(const char *, int, int (*)(int));
|
||||||
|
extern char* tgoto(const char*, int, int);
|
||||||
|
extern char* tgetstr(char*, char**);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* XXXMYSQL: Bug#10218 Command line recall rolls into segfault */
|
||||||
|
#if !HAVE_DECL_TGOTO
|
||||||
|
/*
|
||||||
|
'tgoto' is not declared in the system header files, this causes
|
||||||
|
problems on 64-bit systems. The function returns a 64 bit pointer
|
||||||
|
but caller see it as "int" and it's thus truncated to 32-bit
|
||||||
|
*/
|
||||||
|
extern char* tgoto(const char*, int, int);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef notdef
|
#ifdef notdef
|
||||||
# undef REGEX
|
# undef REGEX
|
||||||
# undef REGEXP
|
# undef REGEXP
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: term.c,v 1.40 2004/05/22 23:21:28 christos Exp $ */
|
/* $NetBSD: term.c,v 1.48 2009/02/06 20:08:13 sketch Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* term.c: Editor/termcap-curses interface
|
* term.c: Editor/termcap-curses interface
|
||||||
@ -44,21 +50,28 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#if 0 /* TODO: do we need this */
|
||||||
|
#ifdef HAVE_TERMCAP_H
|
||||||
|
#include <termcap.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#ifdef HAVE_CURSES_H
|
#ifdef HAVE_CURSES_H
|
||||||
# include <curses.h>
|
#include <curses.h>
|
||||||
#elif HAVE_NCURSES_H
|
#endif
|
||||||
# include <ncurses.h>
|
#ifdef HAVE_NCURSES_H
|
||||||
|
#include <ncurses.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Solaris's term.h does horrid things. */
|
/* Solaris's term.h does horrid things. */
|
||||||
#if (defined(HAVE_TERM_H) && !defined(_SUNOS))
|
#if (defined(HAVE_TERM_H) && !defined(__SunOS))
|
||||||
# include <term.h>
|
#include <term.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#ifdef _REENTRANT
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "el.h"
|
#include "el.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -263,9 +276,13 @@ private int term_alloc_display(EditLine *);
|
|||||||
private void term_alloc(EditLine *, const struct termcapstr *, const char *);
|
private void term_alloc(EditLine *, const struct termcapstr *, const char *);
|
||||||
private void term_init_arrow(EditLine *);
|
private void term_init_arrow(EditLine *);
|
||||||
private void term_reset_arrow(EditLine *);
|
private void term_reset_arrow(EditLine *);
|
||||||
|
private int term_putc(int);
|
||||||
|
private void term_tputs(EditLine *, const char *, int);
|
||||||
|
|
||||||
|
#ifdef _REENTRANT
|
||||||
private FILE *term_outfile = NULL; /* XXX: How do we fix that? */
|
private pthread_mutex_t term_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
#endif
|
||||||
|
private FILE *term_outfile = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* term_setflags():
|
/* term_setflags():
|
||||||
@ -313,7 +330,6 @@ term_setflags(EditLine *el)
|
|||||||
#endif /* DEBUG_SCREEN */
|
#endif /* DEBUG_SCREEN */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* term_init():
|
/* term_init():
|
||||||
* Initialize the terminal stuff
|
* Initialize the terminal stuff
|
||||||
*/
|
*/
|
||||||
@ -339,7 +355,6 @@ term_init(EditLine *el)
|
|||||||
if (el->el_term.t_val == NULL)
|
if (el->el_term.t_val == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
(void) memset(el->el_term.t_val, 0, T_val * sizeof(int));
|
(void) memset(el->el_term.t_val, 0, T_val * sizeof(int));
|
||||||
term_outfile = el->el_outfile;
|
|
||||||
(void) term_set(el, NULL);
|
(void) term_set(el, NULL);
|
||||||
term_init_arrow(el);
|
term_init_arrow(el);
|
||||||
return (0);
|
return (0);
|
||||||
@ -390,6 +405,7 @@ term_alloc(EditLine *el, const struct termcapstr *t, const char *cap)
|
|||||||
* New string is shorter; no need to allocate space
|
* New string is shorter; no need to allocate space
|
||||||
*/
|
*/
|
||||||
if (clen <= tlen) {
|
if (clen <= tlen) {
|
||||||
|
if (*str)
|
||||||
(void) strcpy(*str, cap); /* XXX strcpy is safe */
|
(void) strcpy(*str, cap); /* XXX strcpy is safe */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -464,9 +480,13 @@ term_alloc_display(EditLine *el)
|
|||||||
return (-1);
|
return (-1);
|
||||||
for (i = 0; i < c->v; i++) {
|
for (i = 0; i < c->v; i++) {
|
||||||
b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1)));
|
b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1)));
|
||||||
if (b[i] == NULL)
|
if (b[i] == NULL) {
|
||||||
|
while (--i >= 0)
|
||||||
|
el_free((ptr_t) b[i]);
|
||||||
|
el_free((ptr_t) b);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
b[c->v] = NULL;
|
b[c->v] = NULL;
|
||||||
el->el_display = b;
|
el->el_display = b;
|
||||||
|
|
||||||
@ -475,9 +495,13 @@ term_alloc_display(EditLine *el)
|
|||||||
return (-1);
|
return (-1);
|
||||||
for (i = 0; i < c->v; i++) {
|
for (i = 0; i < c->v; i++) {
|
||||||
b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1)));
|
b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1)));
|
||||||
if (b[i] == NULL)
|
if (b[i] == NULL) {
|
||||||
|
while (--i >= 0)
|
||||||
|
el_free((ptr_t) b[i]);
|
||||||
|
el_free((ptr_t) b);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
b[c->v] = NULL;
|
b[c->v] = NULL;
|
||||||
el->el_vdisplay = b;
|
el->el_vdisplay = b;
|
||||||
return (0);
|
return (0);
|
||||||
@ -542,12 +566,12 @@ term_move_to_line(EditLine *el, int where)
|
|||||||
del--;
|
del--;
|
||||||
} else {
|
} else {
|
||||||
if ((del > 1) && GoodStr(T_DO)) {
|
if ((del > 1) && GoodStr(T_DO)) {
|
||||||
(void) tputs(tgoto(Str(T_DO), del, del),
|
term_tputs(el, tgoto(Str(T_DO), del,
|
||||||
del, term__putc);
|
del), del);
|
||||||
del = 0;
|
del = 0;
|
||||||
} else {
|
} else {
|
||||||
for (; del > 0; del--)
|
for (; del > 0; del--)
|
||||||
term__putc('\n');
|
term__putc(el, '\n');
|
||||||
/* because the \n will become \r\n */
|
/* because the \n will become \r\n */
|
||||||
el->el_cursor.h = 0;
|
el->el_cursor.h = 0;
|
||||||
}
|
}
|
||||||
@ -555,12 +579,11 @@ term_move_to_line(EditLine *el, int where)
|
|||||||
}
|
}
|
||||||
} else { /* del < 0 */
|
} else { /* del < 0 */
|
||||||
if (GoodStr(T_UP) && (-del > 1 || !GoodStr(T_up)))
|
if (GoodStr(T_UP) && (-del > 1 || !GoodStr(T_up)))
|
||||||
(void) tputs(tgoto(Str(T_UP), -del, -del), -del,
|
term_tputs(el, tgoto(Str(T_UP), -del, -del), -del);
|
||||||
term__putc);
|
|
||||||
else {
|
else {
|
||||||
if (GoodStr(T_up))
|
if (GoodStr(T_up))
|
||||||
for (; del < 0; del++)
|
for (; del < 0; del++)
|
||||||
(void) tputs(Str(T_up), 1, term__putc);
|
term_tputs(el, Str(T_up), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
el->el_cursor.v = where;/* now where is here */
|
el->el_cursor.v = where;/* now where is here */
|
||||||
@ -587,7 +610,7 @@ mc_again:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!where) { /* if where is first column */
|
if (!where) { /* if where is first column */
|
||||||
term__putc('\r'); /* do a CR */
|
term__putc(el, '\r'); /* do a CR */
|
||||||
el->el_cursor.h = 0;
|
el->el_cursor.h = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -595,12 +618,11 @@ mc_again:
|
|||||||
|
|
||||||
if ((del < -4 || del > 4) && GoodStr(T_ch))
|
if ((del < -4 || del > 4) && GoodStr(T_ch))
|
||||||
/* go there directly */
|
/* go there directly */
|
||||||
(void) tputs(tgoto(Str(T_ch), where, where), where, term__putc);
|
term_tputs(el, tgoto(Str(T_ch), where, where), where);
|
||||||
else {
|
else {
|
||||||
if (del > 0) { /* moving forward */
|
if (del > 0) { /* moving forward */
|
||||||
if ((del > 4) && GoodStr(T_RI))
|
if ((del > 4) && GoodStr(T_RI))
|
||||||
(void) tputs(tgoto(Str(T_RI), del, del),
|
term_tputs(el, tgoto(Str(T_RI), del, del), del);
|
||||||
del, term__putc);
|
|
||||||
else {
|
else {
|
||||||
/* if I can do tabs, use them */
|
/* if I can do tabs, use them */
|
||||||
if (EL_CAN_TAB) {
|
if (EL_CAN_TAB) {
|
||||||
@ -611,7 +633,7 @@ mc_again:
|
|||||||
(el->el_cursor.h & 0370);
|
(el->el_cursor.h & 0370);
|
||||||
i < (where & 0370);
|
i < (where & 0370);
|
||||||
i += 8)
|
i += 8)
|
||||||
term__putc('\t');
|
term__putc(el, '\t');
|
||||||
/* then tab over */
|
/* then tab over */
|
||||||
el->el_cursor.h = where & 0370;
|
el->el_cursor.h = where & 0370;
|
||||||
}
|
}
|
||||||
@ -631,8 +653,8 @@ mc_again:
|
|||||||
}
|
}
|
||||||
} else { /* del < 0 := moving backward */
|
} else { /* del < 0 := moving backward */
|
||||||
if ((-del > 4) && GoodStr(T_LE))
|
if ((-del > 4) && GoodStr(T_LE))
|
||||||
(void) tputs(tgoto(Str(T_LE), -del, -del),
|
term_tputs(el, tgoto(Str(T_LE), -del, -del),
|
||||||
-del, term__putc);
|
-del);
|
||||||
else { /* can't go directly there */
|
else { /* can't go directly there */
|
||||||
/*
|
/*
|
||||||
* if the "cost" is greater than the "cost"
|
* if the "cost" is greater than the "cost"
|
||||||
@ -643,12 +665,12 @@ mc_again:
|
|||||||
(((unsigned int) where >> 3) +
|
(((unsigned int) where >> 3) +
|
||||||
(where & 07)))
|
(where & 07)))
|
||||||
: (-del > where)) {
|
: (-del > where)) {
|
||||||
term__putc('\r'); /* do a CR */
|
term__putc(el, '\r'); /* do a CR */
|
||||||
el->el_cursor.h = 0;
|
el->el_cursor.h = 0;
|
||||||
goto mc_again; /* and try again */
|
goto mc_again; /* and try again */
|
||||||
}
|
}
|
||||||
for (i = 0; i < -del; i++)
|
for (i = 0; i < -del; i++)
|
||||||
term__putc('\b');
|
term__putc(el, '\b');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -673,7 +695,7 @@ term_overwrite(EditLine *el, const char *cp, int n)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
term__putc(*cp++);
|
term__putc(el, *cp++);
|
||||||
el->el_cursor.h++;
|
el->el_cursor.h++;
|
||||||
} while (--n);
|
} while (--n);
|
||||||
|
|
||||||
@ -689,7 +711,7 @@ term_overwrite(EditLine *el, const char *cp, int n)
|
|||||||
!= '\0')
|
!= '\0')
|
||||||
term_overwrite(el, &c, 1);
|
term_overwrite(el, &c, 1);
|
||||||
else
|
else
|
||||||
term__putc(' ');
|
term__putc(el, ' ');
|
||||||
el->el_cursor.h = 1;
|
el->el_cursor.h = 1;
|
||||||
}
|
}
|
||||||
} else /* no wrap, but cursor stays on screen */
|
} else /* no wrap, but cursor stays on screen */
|
||||||
@ -723,19 +745,18 @@ term_deletechars(EditLine *el, int num)
|
|||||||
if (GoodStr(T_DC)) /* if I have multiple delete */
|
if (GoodStr(T_DC)) /* if I have multiple delete */
|
||||||
if ((num > 1) || !GoodStr(T_dc)) { /* if dc would be more
|
if ((num > 1) || !GoodStr(T_dc)) { /* if dc would be more
|
||||||
* expen. */
|
* expen. */
|
||||||
(void) tputs(tgoto(Str(T_DC), num, num),
|
term_tputs(el, tgoto(Str(T_DC), num, num), num);
|
||||||
num, term__putc);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GoodStr(T_dm)) /* if I have delete mode */
|
if (GoodStr(T_dm)) /* if I have delete mode */
|
||||||
(void) tputs(Str(T_dm), 1, term__putc);
|
term_tputs(el, Str(T_dm), 1);
|
||||||
|
|
||||||
if (GoodStr(T_dc)) /* else do one at a time */
|
if (GoodStr(T_dc)) /* else do one at a time */
|
||||||
while (num--)
|
while (num--)
|
||||||
(void) tputs(Str(T_dc), 1, term__putc);
|
term_tputs(el, Str(T_dc), 1);
|
||||||
|
|
||||||
if (GoodStr(T_ed)) /* if I have delete mode */
|
if (GoodStr(T_ed)) /* if I have delete mode */
|
||||||
(void) tputs(Str(T_ed), 1, term__putc);
|
term_tputs(el, Str(T_ed), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -764,37 +785,35 @@ term_insertwrite(EditLine *el, char *cp, int num)
|
|||||||
if (GoodStr(T_IC)) /* if I have multiple insert */
|
if (GoodStr(T_IC)) /* if I have multiple insert */
|
||||||
if ((num > 1) || !GoodStr(T_ic)) {
|
if ((num > 1) || !GoodStr(T_ic)) {
|
||||||
/* if ic would be more expensive */
|
/* if ic would be more expensive */
|
||||||
(void) tputs(tgoto(Str(T_IC), num, num),
|
term_tputs(el, tgoto(Str(T_IC), num, num), num);
|
||||||
num, term__putc);
|
|
||||||
term_overwrite(el, cp, num);
|
term_overwrite(el, cp, num);
|
||||||
/* this updates el_cursor.h */
|
/* this updates el_cursor.h */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GoodStr(T_im) && GoodStr(T_ei)) { /* if I have insert mode */
|
if (GoodStr(T_im) && GoodStr(T_ei)) { /* if I have insert mode */
|
||||||
(void) tputs(Str(T_im), 1, term__putc);
|
term_tputs(el, Str(T_im), 1);
|
||||||
|
|
||||||
el->el_cursor.h += num;
|
el->el_cursor.h += num;
|
||||||
do
|
do
|
||||||
term__putc(*cp++);
|
term__putc(el, *cp++);
|
||||||
while (--num);
|
while (--num);
|
||||||
|
|
||||||
if (GoodStr(T_ip)) /* have to make num chars insert */
|
if (GoodStr(T_ip)) /* have to make num chars insert */
|
||||||
(void) tputs(Str(T_ip), 1, term__putc);
|
term_tputs(el, Str(T_ip), 1);
|
||||||
|
|
||||||
(void) tputs(Str(T_ei), 1, term__putc);
|
term_tputs(el, Str(T_ei), 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
if (GoodStr(T_ic)) /* have to make num chars insert */
|
if (GoodStr(T_ic)) /* have to make num chars insert */
|
||||||
(void) tputs(Str(T_ic), 1, term__putc);
|
term_tputs(el, Str(T_ic), 1);
|
||||||
/* insert a char */
|
|
||||||
|
|
||||||
term__putc(*cp++);
|
term__putc(el, *cp++);
|
||||||
|
|
||||||
el->el_cursor.h++;
|
el->el_cursor.h++;
|
||||||
|
|
||||||
if (GoodStr(T_ip)) /* have to make num chars insert */
|
if (GoodStr(T_ip)) /* have to make num chars insert */
|
||||||
(void) tputs(Str(T_ip), 1, term__putc);
|
term_tputs(el, Str(T_ip), 1);
|
||||||
/* pad the inserted char */
|
/* pad the inserted char */
|
||||||
|
|
||||||
} while (--num);
|
} while (--num);
|
||||||
@ -810,10 +829,10 @@ term_clear_EOL(EditLine *el, int num)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (EL_CAN_CEOL && GoodStr(T_ce))
|
if (EL_CAN_CEOL && GoodStr(T_ce))
|
||||||
(void) tputs(Str(T_ce), 1, term__putc);
|
term_tputs(el, Str(T_ce), 1);
|
||||||
else {
|
else {
|
||||||
for (i = 0; i < num; i++)
|
for (i = 0; i < num; i++)
|
||||||
term__putc(' ');
|
term__putc(el, ' ');
|
||||||
el->el_cursor.h += num; /* have written num spaces */
|
el->el_cursor.h += num; /* have written num spaces */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -828,14 +847,14 @@ term_clear_screen(EditLine *el)
|
|||||||
|
|
||||||
if (GoodStr(T_cl))
|
if (GoodStr(T_cl))
|
||||||
/* send the clear screen code */
|
/* send the clear screen code */
|
||||||
(void) tputs(Str(T_cl), Val(T_li), term__putc);
|
term_tputs(el, Str(T_cl), Val(T_li));
|
||||||
else if (GoodStr(T_ho) && GoodStr(T_cd)) {
|
else if (GoodStr(T_ho) && GoodStr(T_cd)) {
|
||||||
(void) tputs(Str(T_ho), Val(T_li), term__putc); /* home */
|
term_tputs(el, Str(T_ho), Val(T_li)); /* home */
|
||||||
/* clear to bottom of screen */
|
/* clear to bottom of screen */
|
||||||
(void) tputs(Str(T_cd), Val(T_li), term__putc);
|
term_tputs(el, Str(T_cd), Val(T_li));
|
||||||
} else {
|
} else {
|
||||||
term__putc('\r');
|
term__putc(el, '\r');
|
||||||
term__putc('\n');
|
term__putc(el, '\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -848,9 +867,9 @@ term_beep(EditLine *el)
|
|||||||
{
|
{
|
||||||
if (GoodStr(T_bl))
|
if (GoodStr(T_bl))
|
||||||
/* what termcap says we should use */
|
/* what termcap says we should use */
|
||||||
(void) tputs(Str(T_bl), 1, term__putc);
|
term_tputs(el, Str(T_bl), 1);
|
||||||
else
|
else
|
||||||
term__putc('\007'); /* an ASCII bell; ^G */
|
term__putc(el, '\007'); /* an ASCII bell; ^G */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -862,9 +881,9 @@ protected void
|
|||||||
term_clear_to_bottom(EditLine *el)
|
term_clear_to_bottom(EditLine *el)
|
||||||
{
|
{
|
||||||
if (GoodStr(T_cd))
|
if (GoodStr(T_cd))
|
||||||
(void) tputs(Str(T_cd), Val(T_li), term__putc);
|
term_tputs(el, Str(T_cd), Val(T_li));
|
||||||
else if (GoodStr(T_ce))
|
else if (GoodStr(T_ce))
|
||||||
(void) tputs(Str(T_ce), Val(T_li), term__putc);
|
term_tputs(el, Str(T_ce), Val(T_li));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -936,7 +955,7 @@ term_set(EditLine *el, const char *term)
|
|||||||
Val(T_co) = tgetnum("co");
|
Val(T_co) = tgetnum("co");
|
||||||
Val(T_li) = tgetnum("li");
|
Val(T_li) = tgetnum("li");
|
||||||
for (t = tstr; t->name != NULL; t++) {
|
for (t = tstr; t->name != NULL; t++) {
|
||||||
/* XXX: some systems tgetstr needs non const */
|
/* XXX: some systems' tgetstr needs non const */
|
||||||
term_alloc(el, t, tgetstr(strchr(t->name, *t->name),
|
term_alloc(el, t, tgetstr(strchr(t->name, *t->name),
|
||||||
&area));
|
&area));
|
||||||
}
|
}
|
||||||
@ -1220,26 +1239,62 @@ term_bind_arrow(EditLine *el)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* term_putc():
|
||||||
|
* Add a character
|
||||||
|
*/
|
||||||
|
private int
|
||||||
|
term_putc(int c)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (term_outfile == NULL)
|
||||||
|
return -1;
|
||||||
|
return fputc(c, term_outfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void
|
||||||
|
term_tputs(EditLine *el, const char *cap, int affcnt)
|
||||||
|
{
|
||||||
|
#ifdef _REENTRANT
|
||||||
|
pthread_mutex_lock(&term_mutex);
|
||||||
|
#endif
|
||||||
|
term_outfile = el->el_outfile;
|
||||||
|
(void)tputs(cap, affcnt, term_putc);
|
||||||
|
#ifdef _REENTRANT
|
||||||
|
pthread_mutex_unlock(&term_mutex);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* term__putc():
|
/* term__putc():
|
||||||
* Add a character
|
* Add a character
|
||||||
*/
|
*/
|
||||||
protected int
|
protected int
|
||||||
term__putc(int c)
|
term__putc(EditLine *el, int c)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (fputc(c, term_outfile));
|
return fputc(c, el->el_outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* term__flush():
|
/* term__flush():
|
||||||
* Flush output
|
* Flush output
|
||||||
*/
|
*/
|
||||||
protected void
|
protected void
|
||||||
term__flush(void)
|
term__flush(EditLine *el)
|
||||||
{
|
{
|
||||||
|
|
||||||
(void) fflush(term_outfile);
|
(void) fflush(el->el_outfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* term_writec():
|
||||||
|
* Write the given character out, in a human readable form
|
||||||
|
*/
|
||||||
|
protected void
|
||||||
|
term_writec(EditLine *el, int c)
|
||||||
|
{
|
||||||
|
char buf[8];
|
||||||
|
int cnt = key__decode_char(buf, sizeof(buf), 0, c);
|
||||||
|
buf[cnt] = '\0';
|
||||||
|
term_overwrite(el, buf, cnt);
|
||||||
|
term__flush(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1269,11 +1324,17 @@ term_telltc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
(void) fprintf(el->el_outfile, "\tIt %s magic margins\n",
|
(void) fprintf(el->el_outfile, "\tIt %s magic margins\n",
|
||||||
EL_HAS_MAGIC_MARGINS ? "has" : "does not have");
|
EL_HAS_MAGIC_MARGINS ? "has" : "does not have");
|
||||||
|
|
||||||
for (t = tstr, ts = el->el_term.t_str; t->name != NULL; t++, ts++)
|
for (t = tstr, ts = el->el_term.t_str; t->name != NULL; t++, ts++) {
|
||||||
|
const char *ub;
|
||||||
|
if (*ts && **ts) {
|
||||||
|
(void) key__decode_str(*ts, upbuf, sizeof(upbuf), "");
|
||||||
|
ub = upbuf;
|
||||||
|
} else {
|
||||||
|
ub = "(empty)";
|
||||||
|
}
|
||||||
(void) fprintf(el->el_outfile, "\t%25s (%s) == %s\n",
|
(void) fprintf(el->el_outfile, "\t%25s (%s) == %s\n",
|
||||||
t->long_name,
|
t->long_name, t->name, ub);
|
||||||
t->name, *ts && **ts ?
|
}
|
||||||
key__decode_str(*ts, upbuf, "") : "(empty)");
|
|
||||||
(void) fputc('\n', el->el_outfile);
|
(void) fputc('\n', el->el_outfile);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -1292,7 +1353,7 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
const char *what, *how;
|
const char *what, *how;
|
||||||
|
|
||||||
if (argv == NULL || argv[1] == NULL || argv[2] == NULL)
|
if (argv == NULL || argv[1] == NULL || argv[2] == NULL)
|
||||||
return (-1);
|
return -1;
|
||||||
|
|
||||||
what = argv[1];
|
what = argv[1];
|
||||||
how = argv[2];
|
how = argv[2];
|
||||||
@ -1307,7 +1368,7 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
if (ts->name != NULL) {
|
if (ts->name != NULL) {
|
||||||
term_alloc(el, ts, how);
|
term_alloc(el, ts, how);
|
||||||
term_setflags(el);
|
term_setflags(el);
|
||||||
return (0);
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Do the numeric ones second
|
* Do the numeric ones second
|
||||||
@ -1316,7 +1377,9 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
if (strcmp(tv->name, what) == 0)
|
if (strcmp(tv->name, what) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (tv->name != NULL) {
|
if (tv->name != NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (tv == &tval[T_pt] || tv == &tval[T_km] ||
|
if (tv == &tval[T_pt] || tv == &tval[T_km] ||
|
||||||
tv == &tval[T_am] || tv == &tval[T_xn]) {
|
tv == &tval[T_am] || tv == &tval[T_xn]) {
|
||||||
if (strcmp(how, "yes") == 0)
|
if (strcmp(how, "yes") == 0)
|
||||||
@ -1325,13 +1388,13 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
el->el_term.t_val[tv - tval] = 0;
|
el->el_term.t_val[tv - tval] = 0;
|
||||||
else {
|
else {
|
||||||
(void) fprintf(el->el_errfile,
|
(void) fprintf(el->el_errfile,
|
||||||
"settc: Bad value `%s'.\n", how);
|
"%s: Bad value `%s'.\n", argv[0], how);
|
||||||
return (-1);
|
return -1;
|
||||||
}
|
}
|
||||||
term_setflags(el);
|
term_setflags(el);
|
||||||
if (term_change_size(el, Val(T_li), Val(T_co)) == -1)
|
if (term_change_size(el, Val(T_li), Val(T_co)) == -1)
|
||||||
return (-1);
|
return -1;
|
||||||
return (0);
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
long i;
|
long i;
|
||||||
char *ep;
|
char *ep;
|
||||||
@ -1339,8 +1402,8 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
i = strtol(how, &ep, 10);
|
i = strtol(how, &ep, 10);
|
||||||
if (*ep != '\0') {
|
if (*ep != '\0') {
|
||||||
(void) fprintf(el->el_errfile,
|
(void) fprintf(el->el_errfile,
|
||||||
"settc: Bad value `%s'.\n", how);
|
"%s: Bad value `%s'.\n", argv[0], how);
|
||||||
return (-1);
|
return -1;
|
||||||
}
|
}
|
||||||
el->el_term.t_val[tv - tval] = (int) i;
|
el->el_term.t_val[tv - tval] = (int) i;
|
||||||
el->el_term.t_size.v = Val(T_co);
|
el->el_term.t_size.v = Val(T_co);
|
||||||
@ -1348,14 +1411,66 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
if (tv == &tval[T_co] || tv == &tval[T_li])
|
if (tv == &tval[T_co] || tv == &tval[T_li])
|
||||||
if (term_change_size(el, Val(T_li), Val(T_co))
|
if (term_change_size(el, Val(T_li), Val(T_co))
|
||||||
== -1)
|
== -1)
|
||||||
return (-1);
|
return -1;
|
||||||
return (0);
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* term_gettc():
|
||||||
|
* Get the current terminal characteristics
|
||||||
|
*/
|
||||||
|
protected int
|
||||||
|
/*ARGSUSED*/
|
||||||
|
term_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv)
|
||||||
|
{
|
||||||
|
const struct termcapstr *ts;
|
||||||
|
const struct termcapval *tv;
|
||||||
|
char *what;
|
||||||
|
void *how;
|
||||||
|
|
||||||
|
if (argv == NULL || argv[1] == NULL || argv[2] == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
what = argv[1];
|
||||||
|
how = argv[2];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do the strings first
|
||||||
|
*/
|
||||||
|
for (ts = tstr; ts->name != NULL; ts++)
|
||||||
|
if (strcmp(ts->name, what) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (ts->name != NULL) {
|
||||||
|
*(char **)how = el->el_term.t_str[ts - tstr];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Do the numeric ones second
|
||||||
|
*/
|
||||||
|
for (tv = tval; tv->name != NULL; tv++)
|
||||||
|
if (strcmp(tv->name, what) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (tv->name == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (tv == &tval[T_pt] || tv == &tval[T_km] ||
|
||||||
|
tv == &tval[T_am] || tv == &tval[T_xn]) {
|
||||||
|
static char yes[] = "yes";
|
||||||
|
static char no[] = "no";
|
||||||
|
if (el->el_term.t_val[tv - tval])
|
||||||
|
*(char **)how = yes;
|
||||||
|
else
|
||||||
|
*(char **)how = no;
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
*(int *)how = el->el_term.t_val[tv - tval];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* term_echotc():
|
/* term_echotc():
|
||||||
* Print the termcap string out with variable substitution
|
* Print the termcap string out with variable substitution
|
||||||
*/
|
*/
|
||||||
@ -1441,7 +1556,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (t->name == NULL) {
|
if (t->name == NULL) {
|
||||||
/* XXX: some systems tgetstr needs non const */
|
/* XXX: some systems' tgetstr needs non const */
|
||||||
scap = tgetstr(strchr(*argv, **argv), &area);
|
scap = tgetstr(strchr(*argv, **argv), &area);
|
||||||
}
|
}
|
||||||
if (!scap || scap[0] == '\0') {
|
if (!scap || scap[0] == '\0') {
|
||||||
@ -1494,7 +1609,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
*argv);
|
*argv);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
(void) tputs(scap, 1, term__putc);
|
term_tputs(el, scap, 1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
argv++;
|
argv++;
|
||||||
@ -1522,7 +1637,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
*argv);
|
*argv);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
(void) tputs(tgoto(scap, arg_cols, arg_rows), 1, term__putc);
|
term_tputs(el, tgoto(scap, arg_cols, arg_rows), 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* This is wrong, but I will ignore it... */
|
/* This is wrong, but I will ignore it... */
|
||||||
@ -1578,8 +1693,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)),
|
|||||||
*argv);
|
*argv);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
(void) tputs(tgoto(scap, arg_cols, arg_rows), arg_rows,
|
term_tputs(el, tgoto(scap, arg_cols, arg_rows), arg_rows);
|
||||||
term__putc);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -32,7 +32,13 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tokenize.c: Bourne shell like tokenizer
|
* tokenize.c: Bourne shell like tokenizer
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
/* $NetBSD: tokenizer.h,v 1.5 2002/03/18 16:01:00 christos Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1992, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* Christos Zoulas of Cornell University.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)tokenizer.h 8.1 (Berkeley) 6/4/93
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* tokenizer.h: Header file for tokenizer routines
|
|
||||||
*/
|
|
||||||
#ifndef _h_tokenizer
|
|
||||||
#define _h_tokenizer
|
|
||||||
|
|
||||||
typedef struct tokenizer Tokenizer;
|
|
||||||
|
|
||||||
Tokenizer *tok_init(const char *);
|
|
||||||
void tok_reset(Tokenizer *);
|
|
||||||
void tok_end(Tokenizer *);
|
|
||||||
int tok_line(Tokenizer *, const char *, int *, const char ***);
|
|
||||||
|
|
||||||
#endif /* _h_tokenizer */
|
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: tty.c,v 1.21 2004/08/13 12:10:39 mycroft Exp $ */
|
/* $NetBSD: tty.c,v 1.28 2009/02/06 19:53:23 sketch Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,18 +32,25 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tty.c: tty interface stuff
|
* tty.c: tty interface stuff
|
||||||
*/
|
*/
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
#include "el.h"
|
#include "el.h"
|
||||||
|
|
||||||
typedef struct ttymodes_t {
|
typedef struct ttymodes_t {
|
||||||
const char *m_name;
|
const char *m_name;
|
||||||
u_int m_value;
|
unsigned int m_value;
|
||||||
int m_type;
|
int m_type;
|
||||||
} ttymodes_t;
|
} ttymodes_t;
|
||||||
|
|
||||||
@ -438,13 +445,12 @@ private const ttymodes_t ttymodes[] = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define tty_getty(el, td) tcgetattr((el)->el_infd, (td))
|
|
||||||
#define tty_setty(el, td) tcsetattr((el)->el_infd, TCSADRAIN, (td))
|
|
||||||
|
|
||||||
#define tty__gettabs(td) ((((td)->c_oflag & TAB3) == TAB3) ? 0 : 1)
|
#define tty__gettabs(td) ((((td)->c_oflag & TAB3) == TAB3) ? 0 : 1)
|
||||||
#define tty__geteightbit(td) (((td)->c_cflag & CSIZE) == CS8)
|
#define tty__geteightbit(td) (((td)->c_cflag & CSIZE) == CS8)
|
||||||
#define tty__cooked_mode(td) ((td)->c_lflag & ICANON)
|
#define tty__cooked_mode(td) ((td)->c_lflag & ICANON)
|
||||||
|
|
||||||
|
private int tty_getty(EditLine *, struct termios *);
|
||||||
|
private int tty_setty(EditLine *, int, const struct termios *);
|
||||||
private int tty__getcharindex(int);
|
private int tty__getcharindex(int);
|
||||||
private void tty__getchar(struct termios *, unsigned char *);
|
private void tty__getchar(struct termios *, unsigned char *);
|
||||||
private void tty__setchar(struct termios *, unsigned char *);
|
private void tty__setchar(struct termios *, unsigned char *);
|
||||||
@ -453,6 +459,29 @@ private int tty_setup(EditLine *);
|
|||||||
|
|
||||||
#define t_qu t_ts
|
#define t_qu t_ts
|
||||||
|
|
||||||
|
/* tty_getty():
|
||||||
|
* Wrapper for tcgetattr to handle EINTR
|
||||||
|
*/
|
||||||
|
private int
|
||||||
|
tty_getty(EditLine *el, struct termios *t)
|
||||||
|
{
|
||||||
|
int rv;
|
||||||
|
while ((rv = tcgetattr(el->el_infd, t)) == -1 && errno == EINTR)
|
||||||
|
continue;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* tty_setty():
|
||||||
|
* Wrapper for tcsetattr to handle EINTR
|
||||||
|
*/
|
||||||
|
private int
|
||||||
|
tty_setty(EditLine *el, int action, const struct termios *t)
|
||||||
|
{
|
||||||
|
int rv;
|
||||||
|
while ((rv = tcsetattr(el->el_infd, action, t)) == -1 && errno == EINTR)
|
||||||
|
continue;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
/* tty_setup():
|
/* tty_setup():
|
||||||
* Get the tty parameters and initialize the editing state
|
* Get the tty parameters and initialize the editing state
|
||||||
@ -514,7 +543,7 @@ tty_setup(EditLine *el)
|
|||||||
el->el_tty.t_c[TS_IO][rst];
|
el->el_tty.t_c[TS_IO][rst];
|
||||||
}
|
}
|
||||||
tty__setchar(&el->el_tty.t_ex, el->el_tty.t_c[EX_IO]);
|
tty__setchar(&el->el_tty.t_ex, el->el_tty.t_c[EX_IO]);
|
||||||
if (tty_setty(el, &el->el_tty.t_ex) == -1) {
|
if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ex) == -1) {
|
||||||
#ifdef DEBUG_TTY
|
#ifdef DEBUG_TTY
|
||||||
(void) fprintf(el->el_errfile,
|
(void) fprintf(el->el_errfile,
|
||||||
"tty_setup: tty_setty: %s\n",
|
"tty_setup: tty_setty: %s\n",
|
||||||
@ -522,8 +551,11 @@ tty_setup(EditLine *el)
|
|||||||
#endif /* DEBUG_TTY */
|
#endif /* DEBUG_TTY */
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
#ifdef notdef
|
||||||
|
else
|
||||||
tty__setchar(&el->el_tty.t_ex, el->el_tty.t_c[EX_IO]);
|
tty__setchar(&el->el_tty.t_ex, el->el_tty.t_c[EX_IO]);
|
||||||
|
#endif
|
||||||
|
|
||||||
el->el_tty.t_ed.c_iflag &= ~el->el_tty.t_t[ED_IO][MD_INP].t_clrmask;
|
el->el_tty.t_ed.c_iflag &= ~el->el_tty.t_t[ED_IO][MD_INP].t_clrmask;
|
||||||
el->el_tty.t_ed.c_iflag |= el->el_tty.t_t[ED_IO][MD_INP].t_setmask;
|
el->el_tty.t_ed.c_iflag |= el->el_tty.t_t[ED_IO][MD_INP].t_setmask;
|
||||||
@ -1040,7 +1072,7 @@ tty_rawmode(EditLine *el)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tty_setty(el, &el->el_tty.t_ed) == -1) {
|
if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ed) == -1) {
|
||||||
#ifdef DEBUG_TTY
|
#ifdef DEBUG_TTY
|
||||||
(void) fprintf(el->el_errfile, "tty_rawmode: tty_setty: %s\n",
|
(void) fprintf(el->el_errfile, "tty_rawmode: tty_setty: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@ -1065,7 +1097,7 @@ tty_cookedmode(EditLine *el)
|
|||||||
if (el->el_flags & EDIT_DISABLED)
|
if (el->el_flags & EDIT_DISABLED)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if (tty_setty(el, &el->el_tty.t_ex) == -1) {
|
if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ex) == -1) {
|
||||||
#ifdef DEBUG_TTY
|
#ifdef DEBUG_TTY
|
||||||
(void) fprintf(el->el_errfile,
|
(void) fprintf(el->el_errfile,
|
||||||
"tty_cookedmode: tty_setty: %s\n",
|
"tty_cookedmode: tty_setty: %s\n",
|
||||||
@ -1101,7 +1133,7 @@ tty_quotemode(EditLine *el)
|
|||||||
el->el_tty.t_qu.c_lflag &= ~el->el_tty.t_t[QU_IO][MD_LIN].t_clrmask;
|
el->el_tty.t_qu.c_lflag &= ~el->el_tty.t_t[QU_IO][MD_LIN].t_clrmask;
|
||||||
el->el_tty.t_qu.c_lflag |= el->el_tty.t_t[QU_IO][MD_LIN].t_setmask;
|
el->el_tty.t_qu.c_lflag |= el->el_tty.t_t[QU_IO][MD_LIN].t_setmask;
|
||||||
|
|
||||||
if (tty_setty(el, &el->el_tty.t_qu) == -1) {
|
if (tty_setty(el, TCSADRAIN, &el->el_tty.t_qu) == -1) {
|
||||||
#ifdef DEBUG_TTY
|
#ifdef DEBUG_TTY
|
||||||
(void) fprintf(el->el_errfile, "QuoteModeOn: tty_setty: %s\n",
|
(void) fprintf(el->el_errfile, "QuoteModeOn: tty_setty: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@ -1122,7 +1154,7 @@ tty_noquotemode(EditLine *el)
|
|||||||
|
|
||||||
if (el->el_tty.t_mode != QU_IO)
|
if (el->el_tty.t_mode != QU_IO)
|
||||||
return (0);
|
return (0);
|
||||||
if (tty_setty(el, &el->el_tty.t_ed) == -1) {
|
if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ed) == -1) {
|
||||||
#ifdef DEBUG_TTY
|
#ifdef DEBUG_TTY
|
||||||
(void) fprintf(el->el_errfile, "QuoteModeOff: tty_setty: %s\n",
|
(void) fprintf(el->el_errfile, "QuoteModeOff: tty_setty: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@ -1193,10 +1225,14 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
|
|||||||
st = len =
|
st = len =
|
||||||
strlen(el->el_tty.t_t[z][m->m_type].t_name);
|
strlen(el->el_tty.t_t[z][m->m_type].t_name);
|
||||||
}
|
}
|
||||||
|
if (i != -1) {
|
||||||
x = (el->el_tty.t_t[z][i].t_setmask & m->m_value)
|
x = (el->el_tty.t_t[z][i].t_setmask & m->m_value)
|
||||||
? '+' : '\0';
|
? '+' : '\0';
|
||||||
x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value)
|
x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value)
|
||||||
? '-' : x;
|
? '-' : x;
|
||||||
|
} else {
|
||||||
|
x = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
if (x != '\0' || aflag) {
|
if (x != '\0' || aflag) {
|
||||||
|
|
||||||
@ -1221,7 +1257,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
while (argv && (s = *argv++)) {
|
while (argv && (s = *argv++)) {
|
||||||
char *p;
|
const char *p;
|
||||||
switch (*s) {
|
switch (*s) {
|
||||||
case '+':
|
case '+':
|
||||||
case '-':
|
case '-':
|
||||||
@ -1232,10 +1268,10 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
d = s;
|
d = s;
|
||||||
if ((p = strchr(s, '=')) != NULL)
|
p = strchr(s, '=');
|
||||||
*p++ = '\0';
|
|
||||||
for (m = ttymodes; m->m_name; m++)
|
for (m = ttymodes; m->m_name; m++)
|
||||||
if (strcmp(m->m_name, d) == 0 &&
|
if ((p ? strncmp(m->m_name, d, (size_t)(p - d)) :
|
||||||
|
strcmp(m->m_name, d)) == 0 &&
|
||||||
(p == NULL || m->m_type == MD_CHAR))
|
(p == NULL || m->m_type == MD_CHAR))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1246,7 +1282,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
|
|||||||
}
|
}
|
||||||
if (p) {
|
if (p) {
|
||||||
int c = ffs((int)m->m_value);
|
int c = ffs((int)m->m_value);
|
||||||
int v = *p ? parse__escape((const char **const) &p) :
|
int v = *++p ? parse__escape((const char **) &p) :
|
||||||
el->el_tty.t_vdisable;
|
el->el_tty.t_vdisable;
|
||||||
assert(c-- != 0);
|
assert(c-- != 0);
|
||||||
c = tty__getcharindex(c);
|
c = tty__getcharindex(c);
|
||||||
@ -1269,6 +1305,17 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (el->el_tty.t_mode == z) {
|
||||||
|
if (tty_setty(el, TCSADRAIN, tios) == -1) {
|
||||||
|
#ifdef DEBUG_TTY
|
||||||
|
(void) fprintf(el->el_errfile,
|
||||||
|
"tty_stty: tty_setty: %s\n", strerror(errno));
|
||||||
|
#endif /* DEBUG_TTY */
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: tty.h,v 1.10 2003/08/07 16:44:34 agc Exp $ */
|
/* $NetBSD: tty.h,v 1.11 2005/06/01 11:37:52 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -450,8 +450,8 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *t_name;
|
const char *t_name;
|
||||||
u_int t_setmask;
|
unsigned int t_setmask;
|
||||||
u_int t_clrmask;
|
unsigned int t_clrmask;
|
||||||
} ttyperm_t[NN_IO][MD_NN];
|
} ttyperm_t[NN_IO][MD_NN];
|
||||||
|
|
||||||
typedef unsigned char ttychar_t[NN_IO][C_NCC];
|
typedef unsigned char ttychar_t[NN_IO][C_NCC];
|
||||||
|
@ -1,311 +0,0 @@
|
|||||||
/* $NetBSD: unvis.c,v 1.24 2003/08/07 16:42:59 agc Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1989, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#define __LIBC12_SOURCE__
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <vis.h>
|
|
||||||
|
|
||||||
#ifdef __weak_alias
|
|
||||||
__weak_alias(strunvis,_strunvis)
|
|
||||||
__weak_alias(unvis,_unvis)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __warn_references
|
|
||||||
__warn_references(unvis,
|
|
||||||
"warning: reference to compatibility unvis(); include <vis.h> for correct reference")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !HAVE_VIS
|
|
||||||
/*
|
|
||||||
* decode driven by state machine
|
|
||||||
*/
|
|
||||||
#define S_GROUND 0 /* haven't seen escape char */
|
|
||||||
#define S_START 1 /* start decoding special sequence */
|
|
||||||
#define S_META 2 /* metachar started (M) */
|
|
||||||
#define S_META1 3 /* metachar more, regular char (-) */
|
|
||||||
#define S_CTRL 4 /* control char started (^) */
|
|
||||||
#define S_OCTAL2 5 /* octal digit 2 */
|
|
||||||
#define S_OCTAL3 6 /* octal digit 3 */
|
|
||||||
#define S_HEX1 7 /* hex digit */
|
|
||||||
#define S_HEX2 8 /* hex digit 2 */
|
|
||||||
|
|
||||||
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
|
|
||||||
#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
|
|
||||||
|
|
||||||
int
|
|
||||||
unvis(cp, c, astate, flag)
|
|
||||||
char *cp;
|
|
||||||
int c;
|
|
||||||
int *astate, flag;
|
|
||||||
{
|
|
||||||
return __unvis13(cp, (int)c, astate, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* unvis - decode characters previously encoded by vis
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
__unvis13(cp, c, astate, flag)
|
|
||||||
char *cp;
|
|
||||||
int c;
|
|
||||||
int *astate, flag;
|
|
||||||
{
|
|
||||||
|
|
||||||
_DIAGASSERT(cp != NULL);
|
|
||||||
_DIAGASSERT(astate != NULL);
|
|
||||||
|
|
||||||
if (flag & UNVIS_END) {
|
|
||||||
if (*astate == S_OCTAL2 || *astate == S_OCTAL3
|
|
||||||
|| *astate == S_HEX2) {
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
}
|
|
||||||
return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (*astate) {
|
|
||||||
|
|
||||||
case S_GROUND:
|
|
||||||
*cp = 0;
|
|
||||||
if (c == '\\') {
|
|
||||||
*astate = S_START;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
if ((flag & VIS_HTTPSTYLE) && c == '%') {
|
|
||||||
*astate = S_HEX1;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
*cp = c;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
|
|
||||||
case S_START:
|
|
||||||
switch(c) {
|
|
||||||
case '\\':
|
|
||||||
*cp = c;
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
case '0': case '1': case '2': case '3':
|
|
||||||
case '4': case '5': case '6': case '7':
|
|
||||||
*cp = (c - '0');
|
|
||||||
*astate = S_OCTAL2;
|
|
||||||
return (0);
|
|
||||||
case 'M':
|
|
||||||
*cp = (char)0200;
|
|
||||||
*astate = S_META;
|
|
||||||
return (0);
|
|
||||||
case '^':
|
|
||||||
*astate = S_CTRL;
|
|
||||||
return (0);
|
|
||||||
case 'n':
|
|
||||||
*cp = '\n';
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
case 'r':
|
|
||||||
*cp = '\r';
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
case 'b':
|
|
||||||
*cp = '\b';
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
case 'a':
|
|
||||||
*cp = '\007';
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
case 'v':
|
|
||||||
*cp = '\v';
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
case 't':
|
|
||||||
*cp = '\t';
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
case 'f':
|
|
||||||
*cp = '\f';
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
case 's':
|
|
||||||
*cp = ' ';
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
case 'E':
|
|
||||||
*cp = '\033';
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
case '\n':
|
|
||||||
/*
|
|
||||||
* hidden newline
|
|
||||||
*/
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_NOCHAR);
|
|
||||||
case '$':
|
|
||||||
/*
|
|
||||||
* hidden marker
|
|
||||||
*/
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_NOCHAR);
|
|
||||||
}
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_SYNBAD);
|
|
||||||
|
|
||||||
case S_META:
|
|
||||||
if (c == '-')
|
|
||||||
*astate = S_META1;
|
|
||||||
else if (c == '^')
|
|
||||||
*astate = S_CTRL;
|
|
||||||
else {
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_SYNBAD);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
case S_META1:
|
|
||||||
*astate = S_GROUND;
|
|
||||||
*cp |= c;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
|
|
||||||
case S_CTRL:
|
|
||||||
if (c == '?')
|
|
||||||
*cp |= 0177;
|
|
||||||
else
|
|
||||||
*cp |= c & 037;
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
|
|
||||||
case S_OCTAL2: /* second possible octal digit */
|
|
||||||
if (isoctal(c)) {
|
|
||||||
/*
|
|
||||||
* yes - and maybe a third
|
|
||||||
*/
|
|
||||||
*cp = (*cp << 3) + (c - '0');
|
|
||||||
*astate = S_OCTAL3;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* no - done with current sequence, push back passed char
|
|
||||||
*/
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALIDPUSH);
|
|
||||||
|
|
||||||
case S_OCTAL3: /* third possible octal digit */
|
|
||||||
*astate = S_GROUND;
|
|
||||||
if (isoctal(c)) {
|
|
||||||
*cp = (*cp << 3) + (c - '0');
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* we were done, push back passed char
|
|
||||||
*/
|
|
||||||
return (UNVIS_VALIDPUSH);
|
|
||||||
case S_HEX1:
|
|
||||||
if (isxdigit(c)) {
|
|
||||||
*cp = xtod(c);
|
|
||||||
*astate = S_HEX2;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* no - done with current sequence, push back passed char
|
|
||||||
*/
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_VALIDPUSH);
|
|
||||||
case S_HEX2:
|
|
||||||
*astate = S_GROUND;
|
|
||||||
if (isxdigit(c)) {
|
|
||||||
*cp = xtod(c) | (*cp << 4);
|
|
||||||
return (UNVIS_VALID);
|
|
||||||
}
|
|
||||||
return (UNVIS_VALIDPUSH);
|
|
||||||
default:
|
|
||||||
/*
|
|
||||||
* decoder in unknown state - (probably uninitialized)
|
|
||||||
*/
|
|
||||||
*astate = S_GROUND;
|
|
||||||
return (UNVIS_SYNBAD);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* strunvis - decode src into dst
|
|
||||||
*
|
|
||||||
* Number of chars decoded into dst is returned, -1 on error.
|
|
||||||
* Dst is null terminated.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
|
||||||
strunvisx(dst, src, flag)
|
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
int flag;
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
char *start = dst;
|
|
||||||
int state = 0;
|
|
||||||
|
|
||||||
_DIAGASSERT(src != NULL);
|
|
||||||
_DIAGASSERT(dst != NULL);
|
|
||||||
|
|
||||||
while ((c = *src++) != '\0') {
|
|
||||||
again:
|
|
||||||
switch (__unvis13(dst, c, &state, flag)) {
|
|
||||||
case UNVIS_VALID:
|
|
||||||
dst++;
|
|
||||||
break;
|
|
||||||
case UNVIS_VALIDPUSH:
|
|
||||||
dst++;
|
|
||||||
goto again;
|
|
||||||
case 0:
|
|
||||||
case UNVIS_NOCHAR:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (__unvis13(dst, c, &state, UNVIS_END) == UNVIS_VALID)
|
|
||||||
dst++;
|
|
||||||
*dst = '\0';
|
|
||||||
return (dst - start);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
strunvis(dst, src)
|
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
{
|
|
||||||
return strunvisx(dst, src, 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: vi.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $ */
|
/* $NetBSD: vi.c,v 1.28 2009/02/06 13:14:37 sketch Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -32,11 +32,17 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#if !defined(lint) && !defined(SCCSID)
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* vi.c: Vi mode commands.
|
* vi.c: Vi mode commands.
|
||||||
@ -64,8 +70,10 @@ cv_action(EditLine *el, int c)
|
|||||||
el->el_line.lastchar - el->el_line.buffer);
|
el->el_line.lastchar - el->el_line.buffer);
|
||||||
el->el_chared.c_vcmd.action = NOP;
|
el->el_chared.c_vcmd.action = NOP;
|
||||||
el->el_chared.c_vcmd.pos = 0;
|
el->el_chared.c_vcmd.pos = 0;
|
||||||
|
if (!(c & YANK)) {
|
||||||
el->el_line.lastchar = el->el_line.buffer;
|
el->el_line.lastchar = el->el_line.buffer;
|
||||||
el->el_line.cursor = el->el_line.buffer;
|
el->el_line.cursor = el->el_line.buffer;
|
||||||
|
}
|
||||||
if (c & INSERT)
|
if (c & INSERT)
|
||||||
el->el_map.current = el->el_map.key;
|
el->el_map.current = el->el_map.key;
|
||||||
|
|
||||||
@ -82,7 +90,6 @@ cv_action(EditLine *el, int c)
|
|||||||
private el_action_t
|
private el_action_t
|
||||||
cv_paste(EditLine *el, int c)
|
cv_paste(EditLine *el, int c)
|
||||||
{
|
{
|
||||||
char *ptr;
|
|
||||||
c_kill_t *k = &el->el_chared.c_kill;
|
c_kill_t *k = &el->el_chared.c_kill;
|
||||||
int len = k->last - k->buf;
|
int len = k->last - k->buf;
|
||||||
|
|
||||||
@ -96,12 +103,12 @@ cv_paste(EditLine *el, int c)
|
|||||||
|
|
||||||
if (!c && el->el_line.cursor < el->el_line.lastchar)
|
if (!c && el->el_line.cursor < el->el_line.lastchar)
|
||||||
el->el_line.cursor++;
|
el->el_line.cursor++;
|
||||||
ptr = el->el_line.cursor;
|
|
||||||
|
|
||||||
c_insert(el, len);
|
c_insert(el, len);
|
||||||
if (el->el_line.cursor + len > el->el_line.lastchar)
|
if (el->el_line.cursor + len > el->el_line.lastchar)
|
||||||
return (CC_ERROR);
|
return (CC_ERROR);
|
||||||
(void) memcpy(ptr, k->buf, len +0u);
|
(void) memcpy(el->el_line.cursor, k->buf, len +0u);
|
||||||
|
|
||||||
return (CC_REFRESH);
|
return (CC_REFRESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,13 +599,12 @@ vi_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
|
|||||||
*/
|
*/
|
||||||
protected el_action_t
|
protected el_action_t
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
vi_list_or_eof(EditLine *el, int c __attribute__((__unused__)))
|
vi_list_or_eof(EditLine *el, int c)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (el->el_line.cursor == el->el_line.lastchar) {
|
if (el->el_line.cursor == el->el_line.lastchar) {
|
||||||
if (el->el_line.cursor == el->el_line.buffer) {
|
if (el->el_line.cursor == el->el_line.buffer) {
|
||||||
term_overwrite(el, STReof, 4); /* then do a EOF */
|
term_writec(el, c); /* then do a EOF */
|
||||||
term__flush();
|
|
||||||
return (CC_EOF);
|
return (CC_EOF);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -888,7 +894,7 @@ vi_yank(EditLine *el, int c)
|
|||||||
|
|
||||||
/* vi_comment_out():
|
/* vi_comment_out():
|
||||||
* Vi comment out current command
|
* Vi comment out current command
|
||||||
* [c]
|
* [#]
|
||||||
*/
|
*/
|
||||||
protected el_action_t
|
protected el_action_t
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
@ -905,18 +911,19 @@ vi_comment_out(EditLine *el, int c)
|
|||||||
/* vi_alias():
|
/* vi_alias():
|
||||||
* Vi include shell alias
|
* Vi include shell alias
|
||||||
* [@]
|
* [@]
|
||||||
* NB: posix impiles that we should enter insert mode, however
|
* NB: posix implies that we should enter insert mode, however
|
||||||
* this is against historical precedent...
|
* this is against historical precedent...
|
||||||
*/
|
*/
|
||||||
|
#if defined(__weak_reference) && !defined(__FreeBSD__)
|
||||||
|
extern char *get_alias_text(const char *) __weak_reference(get_alias_text);
|
||||||
|
#endif
|
||||||
protected el_action_t
|
protected el_action_t
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
vi_alias(EditLine *el, int c)
|
vi_alias(EditLine *el, int c)
|
||||||
{
|
{
|
||||||
#ifdef __weak_extern
|
#if defined(__weak_reference) && !defined(__FreeBSD__)
|
||||||
char alias_name[3];
|
char alias_name[3];
|
||||||
char *alias_text;
|
char *alias_text;
|
||||||
extern char *get_alias_text(const char *);
|
|
||||||
__weak_extern(get_alias_text);
|
|
||||||
|
|
||||||
if (get_alias_text == 0) {
|
if (get_alias_text == 0) {
|
||||||
return CC_ERROR;
|
return CC_ERROR;
|
||||||
@ -1014,7 +1021,7 @@ vi_histedit(EditLine *el, int c)
|
|||||||
return CC_ERROR;
|
return CC_ERROR;
|
||||||
case 0:
|
case 0:
|
||||||
close(fd);
|
close(fd);
|
||||||
execlp("vi", "vi", tempfile, (char *) NULL);
|
execlp("vi", "vi", tempfile, (char *)NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
default:
|
default:
|
||||||
|
@ -1,392 +0,0 @@
|
|||||||
/* $NetBSD: vis.c,v 1.27 2004/02/26 23:01:15 enami Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1989, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* AIX requires this to be the first thing in the file. */
|
|
||||||
#if defined (_AIX) && !defined (__GNUC__)
|
|
||||||
#pragma alloca
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# undef alloca
|
|
||||||
# define alloca(n) __builtin_alloca (n)
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_ALLOCA_H
|
|
||||||
# include <alloca.h>
|
|
||||||
# else
|
|
||||||
# ifndef _AIX
|
|
||||||
extern char *alloca ();
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <vis.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#ifdef __weak_alias
|
|
||||||
__weak_alias(strsvis,_strsvis)
|
|
||||||
__weak_alias(strsvisx,_strsvisx)
|
|
||||||
__weak_alias(strvis,_strvis)
|
|
||||||
__weak_alias(strvisx,_strvisx)
|
|
||||||
__weak_alias(svis,_svis)
|
|
||||||
__weak_alias(vis,_vis)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !HAVE_VIS || !HAVE_SVIS
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#undef BELL
|
|
||||||
#define BELL '\a'
|
|
||||||
|
|
||||||
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
|
|
||||||
#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
|
|
||||||
#define issafe(c) (c == '\b' || c == BELL || c == '\r')
|
|
||||||
#define xtoa(c) "0123456789abcdef"[c]
|
|
||||||
|
|
||||||
#define MAXEXTRAS 5
|
|
||||||
|
|
||||||
|
|
||||||
#define MAKEEXTRALIST(flag, extra, orig) \
|
|
||||||
do { \
|
|
||||||
const char *o = orig; \
|
|
||||||
char *e; \
|
|
||||||
while (*o++) \
|
|
||||||
continue; \
|
|
||||||
extra = alloca((size_t)((o - orig) + MAXEXTRAS)); \
|
|
||||||
for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
|
|
||||||
continue; \
|
|
||||||
e--; \
|
|
||||||
if (flag & VIS_SP) *e++ = ' '; \
|
|
||||||
if (flag & VIS_TAB) *e++ = '\t'; \
|
|
||||||
if (flag & VIS_NL) *e++ = '\n'; \
|
|
||||||
if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
|
|
||||||
*e = '\0'; \
|
|
||||||
} while (/*CONSTCOND*/0)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is HVIS, the macro of vis used to HTTP style (RFC 1808)
|
|
||||||
*/
|
|
||||||
#define HVIS(dst, c, flag, nextc, extra) \
|
|
||||||
do \
|
|
||||||
if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) { \
|
|
||||||
*dst++ = '%'; \
|
|
||||||
*dst++ = xtoa(((unsigned int)c >> 4) & 0xf); \
|
|
||||||
*dst++ = xtoa((unsigned int)c & 0xf); \
|
|
||||||
} else { \
|
|
||||||
SVIS(dst, c, flag, nextc, extra); \
|
|
||||||
} \
|
|
||||||
while (/*CONSTCOND*/0)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is SVIS, the central macro of vis.
|
|
||||||
* dst: Pointer to the destination buffer
|
|
||||||
* c: Character to encode
|
|
||||||
* flag: Flag word
|
|
||||||
* nextc: The character following 'c'
|
|
||||||
* extra: Pointer to the list of extra characters to be
|
|
||||||
* backslash-protected.
|
|
||||||
*/
|
|
||||||
#define SVIS(dst, c, flag, nextc, extra) \
|
|
||||||
do { \
|
|
||||||
int isextra; \
|
|
||||||
isextra = strchr(extra, c) != NULL; \
|
|
||||||
if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) || \
|
|
||||||
((flag & VIS_SAFE) && issafe(c)))) { \
|
|
||||||
*dst++ = c; \
|
|
||||||
break; \
|
|
||||||
} \
|
|
||||||
if (flag & VIS_CSTYLE) { \
|
|
||||||
switch (c) { \
|
|
||||||
case '\n': \
|
|
||||||
*dst++ = '\\'; *dst++ = 'n'; \
|
|
||||||
continue; \
|
|
||||||
case '\r': \
|
|
||||||
*dst++ = '\\'; *dst++ = 'r'; \
|
|
||||||
continue; \
|
|
||||||
case '\b': \
|
|
||||||
*dst++ = '\\'; *dst++ = 'b'; \
|
|
||||||
continue; \
|
|
||||||
case BELL: \
|
|
||||||
*dst++ = '\\'; *dst++ = 'a'; \
|
|
||||||
continue; \
|
|
||||||
case '\v': \
|
|
||||||
*dst++ = '\\'; *dst++ = 'v'; \
|
|
||||||
continue; \
|
|
||||||
case '\t': \
|
|
||||||
*dst++ = '\\'; *dst++ = 't'; \
|
|
||||||
continue; \
|
|
||||||
case '\f': \
|
|
||||||
*dst++ = '\\'; *dst++ = 'f'; \
|
|
||||||
continue; \
|
|
||||||
case ' ': \
|
|
||||||
*dst++ = '\\'; *dst++ = 's'; \
|
|
||||||
continue; \
|
|
||||||
case '\0': \
|
|
||||||
*dst++ = '\\'; *dst++ = '0'; \
|
|
||||||
if (isoctal(nextc)) { \
|
|
||||||
*dst++ = '0'; \
|
|
||||||
*dst++ = '0'; \
|
|
||||||
} \
|
|
||||||
continue; \
|
|
||||||
default: \
|
|
||||||
if (isgraph(c)) { \
|
|
||||||
*dst++ = '\\'; *dst++ = c; \
|
|
||||||
continue; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \
|
|
||||||
*dst++ = '\\'; \
|
|
||||||
*dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + '0'; \
|
|
||||||
*dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + '0'; \
|
|
||||||
*dst++ = (c & 07) + '0'; \
|
|
||||||
} else { \
|
|
||||||
if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \
|
|
||||||
if (c & 0200) { \
|
|
||||||
c &= 0177; *dst++ = 'M'; \
|
|
||||||
} \
|
|
||||||
if (iscntrl(c)) { \
|
|
||||||
*dst++ = '^'; \
|
|
||||||
if (c == 0177) \
|
|
||||||
*dst++ = '?'; \
|
|
||||||
else \
|
|
||||||
*dst++ = c + '@'; \
|
|
||||||
} else { \
|
|
||||||
*dst++ = '-'; *dst++ = c; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} while (/*CONSTCOND*/0)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* svis - visually encode characters, also encoding the characters
|
|
||||||
* pointed to by `extra'
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
svis(dst, c, flag, nextc, extra)
|
|
||||||
char *dst;
|
|
||||||
int c, flag, nextc;
|
|
||||||
const char *extra;
|
|
||||||
{
|
|
||||||
char *nextra;
|
|
||||||
_DIAGASSERT(dst != NULL);
|
|
||||||
_DIAGASSERT(extra != NULL);
|
|
||||||
MAKEEXTRALIST(flag, nextra, extra);
|
|
||||||
if (flag & VIS_HTTPSTYLE)
|
|
||||||
HVIS(dst, c, flag, nextc, nextra);
|
|
||||||
else
|
|
||||||
SVIS(dst, c, flag, nextc, nextra);
|
|
||||||
*dst = '\0';
|
|
||||||
return(dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* strsvis, strsvisx - visually encode characters from src into dst
|
|
||||||
*
|
|
||||||
* Extra is a pointer to a \0-terminated list of characters to
|
|
||||||
* be encoded, too. These functions are useful e. g. to
|
|
||||||
* encode strings in such a way so that they are not interpreted
|
|
||||||
* by a shell.
|
|
||||||
*
|
|
||||||
* Dst must be 4 times the size of src to account for possible
|
|
||||||
* expansion. The length of dst, not including the trailing NULL,
|
|
||||||
* is returned.
|
|
||||||
*
|
|
||||||
* Strsvisx encodes exactly len bytes from src into dst.
|
|
||||||
* This is useful for encoding a block of data.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
strsvis(dst, csrc, flag, extra)
|
|
||||||
char *dst;
|
|
||||||
const char *csrc;
|
|
||||||
int flag;
|
|
||||||
const char *extra;
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
char *start;
|
|
||||||
char *nextra;
|
|
||||||
const unsigned char *src = (const unsigned char *)csrc;
|
|
||||||
|
|
||||||
_DIAGASSERT(dst != NULL);
|
|
||||||
_DIAGASSERT(src != NULL);
|
|
||||||
_DIAGASSERT(extra != NULL);
|
|
||||||
MAKEEXTRALIST(flag, nextra, extra);
|
|
||||||
if (flag & VIS_HTTPSTYLE) {
|
|
||||||
for (start = dst; (c = *src++) != '\0'; /* empty */)
|
|
||||||
HVIS(dst, c, flag, *src, nextra);
|
|
||||||
} else {
|
|
||||||
for (start = dst; (c = *src++) != '\0'; /* empty */)
|
|
||||||
SVIS(dst, c, flag, *src, nextra);
|
|
||||||
}
|
|
||||||
*dst = '\0';
|
|
||||||
return (dst - start);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
strsvisx(dst, csrc, len, flag, extra)
|
|
||||||
char *dst;
|
|
||||||
const char *csrc;
|
|
||||||
size_t len;
|
|
||||||
int flag;
|
|
||||||
const char *extra;
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
char *start;
|
|
||||||
char *nextra;
|
|
||||||
const unsigned char *src = (const unsigned char *)csrc;
|
|
||||||
|
|
||||||
_DIAGASSERT(dst != NULL);
|
|
||||||
_DIAGASSERT(src != NULL);
|
|
||||||
_DIAGASSERT(extra != NULL);
|
|
||||||
MAKEEXTRALIST(flag, nextra, extra);
|
|
||||||
|
|
||||||
if (flag & VIS_HTTPSTYLE) {
|
|
||||||
for (start = dst; len > 0; len--) {
|
|
||||||
c = *src++;
|
|
||||||
HVIS(dst, c, flag, len ? *src : '\0', nextra);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (start = dst; len > 0; len--) {
|
|
||||||
c = *src++;
|
|
||||||
SVIS(dst, c, flag, len ? *src : '\0', nextra);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*dst = '\0';
|
|
||||||
return (dst - start);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !HAVE_VIS
|
|
||||||
/*
|
|
||||||
* vis - visually encode characters
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
vis(dst, c, flag, nextc)
|
|
||||||
char *dst;
|
|
||||||
int c, flag, nextc;
|
|
||||||
|
|
||||||
{
|
|
||||||
char *extra;
|
|
||||||
|
|
||||||
_DIAGASSERT(dst != NULL);
|
|
||||||
|
|
||||||
MAKEEXTRALIST(flag, extra, "");
|
|
||||||
if (flag & VIS_HTTPSTYLE)
|
|
||||||
HVIS(dst, c, flag, nextc, extra);
|
|
||||||
else
|
|
||||||
SVIS(dst, c, flag, nextc, extra);
|
|
||||||
*dst = '\0';
|
|
||||||
return (dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* strvis, strvisx - visually encode characters from src into dst
|
|
||||||
*
|
|
||||||
* Dst must be 4 times the size of src to account for possible
|
|
||||||
* expansion. The length of dst, not including the trailing NULL,
|
|
||||||
* is returned.
|
|
||||||
*
|
|
||||||
* Strvisx encodes exactly len bytes from src into dst.
|
|
||||||
* This is useful for encoding a block of data.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
strvis(dst, src, flag)
|
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
int flag;
|
|
||||||
{
|
|
||||||
char *extra;
|
|
||||||
|
|
||||||
MAKEEXTRALIST(flag, extra, "");
|
|
||||||
return (strsvis(dst, src, flag, extra));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
strvisx(dst, src, len, flag)
|
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
size_t len;
|
|
||||||
int flag;
|
|
||||||
{
|
|
||||||
char *extra;
|
|
||||||
|
|
||||||
MAKEEXTRALIST(flag, extra, "");
|
|
||||||
return (strsvisx(dst, src, len, flag, extra));
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,92 +0,0 @@
|
|||||||
/* $NetBSD: vis.h,v 1.15 2005/02/03 04:39:32 perry Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)vis.h 8.1 (Berkeley) 6/2/93
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VIS_H_
|
|
||||||
#define _VIS_H_
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* to select alternate encoding format
|
|
||||||
*/
|
|
||||||
#define VIS_OCTAL 0x01 /* use octal \ddd format */
|
|
||||||
#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropiate */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* to alter set of characters encoded (default is to encode all
|
|
||||||
* non-graphic except space, tab, and newline).
|
|
||||||
*/
|
|
||||||
#define VIS_SP 0x04 /* also encode space */
|
|
||||||
#define VIS_TAB 0x08 /* also encode tab */
|
|
||||||
#define VIS_NL 0x10 /* also encode newline */
|
|
||||||
#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
|
|
||||||
#define VIS_SAFE 0x20 /* only encode "unsafe" characters */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* other
|
|
||||||
*/
|
|
||||||
#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
|
|
||||||
#define VIS_HTTPSTYLE 0x80 /* http-style escape % HEX HEX */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* unvis return codes
|
|
||||||
*/
|
|
||||||
#define UNVIS_VALID 1 /* character valid */
|
|
||||||
#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
|
|
||||||
#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
|
|
||||||
#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
|
|
||||||
#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* unvis flags
|
|
||||||
*/
|
|
||||||
#define UNVIS_END 1 /* no more characters */
|
|
||||||
|
|
||||||
__BEGIN_DECLS
|
|
||||||
char *vis(char *, int, int, int);
|
|
||||||
char *svis(char *, int, int, int, const char *);
|
|
||||||
int strvis(char *, const char *, int);
|
|
||||||
int strsvis(char *, const char *, int, const char *);
|
|
||||||
int strvisx(char *, const char *, size_t, int);
|
|
||||||
int strsvisx(char *, const char *, size_t, int, const char *);
|
|
||||||
int strunvis(char *, const char *);
|
|
||||||
int strunvisx(char *, const char *, int);
|
|
||||||
#ifdef __LIBC12_SOURCE__
|
|
||||||
int unvis(char *, int, int *, int);
|
|
||||||
int __unvis13(char *, int, int *, int);
|
|
||||||
#else
|
|
||||||
int unvis(char *, int, int *, int);
|
|
||||||
#endif
|
|
||||||
__END_DECLS
|
|
||||||
|
|
||||||
#endif /* !_VIS_H_ */
|
|
@ -302,7 +302,9 @@ AC_DEFUN([MYSQL_CONFIGURE_PLUGINS],[
|
|||||||
_MYSQL_CONFIGURE_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
|
_MYSQL_CONFIGURE_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
|
||||||
_MYSQL_EMIT_PLUGIN_ACTIONS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
|
_MYSQL_EMIT_PLUGIN_ACTIONS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
|
||||||
AC_SUBST([mysql_se_dirs])
|
AC_SUBST([mysql_se_dirs])
|
||||||
|
AC_SUBST([mysql_se_distdirs])
|
||||||
AC_SUBST([mysql_pg_dirs])
|
AC_SUBST([mysql_pg_dirs])
|
||||||
|
AC_SUBST([mysql_pg_distdirs])
|
||||||
AC_SUBST([mysql_se_unittest_dirs])
|
AC_SUBST([mysql_se_unittest_dirs])
|
||||||
AC_SUBST([mysql_pg_unittest_dirs])
|
AC_SUBST([mysql_pg_unittest_dirs])
|
||||||
AC_SUBST([condition_dependent_plugin_modules])
|
AC_SUBST([condition_dependent_plugin_modules])
|
||||||
@ -354,6 +356,24 @@ AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
|
|||||||
fi
|
fi
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
],[
|
],[
|
||||||
|
|
||||||
|
# Plugin is not disabled, determine if it should be built,
|
||||||
|
# or only distributed
|
||||||
|
|
||||||
|
m4_ifdef([$6], [
|
||||||
|
if test ! -d "$srcdir/$6"; then
|
||||||
|
# Plugin directory was removed after autoconf was run; treat
|
||||||
|
# this as a disabled plugin
|
||||||
|
if test "X[$with_plugin_]$2" = Xyes; then
|
||||||
|
AC_MSG_RESULT([error])
|
||||||
|
AC_MSG_ERROR([disabled])
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The result message will be printed below
|
||||||
|
[with_plugin_]$2=no
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
m4_ifdef([$9],[
|
m4_ifdef([$9],[
|
||||||
if test "X[$with_plugin_]$2" = Xno; then
|
if test "X[$with_plugin_]$2" = Xno; then
|
||||||
AC_MSG_RESULT([error])
|
AC_MSG_RESULT([error])
|
||||||
@ -372,6 +392,8 @@ AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
if test "X[$with_plugin_]$2" = Xno; then
|
if test "X[$with_plugin_]$2" = Xno; then
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
else
|
else
|
||||||
@ -448,28 +470,36 @@ dnl Although this is "pretty", it breaks libmysqld build
|
|||||||
condition_dependent_plugin_includes="$condition_dependent_plugin_includes -I[\$(top_srcdir)]/$6/m4_bregexp($11, [^.+[/$]], [\&])"
|
condition_dependent_plugin_includes="$condition_dependent_plugin_includes -I[\$(top_srcdir)]/$6/m4_bregexp($11, [^.+[/$]], [\&])"
|
||||||
])
|
])
|
||||||
fi
|
fi
|
||||||
m4_ifdef([$6],[
|
fi
|
||||||
if test -n "$mysql_use_plugin_dir" ; then
|
|
||||||
mysql_plugin_dirs="$mysql_plugin_dirs $6"
|
m4_ifdef([$6], [
|
||||||
|
if test -d "$srcdir/$6"; then
|
||||||
|
# Even if we don't build a plugin, we bundle its source into the dist
|
||||||
|
# file. So its Makefile (and Makefiles for any subdirs) must be
|
||||||
|
# generated for 'make dist' to work.
|
||||||
m4_syscmd(test -f "$6/configure")
|
m4_syscmd(test -f "$6/configure")
|
||||||
ifelse(m4_sysval, 0,
|
ifelse(m4_sysval, 0,
|
||||||
[AC_CONFIG_SUBDIRS($6)],
|
[AC_CONFIG_SUBDIRS($6)],
|
||||||
[AC_CONFIG_FILES($6/Makefile)]
|
[AC_CONFIG_FILES($6/Makefile)]
|
||||||
)
|
)
|
||||||
ifelse(m4_substr($6, 0, 8), [storage/],
|
|
||||||
[
|
ifelse(
|
||||||
[mysql_se_dirs="$mysql_se_dirs ]m4_substr($6, 8)"
|
m4_substr($6, 0, 8), [storage/], [
|
||||||
|
mysql_se_distdirs="$mysql_se_distdirs m4_substr($6, 8)"
|
||||||
|
if test -n "$mysql_use_plugin_dir" ; then
|
||||||
|
mysql_se_dirs="$mysql_se_dirs m4_substr($6, 8)"
|
||||||
mysql_se_unittest_dirs="$mysql_se_unittest_dirs ../$6"
|
mysql_se_unittest_dirs="$mysql_se_unittest_dirs ../$6"
|
||||||
],
|
fi],
|
||||||
m4_substr($6, 0, 7), [plugin/],
|
|
||||||
[
|
m4_substr($6, 0, 7), [plugin/], [
|
||||||
[mysql_pg_dirs="$mysql_pg_dirs ]m4_substr($6, 7)"
|
mysql_pg_distdirs="$mysql_pg_distdirs m4_substr($6, 7)"
|
||||||
|
if test -n "$mysql_use_plugin_dir" ; then
|
||||||
|
mysql_pg_dirs="$mysql_pg_dirs m4_substr($6, 7)"
|
||||||
mysql_pg_unittest_dirs="$mysql_pg_unittest_dirs ../$6"
|
mysql_pg_unittest_dirs="$mysql_pg_unittest_dirs ../$6"
|
||||||
],
|
fi],
|
||||||
[AC_FATAL([don't know how to handle plugin dir ]$6)])
|
[AC_FATAL([don't know how to handle plugin dir ]$6)])
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
fi
|
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
29
configure.in
29
configure.in
@ -36,6 +36,7 @@ MYSQL_NUMERIC_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|[[a-z]][[a-z0-9]]
|
|||||||
MYSQL_BASE_VERSION=`echo $MYSQL_NUMERIC_VERSION | sed -e "s|\.[[^.]]*$||"`
|
MYSQL_BASE_VERSION=`echo $MYSQL_NUMERIC_VERSION | sed -e "s|\.[[^.]]*$||"`
|
||||||
MYSQL_VERSION_ID=`echo $MYSQL_NUMERIC_VERSION | \
|
MYSQL_VERSION_ID=`echo $MYSQL_NUMERIC_VERSION | \
|
||||||
awk -F. '{printf "%d%0.2d%0.2d", $1, $2, $3}'`
|
awk -F. '{printf "%d%0.2d%0.2d", $1, $2, $3}'`
|
||||||
|
MYSQL_COPYRIGHT_YEAR=`date '+%Y'`
|
||||||
|
|
||||||
# Add previous major version for debian package upgrade path
|
# Add previous major version for debian package upgrade path
|
||||||
MYSQL_PREVIOUS_BASE_VERSION=5.0
|
MYSQL_PREVIOUS_BASE_VERSION=5.0
|
||||||
@ -71,6 +72,7 @@ AC_SUBST(MYSQL_NO_DASH_VERSION)
|
|||||||
AC_SUBST(MYSQL_BASE_VERSION)
|
AC_SUBST(MYSQL_BASE_VERSION)
|
||||||
AC_SUBST(MYSQL_VERSION_ID)
|
AC_SUBST(MYSQL_VERSION_ID)
|
||||||
AC_SUBST(MYSQL_PREVIOUS_BASE_VERSION)
|
AC_SUBST(MYSQL_PREVIOUS_BASE_VERSION)
|
||||||
|
AC_SUBST(MYSQL_COPYRIGHT_YEAR)
|
||||||
AC_SUBST(PROTOCOL_VERSION)
|
AC_SUBST(PROTOCOL_VERSION)
|
||||||
AC_DEFINE_UNQUOTED([PROTOCOL_VERSION], [$PROTOCOL_VERSION],
|
AC_DEFINE_UNQUOTED([PROTOCOL_VERSION], [$PROTOCOL_VERSION],
|
||||||
[mysql client protocol version])
|
[mysql client protocol version])
|
||||||
@ -814,7 +816,7 @@ AC_TYPE_SIZE_T
|
|||||||
AC_HEADER_DIRENT
|
AC_HEADER_DIRENT
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_HEADER_SYS_WAIT
|
AC_HEADER_SYS_WAIT
|
||||||
AC_CHECK_HEADERS(fcntl.h float.h floatingpoint.h ieeefp.h limits.h \
|
AC_CHECK_HEADERS(fcntl.h fenv.h float.h floatingpoint.h ieeefp.h limits.h \
|
||||||
memory.h pwd.h select.h fnmatch.h \
|
memory.h pwd.h select.h fnmatch.h \
|
||||||
stdlib.h stddef.h sys/stat.h \
|
stdlib.h stddef.h sys/stat.h \
|
||||||
strings.h string.h synch.h sys/mman.h sys/socket.h netinet/in.h arpa/inet.h \
|
strings.h string.h synch.h sys/mman.h sys/socket.h netinet/in.h arpa/inet.h \
|
||||||
@ -837,19 +839,17 @@ AC_CHECK_LIB(nsl_r, gethostbyname_r, [],
|
|||||||
AC_CHECK_LIB(nsl, gethostbyname_r))
|
AC_CHECK_LIB(nsl, gethostbyname_r))
|
||||||
AC_CHECK_FUNC(gethostbyname_r)
|
AC_CHECK_FUNC(gethostbyname_r)
|
||||||
|
|
||||||
AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
|
AC_SEARCH_LIBS(setsockopt, socket)
|
||||||
AC_CHECK_FUNC(yp_get_default_domain, ,
|
|
||||||
AC_CHECK_LIB(nsl, yp_get_default_domain))
|
|
||||||
AC_CHECK_FUNC(p2open, , AC_CHECK_LIB(gen, p2open))
|
|
||||||
# This may get things to compile even if bind-8 is installed
|
# This may get things to compile even if bind-8 is installed
|
||||||
AC_CHECK_FUNC(bind, , AC_CHECK_LIB(bind, bind))
|
AC_SEARCH_LIBS(bind, bind)
|
||||||
# Check if crypt() exists in libc or libcrypt, sets LIBS if needed
|
# Check if crypt() exists in libc or libcrypt, sets LIBS if needed
|
||||||
AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(HAVE_CRYPT, 1, [crypt]))
|
AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(HAVE_CRYPT, 1, [crypt]))
|
||||||
# See if we need a library for address lookup.
|
# See if we need a library for address lookup.
|
||||||
AC_SEARCH_LIBS(inet_aton, [socket nsl resolv])
|
AC_SEARCH_LIBS(inet_aton, [socket nsl resolv])
|
||||||
|
|
||||||
# For the sched_yield() function on Solaris
|
# For the sched_yield() function on Solaris
|
||||||
AC_CHECK_FUNC(sched_yield, , AC_CHECK_LIB(posix4, sched_yield))
|
AC_SEARCH_LIBS(sched_yield, posix4,
|
||||||
|
AC_DEFINE(HAVE_SCHED_YIELD, 1, [sched_yield]))
|
||||||
|
|
||||||
MYSQL_CHECK_ZLIB_WITH_COMPRESS
|
MYSQL_CHECK_ZLIB_WITH_COMPRESS
|
||||||
|
|
||||||
@ -955,7 +955,7 @@ AC_MSG_RESULT([$USE_PSTACK])
|
|||||||
# Check for gtty if termio.h doesn't exists
|
# Check for gtty if termio.h doesn't exists
|
||||||
if test "$ac_cv_header_termio_h" = "no" -a "$ac_cv_header_termios_h" = "no"
|
if test "$ac_cv_header_termio_h" = "no" -a "$ac_cv_header_termios_h" = "no"
|
||||||
then
|
then
|
||||||
AC_CHECK_FUNC(gtty, , AC_CHECK_LIB(compat, gtty))
|
AC_SEARCH_LIBS(gtty, compat)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We make a special variable for non-threaded version of LIBS to avoid
|
# We make a special variable for non-threaded version of LIBS to avoid
|
||||||
@ -2044,7 +2044,7 @@ AC_FUNC_VPRINTF
|
|||||||
|
|
||||||
AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
|
AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
|
||||||
chsize cuserid fchmod fcntl \
|
chsize cuserid fchmod fcntl \
|
||||||
fconvert fdatasync finite fpresetsticky fpsetmask fsync ftruncate \
|
fconvert fdatasync fesetround finite fpresetsticky fpsetmask fsync ftruncate \
|
||||||
getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \
|
getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \
|
||||||
getpwuid getrlimit getrusage getwd index initgroups isnan \
|
getpwuid getrlimit getrusage getwd index initgroups isnan \
|
||||||
localtime_r gethrtime gmtime_r \
|
localtime_r gethrtime gmtime_r \
|
||||||
@ -2052,7 +2052,7 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
|
|||||||
mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \
|
mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \
|
||||||
pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \
|
pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \
|
||||||
pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \
|
pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \
|
||||||
pthread_key_delete pthread_rwlock_rdlock pthread_setprio pthread_setschedprio \
|
pthread_key_delete pthread_rwlock_rdlock pthread_setprio \
|
||||||
pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
|
pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
|
||||||
realpath rename rint rwlock_init setupterm \
|
realpath rename rint rwlock_init setupterm \
|
||||||
shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
|
shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
|
||||||
@ -2075,6 +2075,15 @@ case "$target" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
case "$mysql_cv_sys_os" in
|
||||||
|
OS400) # i5/OS (OS/400) emits a SIGILL (Function not implemented) when
|
||||||
|
# unsupported priority values are passed to pthread_setschedprio.
|
||||||
|
# Since the only supported value is 1, treat it as inexistent.
|
||||||
|
;;
|
||||||
|
*) AC_CHECK_FUNCS(pthread_setschedprio)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Check that isinf() is available in math.h and can be used in both C and C++
|
# Check that isinf() is available in math.h and can be used in both C and C++
|
||||||
# code
|
# code
|
||||||
AC_MSG_CHECKING(for isinf in <math.h>)
|
AC_MSG_CHECKING(for isinf in <math.h>)
|
||||||
|
@ -34,7 +34,6 @@ functions */
|
|||||||
#include <sys/locking.h>
|
#include <sys/locking.h>
|
||||||
#include <sys/stat.h> /* chmod() constants*/
|
#include <sys/stat.h> /* chmod() constants*/
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <math.h> /* Because of rint() */
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@ -255,13 +254,6 @@ typedef SSIZE_T ssize_t;
|
|||||||
#define inline __inline
|
#define inline __inline
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
inline double rint(double nr)
|
|
||||||
{
|
|
||||||
double f = floor(nr);
|
|
||||||
double c = ceil(nr);
|
|
||||||
return (((c-nr) >= (nr-f)) ? f :c);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#define ulonglong2double(A) ((double) (ulonglong) (A))
|
#define ulonglong2double(A) ((double) (ulonglong) (A))
|
||||||
#define my_off_t2double(A) ((double) (my_off_t) (A))
|
#define my_off_t2double(A) ((double) (my_off_t) (A))
|
||||||
@ -316,7 +308,6 @@ inline ulonglong double2ulonglong(double d)
|
|||||||
#define HAVE_FLOAT_H
|
#define HAVE_FLOAT_H
|
||||||
#define HAVE_LIMITS_H
|
#define HAVE_LIMITS_H
|
||||||
#define HAVE_STDDEF_H
|
#define HAVE_STDDEF_H
|
||||||
#define HAVE_RINT /* defined in this file */
|
|
||||||
#define NO_FCNTL_NONBLOCK /* No FCNTL */
|
#define NO_FCNTL_NONBLOCK /* No FCNTL */
|
||||||
#define HAVE_ALLOCA
|
#define HAVE_ALLOCA
|
||||||
#define HAVE_STRPBRK
|
#define HAVE_STRPBRK
|
||||||
|
@ -72,7 +72,7 @@ extern void my_cleanup_options(const struct my_option *options);
|
|||||||
extern void my_print_help(const struct my_option *options);
|
extern void my_print_help(const struct my_option *options);
|
||||||
extern void my_print_variables(const struct my_option *options);
|
extern void my_print_variables(const struct my_option *options);
|
||||||
extern void my_getopt_register_get_addr(uchar ** (*func_addr)(const char *, uint,
|
extern void my_getopt_register_get_addr(uchar ** (*func_addr)(const char *, uint,
|
||||||
const struct my_option *));
|
const struct my_option *, int *));
|
||||||
|
|
||||||
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
|
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
|
||||||
my_bool *fix);
|
my_bool *fix);
|
||||||
|
@ -430,6 +430,9 @@ C_MODE_END
|
|||||||
#ifdef HAVE_FLOAT_H
|
#ifdef HAVE_FLOAT_H
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_FENV_H
|
||||||
|
#include <fenv.h> /* For fesetround() */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -592,8 +595,39 @@ typedef unsigned short ushort;
|
|||||||
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
|
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
|
||||||
#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
|
#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
|
||||||
#ifndef HAVE_RINT
|
#ifndef HAVE_RINT
|
||||||
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
|
/**
|
||||||
#endif
|
All integers up to this number can be represented exactly as double precision
|
||||||
|
values (DBL_MANT_DIG == 53 for IEEE 754 hardware).
|
||||||
|
*/
|
||||||
|
#define MAX_EXACT_INTEGER ((1LL << DBL_MANT_DIG) - 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
rint(3) implementation for platforms that do not have it.
|
||||||
|
Always rounds to the nearest integer with ties being rounded to the nearest
|
||||||
|
even integer to mimic glibc's rint() behavior in the "round-to-nearest"
|
||||||
|
FPU mode. Hardware-specific optimizations are possible (frndint on x86).
|
||||||
|
Unlike this implementation, hardware will also honor the FPU rounding mode.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline double rint(double x)
|
||||||
|
{
|
||||||
|
double f, i;
|
||||||
|
f = modf(x, &i);
|
||||||
|
/*
|
||||||
|
All doubles with absolute values > MAX_EXACT_INTEGER are even anyway,
|
||||||
|
no need to check it.
|
||||||
|
*/
|
||||||
|
if (x > 0.0)
|
||||||
|
i += (double) ((f > 0.5) || (f == 0.5 &&
|
||||||
|
i <= (double) MAX_EXACT_INTEGER &&
|
||||||
|
(longlong) i % 2));
|
||||||
|
else
|
||||||
|
i -= (double) ((f < -0.5) || (f == -0.5 &&
|
||||||
|
i >= (double) -MAX_EXACT_INTEGER &&
|
||||||
|
(longlong) i % 2));
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_RINT */
|
||||||
|
|
||||||
/* Define some general constants */
|
/* Define some general constants */
|
||||||
#ifndef TRUE
|
#ifndef TRUE
|
||||||
@ -635,7 +669,6 @@ C_MODE_END
|
|||||||
*/
|
*/
|
||||||
#define _VARARGS(X) X
|
#define _VARARGS(X) X
|
||||||
#define _STATIC_VARARGS(X) X
|
#define _STATIC_VARARGS(X) X
|
||||||
#define _PC(X) X
|
|
||||||
|
|
||||||
/* The DBUG_ON flag always takes precedence over default DBUG_OFF */
|
/* The DBUG_ON flag always takes precedence over default DBUG_OFF */
|
||||||
#if defined(DBUG_ON) && defined(DBUG_OFF)
|
#if defined(DBUG_ON) && defined(DBUG_OFF)
|
||||||
@ -739,7 +772,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
|
|||||||
#define UNSINT32 /* unsigned int32 */
|
#define UNSINT32 /* unsigned int32 */
|
||||||
|
|
||||||
/* General constants */
|
/* General constants */
|
||||||
#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */
|
|
||||||
#define FN_LEN 256 /* Max file name len */
|
#define FN_LEN 256 /* Max file name len */
|
||||||
#define FN_HEADLEN 253 /* Max length of filepart of file name */
|
#define FN_HEADLEN 253 /* Max length of filepart of file name */
|
||||||
#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
|
#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
|
||||||
|
@ -13,80 +13,42 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
|
/* See md5.c for explanation and copyright information. */
|
||||||
|
|
||||||
/* MD5.H - header file for MD5C.C
|
/*
|
||||||
|
* $FreeBSD: src/contrib/cvs/lib/md5.h,v 1.2 1999/12/11 15:10:02 peter Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
/* Unlike previous versions of this code, uint32 need not be exactly
|
||||||
rights reserved.
|
32 bits, merely 32 bits or more. Choosing a data type which is 32
|
||||||
|
bits instead of 64 is not important; speed is considerably more
|
||||||
|
important. ANSI guarantees that "unsigned long" will be big enough,
|
||||||
|
and always using it seems to have few disadvantages. */
|
||||||
|
typedef uint32 cvs_uint32;
|
||||||
|
|
||||||
License to copy and use this software is granted provided that it
|
|
||||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
|
||||||
Algorithm" in all material mentioning or referencing this software
|
|
||||||
or this function.
|
|
||||||
|
|
||||||
License is also granted to make and use derivative works provided
|
|
||||||
that such works are identified as "derived from the RSA Data
|
|
||||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
|
||||||
mentioning or referencing the derived work.
|
|
||||||
|
|
||||||
RSA Data Security, Inc. makes no representations concerning either
|
|
||||||
the merchantability of this software or the suitability of this
|
|
||||||
software for any particular purpose. It is provided "as is"
|
|
||||||
without express or implied warranty of any kind.
|
|
||||||
|
|
||||||
These notices must be retained in any copies of any part of this
|
|
||||||
documentation and/or software.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* GLOBAL.H - RSAREF types and constants
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* PROTOTYPES should be set to one if and only if the compiler supports
|
|
||||||
function argument prototyping.
|
|
||||||
The following makes PROTOTYPES default to 0 if it has not already
|
|
||||||
been defined with C compiler flags.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* egcs 1.1.2 under linux didn't defined it.... :( */
|
|
||||||
|
|
||||||
#ifndef PROTOTYPES
|
|
||||||
#define PROTOTYPES 1 /* Assume prototypes */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* POINTER defines a generic pointer type */
|
|
||||||
typedef unsigned char *POINTER;
|
|
||||||
|
|
||||||
/* UINT2 defines a two byte word */
|
|
||||||
typedef uint16 UINT2; /* Fix for MySQL / Alpha */
|
|
||||||
|
|
||||||
/* UINT4 defines a four byte word */
|
|
||||||
typedef uint32 UINT4; /* Fix for MySQL / Alpha */
|
|
||||||
|
|
||||||
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
|
|
||||||
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
|
|
||||||
returns an empty list.
|
|
||||||
*/
|
|
||||||
#if PROTOTYPES
|
|
||||||
#define PROTO_LIST(list) list
|
|
||||||
#else
|
|
||||||
#define PROTO_LIST(list) ()
|
|
||||||
#endif
|
|
||||||
/* MD5 context. */
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT4 state[4]; /* state (ABCD) */
|
cvs_uint32 buf[4];
|
||||||
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
|
cvs_uint32 bits[2];
|
||||||
unsigned char buffer[64]; /* input buffer */
|
unsigned char in[64];
|
||||||
} my_MD5_CTX;
|
} my_MD5Context;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
void my_MD5Init PROTO_LIST ((my_MD5_CTX *));
|
void my_MD5Init (my_MD5Context *context);
|
||||||
void my_MD5Update PROTO_LIST
|
void my_MD5Update (my_MD5Context *context,
|
||||||
((my_MD5_CTX *, unsigned char *, unsigned int));
|
unsigned char const *buf, unsigned len);
|
||||||
void my_MD5Final PROTO_LIST ((unsigned char [16], my_MD5_CTX *));
|
void my_MD5Final (unsigned char digest[16],
|
||||||
|
my_MD5Context *context);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MY_MD5_HASH(digest,buf,len) \
|
||||||
|
do { \
|
||||||
|
my_MD5Context ctx; \
|
||||||
|
my_MD5Init (&ctx); \
|
||||||
|
my_MD5Update (&ctx, buf, len); \
|
||||||
|
my_MD5Final (digest, &ctx); \
|
||||||
|
} while (0)
|
||||||
|
@ -39,8 +39,6 @@ extern int NEAR my_errno; /* Last error in mysys */
|
|||||||
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
|
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
|
||||||
#define MY_INIT(name); { my_progname= name; my_init(); }
|
#define MY_INIT(name); { my_progname= name; my_init(); }
|
||||||
|
|
||||||
#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */
|
|
||||||
#define NRERRBUFFS (2) /* Buffers for parameters */
|
|
||||||
#define MY_FILE_ERROR ((size_t) -1)
|
#define MY_FILE_ERROR ((size_t) -1)
|
||||||
|
|
||||||
/* General bitmaps for my_func's */
|
/* General bitmaps for my_func's */
|
||||||
@ -212,7 +210,6 @@ extern void my_large_free(uchar * ptr, myf my_flags);
|
|||||||
extern int errno; /* declare errno */
|
extern int errno; /* declare errno */
|
||||||
#endif
|
#endif
|
||||||
#endif /* #ifndef errno */
|
#endif /* #ifndef errno */
|
||||||
extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
|
|
||||||
extern char *home_dir; /* Home directory for user */
|
extern char *home_dir; /* Home directory for user */
|
||||||
extern const char *my_progname; /* program-name (printed in errors) */
|
extern const char *my_progname; /* program-name (printed in errors) */
|
||||||
extern const char *my_progname_short; /* like above but without directory */
|
extern const char *my_progname_short; /* like above but without directory */
|
||||||
@ -655,6 +652,7 @@ extern int nt_share_delete(const char *name,myf MyFlags);
|
|||||||
extern void TERMINATE(FILE *file, uint flag);
|
extern void TERMINATE(FILE *file, uint flag);
|
||||||
#endif
|
#endif
|
||||||
extern void init_glob_errs(void);
|
extern void init_glob_errs(void);
|
||||||
|
extern void wait_for_free_space(const char *filename, int errors);
|
||||||
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
|
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
|
||||||
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
|
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
|
||||||
extern int my_fclose(FILE *fd,myf MyFlags);
|
extern int my_fclose(FILE *fd,myf MyFlags);
|
||||||
|
@ -160,7 +160,8 @@ void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
|
|||||||
void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock);
|
void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock);
|
||||||
my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
|
my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
|
||||||
void thr_print_locks(void); /* For debugging */
|
void thr_print_locks(void); /* For debugging */
|
||||||
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data);
|
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
|
||||||
|
enum thr_lock_type new_lock_type);
|
||||||
void thr_downgrade_write_lock(THR_LOCK_DATA *data,
|
void thr_downgrade_write_lock(THR_LOCK_DATA *data,
|
||||||
enum thr_lock_type new_lock_type);
|
enum thr_lock_type new_lock_type);
|
||||||
my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data);
|
my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data);
|
||||||
|
@ -3833,13 +3833,13 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
|
|||||||
#undef NOT_FIXED_DEC
|
#undef NOT_FIXED_DEC
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
The 14 below is to ensure that the server and client has the same
|
DBL_DIG below is to ensure that the server and client has the same
|
||||||
precisions. This will ensure that on the same machine you get the
|
precisions. This will ensure that on the same machine you get the
|
||||||
same value as a string independent of the protocol you use.
|
same value as a string independent of the protocol you use.
|
||||||
*/
|
*/
|
||||||
sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
|
sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
|
||||||
param->buffer_length),
|
param->buffer_length),
|
||||||
min(14,width), value);
|
min(DBL_DIG, width), value);
|
||||||
end= strcend(buff, ' ');
|
end= strcend(buff, ' ');
|
||||||
*end= 0;
|
*end= 0;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,15 @@ extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
|
|||||||
static my_bool emb_read_query_result(MYSQL *mysql);
|
static my_bool emb_read_query_result(MYSQL *mysql);
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" void unireg_clear(int exit_code)
|
||||||
|
{
|
||||||
|
DBUG_ENTER("unireg_clear");
|
||||||
|
clean_up(!opt_help && (exit_code || !opt_bootstrap)); /* purecov: inspected */
|
||||||
|
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reads error information from the MYSQL_DATA and puts
|
Reads error information from the MYSQL_DATA and puts
|
||||||
it into proper MYSQL members
|
it into proper MYSQL members
|
||||||
|
@ -75,13 +75,13 @@ EXTRA_DIST = README \
|
|||||||
|
|
||||||
# List of directories containing test + result files and the
|
# List of directories containing test + result files and the
|
||||||
# related test data files that should be copied
|
# related test data files that should be copied
|
||||||
TEST_DIRS = t r include std_data std_data/parts \
|
TEST_DIRS = t r include std_data std_data/parts collections \
|
||||||
std_data/ndb_backup50 std_data/ndb_backup51 \
|
std_data/ndb_backup50 std_data/ndb_backup51 \
|
||||||
std_data/ndb_backup51_data_be std_data/ndb_backup51_data_le \
|
std_data/ndb_backup51_data_be std_data/ndb_backup51_data_le \
|
||||||
std_data/funcs_1 \
|
std_data/funcs_1 \
|
||||||
extra/binlog_tests/ extra/rpl_tests \
|
extra/binlog_tests/ extra/rpl_tests \
|
||||||
suite/binlog suite/binlog/t suite/binlog/r suite/binlog/std_data \
|
suite/binlog suite/binlog/t suite/binlog/r suite/binlog/std_data \
|
||||||
suite/bugs/data suite/bugs/t suite/bugs/r \
|
suite/bugs suite/bugs/data suite/bugs/t suite/bugs/r \
|
||||||
suite/federated \
|
suite/federated \
|
||||||
suite/funcs_1 suite/funcs_1/bitdata \
|
suite/funcs_1 suite/funcs_1/bitdata \
|
||||||
suite/funcs_1/include suite/funcs_1/lib suite/funcs_1/r \
|
suite/funcs_1/include suite/funcs_1/lib suite/funcs_1/r \
|
||||||
@ -90,7 +90,7 @@ TEST_DIRS = t r include std_data std_data/parts \
|
|||||||
suite/funcs_2 suite/funcs_2/charset suite/funcs_2/data \
|
suite/funcs_2 suite/funcs_2/charset suite/funcs_2/data \
|
||||||
suite/funcs_2/include suite/funcs_2/lib suite/funcs_2/r \
|
suite/funcs_2/include suite/funcs_2/lib suite/funcs_2/r \
|
||||||
suite/funcs_2/t \
|
suite/funcs_2/t \
|
||||||
suite/jp suite/jp/t suite/jp/r suite/jp/std_data \
|
suite/jp suite/jp/t suite/jp/r suite/jp/std_data suite/jp/include \
|
||||||
suite/manual/t suite/manual/r \
|
suite/manual/t suite/manual/r \
|
||||||
suite/ndb_team suite/ndb_team/t suite/ndb_team/r \
|
suite/ndb_team suite/ndb_team/t suite/ndb_team/r \
|
||||||
suite/rpl suite/rpl/data suite/rpl/include suite/rpl/r \
|
suite/rpl suite/rpl/data suite/rpl/include suite/rpl/r \
|
||||||
|
30
mysql-test/collections/README
Normal file
30
mysql-test/collections/README
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
This directory contains collections of test runs that we run during our
|
||||||
|
integration and release testing. Each file contains zero or more lines,
|
||||||
|
with one invocation of mysql-test-run.pl on each. These invocations are
|
||||||
|
written so that, with the assumption that perl is in your search path,
|
||||||
|
any collection can run as a shell script or a batch file, with the parent
|
||||||
|
mysql-test directory being the current working directory.
|
||||||
|
|
||||||
|
During integration testing, we choose the collection to run by following
|
||||||
|
these steps:
|
||||||
|
|
||||||
|
1) We choose the extension to look for, based on these rules:
|
||||||
|
- If we're running a per-push test, we choose ".push" as the extension.
|
||||||
|
- If we're running a daily test, we choose ".daily" as the extension.
|
||||||
|
- If we're running a weekly test, we choose ".weekly" as the extension.
|
||||||
|
|
||||||
|
2) If there is a collection that has the same name as the branch we're
|
||||||
|
testing plus the extension as determined in step 1, we choose that
|
||||||
|
collection.
|
||||||
|
|
||||||
|
3) If the branch is unknown or we have removed all characters from it
|
||||||
|
and still not found a matching collection, we choose the name "default"
|
||||||
|
plus the extension determined in step 1. If there is no such file,
|
||||||
|
we give up and don't test anything at all.
|
||||||
|
|
||||||
|
4) If we haven't found a collection yet, we remove the last character from
|
||||||
|
the branch name and go back to step 2.
|
||||||
|
|
||||||
|
5) The commands from the collection are run line by line via execv() or
|
||||||
|
similar system calls. They are not run as a shell script. Shell
|
||||||
|
expansions are not guaranteed to work and most likely won't.
|
25
mysql-test/collections/README.experimental
Normal file
25
mysql-test/collections/README.experimental
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
The .experimental files in this directory contain names of test cases that
|
||||||
|
are still in development and whose failures should be considered expected,
|
||||||
|
instead of regressions.
|
||||||
|
|
||||||
|
These files are to be used with the --experimental option of
|
||||||
|
mysql-test-run.pl. Please look at its help screen for usage information.
|
||||||
|
|
||||||
|
The syntax is as follows:
|
||||||
|
|
||||||
|
1) One line per test case.
|
||||||
|
|
||||||
|
2) Empty lines and lines starting with a hash (#) are ignored.
|
||||||
|
|
||||||
|
3) If any other line contains a blank followed by a hash (#), the hash
|
||||||
|
and any subsequent characters are ignored.
|
||||||
|
|
||||||
|
4) The full test case name including the suite and execution mode
|
||||||
|
must be specified, for example:
|
||||||
|
main.alias 'row' # bug#00000
|
||||||
|
|
||||||
|
5) As an exception to item 4, the last character of the test case
|
||||||
|
specification may be an asterisk (*). In that case, all test cases that
|
||||||
|
start with the same characters up to the last letter before the asterisk
|
||||||
|
are considered experimental:
|
||||||
|
main.a* # get rid of main.alias, main.alibaba and main.agliolio
|
1
mysql-test/collections/default.daily
Normal file
1
mysql-test/collections/default.daily
Normal file
@ -0,0 +1 @@
|
|||||||
|
perl mysql-test-run.pl --timer --force --comment=rpl_ndb_row --suite=rpl_ndb,ndb --mysqld=--binlog-format=row --experimental=collections/default.experimental
|
1
mysql-test/collections/default.experimental
Normal file
1
mysql-test/collections/default.experimental
Normal file
@ -0,0 +1 @@
|
|||||||
|
funcs_1.charset_collation_1 # depends on compile-time decisions
|
5
mysql-test/collections/default.push
Normal file
5
mysql-test/collections/default.push
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
perl mysql-test-run.pl --timer --force --comment=n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental
|
||||||
|
perl mysql-test-run.pl --timer --force --comment=ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental
|
||||||
|
perl mysql-test-run.pl --timer --force --comment=embedded --embedded --experimental=collections/default.experimental
|
||||||
|
perl mysql-test-run.pl --timer --force --comment=rpl_binlog_row --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental
|
||||||
|
perl mysql-test-run.pl --timer --force --comment=funcs_1 --suite=funcs_1 --experimental=collections/default.experimental
|
0
mysql-test/collections/default.weekly
Normal file
0
mysql-test/collections/default.weekly
Normal file
27
mysql-test/extra/binlog_tests/binlog_truncate.test
Normal file
27
mysql-test/extra/binlog_tests/binlog_truncate.test
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# BUG #36763: TRUNCATE TABLE fails to replicate when stmt-based
|
||||||
|
# binlogging is not supported.
|
||||||
|
|
||||||
|
# This should always be logged as a statement, even when executed as a
|
||||||
|
# row-by-row deletion.
|
||||||
|
|
||||||
|
# $before_truncate A statement to execute (just) before issuing the
|
||||||
|
# TRUNCATE TABLE
|
||||||
|
|
||||||
|
|
||||||
|
eval CREATE TABLE t1 (a INT) ENGINE=$engine;
|
||||||
|
eval CREATE TABLE t2 (a INT) ENGINE=$engine;
|
||||||
|
INSERT INTO t2 VALUES (1),(2),(3);
|
||||||
|
let $binlog_start = query_get_value("SHOW MASTER STATUS", Position, 1);
|
||||||
|
if (`select length('$before_truncate') > 0`) {
|
||||||
|
eval $before_truncate;
|
||||||
|
}
|
||||||
|
--echo **** Truncate of empty table shall be logged
|
||||||
|
TRUNCATE TABLE t1;
|
||||||
|
|
||||||
|
if (`select length('$before_truncate') > 0`) {
|
||||||
|
eval $before_truncate;
|
||||||
|
}
|
||||||
|
TRUNCATE TABLE t2;
|
||||||
|
source include/show_binlog_events.inc;
|
||||||
|
|
||||||
|
DROP TABLE t1,t2;
|
@ -419,7 +419,7 @@ connection master;
|
|||||||
update t31 set f5=555555555555555 where f3=6;
|
update t31 set f5=555555555555555 where f3=6;
|
||||||
update t31 set f2=2 where f3=2;
|
update t31 set f2=2 where f3=2;
|
||||||
update t31 set f1=NULL where f3=1;
|
update t31 set f1=NULL where f3=1;
|
||||||
update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
|
update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
|
||||||
|
|
||||||
--echo
|
--echo
|
||||||
--echo ** Delete from Master **
|
--echo ** Delete from Master **
|
||||||
|
@ -9,27 +9,8 @@
|
|||||||
|
|
||||||
--source include/master-slave.inc
|
--source include/master-slave.inc
|
||||||
|
|
||||||
let $format = STATEMENT;
|
let $trunc_stmt = TRUNCATE TABLE;
|
||||||
let $stmt = TRUNCATE TABLE;
|
|
||||||
--source extra/rpl_tests/rpl_truncate_helper.test
|
--source extra/rpl_tests/rpl_truncate_helper.test
|
||||||
|
|
||||||
let $format = MIXED;
|
let $trunc_stmt = DELETE FROM;
|
||||||
let $stmt = TRUNCATE TABLE;
|
|
||||||
--source extra/rpl_tests/rpl_truncate_helper.test
|
--source extra/rpl_tests/rpl_truncate_helper.test
|
||||||
|
|
||||||
let $format = ROW;
|
|
||||||
let $stmt = TRUNCATE TABLE;
|
|
||||||
--source extra/rpl_tests/rpl_truncate_helper.test
|
|
||||||
|
|
||||||
let $format = STATEMENT;
|
|
||||||
let $stmt = DELETE FROM;
|
|
||||||
--source extra/rpl_tests/rpl_truncate_helper.test
|
|
||||||
|
|
||||||
let $format = MIXED;
|
|
||||||
let $stmt = DELETE FROM;
|
|
||||||
--source extra/rpl_tests/rpl_truncate_helper.test
|
|
||||||
|
|
||||||
let $format = ROW;
|
|
||||||
let $stmt = DELETE FROM;
|
|
||||||
--source extra/rpl_tests/rpl_truncate_helper.test
|
|
||||||
|
|
||||||
|
@ -1,47 +1,35 @@
|
|||||||
connection slave;
|
source include/reset_master_and_slave.inc;
|
||||||
STOP SLAVE;
|
|
||||||
source include/wait_for_slave_to_stop.inc;
|
|
||||||
connection master;
|
|
||||||
--disable_warnings
|
|
||||||
DROP TABLE IF EXISTS t1;
|
|
||||||
--enable_warnings
|
|
||||||
connection slave;
|
|
||||||
--disable_warnings
|
|
||||||
DROP TABLE IF EXISTS t1;
|
|
||||||
--enable_warnings
|
|
||||||
RESET SLAVE;
|
|
||||||
START SLAVE;
|
|
||||||
|
|
||||||
--echo **** On Master ****
|
--echo **** On Master ****
|
||||||
connection master;
|
connection master;
|
||||||
SET @old_session_binlog_format= @@session.binlog_format;
|
|
||||||
SET @old_global_binlog_format= @@global.binlog_format;
|
|
||||||
|
|
||||||
eval SET SESSION BINLOG_FORMAT=$format;
|
|
||||||
eval SET GLOBAL BINLOG_FORMAT=$format;
|
|
||||||
|
|
||||||
eval CREATE TABLE t1 (a INT, b LONG) ENGINE=$engine;
|
eval CREATE TABLE t1 (a INT, b LONG) ENGINE=$engine;
|
||||||
INSERT INTO t1 VALUES (1,1), (2,2);
|
INSERT INTO t1 VALUES (1,1), (2,2);
|
||||||
SELECT * FROM t1;
|
|
||||||
--echo **** On Slave ****
|
|
||||||
sync_slave_with_master;
|
sync_slave_with_master;
|
||||||
INSERT INTO t1 VALUE (3,3);
|
|
||||||
SELECT * FROM t1;
|
|
||||||
--echo **** On Master ****
|
--echo **** On Master ****
|
||||||
connection master;
|
connection master;
|
||||||
eval $stmt t1;
|
eval $trunc_stmt t1;
|
||||||
SELECT * FROM t1;
|
|
||||||
--echo **** On Slave ****
|
|
||||||
sync_slave_with_master;
|
sync_slave_with_master;
|
||||||
# Should be empty
|
|
||||||
SELECT * FROM t1;
|
let $diff_table_1=master:test.t1;
|
||||||
|
let $diff_table_2=slave:test.t1;
|
||||||
|
source include/diff_tables.inc;
|
||||||
|
|
||||||
|
--echo ==== Test using a table with delete triggers ====
|
||||||
--echo **** On Master ****
|
--echo **** On Master ****
|
||||||
connection master;
|
connection master;
|
||||||
DROP TABLE t1;
|
SET @count := 1;
|
||||||
let $SERVER_VERSION=`select version()`;
|
eval CREATE TABLE t2 (a INT, b LONG) ENGINE=$engine;
|
||||||
source include/show_binlog_events.inc;
|
CREATE TRIGGER trg1 BEFORE DELETE ON t1 FOR EACH ROW SET @count := @count + 1;
|
||||||
|
sync_slave_with_master;
|
||||||
|
--echo **** On Master ****
|
||||||
|
connection master;
|
||||||
|
eval $trunc_stmt t1;
|
||||||
|
sync_slave_with_master;
|
||||||
|
|
||||||
|
let $diff_table_1=master:test.t2;
|
||||||
|
let $diff_table_2=slave:test.t2;
|
||||||
|
source include/diff_tables.inc;
|
||||||
|
|
||||||
connection master;
|
connection master;
|
||||||
RESET MASTER;
|
DROP TABLE t1,t2;
|
||||||
SET @@session.binlog_format= @old_session_binlog_format;
|
sync_slave_with_master;
|
||||||
SET @@global.binlog_format= @old_global_binlog_format;
|
|
||||||
|
@ -27,7 +27,7 @@ create temporary table error_log (
|
|||||||
) engine=myisam;
|
) engine=myisam;
|
||||||
|
|
||||||
# Get the name of servers error log
|
# Get the name of servers error log
|
||||||
let $log_error= query_get_value(show variables like 'log_error', Value, 1);
|
let $log_error= $MTR_LOG_ERROR;
|
||||||
let $log_warning= $log_error.warnings;
|
let $log_warning= $log_error.warnings;
|
||||||
|
|
||||||
# Try tload the warnings into a temporary table,
|
# Try tload the warnings into a temporary table,
|
||||||
|
21
mysql-test/include/count_sessions.inc
Normal file
21
mysql-test/include/count_sessions.inc
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# include/count_sessions.inc
|
||||||
|
#
|
||||||
|
# SUMMARY
|
||||||
|
#
|
||||||
|
# Stores the number of current sessions in $count_sessions.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# USAGE
|
||||||
|
#
|
||||||
|
# Please look into include/wait_until_count_sessions.inc
|
||||||
|
# for examples of typical usage.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# EXAMPLE
|
||||||
|
# backup.test, grant3.test
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Created: 2009-01-14 mleich
|
||||||
|
#
|
||||||
|
|
||||||
|
let $count_sessions= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1);
|
@ -479,6 +479,7 @@ handler t1 open;
|
|||||||
--echo --> client 1
|
--echo --> client 1
|
||||||
connection default;
|
connection default;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
disconnect con2;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Bug#30632 HANDLER read failure causes hang
|
# Bug#30632 HANDLER read failure causes hang
|
||||||
@ -692,3 +693,30 @@ unlock tables;
|
|||||||
drop table t1;
|
drop table t1;
|
||||||
--error ER_UNKNOWN_TABLE
|
--error ER_UNKNOWN_TABLE
|
||||||
handler t1 read a next;
|
handler t1 read a next;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug#41110: crash with handler command when used concurrently with alter table
|
||||||
|
# Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table
|
||||||
|
#
|
||||||
|
|
||||||
|
--disable_warnings
|
||||||
|
drop table if exists t1;
|
||||||
|
--enable_warnings
|
||||||
|
create table t1 (a int);
|
||||||
|
insert into t1 values (1);
|
||||||
|
handler t1 open;
|
||||||
|
connect(con1,localhost,root,,);
|
||||||
|
send alter table t1 engine=memory;
|
||||||
|
connection default;
|
||||||
|
let $wait_condition=
|
||||||
|
select count(*) = 1 from information_schema.processlist
|
||||||
|
where state = "rename result table" and info = "alter table t1 engine=memory";
|
||||||
|
--source include/wait_condition.inc
|
||||||
|
--error ER_ILLEGAL_HA
|
||||||
|
handler t1 read a next;
|
||||||
|
handler t1 close;
|
||||||
|
connection con1;
|
||||||
|
--reap
|
||||||
|
drop table t1;
|
||||||
|
disconnect con1;
|
||||||
|
connection default;
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
# By JBM 2006-02-16 So that the code is not repeated #
|
# By JBM 2006-02-16 So that the code is not repeated #
|
||||||
# in test cases and can be reused. #
|
# in test cases and can be reused. #
|
||||||
######################################################
|
######################################################
|
||||||
|
|
||||||
|
# Bug#41307: Tests using include/ndb_backup.inc won't work on Windows due to
|
||||||
|
# 'grep' call
|
||||||
|
# This test is disabled on Windows via the next line until the above bug is
|
||||||
|
# resolved
|
||||||
|
--source include/not_windows.inc
|
||||||
|
|
||||||
--exec $NDB_MGM --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -e "start backup" >> $NDB_TOOLS_OUTPUT
|
--exec $NDB_MGM --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -e "start backup" >> $NDB_TOOLS_OUTPUT
|
||||||
|
|
||||||
# there is no neat way to find the backupid, this is a hack to find it...
|
# there is no neat way to find the backupid, this is a hack to find it...
|
||||||
|
@ -108,7 +108,6 @@ execute stmt1 using @arg00, @arg01;
|
|||||||
select a,b from t1 where a=@arg00;
|
select a,b from t1 where a=@arg00;
|
||||||
set @arg00=NULL;
|
set @arg00=NULL;
|
||||||
set @arg01=2;
|
set @arg01=2;
|
||||||
--error 1048
|
|
||||||
execute stmt1 using @arg00, @arg01;
|
execute stmt1 using @arg00, @arg01;
|
||||||
select a,b from t1 order by a;
|
select a,b from t1 order by a;
|
||||||
set @arg00=0;
|
set @arg00=0;
|
||||||
|
@ -69,9 +69,9 @@ let $_fake_relay_log_purge= `SELECT @@global.relay_log_purge`;
|
|||||||
# Create relay log file.
|
# Create relay log file.
|
||||||
copy_file $fake_relay_log $_fake_relay_log;
|
copy_file $fake_relay_log $_fake_relay_log;
|
||||||
# Create relay log index.
|
# Create relay log index.
|
||||||
--exec echo $_fake_relay_log > $_fake_relay_index
|
--exec echo $_fake_filename-fake.000001 > $_fake_relay_index
|
||||||
|
|
||||||
# Setup replication from existing relay log.
|
# Setup replication from existing relay log.
|
||||||
eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_relay_log', RELAY_LOG_POS=4;
|
eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_filename-fake.000001', RELAY_LOG_POS=4;
|
||||||
|
|
||||||
--enable_query_log
|
--enable_query_log
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Run a query over and over until it suceeds ot timeout occurs
|
# Run a query over and over until it succeeds ot timeout occurs
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ while ($mysql_errno)
|
|||||||
|
|
||||||
if (!$counter)
|
if (!$counter)
|
||||||
{
|
{
|
||||||
die("Waited too long for query to suceed");
|
--die "Waited too long for query to succeed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enable_abort_on_error;
|
enable_abort_on_error;
|
78
mysql-test/include/wait_show_condition.inc
Normal file
78
mysql-test/include/wait_show_condition.inc
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
# include/wait_show_condition.inc
|
||||||
|
#
|
||||||
|
# SUMMARY
|
||||||
|
#
|
||||||
|
# Waits until the show statement ($show_statement) has at least within one of
|
||||||
|
# the rows of the result set for the field ($field) a value which fulfils
|
||||||
|
# a condition ($condition), or the operation times out.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# USAGE
|
||||||
|
#
|
||||||
|
# let $show_statement= SHOW PROCESSLIST;
|
||||||
|
# let $field= State;
|
||||||
|
# let $condition= = 'Updating';
|
||||||
|
# --source include/wait_show_condition.inc
|
||||||
|
#
|
||||||
|
# OR
|
||||||
|
#
|
||||||
|
# let $wait_timeout= 60; # Override default of 30 seconds with 60.
|
||||||
|
# let $show_statement= SHOW PROCESSLIST;
|
||||||
|
# let $field= State;
|
||||||
|
# let $condition= = 'Updating';
|
||||||
|
# --source include/wait_show_condition.inc
|
||||||
|
#
|
||||||
|
# Please do not use this use routine if you can replace the SHOW statement
|
||||||
|
# with a select. In such a case include/wait_condition.inc is recommended.
|
||||||
|
#
|
||||||
|
# Created: 2009-02-18 mleich
|
||||||
|
#
|
||||||
|
|
||||||
|
let $max_run_time= 30;
|
||||||
|
if ($wait_timeout)
|
||||||
|
{
|
||||||
|
let $max_run_time= $wait_timeout;
|
||||||
|
}
|
||||||
|
# Reset $wait_timeout so that its value won't be used on subsequent
|
||||||
|
# calls, and default will be used instead.
|
||||||
|
let $wait_timeout= 0;
|
||||||
|
|
||||||
|
# The smallest timespan till UNIX_TIMESTAMP() gets incremented is ~0 seconds.
|
||||||
|
# We add one second to avoid the case that somebody measures timespans on a
|
||||||
|
# real clock with fractions of seconds, detects that n seconds are sufficient,
|
||||||
|
# assigns n to this routine and suffers because he sometimes gets n - 1
|
||||||
|
# seconds in reality.
|
||||||
|
inc $max_run_time;
|
||||||
|
|
||||||
|
let $found= 0;
|
||||||
|
let $max_end_time= `SELECT UNIX_TIMESTAMP() + $max_run_time`;
|
||||||
|
while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`)
|
||||||
|
{
|
||||||
|
# Sleep a bit to avoid too heavy load.
|
||||||
|
real_sleep 0.2;
|
||||||
|
let $rowno= 1;
|
||||||
|
let $process_result= 1;
|
||||||
|
while (`SELECT $process_result = 1 AND $found = 0`)
|
||||||
|
{
|
||||||
|
let $field_value= query_get_value($show_statement, $field, $rowno);
|
||||||
|
if (`SELECT '$field_value' $condition`)
|
||||||
|
{
|
||||||
|
let $found= 1;
|
||||||
|
}
|
||||||
|
if (`SELECT '$field_value' = 'No such row'`)
|
||||||
|
{
|
||||||
|
# We are behind the last row of the result set.
|
||||||
|
let $process_result= 0;
|
||||||
|
}
|
||||||
|
inc $rowno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$found)
|
||||||
|
{
|
||||||
|
echo # Timeout in include/wait_show_condition.inc for $wait_condition;
|
||||||
|
echo # show_statement : $show_statement;
|
||||||
|
echo # field : $field;
|
||||||
|
echo # condition : $condition;
|
||||||
|
echo # max_run_time : $max_run_time;
|
||||||
|
}
|
||||||
|
|
126
mysql-test/include/wait_until_count_sessions.inc
Normal file
126
mysql-test/include/wait_until_count_sessions.inc
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
# include/wait_until_count_sessions.inc
|
||||||
|
#
|
||||||
|
# SUMMARY
|
||||||
|
#
|
||||||
|
# Waits until the passed number ($count_sessions) of concurrent sessions or
|
||||||
|
# a smaller number was observed via
|
||||||
|
# SHOW STATUS LIKE 'Threads_connected'
|
||||||
|
# or the operation times out.
|
||||||
|
# Note:
|
||||||
|
# 1. We wait for $current_sessions <= $count_sessions because in the use case
|
||||||
|
# with count_sessions.inc before and wait_until_count_sessions.inc after
|
||||||
|
# the core of the test it could happen that the disconnects of sessions
|
||||||
|
# belonging to the preceeding test are not finished.
|
||||||
|
# sessions at test begin($count_sessions) = m + n
|
||||||
|
# sessions of the previous test which will be soon disconnected = n (n >= 0)
|
||||||
|
# sessions at test end ($current sessions, assuming the test disconnects
|
||||||
|
# all additional sessions) = m
|
||||||
|
# 2. Starting with 5.1 we could also use
|
||||||
|
# SELECT COUNT(*) FROM information_schema.processlist
|
||||||
|
# I stay with "SHOW STATUS LIKE 'Threads_connected'" because this
|
||||||
|
# runs in all versions 5.0+
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# USAGE
|
||||||
|
#
|
||||||
|
# let $count_sessions= 3;
|
||||||
|
# --source include/wait_until_count_sessions.inc
|
||||||
|
#
|
||||||
|
# OR typical example of a test which uses more than one session
|
||||||
|
# Such a test could harm successing tests if there is no server shutdown
|
||||||
|
# and start between.
|
||||||
|
#
|
||||||
|
# If the testing box is slow than the disconnect of sessions belonging to
|
||||||
|
# the current test might happen when the successing test gets executed.
|
||||||
|
# This means the successing test might see activities like unexpected
|
||||||
|
# rows within the general log or the PROCESSLIST.
|
||||||
|
# Example from bug http://bugs.mysql.com/bug.php?id=40377
|
||||||
|
# --- bzr_mysql-6.0-rpl/.../r/log_state.result
|
||||||
|
# +++ bzr_mysql-6.0-rpl/.../r/log_state.reject
|
||||||
|
# @@ -25,6 +25,7 @@
|
||||||
|
# event_time user_host ... command_type argument
|
||||||
|
# TIMESTAMP USER_HOST ... Query create table t1(f1 int)
|
||||||
|
# TIMESTAMP USER_HOST ... Query select * from mysql.general_log
|
||||||
|
# +TIMESTAMP USER_HOST ... Quit
|
||||||
|
# ....
|
||||||
|
#
|
||||||
|
# What to do?
|
||||||
|
# -----------
|
||||||
|
# <start of test>
|
||||||
|
# # Determine initial number of connections (set $count_sessions)
|
||||||
|
# --source include/count_sessions.inc
|
||||||
|
# ...
|
||||||
|
# connect (con1,.....)
|
||||||
|
# ...
|
||||||
|
# connection default;
|
||||||
|
# ...
|
||||||
|
# disconnect con1;
|
||||||
|
# ...
|
||||||
|
# # Wait until we have reached the initial number of connections
|
||||||
|
# # or more than the sleep time above (10 seconds) has passed.
|
||||||
|
# # $count_sessions
|
||||||
|
# --source include/wait_until_count_sessions.inc
|
||||||
|
# <end of test>
|
||||||
|
#
|
||||||
|
# Important note about tests with unfortunate (= not cooperative
|
||||||
|
# to successing tests) architecture:
|
||||||
|
# connection con1;
|
||||||
|
# send SELECT ..., sleep(10)
|
||||||
|
# connection default;
|
||||||
|
# ...
|
||||||
|
# disconnect con1;
|
||||||
|
# <end of test>
|
||||||
|
# should be fixed by
|
||||||
|
# connection con1;
|
||||||
|
# send SELECT ..., sleep(10)
|
||||||
|
# connection default;
|
||||||
|
# ...
|
||||||
|
# connect con1;
|
||||||
|
# reap;
|
||||||
|
# connection default;
|
||||||
|
# disconnect con1;
|
||||||
|
# <end of test>
|
||||||
|
# and not only by appending include/wait_until_count_sessions.inc etc.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# EXAMPLE
|
||||||
|
#
|
||||||
|
# backup.test, grant3.test
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Created:
|
||||||
|
# 2009-01-14 mleich
|
||||||
|
# Modified:
|
||||||
|
# 2009-02-24 mleich Fix Bug#43114 wait_until_count_sessions too restrictive,
|
||||||
|
# random PB failures
|
||||||
|
#
|
||||||
|
|
||||||
|
let $wait_counter= 100;
|
||||||
|
if ($wait_timeout)
|
||||||
|
{
|
||||||
|
let $wait_counter= `SELECT $wait_timeout * 10`;
|
||||||
|
}
|
||||||
|
# Reset $wait_timeout so that its value won't be used on subsequent
|
||||||
|
# calls, and default will be used instead.
|
||||||
|
let $wait_timeout= 0;
|
||||||
|
while ($wait_counter)
|
||||||
|
{
|
||||||
|
let $current_sessions= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1);
|
||||||
|
let $success= `SELECT $current_sessions <= $count_sessions`;
|
||||||
|
if ($success)
|
||||||
|
{
|
||||||
|
let $wait_counter= 0;
|
||||||
|
}
|
||||||
|
if (!$success)
|
||||||
|
{
|
||||||
|
real_sleep 0.1;
|
||||||
|
dec $wait_counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$success)
|
||||||
|
{
|
||||||
|
--echo # Timeout in wait_until_count_sessions.inc
|
||||||
|
--echo # Number of sessions expected: <= $count_sessions found: $current_sessions
|
||||||
|
SHOW PROCESSLIST;
|
||||||
|
}
|
||||||
|
|
@ -116,8 +116,8 @@ sub fix_tmpdir {
|
|||||||
|
|
||||||
sub fix_log_error {
|
sub fix_log_error {
|
||||||
my ($self, $config, $group_name, $group)= @_;
|
my ($self, $config, $group_name, $group)= @_;
|
||||||
my $dir= dirname($group->value('datadir'));
|
my $dir= $self->{ARGS}->{vardir};
|
||||||
return "$dir/mysqld.err";
|
return "$dir/log/$group_name.err";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub fix_log {
|
sub fix_log {
|
||||||
@ -204,7 +204,7 @@ my @mysqld_rules=
|
|||||||
{ 'port' => \&fix_port },
|
{ 'port' => \&fix_port },
|
||||||
{ '#extra-port' => \&fix_port },
|
{ '#extra-port' => \&fix_port },
|
||||||
{ 'socket' => \&fix_socket },
|
{ 'socket' => \&fix_socket },
|
||||||
{ 'log-error' => \&fix_log_error },
|
{ '#log-error' => \&fix_log_error },
|
||||||
{ 'general-log' => sub { return 1; } },
|
{ 'general-log' => sub { return 1; } },
|
||||||
{ 'general-log-file' => \&fix_log },
|
{ 'general-log-file' => \&fix_log },
|
||||||
{ 'slow-query-log-file' => \&fix_log_slow_queries },
|
{ 'slow-query-log-file' => \&fix_log_slow_queries },
|
||||||
@ -392,7 +392,7 @@ sub post_check_embedded_group {
|
|||||||
|
|
||||||
my @no_copy =
|
my @no_copy =
|
||||||
(
|
(
|
||||||
'log-error', # Embedded server writes stderr to mysqltest's log file
|
'#log-error', # Embedded server writes stderr to mysqltest's log file
|
||||||
'slave-net-timeout', # Embedded server are not build with replication
|
'slave-net-timeout', # Embedded server are not build with replication
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -104,9 +104,136 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Check that Debugging tools for Windows are installed
|
||||||
|
sub cdb_check {
|
||||||
|
`cdb -? 2>&1`;
|
||||||
|
if ($? >> 8)
|
||||||
|
{
|
||||||
|
print "Cannot find cdb. Please Install Debugging tools for Windows\n";
|
||||||
|
print "from http://www.microsoft.com/whdc/devtools/debugging/";
|
||||||
|
if($ENV{'ProgramW6432'})
|
||||||
|
{
|
||||||
|
print "install64bit.mspx (native x64 version)\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "installx86.mspx\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub _cdb {
|
||||||
|
my ($core_name)= @_;
|
||||||
|
print "\nTrying 'cdb' to get a backtrace\n";
|
||||||
|
return unless -f $core_name;
|
||||||
|
|
||||||
|
# Try to set environment for debugging tools for Windows
|
||||||
|
if ($ENV{'PATH'} !~ /Debugging Tools/)
|
||||||
|
{
|
||||||
|
if ($ENV{'ProgramW6432'})
|
||||||
|
{
|
||||||
|
# On x64 computer
|
||||||
|
$ENV{'PATH'}.= ";".$ENV{'ProgramW6432'}."\\Debugging Tools For Windows (x64)";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# On x86 computer. Newest versions of Debugging tools are installed in the
|
||||||
|
# directory with (x86) suffix, older versions did not have this suffix.
|
||||||
|
$ENV{'PATH'}.= ";".$ENV{'ProgramFiles'}."\\Debugging Tools For Windows (x86)";
|
||||||
|
$ENV{'PATH'}.= ";".$ENV{'ProgramFiles'}."\\Debugging Tools For Windows";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Read module list, find out the name of executable and
|
||||||
|
# build symbol path (required by cdb if executable was built on
|
||||||
|
# different machine)
|
||||||
|
my $tmp_name= $core_name.".cdb_lmv";
|
||||||
|
`cdb -z $core_name -c \"lmv;q\" > $tmp_name 2>&1`;
|
||||||
|
if ($? >> 8)
|
||||||
|
{
|
||||||
|
unlink($tmp_name);
|
||||||
|
# check if cdb is installed and complain if not
|
||||||
|
cdb_check();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
open(temp,"< $tmp_name");
|
||||||
|
my %dirhash=();
|
||||||
|
while(<temp>)
|
||||||
|
{
|
||||||
|
if($_ =~ /Image path\: (.*)/)
|
||||||
|
{
|
||||||
|
if (rindex($1,'\\') != -1)
|
||||||
|
{
|
||||||
|
my $dir= substr($1, 0, rindex($1,'\\'));
|
||||||
|
$dirhash{$dir}++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(temp);
|
||||||
|
unlink($tmp_name);
|
||||||
|
|
||||||
|
my $image_path= join(";", (keys %dirhash),".");
|
||||||
|
|
||||||
|
# For better callstacks, setup _NT_SYMBOL_PATH to include
|
||||||
|
# OS symbols. Note : Dowloading symbols for the first time
|
||||||
|
# can take some minutes
|
||||||
|
if (!$ENV{'_NT_SYMBOL_PATH'})
|
||||||
|
{
|
||||||
|
my $windir= $ENV{'windir'};
|
||||||
|
my $symbol_cache= substr($windir ,0, index($windir,'\\'))."\\cdb_symbols";
|
||||||
|
|
||||||
|
print "OS debug symbols will be downloaded and stored in $symbol_cache.\n";
|
||||||
|
print "You can control the location of symbol cache with _NT_SYMBOL_PATH\n";
|
||||||
|
print "environment variable. Please refer to Microsoft KB article\n";
|
||||||
|
print "http://support.microsoft.com/kb/311503 for details about _NT_SYMBOL_PATH\n";
|
||||||
|
print "-------------------------------------------------------------------------\n";
|
||||||
|
|
||||||
|
$ENV{'_NT_SYMBOL_PATH'}.=
|
||||||
|
"srv*".$symbol_cache."*http://msdl.microsoft.com/download/symbols";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $symbol_path= $image_path.";".$ENV{'_NT_SYMBOL_PATH'};
|
||||||
|
|
||||||
|
|
||||||
|
# Run cdb. Use "analyze" extension to print crashing thread stacktrace
|
||||||
|
# and "uniqstack" to print other threads
|
||||||
|
|
||||||
|
my $cdb_cmd = "!sym prompts off; !analyze -v; .ecxr; !for_each_frame dv /t;!uniqstack -p;q";
|
||||||
|
my $cdb_output=
|
||||||
|
`cdb -z $core_name -i "$image_path" -y "$symbol_path" -t 0 -lines -c "$cdb_cmd" 2>&1`;
|
||||||
|
return if $? >> 8;
|
||||||
|
return unless $cdb_output;
|
||||||
|
|
||||||
|
# Remove comments (lines starting with *), stack pointer and frame
|
||||||
|
# pointer adresses and offsets to function to make output better readable
|
||||||
|
$cdb_output=~ s/^\*.*\n//gm;
|
||||||
|
$cdb_output=~ s/^([\:0-9a-fA-F\`]+ )+//gm;
|
||||||
|
$cdb_output=~ s/^ChildEBP RetAddr//gm;
|
||||||
|
$cdb_output=~ s/^Child\-SP RetAddr Call Site//gm;
|
||||||
|
$cdb_output=~ s/\+0x([0-9a-fA-F]+)//gm;
|
||||||
|
|
||||||
|
print <<EOF, $cdb_output, "\n";
|
||||||
|
Output from cdb follows. Faulting thread is printed twice,with and without function parameters
|
||||||
|
Search for STACK_TEXT to see the stack trace of
|
||||||
|
the faulting thread. Callstacks of other threads are printed after it.
|
||||||
|
EOF
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub show {
|
sub show {
|
||||||
my ($class, $core_name)= @_;
|
my ($class, $core_name)= @_;
|
||||||
|
|
||||||
|
# On Windows, rely on cdb to be there...
|
||||||
|
if (IS_WINDOWS)
|
||||||
|
{
|
||||||
|
_cdb($core_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
# We try dbx first; gdb itself may coredump if run on a Sun Studio
|
# We try dbx first; gdb itself may coredump if run on a Sun Studio
|
||||||
# compiled binary on Solaris.
|
# compiled binary on Solaris.
|
||||||
|
|
||||||
|
@ -113,8 +113,8 @@ sub check_socket_path_length {
|
|||||||
|
|
||||||
# Create a tempfile name with same length as "path"
|
# Create a tempfile name with same length as "path"
|
||||||
my $tmpdir = tempdir( CLEANUP => 0);
|
my $tmpdir = tempdir( CLEANUP => 0);
|
||||||
my $len = length($path) - length($tmpdir);
|
my $len = length($path) - length($tmpdir) - 1;
|
||||||
my $testfile = $tmpdir . "x" x ($len > 0 ? $len : 1);
|
my $testfile = $tmpdir . "/" . "x" x ($len > 0 ? $len : 1);
|
||||||
my $sock;
|
my $sock;
|
||||||
eval {
|
eval {
|
||||||
$sock= new IO::Socket::UNIX
|
$sock= new IO::Socket::UNIX
|
||||||
@ -126,17 +126,15 @@ sub check_socket_path_length {
|
|||||||
die "Could not create UNIX domain socket: $!"
|
die "Could not create UNIX domain socket: $!"
|
||||||
unless defined $sock;
|
unless defined $sock;
|
||||||
|
|
||||||
die "UNIX domain socket patch was truncated"
|
die "UNIX domain socket path was truncated"
|
||||||
unless ($testfile eq $sock->hostpath());
|
unless ($testfile eq $sock->hostpath());
|
||||||
|
|
||||||
$truncated= 0; # Yes, it worked!
|
$truncated= 0; # Yes, it worked!
|
||||||
|
|
||||||
};
|
};
|
||||||
#print "check_socket_path_length, failed: ", $@, '\n' if ($@);
|
|
||||||
|
|
||||||
$sock= undef; # Close socket
|
$sock= undef; # Close socket
|
||||||
unlink($testfile); # Remove the physical file
|
rmtree($tmpdir); # Remove the tempdir and any socket file created
|
||||||
rmdir($tmpdir); # Remove the tempdir
|
|
||||||
return $truncated;
|
return $truncated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +117,7 @@ sub new {
|
|||||||
my $output = delete($opts{'output'});
|
my $output = delete($opts{'output'});
|
||||||
my $error = delete($opts{'error'});
|
my $error = delete($opts{'error'});
|
||||||
my $verbose = delete($opts{'verbose'});
|
my $verbose = delete($opts{'verbose'});
|
||||||
|
my $nocore = delete($opts{'nocore'});
|
||||||
my $host = delete($opts{'host'});
|
my $host = delete($opts{'host'});
|
||||||
my $shutdown = delete($opts{'shutdown'});
|
my $shutdown = delete($opts{'shutdown'});
|
||||||
my $user_data= delete($opts{'user_data'});
|
my $user_data= delete($opts{'user_data'});
|
||||||
@ -137,6 +138,7 @@ sub new {
|
|||||||
push(@safe_args, $safe_script) if defined $safe_script;
|
push(@safe_args, $safe_script) if defined $safe_script;
|
||||||
|
|
||||||
push(@safe_args, "--verbose") if $verbose > 0;
|
push(@safe_args, "--verbose") if $verbose > 0;
|
||||||
|
push(@safe_args, "--nocore") if $nocore;
|
||||||
|
|
||||||
# Point the safe_process at the right parent if running on cygwin
|
# Point the safe_process at the right parent if running on cygwin
|
||||||
push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN;
|
push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN;
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -149,6 +150,7 @@ int main(int argc, char* const argv[] )
|
|||||||
char* const* child_argv= 0;
|
char* const* child_argv= 0;
|
||||||
pid_t own_pid= getpid();
|
pid_t own_pid= getpid();
|
||||||
pid_t parent_pid= getppid();
|
pid_t parent_pid= getppid();
|
||||||
|
bool nocore = false;
|
||||||
|
|
||||||
/* Install signal handlers */
|
/* Install signal handlers */
|
||||||
signal(SIGTERM, handle_signal);
|
signal(SIGTERM, handle_signal);
|
||||||
@ -181,6 +183,9 @@ int main(int argc, char* const argv[] )
|
|||||||
start++; /* Step past = */
|
start++; /* Step past = */
|
||||||
if ((parent_pid= atoi(start)) == 0)
|
if ((parent_pid= atoi(start)) == 0)
|
||||||
die("Invalid value '%s' passed to --parent-id", start);
|
die("Invalid value '%s' passed to --parent-id", start);
|
||||||
|
} else if ( strcmp(arg, "--nocore") == 0 )
|
||||||
|
{
|
||||||
|
nocore = true; // Don't allow the process to dump core
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
die("Unknown option: %s", arg);
|
die("Unknown option: %s", arg);
|
||||||
@ -218,6 +223,15 @@ int main(int argc, char* const argv[] )
|
|||||||
// it and any childs(that hasn't changed group themself)
|
// it and any childs(that hasn't changed group themself)
|
||||||
setpgid(0, 0);
|
setpgid(0, 0);
|
||||||
|
|
||||||
|
if (nocore)
|
||||||
|
{
|
||||||
|
struct rlimit corelim = { 0, 0 };
|
||||||
|
if (setrlimit (RLIMIT_CORE, &corelim) < 0)
|
||||||
|
{
|
||||||
|
message("setrlimit failed, errno=%d", errno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Signal that child is ready
|
// Signal that child is ready
|
||||||
buf= 37;
|
buf= 37;
|
||||||
write(pfd[1], &buf, 1);
|
write(pfd[1], &buf, 1);
|
||||||
|
@ -77,14 +77,29 @@ static void message(const char* fmt, ...)
|
|||||||
|
|
||||||
static void die(const char* fmt, ...)
|
static void die(const char* fmt, ...)
|
||||||
{
|
{
|
||||||
|
DWORD last_err= GetLastError();
|
||||||
va_list args;
|
va_list args;
|
||||||
fprintf(stderr, "%s: FATAL ERROR, ", safe_process_name);
|
fprintf(stderr, "%s: FATAL ERROR, ", safe_process_name);
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vfprintf(stderr, fmt, args);
|
vfprintf(stderr, fmt, args);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
va_end(args);
|
va_end(args);
|
||||||
if (int last_err= GetLastError())
|
if (last_err)
|
||||||
fprintf(stderr, "error: %d, %s\n", last_err, strerror(last_err));
|
{
|
||||||
|
char *message_text;
|
||||||
|
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||||
|
|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, last_err , 0, (LPSTR)&message_text,
|
||||||
|
0, NULL))
|
||||||
|
{
|
||||||
|
fprintf(stderr,"error: %d, %s\n",last_err, message_text);
|
||||||
|
LocalFree(message_text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* FormatMessage failed, print error code only */
|
||||||
|
fprintf(stderr,"error:%d\n", last_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -237,12 +252,19 @@ int main(int argc, const char** argv )
|
|||||||
/*
|
/*
|
||||||
Create the process suspended to make sure it's assigned to the
|
Create the process suspended to make sure it's assigned to the
|
||||||
Job before it creates any process of it's own
|
Job before it creates any process of it's own
|
||||||
|
|
||||||
|
Allow the new process to break away from any job that this
|
||||||
|
process is part of so that it can be assigned to the new JobObject
|
||||||
|
we just created. This is safe since the new JobObject is created with
|
||||||
|
the JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag, making sure it will be
|
||||||
|
terminated when the last handle to it is closed(which is owned by
|
||||||
|
this process).
|
||||||
*/
|
*/
|
||||||
if (CreateProcess(NULL, (LPSTR)child_args,
|
if (CreateProcess(NULL, (LPSTR)child_args,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
TRUE, /* inherit handles */
|
TRUE, /* inherit handles */
|
||||||
CREATE_SUSPENDED,
|
CREATE_SUSPENDED | CREATE_BREAKAWAY_FROM_JOB,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
&si,
|
&si,
|
||||||
|
@ -22,40 +22,46 @@ use strict;
|
|||||||
|
|
||||||
sub gcov_prepare ($) {
|
sub gcov_prepare ($) {
|
||||||
my ($dir)= @_;
|
my ($dir)= @_;
|
||||||
|
print "Purging gcov information from '$dir'...\n";
|
||||||
|
|
||||||
`find $dir -name \*.gcov \
|
system("find $dir -name \*.gcov -o -name \*.da"
|
||||||
-or -name \*.da | xargs rm`;
|
. " -o -name \*.gcda | grep -v 'README.gcov\$' | xargs rm");
|
||||||
}
|
}
|
||||||
|
|
||||||
my @mysqld_src_dirs=
|
#
|
||||||
(
|
# Collect gcov statistics.
|
||||||
"strings",
|
# Arguments:
|
||||||
"mysys",
|
# $dir basedir, normally source directory
|
||||||
"include",
|
# $gcov gcov utility program [path] name
|
||||||
"extra",
|
# $gcov_msg message file name
|
||||||
"regex",
|
# $gcov_err error file name
|
||||||
"isam",
|
#
|
||||||
"merge",
|
|
||||||
"myisam",
|
|
||||||
"myisammrg",
|
|
||||||
"heap",
|
|
||||||
"sql",
|
|
||||||
);
|
|
||||||
|
|
||||||
sub gcov_collect ($$$) {
|
sub gcov_collect ($$$) {
|
||||||
my ($dir, $gcov, $gcov_msg, $gcov_err)= @_;
|
my ($dir, $gcov, $gcov_msg, $gcov_err)= @_;
|
||||||
|
|
||||||
|
# Get current directory to return to later.
|
||||||
my $start_dir= cwd();
|
my $start_dir= cwd();
|
||||||
|
|
||||||
print "Collecting source coverage info...\n";
|
print "Collecting source coverage info using '$gcov'...\n";
|
||||||
-f $gcov_msg and unlink($gcov_msg);
|
-f "$start_dir/$gcov_msg" and unlink("$start_dir/$gcov_msg");
|
||||||
-f $gcov_err and unlink($gcov_err);
|
-f "$start_dir/$gcov_err" and unlink("$start_dir/$gcov_err");
|
||||||
foreach my $d ( @mysqld_src_dirs )
|
|
||||||
{
|
my @dirs= `find "$dir" -type d -print | sort`;
|
||||||
chdir("$dir/$d");
|
#print "List of directories:\n@dirs\n";
|
||||||
foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) )
|
|
||||||
{
|
foreach my $d ( @dirs ) {
|
||||||
`$gcov $f 2>>$gcov_err >>$gcov_msg`;
|
my $dir_reported= 0;
|
||||||
|
chomp($d);
|
||||||
|
chdir($d) or next;
|
||||||
|
|
||||||
|
foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) ) {
|
||||||
|
$f =~ /(.*)\.[ch]c?/;
|
||||||
|
-f "$1.gcno" or next;
|
||||||
|
if (!$dir_reported) {
|
||||||
|
print "Collecting in '$d'...\n";
|
||||||
|
$dir_reported= 1;
|
||||||
|
}
|
||||||
|
system("$gcov $f 2>>$start_dir/$gcov_err >>$start_dir/$gcov_msg");
|
||||||
}
|
}
|
||||||
chdir($start_dir);
|
chdir($start_dir);
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,8 @@ sub _mtr_report_test_name ($) {
|
|||||||
|
|
||||||
print _name(), _timestamp();
|
print _name(), _timestamp();
|
||||||
printf "%-40s ", $tname;
|
printf "%-40s ", $tname;
|
||||||
|
|
||||||
|
return $tname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,20 +107,48 @@ sub mtr_report_test_passed ($) {
|
|||||||
|
|
||||||
sub mtr_report_test ($) {
|
sub mtr_report_test ($) {
|
||||||
my ($tinfo)= @_;
|
my ($tinfo)= @_;
|
||||||
_mtr_report_test_name($tinfo);
|
my $test_name = _mtr_report_test_name($tinfo);
|
||||||
|
|
||||||
my $comment= $tinfo->{'comment'};
|
my $comment= $tinfo->{'comment'};
|
||||||
my $logfile= $tinfo->{'logfile'};
|
my $logfile= $tinfo->{'logfile'};
|
||||||
my $warnings= $tinfo->{'warnings'};
|
my $warnings= $tinfo->{'warnings'};
|
||||||
my $result= $tinfo->{'result'};
|
my $result= $tinfo->{'result'};
|
||||||
|
my $retry= $tinfo->{'retries'} ? "retry-" : "";
|
||||||
|
|
||||||
if ($result eq 'MTR_RES_FAILED'){
|
if ($result eq 'MTR_RES_FAILED'){
|
||||||
|
|
||||||
my $timest = format_time();
|
my $timest = format_time();
|
||||||
|
my $fail = "fail";
|
||||||
|
|
||||||
|
if ( $::opt_experimental )
|
||||||
|
{
|
||||||
|
# Find out if this test case is an experimental one, so we can treat
|
||||||
|
# the failure as an expected failure instead of a regression.
|
||||||
|
for my $exp ( @$::experimental_test_cases ) {
|
||||||
|
if ( $exp ne $test_name ) {
|
||||||
|
# if the expression is not the name of this test case, but has
|
||||||
|
# an asterisk at the end, determine if the characters up to
|
||||||
|
# but excluding the asterisk are the same
|
||||||
|
if ( $exp ne "" && substr($exp, -1, 1) eq "*" ) {
|
||||||
|
$exp = substr($exp, 0, length($exp) - 1);
|
||||||
|
if ( substr($test_name, 0, length($exp)) ne $exp ) {
|
||||||
|
# no match, try next entry
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
# if yes, fall through to set the exp-fail status
|
||||||
|
} else {
|
||||||
|
# no match, try next entry
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$fail = "exp-fail";
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $warnings )
|
if ( $warnings )
|
||||||
{
|
{
|
||||||
mtr_report("[ fail ] Found warnings/errors in server log file!");
|
mtr_report("[ $retry$fail ] Found warnings/errors in server log file!");
|
||||||
mtr_report(" Test ended at $timest");
|
mtr_report(" Test ended at $timest");
|
||||||
mtr_report($warnings);
|
mtr_report($warnings);
|
||||||
return;
|
return;
|
||||||
@ -126,14 +156,14 @@ sub mtr_report_test ($) {
|
|||||||
my $timeout= $tinfo->{'timeout'};
|
my $timeout= $tinfo->{'timeout'};
|
||||||
if ( $timeout )
|
if ( $timeout )
|
||||||
{
|
{
|
||||||
mtr_report("[ fail ] timeout after $timeout seconds");
|
mtr_report("[ $retry$fail ] timeout after $timeout seconds");
|
||||||
mtr_report(" Test ended at $timest");
|
mtr_report(" Test ended at $timest");
|
||||||
mtr_report("\n$tinfo->{'comment'}");
|
mtr_report("\n$tinfo->{'comment'}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mtr_report("[ fail ]\n Test ended at $timest");
|
mtr_report("[ $retry$fail ]\n Test ended at $timest");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $logfile )
|
if ( $logfile )
|
||||||
@ -176,7 +206,7 @@ sub mtr_report_test ($) {
|
|||||||
{
|
{
|
||||||
my $timer_str= $tinfo->{timer} || "";
|
my $timer_str= $tinfo->{timer} || "";
|
||||||
$tot_real_time += ($timer_str/1000);
|
$tot_real_time += ($timer_str/1000);
|
||||||
mtr_report("[ pass ] ", sprintf("%5s", $timer_str));
|
mtr_report("[ ${retry}pass ] ", sprintf("%5s", $timer_str));
|
||||||
|
|
||||||
# Show any problems check-testcase found
|
# Show any problems check-testcase found
|
||||||
if ( defined $tinfo->{'check'} )
|
if ( defined $tinfo->{'check'} )
|
||||||
|
@ -28,7 +28,17 @@ sub msg {
|
|||||||
# print "### unique($$) - ", join(" ", @_), "\n";
|
# print "### unique($$) - ", join(" ", @_), "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $file= "/tmp/mysql-test-ports";
|
my $file;
|
||||||
|
|
||||||
|
if(!IS_WINDOWS)
|
||||||
|
{
|
||||||
|
$file= "/tmp/mysql-test-ports";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$file= $ENV{'TEMP'}."/mysql-test-ports";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
my %mtr_unique_ids;
|
my %mtr_unique_ids;
|
||||||
|
|
||||||
@ -180,6 +190,8 @@ sub mtr_release_unique_id($) {
|
|||||||
|
|
||||||
flock SEM, LOCK_UN or warn "can't unlock $file.sem";
|
flock SEM, LOCK_UN or warn "can't unlock $file.sem";
|
||||||
close SEM;
|
close SEM;
|
||||||
|
|
||||||
|
delete $mtr_unique_ids{$$};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user