Commit 389680e0 authored by hf@deer.mysql.r18.ru's avatar hf@deer.mysql.r18.ru

Conflicts resolving

parents 1f6b6156 d14db396
......@@ -253,6 +253,7 @@ depcomp
extra/comp_err
extra/my_print_defaults
extra/mysql_install
extra/mysql_waitpid
extra/perror
extra/replace
extra/resolve_stack_dump
......@@ -350,6 +351,7 @@ libmysqld/opt_range.cc
libmysqld/opt_sum.cc
libmysqld/password.c
libmysqld/procedure.cc
libmysqld/protocol.cc
libmysqld/records.cc
libmysqld/repl_failsafe.cc
libmysqld/set_var.cc
......@@ -569,6 +571,7 @@ support-files/mysql-log-rotate
support-files/mysql.server
support-files/mysql.spec
tags
test_xml
tests/client_test
tmp/*
tools/my_vsnprintf.c
......@@ -579,6 +582,12 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
libmysqld/protocol.cc
test_xml
extra/mysql_waitpid
comon.h
emacs.h
fcns.c
fcns.h
help.h
help.c
vi.h
include/readline/readline.h
cmd-line-utils/libedit/common.h
......@@ -4,7 +4,7 @@ make -k clean
/bin/rm -f */.deps/*.P config.cache innobase/config.cache bdb/build_unix/config.cache mysql-*.tar.gz
aclocal; autoheader; aclocal; automake; autoconf
CC=ccc CFLAGS="-fast" CXX=cxx CXXFLAGS="-fast -noexceptions -nortti" ./configure --prefix=/usr/local/mysql --disable-shared --with-extra-charsets=complex --enable-thread-safe-client --with-mysqld-ldflags=-non_shared --with-client-ldflags=-non_shared --without-extra-tools
CC=ccc CFLAGS="-fast" CXX=cxx CXXFLAGS="-fast -noexceptions -nortti" ./configure --prefix=/usr/local/mysql --disable-shared --with-extra-charsets=complex --enable-thread-safe-client --with-mysqld-ldflags=-non_shared --with-client-ldflags=-non_shared --without-extra-tools --disable-dependency-tracking
make -j2
find . -name ".deps" | xargs rm -r
......
......@@ -17,6 +17,7 @@ bell@sanja.is.com.ua
bk@admin.bk
davida@isil.mysql.com
gluh@gluh.(none)
gluh@gluh.mysql.r18.ru
heikki@donna.mysql.fi
heikki@hundin.mysql.fi
heikki@rescue.
......
......@@ -21,10 +21,10 @@ AUTOMAKE_OPTIONS = foreign
# These are built from source in the Docs directory
EXTRA_DIST = INSTALL-SOURCE README \
COPYING COPYING.LIB
SUBDIRS = include @docs_dirs@ @readline_dir@ \
SUBDIRS = . include @docs_dirs@ @readline_dir@ \
@thread_dirs@ pstack @sql_client_dirs@ \
@sql_server_dirs@ @libmysqld_dirs@ scripts man \
tests BUILD os2 \
@sql_server_dirs@ scripts man tests \
BUILD os2 libmysql_r @libmysqld_dirs@ \
@bench_dirs@ support-files @fs_dirs@ @tools_dirs@
# Relink after clean
......
......@@ -116,6 +116,10 @@ SOURCE="..\strings\ctype-big5.c"
# End Source File
# Begin Source File
SOURCE="..\strings\ctype-bin.c"
# End Source File
# Begin Source File
SOURCE="..\strings\ctype-czech.c"
# End Source File
# Begin Source File
......@@ -204,10 +208,6 @@ SOURCE=..\mysys\mf_cache.c
# End Source File
# Begin Source File
SOURCE=..\mysys\mf_casecnv.c
# End Source File
# Begin Source File
SOURCE=..\mysys\mf_dirname.c
# End Source File
# Begin Source File
......@@ -422,6 +422,10 @@ SOURCE=.\select_test.c
# End Source File
# Begin Source File
SOURCE=..\mysys\sha1.c
# End Source File
# Begin Source File
SOURCE=.\sql_string.cpp
# End Source File
# Begin Source File
......
......@@ -59,7 +59,6 @@ EXPORTS
list_add
list_delete
max_allowed_packet
my_casecmp
my_init
my_end
my_strdup
......
......@@ -127,6 +127,10 @@ SOURCE="..\strings\ctype-big5.c"
# End Source File
# Begin Source File
SOURCE="..\strings\ctype-bin.c"
# End Source File
# Begin Source File
SOURCE="..\strings\ctype-czech.c"
# End Source File
# Begin Source File
......@@ -219,10 +223,6 @@ SOURCE=..\strings\longlong2str.c
# End Source File
# Begin Source File
SOURCE=..\mysys\mf_casecnv.c
# End Source File
# Begin Source File
SOURCE=..\mysys\mf_dirname.c
# End Source File
# Begin Source File
......@@ -396,6 +396,10 @@ SOURCE=..\client\select_test.c
# End Source File
# Begin Source File
SOURCE=..\mysys\sha1.c
# End Source File
# Begin Source File
SOURCE=..\client\sql_string.cpp
# End Source File
# Begin Source File
......
......@@ -162,10 +162,6 @@ SOURCE=.\mf_cache.c
# End Source File
# Begin Source File
SOURCE=.\mf_casecnv.c
# End Source File
# Begin Source File
SOURCE=.\mf_dirname.c
# End Source File
# Begin Source File
......@@ -234,6 +230,10 @@ SOURCE=.\mf_strip.c
# End Source File
# Begin Source File
SOURCE=.\mf_tempdir.c
# End Source File
# Begin Source File
SOURCE=.\mf_tempfile.c
# End Source File
# Begin Source File
......
......@@ -488,6 +488,10 @@ SOURCE=.\item_func.cpp
# End Source File
# Begin Source File
SOURCE=.\item_row.cpp
# End Source File
# Begin Source File
SOURCE=.\item_strfunc.cpp
!IF "$(CFG)" == "mysqld - Win32 Release"
......@@ -678,26 +682,6 @@ SOURCE=.\mysqld.cpp
# End Source File
# Begin Source File
SOURCE=.\net_pkg.cpp
!IF "$(CFG)" == "mysqld - Win32 Release"
!ELSEIF "$(CFG)" == "mysqld - Win32 Debug"
# ADD CPP /G5
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "mysqld - Win32 nt"
!ELSEIF "$(CFG)" == "mysqld - Win32 Max nt"
!ELSEIF "$(CFG)" == "mysqld - Win32 Max"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\net_serv.cpp
# End Source File
# Begin Source File
......@@ -963,6 +947,10 @@ SOURCE=.\sql_handler.cpp
# End Source File
# Begin Source File
SOURCE=.\sql_help.cpp
# End Source File
# Begin Source File
SOURCE=.\sql_insert.cpp
!IF "$(CFG)" == "mysqld - Win32 Release"
......
......@@ -104,6 +104,10 @@ SOURCE=.\bmove512.c
# End Source File
# Begin Source File
SOURCE=".\ctype-bin.c"
# End Source File
# Begin Source File
SOURCE=".\ctype-big5.c"
# End Source File
# Begin Source File
......@@ -168,6 +172,18 @@ SOURCE=.\str2int.c
# End Source File
# Begin Source File
SOURCE=.\strcend.c
# End Source File
# Begin Source File
SOURCE=.\strend.c
# End Source File
# Begin Source File
SOURCE=.\strfill.c
# End Source File
# Begin Source File
SOURCE=.\Strings.asm
!IF "$(CFG)" == "strings - Win32 Release"
......@@ -199,6 +215,19 @@ InputName=Strings
# End Source File
# Begin Source File
SOURCE=.\strmake.c
# End Source File
# Begin Source File
SOURCE=.\strmov.c
# End Source File
# Begin Source File
SOURCE=.\strnmov.c
# End Source File
# Begin Source File
SOURCE=.\strtol.c
# End Source File
# Begin Source File
......
......@@ -318,6 +318,22 @@
/* READLINE: */
#undef VOID_SIGHANDLER
/* used libedit interface (can we dereference result of rl_completion_entry_function?) */
#undef USE_LIBEDIT_INTERFACE
/* used new readline interface (does rl_completion_func_t and rl_compentry_func_t defined?) */
#undef USE_NEW_READLINE_INTERFACE
/* macro for libedit */
#undef HAVE_VIS_H
#undef HAVE_FGETLN
#undef HAVE_ISSETUGID
#undef HAVE_STRLCPY
#undef HAVE_GETLINE
#undef HAVE_FLOCKFILE
#undef HAVE_SYS_TYPES_H
#undef HAVE_SYS_CDEFS_H
/* Leave that blank line there!! Autoheader needs it.
If you're adding to this file, keep in mind:
......
# Local macros for automake & autoconf
AC_DEFUN(MYSQL_CHECK_LIBEDIT_INTERFACE,[
AC_CACHE_CHECK([libedit variant of rl_completion_entry_function], mysql_cv_libedit_interface,
AC_TRY_COMPILE(
[
#include "stdio.h"
#include "readline/readline.h"
],
[
char res= *(*rl_completion_entry_function)(0,0);
completion_matches(0,0);
],
[
mysql_cv_libedit_interface=yes
AC_DEFINE_UNQUOTED(USE_LIBEDIT_INTERFACE)
],
[mysql_cv_libedit_interface=no]
)
)
])
AC_DEFUN(MYSQL_CHECK_NEW_RL_INTERFACE,[
AC_CACHE_CHECK([defined rl_compentry_func_t and rl_completion_func_t], mysql_cv_new_rl_interface,
AC_TRY_COMPILE(
[
#include "stdio.h"
#include "readline/readline.h"
],
[
rl_completion_func_t *func1= (rl_completion_func_t*)0;
rl_compentry_func_t *func2= (rl_compentry_func_t*)0;
],
[
mysql_cv_new_rl_interface=yes
AC_DEFINE_UNQUOTED(USE_NEW_READLINE_INTERFACE)
],
[mysql_cv_new_rl_interface=no]
)
)
])
# A local version of AC_CHECK_SIZEOF that includes sys/types.h
dnl MYSQL_CHECK_SIZEOF(TYPE [, CROSS-SIZE])
AC_DEFUN(MYSQL_CHECK_SIZEOF,
......
......@@ -38,4 +38,5 @@ enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH,
OPT_SSL_CIPHER, OPT_SHUTDOWN_TIMEOUT, OPT_LOCAL_INFILE,
OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL,
OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM };
OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION,
OPT_COMPATIBLE };
......@@ -34,6 +34,7 @@ int main(int argc, char **argv)
exit(1);
}
mysql_init(&mysql);
if (!(sock = mysql_real_connect(&mysql,NULL,NULL,NULL,argv[1],0,NULL,0)))
{
fprintf(stderr,"Couldn't connect to engine!\n%s\n",mysql_error(&mysql));
......
......@@ -80,6 +80,8 @@ extern "C" {
#if defined( __WIN__) || defined(OS2)
#include <conio.h>
#else
// readline 4.2 has own __P
#undef __P
#include <readline/readline.h>
#define HAVE_READLINE
#endif
......@@ -273,9 +275,9 @@ static const char *server_default_groups[]=
{ "server", "embedded", "mysql_SERVER", 0 };
#ifdef HAVE_READLINE
extern "C" void add_history(char *command); /* From readline directory */
extern "C" int read_history(char *command);
extern "C" int write_history(char *command);
extern "C" int add_history(const char *command); /* From readline directory */
extern "C" int read_history(const char *command);
extern "C" int write_history(const char *command);
static void initialize_readline (char *name);
#endif
......@@ -1081,8 +1083,11 @@ static char **new_mysql_completion (const char *text, int start, int end);
if not.
*/
char *no_completion (const char *text __attribute__ ((unused)),
int )
#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_LIBEDIT_INTERFACE)
char *no_completion(const char*,int)
#else
int no_completion()
#endif
{
return 0; /* No filename completion */
}
......@@ -1093,12 +1098,15 @@ static void initialize_readline (char *name)
rl_readline_name = name;
/* Tell the completer that we want a crack first. */
#if RL_READLINE_VERSION > 0x0400
rl_attempted_completion_function = &new_mysql_completion;
rl_completion_entry_function= &no_completion;
#if defined(USE_NEW_READLINE_INTERFACE)
rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion;
rl_completion_entry_function= (rl_compentry_func_t*)&no_completion;
#elif defined(USE_LIBEDIT_INTERFACE)
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
rl_completion_entry_function= (CPFunction*)&no_completion;
#else
rl_attempted_completion_function =(CPPFunction *)new_mysql_completion;
rl_completion_entry_function= (Function *)no_completion;
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
rl_completion_entry_function= (Function*)&no_completion;
#endif
}
......@@ -1114,7 +1122,7 @@ static char **new_mysql_completion (const char *text,
int end __attribute__((unused)))
{
if (!status.batch && !quick)
#if RL_READLINE_VERSION > 0x0400
#if defined(USE_NEW_READLINE_INTERFACE)
return rl_completion_matches(text, new_command_generator);
#else
return completion_matches((char *)text, (CPFunction *)new_command_generator);
......@@ -2387,14 +2395,12 @@ com_use(String *buffer __attribute__((unused)), char *line)
items in the array to zero first.
*/
enum quote_type { NO_QUOTE, SQUOTE, DQUOTE, BTICK };
char *get_arg(char *line, my_bool get_next_arg)
{
char *ptr;
my_bool quoted= 0, valid_arg= 0;
uint count= 0;
enum quote_type qtype= NO_QUOTE;
char qtype= 0;
ptr= line;
if (get_next_arg)
......@@ -2415,10 +2421,9 @@ char *get_arg(char *line, my_bool get_next_arg)
}
while (my_isspace(system_charset_info, *ptr))
ptr++;
if ((*ptr == '\'' && (qtype= SQUOTE)) ||
(*ptr == '\"' && (qtype= DQUOTE)) ||
(*ptr == '`' && (qtype= BTICK)))
if (*ptr == '\'' || *ptr == '\"' || *ptr == '`')
{
qtype= *ptr;
quoted= 1;
ptr++;
}
......@@ -2435,10 +2440,7 @@ char *get_arg(char *line, my_bool get_next_arg)
ptr= line;
ptr+= count;
}
else if ((!quoted && *ptr == ' ') ||
(*ptr == '\'' && qtype == SQUOTE) ||
(*ptr == '\"' && qtype == DQUOTE) ||
(*ptr == '`' && qtype == BTICK))
else if ((!quoted && *ptr == ' ') || (quoted && *ptr == qtype))
{
*ptr= 0;
break;
......
......@@ -56,6 +56,9 @@ static short binlog_flags = 0;
static MYSQL* mysql = NULL;
static const char* table = 0;
static bool use_local_load= 0;
static const char* dirname_for_local_load= 0;
static void dump_local_log_entries(const char* logname);
static void dump_remote_log_entries(const char* logname);
static void dump_log_entries(const char* logname);
......@@ -64,6 +67,129 @@ static void dump_remote_table(NET* net, const char* db, const char* table);
static void die(const char* fmt, ...);
static MYSQL* safe_connect();
class Load_log_processor {
char target_dir_name[MY_NFILE];
int target_dir_name_len;
DYNAMIC_ARRAY file_names;
const char* create_file(Create_file_log_event *ce)
{
const char *bname= ce->fname + ce->fname_len -1;
while (bname>ce->fname && bname[-1]!=FN_LIBCHAR)
bname--;
uint blen= ce->fname_len - (bname-ce->fname);
uint full_len= target_dir_name_len + blen;
char *tmp;
if (!(tmp= my_malloc(full_len + 9 + 1,MYF(MY_WME))) ||
set_dynamic(&file_names,(gptr)&ce,ce->file_id))
{
die("Could not construct local filename %s%s",target_dir_name,bname);
return 0;
}
char *ptr= tmp;
memcpy(ptr,target_dir_name,target_dir_name_len);
ptr+= target_dir_name_len;
memcpy(ptr,bname,blen);
ptr+= blen;
sprintf(ptr,"-%08x",ce->file_id);
ce->set_fname_outside_temp_buf(tmp,full_len);
return tmp;
}
void append_to_file(const char* fname, int flags,
gptr data, uint size)
{
FILE *file;
if(!(file= my_fopen(fname,flags,MYF(MY_WME))))
exit(1);
if (my_fwrite(file,data,size,MYF(MY_WME|MY_NABP)))
exit(1);
if (my_fclose(file,MYF(MY_WME)))
exit(1);
}
public:
Load_log_processor()
{
init_dynamic_array(&file_names,sizeof(Create_file_log_event*),
100,100 CALLER_INFO);
}
~Load_log_processor()
{
destroy();
delete_dynamic(&file_names);
}
void init_by_dir_name(const char *atarget_dir_name)
{
char *end= strmov(target_dir_name,atarget_dir_name);
if (end[-1]!=FN_LIBCHAR)
*end++= FN_LIBCHAR;
target_dir_name_len= end-target_dir_name;
}
void init_by_file_name(const char *file_name)
{
int len= strlen(file_name);
const char *end= file_name + len - 1;
while (end>file_name && *end!=FN_LIBCHAR)
end--;
if (*end!=FN_LIBCHAR)
target_dir_name_len= 0;
else
{
target_dir_name_len= end - file_name + 1;
memmove(target_dir_name,file_name,target_dir_name_len);
}
}
void init_by_cur_dir()
{
target_dir_name_len= 0;
}
void destroy()
{
Create_file_log_event **ptr= (Create_file_log_event**)file_names.buffer;
Create_file_log_event **end= ptr + file_names.elements;
for (; ptr<end; ptr++)
{
if (*ptr)
{
my_free((char*)(*ptr)->fname,MYF(MY_WME));
delete *ptr;
*ptr= 0;
}
}
}
Create_file_log_event *grab_event(uint file_id)
{
Create_file_log_event **ptr=
(Create_file_log_event**)file_names.buffer + file_id;
Create_file_log_event *res= *ptr;
*ptr= 0;
return res;
}
void process(Create_file_log_event *ce)
{
const char *fname= create_file(ce);
append_to_file (fname,O_CREAT|O_BINARY,ce->block,ce->block_len);
}
void process(Append_block_log_event *ae)
{
if (ae->file_id >= file_names.elements)
die("Skiped CreateFile event for file_id: %u",ae->file_id);
Create_file_log_event* ce=
*((Create_file_log_event**)file_names.buffer + ae->file_id);
append_to_file(ce->fname,O_APPEND|O_BINARY,ae->block,ae->block_len);
}
};
Load_log_processor load_processor;
static struct my_option my_long_options[] =
{
#ifndef DBUG_OFF
......@@ -97,6 +223,9 @@ static struct my_option my_long_options[] =
{"user", 'u', "Connect to the remote server as username",
(gptr*) &user, (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0,
0, 0},
{"local-load", 'l', "Prepare files for local load in directory",
(gptr*) &dirname_for_local_load, (gptr*) &dirname_for_local_load, 0,
GET_STR_ALLOC, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
......@@ -209,6 +338,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'V':
print_version();
exit(0);
case 'l':
use_local_load= 1;
break;
case '?':
usage();
exit(0);
......@@ -420,6 +552,8 @@ static void dump_local_log_entries(const char* logname)
MYF(MY_WME | MY_NABP)))
exit(1);
old_format = check_header(file);
if (use_local_load && !dirname_for_local_load)
load_processor.init_by_file_name(logname);
}
else
{
......@@ -441,6 +575,8 @@ static void dump_local_log_entries(const char* logname)
}
file->pos_in_file=position;
file->seek_not_done=0;
if (use_local_load && !dirname_for_local_load)
load_processor.init_by_cur_dir();
}
if (!position)
......@@ -495,11 +631,43 @@ Could not read entry at offset %s : Error in log format or read error",
}
if (!short_form)
fprintf(result_file, "# at %s\n",llstr(old_off,llbuff));
ev->print(result_file, short_form, last_db);
if (!use_local_load)
ev->print(result_file, short_form, last_db);
else
{
switch(ev->get_type_code())
{
case CREATE_FILE_EVENT:
{
Create_file_log_event* ce= (Create_file_log_event*)ev;
ce->print(result_file, short_form, last_db,true);
load_processor.process(ce);
ev= 0;
break;
}
case APPEND_BLOCK_EVENT:
ev->print(result_file, short_form, last_db);
load_processor.process((Append_block_log_event*)ev);
break;
case EXEC_LOAD_EVENT:
{
ev->print(result_file, short_form, last_db);
Execute_load_log_event *exv= (Execute_load_log_event*)ev;
Create_file_log_event *ce= load_processor.grab_event(exv->file_id);
ce->print(result_file, short_form, last_db,true);
my_free((char*)ce->fname,MYF(MY_WME));
delete ce;
break;
}
default:
ev->print(result_file, short_form, last_db);
}
}
}
rec_count++;
delete ev;
if (ev)
delete ev;
}
if (fd >= 0)
my_close(fd, MYF(MY_WME));
......@@ -520,6 +688,8 @@ int main(int argc, char** argv)
if (use_remote)
mysql = safe_connect();
if (dirname_for_local_load)
load_processor.init_by_dir_name(dirname_for_local_load);
if (table)
{
......
This diff is collapsed.
......@@ -42,7 +42,7 @@
**********************************************************************/
#define MTEST_VERSION "1.26"
#define MTEST_VERSION "1.27"
#include <my_global.h>
#include <mysql_embed.h>
......@@ -684,7 +684,7 @@ int open_file(const char* name)
if (*cur_file && cur_file == file_stack_end)
die("Source directives are nesting too deep");
if (!(*(cur_file+1) = my_fopen(buff, O_RDONLY, MYF(MY_WME))))
if (!(*(cur_file+1) = my_fopen(buff, O_RDONLY | O_BINARY, MYF(MY_WME))))
die(NullS);
cur_file++;
*++lineno=1;
......@@ -1925,7 +1925,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
argument= buff;
}
fn_format(buff, argument, "", "", 4);
if (!(*++cur_file = my_fopen(buff, O_RDONLY, MYF(MY_WME))))
if (!(*++cur_file = my_fopen(buff, O_RDONLY | O_BINARY, MYF(MY_WME))))
die("Could not open %s: errno = %d", argument, errno);
break;
}
......
## 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=vi.c emacs.c common.c
AHDR=vi.h emacs.h common.h
INCLUDES = -I$(top_srcdir)/include -I$(srcdir)/../.. -I..
noinst_LIBRARIES = liblibedit.a
liblibedit_a_SOURCES = chared.c el.c fgetln.c history.c map.c \
prompt.c readline.c search.c \
strlcpy.c tokenizer.c vi.c common.c \
emacs.c hist.c key.c parse.c read.c \
refresh.c sig.c term.c tty.c help.c \
fcns.c
pkginclude_HEADERS = readline/readline.h
noinst_HEADERS = chared.h el.h histedit.h key.h \
parse.h refresh.h sig.h sys.h \
tokenizer.h compat.h fgetln.h \
hist.h map.h prompt.h search.h \
strlcpy.h term.h tty.h
DEFS = -DUNDEF_THREADS_HACK -DHAVE_CONFIG_H -DNO_KILL_INTR
vi.h: vi.c makelist
sh ./makelist -h ./vi.c > $@.tmp && \
mv $@.tmp $@
emacs.h: emacs.c makelist
sh ./makelist -h ./emacs.c > $@.tmp && \
mv $@.tmp $@
common.h: common.c makelist
sh ./makelist -h ./common.c > $@.tmp && \
mv $@.tmp $@
help.c: ${ASRC} makelist
sh ./makelist -bc ${ASRC} > $@.tmp && \
mv $@.tmp $@
help.h: ${ASRC} makelist
sh ./makelist -bh ${ASRC} > $@.tmp && \
mv $@.tmp $@
fcns.h: ${AHDR} makelist
sh ./makelist -fh ${AHDR} > $@.tmp && \
mv $@.tmp $@
fcns.c: ${AHDR} fcns.h makelist
sh ./makelist -fc ${AHDR} > $@.tmp && \
mv $@.tmp $@
#%.o: vi.h emacs.h common.h help.h fcns.h
#objects := $(patsubst %.c,%.o,$(wildcard *.c))
#$(objects): vi.h emacs.h
chared.o: vi.h emacs.h common.h help.h fcns.h
el.o: vi.h emacs.h common.h help.h fcns.h
fgetln.o: vi.h emacs.h common.h help.h fcns.h
history.o: vi.h emacs.h common.h help.h fcns.h
map.o: vi.h emacs.h common.h help.h fcns.h
prompt.o: vi.h emacs.h common.h help.h fcns.h
readline.o: vi.h emacs.h common.h help.h fcns.h
search.o: vi.h emacs.h common.h help.h fcns.h
strlcpy.o: vi.h emacs.h common.h help.h fcns.h
tokenizer.o: vi.h emacs.h common.h help.h fcns.h
vi.o: vi.h emacs.h common.h help.h fcns.h
common.o: vi.h emacs.h common.h help.h fcns.h
emacs.o: vi.h emacs.h common.h help.h fcns.h
hist.o: vi.h emacs.h common.h help.h fcns.h
key.o: vi.h emacs.h common.h help.h fcns.h
parse.o: vi.h emacs.h common.h help.h fcns.h
read.o: vi.h emacs.h common.h help.h fcns.h
refresh.o: vi.h emacs.h common.h help.h fcns.h
sig.o: vi.h emacs.h common.h help.h fcns.h
term.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
fcns.o: vi.h emacs.h common.h help.h fcns.h
# Don't update the files from bitkeeper
%::SCCS/s.%
/* $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);
}
This diff is collapsed.
/* $NetBSD: chared.h,v 1.6 2001/01/10 07:45:41 jdolecek 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.
*
* @(#)chared.h 8.1 (Berkeley) 6/4/93
*/
/*
* el.chared.h: Character editor interface
*/
#ifndef _h_el_chared
#define _h_el_chared
#include <ctype.h>
#include <string.h>
#include "histedit.h"
#define EL_MAXMACRO 10
/*
* This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works
* like real vi: i.e. the transition from command<->insert modes moves
* the cursor.
*
* On the other hand we really don't want to move the cursor, because
* all the editing commands don't include the character under the cursor.
* Probably the best fix is to make all the editing commands aware of
* this fact.
*/
#define VI_MOVE
typedef struct c_macro_t {
int level;
char **macro;
char *nline;
} c_macro_t;
/*
* Undo information for both vi and emacs
*/
typedef struct c_undo_t {
int action;
size_t isize;
size_t dsize;
char *ptr;
char *buf;
} c_undo_t;
/*
* Current action information for vi
*/
typedef struct c_vcmd_t {
int action;
char *pos;
char *ins;
} c_vcmd_t;
/*
* Kill buffer for emacs
*/
typedef struct c_kill_t {
char *buf;
char *last;
char *mark;
} c_kill_t;
/*
* Note that we use both data structures because the user can bind
* commands from both editors!
*/
typedef struct el_chared_t {
c_undo_t c_undo;
c_kill_t c_kill;
c_vcmd_t c_vcmd;
c_macro_t c_macro;
} el_chared_t;
#define STReof "^D\b\b"
#define STRQQ "\"\""
#define isglob(a) (strchr("*[]?", (a)) != NULL)
#define isword(a) (isprint(a))
#define NOP 0x00
#define DELETE 0x01
#define INSERT 0x02
#define CHANGE 0x04
#define CHAR_FWD 0
#define CHAR_BACK 1
#define MODE_INSERT 0
#define MODE_REPLACE 1
#define MODE_REPLACE_1 2
#include "common.h"
#include "vi.h"
#include "emacs.h"
#include "search.h"
#include "fcns.h"
protected int cv__isword(int);
protected void cv_delfini(EditLine *);
protected char *cv__endword(char *, char *, int);
protected int ce__isword(int);
protected void cv_undo(EditLine *, int, size_t, char *);
protected char *cv_next_word(EditLine*, char *, char *, int, int (*)(int));
protected char *cv_prev_word(EditLine*, char *, char *, int, int (*)(int));
protected char *c__next_word(char *, char *, int, int (*)(int));
protected char *c__prev_word(char *, char *, int, int (*)(int));
protected void c_insert(EditLine *, int);
protected void c_delbefore(EditLine *, int);
protected void c_delafter(EditLine *, int);
protected int c_gets(EditLine *, char *);
protected int c_hpos(EditLine *);
protected int ch_init(EditLine *);
protected void ch_reset(EditLine *);
protected int ch_enlargebufs __P((EditLine *, size_t));
protected void ch_end(EditLine *);
#endif /* _h_el_chared */
This diff is collapsed.
#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
#endif
This diff is collapsed.
This diff is collapsed.
/* $NetBSD: el.c,v 1.21 2001/01/05 22:45:30 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.
*/
#include "compat.h"
/*
* el.c: EditLine interface functions
*/
#include "sys.h"
#include <sys/types.h>
#include <sys/param.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "el.h"
/* el_init():
* Initialize editline and set default parameters.
*/
public EditLine *
el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
{
EditLine *el = (EditLine *) el_malloc(sizeof(EditLine));
#ifdef DEBUG
char *tty;
#endif
if (el == NULL)
return (NULL);
memset(el, 0, sizeof(EditLine));
el->el_infd = fileno(fin);
el->el_outfile = fout;
el->el_errfile = ferr;
el->el_prog = strdup(prog);
/*
* Initialize all the modules. Order is important!!!
*/
el->el_flags = 0;
(void) term_init(el);
(void) key_init(el);
(void) map_init(el);
if (tty_init(el) == -1)
el->el_flags |= NO_TTY;
(void) ch_init(el);
(void) search_init(el);
(void) hist_init(el);
(void) prompt_init(el);
(void) sig_init(el);
return (el);
}
/* el_end():
* Clean up.
*/
public void
el_end(EditLine *el)
{
if (el == NULL)
return;
el_reset(el);
term_end(el);
key_end(el);
map_end(el);
tty_end(el);
ch_end(el);
search_end(el);
hist_end(el);
prompt_end(el);
sig_end(el);
el_free((ptr_t) el->el_prog);
el_free((ptr_t) el);
}
/* el_reset():
* Reset the tty and the parser
*/
public void
el_reset(EditLine *el)
{
tty_cookedmode(el);
ch_reset(el); /* XXX: Do we want that? */
}
/* el_set():
* set the editline parameters
*/
public int
el_set(EditLine *el, int op, ...)
{
va_list va;
int rv;
va_start(va, op);
if (el == NULL)
return (-1);
switch (op) {
case EL_PROMPT:
case EL_RPROMPT:
rv = prompt_set(el, va_arg(va, el_pfunc_t), op);
break;
case EL_TERMINAL:
rv = term_set(el, va_arg(va, char *));
break;
case EL_EDITOR:
rv = map_set_editor(el, va_arg(va, char *));
break;
case EL_SIGNAL:
if (va_arg(va, int))
el->el_flags |= HANDLE_SIGNALS;
else
el->el_flags &= ~HANDLE_SIGNALS;
rv = 0;
break;
case EL_BIND:
case EL_TELLTC:
case EL_SETTC:
case EL_ECHOTC:
case EL_SETTY:
{
const char *argv[20];
int i;
for (i = 1; i < 20; i++)
if ((argv[i] = va_arg(va, char *)) == NULL)
break;
switch (op) {
case EL_BIND:
argv[0] = "bind";
rv = map_bind(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;
default:
rv = -1;
EL_ABORT((el->el_errfile, "Bad op %d\n", op));
break;
}
break;
}
case EL_ADDFN:
{
char *name = va_arg(va, char *);
char *help = va_arg(va, char *);
el_func_t func = va_arg(va, el_func_t);
rv = map_addfunc(el, name, help, func);
break;
}
case EL_HIST:
{
hist_fun_t func = va_arg(va, hist_fun_t);
ptr_t ptr = va_arg(va, char *);
rv = hist_set(el, func, ptr);
break;
}
case EL_EDITMODE:
if (va_arg(va, int))
el->el_flags &= ~EDIT_DISABLED;
else
el->el_flags |= EDIT_DISABLED;
rv = 0;
break;
default:
rv = -1;
}
va_end(va);
return (rv);
}
/* el_get():
* retrieve the editline parameters
*/
public int
el_get(EditLine *el, int op, void *ret)
{
int rv;
if (el == NULL || ret == NULL)
return (-1);
switch (op) {
case EL_PROMPT:
case EL_RPROMPT:
rv = prompt_get(el, (el_pfunc_t *) & ret, op);
break;
case EL_EDITOR:
rv = map_get_editor(el, (const char **) &ret);
break;
case EL_SIGNAL:
*((int *) ret) = (el->el_flags & HANDLE_SIGNALS);
rv = 0;
break;
case EL_EDITMODE:
*((int *) ret) = (!(el->el_flags & EDIT_DISABLED));
rv = 0;
break;
#if 0 /* XXX */
case EL_TERMINAL:
rv = term_get(el, (const char *) &ret);
break;
case EL_BIND:
case EL_TELLTC:
case EL_SETTC:
case EL_ECHOTC:
case EL_SETTY:
{
char *argv[20];
int i;
for (i = 1; i < 20; i++)
if ((argv[i] = va_arg(va, char *)) == NULL)
break;
switch (op) {
case EL_BIND:
argv[0] = "bind";
rv = map_bind(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;
default:
rv = -1;
EL_ABORT((el->errfile, "Bad op %d\n", op));
break;
}
break;
}
case EL_ADDFN:
{
char *name = va_arg(va, char *);
char *help = va_arg(va, char *);
el_func_t func = va_arg(va, el_func_t);
rv = map_addfunc(el, name, help, func);
break;
}
case EL_HIST:
{
hist_fun_t func = va_arg(va, hist_fun_t);
ptr_t ptr = va_arg(va, char *);
rv = hist_set(el, func, ptr);
}
break;
#endif /* XXX */
default:
rv = -1;
}
return (rv);
}
/* el_line():
* Return editing info
*/
public const LineInfo *
el_line(EditLine *el)
{
return (const LineInfo *) (void *) &el->el_line;
}
static const char elpath[] = "/.editrc";
/* el_source():
* Source a file
*/
public int
el_source(EditLine *el, const char *fname)
{
FILE *fp;
size_t len;
char *ptr, path[MAXPATHLEN];
fp = NULL;
if (fname == NULL) {
if (issetugid())
return (-1);
if ((ptr = getenv("HOME")) == NULL)
return (-1);
if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path))
return (-1);
if (strlcat(path, elpath, sizeof(path)) >= sizeof(path))
return (-1);
fname = path;
}
if (fp == NULL)
fp = fopen(fname, "r");
if (fp == NULL)
return (-1);
while ((ptr = fgetln(fp, &len)) != NULL) {
if (len > 0 && ptr[len - 1] == '\n')
--len;
ptr[len] = '\0';
if (parse_line(el, ptr) == -1) {
(void) fclose(fp);
return (-1);
}
}
(void) fclose(fp);
return (0);
}
/* el_resize():
* Called from program when terminal is resized
*/
public void
el_resize(EditLine *el)
{
int lins, cols;
sigset_t oset, nset;
(void) sigemptyset(&nset);
(void) sigaddset(&nset, SIGWINCH);
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
/* get the correct window size */
if (term_get_size(el, &lins, &cols))
term_change_size(el, lins, cols);
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
}
/* el_beep():
* Called from the program to beep
*/
public void
el_beep(EditLine *el)
{
term_beep(el);
}
/* el_editmode()
* Set the state of EDIT_DISABLED from the `edit' command.
*/
protected int
/*ARGSUSED*/
el_editmode(EditLine *el, int argc, const char **argv)
{
const char *how;
if (argv == NULL || argc != 2 || argv[1] == NULL)
return (-1);
how = argv[1];
if (strcmp(how, "on") == 0)
el->el_flags &= ~EDIT_DISABLED;
else if (strcmp(how, "off") == 0)
el->el_flags |= EDIT_DISABLED;
else {
(void) fprintf(el->el_errfile, "edit: Bad value `%s'.\n", how);
return (-1);
}
return (0);
}
/* $NetBSD: el.h,v 1.8 2001/01/06 14:44:50 jdolecek 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.
*
* @(#)el.h 8.1 (Berkeley) 6/4/93
*/
/*
* el.h: Internal structures.
*/
#ifndef _h_el
#define _h_el
/*
* Local defaults
*/
#define KSHVI
#define VIDEFAULT
#define ANCHOR
#include <stdio.h>
#include <sys/types.h>
#define EL_BUFSIZ 1024 /* Maximum line size */
#define HANDLE_SIGNALS 1<<0
#define NO_TTY 1<<1
#define EDIT_DISABLED 1<<2
typedef int bool_t; /* True or not */
typedef unsigned char el_action_t; /* Index to command array */
typedef struct coord_t { /* Position on the screen */
int h;
int v;
} coord_t;
typedef struct el_line_t {
char *buffer; /* Input line */
char *cursor; /* Cursor position */
char *lastchar; /* Last character */
const char *limit; /* Max position */
} el_line_t;
/*
* Editor state
*/
typedef struct el_state_t {
int inputmode; /* What mode are we in? */
int doingarg; /* Are we getting an argument? */
int argument; /* Numeric argument */
int metanext; /* Is the next char a meta char */
el_action_t lastcmd; /* Previous command */
} el_state_t;
/*
* Until we come up with something better...
*/
#define el_malloc(a) malloc(a)
#define el_realloc(a,b) realloc(a, b)
#define el_free(a) free(a)
#include "tty.h"
#include "prompt.h"
#include "key.h"
#include "term.h"
#include "refresh.h"
#include "chared.h"
#include "common.h"
#include "search.h"
#include "hist.h"
#include "map.h"
#include "parse.h"
#include "sig.h"
#include "help.h"
struct editline {
char *el_prog; /* the program name */
FILE *el_outfile; /* Stdio stuff */
FILE *el_errfile; /* Stdio stuff */
int el_infd; /* Input file descriptor */
int el_flags; /* Various flags. */
coord_t el_cursor; /* Cursor location */
char **el_display; /* Real screen image = what is there */
char **el_vdisplay; /* Virtual screen image = what we see */
el_line_t el_line; /* The current line information */
el_state_t el_state; /* Current editor state */
el_term_t el_term; /* Terminal dependent stuff */
el_tty_t el_tty; /* Tty dependent stuff */
el_refresh_t el_refresh; /* Refresh stuff */
el_prompt_t el_prompt; /* Prompt stuff */
el_prompt_t el_rprompt; /* Prompt stuff */
el_chared_t el_chared; /* Characted editor stuff */
el_map_t el_map; /* Key mapping stuff */
el_key_t el_key; /* Key binding stuff */
el_history_t el_history; /* History stuff */
el_search_t el_search; /* Search stuff */
el_signal_t el_signal; /* Signal handling stuff */
};
protected int el_editmode(EditLine *, int, const char **);
#ifdef DEBUG
#define EL_ABORT(a) (void) (fprintf(el->el_errfile, "%s, %d: ", \
__FILE__, __LINE__), fprintf a, abort())
#else
#define EL_ABORT(a) abort()
#endif
#endif /* _h_el */
This diff is collapsed.
This diff is collapsed.
#include <stdio.h>
char *fgetln(FILE *stream, size_t *len);
This diff is collapsed.
/* $NetBSD: hist.h,v 1.6 2001/01/10 07:45:41 jdolecek 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.
*
* @(#)hist.h 8.1 (Berkeley) 6/4/93
*/
/*
* el.hist.c: History functions
*/
#ifndef _h_el_hist
#define _h_el_hist
#include "histedit.h"
typedef int (*hist_fun_t)(ptr_t, HistEvent *, int, ...);
typedef struct el_history_t {
char *buf; /* The history buffer */
size_t sz; /* Size of history buffer */
char *last; /* The last character */
int eventno; /* Event we are looking for */
ptr_t ref; /* Argument for history fcns */
hist_fun_t fun; /* Event access */
HistEvent ev; /* Event cookie */
} el_history_t;
#define HIST_FUN(el, fn, arg) \
((((*(el)->el_history.fun) ((el)->el_history.ref, &(el)->el_history.ev, \
fn, arg)) == -1) ? NULL : (el)->el_history.ev.str)
#define HIST_NEXT(el) HIST_FUN(el, H_NEXT, NULL)
#define HIST_FIRST(el) HIST_FUN(el, H_FIRST, NULL)
#define HIST_LAST(el) HIST_FUN(el, H_LAST, NULL)
#define HIST_PREV(el) HIST_FUN(el, H_PREV, NULL)
#define HIST_EVENT(el, num) HIST_FUN(el, H_EVENT, num)
#define HIST_LOAD(el, fname) HIST_FUN(el, H_LOAD fname)
#define HIST_SAVE(el, fname) HIST_FUN(el, H_SAVE fname)
protected int hist_init(EditLine *);
protected void hist_end(EditLine *);
protected el_action_t hist_get(EditLine *);
protected int hist_set(EditLine *, hist_fun_t, ptr_t);
protected int hist_list(EditLine *, int, const char **);
protected int hist_enlargebuf(EditLine *, size_t, size_t);
#endif /* _h_el_hist */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
size_t strlcpy(char *dst, const char *src, size_t size);
size_t strlcat(char *dst, const char *src, size_t size);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,7 +2,8 @@
# Makefile for the GNU readline library.
# Copyright (C) 1994,1996,1997 Free Software Foundation, Inc.
INCLUDES = -I$(top_srcdir)/include
# Last -I$(top_srcdir) needed for RedHat!
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)
noinst_LIBRARIES = libreadline.a
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment